From 8af8c45335eb1149c523011ba67e98c4cbc097ff Mon Sep 17 00:00:00 2001 From: lgh Date: Sun, 10 Jul 2022 22:47:15 +0800 Subject: [PATCH] =?UTF-8?q?apms-createProcess=E7=AB=AF=E5=8F=A3=E6=94=BE?= =?UTF-8?q?=E5=88=B0=E8=BF=9B=E7=82=89=E5=89=8D=E8=AE=BF=E9=97=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wms/core/utils/CodeGeneratorHelper.java | 14 +++++++++ .../wms/empty/params/OrderParamForApms.java | 7 +++++ .../service/impl/OrderInfoServiceImpl.java | 2 ++ .../mt/wms/empty/task/AsynRunTaskService.java | 31 ++++++++++++++++--- .../com/mt/wms/empty/task/ScheduledTask.java | 4 ++- 5 files changed, 53 insertions(+), 5 deletions(-) diff --git a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/CodeGeneratorHelper.java b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/CodeGeneratorHelper.java index 30fbb06..af6ed22 100644 --- a/6.program/wms-core/src/main/java/com/mt/wms/core/utils/CodeGeneratorHelper.java +++ b/6.program/wms-core/src/main/java/com/mt/wms/core/utils/CodeGeneratorHelper.java @@ -36,6 +36,20 @@ public class CodeGeneratorHelper { * 自动任务编码 */ public static final String AUTO_TASK_CODE = "AUTO_TASK_CODE"; + + /** + * 炉号编码 + */ + public static final String STOVE_CODE = "STOVE_CODE"; + + /** + * 生成自炉号编码 + * + * @return 订单编号 + */ + public static String getStoveCode(String kilnNameAndCraft) { + return IDGenerator.gen(kilnNameAndCraft, "yyMMdd", 2, STOVE_CODE); + } /** * 生成自动任务编码 * diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/OrderParamForApms.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/OrderParamForApms.java index 42dffa0..de7f934 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/OrderParamForApms.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/params/OrderParamForApms.java @@ -81,4 +81,11 @@ public class OrderParamForApms extends BaseParam { @ApiModelProperty(value = "单位") private String unit; + + /** + * 技术要求 APMS系统获取 + */ + @ApiModelProperty(value = "技术要求") + private String techRequest; + } 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 b0a12f0..cc83052 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 @@ -95,6 +95,8 @@ public class OrderInfoServiceImpl extends BaseService implements OrderInfoServic setCommon(orderInfo); //设定来源信息为apms orderInfo.setOrderSource(OrderSourceEnum.APMS.getValue()); + //apms传来的技术要求字段使用工艺要求字段,不关注工艺要求字段, + orderInfo.setCraftIll(apmsPostOrderParam.getTechRequest()); orderInfo.setInterCode(IDGenerator.gen("DD", IDGenerator.PATTERN_YYYYMMDDHHMM, 2, "ORDER_CODE")); //检查是否为重复的单号 OrderInfo one = orderInfoService.getOne(new QueryWrapper().eq(OrderInfo.ORDER_NO, apmsPostOrderParam.getOrderNo()).eq(OrderInfo.IDEN_CARD_NUM, apmsPostOrderParam.getIdenCardNum())); 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 6964e6b..8096797 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 @@ -6,14 +6,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.mt.wms.core.base.BaseService; import com.mt.wms.core.dal.entity.*; import com.mt.wms.core.dal.service.*; +import com.mt.wms.core.utils.CodeGeneratorHelper; 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.params.*; +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.websocket.WebSocketServer; @@ -32,6 +31,7 @@ import java.io.IOException; import java.math.BigDecimal; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.TimeUnit; @@ -86,6 +86,7 @@ public class AsynRunTaskService extends BaseService { public void asynRunTask(Long currTaskId,Long vehicleId) throws IOException { CurrTask currTask = currTaskServiceBiz.getById(currTaskId); VehicleInfo vehicle = vehicleInfoServiceBiz.getById(vehicleId); + List currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper().eq(CurrTaskDet.CURR_TASK_ID, currTask)); //检查车辆是否冲突,冲突则避让 rgvStatus(vehicleId,currTask); //新建一条执行任务的关系表存放任务执行信息 @@ -97,6 +98,28 @@ public class AsynRunTaskService extends BaseService { runTask.setEndPosition(currTask.getTargetPosition()); runTask.setBeginTime(LocalDateTime.now()); runTaskServiceBiz.save(runTask); + //通知apms创建一个生产单 + ApmsCreateProcessSheet apmsCreateSheet = new ApmsCreateProcessSheet(); + apmsCreateSheet.setWorkShopCode("BM"); + apmsCreateSheet.setStartTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + apmsCreateSheet.setTechCode(currTask.getCraftCodeId().toString()); + //fixme 暂时没有正式user,使用测试账户 + apmsCreateSheet.setStartUser("QJJP03"); + ArrayList createItems = new ArrayList<>(); + currTaskDetList.forEach(e -> { + CreateItem createItem = new CreateItem(); + createItem.setItemCode(e.getIdenCardNum()); + createItem.setQuantity(e.getQuantity().intValue()); + createItem.setWeight(e.getWeight().doubleValue()); + createItems.add(createItem); + }); + apmsCreateSheet.setStoveCode(CodeGeneratorHelper.getStoveCode(currTask.getKilnName()+String.format("%02d",currTask.getCraftCodeId()))); + apmsCreateSheet.setItems(createItems); + R processSheet = apmsController.createProcessSheet(apmsCreateSheet); + if (!processSheet.getData().getSuccess()){ + logger.info(currTaskId+"创建失败,APMS报错:" + processSheet.getData().getMsg()); + webSocketServer.sendtoUser("创建失败,APMS报错:" + processSheet.getData().getMsg(),"1"); + } //调用车辆填入起终点,得到车辆执行结果 Long startPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getStartPosition())).getCode(); Long endPoint = pointInfoServiceBiz.getOne(new QueryWrapper().eq(PointInfo.NOTE, runTask.getEndPosition())).getCode(); 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 6cee79c..b1ccf48 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 @@ -75,9 +75,11 @@ public class ScheduledTask extends BaseService { private OrderInfoServiceBiz orderInfoServiceBiz; @Test + //@Scheduled(fixedDelay = 1000*20) public void test() throws IOException { + System.out.println(CodeGeneratorHelper.getStoveCode("MBA102")); } - //@Scheduled(fixedDelay = 1000*60) + @Scheduled(fixedDelay = 1000*60) public void testWebsocket() throws IOException { //查询出正在进炉加工的curr_task,查询对应炉号是否Working,查询计划时间,剩余时间,查询标识卡详情 List currTaskList = currTaskServiceBiz.list(new QueryWrapper().eq(CurrTask.IS_IN, 1));