apms上报失败msg推送
This commit is contained in:
李广豪 2022-09-01 13:46:36 +08:00
parent 4af20b8551
commit 942bde619f
2 changed files with 25 additions and 8 deletions

View File

@ -5,6 +5,7 @@ import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSON; import cn.hutool.json.JSON;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject;
import com.mt.wms.core.base.BaseController; import com.mt.wms.core.base.BaseController;
import com.mt.wms.core.constants.CommonConstant; import com.mt.wms.core.constants.CommonConstant;
import com.mt.wms.core.dal.entity.CommunicationLog; 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.ApmsEndProcessVo;
import com.mt.wms.empty.vo.ApmsFinishProcessSheetVo; import com.mt.wms.empty.vo.ApmsFinishProcessSheetVo;
import com.mt.wms.empty.vo.ApmsStoveVo; import com.mt.wms.empty.vo.ApmsStoveVo;
import com.mt.wms.empty.websocket.WebSocketServer;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.io.IOException;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.HashMap; import java.util.HashMap;
@ -46,6 +50,8 @@ public class ApmsController extends BaseController {
@Autowired @Autowired
private CommunicationLogServiceBiz communicationLogServiceBiz; private CommunicationLogServiceBiz communicationLogServiceBiz;
@Autowired
private WebSocketServer webSocketServer;
static String Token = ""; static String Token = "";
static LocalDateTime TokenExpireTime = LocalDateTime.now(); static LocalDateTime TokenExpireTime = LocalDateTime.now();
@ -134,9 +140,20 @@ public class ApmsController extends BaseController {
communicationLog.setContent("param:" + paramJson + "\nresult:" + response.body()); communicationLog.setContent("param:" + paramJson + "\nresult:" + response.body());
setCommonField(communicationLog); setCommonField(communicationLog);
communicationLogServiceBiz.save(communicationLog); communicationLogServiceBiz.save(communicationLog);
String body = response.body();
JSONObject jsonObject = com.alibaba.fastjson.JSON.parseObject(body);
Object success = jsonObject.get("success");
if (status == 200) 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 else
{ {

View File

@ -134,7 +134,7 @@ public class ScheduledTask extends BaseService {
/** /**
* 正在加工的加工任务详情 * 正在加工的加工任务详情
*/ */
@Scheduled(fixedDelay = 1000*60) //Scheduled(fixedDelay = 1000*60)
public void screen() throws IOException { public void screen() throws IOException {
//查询出正在进炉加工的curr_task,查询对应炉号是否Working,查询计划时间剩余时间查询标识卡详情 //查询出正在进炉加工的curr_task,查询对应炉号是否Working,查询计划时间剩余时间查询标识卡详情
List<CurrTask> currTaskList = currTaskServiceBiz.list(new QueryWrapper<CurrTask>() List<CurrTask> currTaskList = currTaskServiceBiz.list(new QueryWrapper<CurrTask>()
@ -199,7 +199,7 @@ public class ScheduledTask extends BaseService {
/** /**
* 查询加工完成的工业炉 * 查询加工完成的工业炉
*/ */
@Scheduled(fixedDelay = 1000*30) //@Scheduled(fixedDelay = 1000*30)
public void taskForStockToKiln() throws IOException { public void taskForStockToKiln() throws IOException {
//两辆车是否都空闲只有两辆车都空闲才被允许做任务 //两辆车是否都空闲只有两辆车都空闲才被允许做任务
List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>().eq(VehicleInfo.STATUS, 0)); List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>().eq(VehicleInfo.STATUS, 0));
@ -250,7 +250,7 @@ public class ScheduledTask extends BaseService {
} }
//查询出正在加工的工业炉遍历根据采集频率的不同采集高频数据能源消耗暂定30秒 //查询出正在加工的工业炉遍历根据采集频率的不同采集高频数据能源消耗暂定30秒
@Scheduled(fixedDelay = 1000*30) //@Scheduled(fixedDelay = 1000*30)
public void getFastValue(){ public void getFastValue(){
//加工炉列表 //加工炉列表
List<KilnInfo> kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper<KilnInfo>().in(KilnInfo.TYPE,1,3)); List<KilnInfo> kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper<KilnInfo>().in(KilnInfo.TYPE,1,3));
@ -366,7 +366,7 @@ public class ScheduledTask extends BaseService {
} }
//查询出正在加工的工业炉遍历根据采集频率的不同采集低频数据能源消耗暂定3分钟一次 //查询出正在加工的工业炉遍历根据采集频率的不同采集低频数据能源消耗暂定3分钟一次
@Scheduled(fixedDelay = 1000*60*3) //@Scheduled(fixedDelay = 1000*60*3)
public void getSlowValue(){ public void getSlowValue(){
List<KilnInfo> kilnInfoList = kilnInfoServiceBiz.list(); List<KilnInfo> kilnInfoList = kilnInfoServiceBiz.list();
for (KilnInfo kilnInfo:kilnInfoList 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 { public void runTaskForEmptyKiln() throws IOException {
List<KilnInfo> kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper<KilnInfo>() List<KilnInfo> kilnInfoList = kilnInfoServiceBiz.list(new QueryWrapper<KilnInfo>()
.eq(KilnInfo.VALID, 1).eq(KilnInfo.STATUS, 0).orderByAsc(KilnInfo.TYPE)); .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(){ public void listenKilnAlarm(){
List<KilnInfo> kilnInfoList = kilnInfoServiceBiz.list(); List<KilnInfo> kilnInfoList = kilnInfoServiceBiz.list();
for (KilnInfo kilnInfo:kilnInfoList 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 { public void listenVehicleOnline() throws IOException {
List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>().eq(VehicleInfo.STATUS,1)); List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>().eq(VehicleInfo.STATUS,1));
for (VehicleInfo vehicleInfo:vehicleInfoList for (VehicleInfo vehicleInfo:vehicleInfoList