现场修改
This commit is contained in:
@@ -165,6 +165,10 @@ public class ScheduleThread {
|
||||
if (plcDdj1ReadCustomThread!=null){
|
||||
plcDdj1ReadCustomThread.getThread().start();
|
||||
|
||||
}
|
||||
if (plcDdj2ReadCustomThread!=null){
|
||||
plcDdj2ReadCustomThread.getThread().start();
|
||||
|
||||
}
|
||||
if (plcDdj4ReadCustomThread!=null){
|
||||
plcDdj4ReadCustomThread.getThread().start();
|
||||
@@ -186,6 +190,10 @@ public class ScheduleThread {
|
||||
if (ddj1CustomThread!=null){
|
||||
ddj1CustomThread.thread.start();
|
||||
|
||||
}
|
||||
if (ddj2CustomThread!=null){
|
||||
ddj2CustomThread.thread.start();
|
||||
|
||||
}
|
||||
if (ddj4CustomThread!=null){
|
||||
ddj4CustomThread.thread.start();
|
||||
|
||||
@@ -125,7 +125,7 @@ public class PlcDdjRead extends Thread {
|
||||
}
|
||||
|
||||
void closeServer() {
|
||||
if (readWriteNet != null) {
|
||||
if (siemensS7Net != null) {
|
||||
siemensS7Net.ConnectClose();
|
||||
}
|
||||
setIsConnect(false);
|
||||
|
||||
@@ -150,8 +150,8 @@ public class PlcSsjRead implements Runnable {
|
||||
}
|
||||
|
||||
void closeServer() {
|
||||
if (readWriteNet != null) {
|
||||
readWriteNet.ConnectClose();
|
||||
if (siemensS7Net != null) {
|
||||
siemensS7Net.ConnectClose();
|
||||
}
|
||||
setIsConnect(false);
|
||||
}
|
||||
|
||||
@@ -48,10 +48,15 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
public Map<String, List<Integer>> roadwayMap = new HashMap<>();
|
||||
private PlcDdjRead plcDdjRead;
|
||||
private PlcSsjRead plcSsjRead;
|
||||
|
||||
//称重 ip port
|
||||
public Map<String, String> czRoadwayMap = new HashMap<>();
|
||||
|
||||
public BaseDdjThread(PlcDdjRead plcDdjRead,PlcSsjRead plcSsjRead) {
|
||||
//超重DB块
|
||||
public Map<String, String> czOverMap = new HashMap<>();
|
||||
//出库任务信号DB块
|
||||
public Map<String, String> outJobMap = new HashMap<>();
|
||||
|
||||
public BaseDdjThread(PlcDdjRead plcDdjRead, PlcSsjRead plcSsjRead) {
|
||||
this.plcDdjRead = plcDdjRead;
|
||||
this.plcSsjRead = plcSsjRead;
|
||||
}
|
||||
@@ -112,11 +117,11 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
Long rwh = msgDdj.getRwh();
|
||||
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, msgDdj.getId());
|
||||
if (ddjDeviceExecutionQueue !=null && ddjDeviceExecutionQueue.getDdjxf().equals("1") && (ddjDeviceExecutionQueue.getRwlx().equals(DDJ_RWLX_3)||ddjDeviceExecutionQueue.getRwlx().equals(DDJ_RWLX_4))){
|
||||
DeviceSsj deviceSsj = PlcSsjRead.deviceSsjMap.get(ddjDeviceExecutionQueue.getSpare2());
|
||||
SendData by1 = new SendData(Tools.INT,1);
|
||||
if (ddjDeviceExecutionQueue != null && ddjDeviceExecutionQueue.getDdjxf().equals("1") && (ddjDeviceExecutionQueue.getRwlx().equals(DDJ_RWLX_3) || ddjDeviceExecutionQueue.getRwlx().equals(DDJ_RWLX_4))) {
|
||||
SendData by1 = new SendData(Tools.INT, 1);
|
||||
byte[] sendData = Tools.sendData(by1);
|
||||
plcSsjRead.writeToSsJ(deviceSsj.getPlcDbWriteAddress(),sendData);
|
||||
String dbWrite = outJobMap.get(ddjDeviceExecutionQueue.getSpare2());
|
||||
plcSsjRead.writeToSsJ(dbWrite, sendData);
|
||||
}//else if (ddjDeviceExecutionQueue !=null){
|
||||
// DeviceSsj deviceSsj = PlcSsjRead.deviceSsjMap.get(ddjDeviceExecutionQueue.getSpare2());
|
||||
// SendData by1 = new SendData(Tools.INT,0);
|
||||
@@ -137,17 +142,17 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
String outSsj = "";
|
||||
switch (exitId) {
|
||||
case "1":
|
||||
List<DeviceSsj> outSsj1 = getDeviceSsjs("outSsj1");
|
||||
List<DeviceSsj> outSsj1 = getDeviceSsjs("outSsj1");
|
||||
if (outSsj1.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() == 0 && ddj.getHczt() == 0 && ddj.getSbzt() == 0)) {
|
||||
outSsj = outSsj1.get(0).getDeviceCode();
|
||||
if (StrUtil.isNotEmpty(outSsj) ) {
|
||||
if (StrUtil.isNotEmpty(outSsj)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<DeviceSsj> outSsj2 = getDeviceSsjs("outSsj2");
|
||||
if (outSsj2.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() == 0 && ddj.getHczt() == 0 && ddj.getSbzt() == 0)) {
|
||||
outSsj = outSsj2.get(0).getDeviceCode();
|
||||
if (StrUtil.isNotEmpty(outSsj) ) {
|
||||
if (StrUtil.isNotEmpty(outSsj)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -156,14 +161,14 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
List<DeviceSsj> outSsj3 = getDeviceSsjs("outSsj3");
|
||||
if (outSsj3.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() == 0 && ddj.getYxxf() == 1 && ddj.getHczt() == 0 && ddj.getSbzt() == 0)) {
|
||||
outSsj = outSsj3.get(0).getDeviceCode();
|
||||
if (StrUtil.isNotEmpty(outSsj) ) {
|
||||
if (StrUtil.isNotEmpty(outSsj)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
List<DeviceSsj> outSsj4 = getDeviceSsjs("outSsj4");
|
||||
if (outSsj4.stream().allMatch(ssj -> ssj.getKx() == 1 && ssj.getTaskNo() == 0 && ddj.getYxxf() == 1 && ddj.getHczt() == 0 && ddj.getSbzt() == 0)) {
|
||||
outSsj = outSsj4.get(0).getDeviceCode();
|
||||
if (StrUtil.isNotEmpty(outSsj) ) {
|
||||
if (StrUtil.isNotEmpty(outSsj)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -175,7 +180,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
if ("0".equals(outJob.getExecutionPhase()) && StrUtil.isNotEmpty(outSsj)) {
|
||||
int ssjJobCount = ddjDeviceExecutionQueueService.selectOutJobCount(getOtherOutDdjQueue(outSsj));
|
||||
|
||||
if (ssjJobCount==0){
|
||||
if (ssjJobCount == 0) {
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(outJob.getTaskNo()), ddj.getId());
|
||||
//查询这个站点是否存在任务
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
@@ -382,30 +387,51 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
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(ssj.getTaskNo()), ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue) && aDouble > 0) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueue.setUuid(IdUtil.simpleUUID());
|
||||
ddjDeviceExecutionQueue.setRwh(Convert.toLong(ssj.getTaskNo()));
|
||||
ddjDeviceExecutionQueue.setDevName(ddj.getName());
|
||||
ddjDeviceExecutionQueue.setDevId(ddj.getId());
|
||||
ddjDeviceExecutionQueue.setRwzt(0);
|
||||
ddjDeviceExecutionQueue.setMbph(1);
|
||||
ddjDeviceExecutionQueue.setMblh(1);
|
||||
ddjDeviceExecutionQueue.setMbch(1);
|
||||
List<Integer> integers = roadwayMap.get(ssj.getDeviceCode());
|
||||
ddjDeviceExecutionQueue.setYph(integers.get(0));
|
||||
ddjDeviceExecutionQueue.setYlh(integers.get(1));
|
||||
ddjDeviceExecutionQueue.setYch(integers.get(2));
|
||||
ddjDeviceExecutionQueue.setDdjxf("0");
|
||||
ddjDeviceExecutionQueue.setRwlx(DDJ_RWLX_1);
|
||||
ddjDeviceExecutionQueue.setScsj(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
ddjDeviceExecutionQueue.setMlfs(3);
|
||||
ddjDeviceExecutionQueue.setSpare1("0");
|
||||
ddjDeviceExecutionQueue.setSpare3(Convert.toStr(weight));
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(taskNo), ddj.getId());
|
||||
if (ObjUtil.isNull(ddjQueue)) {
|
||||
if (aDouble > 0 && aDouble < 1500) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionQueue.setUuid(IdUtil.simpleUUID());
|
||||
ddjDeviceExecutionQueue.setRwh(Convert.toLong(ssj.getTaskNo()));
|
||||
ddjDeviceExecutionQueue.setDevName(ddj.getName());
|
||||
ddjDeviceExecutionQueue.setDevId(ddj.getId());
|
||||
ddjDeviceExecutionQueue.setRwzt(0);
|
||||
ddjDeviceExecutionQueue.setMbph(1);
|
||||
ddjDeviceExecutionQueue.setMblh(1);
|
||||
ddjDeviceExecutionQueue.setMbch(1);
|
||||
List<Integer> integers = roadwayMap.get(ssj.getDeviceCode());
|
||||
ddjDeviceExecutionQueue.setYph(integers.get(0));
|
||||
ddjDeviceExecutionQueue.setYlh(integers.get(1));
|
||||
ddjDeviceExecutionQueue.setYch(integers.get(2));
|
||||
ddjDeviceExecutionQueue.setDdjxf("0");
|
||||
ddjDeviceExecutionQueue.setRwlx(DDJ_RWLX_1);
|
||||
ddjDeviceExecutionQueue.setScsj(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||
ddjDeviceExecutionQueue.setMlfs(3);
|
||||
ddjDeviceExecutionQueue.setSpare1("0");
|
||||
ddjDeviceExecutionQueue.setSpare3(Convert.toStr(weight));
|
||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||
} /*else if (aDouble>=1500) {
|
||||
//写入超重信号
|
||||
SendData by1 = new SendData(Tools.INT,1);
|
||||
byte[] sendData = Tools.sendData(by1);
|
||||
String dbWrite = czOverMap.get(ssj.getDeviceCode());
|
||||
int i = plcSsjRead.writeToSsJ(dbWrite, sendData);
|
||||
if (i==1){
|
||||
log.info("写入 设备:{} 超重信号DB块:{}",ssj.getDeviceCode(),dbWrite);
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
||||
}/*else {
|
||||
//写入超重默认信号 0
|
||||
SendData by1 = new SendData(Tools.INT,0);
|
||||
byte[] sendData = Tools.sendData(by1);
|
||||
String dbWrite = czOverMap.get(ssj.getDeviceCode());
|
||||
int i = plcSsjRead.writeToSsJ(dbWrite, sendData);
|
||||
if (i==1){
|
||||
log.info("写入 设备:{} 默认信号DB块:{}",ssj.getDeviceCode(),dbWrite);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,9 +456,8 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
} else if (ddjDeviceExecutionQueue.getRwlx() == 4) {
|
||||
ddjTaskFinish(rwh, ddj.getId(), 2);
|
||||
} else if (ddjDeviceExecutionQueue.getRwlx() == 1) {
|
||||
if (hczt==0){
|
||||
//回传完成信号
|
||||
ddjTaskFinish(rwh, ddj.getId(), 2);
|
||||
if (hczt == 0) {
|
||||
ddjTaskFinish(ddj.getRwh(), ddj.getId(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -533,6 +558,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
if (ddj.getYxxf() == 1 && ddj.getCzfs() == 5) {
|
||||
DdjDeviceExecutionQueue ddjDeviceExecutionRunningQueueParam = new DdjDeviceExecutionQueue();
|
||||
ddjDeviceExecutionRunningQueueParam.setDdjxf("1");
|
||||
ddjDeviceExecutionRunningQueueParam.setDevId(ddj.getId());
|
||||
|
||||
List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues1 = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueList(ddjDeviceExecutionRunningQueueParam);
|
||||
if (CollUtil.isNotEmpty(ddjDeviceExecutionQueues1)) {
|
||||
@@ -638,7 +664,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
||||
public static void main(String[] args) {
|
||||
String a = "00001234";
|
||||
String b = "004567";
|
||||
System.out.println(a.substring(a.length()-4));
|
||||
System.out.println(b.substring(b.length()-4));
|
||||
System.out.println(a.substring(a.length() - 4));
|
||||
System.out.println(b.substring(b.length() - 4));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +70,16 @@ public class Ddj1Thread extends BaseDdjThread {
|
||||
czRoadwayMap.put("L2007", "172.19.50.73:4001");
|
||||
czRoadwayMap.put("L2008", "172.19.50.74:4001");
|
||||
|
||||
czOverMap.put("L2001", "DB502.12");
|
||||
czOverMap.put("L2002", "DB502.26");
|
||||
czOverMap.put("L2007", "DB502.96");
|
||||
czOverMap.put("L2008", "DB502.110");
|
||||
|
||||
outJobMap.put("L2001", "DB502.10");
|
||||
outJobMap.put("L2002", "DB502.24");
|
||||
outJobMap.put("L2007", "DB502.94");
|
||||
outJobMap.put("L2008", "DB502.108");
|
||||
|
||||
|
||||
log.info("Ddj1Thread init");
|
||||
|
||||
|
||||
@@ -25,42 +25,58 @@ public class Ddj2Thread extends BaseDdjThread {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
/*super.init();
|
||||
super.init();
|
||||
ddjCodeList = new HashMap<>();
|
||||
ssjList = new HashMap<>();
|
||||
ArrayList<MsgDdj> ddjCodes = new ArrayList<>();
|
||||
ddjCodes.add(PlcDdjRead.deviceDdjMap.get("ddj2"));
|
||||
ArrayList<String> ddjCodes = new ArrayList<>();
|
||||
ddjCodes.add("ddj2");
|
||||
ddjCodeList.put("ddj", ddjCodes);
|
||||
ArrayList<DeviceSsj> roadSsjList = new ArrayList<>();
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2003"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2004"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2009"));
|
||||
roadSsjList.add(PlcSsjRead.deviceSsjMap.get("L2010"));
|
||||
ArrayList<String> roadSsjList = new ArrayList<>();
|
||||
roadSsjList.add("L2003");
|
||||
roadSsjList.add("L2004");
|
||||
roadSsjList.add("L2009");
|
||||
roadSsjList.add("L2010");
|
||||
ssjList.put("roadSsjList", roadSsjList);
|
||||
ArrayList<DeviceSsj> outSsj1 = new ArrayList<>();
|
||||
outSsj1.add(PlcSsjRead.deviceSsjMap.get("L2003"));
|
||||
ArrayList<String> outSsj1 = new ArrayList<>();
|
||||
outSsj1.add("L2003");
|
||||
ssjList.put("outSsj1", outSsj1);
|
||||
ArrayList<DeviceSsj> outSsj2 = new ArrayList<>();
|
||||
outSsj2.add(PlcSsjRead.deviceSsjMap.get("L2004"));
|
||||
ArrayList<String> outSsj2 = new ArrayList<>();
|
||||
outSsj2.add("L2004");
|
||||
ssjList.put("outSsj2", outSsj2);
|
||||
ArrayList<DeviceSsj> outSsj3 = new ArrayList<>();
|
||||
outSsj3.add(PlcSsjRead.deviceSsjMap.get("L2009"));
|
||||
ArrayList<String> outSsj3 = new ArrayList<>();
|
||||
outSsj3.add("L2009");
|
||||
ssjList.put("outSsj3", outSsj3);
|
||||
ArrayList<DeviceSsj> outSsj4 = new ArrayList<>();
|
||||
outSsj4.add(PlcSsjRead.deviceSsjMap.get("L2010"));
|
||||
ArrayList<String> outSsj4 = new ArrayList<>();
|
||||
outSsj4.add("L2010");
|
||||
ssjList.put("outSsj4", outSsj4);
|
||||
|
||||
//初始化巷道口 排 列 层
|
||||
roadwayMap.put("L2003", Arrays.asList(3, 1, 1));
|
||||
roadwayMap.put("L2004", Arrays.asList(4, 1, 1));
|
||||
roadwayMap.put("L2009", Arrays.asList(3, 22, 1));
|
||||
roadwayMap.put("L2010", Arrays.asList(4, 22, 1));
|
||||
roadwayMap.put("L2003", Arrays.asList(1, 0, 1));
|
||||
roadwayMap.put("L2004", Arrays.asList(2, 0, 1));
|
||||
roadwayMap.put("L2009", Arrays.asList(1, 20, 1));
|
||||
roadwayMap.put("L2010", Arrays.asList(2, 20, 1));
|
||||
roadwayRollback.put("L2003", 84);
|
||||
roadwayRollback.put("L2004", 85);
|
||||
roadwayRollback.put("L2009", 86);
|
||||
roadwayRollback.put("L2010", 87);
|
||||
//初始化称重设备连接ip port
|
||||
czRoadwayMap.put("L2003", "172.19.50.75:4001");
|
||||
czRoadwayMap.put("L2004", "172.19.50.76:4001");
|
||||
czRoadwayMap.put("L2009", "172.19.50.77:4001");
|
||||
czRoadwayMap.put("L2010","172.19.50.78:4001");
|
||||
|
||||
log.info("Ddj2Thread init");*/
|
||||
czOverMap.put("L2003", "DB502.12");
|
||||
czOverMap.put("L2004", "DB502.26");
|
||||
czOverMap.put("L2009", "DB502.96");
|
||||
czOverMap.put("L2010", "DB502.110");
|
||||
|
||||
outJobMap.put("L2003", "DB502.38");
|
||||
outJobMap.put("L2004", "DB502.52");
|
||||
outJobMap.put("L2009", "DB502.122");
|
||||
outJobMap.put("L2010", "DB502.136");
|
||||
|
||||
|
||||
log.info("Ddj2Thread init");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,13 @@ public class Ddj4Thread extends BaseDdjThread {
|
||||
//初始化称重设备连接ip port
|
||||
czRoadwayMap.put("L1001", "172.19.40.203:4001");
|
||||
czRoadwayMap.put("L1002", "172.19.40.202:4001");
|
||||
|
||||
czOverMap.put("L1001", "DB502.12");
|
||||
czOverMap.put("L1002", "DB502.26");
|
||||
|
||||
outJobMap.put("L1001", "DB502.10");
|
||||
outJobMap.put("L1002", "DB502.24");
|
||||
|
||||
log.info("Ddj4Thread init");
|
||||
}
|
||||
|
||||
|
||||
@@ -50,11 +50,8 @@ public class CheckWeight {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
/*CheckWeight checkWeight = new CheckWeight();
|
||||
System.out.println(checkWeight.sendWeight("172.19.40.203", 4001));
|
||||
System.out.println(checkWeight.sendWeight("172.19.40.202", 4001));*/
|
||||
Double aDouble = Convert.toDouble("-000019");
|
||||
System.out.println(aDouble);
|
||||
CheckWeight checkWeight = new CheckWeight();
|
||||
System.out.println(checkWeight.sendWeight("172.19.50.75", 4001));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
order by scsj asc
|
||||
order by rwlx desc,scsj asc
|
||||
</select>
|
||||
|
||||
<select id="selectDdjDeviceExecutionQueueByUuid" parameterType="String" resultMap="DdjDeviceExecutionQueueResult">
|
||||
|
||||
Reference in New Issue
Block a user