wcs项目初始化
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
package com.ruoyi.schedule.scheduleTask.agv;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AgvDispatch {
|
||||
|
||||
// 基础URL
|
||||
private final String baseUrl;
|
||||
|
||||
// 客户端编号
|
||||
private String clientCode;
|
||||
|
||||
// 令牌号
|
||||
private String tokenCode;
|
||||
|
||||
public AgvDispatch(String ip, int port) {
|
||||
this.baseUrl = String.format("http://%s:%d/rcms/services/rest", ip, port);
|
||||
}
|
||||
|
||||
public AgvDispatch(String baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成唯一请求编号
|
||||
*/
|
||||
private String generateReqCode() {
|
||||
return IdUtil.fastSimpleUUID();
|
||||
}
|
||||
|
||||
// ------------------------------ 常用接口 ------------------------------
|
||||
|
||||
/**
|
||||
* 2.1.1 生成任务单
|
||||
* @param taskTyp 任务类型
|
||||
* @param wbCode 工作位
|
||||
* @param positionCodePath 位置路径
|
||||
* @param podCode 货架编号
|
||||
* @return 接口返回结果
|
||||
*/
|
||||
public String genAgvSchedulingTask(String taskTyp, String wbCode,
|
||||
Object[] positionCodePath, String podCode) throws IOException {
|
||||
String url = baseUrl + "/hikRpcService/genAgvSchedulingTask";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("taskTyp", taskTyp);
|
||||
params.put("wbCode", wbCode);
|
||||
params.put("positionCodePath", positionCodePath);
|
||||
params.put("podCode", podCode);
|
||||
return HttpUtil.post(url, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 2.1.2 继续执行任务
|
||||
* @param taskCode 任务单号
|
||||
* @return 接口返回结果
|
||||
*/
|
||||
public String continueTask(String taskCode) throws IOException {
|
||||
String url = baseUrl + "/hikRpcService/continueTask";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("taskCode", taskCode);
|
||||
return HttpUtil.post(url, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 2.1.3 取消任务
|
||||
* @param taskCode 任务单号
|
||||
* @param forceCancel 取消类型(0-直接放地上,1-软取消)
|
||||
* @return 接口返回结果
|
||||
*/
|
||||
public String cancelTask(String taskCode, String forceCancel) throws IOException {
|
||||
String url = baseUrl + "/hikRpcService/cancelTask";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("taskCode", taskCode);
|
||||
params.put("forceCancel", forceCancel);
|
||||
return HttpUtil.post(url, params);
|
||||
}
|
||||
|
||||
// ------------------------------ 可选接口 ------------------------------
|
||||
|
||||
/**
|
||||
* 3.1.1 任务优先级设置
|
||||
* @param priorities 优先级列表
|
||||
* @return 接口返回结果
|
||||
*/
|
||||
public String setTaskPriority(Object[] priorities) throws IOException {
|
||||
String url = baseUrl + "/hikRpcService/setTaskPriority";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("priorities", priorities);
|
||||
return HttpUtil.post(url, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 3.1.2 货架与位置绑定、解绑
|
||||
* @param podCode 货架编号
|
||||
* @param positionCode 位置编号
|
||||
* @param indBind 1-绑定,0-解绑
|
||||
* @return 接口返回结果
|
||||
*/
|
||||
public String bindPodAndBerth(String podCode, String positionCode, String indBind) throws IOException {
|
||||
String url = baseUrl + "/hikRpcService/bindPodAndBerth";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("podCode", podCode);
|
||||
params.put("positionCode", positionCode);
|
||||
params.put("indBind", indBind);
|
||||
return HttpUtil.post(url, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 3.1.9 查询任务状态
|
||||
* @param taskCodes 任务单编号数组
|
||||
* @return 接口返回结果
|
||||
*/
|
||||
public String queryTaskStatus(String[] taskCodes) throws IOException {
|
||||
String url = baseUrl + "/hikRpcService/queryTaskStatus";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("taskCodes", taskCodes);
|
||||
return HttpUtil.post(url, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 3.1.10 查询AGV状态
|
||||
* @param mapCode 地图编号
|
||||
* @return 接口返回结果
|
||||
*/
|
||||
public String queryAgvStatus(String mapCode) throws IOException {
|
||||
String url = "http://" + baseUrl.split("//")[1].split("/")[0] + "/rcms-dps/rest/queryAgvStatus";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("mapCode", mapCode);
|
||||
return HttpUtil.post(url, params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 3.1.16 料箱出库TPS(CTU+分拨墙)
|
||||
* @param taskTyp 任务类型(传1)
|
||||
* @param data 任务数据列表
|
||||
* @return 接口返回结果
|
||||
*/
|
||||
public String getOutPod(String taskTyp, Object[] data) throws IOException {
|
||||
String url = baseUrl + "/hikTpsService/getOutPod";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("taskTyp", taskTyp);
|
||||
params.put("data", data);
|
||||
return HttpUtil.post(url, params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.bs;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskRequest;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
|
||||
import com.ruoyi.api.domain.wcs2wms.MydoJob;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.agv.domain.AgvQueue;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class BsInSsjThread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
//todo 获取设备编码列表
|
||||
ssjCodeList = new HashMap<>();
|
||||
log.info("初始化臂式入库输送机");
|
||||
//入库口
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("G1003");
|
||||
ssjCodes.add("G1009");
|
||||
ssjCodeList.put("ssjIn", ssjCodes);
|
||||
//流利架
|
||||
ArrayList<String> ssjCodes2 = new ArrayList<>();
|
||||
ssjCodes2.add("fluent1-11");
|
||||
ssjCodes2.add("fluent1-12");
|
||||
ssjCodes2.add("fluent1-13");
|
||||
ssjCodes2.add("fluent1-14");
|
||||
ssjCodes2.add("fluent1-15");
|
||||
ssjCodes2.add("fluent2-11");
|
||||
ssjCodes2.add("fluent2-12");
|
||||
ssjCodes2.add("fluent2-13");
|
||||
ssjCodes2.add("fluent2-14");
|
||||
ssjCodes2.add("fluent2-15");
|
||||
ssjCodeList.put("fluentIn", ssjCodes2);
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
log.info("初始化服务 {},{}", apiService, agvQueueService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
|
||||
switch (type) {
|
||||
case "ssjIn":
|
||||
//正常入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case "fluentIn":
|
||||
//流利架 空料箱入库
|
||||
for (String lljCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
inLljDispatch(lljCode);
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 流利架空料箱入库
|
||||
*
|
||||
* @param lljCode
|
||||
*/
|
||||
private void inLljDispatch(String lljCode) {
|
||||
|
||||
//判断是否生成队列
|
||||
AgvQueue agvQueueParam = new AgvQueue();
|
||||
agvQueueParam.setPositionCode1(lljCode);
|
||||
agvQueueParam.setStatus("0");
|
||||
List<AgvQueue> agvQueues = agvQueueService.selectAgvQueueList(agvQueueParam);
|
||||
if (CollUtil.isNotEmpty(agvQueues)) {
|
||||
for (AgvQueue agvQueue : agvQueues) {
|
||||
//请求任务生成
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(agvQueue);
|
||||
//修改wms任务状态
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 输送线入库
|
||||
*
|
||||
* @param inSsjDevice
|
||||
*/
|
||||
public void inDispatch(DeviceSsj inSsjDevice) {
|
||||
//如果入库请求1 并且 托盘码不为空
|
||||
if (inSsjDevice.getDw()==1 && inSsjDevice.getRkqq() == 1 && StrUtil.isNotEmpty(inSsjDevice.getTrayCode())) {
|
||||
//判断是否生成队列
|
||||
AgvQueue agvQueueParam = new AgvQueue();
|
||||
agvQueueParam.setWmsTraycode(inSsjDevice.getTrayCode());
|
||||
//agvQueueParam.setStatus("0");
|
||||
List<AgvQueue> agvQueues = agvQueueService.selectAgvQueueList(agvQueueParam);
|
||||
if (CollUtil.isEmpty(agvQueues)) {
|
||||
//根据入口,查询对应的入库作业
|
||||
MydoJob mydoJobParam = new MydoJob();
|
||||
mydoJobParam.setStatus("1");
|
||||
mydoJobParam.setTrayCode(inSsjDevice.getTrayCode());
|
||||
mydoJobParam.setEntranceId(inSsjDevice.getDeviceCode());
|
||||
MydoJob mydoJob = apiService.requestEnterByTrayCode(mydoJobParam);
|
||||
if (ObjUtil.isNotNull(mydoJob)) {
|
||||
|
||||
//生成agv队列
|
||||
AgvQueue agvQueue = apiService.createAgvQueue(inSsjDevice.getName(), mydoJob.getCargoSpaceId(),mydoJob.getTrayCode(),mydoJob.getTaskNo(),"1");
|
||||
//请求任务生成
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue( agvQueue);
|
||||
//修改wms任务状态
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}else {
|
||||
AgvQueue agvQueue = agvQueues.get(0);
|
||||
if ("0".equals(agvQueue.getStatus())){
|
||||
//请求任务生成
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(agvQueue);
|
||||
//修改wms任务状态
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.bs;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.bas.fluent.domain.BasFluentFrame;
|
||||
import com.ruoyi.bas.fluent.service.IBasFluentFrameService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.agv.domain.AgvQueue;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskRequest;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
|
||||
import com.ruoyi.api.domain.wcs2wms.MydoJob;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class BsOutSsjThread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IAgvQueueService agvQueueService;
|
||||
private IBasFluentFrameService basFluentFrameService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("G1004");
|
||||
ssjCodes.add("G1010");
|
||||
ssjCodeList.put("ssjOut", ssjCodes);
|
||||
ArrayList<String> fluentOut = new ArrayList<>();
|
||||
fluentOut.add("fluent1");
|
||||
fluentOut.add("fluent2");
|
||||
ssjCodeList.put("fluentOut", fluentOut);
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
basFluentFrameService = SpringUtils.getBean(IBasFluentFrameService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
switch (type){
|
||||
case "ssjOut":
|
||||
//正常输送线出口
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
ssjOutDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case "fluentOut":
|
||||
//流利架出口
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
fluentOutDispatch(ssjCode);
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 输送线出口
|
||||
* @param outSsjDevice
|
||||
*/
|
||||
public void ssjOutDispatch(DeviceSsj outSsjDevice) {
|
||||
//输送线出库
|
||||
if (outSsjDevice.getKx()==1){
|
||||
//查询对应的作业
|
||||
AgvQueue agvQueue = new AgvQueue();
|
||||
agvQueue.setPositionCode2(outSsjDevice.getDeviceCode());
|
||||
agvQueue.setStatus("0");
|
||||
List<AgvQueue> agvQueueList = agvQueueService.selectAgvQueueList(agvQueue);
|
||||
if (CollUtil.isNotEmpty(agvQueueList)){
|
||||
for (AgvQueue queue : agvQueueList) {
|
||||
apiService.requestAgvQueue(queue);
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(queue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* todo 流利架出口
|
||||
* @param outSsjDevice
|
||||
*/
|
||||
public void fluentOutDispatch(String outSsjDevice) {
|
||||
//查询对应的作业
|
||||
AgvQueue agvQueue = new AgvQueue();
|
||||
agvQueue.setPositionCode2(outSsjDevice);
|
||||
agvQueue.setStatus("0");
|
||||
List<AgvQueue> agvQueueList = agvQueueService.selectAgvQueueList(agvQueue);
|
||||
for (AgvQueue queue : agvQueueList) {
|
||||
//修改实际流利架货位
|
||||
BasFluentFrame basFluentFrame = basFluentFrameService.selectBasFluentFrameOrderByAllotNum(queue.getPositionCode2());
|
||||
if (basFluentFrame != null){
|
||||
queue.setPositionCode2(basFluentFrame.getLocationName());
|
||||
agvQueueService.updateAgvQueue(queue);
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(queue);
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
queue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(queue);
|
||||
log.info("向CTU下入库库作业");
|
||||
//更新流利架
|
||||
basFluentFrame.setTrayCode(queue.getWmsTraycode());
|
||||
basFluentFrame.setAllotNum(1L);
|
||||
basFluentFrameService.updateBasFluentFrame(basFluentFrame);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.bs;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.api.domain.RequestLog;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.bas.port.domain.WcsPort;
|
||||
import com.ruoyi.bas.port.service.IWcsPortService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.ruoyi.common.Constant.JOB_FINISH_URL;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class BsPickSsjTread implements Runnable{
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IAgvQueueService agvQueueService;
|
||||
private IWcsPortService wcsPortService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("G1006");
|
||||
ssjCodes.add("G1012");
|
||||
ssjCodeList.put("pick", ssjCodes);
|
||||
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
wcsPortService = SpringUtils.getBean(IWcsPortService.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
if ("pick".equals(type)) {
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
pickDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void pickDispatch(DeviceSsj pickSsjDevice) {
|
||||
if (pickSsjDevice.getDw() == 1 && pickSsjDevice.getTaskNo() > 0) {
|
||||
WcsPort wcsPortParam = new WcsPort();
|
||||
wcsPortParam.setPortCode(pickSsjDevice.getDeviceCode());
|
||||
wcsPortParam.setPortType("1");
|
||||
List<WcsPort> wcsPorts = wcsPortService.selectWcsPortList(wcsPortParam);
|
||||
if (CollUtil.isNotEmpty(wcsPorts)){
|
||||
WcsPort wcsPort = wcsPorts.get(0);
|
||||
if ("1".equals(wcsPort.getStatus())){
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("taskNo", pickSsjDevice.getTaskNo());
|
||||
param.put("wmsType", "2");
|
||||
param.put("pickSsj", pickSsjDevice.getDeviceCode());
|
||||
RequestLog requestLog = apiService.finishMydoJob(JOB_FINISH_URL, "出库任务到达拣选口", param);
|
||||
if ("1".equals(requestLog.getIsSuccessful())){
|
||||
wcsPort.setStatus("2");
|
||||
wcsPortService.updateWcsPort(wcsPort);
|
||||
}else {
|
||||
log.error("任务失败{}", requestLog.getErrorDetails());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (pickSsjDevice.getKx() == 1 && pickSsjDevice.getTaskNo() == 0){
|
||||
WcsPort wcsPortParam = new WcsPort();
|
||||
wcsPortParam.setPortCode(pickSsjDevice.getDeviceCode());
|
||||
wcsPortParam.setPortType("1");
|
||||
List<WcsPort> wcsPorts = wcsPortService.selectWcsPortList(wcsPortParam);
|
||||
if (CollUtil.isNotEmpty(wcsPorts)){
|
||||
WcsPort wcsPort = wcsPorts.get(0);
|
||||
if ("2".equals(wcsPort.getStatus())){
|
||||
wcsPort.setStatus("1");
|
||||
wcsPortService.updateWcsPort(wcsPort);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.js;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
|
||||
import com.ruoyi.api.domain.wcs2wms.MydoJob;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.agv.domain.AgvQueue;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class JsInSsjThread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
//todo 获取设备编码列表
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("G2012");
|
||||
ssjCodes.add("G3009");
|
||||
ssjCodes.add("G3018");
|
||||
ssjCodes.add("G4009");
|
||||
ssjCodes.add("G4018");
|
||||
ssjCodes.add("G5009");
|
||||
ssjCodes.add("G5018");
|
||||
ssjCodeList.put("in", ssjCodes);
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
log.info("初始化服务 {},{}", apiService, agvQueueService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
|
||||
switch ( type){
|
||||
case "in":
|
||||
//正常入库 尾箱回流 物料入库 空料箱入库
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
inDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void inDispatch(DeviceSsj inSsjDevice) {
|
||||
//如果入库请求1 并且 托盘码不为空
|
||||
if (inSsjDevice.getDw()==1 && inSsjDevice.getRkqq() == 1 && StrUtil.isNotEmpty(inSsjDevice.getTrayCode())) {
|
||||
//判断是否生成队列
|
||||
AgvQueue agvQueueParam = new AgvQueue();
|
||||
agvQueueParam.setWmsTraycode(inSsjDevice.getTrayCode());
|
||||
//agvQueueParam.setStatus("0");
|
||||
List<AgvQueue> agvQueues = agvQueueService.selectAgvQueueList(agvQueueParam);
|
||||
if (CollUtil.isEmpty(agvQueues)) {
|
||||
//根据入口,查询对应的入库作业
|
||||
MydoJob mydoJobParam = new MydoJob();
|
||||
mydoJobParam.setStatus("1");
|
||||
mydoJobParam.setTrayCode(inSsjDevice.getTrayCode());
|
||||
mydoJobParam.setEntranceId(inSsjDevice.getDeviceCode());
|
||||
MydoJob mydoJob = apiService.requestEnterByTrayCode(mydoJobParam);
|
||||
if (ObjUtil.isNotNull(mydoJob)) {
|
||||
|
||||
//生成agv队列
|
||||
AgvQueue agvQueue = apiService.createAgvQueue(inSsjDevice.getName(), mydoJob.getCargoSpaceId(),mydoJob.getTrayCode(),mydoJob.getTaskNo(),"1");
|
||||
//请求任务生成
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(agvQueue);
|
||||
//修改wms任务状态
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}else {
|
||||
AgvQueue agvQueue = agvQueues.get(0);
|
||||
if ("0".equals(agvQueue.getStatus())){
|
||||
//请求任务生成
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.requestAgvQueue(agvQueue);
|
||||
//修改wms任务状态
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0) {
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.js;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.api.domain.agv.continueTask.ContinueTaskRequest;
|
||||
import com.ruoyi.api.domain.agv.continueTask.ContinueTaskResponse;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskRequest;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
|
||||
import com.ruoyi.api.domain.wcs2wms.MydoJob;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.agv.domain.AgvQueue;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class JsOutSsjThread implements Runnable{
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IAgvQueueService agvQueueService;
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("G2001");
|
||||
ssjCodes.add("G3001");
|
||||
ssjCodes.add("G3010");
|
||||
ssjCodes.add("G4001");
|
||||
ssjCodes.add("G4010");
|
||||
ssjCodes.add("G5001");
|
||||
ssjCodes.add("G5010");
|
||||
ssjCodeList.put("ssjOut", ssjCodes);
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
|
||||
while (isRun){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
switch (type){
|
||||
case "ssjOut":
|
||||
try {
|
||||
//正常输送线出口
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
ssjOutDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
break;
|
||||
case "fluentOut":
|
||||
//流利架出口(剪式没有)
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 输送线出口
|
||||
* @param outSsjDevice
|
||||
*/
|
||||
public void ssjOutDispatch(DeviceSsj outSsjDevice) {
|
||||
if (outSsjDevice.getKx()==1){
|
||||
//查询对应的作业
|
||||
AgvQueue agvQueue = new AgvQueue();
|
||||
agvQueue.setPositionCode2(outSsjDevice.getDeviceCode());
|
||||
agvQueue.setStatus("0");
|
||||
List<AgvQueue> agvQueueList = agvQueueService.selectAgvQueueList(agvQueue);
|
||||
if (CollUtil.isNotEmpty(agvQueueList)){
|
||||
for (AgvQueue queue : agvQueueList) {
|
||||
requestAgvQueue( queue);
|
||||
}
|
||||
}else {
|
||||
log.info("ssjCode:{},没有待下发的出库任务", outSsjDevice.getDeviceCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求海康生成agv任务,并修改wms任务状态
|
||||
* @param agvQueue
|
||||
*/
|
||||
private void requestAgvQueue(AgvQueue agvQueue) {
|
||||
//请求ctu
|
||||
GenAgvSchedulingTaskRequest genAgvSchedulingTaskRequest = new GenAgvSchedulingTaskRequest();
|
||||
genAgvSchedulingTaskRequest.setReqCode(agvQueue.getReqCode());
|
||||
genAgvSchedulingTaskRequest.setTaskMode("0");
|
||||
genAgvSchedulingTaskRequest.setPriority("10");
|
||||
genAgvSchedulingTaskRequest.setTaskTyp("F01");
|
||||
genAgvSchedulingTaskRequest.setCtnrCode("0");
|
||||
genAgvSchedulingTaskRequest.setCtnrNum("0");
|
||||
genAgvSchedulingTaskRequest.setTaskMode("0");
|
||||
genAgvSchedulingTaskRequest.setTaskCode(agvQueue.getTaskCode());
|
||||
genAgvSchedulingTaskRequest.setAgvTyp("CTU");
|
||||
genAgvSchedulingTaskRequest.setPositionSelStrategy("0");
|
||||
GenAgvSchedulingTaskResponse genAgvSchedulingTaskResponse = apiService.genAgvSchedulingTask(genAgvSchedulingTaskRequest);
|
||||
if (genAgvSchedulingTaskResponse.getCode() == 0){
|
||||
//修改ctu执行状态
|
||||
agvQueue.setStatus("1");
|
||||
agvQueueService.updateAgvQueue(agvQueue);
|
||||
log.info("向CTU下入库库作业");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.js;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ruoyi.api.domain.RequestLog;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.bas.port.domain.WcsPort;
|
||||
import com.ruoyi.bas.port.service.IWcsPortService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.ruoyi.common.Constant.JOB_FINISH_URL;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class JsPickSsjTread implements Runnable {
|
||||
|
||||
public HashMap<String, List<String>> ssjCodeList;
|
||||
|
||||
private IApiService apiService;
|
||||
private IAgvQueueService agvQueueService;
|
||||
private IWcsPortService wcsPortService;
|
||||
|
||||
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
ssjCodeList = new HashMap<>();
|
||||
ArrayList<String> ssjCodes = new ArrayList<>();
|
||||
ssjCodes.add("G5013");
|
||||
ssjCodes.add("G5014");
|
||||
ssjCodes.add("G5015");
|
||||
ssjCodes.add("G5004");
|
||||
ssjCodes.add("G5005");
|
||||
ssjCodes.add("G5006");
|
||||
ssjCodes.add("G4013");
|
||||
ssjCodes.add("G4014");
|
||||
ssjCodes.add("G4015");
|
||||
ssjCodes.add("G4004");
|
||||
ssjCodes.add("G4005");
|
||||
ssjCodes.add("G4006");
|
||||
ssjCodeList.put("pick", ssjCodes);
|
||||
|
||||
|
||||
apiService = SpringUtils.getBean(IApiService.class);
|
||||
agvQueueService = SpringUtils.getBean(IAgvQueueService.class);
|
||||
wcsPortService = SpringUtils.getBean(IWcsPortService.class);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run(){
|
||||
init();
|
||||
while (isRun){
|
||||
for (String type : ssjCodeList.keySet()) {
|
||||
if ("pick".equals(type)) {
|
||||
for (String ssjCode : ssjCodeList.get(type)) {
|
||||
try {
|
||||
if (PlcRead.deviceMap.containsKey(ssjCode)) {
|
||||
pickDispatch(PlcRead.deviceMap.get(ssjCode));
|
||||
} else {
|
||||
log.error("设备不存在 ssjCode{}", ssjCode);
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void pickDispatch(DeviceSsj pickSsjDevice) {
|
||||
if (pickSsjDevice.getDw() == 1 && pickSsjDevice.getTaskNo() > 0) {
|
||||
WcsPort wcsPortParam = new WcsPort();
|
||||
wcsPortParam.setPortCode(pickSsjDevice.getDeviceCode());
|
||||
wcsPortParam.setPortType("1");
|
||||
List<WcsPort> wcsPorts = wcsPortService.selectWcsPortList(wcsPortParam);
|
||||
if (CollUtil.isNotEmpty(wcsPorts)){
|
||||
WcsPort wcsPort = wcsPorts.get(0);
|
||||
if ("1".equals(wcsPort.getStatus())){
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("taskNo", pickSsjDevice.getTaskNo());
|
||||
param.put("wmsType", "2");
|
||||
param.put("pickSsj", pickSsjDevice.getDeviceCode());
|
||||
RequestLog requestLog = apiService.finishMydoJob(JOB_FINISH_URL, "出库任务到达拣选口", param);
|
||||
if ("1".equals(requestLog.getIsSuccessful())){
|
||||
wcsPort.setStatus("2");
|
||||
wcsPortService.updateWcsPort(wcsPort);
|
||||
}else {
|
||||
log.error("任务失败{}", requestLog.getErrorDetails());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (pickSsjDevice.getKx() == 1 && pickSsjDevice.getTaskNo() == 0){
|
||||
WcsPort wcsPortParam = new WcsPort();
|
||||
wcsPortParam.setPortCode(pickSsjDevice.getDeviceCode());
|
||||
wcsPortParam.setPortType("1");
|
||||
List<WcsPort> wcsPorts = wcsPortService.selectWcsPortList(wcsPortParam);
|
||||
if (CollUtil.isNotEmpty(wcsPorts)){
|
||||
WcsPort wcsPort = wcsPorts.get(0);
|
||||
if ("2".equals(wcsPort.getStatus())){
|
||||
wcsPort.setStatus("1");
|
||||
wcsPortService.updateWcsPort(wcsPort);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.monitor;
|
||||
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.device.ssj.service.IDeviceSsjService;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class CarMonitorThread implements Runnable {
|
||||
|
||||
|
||||
|
||||
private IDeviceSsjService deviceSsjService;
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
deviceSsjService = SpringUtils.getBean(IDeviceSsjService.class);
|
||||
log.info("初始化服务 {}", deviceSsjService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String ssjCode : PlcRead.deviceMap.keySet()) {
|
||||
try {
|
||||
DeviceSsj deviceSsj = PlcRead.deviceMap.get(ssjCode);
|
||||
if (ObjUtil.isNotNull(deviceSsj)){
|
||||
switch (deviceSsj.getType()) {
|
||||
case "1":
|
||||
monitor1(deviceSsj);
|
||||
break;
|
||||
case "2":
|
||||
monitor2(deviceSsj);
|
||||
break;
|
||||
case "3":
|
||||
monitor3(deviceSsj);
|
||||
break;
|
||||
case "4":
|
||||
monitor4(deviceSsj);
|
||||
break;
|
||||
}
|
||||
}else {
|
||||
log.error("设备不存在 {}", ssjCode);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1500);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*其他输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor4(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
|
||||
/**
|
||||
*入库输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor3(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
|
||||
/**
|
||||
*拣选输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor2(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
|
||||
/**
|
||||
*出库输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor1(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.ruoyi.schedule.scheduleTask.ssj.monitor;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.ruoyi.api.domain.agv.genAgvSchedulingTask.GenAgvSchedulingTaskResponse;
|
||||
import com.ruoyi.api.domain.wcs2wms.MydoJob;
|
||||
import com.ruoyi.api.service.IApiService;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.device.agv.domain.AgvQueue;
|
||||
import com.ruoyi.device.agv.service.IAgvQueueService;
|
||||
import com.ruoyi.device.ssj.domain.DeviceSsj;
|
||||
import com.ruoyi.device.ssj.service.IDeviceSsjService;
|
||||
import com.ruoyi.schedule.plcRead.ssj.PlcRead;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class SsjMonitorThread implements Runnable {
|
||||
|
||||
|
||||
|
||||
private IDeviceSsjService deviceSsjService;
|
||||
public boolean isRun = true;
|
||||
|
||||
|
||||
public void init() {
|
||||
deviceSsjService = SpringUtils.getBean(IDeviceSsjService.class);
|
||||
log.info("初始化服务 {}", deviceSsjService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
init();
|
||||
while (isRun) {
|
||||
for (String ssjCode : PlcRead.deviceMap.keySet()) {
|
||||
try {
|
||||
DeviceSsj deviceSsj = PlcRead.deviceMap.get(ssjCode);
|
||||
if (ObjUtil.isNotNull(deviceSsj)){
|
||||
switch (deviceSsj.getType()) {
|
||||
case "1":
|
||||
monitor1(deviceSsj);
|
||||
break;
|
||||
case "2":
|
||||
monitor2(deviceSsj);
|
||||
break;
|
||||
case "3":
|
||||
monitor3(deviceSsj);
|
||||
break;
|
||||
case "4":
|
||||
monitor4(deviceSsj);
|
||||
break;
|
||||
}
|
||||
}else {
|
||||
log.error("设备不存在 {}", ssjCode);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.sleep(15000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*其他输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor4(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
|
||||
/**
|
||||
*入库输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor3(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
|
||||
/**
|
||||
*拣选输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor2(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
|
||||
/**
|
||||
*出库输送机监控
|
||||
* @param deviceSsj
|
||||
*/
|
||||
private void monitor1(DeviceSsj deviceSsj) {
|
||||
deviceSsjService.updateDeviceSsj(deviceSsj);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user