Compare commits
9 Commits
7783de0cc0
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52772494d4 | ||
|
|
2272a89b2a | ||
|
|
b4ed427de9 | ||
|
|
8e60b8e9c1 | ||
|
|
f2e0c086eb | ||
|
|
c85e53ac1d | ||
|
|
9938ca3a41 | ||
|
|
2def16ad4b | ||
|
|
cdc8ae9e45 |
@@ -130,6 +130,14 @@
|
|||||||
<warName>${project.artifactId}</warName>
|
<warName>${project.artifactId}</warName>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>9</source>
|
||||||
|
<target>9</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<finalName>${project.artifactId}</finalName>
|
<finalName>${project.artifactId}</finalName>
|
||||||
</build>
|
</build>
|
||||||
|
|||||||
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,5 +17,6 @@ public class ReceiveJob {
|
|||||||
private String jobId;
|
private String jobId;
|
||||||
private String roadwayId;
|
private String roadwayId;
|
||||||
private String warehouseId;
|
private String warehouseId;
|
||||||
|
private Long priority;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,4 +127,11 @@ public interface IApiService
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AjaxResult selectMydoJobByTrayCodeAndEntranceId(HashMap<String, Object> paramMap);
|
AjaxResult selectMydoJobByTrayCodeAndEntranceId(HashMap<String, Object> paramMap);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主动获取任务
|
||||||
|
* @param jobParam
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult outMyJobXf(JobParam jobParam);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -368,6 +368,7 @@ public class ApiServiceImpl implements IApiService {
|
|||||||
mydoJob.setCreateTime(DateUtils.getNowDate());
|
mydoJob.setCreateTime(DateUtils.getNowDate());
|
||||||
mydoJob.setExecutionPhase("0");
|
mydoJob.setExecutionPhase("0");
|
||||||
mydoJob.setWarehouseId(receiveOutJob.getWarehouseId());
|
mydoJob.setWarehouseId(receiveOutJob.getWarehouseId());
|
||||||
|
mydoJob.setPriority(receiveOutJob.getPriority());
|
||||||
int i = mydoJobService.insertMydoJob(mydoJob);
|
int i = mydoJobService.insertMydoJob(mydoJob);
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
@@ -389,4 +390,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_ASSIGN_URL = WMS_BASE_URL+"reAssign";
|
||||||
public static final String RE_MATERIAL_URL = WMS_BASE_URL+"reMaterial";
|
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 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";
|
public static final String WAREHOUSE_01 = "01";
|
||||||
|
|||||||
@@ -182,41 +182,79 @@ public class MydoJobServiceImpl implements IMydoJobService
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, List<MydoJobScreen>> selectJobListByWarehouseIdAndType(String warehouseId, String type) {
|
public Map<String, List<MydoJobScreen>> selectJobListByWarehouseIdAndType(String warehouseId, String type) {
|
||||||
Map<String, List<MydoJobScreen>> map = new HashMap<>();
|
Map<String, List<MydoJobScreen>> map = new HashMap<>();
|
||||||
map.put("1",new ArrayList<>());
|
if ("01".equals(warehouseId)){
|
||||||
map.put("2",new ArrayList<>());
|
map.put("1",new ArrayList<>());
|
||||||
map.put("3",new ArrayList<>());
|
map.put("2",new ArrayList<>());
|
||||||
map.put("4",new ArrayList<>());
|
map.put("3",new ArrayList<>());
|
||||||
map.put("5",new ArrayList<>());
|
MydoJob outParam = new MydoJob();
|
||||||
map.put("6",new ArrayList<>());
|
outParam.setWarehouseId(warehouseId);
|
||||||
MydoJob outParam = new MydoJob();
|
outParam.setExitId(type);
|
||||||
outParam.setWarehouseId(warehouseId);
|
List<MydoJobScreen> outMydoJobs = mydoJobMapper.selectJobListByWarehouseIdAndType(outParam);
|
||||||
outParam.setExitId(type);
|
if (CollUtil.isNotEmpty(outMydoJobs)){
|
||||||
List<MydoJobScreen> outMydoJobs = mydoJobMapper.selectJobListByWarehouseIdAndType(outParam);
|
Map<String, List<MydoJobScreen>> collect = outMydoJobs.stream().collect(Collectors.groupingBy(MydoJobScreen::getRoadwayId));
|
||||||
if (CollUtil.isNotEmpty(outMydoJobs)){
|
for (String roadwayId : collect.keySet()) {
|
||||||
Map<String, List<MydoJobScreen>> collect = outMydoJobs.stream().collect(Collectors.groupingBy(MydoJobScreen::getRoadwayId));
|
if (map.containsKey(roadwayId)){
|
||||||
for (String roadwayId : collect.keySet()) {
|
List<MydoJobScreen> mydoJobs = map.get(roadwayId);
|
||||||
if (map.containsKey(roadwayId)){
|
mydoJobs.addAll(collect.get(roadwayId));
|
||||||
List<MydoJobScreen> mydoJobs = map.get(roadwayId);
|
map.put(roadwayId,mydoJobs);
|
||||||
mydoJobs.addAll(collect.get(roadwayId));
|
}
|
||||||
map.put(roadwayId,mydoJobs);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
MydoJob inParam = new MydoJob();
|
||||||
MydoJob inParam = new MydoJob();
|
inParam.setWarehouseId(warehouseId);
|
||||||
inParam.setWarehouseId(warehouseId);
|
inParam.setEntranceId(type);
|
||||||
inParam.setEntranceId(type);
|
List<MydoJobScreen> inMydoJobs = mydoJobMapper.selectJobListByWarehouseIdAndType(inParam);
|
||||||
List<MydoJobScreen> inMydoJobs = mydoJobMapper.selectJobListByWarehouseIdAndType(inParam);
|
if (CollUtil.isNotEmpty(inMydoJobs)) {
|
||||||
if (CollUtil.isNotEmpty(inMydoJobs)) {
|
Map<String, List<MydoJobScreen>> collect = inMydoJobs.stream().collect(Collectors.groupingBy(MydoJobScreen::getRoadwayId));
|
||||||
Map<String, List<MydoJobScreen>> collect = inMydoJobs.stream().collect(Collectors.groupingBy(MydoJobScreen::getRoadwayId));
|
for (String roadwayId : collect.keySet()) {
|
||||||
for (String roadwayId : collect.keySet()) {
|
if (map.containsKey(roadwayId)){
|
||||||
if (map.containsKey(roadwayId)){
|
List<MydoJobScreen> mydoJobs = map.get(roadwayId);
|
||||||
List<MydoJobScreen> mydoJobs = map.get(roadwayId);
|
mydoJobs.addAll(collect.get(roadwayId));
|
||||||
mydoJobs.addAll(collect.get(roadwayId));
|
map.put(roadwayId,mydoJobs);
|
||||||
map.put(roadwayId,mydoJobs);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return map;
|
||||||
|
}else {
|
||||||
|
map.put("1",new ArrayList<>());
|
||||||
|
map.put("2",new ArrayList<>());
|
||||||
|
map.put("3",new ArrayList<>());
|
||||||
|
map.put("4",new ArrayList<>());
|
||||||
|
map.put("5",new ArrayList<>());
|
||||||
|
map.put("6",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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.put("1",map.get("4"));
|
||||||
|
map.put("2",map.get("5"));
|
||||||
|
map.put("3",map.get("6"));
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
return map;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -161,32 +161,40 @@ public class ScheduleThread {
|
|||||||
* 开始线程
|
* 开始线程
|
||||||
*/
|
*/
|
||||||
public void startAllThread() {
|
public void startAllThread() {
|
||||||
plcSsjReadCustomThread.getThread().start();
|
if (plcSsjReadCustomThread !=null){
|
||||||
|
plcSsjReadCustomThread.getThread().setName("输送机读取线程");
|
||||||
|
plcSsjReadCustomThread.getThread().start();
|
||||||
|
}
|
||||||
if (plcDdj1ReadCustomThread!=null){
|
if (plcDdj1ReadCustomThread!=null){
|
||||||
|
plcDdj1ReadCustomThread.getThread().setName("ddj1读取线程");
|
||||||
plcDdj1ReadCustomThread.getThread().start();
|
plcDdj1ReadCustomThread.getThread().start();
|
||||||
|
|
||||||
}
|
}
|
||||||
if (plcDdj2ReadCustomThread!=null){
|
if (plcDdj2ReadCustomThread!=null){
|
||||||
|
plcDdj2ReadCustomThread.getThread().setName("ddj2读取线程");
|
||||||
plcDdj2ReadCustomThread.getThread().start();
|
plcDdj2ReadCustomThread.getThread().start();
|
||||||
|
|
||||||
}
|
}
|
||||||
if (plcDdj3ReadCustomThread!=null){
|
if (plcDdj3ReadCustomThread!=null){
|
||||||
|
plcDdj3ReadCustomThread.getThread().setName("ddj3读取线程");
|
||||||
plcDdj3ReadCustomThread.getThread().start();
|
plcDdj3ReadCustomThread.getThread().start();
|
||||||
|
|
||||||
}
|
}
|
||||||
if (plcDdj4ReadCustomThread!=null){
|
if (plcDdj4ReadCustomThread!=null){
|
||||||
|
plcDdj4ReadCustomThread.getThread().setName("ddj4读取线程");
|
||||||
plcDdj4ReadCustomThread.getThread().start();
|
plcDdj4ReadCustomThread.getThread().start();
|
||||||
|
|
||||||
}
|
}
|
||||||
if (plcDdj5ReadCustomThread!=null){
|
if (plcDdj5ReadCustomThread!=null){
|
||||||
|
plcDdj5ReadCustomThread.getThread().setName("ddj5读取线程");
|
||||||
plcDdj5ReadCustomThread.getThread().start();
|
plcDdj5ReadCustomThread.getThread().start();
|
||||||
|
|
||||||
}
|
}
|
||||||
/*plcDdj2ReadCustomThread.getThread().start();
|
if (plcDdj6ReadCustomThread!=null){
|
||||||
plcDdj3ReadCustomThread.getThread().start();
|
plcDdj6ReadCustomThread.getThread().setName("ddj6读取线程");
|
||||||
plcDdj4ReadCustomThread.getThread().start();
|
plcDdj6ReadCustomThread.getThread().start();
|
||||||
plcDdj5ReadCustomThread.getThread().start();
|
|
||||||
plcDdj6ReadCustomThread.getThread().start();*/
|
}
|
||||||
isRun = true;
|
isRun = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,32 +202,40 @@ public class ScheduleThread {
|
|||||||
* 开启线程2
|
* 开启线程2
|
||||||
*/
|
*/
|
||||||
public void startAllThread2() {
|
public void startAllThread2() {
|
||||||
monitoringCustomThread.thread.start();
|
if (monitoringCustomThread!=null){
|
||||||
|
monitoringCustomThread.thread.setName("监控线程");
|
||||||
|
monitoringCustomThread.thread.start();
|
||||||
|
}
|
||||||
if (ddj1CustomThread!=null){
|
if (ddj1CustomThread!=null){
|
||||||
|
ddj1CustomThread.thread.setName("ddj1调度线程");
|
||||||
ddj1CustomThread.thread.start();
|
ddj1CustomThread.thread.start();
|
||||||
|
|
||||||
}
|
}
|
||||||
if (ddj2CustomThread!=null){
|
if (ddj2CustomThread!=null){
|
||||||
|
ddj2CustomThread.thread.setName("ddj2调度线程");
|
||||||
ddj2CustomThread.thread.start();
|
ddj2CustomThread.thread.start();
|
||||||
|
|
||||||
}
|
}
|
||||||
if (ddj3CustomThread!=null){
|
if (ddj3CustomThread!=null){
|
||||||
|
ddj3CustomThread.thread.setName("ddj3调度线程");
|
||||||
ddj3CustomThread.thread.start();
|
ddj3CustomThread.thread.start();
|
||||||
|
|
||||||
}
|
}
|
||||||
if (ddj4CustomThread!=null){
|
if (ddj4CustomThread!=null){
|
||||||
|
ddj4CustomThread.thread.setName("ddj4调度线程");
|
||||||
ddj4CustomThread.thread.start();
|
ddj4CustomThread.thread.start();
|
||||||
|
|
||||||
}
|
}
|
||||||
if (ddj5CustomThread!=null){
|
if (ddj5CustomThread!=null){
|
||||||
|
ddj5CustomThread.thread.setName("ddj5调度线程");
|
||||||
ddj5CustomThread.thread.start();
|
ddj5CustomThread.thread.start();
|
||||||
|
|
||||||
}
|
}
|
||||||
/*ddj2CustomThread.thread.start();
|
if (ddj6CustomThread!=null){
|
||||||
ddj3CustomThread.thread.start();
|
ddj6CustomThread.thread.setName("ddj6调度线程");
|
||||||
ddj4CustomThread.thread.start();
|
ddj6CustomThread.thread.start();
|
||||||
ddj5CustomThread.thread.start();
|
|
||||||
ddj6CustomThread.thread.start();*/
|
}
|
||||||
isRun2 = true;
|
isRun2 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,11 +248,15 @@ public class ScheduleThread {
|
|||||||
plcDdj1ReadCustomThread.runnable.isRun = false;
|
plcDdj1ReadCustomThread.runnable.isRun = false;
|
||||||
plcDdj1ReadCustomThread.thread.interrupt();
|
plcDdj1ReadCustomThread.thread.interrupt();
|
||||||
plcDdj2ReadCustomThread.runnable.isRun = false;
|
plcDdj2ReadCustomThread.runnable.isRun = false;
|
||||||
|
plcDdj2ReadCustomThread.thread.interrupt();
|
||||||
plcDdj3ReadCustomThread.runnable.isRun = false;
|
plcDdj3ReadCustomThread.runnable.isRun = false;
|
||||||
|
plcDdj3ReadCustomThread.thread.interrupt();
|
||||||
plcDdj4ReadCustomThread.runnable.isRun = false;
|
plcDdj4ReadCustomThread.runnable.isRun = false;
|
||||||
plcDdj4ReadCustomThread.thread.interrupt();
|
plcDdj4ReadCustomThread.thread.interrupt();
|
||||||
plcDdj5ReadCustomThread.runnable.isRun = false;
|
plcDdj5ReadCustomThread.runnable.isRun = false;
|
||||||
|
plcDdj5ReadCustomThread.thread.interrupt();
|
||||||
plcDdj6ReadCustomThread.runnable.isRun = false;
|
plcDdj6ReadCustomThread.runnable.isRun = false;
|
||||||
|
plcDdj6ReadCustomThread.thread.interrupt();
|
||||||
plcReadInit();
|
plcReadInit();
|
||||||
isRun = false;
|
isRun = false;
|
||||||
}
|
}
|
||||||
@@ -247,8 +267,18 @@ public class ScheduleThread {
|
|||||||
public void stopAllThread2() {
|
public void stopAllThread2() {
|
||||||
monitoringCustomThread.runnable.isRun = false;
|
monitoringCustomThread.runnable.isRun = false;
|
||||||
monitoringCustomThread.thread.interrupt();
|
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.runnable.isRun = false;
|
||||||
ddj4CustomThread.thread.interrupt();
|
ddj4CustomThread.thread.interrupt();
|
||||||
|
ddj5CustomThread.runnable.isRun = false;
|
||||||
|
ddj5CustomThread.thread.interrupt();
|
||||||
|
ddj6CustomThread.runnable.isRun = false;
|
||||||
|
ddj6CustomThread.thread.interrupt();
|
||||||
scheduleInit();
|
scheduleInit();
|
||||||
isRun2 = false;
|
isRun2 = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ public class PlcDdjRead extends Thread {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
int i = 0;
|
||||||
while (isRun) {
|
while (isRun) {
|
||||||
try {
|
try {
|
||||||
if (IsConnect()) {
|
if (IsConnect()) {
|
||||||
@@ -45,9 +46,13 @@ public class PlcDdjRead extends Thread {
|
|||||||
} else {
|
} else {
|
||||||
reConnect();
|
reConnect();
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
i++;
|
||||||
Thread.currentThread().interrupt();
|
if (i==100){
|
||||||
|
log.info("读取线程执行正常");
|
||||||
|
i=0;
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
log.info("********IP:" + this.ip + " port:" + this.port + "端口号 " + e.getMessage());
|
log.info("********IP:" + this.ip + " port:" + this.port + "端口号 " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ public class PlcSsjRead implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
int i = 0;
|
||||||
while (isRun) {
|
while (isRun) {
|
||||||
try {
|
try {
|
||||||
if (IsConnect()) {
|
if (IsConnect()) {
|
||||||
@@ -72,11 +73,13 @@ public class PlcSsjRead implements Runnable {
|
|||||||
} else {
|
} else {
|
||||||
reConnect();
|
reConnect();
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
i++;
|
||||||
// 捕获中断异常,退出循环
|
if (i==100){
|
||||||
Thread.currentThread().interrupt(); // 重新设置中断标志
|
log.info("读取线程执行正常");
|
||||||
return;
|
i=0;
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
log.info("********IP:" + this.ip + " port:" + this.port + "读取数据异常 " + e.getMessage());
|
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.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.domain.SendData;
|
import com.ruoyi.common.domain.SendData;
|
||||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
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.domain.MsgDdj;
|
||||||
import com.ruoyi.device.ddj.service.IMsgDdjService;
|
import com.ruoyi.device.ddj.service.IMsgDdjService;
|
||||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||||
@@ -46,6 +48,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
private IMsgDdjService msgDdjService;
|
private IMsgDdjService msgDdjService;
|
||||||
private IMydoJobService mydoJobService;
|
private IMydoJobService mydoJobService;
|
||||||
private IBasCargoSpaceService basCargoSpaceService;
|
private IBasCargoSpaceService basCargoSpaceService;
|
||||||
|
private ISsjWeightInfoService ssjWeightInfoService;
|
||||||
public Map<String, List<Integer>> roadwayMap = new HashMap<>();
|
public Map<String, List<Integer>> roadwayMap = new HashMap<>();
|
||||||
private PlcDdjRead plcDdjRead;
|
private PlcDdjRead plcDdjRead;
|
||||||
private PlcSsjRead plcSsjRead;
|
private PlcSsjRead plcSsjRead;
|
||||||
@@ -78,37 +81,42 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
basCargoSpaceService = SpringUtils.getBean(IBasCargoSpaceService.class);
|
basCargoSpaceService = SpringUtils.getBean(IBasCargoSpaceService.class);
|
||||||
msgDdjService = SpringUtils.getBean(IMsgDdjService.class);
|
msgDdjService = SpringUtils.getBean(IMsgDdjService.class);
|
||||||
mydoJobService = SpringUtils.getBean(IMydoJobService.class);
|
mydoJobService = SpringUtils.getBean(IMydoJobService.class);
|
||||||
|
ssjWeightInfoService = SpringUtils.getBean(ISsjWeightInfoService.class);
|
||||||
log.info("初始化服务 {},{},{},{}", apiService, ddjDeviceExecutionQueueService, ddjDeviceExecutionQueueFinishService, mydoJobService);
|
log.info("初始化服务 {},{},{},{}", apiService, ddjDeviceExecutionQueueService, ddjDeviceExecutionQueueFinishService, mydoJobService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
init();
|
init();
|
||||||
|
int i = 0;
|
||||||
while (isRun) {
|
while (isRun) {
|
||||||
for (String type : ddjCodeList.keySet()) {
|
try {
|
||||||
|
for (String type : ddjCodeList.keySet()) {
|
||||||
|
|
||||||
for (String ddjCode : ddjCodeList.get(type)) {
|
for (String ddjCode : ddjCodeList.get(type)) {
|
||||||
MsgDdj msgDdj = PlcDdjRead.deviceDdjMap.get(ddjCode);
|
MsgDdj msgDdj = PlcDdjRead.deviceDdjMap.get(ddjCode);
|
||||||
try {
|
|
||||||
if (ObjUtil.isNotNull(msgDdj)) {
|
if (ObjUtil.isNotNull(msgDdj)) {
|
||||||
generateInBoundPickQueue(msgDdj);
|
generateInBoundPickQueue(msgDdj);
|
||||||
generateInBoundLoadQueue(msgDdj);
|
generateInBoundLoadQueue(msgDdj);
|
||||||
generateOutBoundQueue(msgDdj);
|
generateOutBoundQueue(msgDdj);
|
||||||
setOutSsjStatus(msgDdj);
|
setOutSsjStatus(msgDdj);
|
||||||
ddjTask(msgDdj);
|
ddjTask(msgDdj);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
log.error("堆垛机设备为空");
|
log.error("堆垛机设备为空");
|
||||||
}
|
}
|
||||||
} catch (RuntimeException e) {
|
|
||||||
log.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
i++;
|
||||||
try {
|
if (i == 100) {
|
||||||
|
log.info("ddj{},循环完成", ddjCodeList);
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
|
||||||
Thread.sleep(1500);
|
Thread.sleep(1500);
|
||||||
} catch (InterruptedException e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,14 +158,14 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
switch (exitId) {
|
switch (exitId) {
|
||||||
case "1":
|
case "1":
|
||||||
List<DeviceSsj> outSsj1 = getDeviceSsjs("outSsj1");
|
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();
|
outSsj = outSsj1.get(0).getDeviceCode();
|
||||||
if (StrUtil.isNotEmpty(outSsj)) {
|
if (StrUtil.isNotEmpty(outSsj)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<DeviceSsj> outSsj2 = getDeviceSsjs("outSsj2");
|
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();
|
outSsj = outSsj2.get(0).getDeviceCode();
|
||||||
if (StrUtil.isNotEmpty(outSsj)) {
|
if (StrUtil.isNotEmpty(outSsj)) {
|
||||||
break;
|
break;
|
||||||
@@ -166,14 +174,14 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
break;
|
break;
|
||||||
case "2":
|
case "2":
|
||||||
List<DeviceSsj> outSsj3 = getDeviceSsjs("outSsj3");
|
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();
|
outSsj = outSsj3.get(0).getDeviceCode();
|
||||||
if (StrUtil.isNotEmpty(outSsj)) {
|
if (StrUtil.isNotEmpty(outSsj)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<DeviceSsj> outSsj4 = getDeviceSsjs("outSsj4");
|
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();
|
outSsj = outSsj4.get(0).getDeviceCode();
|
||||||
if (StrUtil.isNotEmpty(outSsj)) {
|
if (StrUtil.isNotEmpty(outSsj)) {
|
||||||
break;
|
break;
|
||||||
@@ -257,7 +265,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
createRollbackQueue(ddj, 1);
|
createRollbackQueue(ddj, 1);
|
||||||
|
|
||||||
} else if (!"00000000".equals(trayCode) && !"000000".equals(trayCode)) {
|
} 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);
|
trayCode = trayCode.substring(trayCode.length() - 4);
|
||||||
MydoJob param = new MydoJob();
|
MydoJob param = new MydoJob();
|
||||||
param.setTrayCode(trayCode);
|
param.setTrayCode(trayCode);
|
||||||
@@ -323,7 +331,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
ddjDeviceExecutionQueue.setRwlx(DDJ_RWLX_2);
|
ddjDeviceExecutionQueue.setRwlx(DDJ_RWLX_2);
|
||||||
ddjDeviceExecutionQueue.setSpare4(trayCode);
|
ddjDeviceExecutionQueue.setSpare4(trayCode);
|
||||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||||
log.info("324- 任务生成成功 trayCode:{}",trayCode);
|
log.info("324- 任务生成成功 ddj:{} trayCode:{}",ddj.getId(),trayCode);
|
||||||
|
|
||||||
inJob.setStatus("3");
|
inJob.setStatus("3");
|
||||||
inJob.setStartTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
inJob.setStartTime(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||||
@@ -419,14 +427,19 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
int rkqq = ssj.getRkqq();
|
int rkqq = ssj.getRkqq();
|
||||||
if (taskNo > 0 && rkqq == 1) {
|
if (taskNo > 0 && rkqq == 1) {
|
||||||
//log.info("取货任务 任务号{}",taskNo);
|
//log.info("取货任务 任务号{}",taskNo);
|
||||||
//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());
|
DdjDeviceExecutionQueue ddjQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(Convert.toLong(taskNo), ddj.getId());
|
||||||
if (ObjUtil.isNull(ddjQueue)) {
|
if (ObjUtil.isNull(ddjQueue)) {
|
||||||
log.info("取货任务 任务号:{} 重量:{}",taskNo,aDouble);
|
//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);
|
||||||
|
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) {
|
if (aDouble > 0 && aDouble < 1500) {
|
||||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = new DdjDeviceExecutionQueue();
|
||||||
ddjDeviceExecutionQueue.setUuid(IdUtil.simpleUUID());
|
ddjDeviceExecutionQueue.setUuid(IdUtil.simpleUUID());
|
||||||
@@ -446,7 +459,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
ddjDeviceExecutionQueue.setScsj(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
ddjDeviceExecutionQueue.setScsj(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
|
||||||
ddjDeviceExecutionQueue.setMlfs(3);
|
ddjDeviceExecutionQueue.setMlfs(3);
|
||||||
ddjDeviceExecutionQueue.setSpare1("0");
|
ddjDeviceExecutionQueue.setSpare1("0");
|
||||||
ddjDeviceExecutionQueue.setSpare3(Convert.toStr(weight));
|
ddjDeviceExecutionQueue.setSpare3(Convert.toStr(aDouble));
|
||||||
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
ddjDeviceExecutionQueueService.insertDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||||
} /*else if (aDouble>=1500) {
|
} /*else if (aDouble>=1500) {
|
||||||
//写入超重信号
|
//写入超重信号
|
||||||
@@ -490,12 +503,17 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
if (ObjUtil.isNotNull(mydoJob)) {
|
if (ObjUtil.isNotNull(mydoJob)) {
|
||||||
//回传完成信号
|
//回传完成信号
|
||||||
ddjTaskFinish(rwh, ddj.getId(), 1);
|
ddjTaskFinish(rwh, ddj.getId(), 1);
|
||||||
|
log.info("堆垛机完成任务 ddj:{},taskNo:{} rwlx:{}",ddj.getId(),rwh,ddjDeviceExecutionQueue.getRwlx() );
|
||||||
}
|
}
|
||||||
} else if (ddjDeviceExecutionQueue.getRwlx() == 4) {
|
} else if (ddjDeviceExecutionQueue.getRwlx() == 4) {
|
||||||
ddjTaskFinish(rwh, ddj.getId(), 2);
|
ddjTaskFinish(rwh, ddj.getId(), 2);
|
||||||
|
log.info("堆垛机完成任务 ddj:{},taskNo:{} rwlx:{}",ddj.getId(),rwh,ddjDeviceExecutionQueue.getRwlx() );
|
||||||
|
|
||||||
} else if (ddjDeviceExecutionQueue.getRwlx() == 1) {
|
} else if (ddjDeviceExecutionQueue.getRwlx() == 1) {
|
||||||
if (hczt == 0) {
|
if (hczt == 0) {
|
||||||
ddjTaskFinish(ddj.getRwh(), ddj.getId(), 2);
|
ddjTaskFinish(ddj.getRwh(), ddj.getId(), 2);
|
||||||
|
log.info("堆垛机完成任务 ddj:{},taskNo:{} rwlx:{}",ddj.getId(),rwh,ddjDeviceExecutionQueue.getRwlx());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -526,12 +544,14 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
Long rwh = ddj.getRwh();
|
Long rwh = ddj.getRwh();
|
||||||
String trayCode = ddj.getTrayCode();
|
String trayCode = ddj.getTrayCode();
|
||||||
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(rwh);
|
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(rwh);
|
||||||
|
String oldCargoSpaceId = mydoJob.getCargoSpaceId();
|
||||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
|
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
|
||||||
if ("0".equals(mydoJob.getFaultFlag()) && "1".equals(ddjDeviceExecutionQueue.getSpare1())) {
|
if ("0".equals(mydoJob.getFaultFlag()) && "1".equals(ddjDeviceExecutionQueue.getSpare1())) {
|
||||||
mydoJob.setStatus("1");
|
mydoJob.setStatus("1");
|
||||||
mydoJobService.updateMydoJob(mydoJob);
|
mydoJobService.updateMydoJob(mydoJob);
|
||||||
AjaxResult ajaxResult = apiService.reAssign(new JobParam(mydoJob.getJobId(), trayCode, ddjDeviceExecutionQueue.getRwh().toString()));
|
AjaxResult ajaxResult = apiService.reAssign(new JobParam(mydoJob.getJobId(), trayCode, ddjDeviceExecutionQueue.getRwh().toString()));
|
||||||
if (ajaxResult.isSuccess()) {
|
if (ajaxResult.isSuccess()) {
|
||||||
|
|
||||||
mydoJob = mydoJobService.selectMydoJobByTaskNo(rwh);
|
mydoJob = mydoJobService.selectMydoJobByTaskNo(rwh);
|
||||||
mydoJob.setFaultFlag("2");
|
mydoJob.setFaultFlag("2");
|
||||||
mydoJobService.updateMydoJob(mydoJob);
|
mydoJobService.updateMydoJob(mydoJob);
|
||||||
@@ -542,6 +562,8 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
ddjDeviceExecutionQueue.setSpare1("0");
|
ddjDeviceExecutionQueue.setSpare1("0");
|
||||||
ddjDeviceExecutionQueue.setDdjxf("0");
|
ddjDeviceExecutionQueue.setDdjxf("0");
|
||||||
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||||
|
log.info("放货有货,重分货位 ddj:{},rwh:{} 原货位:{} 新货位:{}",ddj.getId(),rwh,oldCargoSpaceId,mydoJob.getCargoSpaceId());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -556,11 +578,16 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
|
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueByRwh(rwh, ddj.getId());
|
||||||
//找到对应任务 调用api接口 取货无货,重新分配单据
|
//找到对应任务 调用api接口 取货无货,重新分配单据
|
||||||
if (ObjUtil.isNotNull(ddjDeviceExecutionQueue)) {
|
if (ObjUtil.isNotNull(ddjDeviceExecutionQueue)) {
|
||||||
AjaxResult ajaxResult = apiService.reMaterial(new JobParam(rwh.toString(), null, null));
|
MydoJob mydoJob = mydoJobService.selectMydoJobByTaskNo(rwh);
|
||||||
if (ajaxResult.isSuccess()) {
|
if (ObjUtil.isNotNull(mydoJob)){
|
||||||
//作废作业
|
AjaxResult ajaxResult = apiService.reMaterial(new JobParam(mydoJob.getJobId(), null, rwh.toString()));
|
||||||
InvalidMydoJob(rwh, ddj.getId());
|
if (ajaxResult.isSuccess()) {
|
||||||
|
//作废作业
|
||||||
|
InvalidMydoJob(rwh, ddj.getId());
|
||||||
|
log.info("取货无货 作废作业 ddj:{},rwh:{}",ddj.getId(),rwh);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,7 +612,7 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||||
mydoJob.setFaultFlag("0");
|
mydoJob.setFaultFlag("0");
|
||||||
mydoJobService.updateMydoJob(mydoJob);
|
mydoJobService.updateMydoJob(mydoJob);
|
||||||
log.info("托盘堆垛机重新下发任务成功 rwh:{}", rwh);
|
log.info("托盘堆垛机重新下发任务成功 ddj:{} rwh:{}",ddj.getId(), ddjDeviceExecutionQueue.getRwh());
|
||||||
} else {
|
} else {
|
||||||
log.error("托盘堆垛机重新下发任务失败!!!!!!!");
|
log.error("托盘堆垛机重新下发任务失败!!!!!!!");
|
||||||
}
|
}
|
||||||
@@ -600,11 +627,17 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
|
|
||||||
List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues1 = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueList(ddjDeviceExecutionRunningQueueParam);
|
List<DdjDeviceExecutionQueue> ddjDeviceExecutionQueues1 = ddjDeviceExecutionQueueService.selectDdjDeviceExecutionQueueList(ddjDeviceExecutionRunningQueueParam);
|
||||||
if (CollUtil.isNotEmpty(ddjDeviceExecutionQueues1)) {
|
if (CollUtil.isNotEmpty(ddjDeviceExecutionQueues1)) {
|
||||||
log.info("正在执行任务 {}", 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ddj.getSbzt() == 0 && ddj.getHczt() == 0) {
|
if (ddj.getHczt() == 0) {
|
||||||
//无货待机 只查询入库取货扫码或者出库队列
|
//无货待机 只查询入库取货扫码或者出库队列
|
||||||
ArrayList<Integer> rwlxList = new ArrayList<>();
|
ArrayList<Integer> rwlxList = new ArrayList<>();
|
||||||
rwlxList.add(DDJ_RWLX_1);
|
rwlxList.add(DDJ_RWLX_1);
|
||||||
@@ -619,16 +652,26 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueues.get(0);
|
DdjDeviceExecutionQueue ddjDeviceExecutionQueue = ddjDeviceExecutionQueues.get(0);
|
||||||
int i = issuedDDJTask(ddj, ddjDeviceExecutionQueue);
|
int i = issuedDDJTask(ddj, ddjDeviceExecutionQueue);
|
||||||
if (i == 1) {
|
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
|
//更新开始时间,修改ddjxf为已下发1
|
||||||
ddjDeviceExecutionQueue.setXfsj(DateUtil.formatDateTime(DateUtil.date()));
|
ddjDeviceExecutionQueue.setXfsj(DateUtil.formatDateTime(DateUtil.date()));
|
||||||
ddjDeviceExecutionQueue.setDdjxf("1");
|
ddjDeviceExecutionQueue.setDdjxf("1");
|
||||||
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||||
log.info("托盘堆垛机下发任务成功 rwh:{}", ddjDeviceExecutionQueue.getRwh());
|
log.info("托盘堆垛机下发任务成功 ddj:{} rwh:{}",ddj.getId(), ddjDeviceExecutionQueue.getRwh());
|
||||||
} else {
|
} else {
|
||||||
log.error("托盘堆垛机下发任务失败!!!!!!!");
|
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();
|
DdjDeviceExecutionQueue ddjDeviceExecutionQueueParam = new DdjDeviceExecutionQueue();
|
||||||
ddjDeviceExecutionQueueParam.setDdjxf("0");
|
ddjDeviceExecutionQueueParam.setDdjxf("0");
|
||||||
@@ -646,9 +689,9 @@ public abstract class BaseDdjThread implements Runnable, DdjThreadInterface {
|
|||||||
ddjDeviceExecutionQueue.setXfsj(DateUtil.formatDateTime(DateUtil.date()));
|
ddjDeviceExecutionQueue.setXfsj(DateUtil.formatDateTime(DateUtil.date()));
|
||||||
ddjDeviceExecutionQueue.setDdjxf("1");
|
ddjDeviceExecutionQueue.setDdjxf("1");
|
||||||
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
ddjDeviceExecutionQueueService.updateDdjDeviceExecutionQueue(ddjDeviceExecutionQueue);
|
||||||
log.info("托盘堆垛机下发任务成功 rwh:{}", ddjDeviceExecutionQueue.getRwh());
|
log.info("托盘堆垛机下发任务成功 ddj:{} rwh:{}",ddj.getId(), ddjDeviceExecutionQueue.getRwh());
|
||||||
} else {
|
} else {
|
||||||
log.error("托盘堆垛机下发任务失败!!!!!!!");
|
log.error("托盘堆垛机下发任务失败!!!!!!ddj:{} rwh:{}",ddj.getId(), ddjDeviceExecutionQueue.getRwh());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,20 +43,32 @@ public class Ddj5Thread extends BaseDdjThread {
|
|||||||
ssjList.put("outSsj2", outSsj2);
|
ssjList.put("outSsj2", outSsj2);
|
||||||
|
|
||||||
//初始化巷道口 排 列 层
|
//初始化巷道口 排 列 层
|
||||||
roadwayMap.put("L1003", Arrays.asList(1, 1, 1));
|
roadwayMap.put("L1003", Arrays.asList(1, 0, 1));
|
||||||
roadwayMap.put("L1004", Arrays.asList(2, 1, 1));
|
roadwayMap.put("L1004", Arrays.asList(2, 0, 1));
|
||||||
|
//未扫码 回退任务号 无入库任务在此基础+100
|
||||||
roadwayRollback.put("L1003", 94);
|
roadwayRollback.put("L1003", 94);
|
||||||
roadwayRollback.put("L1004", 95);
|
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");
|
log.info("Ddj5Thread init");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HashMap<String, Object> getParamMap(String trayCode,Integer height,double weight) {
|
public HashMap<String, Object> getParamMap(String trayCode,Integer height,double weight) {
|
||||||
HashMap<String, Object> paramMap = new HashMap<>();
|
HashMap<String, Object> paramMap = new HashMap<>();
|
||||||
paramMap.put("trayCode", trayCode);
|
paramMap.put("trayCode", trayCode);
|
||||||
paramMap.put("warehouseId",WAREHOUSE_02);
|
paramMap.put("warehouseId",WAREHOUSE_02);
|
||||||
paramMap.put("roadwayId",ROADWAY_ID_02);
|
paramMap.put("roadwayId",ROADWAY_ID_05);
|
||||||
paramMap.put("height",height);
|
paramMap.put("height",height);
|
||||||
paramMap.put("weight",weight);
|
paramMap.put("weight",weight);
|
||||||
return paramMap;
|
return paramMap;
|
||||||
@@ -66,7 +78,7 @@ public class Ddj5Thread extends BaseDdjThread {
|
|||||||
public MydoJob getOutJobParam() {
|
public MydoJob getOutJobParam() {
|
||||||
MydoJob mydoJob = new MydoJob();
|
MydoJob mydoJob = new MydoJob();
|
||||||
mydoJob.setWarehouseId(WAREHOUSE_02);
|
mydoJob.setWarehouseId(WAREHOUSE_02);
|
||||||
mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_02));
|
mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_05));
|
||||||
mydoJob.setStatus("1");
|
mydoJob.setStatus("1");
|
||||||
|
|
||||||
return mydoJob;
|
return mydoJob;
|
||||||
|
|||||||
@@ -43,11 +43,22 @@ public class Ddj6Thread extends BaseDdjThread {
|
|||||||
ssjList.put("outSsj2", outSsj2);
|
ssjList.put("outSsj2", outSsj2);
|
||||||
|
|
||||||
//初始化巷道口 排 列 层
|
//初始化巷道口 排 列 层
|
||||||
roadwayMap.put("L1005", Arrays.asList(1, 1, 1));
|
roadwayMap.put("L1005", Arrays.asList(1, 0, 1));
|
||||||
roadwayMap.put("L1006", Arrays.asList(2, 1, 1));
|
roadwayMap.put("L1006", Arrays.asList(2, 0, 1));
|
||||||
|
//未扫码 回退任务号 无入库任务在此基础+100
|
||||||
roadwayRollback.put("L1005", 96);
|
roadwayRollback.put("L1005", 96);
|
||||||
roadwayRollback.put("L1006", 97);
|
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");
|
log.info("Ddj6Thread init");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,10 +68,9 @@ public class Ddj6Thread extends BaseDdjThread {
|
|||||||
HashMap<String, Object> paramMap = new HashMap<>();
|
HashMap<String, Object> paramMap = new HashMap<>();
|
||||||
paramMap.put("trayCode", trayCode);
|
paramMap.put("trayCode", trayCode);
|
||||||
paramMap.put("warehouseId",WAREHOUSE_02);
|
paramMap.put("warehouseId",WAREHOUSE_02);
|
||||||
paramMap.put("roadwayId",ROADWAY_ID_03);
|
paramMap.put("roadwayId",ROADWAY_ID_06);
|
||||||
paramMap.put("height",height);
|
paramMap.put("height",height);
|
||||||
paramMap.put("weight",weight);
|
paramMap.put("weight",weight);
|
||||||
|
|
||||||
return paramMap;
|
return paramMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +78,7 @@ public class Ddj6Thread extends BaseDdjThread {
|
|||||||
public MydoJob getOutJobParam() {
|
public MydoJob getOutJobParam() {
|
||||||
MydoJob mydoJob = new MydoJob();
|
MydoJob mydoJob = new MydoJob();
|
||||||
mydoJob.setWarehouseId(WAREHOUSE_02);
|
mydoJob.setWarehouseId(WAREHOUSE_02);
|
||||||
mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_03));
|
mydoJob.setRoadwayId(String.valueOf(ROADWAY_ID_06));
|
||||||
mydoJob.setStatus("1");
|
mydoJob.setStatus("1");
|
||||||
|
|
||||||
return mydoJob;
|
return mydoJob;
|
||||||
@@ -86,4 +96,5 @@ public class Ddj6Thread extends BaseDdjThread {
|
|||||||
return "1";
|
return "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,124 +45,77 @@ public class MonitoringThread implements Runnable {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
init();
|
init();
|
||||||
|
int i =0;
|
||||||
while (isRun){
|
while (isRun){
|
||||||
try {
|
try {
|
||||||
|
|
||||||
for (String ssjCode : PlcSsjRead.deviceSsjMap.keySet()) {
|
for (String ssjCode : PlcSsjRead.deviceSsjMap.keySet()) {
|
||||||
DeviceSsj deviceSsj = PlcSsjRead.deviceSsjMap.get(ssjCode);
|
try {
|
||||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
DeviceSsj deviceSsj = PlcSsjRead.deviceSsjMap.get(ssjCode);
|
||||||
|
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||||
|
int taskNo = deviceSsj.getTaskNo();
|
||||||
|
|
||||||
//输送机外形异常 101-前超长 102-后超长 103-左超宽 104-右超宽 105-超高 106-超重
|
//输送机外形异常 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()));
|
|
||||||
param.setJobId("0");
|
|
||||||
List<BasFaultRecord> basFaultRecords = basFaultRecordService.selectBasFaultRecordList(param);
|
|
||||||
if (CollUtil.isEmpty(basFaultRecords)) {
|
|
||||||
BasFaultRecord record = new BasFaultRecord();
|
|
||||||
record.setId(IdUtil.simpleUUID());
|
|
||||||
record.setDeviceId(Convert.toStr(deviceSsj.getDeviceCode()));
|
|
||||||
record.setDeviceName(deviceSsj.getName());
|
|
||||||
record.setDeviceType("ssj");
|
|
||||||
record.setTaskNo(Convert.toStr(deviceSsj.getTaskNo()));
|
|
||||||
record.setStartTime(DateUtil.formatDateTime(new Date()));
|
|
||||||
record.setFault(getSsjZt(deviceSsj.getException()));
|
|
||||||
record.setJobId("0");
|
|
||||||
basFaultRecordService.insertBasFaultRecord(record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//人工处理 恢复异常
|
|
||||||
if (deviceSsj.getException() == 0 && deviceSsj.getTaskNo() >= 200) {
|
|
||||||
//查询记录 更新故障结束时间
|
|
||||||
BasFaultRecord param = new BasFaultRecord();
|
|
||||||
param.setDeviceId(Convert.toStr(deviceSsj.getDeviceCode()));
|
|
||||||
param.setJobId("0");
|
|
||||||
List<BasFaultRecord> basFaultRecords = basFaultRecordService.selectBasFaultRecordList(param);
|
|
||||||
if (CollUtil.isNotEmpty(basFaultRecords)) {
|
|
||||||
BasFaultRecord record = basFaultRecords.get(0);
|
|
||||||
record.setJobId("1");
|
|
||||||
record.setFinishTime(DateUtil.formatDateTime(new Date()));
|
|
||||||
basFaultRecordService.updateBasFaultRecord(record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//取走托盘 恢复异常
|
|
||||||
if (deviceSsj.getTaskNo() == 0 && deviceSsj.getKx() == 1) {
|
|
||||||
//查询记录 更新故障结束时间
|
|
||||||
BasFaultRecord param = new BasFaultRecord();
|
|
||||||
param.setDeviceId(Convert.toStr(deviceSsj.getDeviceCode()));
|
|
||||||
param.setJobId("0");
|
|
||||||
List<BasFaultRecord> basFaultRecords = basFaultRecordService.selectBasFaultRecordList(param);
|
|
||||||
if (CollUtil.isNotEmpty(basFaultRecords)) {
|
|
||||||
BasFaultRecord record = basFaultRecords.get(0);
|
|
||||||
record.setJobId("1");
|
|
||||||
record.setFinishTime(DateUtil.formatDateTime(new Date()));
|
|
||||||
basFaultRecordService.updateBasFaultRecord(record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (String ddjCode : PlcDdjRead.deviceDdjMap.keySet()) {
|
|
||||||
MsgDdj msgDdj = PlcDdjRead.deviceDdjMap.get(ddjCode);
|
|
||||||
msgDdjService.updateMsgDdj(msgDdj);
|
|
||||||
//记录异常
|
|
||||||
if (msgDdj.getSbzt() > 1000) {
|
|
||||||
//查询记录,添加故障开始时间
|
|
||||||
BasFaultRecord param = new BasFaultRecord();
|
|
||||||
param.setTaskNo(Convert.toStr(msgDdj.getRwh()));
|
|
||||||
param.setDeviceId(Convert.toStr(msgDdj.getId()));
|
|
||||||
param.setJobId("0");
|
|
||||||
List<BasFaultRecord> basFaultRecords = basFaultRecordService.selectBasFaultRecordList(param);
|
|
||||||
if (CollUtil.isEmpty(basFaultRecords)){
|
|
||||||
BasFaultRecord record = new BasFaultRecord();
|
|
||||||
record.setId(IdUtil.simpleUUID());
|
|
||||||
record.setDeviceId(Convert.toStr(msgDdj.getId()));
|
|
||||||
record.setDeviceName(msgDdj.getName());
|
|
||||||
record.setDeviceType("ddj");
|
|
||||||
record.setTaskNo(Convert.toStr(msgDdj.getRwh()));
|
|
||||||
record.setStartTime(DateUtil.formatDateTime(new Date()));
|
|
||||||
record.setFault(getDdjZt(msgDdj.getSbzt(), null));
|
|
||||||
record.setJobId("0");
|
|
||||||
basFaultRecordService.insertBasFaultRecord(record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//恢复异常
|
|
||||||
if (msgDdj.getSbzt() < 1000 && msgDdj.getCzfs()==5){
|
|
||||||
//查询记录 更新故障结束时间
|
|
||||||
BasFaultRecord param = new BasFaultRecord();
|
|
||||||
//param.setTaskNo(Convert.toStr(msgDdj.getRwh()));
|
|
||||||
param.setDeviceId(Convert.toStr(msgDdj.getId()));
|
|
||||||
param.setJobId("0");
|
|
||||||
List<BasFaultRecord> basFaultRecords = basFaultRecordService.selectBasFaultRecordList(param);
|
|
||||||
if (CollUtil.isNotEmpty(basFaultRecords)){
|
|
||||||
BasFaultRecord record = basFaultRecords.get(0);
|
|
||||||
record.setJobId("1");
|
|
||||||
record.setFinishTime(DateUtil.formatDateTime(new Date()));
|
|
||||||
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();
|
BasFaultRecord param = new BasFaultRecord();
|
||||||
param.setTaskNo(Convert.toStr(msgDdj.getRwh()));
|
param.setTaskNo(Convert.toStr(deviceSsj.getTaskNo()));
|
||||||
param.setDeviceId(Convert.toStr(ddjDeviceExecutionQueue.getSpare2()));
|
param.setDeviceId(Convert.toStr(deviceSsj.getDeviceCode()));
|
||||||
param.setJobId("0");
|
param.setJobId("0");
|
||||||
List<BasFaultRecord> basFaultRecords = basFaultRecordService.selectBasFaultRecordList(param);
|
List<BasFaultRecord> basFaultRecords = basFaultRecordService.selectBasFaultRecordList(param);
|
||||||
if (CollUtil.isEmpty(basFaultRecords)) {
|
if (CollUtil.isEmpty(basFaultRecords)) {
|
||||||
BasFaultRecord record = new BasFaultRecord();
|
BasFaultRecord record = new BasFaultRecord();
|
||||||
record.setId(IdUtil.simpleUUID());
|
record.setId(IdUtil.simpleUUID());
|
||||||
record.setDeviceId(param.getDeviceName());
|
record.setDeviceId(Convert.toStr(deviceSsj.getDeviceCode()));
|
||||||
record.setDeviceName(param.getDeviceName());
|
record.setDeviceName(deviceSsj.getName());
|
||||||
|
record.setDeviceType("ssj");
|
||||||
|
record.setTaskNo(Convert.toStr(deviceSsj.getTaskNo()));
|
||||||
|
record.setStartTime(DateUtil.formatDateTime(new Date()));
|
||||||
|
record.setFault(getSsjZt(deviceSsj.getException()));
|
||||||
|
record.setJobId("0");
|
||||||
|
basFaultRecordService.insertBasFaultRecord(record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//人工处理 恢复异常
|
||||||
|
if (deviceSsj.getException() == 0 && deviceSsj.getTaskNo() >= 200) {
|
||||||
|
//查询记录 更新故障结束时间
|
||||||
|
BasFaultRecord param = new BasFaultRecord();
|
||||||
|
param.setDeviceId(Convert.toStr(deviceSsj.getDeviceCode()));
|
||||||
|
param.setJobId("0");
|
||||||
|
List<BasFaultRecord> basFaultRecords = basFaultRecordService.selectBasFaultRecordList(param);
|
||||||
|
if (CollUtil.isNotEmpty(basFaultRecords)) {
|
||||||
|
BasFaultRecord record = basFaultRecords.get(0);
|
||||||
|
record.setJobId("1");
|
||||||
|
record.setFinishTime(DateUtil.formatDateTime(new Date()));
|
||||||
|
basFaultRecordService.updateBasFaultRecord(record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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.setDeviceType("ssj");
|
||||||
record.setTaskNo(Convert.toStr(taskNo));
|
record.setTaskNo(Convert.toStr(taskNo));
|
||||||
record.setStartTime(DateUtil.formatDateTime(new Date()));
|
record.setStartTime(DateUtil.formatDateTime(new Date()));
|
||||||
@@ -182,9 +135,78 @@ public class MonitoringThread implements Runnable {
|
|||||||
record.setJobId("0");
|
record.setJobId("0");
|
||||||
basFaultRecordService.insertBasFaultRecord(record);
|
basFaultRecordService.insertBasFaultRecord(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//取走托盘 恢复异常
|
||||||
|
if (deviceSsj.getTaskNo() == 0 && deviceSsj.getKx() == 1) {
|
||||||
|
//查询记录 更新故障结束时间
|
||||||
|
BasFaultRecord param = new BasFaultRecord();
|
||||||
|
param.setDeviceId(Convert.toStr(deviceSsj.getDeviceCode()));
|
||||||
|
param.setJobId("0");
|
||||||
|
List<BasFaultRecord> basFaultRecords = basFaultRecordService.selectBasFaultRecordList(param);
|
||||||
|
if (CollUtil.isNotEmpty(basFaultRecords)) {
|
||||||
|
BasFaultRecord record = basFaultRecords.get(0);
|
||||||
|
record.setJobId("1");
|
||||||
|
record.setFinishTime(DateUtil.formatDateTime(new Date()));
|
||||||
|
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);
|
||||||
|
//记录异常
|
||||||
|
if (msgDdj.getSbzt() > 1000) {
|
||||||
|
//查询记录,添加故障开始时间
|
||||||
|
BasFaultRecord param = new BasFaultRecord();
|
||||||
|
param.setTaskNo(Convert.toStr(msgDdj.getRwh()));
|
||||||
|
param.setDeviceId(Convert.toStr(msgDdj.getId()));
|
||||||
|
param.setJobId("0");
|
||||||
|
List<BasFaultRecord> basFaultRecords = basFaultRecordService.selectBasFaultRecordList(param);
|
||||||
|
if (CollUtil.isEmpty(basFaultRecords)){
|
||||||
|
BasFaultRecord record = new BasFaultRecord();
|
||||||
|
record.setId(IdUtil.simpleUUID());
|
||||||
|
record.setDeviceId(Convert.toStr(msgDdj.getId()));
|
||||||
|
record.setDeviceName(msgDdj.getName());
|
||||||
|
record.setDeviceType("ddj");
|
||||||
|
record.setTaskNo(Convert.toStr(msgDdj.getRwh()));
|
||||||
|
record.setStartTime(DateUtil.formatDateTime(new Date()));
|
||||||
|
record.setFault(getDdjZt(msgDdj.getSbzt(), null));
|
||||||
|
record.setJobId("0");
|
||||||
|
basFaultRecordService.insertBasFaultRecord(record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//恢复异常
|
||||||
|
if (msgDdj.getSbzt() < 1000 && msgDdj.getCzfs()==5){
|
||||||
|
//查询记录 更新故障结束时间
|
||||||
|
BasFaultRecord param = new BasFaultRecord();
|
||||||
|
//param.setTaskNo(Convert.toStr(msgDdj.getRwh()));
|
||||||
|
param.setDeviceId(Convert.toStr(msgDdj.getId()));
|
||||||
|
param.setJobId("0");
|
||||||
|
List<BasFaultRecord> basFaultRecords = basFaultRecordService.selectBasFaultRecordList(param);
|
||||||
|
if (CollUtil.isNotEmpty(basFaultRecords)){
|
||||||
|
BasFaultRecord record = basFaultRecords.get(0);
|
||||||
|
record.setJobId("1");
|
||||||
|
record.setFinishTime(DateUtil.formatDateTime(new Date()));
|
||||||
|
basFaultRecordService.updateBasFaultRecord(record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(),e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
if (i==100){
|
||||||
|
log.info("监控线程循环完成");
|
||||||
|
i=0;
|
||||||
}
|
}
|
||||||
Thread.sleep(1500);
|
Thread.sleep(1500);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -208,7 +230,13 @@ public class MonitoringThread implements Runnable {
|
|||||||
return "超高";
|
return "超高";
|
||||||
} else if (value == 106) {
|
} else if (value == 106) {
|
||||||
return "超重";
|
return "超重";
|
||||||
} else {
|
} else if (value==112){
|
||||||
|
return "输送超时";
|
||||||
|
}else if (value==113){
|
||||||
|
return "变频器报警";
|
||||||
|
}else if (value==114){
|
||||||
|
return "开关异常";
|
||||||
|
}else {
|
||||||
return "未知";
|
return "未知";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,57 +1,100 @@
|
|||||||
package com.ruoyi.schedule.util;
|
package com.ruoyi.schedule.util;
|
||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class CheckWeight {
|
public class CheckWeight {
|
||||||
|
|
||||||
public static String sendWeight(String ip, int por) {
|
public static String sendWeight(String ip, int por) {
|
||||||
|
|
||||||
String zhi = "0";
|
String zhi = "0";
|
||||||
try (
|
Socket socket = null;
|
||||||
Socket socket = new Socket(ip, por);
|
InputStream is = null;
|
||||||
InputStream is = socket.getInputStream();
|
try {
|
||||||
) {
|
socket = new Socket();
|
||||||
Thread.sleep(100);
|
socket.connect(new InetSocketAddress(ip, por), 1000);
|
||||||
byte[] bytes = new byte[10];
|
socket.setSoTimeout(10000);
|
||||||
int read = is.read(bytes);
|
is = socket.getInputStream();
|
||||||
if (read!=-1){
|
|
||||||
String weight = byteArrayToCharArray(bytes, "UTF-8");
|
|
||||||
weight = weight.substring(1,8);
|
|
||||||
weight = weight.replace("=","");
|
|
||||||
|
|
||||||
if (weight.length() == 7 && !weight.equals("0000000")) {
|
byte[] clearBuf = new byte[4096];
|
||||||
zhi = weight;
|
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) {
|
||||||
|
String[] weightList = byteArrayToCharArray(bytes, "UTF-8").split("\r\n");
|
||||||
|
System.out.println(Arrays.toString(weightList));
|
||||||
|
String weight = getMostFrequentByHutool(weightList);
|
||||||
|
if (weight != null) {
|
||||||
|
weight = weight.replace("=", "").replace("\r", "").replace("\n", "");
|
||||||
|
if (!weight.equals("0000000")) {
|
||||||
|
zhi = weight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
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;
|
return zhi;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static String getMostFrequentByHutool(String[] strArray) {
|
||||||
* 将byte数组按指定编码转为char数组
|
if (strArray == null || strArray.length == 0) {
|
||||||
* @param byteArr 输入的byte数组
|
return null;
|
||||||
* @param charset 字符编码(如UTF-8、GBK、ASCII)
|
}
|
||||||
* @return 转换后的char数组
|
List<String> strList = CollUtil.newArrayList(strArray);
|
||||||
* @throws UnsupportedEncodingException 编码不支持时抛出
|
Map<String, Integer> countMap = CollUtil.countMap(strList);
|
||||||
*/
|
|
||||||
|
String mostFrequent = null;
|
||||||
|
int maxCount = 0;
|
||||||
|
for (Map.Entry<String, Integer> entry : countMap.entrySet()) {
|
||||||
|
if (entry.getValue() > maxCount) {
|
||||||
|
maxCount = entry.getValue();
|
||||||
|
mostFrequent = entry.getKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return mostFrequent;
|
||||||
|
}
|
||||||
|
|
||||||
public static String byteArrayToCharArray(byte[] byteArr, String charset) throws UnsupportedEncodingException {
|
public static String byteArrayToCharArray(byte[] byteArr, String charset) throws UnsupportedEncodingException {
|
||||||
if (byteArr == null) {
|
if (byteArr == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// 核心:先将byte数组按指定编码转为String,再转为char数组
|
|
||||||
return new String(byteArr, charset);
|
return new String(byteArr, charset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
CheckWeight checkWeight = new CheckWeight();
|
System.out.println(sendWeight("172.19.50.75", 4001));
|
||||||
System.out.println(checkWeight.sendWeight("172.19.50.75", 4001));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ spring:
|
|||||||
druid:
|
druid:
|
||||||
#主数据信息
|
#主数据信息
|
||||||
master:
|
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
|
username: sa
|
||||||
password: Flrd0914.
|
password: Flrd0914.
|
||||||
# 从库数据源
|
# 从库数据源
|
||||||
|
|||||||
@@ -249,5 +249,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
and status = #{status}
|
and status = #{status}
|
||||||
and roadway_id = #{roadwayId}
|
and roadway_id = #{roadwayId}
|
||||||
and warehouse_id = #{warehouseId}
|
and warehouse_id = #{warehouseId}
|
||||||
|
order by priority desc,create_time asc
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -84,10 +84,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<include refid="selectDdjDeviceExecutionQueueVo"/>
|
<include refid="selectDdjDeviceExecutionQueueVo"/>
|
||||||
where rwh = #{rwh} and dev_id = #{devId}
|
where rwh = #{rwh} and dev_id = #{devId}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectOutJobCount" resultType="java.lang.Integer">
|
||||||
<select id="selectOutJobCount">
|
select count(*)
|
||||||
select count(*) from ddj_device_execution_queue
|
from ddj_device_execution_queue
|
||||||
where spare2=#{spare2}
|
where spare2 = #{spare2}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user