diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ApmsController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ApmsController.java index 5bf52ea..de45bea 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ApmsController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/ApmsController.java @@ -5,6 +5,7 @@ import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpUtil; import cn.hutool.json.JSON; import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.JSONObject; import com.mt.wms.core.base.BaseController; import com.mt.wms.core.constants.CommonConstant; import com.mt.wms.core.dal.entity.CommunicationLog; @@ -17,6 +18,7 @@ import com.mt.wms.empty.vo.ApmsCreateProcessSheetVo; import com.mt.wms.empty.vo.ApmsEndProcessVo; import com.mt.wms.empty.vo.ApmsFinishProcessSheetVo; import com.mt.wms.empty.vo.ApmsStoveVo; +import com.mt.wms.empty.websocket.WebSocketServer; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; @@ -27,6 +29,8 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import javax.annotation.Resource; +import java.io.IOException; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.HashMap; @@ -46,6 +50,8 @@ public class ApmsController extends BaseController { @Autowired private CommunicationLogServiceBiz communicationLogServiceBiz; + @Autowired + private WebSocketServer webSocketServer; static String Token = ""; static LocalDateTime TokenExpireTime = LocalDateTime.now(); @@ -134,9 +140,20 @@ public class ApmsController extends BaseController { communicationLog.setContent("param:" + paramJson + "\nresult:" + response.body()); setCommonField(communicationLog); communicationLogServiceBiz.save(communicationLog); + String body = response.body(); + JSONObject jsonObject = com.alibaba.fastjson.JSON.parseObject(body); + Object success = jsonObject.get("success"); if (status == 200) { - return successful(JSONUtil.toBean(response.body(), ApmsCreateProcessSheetVo.class)); + ApmsCreateProcessSheetVo apmsCreateProcessSheetVo = JSONUtil.toBean(response.body(), ApmsCreateProcessSheetVo.class); + if (!apmsCreateProcessSheetVo.getSuccess()){ + try { + webSocketServer.sendtoAll(apmsCreateProcessSheetVo.getMsg()); + } catch (IOException e) { + e.printStackTrace(); + } + } + return successful(apmsCreateProcessSheetVo); } else { diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java index 27780a9..cbf707a 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java @@ -134,7 +134,7 @@ public class ScheduledTask extends BaseService { /** * 正在加工的加工任务详情 */ - @Scheduled(fixedDelay = 1000*60) + //Scheduled(fixedDelay = 1000*60) public void screen() throws IOException { //查询出正在进炉加工的curr_task,查询对应炉号是否Working,查询计划时间,剩余时间,查询标识卡详情 List currTaskList = currTaskServiceBiz.list(new QueryWrapper() @@ -199,7 +199,7 @@ public class ScheduledTask extends BaseService { /** * 查询加工完成的工业炉 */ - @Scheduled(fixedDelay = 1000*30) + //@Scheduled(fixedDelay = 1000*30) public void taskForStockToKiln() throws IOException { //两辆车是否都空闲,只有两辆车都空闲才被允许做任务 List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 0)); @@ -250,7 +250,7 @@ public class ScheduledTask extends BaseService { } //查询出正在加工的工业炉,遍历,根据采集频率的不同,采集高频数据能源消耗。暂定30秒 - @Scheduled(fixedDelay = 1000*30) + //@Scheduled(fixedDelay = 1000*30) public void getFastValue(){ //加工炉列表 List kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper().in(KilnInfo.TYPE,1,3)); @@ -366,7 +366,7 @@ public class ScheduledTask extends BaseService { } //查询出正在加工的工业炉,遍历,根据采集频率的不同,采集低频数据能源消耗。暂定3分钟一次 - @Scheduled(fixedDelay = 1000*60*3) + //@Scheduled(fixedDelay = 1000*60*3) public void getSlowValue(){ List kilnInfoList = kilnInfoServiceBiz.list(); for (KilnInfo kilnInfo:kilnInfoList @@ -538,7 +538,7 @@ public class ScheduledTask extends BaseService { //遍历工业炉,空工业炉查询缓存区是否有等待加工的任务, //待加工任务存在且没有状态为正在进炉的情况下,按照先进先出的规则选择待加工任务呼叫车辆进炉 - @Scheduled(fixedDelay = 1000*60) + //@Scheduled(fixedDelay = 1000*60) public void runTaskForEmptyKiln() throws IOException { List kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper() .eq(KilnInfo.VALID, 1).eq(KilnInfo.STATUS, 0).orderByAsc(KilnInfo.TYPE)); @@ -608,7 +608,7 @@ public class ScheduledTask extends BaseService { } //遍历正在工作炉子的报警变量,记录报警 - @Scheduled(fixedDelay = 1000*60) + //@Scheduled(fixedDelay = 1000*60) public void listenKilnAlarm(){ List kilnInfoList = kilnInfoServiceBiz.list(); for (KilnInfo kilnInfo:kilnInfoList @@ -681,7 +681,7 @@ public class ScheduledTask extends BaseService { } //监听车辆是否在线,定时恢复车辆状态会导致避让时等待时间过久,再次发起任务,造成重复发起 - @Scheduled(fixedDelay = 1000*60) + //@Scheduled(fixedDelay = 1000*60) public void listenVehicleOnline() throws IOException { List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS,1)); for (VehicleInfo vehicleInfo:vehicleInfoList