From 466acbeed92a4f162132219052089bf4c494b90b Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期六, 05 七月 2025 13:29:42 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/impl/NyShuttleThread.java | 75 ++--
src/main/java/com/zy/core/utils/DeviceMsgUtils.java | 12
src/main/java/com/zy/core/cache/MessageQueue.java | 12
src/main/webapp/views/admin/deviceConfig/deviceConfig_detail.html | 90 +++++
src/main/java/com/zy/common/CodeBuilder.java | 2
src/main/java/com/zy/core/ServerBootstrap.java | 96 +++--
src/main/resources/mapper/DeviceConfigMapper.xml | 17 +
src/main/java/com/zy/asrs/mapper/DeviceConfigMapper.java | 12
src/main/java/com/zy/asrs/controller/DeviceConfigController.java | 126 +++++++
src/main/webapp/views/admin/deviceConfig/deviceConfig.html | 116 ++++++
src/main/java/com/zy/asrs/service/impl/DeviceConfigServiceImpl.java | 12
src/main/java/com/zy/asrs/service/DeviceConfigService.java | 8
src/main/java/com/zy/core/enums/RedisKeyType.java | 3
src/main/java/com/zy/asrs/entity/DeviceConfig.java | 94 +++++
src/main/webapp/static/js/deviceConfig/deviceConfig.js | 255 +++++++++++++++
src/main/resources/application.yml | 86 ++--
16 files changed, 895 insertions(+), 121 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/DeviceConfigController.java b/src/main/java/com/zy/asrs/controller/DeviceConfigController.java
new file mode 100644
index 0000000..5fc9ea0
--- /dev/null
+++ b/src/main/java/com/zy/asrs/controller/DeviceConfigController.java
@@ -0,0 +1,126 @@
+package com.zy.asrs.controller;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.baomidou.mybatisplus.mapper.Wrapper;
+import com.baomidou.mybatisplus.plugins.Page;
+import com.core.common.DateUtils;
+import com.zy.asrs.entity.DeviceConfig;
+import com.zy.asrs.service.DeviceConfigService;
+import com.core.annotations.ManagerAuth;
+import com.core.common.BaseRes;
+import com.core.common.Cools;
+import com.core.common.R;
+import com.zy.common.web.BaseController;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.*;
+
+@RestController
+public class DeviceConfigController extends BaseController {
+
+ @Autowired
+ private DeviceConfigService deviceConfigService;
+
+ @RequestMapping(value = "/deviceConfig/{id}/auth")
+ @ManagerAuth
+ public R get(@PathVariable("id") String id) {
+ return R.ok(deviceConfigService.selectById(String.valueOf(id)));
+ }
+
+ @RequestMapping(value = "/deviceConfig/list/auth")
+ @ManagerAuth
+ public R list(@RequestParam(defaultValue = "1")Integer curr,
+ @RequestParam(defaultValue = "10")Integer limit,
+ @RequestParam(required = false)String orderByField,
+ @RequestParam(required = false)String orderByType,
+ @RequestParam(required = false)String condition,
+ @RequestParam Map<String, Object> param){
+ EntityWrapper<DeviceConfig> wrapper = new EntityWrapper<>();
+ excludeTrash(param);
+ convert(param, wrapper);
+ allLike(DeviceConfig.class, param.keySet(), wrapper, condition);
+ if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
+ return R.ok(deviceConfigService.selectPage(new Page<>(curr, limit), wrapper));
+ }
+
+ private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){
+ for (Map.Entry<String, Object> entry : map.entrySet()){
+ String val = String.valueOf(entry.getValue());
+ if (val.contains(RANGE_TIME_LINK)){
+ String[] dates = val.split(RANGE_TIME_LINK);
+ wrapper.ge(entry.getKey(), DateUtils.convert(dates[0]));
+ wrapper.le(entry.getKey(), DateUtils.convert(dates[1]));
+ } else {
+ wrapper.like(entry.getKey(), val);
+ }
+ }
+ }
+
+ @RequestMapping(value = "/deviceConfig/add/auth")
+ @ManagerAuth
+ public R add(DeviceConfig deviceConfig) {
+ deviceConfig.setCreateTime(new Date());
+ deviceConfigService.insert(deviceConfig);
+ return R.ok();
+ }
+
+ @RequestMapping(value = "/deviceConfig/update/auth")
+ @ManagerAuth
+ public R update(DeviceConfig deviceConfig){
+ if (Cools.isEmpty(deviceConfig) || null==deviceConfig.getId()){
+ return R.error();
+ }
+ deviceConfigService.updateById(deviceConfig);
+ return R.ok();
+ }
+
+ @RequestMapping(value = "/deviceConfig/delete/auth")
+ @ManagerAuth
+ public R delete(@RequestParam(value="ids[]") Integer[] ids){
+ for (Integer id : ids){
+ deviceConfigService.deleteById(id);
+ }
+ return R.ok();
+ }
+
+ @RequestMapping(value = "/deviceConfig/export/auth")
+ @ManagerAuth
+ public R export(@RequestBody JSONObject param){
+ EntityWrapper<DeviceConfig> wrapper = new EntityWrapper<>();
+ List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class);
+ Map<String, Object> map = excludeTrash(param.getJSONObject("deviceConfig"));
+ convert(map, wrapper);
+ List<DeviceConfig> list = deviceConfigService.selectList(wrapper);
+ return R.ok(exportSupport(list, fields));
+ }
+
+ @RequestMapping(value = "/deviceConfigQuery/auth")
+ @ManagerAuth
+ public R query(String condition) {
+ EntityWrapper<DeviceConfig> wrapper = new EntityWrapper<>();
+ wrapper.like("id", condition);
+ Page<DeviceConfig> page = deviceConfigService.selectPage(new Page<>(0, 10), wrapper);
+ List<Map<String, Object>> result = new ArrayList<>();
+ for (DeviceConfig deviceConfig : page.getRecords()){
+ Map<String, Object> map = new HashMap<>();
+ map.put("id", deviceConfig.getId());
+ map.put("value", deviceConfig.getId());
+ result.add(map);
+ }
+ return R.ok(result);
+ }
+
+ @RequestMapping(value = "/deviceConfig/check/column/auth")
+ @ManagerAuth
+ public R query(@RequestBody JSONObject param) {
+ Wrapper<DeviceConfig> wrapper = new EntityWrapper<DeviceConfig>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val"));
+ if (null != deviceConfigService.selectOne(wrapper)){
+ return R.parse(BaseRes.REPEAT).add(getComment(DeviceConfig.class, String.valueOf(param.get("key"))));
+ }
+ return R.ok();
+ }
+
+}
diff --git a/src/main/java/com/zy/asrs/entity/DeviceConfig.java b/src/main/java/com/zy/asrs/entity/DeviceConfig.java
new file mode 100644
index 0000000..a2e53c4
--- /dev/null
+++ b/src/main/java/com/zy/asrs/entity/DeviceConfig.java
@@ -0,0 +1,94 @@
+package com.zy.asrs.entity;
+
+import com.core.common.Cools;import com.baomidou.mybatisplus.annotations.TableId;
+import com.baomidou.mybatisplus.enums.IdType;
+import com.baomidou.mybatisplus.annotations.TableField;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import com.baomidou.mybatisplus.annotations.TableName;
+import java.io.Serializable;
+
+@Data
+@TableName("rcs_device_config")
+public class DeviceConfig implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value= "")
+ @TableId(value = "id", type = IdType.AUTO)
+ private Integer id;
+
+ /**
+ * 璁惧ip
+ */
+ @ApiModelProperty(value= "璁惧ip")
+ private String ip;
+
+ /**
+ * 璁惧绔彛
+ */
+ @ApiModelProperty(value= "璁惧绔彛")
+ private Integer port;
+
+ /**
+ * 瀹炵幇绫�
+ */
+ @ApiModelProperty(value= "瀹炵幇绫�")
+ @TableField("thread_impl")
+ private String threadImpl;
+
+ /**
+ * 鍒涘缓鏃堕棿
+ */
+ @ApiModelProperty(value= "鍒涘缓鏃堕棿")
+ @TableField("create_time")
+ @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+ private Date createTime;
+
+ /**
+ * 璁惧绫诲瀷
+ */
+ @ApiModelProperty(value= "璁惧绫诲瀷")
+ @TableField("device_type")
+ private String deviceType;
+
+ /**
+ * 璁惧缂栧彿
+ */
+ @ApiModelProperty(value= "璁惧缂栧彿")
+ @TableField("device_no")
+ private Integer deviceNo;
+
+ public DeviceConfig() {}
+
+ public DeviceConfig(String ip,Integer port,String threadImpl,Date createTime,String deviceType,Integer deviceNo) {
+ this.ip = ip;
+ this.port = port;
+ this.threadImpl = threadImpl;
+ this.createTime = createTime;
+ this.deviceType = deviceType;
+ this.deviceNo = deviceNo;
+ }
+
+// DeviceConfig deviceConfig = new DeviceConfig(
+// null, // 璁惧ip
+// null, // 璁惧绔彛
+// null, // 瀹炵幇绫�
+// null, // 鍒涘缓鏃堕棿
+// null, // 璁惧绫诲瀷
+// null // 璁惧缂栧彿
+// );
+
+ public String getCreateTime$(){
+ if (Cools.isEmpty(this.createTime)){
+ return "";
+ }
+ return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.createTime);
+ }
+
+
+}
diff --git a/src/main/java/com/zy/asrs/mapper/DeviceConfigMapper.java b/src/main/java/com/zy/asrs/mapper/DeviceConfigMapper.java
new file mode 100644
index 0000000..33b0117
--- /dev/null
+++ b/src/main/java/com/zy/asrs/mapper/DeviceConfigMapper.java
@@ -0,0 +1,12 @@
+package com.zy.asrs.mapper;
+
+import com.zy.asrs.entity.DeviceConfig;
+import com.baomidou.mybatisplus.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+@Mapper
+@Repository
+public interface DeviceConfigMapper extends BaseMapper<DeviceConfig> {
+
+}
diff --git a/src/main/java/com/zy/asrs/service/DeviceConfigService.java b/src/main/java/com/zy/asrs/service/DeviceConfigService.java
new file mode 100644
index 0000000..f859f33
--- /dev/null
+++ b/src/main/java/com/zy/asrs/service/DeviceConfigService.java
@@ -0,0 +1,8 @@
+package com.zy.asrs.service;
+
+import com.zy.asrs.entity.DeviceConfig;
+import com.baomidou.mybatisplus.service.IService;
+
+public interface DeviceConfigService extends IService<DeviceConfig> {
+
+}
diff --git a/src/main/java/com/zy/asrs/service/impl/DeviceConfigServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/DeviceConfigServiceImpl.java
new file mode 100644
index 0000000..15c7ba0
--- /dev/null
+++ b/src/main/java/com/zy/asrs/service/impl/DeviceConfigServiceImpl.java
@@ -0,0 +1,12 @@
+package com.zy.asrs.service.impl;
+
+import com.zy.asrs.mapper.DeviceConfigMapper;
+import com.zy.asrs.entity.DeviceConfig;
+import com.zy.asrs.service.DeviceConfigService;
+import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+@Service("deviceConfigService")
+public class DeviceConfigServiceImpl extends ServiceImpl<DeviceConfigMapper, DeviceConfig> implements DeviceConfigService {
+
+}
diff --git a/src/main/java/com/zy/common/CodeBuilder.java b/src/main/java/com/zy/common/CodeBuilder.java
index d8243bc..9f9e5d9 100644
--- a/src/main/java/com/zy/common/CodeBuilder.java
+++ b/src/main/java/com/zy/common/CodeBuilder.java
@@ -15,7 +15,7 @@
generator.url="localhost:3306/shuttle_rcs";
generator.username="root";
generator.password="root";
- generator.table="asr_bas_shuttle_charge";
+ generator.table="rcs_device_config";
// sqlserver
// generator.sqlOsType = SqlOsType.SQL_SERVER;
// generator.url="127.0.0.1:1433;databasename=tzskasrs";
diff --git a/src/main/java/com/zy/core/ServerBootstrap.java b/src/main/java/com/zy/core/ServerBootstrap.java
index c5c91c0..f90de2d 100644
--- a/src/main/java/com/zy/core/ServerBootstrap.java
+++ b/src/main/java/com/zy/core/ServerBootstrap.java
@@ -1,6 +1,10 @@
package com.zy.core;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.exception.CoolException;
+import com.zy.asrs.entity.DeviceConfig;
+import com.zy.asrs.service.DeviceConfigService;
import com.zy.common.utils.RedisUtil;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.SlaveConnection;
@@ -12,6 +16,7 @@
import com.zy.core.thread.impl.LfdZyForkLiftSlaveThread;
import com.zy.core.thread.impl.NyShuttleThread;
import com.zy.core.thread.impl.ZyForkLiftThread;
+import com.zy.core.utils.DeviceMsgUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
@@ -19,6 +24,8 @@
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
+import java.util.ArrayList;
+import java.util.List;
/**
* Created by vincent on 2020/8/4
@@ -28,12 +35,13 @@
public class ServerBootstrap {
@Autowired
- private SlaveProperties slaveProperties;
- @Autowired
private MainProcess mainProcess;
@Autowired
private RedisUtil redisUtil;
-
+ @Autowired
+ private DeviceConfigService deviceConfigService;
+ @Autowired
+ private DeviceMsgUtils deviceMsgUtils;
@PostConstruct
@Async
@@ -51,59 +59,75 @@
private void initMq(){
// 鍒濆鍖栬揣鍙夋彁鍗囨満mq
- for (Slave forkLift : slaveProperties.getForkLift()) {
+ List<DeviceConfig> forkLiftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.ForkLift)));
+ for (DeviceConfig forkLift : forkLiftList) {
MessageQueue.init(SlaveType.ForkLift, forkLift);
}
// 鍒濆鍖栧洓鍚戠┛姊溅mq
- for (Slave shuttle : slaveProperties.getShuttle()) {
+ List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Shuttle)));
+ for (DeviceConfig shuttle : shuttleList) {
MessageQueue.init(SlaveType.Shuttle, shuttle);
}
}
private void initThread(){
- // 鍒濆鍖栬揣鍙夋彁鍗囨満
- for (ForkLiftSlave forkLiftSlave : slaveProperties.getForkLift()) {
- News.info("鍒濆鍖栬揣鍙夋彁鍗囨満........................................................");
- ThreadHandler thread = null;
- if (forkLiftSlave.getThreadImpl().equals("ZyForkLiftThread")) {
- thread = new ZyForkLiftThread(forkLiftSlave, redisUtil);
- } else if (forkLiftSlave.getThreadImpl().equals("LfdZyForkLiftSlaveThread")) {
- thread = new LfdZyForkLiftSlaveThread(forkLiftSlave, redisUtil, forkLiftSlave.getMasterId());
- } else {
- throw new CoolException("鏈煡鐨勭嚎绋嬪疄鐜�");
- }
+ List<DeviceConfig> allDevices = new ArrayList<>();
- new Thread(thread).start();
- SlaveConnection.put(SlaveType.ForkLift, forkLiftSlave.getId(), thread);
- }
+// // 鍒濆鍖栬揣鍙夋彁鍗囨満
+// List<DeviceConfig> forkLiftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+// .eq("device_type", String.valueOf(SlaveType.ForkLift)));
+// allDevices.addAll(forkLiftList);
+// for (DeviceConfig deviceConfig : forkLiftList) {
+// News.info("鍒濆鍖栬揣鍙夋彁鍗囨満........................................................");
+// ThreadHandler thread = null;
+// if (deviceConfig.getThreadImpl().equals("ZyForkLiftThread")) {
+// thread = new ZyForkLiftThread(forkLiftSlave, redisUtil);
+// } else if (deviceConfig.getThreadImpl().equals("LfdZyForkLiftSlaveThread")) {
+// thread = new LfdZyForkLiftSlaveThread(forkLiftSlave, redisUtil, forkLiftSlave.getMasterId());
+// } else {
+// throw new CoolException("鏈煡鐨勭嚎绋嬪疄鐜�");
+// }
+//
+// new Thread(thread).start();
+// SlaveConnection.put(SlaveType.ForkLift, deviceConfig.getDeviceNo(), thread);
+// }
- // 鍒濆鍖栬揣鍙夋彁鍗囨満
- for (ForkLiftSlave forkLiftSlave : slaveProperties.getForkLiftMaster()) {
- News.info("鍒濆鍖栬揣鍙夋彁鍗囨満Master........................................................");
- ThreadHandler thread = null;
- if (forkLiftSlave.getThreadImpl().equals("LfdZyForkLiftMasterThread")) {
- thread = new LfdZyForkLiftMasterThread(forkLiftSlave, redisUtil);
- } else {
- throw new CoolException("鏈煡鐨勭嚎绋嬪疄鐜�");
- }
-
- new Thread(thread).start();
- SlaveConnection.put(SlaveType.ForkLiftMaster, forkLiftSlave.getId(), thread);
- }
+// // 鍒濆鍖栬揣鍙夋彁鍗囨満
+// for (ForkLiftSlave forkLiftSlave : slaveProperties.getForkLiftMaster()) {
+// News.info("鍒濆鍖栬揣鍙夋彁鍗囨満Master........................................................");
+// ThreadHandler thread = null;
+// if (forkLiftSlave.getThreadImpl().equals("LfdZyForkLiftMasterThread")) {
+// thread = new LfdZyForkLiftMasterThread(forkLiftSlave, redisUtil);
+// } else {
+// throw new CoolException("鏈煡鐨勭嚎绋嬪疄鐜�");
+// }
+//
+// new Thread(thread).start();
+// SlaveConnection.put(SlaveType.ForkLiftMaster, forkLiftSlave.getId(), thread);
+// }
// 鍒濆鍖栧洓鍚戠┛姊溅
- for (ShuttleSlave shuttleSlave : slaveProperties.getShuttle()) {
+ List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+ .eq("device_type", String.valueOf(SlaveType.Shuttle)));
+ allDevices.addAll(shuttleList);
+ for (DeviceConfig deviceConfig : shuttleList) {
News.info("鍒濆鍖栧洓鍚戠┛姊溅......................................................");
ThreadHandler thread = null;
- if (shuttleSlave.getThreadImpl().equals("NyShuttleThread")) {
- thread = new NyShuttleThread(shuttleSlave, redisUtil);
+ if (deviceConfig.getThreadImpl().equals("NyShuttleThread")) {
+ thread = new NyShuttleThread(deviceConfig, redisUtil);
} else {
throw new CoolException("鏈煡鐨勭嚎绋嬪疄鐜�");
}
new Thread(thread).start();
- SlaveConnection.put(SlaveType.Shuttle, shuttleSlave.getId(), thread);
+ SlaveConnection.put(SlaveType.Shuttle, deviceConfig.getDeviceNo(), thread);
}
+
+
+ //璁惧鍒濆鍖栧畬姣�
+ deviceMsgUtils.sendDeviceConfig(JSON.toJSONString(allDevices));
}
diff --git a/src/main/java/com/zy/core/cache/MessageQueue.java b/src/main/java/com/zy/core/cache/MessageQueue.java
index a7a9efd..4037c4a 100644
--- a/src/main/java/com/zy/core/cache/MessageQueue.java
+++ b/src/main/java/com/zy/core/cache/MessageQueue.java
@@ -1,6 +1,6 @@
package com.zy.core.cache;
-import com.zy.core.Slave;
+import com.zy.asrs.entity.DeviceConfig;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.Task;
@@ -26,19 +26,19 @@
/**
* mq 浜ゆ崲鏈哄垵濮嬪寲
*/
- public static void init(SlaveType type, Slave slave) {
+ public static void init(SlaveType type, DeviceConfig deviceConfig) {
switch (type) {
case Shuttle:
- SHUTTLE_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>());
+ SHUTTLE_EXCHANGE.put(deviceConfig.getDeviceNo(), new ConcurrentLinkedQueue<>());
break;
case ForkLift:
- FORK_LIFT_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>());
+ FORK_LIFT_EXCHANGE.put(deviceConfig.getDeviceNo(), new ConcurrentLinkedQueue<>());
break;
case ForkLiftMaster:
- FORK_LIFT_MASTER_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>());
+ FORK_LIFT_MASTER_EXCHANGE.put(deviceConfig.getDeviceNo(), new ConcurrentLinkedQueue<>());
break;
case Lift:
- LIFT_EXCHANGE.put(slave.getId(), new ConcurrentLinkedQueue<>());
+ LIFT_EXCHANGE.put(deviceConfig.getDeviceNo(), new ConcurrentLinkedQueue<>());
break;
default:
break;
diff --git a/src/main/java/com/zy/core/enums/RedisKeyType.java b/src/main/java/com/zy/core/enums/RedisKeyType.java
index 4cd2014..0ac7ce7 100644
--- a/src/main/java/com/zy/core/enums/RedisKeyType.java
+++ b/src/main/java/com/zy/core/enums/RedisKeyType.java
@@ -21,6 +21,9 @@
//璁惧鎸囦护娑堟伅KEY
DEVICE_SHUTTLE_COMMAND_MSG_KEY("deviceShuttleCommandMsgKey_"),
DEVICE_FORK_LIFT_COMMAND_MSG_KEY("deviceForkLiftCommandMsgKey_"),
+
+ //璁惧閰嶇疆鏂囦欢
+ DEVICE_CONFIG("deviceConfig"),
;
public String key;
diff --git a/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java b/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java
index 9d139e2..c375106 100644
--- a/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java
+++ b/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java
@@ -8,6 +8,7 @@
import com.core.exception.CoolException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.zy.asrs.entity.BasShuttle;
+import com.zy.asrs.entity.DeviceConfig;
import com.zy.asrs.entity.DeviceDataLog;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.service.BasShuttleService;
@@ -29,7 +30,6 @@
import com.zy.core.enums.*;
import com.zy.core.model.CommandResponse;
import com.zy.core.model.DeviceMsgModel;
-import com.zy.core.model.ShuttleSlave;
import com.zy.core.model.command.NyShuttleHttpCommand;
import com.zy.core.model.command.ShuttleCommand;
import com.zy.core.model.command.ShuttleRedisCommand;
@@ -49,7 +49,7 @@
@SuppressWarnings("all")
public class NyShuttleThread implements ShuttleThread {
- private ShuttleSlave slave;
+ private DeviceConfig deviceConfig;
private RedisUtil redisUtil;
private ShuttleProtocol shuttleProtocol;
@@ -61,14 +61,14 @@
//鍘熷璁惧鏁版嵁
private Object originDeviceData;
- public NyShuttleThread(ShuttleSlave slave, RedisUtil redisUtil) {
- this.slave = slave;
+ public NyShuttleThread(DeviceConfig deviceConfig, RedisUtil redisUtil) {
+ this.deviceConfig = deviceConfig;
this.redisUtil = redisUtil;
}
@Override
public void run() {
- News.info("{}鍙峰洓鍚戣溅绾跨▼鍚姩", slave.getId());
+ News.info("{}鍙峰洓鍚戣溅绾跨▼鍚姩", deviceConfig.getDeviceNo());
//璁惧璇诲彇
Thread readThread = new Thread(() -> {
@@ -100,7 +100,7 @@
continue;
}
- Object object = redisUtil.get(RedisKeyType.SHUTTLE_FLAG.key + slave.getId());
+ Object object = redisUtil.get(RedisKeyType.SHUTTLE_FLAG.key + deviceConfig.getDeviceNo());
if (object == null) {
continue;
}
@@ -108,14 +108,14 @@
Integer taskNo = Integer.valueOf(String.valueOf(object));
if (taskNo != 0) {
//瀛樺湪浠诲姟闇�瑕佹墽琛�
- boolean result = shuttleAction.executeWork(slave.getId(), taskNo);
+ boolean result = shuttleAction.executeWork(deviceConfig.getDeviceNo(), taskNo);
}
// //灏忚溅绌洪棽涓旀湁璺戝簱绋嬪簭
-// shuttleAction.moveLoc(slave.getId());
+// shuttleAction.moveLoc(deviceConfig.getDeviceNo());
//婕旂ず妯″紡
- shuttleAction.demo(slave.getId());
+ shuttleAction.demo(deviceConfig.getDeviceNo());
Thread.sleep(200);
} catch (Exception e) {
@@ -155,24 +155,29 @@
deviceDataLog.setOriginData(JSON.toJSONString(this.originDeviceData));
deviceDataLog.setWcsData(JSON.toJSONString(shuttleProtocol));
deviceDataLog.setType(String.valueOf(SlaveType.Shuttle));
- deviceDataLog.setDeviceNo(slave.getId());
+ deviceDataLog.setDeviceNo(deviceConfig.getDeviceNo());
deviceDataLog.setCreateTime(new Date());
deviceDataLogService.insert(deviceDataLog);
//鏇存柊閲囬泦鏃堕棿
shuttleProtocol.setDeviceDataLog(System.currentTimeMillis());
- OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛",DateUtils.convert(new Date()), slave.getId()));
+ OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛",DateUtils.convert(new Date()), deviceConfig.getDeviceNo()));
}
}
}
private void listenMessageFromRedis() {
try {
- DeviceMsgUtils deviceMsgUtils = SpringUtils.getBean(DeviceMsgUtils.class);
+ DeviceMsgUtils deviceMsgUtils = null;
+ try {
+ deviceMsgUtils = SpringUtils.getBean(DeviceMsgUtils.class);
+ }catch (Exception e){
+
+ }
if (deviceMsgUtils == null) {
return;
}
- DeviceMsgModel deviceMsg = deviceMsgUtils.getDeviceMsg(SlaveType.Shuttle, slave.getId());
+ DeviceMsgModel deviceMsg = deviceMsgUtils.getDeviceMsg(SlaveType.Shuttle, deviceConfig.getDeviceNo());
if(deviceMsg == null){
return;
}
@@ -241,7 +246,7 @@
try {
if (null == shuttleProtocol) {
shuttleProtocol = new ShuttleProtocol();
- shuttleProtocol.setShuttleNo(slave.getId());
+ shuttleProtocol.setShuttleNo(deviceConfig.getDeviceNo());
shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE);
InnerSuhttleExtend extend = new InnerSuhttleExtend();
@@ -259,9 +264,9 @@
return;
}
- NyShuttleHttpCommand readStatusCommand = getReadStatusCommand(slave.getId());
+ NyShuttleHttpCommand readStatusCommand = getReadStatusCommand(deviceConfig.getDeviceNo());
//鎸囦护瓒呰繃浜旀潯锛屼笉鍐嶄笅鍙戜换鍔$姸鎬佽姹�
- TreeSet<String> deviceCommandMsgListKey = deviceMsgUtils.getDeviceCommandMsgListKey(SlaveType.Shuttle, slave.getId());
+ TreeSet<String> deviceCommandMsgListKey = deviceMsgUtils.getDeviceCommandMsgListKey(SlaveType.Shuttle, deviceConfig.getDeviceNo());
if (deviceCommandMsgListKey.size() < 5) {
requestCommandAsync(readStatusCommand);//璇锋眰鐘舵��
}
@@ -339,10 +344,10 @@
this.originDeviceData = data.getString("originDeviceData");
- OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛",DateUtils.convert(new Date()), slave.getId()));
+ OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛",DateUtils.convert(new Date()), deviceConfig.getDeviceNo()));
} catch (Exception e) {
e.printStackTrace();
- OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆戝洓鍚戠┛姊溅Socket鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
+ OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆戝洓鍚戠┛姊溅Socket鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort()));
}
}
@@ -379,8 +384,8 @@
NyShuttleHttpCommand httpCommand = JSON.parseObject(initCommand.getBody(), NyShuttleHttpCommand.class);
JSONObject requestResult = requestCommand(httpCommand);
- log.info(MessageFormat.format("銆恵0}銆戝洓鍚戣溅澶嶄綅涓婃姤 ===>> [code:{1}] [ip:{2}] [port:{3}]", slave.getId(), code, slave.getIp(), slave.getPort()));
- OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆戝洓鍚戣溅澶嶄綅涓婃姤 ===>> [code:{1}] [ip:{2}] [port:{3}]", slave.getId(), code, slave.getIp(), slave.getPort()));
+ log.info(MessageFormat.format("銆恵0}銆戝洓鍚戣溅澶嶄綅涓婃姤 ===>> [code:{1}] [ip:{2}] [port:{3}]", deviceConfig.getDeviceNo(), code, deviceConfig.getIp(), deviceConfig.getPort()));
+ OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆戝洓鍚戣溅澶嶄綅涓婃姤 ===>> [code:{1}] [ip:{2}] [port:{3}]", deviceConfig.getDeviceNo(), code, deviceConfig.getIp(), deviceConfig.getPort()));
break;
}
}
@@ -638,7 +643,7 @@
if (shuttleService == null) {
return false;
}
- BasShuttle basShuttle = shuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", slave.getId()));
+ BasShuttle basShuttle = shuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", deviceConfig.getDeviceNo()));
if (basShuttle == null) {
return false;
}
@@ -871,7 +876,7 @@
@Override
public ShuttleCommand getMoveCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes) {
NavigateMapData navigateMapData = SpringUtils.getBean(NavigateMapData.class);
- NyShuttleHttpCommand httpStandard = getHttpStandard(slave.getId(), taskNo);
+ NyShuttleHttpCommand httpStandard = getHttpStandard(deviceConfig.getDeviceNo(), taskNo);
NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
ArrayList<HashMap<String, Object>> path = new ArrayList<>();
@@ -916,7 +921,7 @@
}
ShuttleCommand command = new ShuttleCommand();
- command.setShuttleNo(slave.getId());
+ command.setShuttleNo(deviceConfig.getDeviceNo());
command.setBody(JSON.toJSONString(httpStandard));
command.setMode(ShuttleCommandModeType.MOVE.id);
command.setTargetLocNo(locMast.getLocNo());
@@ -926,7 +931,7 @@
@Override
public ShuttleCommand getLiftCommand(Integer taskNo, Boolean lift) {
- NyShuttleHttpCommand httpStandard = getHttpStandard(slave.getId(), taskNo);
+ NyShuttleHttpCommand httpStandard = getHttpStandard(deviceConfig.getDeviceNo(), taskNo);
NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
Integer taskId = getTaskId();//TaskID闇�瑕侀殢鏈�
@@ -938,7 +943,7 @@
httpStandard.setRequest(request);
ShuttleCommand command = new ShuttleCommand();
- command.setShuttleNo(slave.getId());
+ command.setShuttleNo(deviceConfig.getDeviceNo());
command.setBody(JSON.toJSONString(httpStandard));
command.setMode(lift ? ShuttleCommandModeType.PALLET_LIFT.id : ShuttleCommandModeType.PALLET_DOWN.id);
command.setTaskNo(taskId);
@@ -947,7 +952,7 @@
@Override
public ShuttleCommand getChargeCommand(Integer taskNo, Boolean charge) {
- NyShuttleHttpCommand httpStandard = getHttpStandard(slave.getId(), taskNo);
+ NyShuttleHttpCommand httpStandard = getHttpStandard(deviceConfig.getDeviceNo(), taskNo);
NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
Integer taskId = getTaskId();//TaskID闇�瑕侀殢鏈�
@@ -959,7 +964,7 @@
httpStandard.setRequest(request);
ShuttleCommand command = new ShuttleCommand();
- command.setShuttleNo(slave.getId());
+ command.setShuttleNo(deviceConfig.getDeviceNo());
command.setBody(JSON.toJSONString(httpStandard));
command.setMode(charge ? ShuttleCommandModeType.CHARGE_OPEN.id : ShuttleCommandModeType.CHARGE_CLOSE.id);
command.setTaskNo(taskId);
@@ -968,7 +973,7 @@
@Override
public ShuttleCommand getUpdateLocationCommand(Integer taskNo, String locNo) {
- NyShuttleHttpCommand httpStandard = getHttpStandard(slave.getId(), taskNo);
+ NyShuttleHttpCommand httpStandard = getHttpStandard(deviceConfig.getDeviceNo(), taskNo);
NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
HashMap<String, Object> body = new HashMap<>();
@@ -979,7 +984,7 @@
httpStandard.setRequest(request);
ShuttleCommand command = new ShuttleCommand();
- command.setShuttleNo(slave.getId());
+ command.setShuttleNo(deviceConfig.getDeviceNo());
command.setBody(JSON.toJSONString(httpStandard));
command.setMode(ShuttleCommandModeType.UPDATE_LOCATION.id);
command.setTaskNo(taskNo);
@@ -990,7 +995,7 @@
public ShuttleCommand getInitCommand(Integer taskNo, Integer code) {
LocMastService locMastService = SpringUtils.getBean(LocMastService.class);
NavigateMapData navigateMapData = SpringUtils.getBean(NavigateMapData.class);
- NyShuttleHttpCommand httpStandard = getHttpStandard(slave.getId(), taskNo);
+ NyShuttleHttpCommand httpStandard = getHttpStandard(deviceConfig.getDeviceNo(), taskNo);
NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest();
//code -> {Integer@13781} 1101101
@@ -1031,7 +1036,7 @@
httpStandard.setRequest(request);
ShuttleCommand command = new ShuttleCommand();
- command.setShuttleNo(slave.getId());
+ command.setShuttleNo(deviceConfig.getDeviceNo());
command.setBody(JSON.toJSONString(httpStandard));
command.setMode(ShuttleCommandModeType.RESET.id);
command.setTaskNo(taskNo);
@@ -1105,10 +1110,10 @@
data.remove("nodes");
DeviceCommandMsgModel commandMsgModel = new DeviceCommandMsgModel();
- commandMsgModel.setDeviceId(slave.getId());
+ commandMsgModel.setDeviceId(deviceConfig.getDeviceNo());
commandMsgModel.setDeviceType(String.valueOf(SlaveType.Shuttle));
commandMsgModel.setCommand(data);
- String key = deviceMsgUtils.sendDeviceCommand(SlaveType.Shuttle, slave.getId(), commandMsgModel);
+ String key = deviceMsgUtils.sendDeviceCommand(SlaveType.Shuttle, deviceConfig.getDeviceNo(), commandMsgModel);
String requestType = null;
String taskId = null;
@@ -1155,10 +1160,10 @@
data.remove("nodes");
DeviceCommandMsgModel commandMsgModel = new DeviceCommandMsgModel();
- commandMsgModel.setDeviceId(slave.getId());
+ commandMsgModel.setDeviceId(deviceConfig.getDeviceNo());
commandMsgModel.setDeviceType(String.valueOf(SlaveType.Shuttle));
commandMsgModel.setCommand(data);
- String key = deviceMsgUtils.sendDeviceCommand(SlaveType.Shuttle, slave.getId(), commandMsgModel);
+ String key = deviceMsgUtils.sendDeviceCommand(SlaveType.Shuttle, deviceConfig.getDeviceNo(), commandMsgModel);
String requestType = null;
String taskId = null;
diff --git a/src/main/java/com/zy/core/utils/DeviceMsgUtils.java b/src/main/java/com/zy/core/utils/DeviceMsgUtils.java
index 5a1fb51..b30d9c2 100644
--- a/src/main/java/com/zy/core/utils/DeviceMsgUtils.java
+++ b/src/main/java/com/zy/core/utils/DeviceMsgUtils.java
@@ -24,6 +24,14 @@
@Autowired
private RedisUtil redisUtil;
+ public String getDeviceConfig() {
+ Object obj = redisUtil.get(RedisKeyType.DEVICE_CONFIG.key);
+ if(null == obj){
+ return null;
+ }
+ return obj.toString();
+ }
+
public DeviceCommandMsgModel getDeviceCommandMsg(SlaveType deviceType, Integer deviceId) {
TreeSet<String> listKey = getDeviceCommandMsgListKey(deviceType, deviceId);
if (listKey.isEmpty()) {
@@ -80,6 +88,10 @@
return key;
}
+ public void sendDeviceConfig(String allDevices) {
+ redisUtil.set(RedisKeyType.DEVICE_CONFIG.key, allDevices);
+ }
+
public TreeSet<String> getDeviceMsgListKey(SlaveType deviceType, Integer deviceId) {
String listKey = parseDeviceMsgKey(deviceType, deviceId);
Set<String> keys = redisUtil.searchKeys(listKey);
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index fdea1d2..4b685fd 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -56,46 +56,46 @@
rack: 0
slot: 0
threadImpl: NyShuttleThread
- # 鍥涘悜绌挎杞�2
- shuttle[1]:
- id: 2
- ip: 10.10.20.12
- port: 8888
- rack: 0
- slot: 0
- threadImpl: NyShuttleThread
- # 璐у弶鎻愬崌鏈轰富绾跨▼
- forkLiftMaster[0]:
- id: 99
- ip: 10.10.20.20
- port: 102
- rack: 0
- slot: 0
- threadImpl: LfdZyForkLiftMasterThread
- # 璐у弶鎻愬崌鏈�1
- forkLift[0]:
- id: 1
- ip: 10.10.20.20
- port: 102
- rack: 0
- slot: 0
- threadImpl: LfdZyForkLiftSlaveThread
- masterId: 99
- staRow: 9
- staBay: 6
- sta[0]:
- staNo: 1001
- lev: 1
- liftNo: ${wcs-slave.forkLift[0].id}
- sta[1]:
- staNo: 1002
- lev: 2
- liftNo: ${wcs-slave.forkLift[0].id}
- sta[2]:
- staNo: 1003
- lev: 3
- liftNo: ${wcs-slave.forkLift[0].id}
- sta[3]:
- staNo: 1004
- lev: 4
- liftNo: ${wcs-slave.forkLift[0].id}
\ No newline at end of file
+# # 鍥涘悜绌挎杞�2
+# shuttle[1]:
+# id: 2
+# ip: 10.10.20.12
+# port: 8888
+# rack: 0
+# slot: 0
+# threadImpl: NyShuttleThread
+# # 璐у弶鎻愬崌鏈轰富绾跨▼
+# forkLiftMaster[0]:
+# id: 99
+# ip: 10.10.20.20
+# port: 102
+# rack: 0
+# slot: 0
+# threadImpl: LfdZyForkLiftMasterThread
+# # 璐у弶鎻愬崌鏈�1
+# forkLift[0]:
+# id: 1
+# ip: 10.10.20.20
+# port: 102
+# rack: 0
+# slot: 0
+# threadImpl: LfdZyForkLiftSlaveThread
+# masterId: 99
+# staRow: 9
+# staBay: 6
+# sta[0]:
+# staNo: 1001
+# lev: 1
+# liftNo: ${wcs-slave.forkLift[0].id}
+# sta[1]:
+# staNo: 1002
+# lev: 2
+# liftNo: ${wcs-slave.forkLift[0].id}
+# sta[2]:
+# staNo: 1003
+# lev: 3
+# liftNo: ${wcs-slave.forkLift[0].id}
+# sta[3]:
+# staNo: 1004
+# lev: 4
+# liftNo: ${wcs-slave.forkLift[0].id}
\ No newline at end of file
diff --git a/src/main/resources/mapper/DeviceConfigMapper.xml b/src/main/resources/mapper/DeviceConfigMapper.xml
new file mode 100644
index 0000000..c1602d5
--- /dev/null
+++ b/src/main/resources/mapper/DeviceConfigMapper.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zy.asrs.mapper.DeviceConfigMapper">
+
+ <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 -->
+ <resultMap id="BaseResultMap" type="com.zy.asrs.entity.DeviceConfig">
+ <id column="id" property="id" />
+ <result column="ip" property="ip" />
+ <result column="port" property="port" />
+ <result column="thread_impl" property="threadImpl" />
+ <result column="create_time" property="createTime" />
+ <result column="device_type" property="deviceType" />
+ <result column="device_no" property="deviceNo" />
+
+ </resultMap>
+
+</mapper>
diff --git a/src/main/webapp/static/js/deviceConfig/deviceConfig.js b/src/main/webapp/static/js/deviceConfig/deviceConfig.js
new file mode 100644
index 0000000..adf938a
--- /dev/null
+++ b/src/main/webapp/static/js/deviceConfig/deviceConfig.js
@@ -0,0 +1,255 @@
+var pageCurr;
+layui.config({
+ base: baseUrl + "/static/layui/lay/modules/"
+}).use(['table','laydate', 'form', 'admin'], function(){
+ var table = layui.table;
+ var $ = layui.jquery;
+ var layer = layui.layer;
+ var layDate = layui.laydate;
+ var form = layui.form;
+ var admin = layui.admin;
+
+ // 鏁版嵁娓叉煋
+ tableIns = table.render({
+ elem: '#deviceConfig',
+ headers: {token: localStorage.getItem('token')},
+ url: baseUrl+'/deviceConfig/list/auth',
+ page: true,
+ limit: 15,
+ limits: [15, 30, 50, 100, 200, 500],
+ toolbar: '#toolbar',
+ cellMinWidth: 50,
+ height: 'full-120',
+ cols: [[
+ {type: 'checkbox'}
+ ,{field: 'deviceNo', align: 'center',title: '璁惧缂栧彿'}
+ ,{field: 'deviceType', align: 'center',title: '璁惧绫诲瀷'}
+ ,{field: 'ip', align: 'center',title: '璁惧ip'}
+ ,{field: 'port', align: 'center',title: '璁惧绔彛'}
+ ,{field: 'threadImpl', align: 'center',title: '瀹炵幇绫�'}
+ ,{field: 'createTime$', align: 'center',title: '鍒涘缓鏃堕棿'}
+
+ ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:120}
+ ]],
+ request: {
+ pageName: 'curr',
+ pageSize: 'limit'
+ },
+ parseData: function (res) {
+ return {
+ 'code': res.code,
+ 'msg': res.msg,
+ 'count': res.data.total,
+ 'data': res.data.records
+ }
+ },
+ response: {
+ statusCode: 200
+ },
+ done: function(res, curr, count) {
+ if (res.code === 403) {
+ top.location.href = baseUrl+"/";
+ }
+ pageCurr=curr;
+ limit();
+ }
+ });
+
+ // 鐩戝惉鎺掑簭浜嬩欢
+ table.on('sort(deviceConfig)', function (obj) {
+ var searchData = {};
+ $.each($('#search-box [name]').serializeArray(), function() {
+ searchData[this.name] = this.value;
+ });
+ searchData['orderByField'] = obj.field;
+ searchData['orderByType'] = obj.type;
+ tableIns.reload({
+ where: searchData,
+ page: {curr: 1}
+ });
+ });
+
+ // 鐩戝惉澶村伐鍏锋爮浜嬩欢
+ table.on('toolbar(deviceConfig)', function (obj) {
+ var checkStatus = table.checkStatus(obj.config.id).data;
+ switch(obj.event) {
+ case 'addData':
+ showEditModel();
+ break;
+ case 'deleteData':
+ if (checkStatus.length === 0) {
+ layer.msg('璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁', {icon: 2});
+ return;
+ }
+ del(checkStatus.map(function (d) {
+ return d.id;
+ }));
+ break;
+ case 'exportData':
+ admin.confirm('纭畾瀵煎嚭Excel鍚�', {shadeClose: true}, function(){
+ var titles=[];
+ var fields=[];
+ obj.config.cols[0].map(function (col) {
+ if (col.type === 'normal' && col.hide === false && col.toolbar == null) {
+ titles.push(col.title);
+ fields.push(col.field);
+ }
+ });
+ var exportData = {};
+ $.each($('#search-box [name]').serializeArray(), function() {
+ exportData[this.name] = this.value;
+ });
+ var param = {
+ 'deviceConfig': exportData,
+ 'fields': fields
+ };
+ $.ajax({
+ url: baseUrl+"/deviceConfig/export/auth",
+ headers: {'token': localStorage.getItem('token')},
+ data: JSON.stringify(param),
+ dataType:'json',
+ contentType:'application/json;charset=UTF-8',
+ method: 'POST',
+ success: function (res) {
+ layer.closeAll();
+ if (res.code === 200) {
+ table.exportFile(titles,res.data,'xls');
+ } else if (res.code === 403) {
+ top.location.href = baseUrl+"/";
+ } else {
+ layer.msg(res.msg, {icon: 2})
+ }
+ }
+ });
+ });
+ break;
+ }
+ });
+
+ // 鐩戝惉琛屽伐鍏蜂簨浠�
+ table.on('tool(deviceConfig)', function(obj){
+ var data = obj.data;
+ switch (obj.event) {
+ case 'edit':
+ showEditModel(data);
+ break;
+ case "del":
+ del([data.id]);
+ break;
+ }
+ });
+
+ /* 寮圭獥 - 鏂板銆佷慨鏀� */
+ function showEditModel(mData) {
+ admin.open({
+ type: 1,
+ area: '600px',
+ title: (mData ? '淇敼' : '娣诲姞') + '璁㈠崟鐘舵��',
+ content: $('#editDialog').html(),
+ success: function (layero, dIndex) {
+ layDateRender(mData);
+ form.val('detail', mData);
+ form.on('submit(editSubmit)', function (data) {
+ var loadIndex = layer.load(2);
+ $.ajax({
+ url: baseUrl+"/deviceConfig/"+(mData?'update':'add')+"/auth",
+ headers: {'token': localStorage.getItem('token')},
+ data: data.field,
+ method: 'POST',
+ success: function (res) {
+ layer.close(loadIndex);
+ if (res.code === 200){
+ layer.close(dIndex);
+ layer.msg(res.msg, {icon: 1});
+ tableReload();
+ } else if (res.code === 403){
+ top.location.href = baseUrl+"/";
+ }else {
+ layer.msg(res.msg, {icon: 2});
+ }
+ }
+ })
+ return false;
+ });
+ $(layero).children('.layui-layer-content').css('overflow', 'visible');
+ layui.form.render('select');
+ }
+ });
+ }
+
+ /* 鍒犻櫎 */
+ function del(ids) {
+ layer.confirm('纭畾瑕佸垹闄ら�変腑鏁版嵁鍚楋紵', {
+ skin: 'layui-layer-admin',
+ shade: .1
+ }, function (i) {
+ layer.close(i);
+ var loadIndex = layer.load(2);
+ $.ajax({
+ url: baseUrl+"/deviceConfig/delete/auth",
+ headers: {'token': localStorage.getItem('token')},
+ data: {ids: ids},
+ method: 'POST',
+ success: function (res) {
+ layer.close(loadIndex);
+ if (res.code === 200){
+ layer.msg(res.msg, {icon: 1});
+ tableReload();
+ } else if (res.code === 403){
+ top.location.href = baseUrl+"/";
+ } else {
+ layer.msg(res.msg, {icon: 2});
+ }
+ }
+ })
+ });
+ }
+
+ // 鎼滅储
+ form.on('submit(search)', function (data) {
+ pageCurr = 1;
+ tableReload(false);
+ });
+
+ // 閲嶇疆
+ form.on('submit(reset)', function (data) {
+ pageCurr = 1;
+ clearFormVal($('#search-box'));
+ tableReload(false);
+ });
+
+ // 鏃堕棿閫夋嫨鍣�
+ function layDateRender(data) {
+ setTimeout(function () {
+ layDate.render({
+ elem: '.layui-laydate-range'
+ ,type: 'datetime'
+ ,range: true
+ });
+ layDate.render({
+ elem: '#createTime\\$',
+ type: 'datetime',
+ value: data!==undefined?data['createTime\\$']:null
+ });
+
+ }, 300);
+ }
+ layDateRender();
+
+});
+
+// 鍏抽棴鍔ㄤ綔
+$(document).on('click','#data-detail-close', function () {
+ parent.layer.closeAll();
+});
+
+function tableReload(child) {
+ var searchData = {};
+ $.each($('#search-box [name]').serializeArray(), function() {
+ searchData[this.name] = this.value;
+ });
+ tableIns.reload({
+ where: searchData,
+ page: {curr: pageCurr}
+ });
+}
diff --git a/src/main/webapp/views/admin/deviceConfig/deviceConfig.html b/src/main/webapp/views/admin/deviceConfig/deviceConfig.html
new file mode 100644
index 0000000..321e9c1
--- /dev/null
+++ b/src/main/webapp/views/admin/deviceConfig/deviceConfig.html
@@ -0,0 +1,116 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title></title>
+ <meta name="renderer" content="webkit">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
+ <link rel="stylesheet" href="../../../static/layui/css/layui.css" media="all">
+ <link rel="stylesheet" href="../../../static/css/admin.css?v=318" media="all">
+ <link rel="stylesheet" href="../../../static/css/cool.css" media="all">
+</head>
+<body>
+
+<div class="layui-fluid">
+ <div class="layui-card">
+ <div class="layui-card-body">
+ <div class="layui-form toolbar" id="search-box">
+ <div class="layui-form-item">
+ <div class="layui-inline">
+ <div class="layui-input-inline">
+ <input class="layui-input" type="text" name="id" placeholder="缂栧彿" autocomplete="off">
+ </div>
+ </div>
+ <div class="layui-inline" style="width: 300px">
+ <div class="layui-input-inline">
+ <input class="layui-input layui-laydate-range" name="create_time" type="text" placeholder="璧峰鏃堕棿 - 缁堟鏃堕棿" autocomplete="off" style="width: 300px">
+ </div>
+ </div>
+ <div class="layui-inline">
+ <div class="layui-input-inline">
+ <input class="layui-input" type="text" name="condition" placeholder="璇疯緭鍏�" autocomplete="off">
+ </div>
+ </div>
+ <div class="layui-inline"> 
+ <button class="layui-btn icon-btn" lay-filter="search" lay-submit>
+ <i class="layui-icon"></i>鎼滅储
+ </button>
+ <button class="layui-btn icon-btn" lay-filter="reset" lay-submit>
+ <i class="layui-icon"></i>閲嶇疆
+ </button>
+ </div>
+ </div>
+ </div>
+ <table class="layui-hide" id="deviceConfig" lay-filter="deviceConfig"></table>
+ </div>
+ </div>
+</div>
+
+<script type="text/html" id="toolbar">
+ <div class="layui-btn-container">
+ <button class="layui-btn layui-btn-sm" id="btn-add" lay-event="addData">鏂板</button>
+ <button class="layui-btn layui-btn-sm layui-btn-danger" id="btn-delete" lay-event="deleteData">鍒犻櫎</button>
+ <button class="layui-btn layui-btn-primary layui-btn-sm" id="btn-export" lay-event="exportData" style="float: right">瀵煎嚭</button>
+ </div>
+</script>
+
+<script type="text/html" id="operate">
+ <a class="layui-btn layui-btn-primary layui-btn-xs btn-edit" lay-event="edit">淇敼</a>
+ <a class="layui-btn layui-btn-danger layui-btn-xs btn-edit" lay-event="del">鍒犻櫎</a>
+</script>
+
+<script type="text/javascript" src="../../../static/js/jquery/jquery-3.3.1.min.js"></script>
+<script type="text/javascript" src="../../../static/layui/layui.js" charset="utf-8"></script>
+<script type="text/javascript" src="../../../static/js/common.js" charset="utf-8"></script>
+<script type="text/javascript" src="../../../static/js/cool.js" charset="utf-8"></script>
+<script type="text/javascript" src="../../../static/js/deviceConfig/deviceConfig.js" charset="utf-8"></script>
+</body>
+<!-- 琛ㄥ崟寮圭獥 -->
+<script type="text/html" id="editDialog">
+ <form id="detail" lay-filter="detail" class="layui-form admin-form model-form">
+ <input name="id" type="hidden">
+ <div class="layui-row">
+ <div class="layui-col-md12">
+ <div class="layui-form-item">
+ <label class="layui-form-label">璁惧缂栧彿: </label>
+ <div class="layui-input-block">
+ <input class="layui-input" name="deviceNo" placeholder="璇疯緭鍏ヨ澶囩紪鍙�">
+ </div>
+ </div>
+ <div class="layui-form-item">
+ <label class="layui-form-label">璁惧绫诲瀷: </label>
+ <div class="layui-input-block">
+ <input class="layui-input" name="deviceType" placeholder="璇疯緭鍏ヨ澶囩被鍨�">
+ </div>
+ </div>
+ <div class="layui-form-item">
+ <label class="layui-form-label">璁惧ip: </label>
+ <div class="layui-input-block">
+ <input class="layui-input" name="ip" placeholder="璇疯緭鍏ヨ澶噄p">
+ </div>
+ </div>
+ <div class="layui-form-item">
+ <label class="layui-form-label">璁惧绔彛: </label>
+ <div class="layui-input-block">
+ <input class="layui-input" name="port" placeholder="璇疯緭鍏ヨ澶囩鍙�">
+ </div>
+ </div>
+ <div class="layui-form-item">
+ <label class="layui-form-label">瀹炵幇绫�: </label>
+ <div class="layui-input-block">
+ <input class="layui-input" name="threadImpl" placeholder="璇疯緭鍏ュ疄鐜扮被">
+ </div>
+ </div>
+
+ </div>
+ </div>
+ <hr class="layui-bg-gray">
+ <div class="layui-form-item text-right">
+ <button class="layui-btn" lay-filter="editSubmit" lay-submit="">淇濆瓨</button>
+ <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">鍙栨秷</button>
+ </div>
+ </form>
+</script>
+</html>
+
diff --git a/src/main/webapp/views/admin/deviceConfig/deviceConfig_detail.html b/src/main/webapp/views/admin/deviceConfig/deviceConfig_detail.html
new file mode 100644
index 0000000..17705ac
--- /dev/null
+++ b/src/main/webapp/views/admin/deviceConfig/deviceConfig_detail.html
@@ -0,0 +1,90 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="utf-8">
+ <title></title>
+ <meta name="renderer" content="webkit">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
+ <link rel="stylesheet" href="../../../static/layui/css/layui.css" media="all">
+ <link rel="stylesheet" href="../../../static/css/cool.css" media="all">
+ <link rel="stylesheet" href="../../../static/css/common.css" media="all">
+</head>
+<body>
+
+<!-- 璇︽儏 -->
+<div id="data-detail" class="layer_self_wrap">
+ <form id="detail" class="layui-form">
+ <!--
+ <div class="layui-inline" style="display: none">
+ <label class="layui-form-label"><span class="not-null">*</span>缂栥��銆�鍙凤細</label>
+ <div class="layui-input-inline">
+ <input id="id" class="layui-input" type="text" placeholder="缂栧彿">
+ </div>
+ </div>
+ -->
+ <div class="layui-inline" style="width:31%;">
+ <label class="layui-form-label"><span class="not-null">*</span>锛�</label>
+ <div class="layui-input-inline">
+ <input id="id" class="layui-input" type="text" onkeyup="check(this.id, 'deviceConfig')" lay-verify="number" >
+ </div>
+ </div>
+ <div class="layui-inline" style="width:31%;">
+ <label class="layui-form-label">璁惧ip锛�</label>
+ <div class="layui-input-inline">
+ <input id="ip" class="layui-input" type="text">
+ </div>
+ </div>
+ <div class="layui-inline" style="width:31%;">
+ <label class="layui-form-label">璁惧绔彛锛�</label>
+ <div class="layui-input-inline">
+ <input id="port" class="layui-input" type="text" lay-verify="number" >
+ </div>
+ </div>
+ <div class="layui-inline" style="width:31%;">
+ <label class="layui-form-label">瀹� 鐜� 绫伙細</label>
+ <div class="layui-input-inline">
+ <input id="threadImpl" class="layui-input" type="text">
+ </div>
+ </div>
+ <div class="layui-inline" style="width:31%;">
+ <label class="layui-form-label">鍒涘缓鏃堕棿锛�</label>
+ <div class="layui-input-inline">
+ <input id="createTime$" class="layui-input" type="text" autocomplete="off">
+ </div>
+ </div>
+ <div class="layui-inline" style="width:31%;">
+ <label class="layui-form-label">璁惧绫诲瀷锛�</label>
+ <div class="layui-input-inline">
+ <input id="deviceType" class="layui-input" type="text">
+ </div>
+ </div>
+ <div class="layui-inline" style="width:31%;">
+ <label class="layui-form-label">璁惧缂栧彿锛�</label>
+ <div class="layui-input-inline">
+ <input id="deviceNo" class="layui-input" type="text" lay-verify="number" >
+ </div>
+ </div>
+
+
+ <hr class="layui-bg-gray">
+
+ <div id="data-detail-btn" class="layui-btn-container layui-form-item">
+ <div id="data-detail-submit-save" type="button" class="layui-btn layui-btn-normal" lay-submit lay-filter="save">淇濆瓨</div>
+ <div id="data-detail-submit-edit" type="button" class="layui-btn layui-btn-normal" lay-submit lay-filter="edit">淇敼</div>
+ <div id="data-detail-close" type="button" class="layui-btn" lay-submit lay-filter="close">鍏抽棴</div>
+ </div>
+
+ <div id="prompt">
+ 娓╅Θ鎻愮ず锛氳浠旂粏濉啓鐩稿叧淇℃伅锛�<span class="extrude"><span class="not-null">*</span> 涓哄繀濉�夐」銆�</span>
+ </div>
+ </form>
+</div>
+</body>
+<script type="text/javascript" src="../../../static/js/jquery/jquery-3.3.1.min.js"></script>
+<script type="text/javascript" src="../../../static/layui/layui.js" charset="utf-8"></script>
+<script type="text/javascript" src="../../../static/js/common.js" charset="utf-8"></script>
+<script type="text/javascript" src="../../../static/js/cool.js" charset="utf-8"></script>
+<script type="text/javascript" src="../../../static/js/deviceConfig/deviceConfig.js" charset="utf-8"></script>
+</html>
+
--
Gitblit v1.9.1