|
@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.ruoyi.ams.task.domain.WcsTask;
|
|
|
import com.ruoyi.ams.task.service.IWcsTaskService;
|
|
|
+import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.redis.RedisCache;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import com.ruoyi.hard.modbus.tcp.ChargingMachineClient;
|
|
@@ -49,7 +50,7 @@ public class ChargerButtService {
|
|
|
private ChargingMachineClient chargingMachineClient;
|
|
|
|
|
|
// 创建一个线程池
|
|
|
- private ExecutorService executorService = new ThreadPoolExecutor(2, 10
|
|
|
+ private ExecutorService executorService = new ThreadPoolExecutor(2, 20
|
|
|
, 60L, TimeUnit.SECONDS
|
|
|
, new SynchronousQueue<Runnable>());
|
|
|
|
|
@@ -98,15 +99,15 @@ public class ChargerButtService {
|
|
|
/***
|
|
|
* B
|
|
|
*/
|
|
|
- B(1, 1),
|
|
|
+ B(2, 1),
|
|
|
/***
|
|
|
* 空
|
|
|
*/
|
|
|
- C(1, 1),
|
|
|
+ C(3, 1),
|
|
|
/***
|
|
|
* 无
|
|
|
*/
|
|
|
- D(1, 1);
|
|
|
+ D(4, 1);
|
|
|
private Integer chargerNo;
|
|
|
private Integer slaveId;
|
|
|
|
|
@@ -180,33 +181,32 @@ public class ChargerButtService {
|
|
|
// 如果已经开始充电 不可重复请求
|
|
|
if (agvInfoMap.get(KEY_AGV_STS) != null
|
|
|
&& agvInfoMap.get(KEY_AGV_STS).toString().equals(AGV_CHARGING_STS.START.toString())) {
|
|
|
+ log.error("充电机已经开始充电,不可重复请求!车号:{},充电机号:{}", agvNo, chargingSite);
|
|
|
return;
|
|
|
}
|
|
|
// 如果是TS创建的充电任务 是没有对应的WcsTask任务 需要创建 并且设置到Redis
|
|
|
+ // 不管是不是wms下发的充电任务,为了方便我们都重新生成一条wcstask任务
|
|
|
if (agvInfoMap.get(KEY_TASK_NO) == null || StringUtils.isEmpty(agvInfoMap.get(KEY_TASK_NO).toString())) {
|
|
|
- // todo
|
|
|
-// R r = wcsTaskService.addChargingTask(agvNo, chargingSite, index);
|
|
|
-// if (!r.isOk()) {
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// taskNo = (String) r.get("taskNo");
|
|
|
-// agvInfoMap.put(KEY_TASK_NO, taskNo);
|
|
|
-// agvInfoMap.put(KEY_AGV_STS, AGV_CHARGING_STS.READY.toString());
|
|
|
-// redisUtils.set(KEY_PREFIX + agvNo, agvInfoMap);
|
|
|
+ AjaxResult ajaxResult = wcsTaskService.addChargingTask(agvNo, chargingSite, index);
|
|
|
+ if (!ajaxResult.isSuccess()) {
|
|
|
+ log.error(ajaxResult.getMsg());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ taskNo = (String) ajaxResult.get("data");
|
|
|
+ agvInfoMap.put(KEY_TASK_NO, taskNo);
|
|
|
+ agvInfoMap.put(KEY_AGV_STS, AGV_CHARGING_STS.READY.toString());
|
|
|
+ redisCache.setCacheMap(KEY_PREFIX + agvNo, agvInfoMap);
|
|
|
} else {
|
|
|
taskNo = agvInfoMap.get(KEY_TASK_NO).toString();
|
|
|
}
|
|
|
|
|
|
// WcsTask
|
|
|
WcsTask wcsTask = wcsTaskService.selectWcsTaskByTaskNo(taskNo);
|
|
|
- if (wcsTask == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
|
|
|
- // 充电机号 用true和false表示
|
|
|
+ // 充电机号
|
|
|
Integer chargerNo = chargingSite;
|
|
|
- boolean xx = chargerNo == 1;
|
|
|
- // 从节点ID todo 默认为
|
|
|
+ boolean xx = chargerNo == 2;
|
|
|
+ // 从节点ID 充电机根据不同的ip地址区分,从节点地址默认都是1
|
|
|
Integer slaveId = CHARGING_SLAVEID_MAPPING.getSlaveIdByChargerNo(chargingSite);
|
|
|
// 确认是否故障
|
|
|
boolean isFault = this.confirmChargerStatus(IS_FAULT, new Date(), true, xx);
|
|
@@ -275,13 +275,14 @@ public class ChargerButtService {
|
|
|
}
|
|
|
// 没有充电桩号没办法取消对应的充电机
|
|
|
if (chargingSite == null) {
|
|
|
+ log.error("没有充电桩号没办法取消对应的充电机!");
|
|
|
return;
|
|
|
}
|
|
|
String taskNo = "";
|
|
|
WcsTask wcsTask = null;
|
|
|
// 充电机号
|
|
|
Integer chargerNo = chargingSite;
|
|
|
- boolean xx = chargerNo == 1;
|
|
|
+ boolean xx = chargerNo == 2;
|
|
|
// 从节点ID
|
|
|
Integer slaveId = CHARGING_SLAVEID_MAPPING.getSlaveIdByChargerNo(chargingSite);
|
|
|
// 从Redis拿到充电信息
|
|
@@ -307,10 +308,12 @@ public class ChargerButtService {
|
|
|
this.feedbackTSLog(taskNo, index, FAULT, agvNo + ",确认信号:无压紧、无充电、归位,失败!", xx);
|
|
|
}
|
|
|
// 判断先前是否收到过4003消息的标识
|
|
|
- boolean con = wcsTask != null ? wcsTask.getExt4().equals("1") : false;
|
|
|
- if (!con) {
|
|
|
- // 反馈TS结束充电
|
|
|
- this.feedbackTSLog(taskNo, index, AGV_STOP, agvNo + ",AGV结束充电!", xx);
|
|
|
+ if (wcsTask != null) {
|
|
|
+ boolean con = wcsTask.getExt4().equals("1") ? true : false;
|
|
|
+ if (!con) {
|
|
|
+ // 反馈TS结束充电
|
|
|
+ this.feedbackTSLog(taskNo, index, AGV_STOP, agvNo + ",AGV结束充电!", xx);
|
|
|
+ }
|
|
|
}
|
|
|
// 下发一个TS101的任务
|
|
|
feedbackTS.feedbackTS101(taskNo, index, agvNo);
|
|
@@ -335,7 +338,7 @@ public class ChargerButtService {
|
|
|
String taskNo = "";
|
|
|
WcsTask wcsTask;
|
|
|
// 从redis拿到充电信息
|
|
|
- Map<String, Object> agvInfoMap = redisCache.getCacheMap(KEY_PREFIX);
|
|
|
+ Map<String, Object> agvInfoMap = redisCache.getCacheMap(KEY_PREFIX + agvNo);
|
|
|
// 拿到对应WcsTask任务号
|
|
|
if (agvInfoMap != null && agvInfoMap.get(KEY_TASK_NO) != null
|
|
|
&& StringUtils.isNotEmpty(agvInfoMap.get(KEY_TASK_NO).toString())) {
|
|
@@ -450,24 +453,38 @@ public class ChargerButtService {
|
|
|
WcsTask wcsTask = wcsTaskService.selectWcsTaskByTaskNo(taskNo);
|
|
|
|
|
|
// 查询充电机状态是否为完成(确认信号:无压紧、无充电、归位),充电机充电完成会自动停止放电 退回伸缩杆、归位
|
|
|
- boolean isEnd = chargerButtService.confirmChargerStatus(IS_END, new Date(), false,xx);
|
|
|
+ boolean isEnd = chargerButtService.confirmChargerStatus(IS_END, new Date(), false, xx);
|
|
|
if (isEnd) {
|
|
|
// 判断先前是否收到过4003消息的标识
|
|
|
- boolean con = wcsTask != null ? wcsTask.getExt4().equals("1") : false;
|
|
|
- if (!con) {
|
|
|
- // 反馈TS结束充电
|
|
|
- chargerButtService.feedbackTSLog(taskNo, index, AGV_STOP, agvNo + "AGV充电结束!", xx);
|
|
|
+ if (wcsTask != null) {
|
|
|
+ boolean con = wcsTask.getExt4().equals("1") ? true : false;
|
|
|
+ if (!con) {
|
|
|
+ // 反馈TS结束充电
|
|
|
+ chargerButtService.feedbackTSLog(taskNo, index, AGV_STOP, agvNo + "AGV充电结束!", xx);
|
|
|
+ }
|
|
|
}
|
|
|
// 下发一个TS101的任务
|
|
|
feedbackTS.feedbackTS101(taskNo, index, agvNo);
|
|
|
+ // 设置Redis充电状态为停止
|
|
|
+ Map<String, Object> agvInfoMapU = redisCache.getCacheMap(KEY_PREFIX + agvNo);
|
|
|
+ if (agvInfoMapU != null) {
|
|
|
+ agvInfoMapU.put(KEY_AGV_STS, AGV_CHARGING_STS.STOP.toString());
|
|
|
+ redisCache.setCacheMap(KEY_PREFIX + agvNo, agvInfoMapU);
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
// 查询充电机是否故障 关闭充电机 停止充电
|
|
|
- boolean isFault = chargerButtService.confirmChargerStatus(IS_FAULT, new Date(), false,xx);
|
|
|
+ boolean isFault = chargerButtService.confirmChargerStatus(IS_FAULT, new Date(), false, xx);
|
|
|
if (isFault) {
|
|
|
chargerButtService.operation(STOP, xx);
|
|
|
// 反馈TS充电机故障
|
|
|
chargerButtService.feedbackTSLog(taskNo, index, FAULT, agvNo + ",充电机故障!", xx);
|
|
|
+ // 设置Redis充电状态为停止
|
|
|
+ Map<String, Object> agvInfoMapU = redisCache.getCacheMap(KEY_PREFIX + agvNo);
|
|
|
+ if (agvInfoMapU != null) {
|
|
|
+ agvInfoMapU.put(KEY_AGV_STS, AGV_CHARGING_STS.STOP.toString());
|
|
|
+ redisCache.setCacheMap(KEY_PREFIX + agvNo, agvInfoMapU);
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
try {
|
|
@@ -586,11 +603,11 @@ public class ChargerButtService {
|
|
|
// 待机
|
|
|
boolean bit_04_0 = BIT_04_0.isTrue(status);
|
|
|
// 在线
|
|
|
- boolean bit_04_5 = BIT_04_5.isTrue(status);
|
|
|
+// boolean bit_04_5 = BIT_04_5.isTrue(status);
|
|
|
|
|
|
|
|
|
// 所有的是true 返回true
|
|
|
- boolean result = Stream.of(bit_04_0, bit_04_5).allMatch(t -> t == true);
|
|
|
+ boolean result = Stream.of(bit_04_0/*, bit_04_5*/).allMatch(t -> t == true);
|
|
|
|
|
|
return result;
|
|
|
}
|
|
@@ -647,20 +664,20 @@ public class ChargerButtService {
|
|
|
// 短路
|
|
|
boolean bit_05_3 = BIT_05_3.isTrue(status);
|
|
|
// 电池未接
|
|
|
- boolean bit_05_4 = BIT_05_4.isTrue(status);
|
|
|
+// boolean bit_05_4 = BIT_05_4.isTrue(status);
|
|
|
// 电池反接
|
|
|
boolean bit_05_5 = BIT_05_5.isTrue(status);
|
|
|
// 模块通信故障
|
|
|
boolean bit_05_6 = BIT_05_6.isTrue(status);
|
|
|
// Can通信超时
|
|
|
- boolean bit_05_7 = BIT_05_7.isTrue(status);
|
|
|
+// boolean bit_05_7 = BIT_05_7.isTrue(status);
|
|
|
|
|
|
// 伸缩故障
|
|
|
boolean bit_06_5 = BIT_06_5.isTrue(status);
|
|
|
|
|
|
// 如果任何一个是true 返回true
|
|
|
boolean result = Stream.of(bit_04_1
|
|
|
- , bit_05_0, bit_05_1, bit_05_2, bit_05_3, bit_05_4, bit_05_5, bit_05_6, bit_05_7
|
|
|
+ , bit_05_0, bit_05_1, bit_05_2, bit_05_3, /*bit_05_4,*/ bit_05_5, bit_05_6/*, bit_05_7*/
|
|
|
, bit_06_5).anyMatch(t -> t == true);
|
|
|
|
|
|
return result;
|