From b107cd2446455c9b3363a7cdea2fe181f92741a7 Mon Sep 17 00:00:00 2001 From: LGH <1746689524@qq.com> Date: Wed, 6 Jul 2022 18:35:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E6=8A=A5apms=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E5=8D=95=E8=BF=9B=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CheckResultController.java | 37 +++++++++ .../params/ApmsCheckRusultQueryParam.java | 24 ++++++ .../service/impl/OrderInfoServiceImpl.java | 6 +- .../mt/wms/empty/task/AsynRunTaskService.java | 78 ++++++++++++++++++- .../com/mt/wms/empty/task/ScheduledTask.java | 20 +++-- 5 files changed, 152 insertions(+), 13 deletions(-) create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CheckResultController.java create mode 100644 6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsCheckRusultQueryParam.java diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CheckResultController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CheckResultController.java new file mode 100644 index 0000000..00d9a4d --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CheckResultController.java @@ -0,0 +1,37 @@ +package com.mt.wms.empty.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.mt.wms.core.base.BaseController; +import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.dal.entity.ApmsCheckResult; +import com.mt.wms.core.dal.service.ApmsCheckResultServiceBiz; +import com.mt.wms.core.vo.R; +import com.mt.wms.empty.params.ApmsCheckRusultQueryParam; +import io.swagger.annotations.Api; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @Author: LGH + * @Date: 2022/7/6 + */ +@RestController +@RequestMapping(CommonConstant.API_MODULE_BASE + "checkResult") +@Slf4j +@Api(value = "检验结果相关接口", tags = "检验结果相关接口", hidden = false) +public class CheckResultController extends BaseController { + + @Resource + private ApmsCheckResultServiceBiz apmsCheckResultServiceBiz; + + public R checkResult(ApmsCheckRusultQueryParam apmsCheckRusultQueryParam){ + ApmsCheckResult apmsCheckResult = apmsCheckResultServiceBiz.getOne(new QueryWrapper() + .eq(ApmsCheckResult.SHEET_NO, apmsCheckRusultQueryParam.getSheetNo()) + .eq(ApmsCheckResult.IDEN_CARD_NUM, apmsCheckRusultQueryParam.getIdenCardNum())); + return successful(apmsCheckResult); + } +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsCheckRusultQueryParam.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsCheckRusultQueryParam.java new file mode 100644 index 0000000..173dcb9 --- /dev/null +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/ApmsCheckRusultQueryParam.java @@ -0,0 +1,24 @@ +package com.mt.wms.empty.params; + +import com.mt.wms.core.params.BasePageParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * @Author: LGH + * @Date: 2022/7/6 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value = "检验结果查询参数", description = "检验结果查询参数") +public class ApmsCheckRusultQueryParam extends BasePageParam { + @ApiModelProperty(value = "生产单号", required = true) + private String sheetNo; + + @ApiModelProperty(value = "标识卡号", required = true) + private String idenCardNum; +} diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java index e11109b..323444b 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/OrderInfoServiceImpl.java @@ -181,16 +181,16 @@ public class OrderInfoServiceImpl extends BaseService implements OrderInfoServic orderInfo.setKilnId(currTask.getKilnId()); orderInfo.setStartPosition(currTask.getStartPosition()); orderInfo.setTargetPosition(currTask.getTargetPosition()); - orderInfo.setVehicleId(currTask.getVehicleId()); + //orderInfo.setVehicleId(currTask.getVehicleId()); //获取窑炉和车辆的名称信息 if (orderInfo.getKilnId() != null) { orderInfo.setKilnName(collect2.get(orderInfo.getKilnId()).get(0).getKilnName()); } - if (orderInfo.getVehicleId() != null) +/* if (orderInfo.getVehicleId() != null) { orderInfo.setVehicleName(collect.get(orderInfo.getVehicleId()).get(0).getVehicleName()); - } + }*/ } ); return successful(currOrderCurrTask); diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java index dccbecb..e56ef19 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/AsynRunTaskService.java @@ -8,6 +8,14 @@ import com.mt.wms.core.dal.entity.*; import com.mt.wms.core.dal.service.*; import com.mt.wms.core.utils.HttpClient; import com.mt.wms.core.utils.IDGenerator; +import com.mt.wms.core.vo.R; +import com.mt.wms.empty.controller.ApmsController; +import com.mt.wms.empty.params.ApmsEndProcess; +import com.mt.wms.empty.params.ApmsFinishProcessSheet; +import com.mt.wms.empty.params.ApmsStartProcess; +import com.mt.wms.empty.params.FinishItem; +import com.mt.wms.empty.vo.ApmsEndProcessVo; +import com.mt.wms.empty.vo.ApmsFinishProcessSheetVo; import com.mt.wms.empty.websocket.WebSocketServer; import io.swagger.models.auth.In; import org.junit.jupiter.api.Test; @@ -21,11 +29,10 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.IOException; +import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; +import java.util.*; import java.util.concurrent.TimeUnit; /** @@ -68,6 +75,12 @@ public class AsynRunTaskService extends BaseService { private ParGasValueServiceBiz parGasValueServiceBiz; @Resource private WebSocketServer webSocketServer; + @Resource + private ApmsController apmsController; + @Resource + private AutoExeTaskServiceBiz autoExeTaskServiceBiz; + @Resource + private CurrTaskDetServiceBiz currTaskDetServiceBiz; //窑炉可用未满的情况下,调用车辆起点为提升台终点为窑炉 @Async("asyncServiceExecutor") public void asynRunTask(Long currTaskId,Long vehicleId) throws IOException { @@ -133,6 +146,9 @@ public class AsynRunTaskService extends BaseService { //更新小车状态 vehicle.setStatus(0); vehicleInfoServiceBiz.updateById(vehicle); + // TODO: 2022/7/6 上报apms加工单开始 + //apmsStartProcess(currTask); + }else { runTask.setStatus(3); runTask.setUpdateTime(LocalDateTime.now()); @@ -225,6 +241,8 @@ public class AsynRunTaskService extends BaseService { //更新小车状态 vehicle.setStatus(0); vehicleInfoServiceBiz.updateById(vehicle); + // TODO: 2022/7/6 上报apms生产单开始加工 + //apmsStartProcess(currTask); }else { runTask.setStatus(3); runTask.setUpdateTime(LocalDateTime.now()); @@ -415,6 +433,48 @@ public class AsynRunTaskService extends BaseService { //更新小车状态 vehicle.setStatus(0); vehicleInfoServiceBiz.updateById(vehicle); + // TODO: 2022/7/6 上报apms加工完成 +/* ApmsEndProcess apmsEndProcess=new ApmsEndProcess(); + apmsEndProcess.setEndTime(LocalDateTime.now().toString()); + apmsEndProcess.setEndUser("QJJP03"); + apmsEndProcess.setSheetNo(currTask.getSheetNo()); + R apmsEndProcessVoR = apmsController.endProcess(apmsEndProcess); + if (apmsEndProcessVoR.getCode()!=0){ + logger.info("任务:"+currTaskId+" 生产单号:"+currTask.getSheetNo()+"上报apm完成处理生产单失败!"); + } + if (currTask.getIsAuto()==1){ + //两步且是第二步 + List twoSpet = autoExeTaskServiceBiz.list(new QueryWrapper() + .eq(AutoExeTask.PROCESS_FLOW_TYPE, 1) + .eq(AutoExeTask.T_TASK_ID, currTaskId)); + //三步且是第三步 + List threeSpet = autoExeTaskServiceBiz.list(new QueryWrapper() + .eq(AutoExeTask.PROCESS_FLOW_TYPE, 2) + .eq(AutoExeTask.TH_TASK_ID, currTaskId)); + if (!(threeSpet.size()!=0||twoSpet.size()!=0)){ + return; + } + } + ApmsFinishProcessSheet apmsFinishProcessSheet=new ApmsFinishProcessSheet(); + apmsFinishProcessSheet.setSheetNo(currTask.getSheetNo()); + apmsFinishProcessSheet.setEndTime(LocalDateTime.now().toString()); + apmsFinishProcessSheet.setEndUser("QJJP03"); + List finishItems=new ArrayList<>(); + List currTaskDets = currTaskDetServiceBiz.list(new QueryWrapper().eq(CurrTaskDet.CURR_TASK_ID, currTaskId)); + for (CurrTaskDet currTaskDet:currTaskDets + ) { + FinishItem finishItem=new FinishItem(); + BigDecimal bigDecimal = new BigDecimal(currTaskDet.getWeight()); + finishItem.setFinishWeight(bigDecimal.doubleValue()); + finishItem.setFinishQuantity(Math.round(currTaskDet.getQuantity())); + finishItem.setItemCode(currTaskDet.getIdenCardNum()); + finishItems.add(finishItem); + } + apmsFinishProcessSheet.setItems(finishItems); + R apmsFinishProcessSheetVoR = apmsController.finishProcessSheet(apmsFinishProcessSheet); + if (apmsFinishProcessSheetVoR.getCode()!=0){ + logger.info("任务:"+currTask.getTaskCode()+"完成后上报apms完成生产单失败!"); + }*/ }else { runTask.setStatus(3); runTask.setUpdateTime(LocalDateTime.now()); @@ -1019,4 +1079,16 @@ public class AsynRunTaskService extends BaseService { return Integer.parseInt(String.valueOf(jsonObject.get("msg"))); } + private void apmsStartProcess(CurrTask currTask) { + ApmsStartProcess apmsStartProcess = new ApmsStartProcess(); + apmsStartProcess.setStartTime(LocalDateTime.now().toString()); + apmsStartProcess.setStartUser("QJJP03"); + apmsStartProcess.setSheetNo(currTask.getSheetNo()); + apmsStartProcess.setTechName(currTask.getCraftCodeId().toString()); + apmsStartProcess.setStoveCode(kilnInfoServiceBiz.getById(currTask.getKilnId()).getCode()); + R apmsStartProcessR = apmsController.startProcess(apmsStartProcess); + if (apmsStartProcessR.getCode() != 0) { + logger.info("任务号" + currTask.getTaskCode() + "生产单号:" + currTask.getSheetNo() + "生产单开始生产上报apms失败"); + } + } } 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 73b4357..ddd57a7 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 @@ -81,6 +81,9 @@ public class ScheduledTask extends BaseService { public void testWebsocket() throws IOException { //查询出正在进炉加工的curr_task,查询对应炉号是否Working,查询计划时间,剩余时间,查询标识卡详情 List currTaskList = currTaskServiceBiz.list(new QueryWrapper().eq(CurrTask.IS_IN, 1)); + if (currTaskList.size()==0){ + return; + } List nowCurrTaskDetVoList = BeanUtils.copyList(currTaskList, NowCurrTaskDetVo.class); for (NowCurrTaskDetVo nowCurrTask:nowCurrTaskDetVoList ) { @@ -119,10 +122,13 @@ 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().eq(CurrTask.IS_IN, 1)); + if (currTaskList.size()==0){ + return; + } List nowCurrTaskDetVoList = BeanUtils.copyList(currTaskList, NowCurrTaskDetVo.class); for (NowCurrTaskDetVo nowCurrTask:nowCurrTaskDetVoList ) { @@ -166,12 +172,12 @@ public class ScheduledTask extends BaseService { nowCurrTask.setCurrTaskDetVoList(currTaskDetVoList); } } - webSocketServer.sendtoAll(JSONObject.toJSONString(nowCurrTaskDetVoList)); + webSocketServer.sendtoUser(JSON.toJSONString(nowCurrTaskDetVoList),"2"); } /** * 查询加工完成的窑炉 */ - //@Scheduled(fixedDelay = 1000*60*3) + @Scheduled(fixedDelay = 1000*60*3) public void taskForStockToKiln() throws IOException { //两辆车是否都空闲,只有两辆车都空闲才被允许做任务 List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 0)); @@ -204,7 +210,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)); @@ -292,7 +298,7 @@ public class ScheduledTask extends BaseService { } //查询出正在加工的窑炉,遍历,根据采集频率的不同,采集低频数据能源消耗。暂定3分钟一次 - //@Scheduled(fixedDelay = 1000*60*3) + @Scheduled(fixedDelay = 1000*60*3) public void getSlowValue(){ System.out.println("开始采集数据"); List kilnInfoList = kilnInfoServiceBiz.list(); @@ -436,7 +442,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)); @@ -483,7 +489,7 @@ public class ScheduledTask extends BaseService { } //遍历正在工作炉子的报警变量,记录报警 - //@Scheduled(fixedDelay = 1000*30) + @Scheduled(fixedDelay = 1000*30) public void listenKilnAlarm(){ List kilnInfoList = kilnInfoServiceBiz.list(); for (KilnInfo kilnInfo:kilnInfoList