现场调度修改
This commit is contained in:
21
ruoyi-admin/src/main/java/com/ruoyi/MyStartupRunner.java
Normal file
21
ruoyi-admin/src/main/java/com/ruoyi/MyStartupRunner.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.ruoyi;
|
||||
|
||||
import com.ruoyi.schedule.ScheduleThread;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class MyStartupRunner implements CommandLineRunner {
|
||||
|
||||
@Autowired
|
||||
private ScheduleThread scheduleThread;
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
// 这里编写项目启动后要执行的方法逻辑
|
||||
//System.out.println("项目启动成功后自动执行此方法");
|
||||
scheduleThread.startAllThread();
|
||||
scheduleThread.startAllThread2();
|
||||
}
|
||||
}
|
||||
@@ -127,4 +127,11 @@ public interface IApiService
|
||||
* @return
|
||||
*/
|
||||
AjaxResult selectMydoJobByTrayCodeAndEntranceId(HashMap<String, Object> paramMap);
|
||||
|
||||
/**
|
||||
* 主动获取任务
|
||||
* @param jobParam
|
||||
* @return
|
||||
*/
|
||||
AjaxResult outMyJobXf(JobParam jobParam);
|
||||
}
|
||||
|
||||
@@ -389,4 +389,15 @@ public class ApiServiceImpl implements IApiService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult outMyJobXf(JobParam jobParam) {
|
||||
RequestLog requestLog = requestLogService.getRequestLog(XF_OUT_JOB_URL, "出库作业下发成功", JSONUtil.toJsonStr(jobParam));
|
||||
InterfaceReceive bean = JSONUtil.toBean(requestLog.getResponseBody(), InterfaceReceive.class);
|
||||
if ("1".equals(requestLog.getIsSuccessful())) {
|
||||
return AjaxResult.success(bean.getData());
|
||||
} else {
|
||||
return AjaxResult.error(bean.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ public class Constant {
|
||||
public static final String RE_ASSIGN_URL = WMS_BASE_URL+"reAssign";
|
||||
public static final String RE_MATERIAL_URL = WMS_BASE_URL+"reMaterial";
|
||||
public static final String REQUEST_ENTER_URL = WMS_BASE_URL+"requestEnterByTrayCodeAndEntranceId";
|
||||
public static final String XF_OUT_JOB_URL = WMS_BASE_URL+"outJobStart";
|
||||
|
||||
|
||||
public static final String WAREHOUSE_01 = "01";
|
||||
|
||||
@@ -178,14 +178,11 @@ public class ScheduleThread {
|
||||
plcDdj4ReadCustomThread.getThread().start();
|
||||
|
||||
}
|
||||
if (plcDdj5ReadCustomThread!=null){
|
||||
/*plcDdj2ReadCustomThread.getThread().start();
|
||||
plcDdj3ReadCustomThread.getThread().start();
|
||||
plcDdj4ReadCustomThread.getThread().start();
|
||||
plcDdj5ReadCustomThread.getThread().start();
|
||||
|
||||
}
|
||||
if (plcDdj6ReadCustomThread!=null){
|
||||
plcDdj6ReadCustomThread.getThread().start();
|
||||
|
||||
}
|
||||
plcDdj6ReadCustomThread.getThread().start();*/
|
||||
isRun = true;
|
||||
}
|
||||
|
||||
@@ -210,14 +207,11 @@ public class ScheduleThread {
|
||||
ddj4CustomThread.thread.start();
|
||||
|
||||
}
|
||||
if (ddj5CustomThread!=null){
|
||||
/*ddj2CustomThread.thread.start();
|
||||
ddj3CustomThread.thread.start();
|
||||
ddj4CustomThread.thread.start();
|
||||
ddj5CustomThread.thread.start();
|
||||
|
||||
}
|
||||
if (ddj6CustomThread!=null){
|
||||
ddj6CustomThread.thread.start();
|
||||
|
||||
}
|
||||
ddj6CustomThread.thread.start();*/
|
||||
isRun2 = true;
|
||||
}
|
||||
|
||||
@@ -230,15 +224,11 @@ public class ScheduleThread {
|
||||
plcDdj1ReadCustomThread.runnable.isRun = false;
|
||||
plcDdj1ReadCustomThread.thread.interrupt();
|
||||
plcDdj2ReadCustomThread.runnable.isRun = false;
|
||||
plcDdj2ReadCustomThread.thread.interrupt();
|
||||
plcDdj3ReadCustomThread.runnable.isRun = false;
|
||||
plcDdj3ReadCustomThread.thread.interrupt();
|
||||
plcDdj4ReadCustomThread.runnable.isRun = false;
|
||||
plcDdj4ReadCustomThread.thread.interrupt();
|
||||
plcDdj5ReadCustomThread.runnable.isRun = false;
|
||||
plcDdj5ReadCustomThread.thread.interrupt();
|
||||
plcDdj6ReadCustomThread.runnable.isRun = false;
|
||||
plcDdj6ReadCustomThread.thread.interrupt();
|
||||
plcReadInit();
|
||||
isRun = false;
|
||||
}
|
||||
@@ -249,18 +239,8 @@ public class ScheduleThread {
|
||||
public void stopAllThread2() {
|
||||
monitoringCustomThread.runnable.isRun = false;
|
||||
monitoringCustomThread.thread.interrupt();
|
||||
ddj1CustomThread.runnable.isRun = false;
|
||||
ddj1CustomThread.thread.interrupt();
|
||||
ddj2CustomThread.runnable.isRun = false;
|
||||
ddj2CustomThread.thread.interrupt();
|
||||
ddj3CustomThread.runnable.isRun = false;
|
||||
ddj3CustomThread.thread.interrupt();
|
||||
ddj4CustomThread.runnable.isRun = false;
|
||||
ddj4CustomThread.thread.interrupt();
|
||||
ddj5CustomThread.runnable.isRun = false;
|
||||
ddj5CustomThread.thread.interrupt();
|
||||
ddj6CustomThread.runnable.isRun = false;
|
||||
ddj6CustomThread.thread.interrupt();
|
||||
scheduleInit();
|
||||
isRun2 = false;
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
createRollbackQueue(ddj, 1);
|
||||
|
||||
} else if (!"00000000".equals(trayCode) && !"000000".equals(trayCode)) {
|
||||
log.info("258- 扫码成功 trayCode:{}",trayCode);
|
||||
log.info("258- 扫码成功 ddj:{} trayCode:{}",ddj.getId(),trayCode);
|
||||
trayCode = trayCode.substring(trayCode.length() - 4);
|
||||
MydoJob param = new MydoJob();
|
||||
param.setTrayCode(trayCode);
|
||||
@@ -323,7 +323,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
ddjDeviceExecutionQueue.setRwlx(DDJ_RWLX_2);
|
||||
ddjDeviceExecutionQueue.setSpare4(trayCode);
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
log.info("324- 任务生成成功 trayCode:{}",trayCode);
|
||||
log.info("324- 任务生成成功 ddj:{} trayCode:{}",ddj.getId(),trayCode);
|
||||
|
||||
inJob.setStatus("3");
|
||||
inJob.setStartTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
@@ -426,7 +426,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
Double aDouble = Convert.toDouble(weight);
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(taskNo), ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
log.info("取货任务 任务号:{} 重量:{}",taskNo,aDouble);
|
||||
log.info("取货任务 ddj:{} 任务号:{} 重量:{}",ddj.getId(),taskNo,aDouble);
|
||||
if (aDouble > 0 && aDouble < 1500) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueue.setUuid(IdUtil.simpleUUID());
|
||||
@@ -490,12 +490,17 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
if (ObjUtil.isNotNull(mydoJob)) {
|
||||
//回传完成信号
|
||||
ddjTaskFinish(rwh, ddj.getId(), 1);
|
||||
log.info("堆垛机完成任务 ddj:{},taskNo:{} rwlx:{}",ddj.getId(),rwh,ddjDeviceExecutionQueue.getRwlx() );
|
||||
}
|
||||
} else if (ddjDeviceExecutionQueue.getRwlx() == 4) {
|
||||
ddjTaskFinish(rwh, ddj.getId(), 2);
|
||||
log.info("堆垛机完成任务 ddj:{},taskNo:{} rwlx:{}",ddj.getId(),rwh,ddjDeviceExecutionQueue.getRwlx() );
|
||||
|
||||
} else if (ddjDeviceExecutionQueue.getRwlx() == 1) {
|
||||
if (hczt == 0) {
|
||||
ddjTaskFinish(ddj.getRwh(), ddj.getId(), 2);
|
||||
log.info("堆垛机完成任务 ddj:{},taskNo:{} rwlx:{}",ddj.getId(),rwh,ddjDeviceExecutionQueue.getRwlx());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -526,12 +531,14 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
Long rwh = ddj.getRwh();
|
||||
String trayCode = ddj.getTrayCode();
|
||||
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(rwh);
|
||||
String oldCargoSpaceId = mydoJob.getCargoSpaceId();
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
|
||||
if ("0".equals(mydoJob.getFaultFlag()) && "1".equals(ddjDeviceExecutionQueue.getSpare1())) {
|
||||
mydoJob.setStatus("1");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
AjaxResult ajaxResult = apiService.reAssign(new JobParam(mydoJob.getJobId(), trayCode, ddjDeviceExecutionQueue.getRwh().toString()));
|
||||
if (ajaxResult.isSuccess()) {
|
||||
|
||||
mydoJob = mydoJobService.selectMydoJobByTaskNo(rwh);
|
||||
mydoJob.setFaultFlag("2");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
@@ -542,6 +549,8 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
ddjDeviceExecutionQueue.setSpare1("0");
|
||||
ddjDeviceExecutionQueue.setDdjxf("0");
|
||||
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
log.info("放货有货,重分货位 ddj:{},rwh:{} 原货位:{} 新货位:{}",ddj.getId(),rwh,oldCargoSpaceId,mydoJob.getCargoSpaceId());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -556,12 +565,17 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
|
||||
//找到对应任务 调用api接口 取货无货,重新分配单据
|
||||
if (ObjUtil.isNotNull(ddjDeviceExecutionQueue)) {
|
||||
AjaxResult ajaxResult = apiService.reMaterial(new JobParam(rwh.toString(), null, null));
|
||||
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(rwh);
|
||||
if (ObjUtil.isNotNull(mydoJob)){
|
||||
AjaxResult ajaxResult = apiService.reMaterial(new JobParam(mydoJob.getJobId(), null, rwh.toString()));
|
||||
if (ajaxResult.isSuccess()) {
|
||||
//作废作业
|
||||
InvalidMydoJob(rwh, ddj.getId());
|
||||
log.info("取货无货 作废作业 ddj:{},rwh:{}",ddj.getId(),rwh);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -585,7 +599,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
mydoJob.setFaultFlag("0");
|
||||
mydoJobService.updateMydoJob(mydoJob);
|
||||
log.info("托盘堆垛机重新下发任务成功 rwh:{}", rwh);
|
||||
log.info("托盘堆垛机重新下发任务成功 ddj:{} rwh:{}",ddj.getId(), ddjDeviceExecutionQueue.getRwh());
|
||||
} else {
|
||||
log.error("托盘堆垛机重新下发任务失败!!!!!!!");
|
||||
}
|
||||
@@ -600,7 +614,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
|
||||
List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues1 = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueList(ddjDeviceExecutionRunningQueueParam);
|
||||
if (CollUtil.isNotEmpty(ddjDeviceExecutionQueues1)) {
|
||||
log.info("正在执行任务 {}", ddjDeviceExecutionQueues1.get(0).getRwh());
|
||||
log.info("ddj:{} 正在执行任务 {}",ddj.getId(), ddjDeviceExecutionQueues1.get(0).getRwh());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -619,13 +633,23 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueues.get(0);
|
||||
int i = issuedDDJTask(ddj, ddjDeviceExecutionQueue);
|
||||
if (i == 1) {
|
||||
if (ddjDeviceExecutionQueue.getRwlx() ==DDJ_RWLX_3){
|
||||
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(ddjDeviceExecutionQueue.getRwh());
|
||||
if (ObjUtil.isNotNull(mydoJob)){
|
||||
//通知出库任务开始
|
||||
AjaxResult ajaxResult = apiService.outMyJobXf(new JobParam(mydoJob.getJobId(), null, ddjDeviceExecutionQueue.getRwh().toString()));
|
||||
if (ajaxResult.isSuccess()) {
|
||||
log.info("通知出库任务开始成功 ddj:{},rwh:{}",ddj.getId(),ddjDeviceExecutionQueue.getRwh());
|
||||
}
|
||||
}
|
||||
}
|
||||
//更新开始时间,修改ddjxf为已下发1
|
||||
ddjDeviceExecutionQueue.setXfsj(DateUtil.formatDateTime(DateUtil.date()));
|
||||
ddjDeviceExecutionQueue.setDdjxf("1");
|
||||
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
log.info("托盘堆垛机下发任务成功 rwh:{}", ddjDeviceExecutionQueue.getRwh());
|
||||
log.info("托盘堆垛机下发任务成功 ddj:{} rwh:{}",ddj.getId(), ddjDeviceExecutionQueue.getRwh());
|
||||
} else {
|
||||
log.error("托盘堆垛机下发任务失败!!!!!!!");
|
||||
log.error("托盘堆垛机下发任务失败!!!!!!!ddj:{} rwh:{}",ddj.getId(), ddjDeviceExecutionQueue.getRwh());
|
||||
}
|
||||
}
|
||||
} else if ((ddj.getSbzt() == 0 || ddj.getSbzt()==1047) && ddj.getHczt() == 1) {
|
||||
@@ -646,9 +670,9 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
ddjDeviceExecutionQueue.setXfsj(DateUtil.formatDateTime(DateUtil.date()));
|
||||
ddjDeviceExecutionQueue.setDdjxf("1");
|
||||
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
log.info("托盘堆垛机下发任务成功 rwh:{}", ddjDeviceExecutionQueue.getRwh());
|
||||
log.info("托盘堆垛机下发任务成功 ddj:{} rwh:{}",ddj.getId(), ddjDeviceExecutionQueue.getRwh());
|
||||
} else {
|
||||
log.error("托盘堆垛机下发任务失败!!!!!!!");
|
||||
log.error("托盘堆垛机下发任务失败!!!!!!ddj:{} rwh:{}",ddj.getId(), ddjDeviceExecutionQueue.getRwh());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,32 +43,20 @@ public class Ddj5Thread extends BaseDdjThread {
|
||||
ssjList.put("outSsj2", outSsj2);
|
||||
|
||||
//初始化巷道口 排 列 层
|
||||
roadwayMap.put("L1003", Arrays.asList(1, 0, 1));
|
||||
roadwayMap.put("L1004", Arrays.asList(2, 0, 1));
|
||||
//未扫码 回退任务号 无入库任务在此基础+100
|
||||
roadwayMap.put("L1003", Arrays.asList(1, 1, 1));
|
||||
roadwayMap.put("L1004", Arrays.asList(2, 1, 1));
|
||||
roadwayRollback.put("L1003", 94);
|
||||
roadwayRollback.put("L1004", 95);
|
||||
|
||||
//初始化称重设备连接ip port
|
||||
czRoadwayMap.put("L1003", "172.19.40.216:4001");
|
||||
czRoadwayMap.put("L1004", "172.19.40.217:4001");
|
||||
|
||||
/*czOverMap.put("L1003", "DB502.12");
|
||||
czOverMap.put("L1004", "DB502.26");*/
|
||||
|
||||
outJobMap.put("L1003", "DB502.38");
|
||||
outJobMap.put("L1004", "DB502.52");
|
||||
|
||||
log.info("Ddj5Thread init");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HashMap<String, Object> getParamMap(String trayCode,Integer height,double weight) {
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("trayCode", trayCode);
|
||||
paramMap.put("warehouseId",WAREHOUSE_02);
|
||||
paramMap.put("roadwayId",ROADWAY_ID_05);
|
||||
paramMap.put("roadwayId",ROADWAY_ID_02);
|
||||
paramMap.put("height",height);
|
||||
paramMap.put("weight",weight);
|
||||
return paramMap;
|
||||
@@ -78,7 +66,7 @@ public class Ddj5Thread extends BaseDdjThread {
|
||||
public MydoJob getOutJobParam() {
|
||||
MydoJob mydoJob = new MydoJob();
|
||||
mydoJob.setWarehouseId(WAREHOUSE_02);
|
||||
mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_05));
|
||||
mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_02));
|
||||
mydoJob.setStatus("1");
|
||||
|
||||
return mydoJob;
|
||||
|
||||
@@ -43,22 +43,11 @@ public class Ddj6Thread extends BaseDdjThread {
|
||||
ssjList.put("outSsj2", outSsj2);
|
||||
|
||||
//初始化巷道口 排 列 层
|
||||
roadwayMap.put("L1005", Arrays.asList(1, 0, 1));
|
||||
roadwayMap.put("L1006", Arrays.asList(2, 0, 1));
|
||||
//未扫码 回退任务号 无入库任务在此基础+100
|
||||
roadwayMap.put("L1005", Arrays.asList(1, 1, 1));
|
||||
roadwayMap.put("L1006", Arrays.asList(2, 1, 1));
|
||||
roadwayRollback.put("L1005", 96);
|
||||
roadwayRollback.put("L1006", 97);
|
||||
|
||||
//初始化称重设备连接ip port
|
||||
czRoadwayMap.put("L1005", "172.19.40.218:4001");
|
||||
czRoadwayMap.put("L1006", "172.19.40.219:4001");
|
||||
|
||||
/*czOverMap.put("L1003", "DB502.12");
|
||||
czOverMap.put("L1004", "DB502.26");*/
|
||||
|
||||
outJobMap.put("L1005", "DB502.66");
|
||||
outJobMap.put("L1006", "DB502.80");
|
||||
|
||||
log.info("Ddj6Thread init");
|
||||
}
|
||||
|
||||
@@ -68,9 +57,10 @@ public class Ddj6Thread extends BaseDdjThread {
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("trayCode", trayCode);
|
||||
paramMap.put("warehouseId",WAREHOUSE_02);
|
||||
paramMap.put("roadwayId",ROADWAY_ID_06);
|
||||
paramMap.put("roadwayId",ROADWAY_ID_03);
|
||||
paramMap.put("height",height);
|
||||
paramMap.put("weight",weight);
|
||||
|
||||
return paramMap;
|
||||
}
|
||||
|
||||
@@ -78,7 +68,7 @@ public class Ddj6Thread extends BaseDdjThread {
|
||||
public MydoJob getOutJobParam() {
|
||||
MydoJob mydoJob = new MydoJob();
|
||||
mydoJob.setWarehouseId(WAREHOUSE_02);
|
||||
mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_06));
|
||||
mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_03));
|
||||
mydoJob.setStatus("1");
|
||||
|
||||
return mydoJob;
|
||||
@@ -96,5 +86,4 @@ public class Ddj6Thread extends BaseDdjThread {
|
||||
return "1";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ public class MonitoringThread implements Runnable {
|
||||
for (String ssjCode : PlcSsjRead.deviceSsjMap.keySet()) {
|
||||
DeviceSsj deviceSsj = PlcSsjRead.deviceSsjMap.get(ssjCode);
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
int taskNo = deviceSsj.getTaskNo();
|
||||
|
||||
//输送机外形异常 101-前超长 102-后超长 103-左超宽 104-右超宽 105-超高 106-超重
|
||||
if (deviceSsj.getException() >= 101 && deviceSsj.getException() <= 106 && deviceSsj.getTaskNo()>0) {
|
||||
@@ -88,6 +89,53 @@ public class MonitoringThread implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
if (taskNo >= 50 && taskNo < 200) {
|
||||
//扫码失败+0 无任务+100 无货位+20 已存在当前托盘+40
|
||||
/*
|
||||
"L2001", 80 "L2002", 81 "L2007", 82 "L2008", 83 "L2003", 84 "L2004", 85
|
||||
"L2009", 86 "L2010", 87 "L2005", 88 "L2006", 89 "L2011", 90 "L2012", 91
|
||||
"L1001", 92 "L1002", 93 "L1003", 94 "L1004", 95 "L1005", 96 "L1006", 97
|
||||
*/
|
||||
String trayCode = null;
|
||||
if (taskNo>100){
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(taskNo), Convert.toInt(deviceSsj.getId()));
|
||||
if (ObjUtil.isNotNull(ddjDeviceExecutionQueue)) {
|
||||
trayCode = ddjDeviceExecutionQueue.getSpare4();
|
||||
}
|
||||
}
|
||||
BasFaultRecord param = new BasFaultRecord();
|
||||
param.setTaskNo(Convert.toStr(taskNo));
|
||||
param.setDeviceId(ssjCode);
|
||||
param.setJobId("0");
|
||||
List<BasFaultRecord> basFaultRecords = basFaultRecordService.selectBasFaultRecordList(param);
|
||||
if (CollUtil.isEmpty(basFaultRecords)) {
|
||||
BasFaultRecord record = new BasFaultRecord();
|
||||
record.setId(IdUtil.simpleUUID());
|
||||
record.setDeviceId(ssjCode);
|
||||
record.setDeviceName(ssjCode);
|
||||
record.setDeviceType("ssj");
|
||||
record.setTaskNo(Convert.toStr(taskNo));
|
||||
record.setStartTime(DateUtil.formatDateTime(new Date()));
|
||||
if (taskNo >= 80 && taskNo <= 97) {
|
||||
//扫码失败
|
||||
record.setFault(getDdjZt(107, trayCode));
|
||||
} else if (taskNo >= 100 && taskNo < 120) {
|
||||
//无货位
|
||||
record.setFault(getDdjZt(108, trayCode));
|
||||
} else if (taskNo >= 120 && taskNo < 140) {
|
||||
//已存在当前托盘
|
||||
record.setFault(getDdjZt(109, trayCode));
|
||||
} else {
|
||||
//无任务
|
||||
record.setFault(getDdjZt(110, trayCode));
|
||||
}
|
||||
record.setJobId("0");
|
||||
basFaultRecordService.insertBasFaultRecord(record);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//取走托盘 恢复异常
|
||||
if (deviceSsj.getTaskNo() == 0 && deviceSsj.getKx() == 1) {
|
||||
//查询记录 更新故障结束时间
|
||||
@@ -142,50 +190,8 @@ public class MonitoringThread implements Runnable {
|
||||
basFaultRecordService.updateBasFaultRecord(record);
|
||||
}
|
||||
}
|
||||
if (msgDdj.getRwh() >= 50 && msgDdj.getRwh() < 200) {
|
||||
//扫码失败+0 无任务+100 无货位+20 已存在当前托盘+40
|
||||
long taskNo = msgDdj.getRwh();
|
||||
/*
|
||||
"L2001", 80 "L2002", 81 "L2007", 82 "L2008", 83 "L2003", 84 "L2004", 85
|
||||
"L2009", 86 "L2010", 87 "L2005", 88 "L2006", 89 "L2011", 90 "L2012", 91
|
||||
"L1001", 92 "L1002", 93 "L1003", 94 "L1004", 95 "L1005", 96 "L1006", 97
|
||||
*/
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(taskNo, msgDdj.getId());
|
||||
if (ObjUtil.isNotNull(ddjDeviceExecutionQueue)) {
|
||||
String trayCode = ddjDeviceExecutionQueue.getSpare4();
|
||||
BasFaultRecord param = new BasFaultRecord();
|
||||
param.setTaskNo(Convert.toStr(msgDdj.getRwh()));
|
||||
param.setDeviceId(Convert.toStr(ddjDeviceExecutionQueue.getSpare2()));
|
||||
param.setJobId("0");
|
||||
List<BasFaultRecord> basFaultRecords = basFaultRecordService.selectBasFaultRecordList(param);
|
||||
if (CollUtil.isEmpty(basFaultRecords)) {
|
||||
BasFaultRecord record = new BasFaultRecord();
|
||||
record.setId(IdUtil.simpleUUID());
|
||||
record.setDeviceId(param.getDeviceName());
|
||||
record.setDeviceName(param.getDeviceName());
|
||||
record.setDeviceType("ssj");
|
||||
record.setTaskNo(Convert.toStr(taskNo));
|
||||
record.setStartTime(DateUtil.formatDateTime(new Date()));
|
||||
if (taskNo >= 80 && taskNo <= 97) {
|
||||
//扫码失败
|
||||
record.setFault(getDdjZt(107, trayCode));
|
||||
} else if (taskNo >= 100 && taskNo < 120) {
|
||||
//无货位
|
||||
record.setFault(getDdjZt(108, trayCode));
|
||||
} else if (taskNo >= 120 && taskNo < 140) {
|
||||
//已存在当前托盘
|
||||
record.setFault(getDdjZt(109, trayCode));
|
||||
} else {
|
||||
//无任务
|
||||
record.setFault(getDdjZt(110, trayCode));
|
||||
}
|
||||
record.setJobId("0");
|
||||
basFaultRecordService.insertBasFaultRecord(record);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Thread.sleep(1500);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package com.ruoyi.schedule.util;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.Socket;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CheckWeight {
|
||||
|
||||
@@ -15,15 +19,16 @@ public class CheckWeight {
|
||||
Socket socket = new Socket(ip, por);
|
||||
InputStream is = socket.getInputStream();
|
||||
) {
|
||||
Thread.sleep(100);
|
||||
byte[] bytes = new byte[10];
|
||||
Thread.sleep(1000);
|
||||
byte[] bytes = new byte[100];
|
||||
int read = is.read(bytes);
|
||||
if (read!=-1){
|
||||
String weight = byteArrayToCharArray(bytes, "UTF-8");
|
||||
weight = weight.substring(1,8);
|
||||
weight = weight.replace("=","");
|
||||
String[] weightList = byteArrayToCharArray(bytes, "UTF-8").split("\r\n");
|
||||
System.out.println(Arrays.toString(weightList));
|
||||
String weight = getMostFrequentByHutool(weightList);
|
||||
weight = weight.replace("=","").replace("\r","").replace("\n","");
|
||||
|
||||
if (weight.length() == 7 && !weight.equals("0000000")) {
|
||||
if (!weight.equals("0000000")) {
|
||||
zhi = weight;
|
||||
}
|
||||
}
|
||||
@@ -34,6 +39,41 @@ public class CheckWeight {
|
||||
return zhi;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用 Hutool 找出数组中出现次数最多的字符串
|
||||
* @param strArray 目标字符串数组
|
||||
* @return 出现次数最多的字符串(空数组返回 null,多最大值返回第一个)
|
||||
*/
|
||||
/**
|
||||
* 兼容所有 Hutool 版本:找出数组中出现次数最多的字符串
|
||||
* @param strArray 目标字符串数组
|
||||
* @return 出现次数最多的字符串(空数组返回 null,多最大值返回第一个)
|
||||
*/
|
||||
public static String getMostFrequentByHutool(String[] strArray) {
|
||||
// 1. 空值校验 + 数组转 List
|
||||
if (strArray == null || strArray.length == 0) {
|
||||
return null;
|
||||
}
|
||||
List<String> strList = CollUtil.newArrayList(strArray);
|
||||
|
||||
// 2. 用 Hutool 统计频次(所有版本都支持)
|
||||
Map<String, Integer> countMap = CollUtil.countMap(strList);
|
||||
|
||||
// 3. 手动遍历找最大值(替代不存在的 getMaxKey 方法)
|
||||
String mostFrequent = null;
|
||||
int maxCount = 0;
|
||||
// 遍历 Map 条目,Hutool 5.x 及以上都支持 entrySet 遍历
|
||||
for (Map.Entry<String, Integer> entry : countMap.entrySet()) {
|
||||
if (entry.getValue() > maxCount) {
|
||||
maxCount = entry.getValue();
|
||||
mostFrequent = entry.getKey();
|
||||
}
|
||||
}
|
||||
|
||||
return mostFrequent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将byte数组按指定编码转为char数组
|
||||
* @param byteArr 输入的byte数组
|
||||
@@ -51,7 +91,10 @@ public class CheckWeight {
|
||||
|
||||
public static void main(String[] args) {
|
||||
CheckWeight checkWeight = new CheckWeight();
|
||||
System.out.println(checkWeight.sendWeight("172.19.50.75", 4001));
|
||||
while (true){
|
||||
System.out.println(checkWeight.sendWeight("172.19.50.80", 4001));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user