Compare commits
7 Commits
2def16ad4b
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52772494d4 | ||
|
|
2272a89b2a | ||
|
|
b4ed427de9 | ||
|
|
8e60b8e9c1 | ||
|
|
f2e0c086eb | ||
|
|
c85e53ac1d | ||
|
|
9938ca3a41 |
@@ -130,6 +130,14 @@
|
||||
<warName>${project.artifactId}</warName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>9</source>
|
||||
<target>9</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
</build>
|
||||
|
||||
@@ -17,5 +17,6 @@ public class ReceiveJob {
|
||||
private String jobId;
|
||||
private String roadwayId;
|
||||
private String warehouseId;
|
||||
private Long priority;
|
||||
|
||||
}
|
||||
|
||||
@@ -368,6 +368,7 @@ public class ApiServiceImpl implements IApiService {
|
||||
mydoJob.setCreateTime(DateUtils.getNowDate());
|
||||
mydoJob.setExecutionPhase("0");
|
||||
mydoJob.setWarehouseId(receiveOutJob.getWarehouseId());
|
||||
mydoJob.setPriority(receiveOutJob.getPriority());
|
||||
int i = mydoJobService.insertMydoJob(mydoJob);
|
||||
if (i > 0) {
|
||||
return AjaxResult.success();
|
||||
|
||||
@@ -182,6 +182,40 @@ public class MydoJobServiceImpl implements IMydoJobService
|
||||
@Override
|
||||
public Map<String, List<MydoJobScreen>> selectJobListByWarehouseIdAndType(String warehouseId, String type) {
|
||||
Map<String, List<MydoJobScreen>> map = new HashMap<>();
|
||||
if ("01".equals(warehouseId)){
|
||||
map.put("1",new ArrayList<>());
|
||||
map.put("2",new ArrayList<>());
|
||||
map.put("3",new ArrayList<>());
|
||||
MydoJob outParam = new MydoJob();
|
||||
outParam.setWarehouseId(warehouseId);
|
||||
outParam.setExitId(type);
|
||||
List<MydoJobScreen> outMydoJobs = mydoJobMapper.selectJobListByWarehouseIdAndType(outParam);
|
||||
if (CollUtil.isNotEmpty(outMydoJobs)){
|
||||
Map<String, List<MydoJobScreen>> collect = outMydoJobs.stream().collect(Collectors.groupingBy(MydoJobScreen::getRoadwayId));
|
||||
for (String roadwayId : collect.keySet()) {
|
||||
if (map.containsKey(roadwayId)){
|
||||
List<MydoJobScreen> mydoJobs = map.get(roadwayId);
|
||||
mydoJobs.addAll(collect.get(roadwayId));
|
||||
map.put(roadwayId,mydoJobs);
|
||||
}
|
||||
}
|
||||
}
|
||||
MydoJob inParam = new MydoJob();
|
||||
inParam.setWarehouseId(warehouseId);
|
||||
inParam.setEntranceId(type);
|
||||
List<MydoJobScreen> inMydoJobs = mydoJobMapper.selectJobListByWarehouseIdAndType(inParam);
|
||||
if (CollUtil.isNotEmpty(inMydoJobs)) {
|
||||
Map<String, List<MydoJobScreen>> collect = inMydoJobs.stream().collect(Collectors.groupingBy(MydoJobScreen::getRoadwayId));
|
||||
for (String roadwayId : collect.keySet()) {
|
||||
if (map.containsKey(roadwayId)){
|
||||
List<MydoJobScreen> mydoJobs = map.get(roadwayId);
|
||||
mydoJobs.addAll(collect.get(roadwayId));
|
||||
map.put(roadwayId,mydoJobs);
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}else {
|
||||
map.put("1",new ArrayList<>());
|
||||
map.put("2",new ArrayList<>());
|
||||
map.put("3",new ArrayList<>());
|
||||
@@ -216,8 +250,12 @@ public class MydoJobServiceImpl implements IMydoJobService
|
||||
}
|
||||
}
|
||||
}
|
||||
map.put("1",map.get("4"));
|
||||
map.put("2",map.get("5"));
|
||||
map.put("3",map.get("6"));
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MydoJob> selectOutMydoJobList(MydoJob outJobParam) {
|
||||
|
||||
@@ -161,28 +161,40 @@ public class ScheduleThread {
|
||||
* 开始线程
|
||||
*/
|
||||
public void startAllThread() {
|
||||
if (plcSsjReadCustomThread !=null){
|
||||
plcSsjReadCustomThread.getThread().setName("输送机读取线程");
|
||||
plcSsjReadCustomThread.getThread().start();
|
||||
}
|
||||
if (plcDdj1ReadCustomThread!=null){
|
||||
plcDdj1ReadCustomThread.getThread().setName("ddj1读取线程");
|
||||
plcDdj1ReadCustomThread.getThread().start();
|
||||
|
||||
}
|
||||
if (plcDdj2ReadCustomThread!=null){
|
||||
plcDdj2ReadCustomThread.getThread().setName("ddj2读取线程");
|
||||
plcDdj2ReadCustomThread.getThread().start();
|
||||
|
||||
}
|
||||
if (plcDdj3ReadCustomThread!=null){
|
||||
plcDdj3ReadCustomThread.getThread().setName("ddj3读取线程");
|
||||
plcDdj3ReadCustomThread.getThread().start();
|
||||
|
||||
}
|
||||
if (plcDdj4ReadCustomThread!=null){
|
||||
plcDdj4ReadCustomThread.getThread().setName("ddj4读取线程");
|
||||
plcDdj4ReadCustomThread.getThread().start();
|
||||
|
||||
}
|
||||
/*plcDdj2ReadCustomThread.getThread().start();
|
||||
plcDdj3ReadCustomThread.getThread().start();
|
||||
plcDdj4ReadCustomThread.getThread().start();
|
||||
if (plcDdj5ReadCustomThread!=null){
|
||||
plcDdj5ReadCustomThread.getThread().setName("ddj5读取线程");
|
||||
plcDdj5ReadCustomThread.getThread().start();
|
||||
plcDdj6ReadCustomThread.getThread().start();*/
|
||||
|
||||
}
|
||||
if (plcDdj6ReadCustomThread!=null){
|
||||
plcDdj6ReadCustomThread.getThread().setName("ddj6读取线程");
|
||||
plcDdj6ReadCustomThread.getThread().start();
|
||||
|
||||
}
|
||||
isRun = true;
|
||||
}
|
||||
|
||||
@@ -190,28 +202,40 @@ public class ScheduleThread {
|
||||
* 开启线程2
|
||||
*/
|
||||
public void startAllThread2() {
|
||||
if (monitoringCustomThread!=null){
|
||||
monitoringCustomThread.thread.setName("监控线程");
|
||||
monitoringCustomThread.thread.start();
|
||||
}
|
||||
if (ddj1CustomThread!=null){
|
||||
ddj1CustomThread.thread.setName("ddj1调度线程");
|
||||
ddj1CustomThread.thread.start();
|
||||
|
||||
}
|
||||
if (ddj2CustomThread!=null){
|
||||
ddj2CustomThread.thread.setName("ddj2调度线程");
|
||||
ddj2CustomThread.thread.start();
|
||||
|
||||
}
|
||||
if (ddj3CustomThread!=null){
|
||||
ddj3CustomThread.thread.setName("ddj3调度线程");
|
||||
ddj3CustomThread.thread.start();
|
||||
|
||||
}
|
||||
if (ddj4CustomThread!=null){
|
||||
ddj4CustomThread.thread.setName("ddj4调度线程");
|
||||
ddj4CustomThread.thread.start();
|
||||
|
||||
}
|
||||
/*ddj2CustomThread.thread.start();
|
||||
ddj3CustomThread.thread.start();
|
||||
ddj4CustomThread.thread.start();
|
||||
if (ddj5CustomThread!=null){
|
||||
ddj5CustomThread.thread.setName("ddj5调度线程");
|
||||
ddj5CustomThread.thread.start();
|
||||
ddj6CustomThread.thread.start();*/
|
||||
|
||||
}
|
||||
if (ddj6CustomThread!=null){
|
||||
ddj6CustomThread.thread.setName("ddj6调度线程");
|
||||
ddj6CustomThread.thread.start();
|
||||
|
||||
}
|
||||
isRun2 = true;
|
||||
}
|
||||
|
||||
@@ -224,11 +248,15 @@ 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;
|
||||
}
|
||||
@@ -239,8 +267,18 @@ 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;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ public class PlcDdjRead extends Thread {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
int i = 0;
|
||||
while (isRun) {
|
||||
try {
|
||||
if (IsConnect()) {
|
||||
@@ -45,9 +46,13 @@ public class PlcDdjRead extends Thread {
|
||||
} else {
|
||||
reConnect();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
i++;
|
||||
if (i==100){
|
||||
log.info("读取线程执行正常");
|
||||
i=0;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
log.info("********IP:" + this.ip + " port:" + this.port + "端口号 " + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ public class PlcSsjRead implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
int i = 0;
|
||||
while (isRun) {
|
||||
try {
|
||||
if (IsConnect()) {
|
||||
@@ -72,11 +73,13 @@ public class PlcSsjRead implements Runnable {
|
||||
} else {
|
||||
reConnect();
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
// 捕获中断异常,退出循环
|
||||
Thread.currentThread().interrupt(); // 重新设置中断标志
|
||||
return;
|
||||
i++;
|
||||
if (i==100){
|
||||
log.info("读取线程执行正常");
|
||||
i=0;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
log.info("********IP:" + this.ip + " port:" + this.port + "读取数据异常 " + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ import com.ruoyi.bas.cargospace.service.IBasCargoSpaceService;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.domain.SendData;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.cz.domain.SsjWeightInfo;
|
||||
import com.ruoyi.device.cz.service.ISsjWeightInfoService;
|
||||
import com.ruoyi.device.ddj.domain.MsgDdj;
|
||||
import com.ruoyi.device.ddj.service.IMsgDdjService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
@@ -46,6 +48,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
private IMsgDdjService msgDdjService;
|
||||
private IMydoJobService mydoJobService;
|
||||
private IBasCargoSpaceService basCargoSpaceService;
|
||||
private ISsjWeightInfoService ssjWeightInfoService;
|
||||
public Map<String, List<Integer>> roadwayMap = new HashMap<>();
|
||||
private PlcDdjRead plcDdjRead;
|
||||
private PlcSsjRead plcSsjRead;
|
||||
@@ -78,37 +81,42 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
basCargoSpaceService = SpringUtils.getBean(IBasCargoSpaceService.class);
|
||||
msgDdjService = SpringUtils.getBean(IMsgDdjService.class);
|
||||
mydoJobService = SpringUtils.getBean(IMydoJobService.class);
|
||||
ssjWeightInfoService = SpringUtils.getBean(ISsjWeightInfoService.class);
|
||||
log.info("初始化服务 {},{},{},{}", apiService, ddjDeviceExecutionQueueService, ddjDeviceExecutionQueueFinishService, mydoJobService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
int i = 0;
|
||||
while (isRun) {
|
||||
try {
|
||||
for (String type : ddjCodeList.keySet()) {
|
||||
|
||||
for (String ddjCode : ddjCodeList.get(type)) {
|
||||
MsgDdj msgDdj = PlcDdjRead.deviceDdjMap.get(ddjCode);
|
||||
try {
|
||||
if (ObjUtil.isNotNull(msgDdj)) {
|
||||
generateInBoundPickQueue(msgDdj);
|
||||
generateInBoundLoadQueue(msgDdj);
|
||||
generateOutBoundQueue(msgDdj);
|
||||
setOutSsjStatus(msgDdj);
|
||||
ddjTask(msgDdj);
|
||||
|
||||
} else {
|
||||
log.error("堆垛机设备为空");
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
try {
|
||||
i++;
|
||||
if (i == 100) {
|
||||
log.info("ddj{},循环完成", ddjCodeList);
|
||||
i = 0;
|
||||
}
|
||||
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,14 +158,14 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
switch (exitId) {
|
||||
case "1":
|
||||
List<DeviceSsj> outSsj1 = getDeviceSsjs("outSsj1");
|
||||
if (outSsj1.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() == 0 )) {
|
||||
if (outSsj1.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() == 0 && ddj.getHczt() == 0 && ddj.getYxxf()==1)) {
|
||||
outSsj = outSsj1.get(0).getDeviceCode();
|
||||
if (StrUtil.isNotEmpty(outSsj)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<DeviceSsj> outSsj2 = getDeviceSsjs("outSsj2");
|
||||
if (outSsj2.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() == 0 )) {
|
||||
if (outSsj2.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() == 0 && ddj.getHczt() == 0 && ddj.getYxxf()==1)) {
|
||||
outSsj = outSsj2.get(0).getDeviceCode();
|
||||
if (StrUtil.isNotEmpty(outSsj)) {
|
||||
break;
|
||||
@@ -166,14 +174,14 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
break;
|
||||
case "2":
|
||||
List<DeviceSsj> outSsj3 = getDeviceSsjs("outSsj3");
|
||||
if (outSsj3.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() == 0 )) {
|
||||
if (outSsj3.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() == 0 && ddj.getHczt() == 0 && ddj.getYxxf()==1)) {
|
||||
outSsj = outSsj3.get(0).getDeviceCode();
|
||||
if (StrUtil.isNotEmpty(outSsj)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<DeviceSsj> outSsj4 = getDeviceSsjs("outSsj4");
|
||||
if (outSsj4.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() == 0)) {
|
||||
if (outSsj4.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() == 0 && ddj.getHczt() == 0 && ddj.getYxxf()==1)) {
|
||||
outSsj = outSsj4.get(0).getDeviceCode();
|
||||
if (StrUtil.isNotEmpty(outSsj)) {
|
||||
break;
|
||||
@@ -419,13 +427,18 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
int rkqq = ssj.getRkqq();
|
||||
if (taskNo > 0 && rkqq == 1) {
|
||||
//log.info("取货任务 任务号{}",taskNo);
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(taskNo), ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
//todo 连接称重 并保存数据
|
||||
String czDeviceIpPort = czRoadwayMap.get(ssj.getDeviceCode());
|
||||
String[] split = czDeviceIpPort.split(":");
|
||||
String weight = CheckWeight.sendWeight(split[0], Convert.toInt(split[1]));
|
||||
Double aDouble = Convert.toDouble(weight);
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(taskNo), ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
if (aDouble<40){
|
||||
aDouble = 40d;
|
||||
}
|
||||
SsjWeightInfo ssjWeightInfo = ssjWeightInfoService.selectWeightBySsjCodeAndRwh(taskNo, ssj.getDeviceCode());
|
||||
aDouble = ssjWeightInfo.getWeight().doubleValue();
|
||||
log.info("取货任务 ddj:{} 任务号:{} 重量:{}",ddj.getId(),taskNo,aDouble);
|
||||
if (aDouble > 0 && aDouble < 1500) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
@@ -446,7 +459,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
ddjDeviceExecutionQueue.setScsj(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
ddjDeviceExecutionQueue.setMlfs(3);
|
||||
ddjDeviceExecutionQueue.setSpare1("0");
|
||||
ddjDeviceExecutionQueue.setSpare3(Convert.toStr(weight));
|
||||
ddjDeviceExecutionQueue.setSpare3(Convert.toStr(aDouble));
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
} /*else if (aDouble>=1500) {
|
||||
//写入超重信号
|
||||
@@ -614,11 +627,17 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
|
||||
List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues1 = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueList(ddjDeviceExecutionRunningQueueParam);
|
||||
if (CollUtil.isNotEmpty(ddjDeviceExecutionQueues1)) {
|
||||
log.info("ddj:{} 正在执行任务 {}",ddj.getId(), ddjDeviceExecutionQueues1.get(0).getRwh());
|
||||
log.info("ddj:{} 已下发任务号 {} ddj当前任务号 {}",ddj.getId(), ddjDeviceExecutionQueues1.get(0).getRwh(),ddj.getRwh());
|
||||
if (!ddj.getRwh().equals(ddjDeviceExecutionQueues1.get(0).getRwh())){
|
||||
int i = issuedDDJTask(ddj, ddjDeviceExecutionQueues1.get(0));
|
||||
if (i == 1) {
|
||||
log.info("ddj:{} 重新下发任务 {}",ddj.getId(), ddjDeviceExecutionQueues1.get(0).getRwh());
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (ddj.getSbzt() == 0 && ddj.getHczt() == 0) {
|
||||
if (ddj.getHczt() == 0) {
|
||||
//无货待机 只查询入库取货扫码或者出库队列
|
||||
ArrayList<Integer> rwlxList = new ArrayList<>();
|
||||
rwlxList.add(DDJ_RWLX_1);
|
||||
@@ -652,7 +671,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
log.error("托盘堆垛机下发任务失败!!!!!!!ddj:{} rwh:{}",ddj.getId(), ddjDeviceExecutionQueue.getRwh());
|
||||
}
|
||||
}
|
||||
} else if ((ddj.getSbzt() == 0 || ddj.getSbzt()==1047) && ddj.getHczt() == 1) {
|
||||
} else if (ddj.getHczt() == 1) {
|
||||
//有货待机 只查询入库放货队列和 无任务 未扫码回滚 队列
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueueParam = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueueParam.setDdjxf("0");
|
||||
|
||||
@@ -43,20 +43,32 @@ public class Ddj5Thread extends BaseDdjThread {
|
||||
ssjList.put("outSsj2", outSsj2);
|
||||
|
||||
//初始化巷道口 排 列 层
|
||||
roadwayMap.put("L1003", Arrays.asList(1, 1, 1));
|
||||
roadwayMap.put("L1004", Arrays.asList(2, 1, 1));
|
||||
roadwayMap.put("L1003", Arrays.asList(1, 0, 1));
|
||||
roadwayMap.put("L1004", Arrays.asList(2, 0, 1));
|
||||
//未扫码 回退任务号 无入库任务在此基础+100
|
||||
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_02);
|
||||
paramMap.put("roadwayId",ROADWAY_ID_05);
|
||||
paramMap.put("height",height);
|
||||
paramMap.put("weight",weight);
|
||||
return paramMap;
|
||||
@@ -66,7 +78,7 @@ public class Ddj5Thread extends BaseDdjThread {
|
||||
public MydoJob getOutJobParam() {
|
||||
MydoJob mydoJob = new MydoJob();
|
||||
mydoJob.setWarehouseId(WAREHOUSE_02);
|
||||
mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_02));
|
||||
mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_05));
|
||||
mydoJob.setStatus("1");
|
||||
|
||||
return mydoJob;
|
||||
|
||||
@@ -43,11 +43,22 @@ public class Ddj6Thread extends BaseDdjThread {
|
||||
ssjList.put("outSsj2", outSsj2);
|
||||
|
||||
//初始化巷道口 排 列 层
|
||||
roadwayMap.put("L1005", Arrays.asList(1, 1, 1));
|
||||
roadwayMap.put("L1006", Arrays.asList(2, 1, 1));
|
||||
roadwayMap.put("L1005", Arrays.asList(1, 0, 1));
|
||||
roadwayMap.put("L1006", Arrays.asList(2, 0, 1));
|
||||
//未扫码 回退任务号 无入库任务在此基础+100
|
||||
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");
|
||||
}
|
||||
|
||||
@@ -57,10 +68,9 @@ 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_03);
|
||||
paramMap.put("roadwayId",ROADWAY_ID_06);
|
||||
paramMap.put("height",height);
|
||||
paramMap.put("weight",weight);
|
||||
|
||||
return paramMap;
|
||||
}
|
||||
|
||||
@@ -68,7 +78,7 @@ public class Ddj6Thread extends BaseDdjThread {
|
||||
public MydoJob getOutJobParam() {
|
||||
MydoJob mydoJob = new MydoJob();
|
||||
mydoJob.setWarehouseId(WAREHOUSE_02);
|
||||
mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_03));
|
||||
mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_06));
|
||||
mydoJob.setStatus("1");
|
||||
|
||||
return mydoJob;
|
||||
@@ -86,4 +96,5 @@ public class Ddj6Thread extends BaseDdjThread {
|
||||
return "1";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -45,15 +45,18 @@ public class MonitoringThread implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
int i =0;
|
||||
while (isRun){
|
||||
try {
|
||||
|
||||
for (String ssjCode : PlcSsjRead.deviceSsjMap.keySet()) {
|
||||
try {
|
||||
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) {
|
||||
if (deviceSsj.getException() >= 101 && deviceSsj.getException() <= 120 && deviceSsj.getTaskNo()>0) {
|
||||
BasFaultRecord param = new BasFaultRecord();
|
||||
param.setTaskNo(Convert.toStr(deviceSsj.getTaskNo()));
|
||||
param.setDeviceId(Convert.toStr(deviceSsj.getDeviceCode()));
|
||||
@@ -150,8 +153,13 @@ public class MonitoringThread implements Runnable {
|
||||
basFaultRecordService.updateBasFaultRecord(record);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
}
|
||||
for (String ddjCode : PlcDdjRead.deviceDdjMap.keySet()) {
|
||||
try {
|
||||
MsgDdj msgDdj = PlcDdjRead.deviceDdjMap.get(ddjCode);
|
||||
msgDdjService.updateMsgDdj(msgDdj);
|
||||
//记录异常
|
||||
@@ -190,8 +198,16 @@ public class MonitoringThread implements Runnable {
|
||||
basFaultRecordService.updateBasFaultRecord(record);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
}
|
||||
i++;
|
||||
if (i==100){
|
||||
log.info("监控线程循环完成");
|
||||
i=0;
|
||||
}
|
||||
Thread.sleep(1500);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
@@ -214,7 +230,13 @@ public class MonitoringThread implements Runnable {
|
||||
return "超高";
|
||||
} else if (value == 106) {
|
||||
return "超重";
|
||||
} else {
|
||||
} else if (value==112){
|
||||
return "输送超时";
|
||||
}else if (value==113){
|
||||
return "变频器报警";
|
||||
}else if (value==114){
|
||||
return "开关异常";
|
||||
}else {
|
||||
return "未知";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
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.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -13,88 +13,88 @@ import java.util.Map;
|
||||
public class CheckWeight {
|
||||
|
||||
public static String sendWeight(String ip, int por) {
|
||||
|
||||
String zhi = "0";
|
||||
try (
|
||||
Socket socket = new Socket(ip, por);
|
||||
InputStream is = socket.getInputStream();
|
||||
) {
|
||||
Thread.sleep(1000);
|
||||
byte[] bytes = new byte[100];
|
||||
Socket socket = null;
|
||||
InputStream is = null;
|
||||
try {
|
||||
socket = new Socket();
|
||||
socket.connect(new InetSocketAddress(ip, por), 1000);
|
||||
socket.setSoTimeout(10000);
|
||||
is = socket.getInputStream();
|
||||
|
||||
byte[] clearBuf = new byte[4096];
|
||||
long endClearTime = System.currentTimeMillis() + 800;
|
||||
while (System.currentTimeMillis() < endClearTime) {
|
||||
if (is.available() > 0) {
|
||||
is.read(clearBuf);
|
||||
} else {
|
||||
Thread.sleep(50);
|
||||
}
|
||||
}
|
||||
|
||||
Thread.sleep(200);
|
||||
byte[] bytes = new byte[256];
|
||||
int read = is.read(bytes);
|
||||
if (read!=-1){
|
||||
if (read != -1) {
|
||||
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 != null) {
|
||||
weight = weight.replace("=", "").replace("\r", "").replace("\n", "");
|
||||
if (!weight.equals("0000000")) {
|
||||
zhi = weight;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
// finally手动关闭流和socket
|
||||
try {
|
||||
if (is != null) {
|
||||
is.close();
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
ignored.printStackTrace();
|
||||
}
|
||||
try {
|
||||
if (socket != null) {
|
||||
socket.close();
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
ignored.printStackTrace();
|
||||
}
|
||||
}
|
||||
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数组
|
||||
* @param charset 字符编码(如UTF-8、GBK、ASCII)
|
||||
* @return 转换后的char数组
|
||||
* @throws UnsupportedEncodingException 编码不支持时抛出
|
||||
*/
|
||||
public static String byteArrayToCharArray(byte[] byteArr, String charset) throws UnsupportedEncodingException {
|
||||
if (byteArr == null) {
|
||||
return null;
|
||||
}
|
||||
// 核心:先将byte数组按指定编码转为String,再转为char数组
|
||||
return new String(byteArr, charset);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
CheckWeight checkWeight = new CheckWeight();
|
||||
while (true){
|
||||
System.out.println(checkWeight.sendWeight("172.19.50.80", 4001));
|
||||
|
||||
}
|
||||
System.out.println(sendWeight("172.19.50.75", 4001));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ spring:
|
||||
druid:
|
||||
#主数据信息
|
||||
master:
|
||||
url: jdbc:sqlserver://172.19.1.119:1433;databaseName=FT541-wcs-2;
|
||||
url: jdbc:sqlserver://172.19.1.119:1433;databaseName=FT541-wcs;
|
||||
# url: jdbc:sqlserver://172.19.1.119:1433;databaseName=FT541-wcs-2;
|
||||
username: sa
|
||||
password: Flrd0914.
|
||||
# 从库数据源
|
||||
|
||||
@@ -249,5 +249,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and status = #{status}
|
||||
and roadway_id = #{roadwayId}
|
||||
and warehouse_id = #{warehouseId}
|
||||
order by priority desc,create_time asc
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -84,10 +84,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectDdjDeviceExecutionQueueVo"/>
|
||||
where rwh = #{rwh} and dev_id = #{devId}
|
||||
</select>
|
||||
|
||||
<select id="selectOutJobCount">
|
||||
select count(*) from ddj_device_execution_queue
|
||||
where spare2=#{spare2}
|
||||
<select id="selectOutJobCount" resultType="java.lang.Integer">
|
||||
select count(*)
|
||||
from ddj_device_execution_queue
|
||||
where spare2 = #{spare2}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user