From ec7f364ccf28451726fddd554474cda9b17c163c Mon Sep 17 00:00:00 2001 From: LGH <1746689524@qq.com> Date: Mon, 21 Nov 2022 15:54:43 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E7=82=89=E5=8F=B7=E7=94=9F=E6=88=90?= =?UTF-8?q?=E8=A7=84=E5=88=99=E4=BF=AE=E6=94=B9;=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=9C=AA=E6=88=90=E5=8A=9F=E6=8A=A5=E5=B7=A5=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3;=20=E6=96=B0=E5=A2=9E=E6=8A=A5=E5=B7=A5?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../empty/controller/CurrTaskController.java | 180 +++++---- .../empty/controller/EnergyController.java | 44 +-- .../mt/wms/empty/service/CurrTaskService.java | 17 + .../service/impl/CurrTaskServiceImpl.java | 374 ++++++++++++------ .../mt/wms/empty/task/AsynRunTaskService.java | 24 +- 5 files changed, 397 insertions(+), 242 deletions(-) diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java index 330d215..2537734 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/CurrTaskController.java @@ -86,16 +86,13 @@ public class CurrTaskController extends BaseController { stoveCodes.forEach(kilnMap -> { codeStr.add(kilnMap.get("code")); }); - for (String s : codeStr) - { - if (s.equals(kilnCode)) - { + for (String s : codeStr) { + if (s.equals(kilnCode)) { verifyCodes = true; break; } } - if (!verifyCodes) - { + if (!verifyCodes) { return failed("创建失败,APMS中验证炉号" + kilnCode + "失败!"); } @@ -120,17 +117,17 @@ public class CurrTaskController extends BaseController { //if (processSheet.getData().getSuccess()) //{ - //apms创建成功后写入数据库 - param.setAutoTaskType(0); - R mainTask = currTaskService.createProcessTask(param); - currTaskDetService.createProcessTaskDet(param.getDetParams(), mainTask.getData().getId()); - //String sheetNo = processSheet.getData().getSheetNo(); - //将返回的生产单号写入到主任务中。 - //CurrTask currTaskById = currTaskService.getCurrTaskById(mainTask.getData().getId()); - //currTaskById.setSheetNo(sheetNo); - //currTaskService.updateCurrTaskById(currTaskById); - //生成详细任务中的检验结果数据在apms推送生产单结果时创建 - return successful(0,"创建成功,任务添加至等待执行队列。详情请在订单加工管理下当前任务列表查看",""); + //apms创建成功后写入数据库 + param.setAutoTaskType(0); + R mainTask = currTaskService.createProcessTask(param); + currTaskDetService.createProcessTaskDet(param.getDetParams(), mainTask.getData().getId()); + //String sheetNo = processSheet.getData().getSheetNo(); + //将返回的生产单号写入到主任务中。 + //CurrTask currTaskById = currTaskService.getCurrTaskById(mainTask.getData().getId()); + //currTaskById.setSheetNo(sheetNo); + //currTaskService.updateCurrTaskById(currTaskById); + //生成详细任务中的检验结果数据在apms推送生产单结果时创建 + return successful(0, "创建成功,任务添加至等待执行队列。详情请在订单加工管理下当前任务列表查看", ""); //} //else //{ @@ -140,19 +137,19 @@ public class CurrTaskController extends BaseController { @PostMapping(value = "createAutoTask") @ApiOperation(value = "订单加工-创建多个个分步骤加工任务至任务队列") - public R createAutoTask(@Validated @RequestBody AutoCurrTaskParam autoCurrTaskParam){ + public R createAutoTask(@Validated @RequestBody AutoCurrTaskParam autoCurrTaskParam) { List detParams = autoCurrTaskParam.getTaskCreateParamList(); - if (detParams.size()==0){ + if (detParams.size() == 0) { return failed("请添加至少一个标识卡!"); } - Boolean apmsCreateProcessSheet=false; - String sheetNo=null; - int i=1; - R processSheet=null; + Boolean apmsCreateProcessSheet = false; + String sheetNo = null; + int i = 1; + R processSheet = null; //自动任务循环添加多条currTask - AutoExeTask autoExeTask=new AutoExeTask(); - for (TaskCreateParam param:detParams - ) { + AutoExeTask autoExeTask = new AutoExeTask(); + for (TaskCreateParam param : detParams + ) { //验证标识卡号正确无误。 orderInfoService.verifyTaskInfoByIdenCardNum(param.getDetParams()); //验证炉子编码信息在apms正确无误 @@ -166,16 +163,13 @@ public class CurrTaskController extends BaseController { stoveCodes.forEach(kilnMap -> { codeStr.add(kilnMap.get("code")); }); - for (String s : codeStr) - { - if (s.equals(kilnCode)) - { + for (String s : codeStr) { + if (s.equals(kilnCode)) { verifyCodes = true; break; } } - if (!verifyCodes) - { + if (!verifyCodes) { return failed("创建失败,APMS中验证炉号" + kilnCode + "失败!"); } /* @@ -205,50 +199,50 @@ public class CurrTaskController extends BaseController { //if (apmsCreateProcessSheet) //{ - //apms创建成功后写入数据库 - R mainTask = currTaskService.createProcessTask(param); - currTaskDetService.createProcessTaskDet(param.getDetParams(), mainTask.getData().getId()); - CurrTask currTask = currTaskServiceBiz.getById(mainTask.getData().getId()); - //工艺步骤中第一步 - if (param.getAutoTaskStep()==1){ - autoExeTask.setInterCode(CodeGeneratorHelper.getAutoTaskCode()); - autoExeTask.setProcessFlowType(param.getAutoTaskType()); - autoExeTask.setFTaskId(currTask.getId()); - autoExeTask.setFDetTaskCode(currTask.getTaskCode()); - autoExeTask.setFEquipmentId(currTask.getKilnId()); - autoExeTask.setFEquipmentName(currTask.getKilnName()); - autoExeTask.setFCraftCodeId(currTask.getCraftCodeId()); - autoExeTask.setFPlcValue(currTask.getPlcValue()); - setCommonField(autoExeTask); - autoExeTaskServiceBiz.save(autoExeTask); - } - if (param.getAutoTaskStep()==2){ - autoExeTask.setTTaskId(currTask.getId()); - autoExeTask.setTDetTaskCode(currTask.getTaskCode()); - autoExeTask.setTEquipmentId(currTask.getKilnId()); - autoExeTask.setTEquipmentName(currTask.getKilnName()); - autoExeTask.setTCraftCodeId(currTask.getCraftCodeId()); - autoExeTask.setTPlcValue(currTask.getPlcValue()); - setUpdateCommonField(autoExeTask); - autoExeTaskServiceBiz.updateById(autoExeTask); - } - if (param.getAutoTaskStep()==3){ - autoExeTask.setThTaskId(currTask.getId()); - autoExeTask.setThDetTaskCode(currTask.getTaskCode()); - autoExeTask.setThEquipmentId(currTask.getKilnId()); - autoExeTask.setThEquipmentName(currTask.getKilnName()); - autoExeTask.setThCraftCodeId(currTask.getCraftCodeId()); - autoExeTask.setThPlcValue(currTask.getPlcValue()); - setUpdateCommonField(autoExeTask); - autoExeTaskServiceBiz.updateById(autoExeTask); - } - //将返回的生产单号写入到主任务中。 - CurrTask currTaskById = currTaskService.getCurrTaskById(mainTask.getData().getId()); - //currTaskById.setSheetNo(sheetNo); - currTaskById.setAutoExeTaskId(autoExeTask.getId()); - currTaskService.updateCurrTaskById(currTaskById); - //生成详细任务中的检验结果数据在apms推送生产单结果时创建 - //return successful("创建成功,任务添加至等待执行队列。"); + //apms创建成功后写入数据库 + R mainTask = currTaskService.createProcessTask(param); + currTaskDetService.createProcessTaskDet(param.getDetParams(), mainTask.getData().getId()); + CurrTask currTask = currTaskServiceBiz.getById(mainTask.getData().getId()); + //工艺步骤中第一步 + if (param.getAutoTaskStep() == 1) { + autoExeTask.setInterCode(CodeGeneratorHelper.getAutoTaskCode()); + autoExeTask.setProcessFlowType(param.getAutoTaskType()); + autoExeTask.setFTaskId(currTask.getId()); + autoExeTask.setFDetTaskCode(currTask.getTaskCode()); + autoExeTask.setFEquipmentId(currTask.getKilnId()); + autoExeTask.setFEquipmentName(currTask.getKilnName()); + autoExeTask.setFCraftCodeId(currTask.getCraftCodeId()); + autoExeTask.setFPlcValue(currTask.getPlcValue()); + setCommonField(autoExeTask); + autoExeTaskServiceBiz.save(autoExeTask); + } + if (param.getAutoTaskStep() == 2) { + autoExeTask.setTTaskId(currTask.getId()); + autoExeTask.setTDetTaskCode(currTask.getTaskCode()); + autoExeTask.setTEquipmentId(currTask.getKilnId()); + autoExeTask.setTEquipmentName(currTask.getKilnName()); + autoExeTask.setTCraftCodeId(currTask.getCraftCodeId()); + autoExeTask.setTPlcValue(currTask.getPlcValue()); + setUpdateCommonField(autoExeTask); + autoExeTaskServiceBiz.updateById(autoExeTask); + } + if (param.getAutoTaskStep() == 3) { + autoExeTask.setThTaskId(currTask.getId()); + autoExeTask.setThDetTaskCode(currTask.getTaskCode()); + autoExeTask.setThEquipmentId(currTask.getKilnId()); + autoExeTask.setThEquipmentName(currTask.getKilnName()); + autoExeTask.setThCraftCodeId(currTask.getCraftCodeId()); + autoExeTask.setThPlcValue(currTask.getPlcValue()); + setUpdateCommonField(autoExeTask); + autoExeTaskServiceBiz.updateById(autoExeTask); + } + //将返回的生产单号写入到主任务中。 + CurrTask currTaskById = currTaskService.getCurrTaskById(mainTask.getData().getId()); + //currTaskById.setSheetNo(sheetNo); + currTaskById.setAutoExeTaskId(autoExeTask.getId()); + currTaskService.updateCurrTaskById(currTaskById); + //生成详细任务中的检验结果数据在apms推送生产单结果时创建 + //return successful("创建成功,任务添加至等待执行队列。"); //} //else @@ -257,7 +251,7 @@ public class CurrTaskController extends BaseController { //} //i++; } - return successful(0,"操作成功,任务加入待执行队列,详情请在订单加工管理下当前任务列表查看!",""); + return successful(0, "操作成功,任务加入待执行队列,详情请在订单加工管理下当前任务列表查看!", ""); } @PostMapping(value = "mainCurrentTaskNow") @@ -277,11 +271,25 @@ public class CurrTaskController extends BaseController { public R> currentTaskInfo(@Validated @RequestBody CurrTaskQueryParam param) { return currTaskService.currentTaskInfoPage(param); } + + @PostMapping(value = "taskInfoNotToApms") + @ApiOperation(value = "获取未报工任务列表以及详情") + public R> taskInfoNotToApms(@Validated @RequestBody CurrTaskQueryParam param) { + return currTaskService.currentTaskInfoPageForNotToApms(param); + } + + @PostMapping(value = "oneStepToApms") + @ApiOperation(value = "手动报工") + public R oneStepToApms(@Validated @RequestBody CurrTaskInfoVo currTaskInfoVo) { + return currTaskService.oneStepToApms(currTaskInfoVo); + } + @PostMapping(value = "updateCurrTaskStatus") @ApiOperation(value = "更新任务状态") - public R updateCurrTaskStatus(@Validated @RequestBody CurrTaskParam param){ + public R updateCurrTaskStatus(@Validated @RequestBody CurrTaskParam param) { return currTaskService.updateCurrTaskStatus(param); } + @PostMapping(value = "completeTask") @ApiOperation(value = "执行任务完成(仅wms,不通知apms)") public R completeTask(@Validated @RequestBody IdParam param) { @@ -305,26 +313,30 @@ public class CurrTaskController extends BaseController { public R top(@Validated @RequestBody IdParam param) { return currTaskService.top(param); } + @PostMapping(value = "runTask") @ApiOperation(value = "执行任务") public R runTask(@Validated @RequestBody IdParam param) throws InterruptedException, IOException { //点击执行按钮会判断当前任务是否为自动任务,如果是自动任务会去自动任务查一下该自动任务的上一步是否已完成(仅非一步时) return currTaskService.runTask(param.getId()); } + @PostMapping(value = "testRunTask") @ApiOperation(value = "执行任务") - public R testRunTask(@RequestBody RGVTask rgvTask){ - sendTaskToRgv(rgvTask.getTaskType(),rgvTask.getVehicleId(),rgvTask.getTaskNo(),rgvTask.getPickRow(),rgvTask.getSendRow(),rgvTask.getProcessNumber()); + public R testRunTask(@RequestBody RGVTask rgvTask) { + sendTaskToRgv(rgvTask.getTaskType(), rgvTask.getVehicleId(), rgvTask.getTaskNo(), rgvTask.getPickRow(), rgvTask.getSendRow(), rgvTask.getProcessNumber()); return null; } + @PostMapping(value = "testRgv") @ApiOperation(value = "测试rgv避让逻辑") private String testRgv(@RequestBody TestRgv testRgv) throws IOException { Long aLong = taskDistanceUtils.chooseVehicle(testRgv.getStartPoint(), testRgv.getEndPoint()); Boolean aBoolean = taskDistanceUtils.conflictForVehicle(testRgv.getVehicleId(), testRgv.getStartPoint(), testRgv.getEndPoint(), testRgv.getOtherVehicle()); - return String.valueOf(aLong)+String.valueOf(aBoolean); + return String.valueOf(aLong) + String.valueOf(aBoolean); } - private Integer sendTaskToRgv(Integer taskType,Long vehicleId, Long currTaskId, Long startPoint, Long endPoint, Integer processNumber) { + + private Integer sendTaskToRgv(Integer taskType, Long vehicleId, Long currTaskId, Long startPoint, Long endPoint, Integer processNumber) { Map json = new HashMap(); // taskType 1 搬运 json.put("taskType", taskType); @@ -351,7 +363,7 @@ public class CurrTaskController extends BaseController { @PostMapping(value = "testStoveCode") @ApiOperation(value = "测试炉号生成") - public String testStoveCode(@RequestBody TestStoveCode testStoveCode){ - return StoveCodeUtils.getStoveCode(testStoveCode.getKilnName(),testStoveCode.getCraft()); + public String testStoveCode(@RequestBody TestStoveCode testStoveCode) { + return StoveCodeUtils.getStoveCode(testStoveCode.getKilnName(), testStoveCode.getCraft()); } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java index 137a08b..7aa5d58 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/controller/EnergyController.java @@ -477,11 +477,15 @@ public class EnergyController extends BaseController { //获取检验结果 List apmsCheckResults = apmsCheckResultServiceBiz.list(new QueryWrapper() .eq(ApmsCheckResult.SHEET_NO, currTask.getSheetNo())); - List apmsCheckResultVos = BeanUtils.copyList(apmsCheckResults, ApmsCheckResultVo.class); - for (ApmsCheckResultVo apmsCheckResultVo : apmsCheckResultVos - ) { - apmsCheckResultVo.setStoveCode(currTask.getStoveCode()); + if (apmsCheckResults.size() != 0) { + List apmsCheckResultVos = BeanUtils.copyList(apmsCheckResults, ApmsCheckResultVo.class); + for (ApmsCheckResultVo apmsCheckResultVo : apmsCheckResultVos + ) { + apmsCheckResultVo.setStoveCode(currTask.getStoveCode()); + } + checkResultList.add(apmsCheckResultVos); } + Long kilnId = currTask.getKilnId(); KilnInfo kilnInfo = kilnInfoServiceBiz.getById(kilnId); Integer kilnType = kilnInfo.getType(); @@ -717,7 +721,6 @@ public class EnergyController extends BaseController { if (parRotSpeedValueList.size() > 0) { if (kilnType == 1) { List rot1Consume = new ArrayList<>(); - List rot2Consume = new ArrayList<>(); for (ParRotSpeedValue parRotSpeedValue : parRotSpeedValueList ) { EnergyVo rot1Vo = EnergyVo.builder().build(); @@ -727,17 +730,8 @@ public class EnergyController extends BaseController { rot1Vo.setValue(parRotSpeedValue.getOilStiSpeedAValue()); rot1Vo.setTime(parRotSpeedValue.getCreateTime()); rot1Consume.add(rot1Vo); - - EnergyVo rot2Vo = EnergyVo.builder().build(); - rot2Vo.setCode(currTask.getStoveCode()); - rot2Vo.setUnit("转/min"); - rot2Vo.setName("2号油搅拌转速"); - rot2Vo.setValue(parRotSpeedValue.getOilStiSpeedBValue()); - rot2Vo.setTime(parRotSpeedValue.getCreateTime()); - rot1Consume.add(rot2Vo); } rot1ConsumeList.add(rot1Consume); - rot2ConsumeList.add(rot2Consume); } } //温度趋势(实际温度、设定温度)油槽温度外区温度 @@ -839,30 +833,11 @@ public class EnergyController extends BaseController { setTempVo.setName("设定温度"); setupTempConsume.add(setTempVo); - EnergyVo outer1TempVo = EnergyVo.builder().build(); - outer1TempVo.setTime(parTemValue.getCreateTime()); - outer1TempVo.setCode(currTask.getStoveCode()); - outer1TempVo.setUnit("℃"); - outer1TempVo.setValue(parTemValue.getOuterZone1Temp()); - outer1TempVo.setName("外一区温度"); - setupTempConsume.add(outer1TempVo); - - EnergyVo outer2TempVo = EnergyVo.builder().build(); - outer2TempVo.setTime(parTemValue.getCreateTime()); - outer2TempVo.setCode(currTask.getStoveCode()); - outer2TempVo.setUnit("℃"); - outer2TempVo.setValue(parTemValue.getOuterZone2Temp()); - outer2TempVo.setName("外二区温度"); - setupTempConsume.add(outer2TempVo); - } tempConsumeList.add(actualTempConsume); tempConsumeList.add(setupTempConsume); - outerZone1TempConsumeList.add(outerZone1TempConsume); - outerZone2TempConsumeList.add(outerZone2TempConsume); } } - checkResultList.add(apmsCheckResultVos); } map.put("checkResult", checkResultList); map.put("ele", eleConsumeList); @@ -879,11 +854,8 @@ public class EnergyController extends BaseController { map.put("ammon", ammoniaConsumeList); map.put("car", carbonConsumeList); map.put("rot1", rot1ConsumeList); - map.put("rot2", rot2ConsumeList); map.put("temp", tempConsumeList); map.put("oilTemp", oilTempConsumeList); - map.put("outer1Temp", outerZone1TempConsumeList); - map.put("outer2Temp", outerZone2TempConsumeList); return successful(JSONObject.parseObject(JSON.toJSONString(map))); } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/CurrTaskService.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/CurrTaskService.java index 09870a0..dd8dfa2 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/CurrTaskService.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/CurrTaskService.java @@ -74,6 +74,22 @@ public interface CurrTaskService { */ R> currentTaskInfoPage(CurrTaskQueryParam param); + /** + * 未成功报工任务查询 + * + * @param param 查询参数 + * @return 结果 + */ + R> currentTaskInfoPageForNotToApms(CurrTaskQueryParam param); + + /** + * 未成功报工任务查询 + * + * @param + * @return 结果 + */ + R oneStepToApms(CurrTaskInfoVo currTaskInfoVo); + /** * 更新任务状态 * @@ -97,6 +113,7 @@ public interface CurrTaskService { * @return 结果 */ R deleteBySheetNo(String sheetNo); + /** * 通过id删除生产单 * diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java index 37498f0..f19081c 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/service/impl/CurrTaskServiceImpl.java @@ -29,6 +29,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.IOException; +import java.math.BigDecimal; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; @@ -45,24 +46,18 @@ import java.util.stream.Collectors; @Transactional public class CurrTaskServiceImpl extends BaseService implements CurrTaskService { - private Logger logger = LoggerFactory.getLogger(getClass()); @Autowired CurrTaskServiceBiz currTaskServiceBiz; - @Autowired CurrTaskDetService currTaskDetService; - @Autowired TaskHisService taskHisService; - @Autowired TaskDetHisService taskDetHisService; - @Autowired ApmsController apmsControl; @Autowired WebSocketServer webSocketServer; - @Autowired OrderInfoServiceBiz orderInfoServiceBiz; @Autowired @@ -83,6 +78,7 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService CurrTaskDetServiceBiz currTaskDetServiceBiz; @Autowired InStockInfoServiceBiz inStockInfoServiceBiz; + private Logger logger = LoggerFactory.getLogger(getClass()); @Override public CurrTaskVo getCurrTask(IdParam idParam) { @@ -109,7 +105,7 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService BeanUtils.copyProperties(param, currTask); currTask.setTaskType(TaskTypeEnum.WTK.getValue()); KilnInfo kilnInfo = kilnInfoServiceBiz.getById(currTask.getKilnId()); - if (param.getAutoTaskType()!=0){ + if (param.getAutoTaskType() != 0) { currTask.setIsAuto(1); } @@ -129,7 +125,7 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService public R> currentTaskPage(CurrTaskQueryParam param) { QueryWrapper currTaskQueryWrapper = new QueryWrapper<>(); currTaskQueryWrapper.eq(CurrTask.VALID, 1); - currTaskQueryWrapper.in(CurrTask.STATUS,0,1); + currTaskQueryWrapper.in(CurrTask.STATUS, 0, 1); Page page = currTaskServiceBiz.page(new Page<>(param.getCurrent(), param.getSize()), currTaskQueryWrapper); return successful(new PageVo<>(page, CurrTaskQueryVo.class)); } @@ -138,88 +134,88 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService public R> currentTaskInfoPage(CurrTaskQueryParam param) { QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq(CurrTask.VALID, 1); - wrapper.in(CurrTask.STATUS,0,1); + wrapper.in(CurrTask.STATUS, 0, 1); List currTaskList = currTaskServiceBiz.list(wrapper); - List list=new ArrayList<>(); - for (CurrTask currTask:currTaskList - ) { - CurrTaskInfoVo currTaskInfoVo=CurrTaskInfoVo.builder().build(); + List list = new ArrayList<>(); + for (CurrTask currTask : currTaskList + ) { + CurrTaskInfoVo currTaskInfoVo = CurrTaskInfoVo.builder().build(); //是否多步骤任务 currTaskInfoVo.setIsAuto(currTask.getIsAuto()); //任务状态 - if (currTask.getStatus()==1){ + if (currTask.getStatus() == 1) { currTaskInfoVo.setStatus(currTask.getStatus()); - }else if (currTask.getIsCache()==1){ + } else if (currTask.getIsCache() == 1) { currTaskInfoVo.setStatus(2); - }else { + } else { currTaskInfoVo.setStatus(0); } //生产单号 - if (currTask.getSheetNo()!=null){ + if (currTask.getSheetNo() != null) { currTaskInfoVo.setSheetNo(currTask.getSheetNo()); } currTaskInfoVo.setCreateTime(currTask.getCreateTime()); //开始位置 currTaskInfoVo.setStartPosition(currTask.getStartPosition()); //currTask - if (currTask.getIsAuto()==1){ + if (currTask.getIsAuto() == 1) { List currTasks = currTaskServiceBiz .list(new QueryWrapper() .eq(CurrTask.AUTO_EXE_TASK_ID, currTask.getAutoExeTaskId()) .orderByAsc(CurrTask.ID)); List currTaskVos = com.mt.wms.core.utils.BeanUtils.copyList(currTasks, CurrTaskVo.class); currTaskInfoVo.setCurrTaskVoList(currTaskVos); - String allStep="液压台"; - String nowStep="未开始"; - for (CurrTask currTask1:currTasks - ) { + String allStep = "液压台"; + String nowStep = "未开始"; + for (CurrTask currTask1 : currTasks + ) { InStockInfo inStockInfo = inStockInfoServiceBiz.getOne(new QueryWrapper().eq(InStockInfo.TASK_ID, currTask1.getId())); - if (inStockInfo!=null){ - List inStockInfoVoList=new ArrayList<>(); - InStockInfoVo inStockInfoVo=InStockInfoVo.builder().build(); - BeanUtils.copyProperties(inStockInfo,inStockInfoVo); + if (inStockInfo != null) { + List inStockInfoVoList = new ArrayList<>(); + InStockInfoVo inStockInfoVo = InStockInfoVo.builder().build(); + BeanUtils.copyProperties(inStockInfo, inStockInfoVo); inStockInfoVoList.add(inStockInfoVo); currTaskInfoVo.setInStockInfoVoList(inStockInfoVoList); } - if (currTask1.getStatus()==1){ - nowStep=currTask1.getTargetPosition(); - }else if (currTask1.getIsCache()==1){ - nowStep=currTask.getLocationName(); + if (currTask1.getStatus() == 1) { + nowStep = currTask1.getTargetPosition(); + } else if (currTask1.getIsCache() == 1) { + nowStep = currTask.getLocationName(); } - if (currTaskInfoVo.getInStockInfoVoList()!=null){ - if (currTaskInfoVo.getCurrTaskVoList().size()>0){ + if (currTaskInfoVo.getInStockInfoVoList() != null) { + if (currTaskInfoVo.getCurrTaskVoList().size() > 0) { - nowStep=currTaskInfoVo.getInStockInfoVoList().get(0).getLocationName(); + nowStep = currTaskInfoVo.getInStockInfoVoList().get(0).getLocationName(); } } - allStep=allStep.concat("->").concat(currTask1.getTargetPosition()); + allStep = allStep.concat("->").concat(currTask1.getTargetPosition()); } // currTaskInfoVo.setAllStep(allStep); currTaskInfoVo.setNowStep(nowStep); currTaskInfoVo.setAutoExeTaskId(currTask.getAutoExeTaskId()); - }else { + } else { currTaskInfoVo.setAllStep(currTask.getTargetPosition()); - if (currTask.getStatus()==1){ + if (currTask.getStatus() == 1) { currTaskInfoVo.setNowStep(currTask.getTargetPosition()); - }else if (currTask.getIsCache()==1){ + } else if (currTask.getIsCache() == 1) { currTaskInfoVo.setNowStep(currTask.getLocationName()); } currTaskInfoVo.setAutoExeTaskId(currTask.getId()); InStockInfo inStockInfo = inStockInfoServiceBiz.getOne(new QueryWrapper().eq(InStockInfo.TASK_ID, currTask.getId())); - if (inStockInfo!=null){ - List inStockInfoVoList=new ArrayList<>(); - InStockInfoVo inStockInfoVo=InStockInfoVo.builder().build(); - BeanUtils.copyProperties(inStockInfo,inStockInfoVo); + if (inStockInfo != null) { + List inStockInfoVoList = new ArrayList<>(); + InStockInfoVo inStockInfoVo = InStockInfoVo.builder().build(); + BeanUtils.copyProperties(inStockInfo, inStockInfoVo); inStockInfoVoList.add(inStockInfoVo); currTaskInfoVo.setInStockInfoVoList(inStockInfoVoList); } } //currTaskDet List currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper().eq(CurrTaskDet.CURR_TASK_ID, currTask.getId())); - currTaskInfoVo.setCurrTaskDetVoList(com.mt.wms.core.utils.BeanUtils.copyList(currTaskDetList,CurrTaskDetVo.class)); - for (CurrTaskDetVo currTaskDetVo:currTaskInfoVo.getCurrTaskDetVoList() - ) { + currTaskInfoVo.setCurrTaskDetVoList(com.mt.wms.core.utils.BeanUtils.copyList(currTaskDetList, CurrTaskDetVo.class)); + for (CurrTaskDetVo currTaskDetVo : currTaskInfoVo.getCurrTaskDetVoList() + ) { String idenCardNum = currTaskDetVo.getIdenCardNum(); OrderInfo orderInfo = orderInfoServiceBiz.getOne(new QueryWrapper().eq(OrderInfo.IDEN_CARD_NUM, idenCardNum)); currTaskDetVo.setCustomer(orderInfo.getCustomerName()); @@ -228,22 +224,173 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService } list.add(currTaskInfoVo); } - list = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CurrTaskInfoVo :: getAutoExeTaskId))), ArrayList::new)); + list = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CurrTaskInfoVo::getAutoExeTaskId))), ArrayList::new)); return successful(list); } + //获取未成功报工apms的任务,判定标准:没有生产单号,状态为完成 + @Override + public R> currentTaskInfoPageForNotToApms(CurrTaskQueryParam param) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(CurrTask.VALID, 1); + wrapper.in(CurrTask.STATUS, 2); + wrapper.isNull(CurrTask.SHEET_NO); + wrapper.between(CurrTask.CREATE_TIME, "2022-10-12 05:14:11", LocalDateTime.now()); + List currTaskList = currTaskServiceBiz.list(wrapper); + List list = new ArrayList<>(); + for (CurrTask currTask : currTaskList + ) { + CurrTaskInfoVo currTaskInfoVo = CurrTaskInfoVo.builder().build(); + //currTask + if (currTask.getIsAuto() == 1) { + + + currTaskInfoVo.setAutoExeTaskId(currTask.getAutoExeTaskId()); + List currTasks = currTaskServiceBiz + .list(new QueryWrapper() + .eq(CurrTask.AUTO_EXE_TASK_ID, currTask.getAutoExeTaskId()) + .orderByAsc(CurrTask.ID)); + List currTaskVos = com.mt.wms.core.utils.BeanUtils.copyList(currTasks, CurrTaskVo.class); + currTaskInfoVo.setCurrTaskVoList(currTaskVos); + String allStep = ""; + for (CurrTask currTask1 : currTasks + ) { + + allStep = allStep.concat("->").concat(currTask1.getTargetPosition()); + } + currTaskInfoVo.setAllStep(allStep); + } else { + currTaskInfoVo.setAllStep(currTask.getTargetPosition()); + } + //currTaskDet + List currTaskDetList = currTaskDetServiceBiz.list(new QueryWrapper().eq(CurrTaskDet.CURR_TASK_ID, currTask.getId())); + currTaskInfoVo.setCurrTaskDetVoList(com.mt.wms.core.utils.BeanUtils.copyList(currTaskDetList, CurrTaskDetVo.class)); + for (CurrTaskDetVo currTaskDetVo : currTaskInfoVo.getCurrTaskDetVoList() + ) { + String idenCardNum = currTaskDetVo.getIdenCardNum(); + OrderInfo orderInfo = orderInfoServiceBiz.getOne(new QueryWrapper().eq(OrderInfo.IDEN_CARD_NUM, idenCardNum)); + currTaskDetVo.setCustomer(orderInfo.getCustomerName()); + currTaskDetVo.setCraftIll(orderInfo.getCraftIll()); + currTaskDetVo.setProductModel(orderInfo.getProductModel()); + } + list.add(currTaskInfoVo); + } + list = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CurrTaskInfoVo::getAutoExeTaskId))), ArrayList::new)); + + return successful(list); + } + + @Override + public R oneStepToApms(CurrTaskInfoVo currTaskInfoVo) { + List currTaskDetVoList = currTaskInfoVo.getCurrTaskDetVoList(); + List currTaskVoList = currTaskInfoVo.getCurrTaskVoList(); + //报工apms + List currTaskDetList = com.mt.wms.core.utils.BeanUtils.copyList(currTaskDetVoList, CurrTaskDet.class); + List currTasks = com.mt.wms.core.utils.BeanUtils.copyList(currTaskVoList, CurrTask.class); + for (CurrTask currTask1 : currTasks + ) { + if (currTask1.getIsAuto() == 1) { + AutoExeTask autoExeTask = autoExeTaskServiceBiz.getById(currTaskInfoVo.getAutoExeTaskId()); + KilnInfo kilnInfo = kilnInfoServiceBiz.getById(currTask1.getKilnId()); + //加工炉为BMA或BMB时上报apms,其他的不需要上报 + if (kilnInfo.getType() == 1 || kilnInfo.getType() == 3) { + if (currTask1.getStoveCode() == null) { + return failed("该任务没有正常进炉加工生成炉号,不能上报apms!"); + } + //通知apms创建一个生产单 + ApmsCreateProcessSheet apmsCreateSheet = new ApmsCreateProcessSheet(); + apmsCreateSheet.setWorkShopCode("BM"); + apmsCreateSheet.setStartTime(currTask1.getBeginTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + apmsCreateSheet.setTechCode(currTask1.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()); + BigDecimal b = new BigDecimal(String.valueOf(e.getWeight())); + createItem.setWeight(b.doubleValue()); + createItems.add(createItem); + }); + //apmsCreateSheet.setStoveCode(code); + if (currTask1.getStoveCode() != null) { + apmsCreateSheet.setStoveCode(currTask1.getStoveCode()); + } + apmsCreateSheet.setItems(createItems); + logger.info(currTask1.getId() + "开始创建apms生产单号-手动上报"); + R processSheet = apmsControl.createProcessSheet(apmsCreateSheet); + if (!processSheet.getData().getSuccess()) { + logger.info(currTask1.getId() + "创建失败,APMS报错:" + processSheet.getData().getMsg()); + return failed(processSheet.getData().getMsg()); + } else { + logger.info(currTask1.getId() + "创建apms生产单号成功"); + currTask1.setSheetNo(processSheet.getData().getSheetNo()); + currTaskServiceBiz.updateById(currTask1); + //多步骤任务除了第一步写入sheetNo + if (currTask1.getIsAuto() == 1) { + CurrTask secondCurrTask = currTaskServiceBiz.getById(autoExeTask.getTTaskId()); + secondCurrTask.setSheetNo(currTask1.getSheetNo()); + currTaskServiceBiz.updateById(secondCurrTask); + //三步任务 + if (autoExeTask.getProcessFlowType() == 2) { + CurrTask threeCurrTask = currTaskServiceBiz.getById(autoExeTask.getThTaskId()); + threeCurrTask.setSheetNo(currTask1.getSheetNo()); + currTaskServiceBiz.updateById(threeCurrTask); + } + } + return successful("上报APMS成功"); + } + } + } else { + //通知apms创建一个生产单 + ApmsCreateProcessSheet apmsCreateSheet = new ApmsCreateProcessSheet(); + apmsCreateSheet.setWorkShopCode("BM"); + apmsCreateSheet.setStartTime(currTask1.getBeginTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); + apmsCreateSheet.setTechCode(currTask1.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()); + BigDecimal b = new BigDecimal(String.valueOf(e.getWeight())); + createItem.setWeight(b.doubleValue()); + createItems.add(createItem); + }); + //apmsCreateSheet.setStoveCode(code); + if (currTask1.getStoveCode() != null) { + apmsCreateSheet.setStoveCode(currTask1.getStoveCode()); + } + apmsCreateSheet.setItems(createItems); + logger.info(currTask1.getId() + "开始创建apms生产单号-手动上报"); + R processSheet = apmsControl.createProcessSheet(apmsCreateSheet); + if (!processSheet.getData().getSuccess()) { + logger.info(currTask1.getId() + "创建失败,APMS报错:" + processSheet.getData().getMsg()); + return failed(processSheet.getData().getMsg()); + } else { + logger.info(currTask1.getId() + "创建apms生产单号成功"); + currTask1.setSheetNo(processSheet.getData().getSheetNo()); + currTaskServiceBiz.updateById(currTask1); + } + } + } + return null; + } + @Override public R updateCurrTaskStatus(CurrTaskParam param) { CurrTask currTask = currTaskServiceBiz.getById(param.getId()); Integer status = param.getStatus(); Long kilnId = param.getKilnId(); //修改任务状态 - if(!status.equals(currTask.getStatus())){ + if (!status.equals(currTask.getStatus())) { //修改为加工中,多步骤任务修改为加工中,查询缓存区,查询前置任务状态,并修改 - if (status==1){ + if (status == 1) { InStockInfo inStockInfo = inStockInfoServiceBiz.getOne(new QueryWrapper().eq(InStockInfo.TASK_ID, currTask.getId())); - if (inStockInfo!=null){ + if (inStockInfo != null) { //更新库位状态为未占用 Location location = locationServiceBiz.getById(inStockInfo.getLocationId()); location.setStatus(0); @@ -251,11 +398,11 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService //删除库位缓存 inStockInfoServiceBiz.removeById(inStockInfo); } - if (currTask.getIsAuto()==1){ + if (currTask.getIsAuto() == 1) { AutoExeTask autoExeTask = autoExeTaskServiceBiz.getById(currTask.getAutoExeTaskId()); - if (currTask.getId().equals(autoExeTask.getFTaskId())){ + if (currTask.getId().equals(autoExeTask.getFTaskId())) { //该任务为自动任务第一条,是否有sheetNo,若无上报apms - if (currTask.getSheetNo()==null){ + if (currTask.getSheetNo() == null) { try { apmsCreateProcess(currTask); } catch (IOException e) { @@ -263,7 +410,7 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService } } } - if (currTask.getId().equals(autoExeTask.getTTaskId())){ + if (currTask.getId().equals(autoExeTask.getTTaskId())) { //该任务为自动任务第二条,修改自动任务第一条的状态 CurrTask currTask1 = currTaskServiceBiz.getById(autoExeTask.getFTaskId()); currTask1.setStatus(2); @@ -272,7 +419,7 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService currTask1.setUpdaterId(99); currTask1.setUpdateTime(LocalDateTime.now()); currTaskServiceBiz.updateById(currTask1); - }else if (currTask.getId().equals(autoExeTask.getThTaskId())){ + } else if (currTask.getId().equals(autoExeTask.getThTaskId())) { //该任务为自动任务第三条,修改自动任务第二条的状态 CurrTask currTask2 = currTaskServiceBiz.getById(autoExeTask.getFTaskId()); currTask2.setStatus(2); @@ -289,12 +436,12 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService currTask.setUpdateTime(LocalDateTime.now()); currTask.setBeginTime(LocalDateTime.now()); currTaskServiceBiz.updateById(currTask); - logger.info("修改任务"+currTask.getId()+"状态为加工中成功"); + logger.info("修改任务" + currTask.getId() + "状态为加工中成功"); } //修改为加工完成,查询缓存,并修改 - if (status==2){ + if (status == 2) { InStockInfo inStockInfo = inStockInfoServiceBiz.getOne(new QueryWrapper().eq(InStockInfo.TASK_ID, currTask.getId())); - if (inStockInfo!=null){ + if (inStockInfo != null) { //更新库位状态为未占用 Location location = locationServiceBiz.getById(inStockInfo.getLocationId()); location.setStatus(0); @@ -306,16 +453,16 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService currTask.setCreatorId(99); currTask.setBeginTime(LocalDateTime.now()); currTaskServiceBiz.updateById(currTask); - logger.info("修改任务"+currTask.getId()+"状态为加工完成成功"); + logger.info("修改任务" + currTask.getId() + "状态为加工完成成功"); } currTask.setStatus(status); currTask.setCreatorId(99); currTask.setBeginTime(LocalDateTime.now()); currTaskServiceBiz.updateById(currTask); - logger.info("修改任务"+currTask.getId()+"状态为未加工成功"); + logger.info("修改任务" + currTask.getId() + "状态为未加工成功"); } //修改目标加工炉 - if (!kilnId.equals(currTask.getKilnId())){ + if (!kilnId.equals(currTask.getKilnId())) { KilnInfo kiln = kilnInfoServiceBiz.getById(kilnId); //修改目标加工炉,修改终点 currTask.setKilnId(kilnId); @@ -325,7 +472,7 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService currTaskServiceBiz.updateById(currTask); InStockInfo inStockInfo = inStockInfoServiceBiz.getOne(new QueryWrapper().eq(InStockInfo.TASK_ID, currTask.getId())); //是否存在缓存 - if (inStockInfo!=null){ + if (inStockInfo != null) { //修改缓存后目标加工炉 inStockInfo.setKilnId(kilnId); inStockInfo.setKilnName(kiln.getKilnName()); @@ -334,19 +481,19 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService inStockInfoServiceBiz.updateById(inStockInfo); } //任务为多步骤任务 - if (currTask.getIsAuto()==1){ + if (currTask.getIsAuto() == 1) { AutoExeTask autoExeTask = autoExeTaskServiceBiz.getById(currTask.getAutoExeTaskId()); //任务为多步骤任务第一步 - if (currTask.getId().equals(autoExeTask.getFTaskId())){ + if (currTask.getId().equals(autoExeTask.getFTaskId())) { //修改多步骤第二步的起点 CurrTask currTask2 = currTaskServiceBiz.getById(autoExeTask.getTTaskId()); currTask2.setStartPosition(kiln.getCode()); currTask2.setUpdateTime(LocalDateTime.now()); currTask2.setUpdaterId(99); currTaskServiceBiz.updateById(currTask2); - }else if (currTask.getId().equals(autoExeTask.getTTaskId())){ + } else if (currTask.getId().equals(autoExeTask.getTTaskId())) { //任务为多步骤任务第二步且有第三步,修改第三步起点 - if (autoExeTask.getProcessFlowType()==2){ + if (autoExeTask.getProcessFlowType() == 2) { CurrTask currTask3 = currTaskServiceBiz.getById(autoExeTask.getThTaskId()); currTask3.setStartPosition(kiln.getCode()); currTask3.setUpdateTime(LocalDateTime.now()); @@ -387,22 +534,22 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService public R deleteBySheetNo(String sheetNo) { //一个生产单可能对应多个currTask,删除的时候查询是否对应多个,如果对应多个,自动循环删除所有currTask,当删除最后一条currTask时上报apms List currTaskList = currTaskServiceBiz.list(new QueryWrapper().eq(CurrTask.SHEET_NO, sheetNo)); - if (currTaskList.size()>1){ - int i=0; - for (CurrTask currTask:currTaskList - ) { + if (currTaskList.size() > 1) { + int i = 0; + for (CurrTask currTask : currTaskList + ) { i++; - if(currTask.getStatus()==0){ - if (i==currTaskList.size()){ + if (currTask.getStatus() == 0) { + if (i == currTaskList.size()) { R apmsStartProcessR = apmsControl.deleteBySheetNo(sheetNo); - if (!apmsStartProcessR.getData().getSuccess()){ + if (!apmsStartProcessR.getData().getSuccess()) { return failed(apmsStartProcessR.getData().getMsg()); } } Long currTaskId = currTask.getId(); - if (currTask.getIsAuto()==1){ + if (currTask.getIsAuto() == 1) { List currTaskList2 = currTaskServiceBiz.list(new QueryWrapper().eq(CurrTask.AUTO_EXE_TASK_ID, currTask.getAutoExeTaskId())); - if (currTaskList2.size()==1){ + if (currTaskList2.size() == 1) { autoExeTaskServiceBiz.removeById(currTask.getAutoExeTaskId()); } } @@ -410,45 +557,44 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService currTaskDetService.deleteByCurrTaskId(currTaskId); } - if (currTask.getStatus()==2){ + if (currTask.getStatus() == 2) { return failed("无法删除,任务已加工完成。"); - }if (currTask.getStatus()==1){ + } + if (currTask.getStatus() == 1) { return failed("无法删除,任务正在执行中。"); } } - return successful(0,"APMS生产单删除成功。",""); - }else { - for (CurrTask currTask:currTaskList - ) { - if (currTask.getStatus()==0){ + return successful(0, "APMS生产单删除成功。", ""); + } else { + for (CurrTask currTask : currTaskList + ) { + if (currTask.getStatus() == 0) { R apmsStartProcessR = apmsControl.deleteBySheetNo(sheetNo); - if (apmsStartProcessR.getData().getSuccess()) - { + if (apmsStartProcessR.getData().getSuccess()) { Long currTaskId = currTask.getId(); - if (currTask.getIsAuto()==1){ + if (currTask.getIsAuto() == 1) { List currTaskList2 = currTaskServiceBiz.list(new QueryWrapper().eq(CurrTask.AUTO_EXE_TASK_ID, currTask.getAutoExeTaskId())); - if (currTaskList2.size()==1){ + if (currTaskList2.size() == 1) { autoExeTaskServiceBiz.removeById(currTask.getAutoExeTaskId()); } } currTaskServiceBiz.removeById(currTaskId); currTaskDetService.deleteByCurrTaskId(currTaskId); - if (currTask.getIsAuto()==1){ + if (currTask.getIsAuto() == 1) { List currTaskList2 = currTaskServiceBiz.list(new QueryWrapper().eq(CurrTask.AUTO_EXE_TASK_ID, currTask.getAutoExeTaskId())); - if (currTaskList2.size()==0){ + if (currTaskList2.size() == 0) { autoExeTaskServiceBiz.removeById(currTask.getAutoExeTaskId()); } } - return successful(0,"APMS生产单删除成功。",""); - } - else - { + return successful(0, "APMS生产单删除成功。", ""); + } else { return failed(apmsStartProcessR.getData().getMsg()); } } - if (currTask.getStatus()==2){ + if (currTask.getStatus() == 2) { return failed("无法删除,任务已加工完成。"); - }if (currTask.getStatus()==1){ + } + if (currTask.getStatus() == 1) { return failed("无法删除,任务正在执行中。"); } @@ -461,31 +607,31 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService @Override public R deleteById(IdParam idParam) { CurrTask currTask = currTaskServiceBiz.getById(idParam.getId()); - if (currTask.getIsAuto()==1){ + if (currTask.getIsAuto() == 1) { List currTaskList = currTaskServiceBiz.list(new QueryWrapper().eq(CurrTask.AUTO_EXE_TASK_ID, currTask.getAutoExeTaskId())); - for (CurrTask currTask1:currTaskList - ) { - if (currTask1.getStatus()!=0){ + for (CurrTask currTask1 : currTaskList + ) { + if (currTask1.getStatus() != 0) { return R.failed("该自动任务已有步骤在执行中或执行完成,不能删除!"); } } //能删除 autoExeTaskServiceBiz.removeById(currTask.getAutoExeTaskId()); - for (CurrTask currTask1:currTaskList - ) { + for (CurrTask currTask1 : currTaskList + ) { InStockInfo inStockInfo = inStockInfoServiceBiz.getOne(new QueryWrapper().eq(InStockInfo.TASK_ID, currTask1.getId())); - if (inStockInfo!=null){ + if (inStockInfo != null) { Location location = locationServiceBiz.getById(inStockInfo.getLocationId()); location.setStatus(0); locationServiceBiz.updateById(location); inStockInfoServiceBiz.removeById(inStockInfo); } - currTaskDetServiceBiz.remove(new QueryWrapper().eq(CurrTaskDet.CURR_TASK_ID,currTask1.getId())); + currTaskDetServiceBiz.remove(new QueryWrapper().eq(CurrTaskDet.CURR_TASK_ID, currTask1.getId())); currTaskServiceBiz.removeById(currTask1); } return R.ok(idParam.getId().toString()); - }else { - currTaskDetServiceBiz.remove(new QueryWrapper().eq(CurrTaskDet.CURR_TASK_ID,currTask.getId())); + } else { + currTaskDetServiceBiz.remove(new QueryWrapper().eq(CurrTaskDet.CURR_TASK_ID, currTask.getId())); currTaskServiceBiz.removeById(idParam); return R.ok(idParam.getId().toString()); } @@ -530,13 +676,13 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService @Override public R runTask(Long taskId) throws InterruptedException, IOException { CurrTask currTask = currTaskServiceBiz.getById(taskId); - if (currTask.getStatus()!=0){ + if (currTask.getStatus() != 0) { return R.failed("该任务状态不为未执行,无法执行!"); } //是否为自动任务 - if (currTask.getIsAuto()==1){ + if (currTask.getIsAuto() == 1) { List exeTaskList = autoExeTaskServiceBiz.list(new QueryWrapper().eq(AutoExeTask.F_TASK_ID, taskId)); - if (exeTaskList.size()==0){ + if (exeTaskList.size() == 0) { return R.failed("该任务为多步骤加工任务且该步骤不是第一步,请选择第一步骤任务执行!"); } } @@ -550,6 +696,7 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService /** * 传入任务id,查询任务炉子,然后根据炉子查询等待列表,然后时间置为早 + * * @param idParam * @return */ @@ -557,26 +704,27 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService public R top(IdParam idParam) { CurrTask currTask = currTaskServiceBiz.getById(idParam.getId()); currTask.getIsCache(); - if (currTask.getIsCache()==0){ + if (currTask.getIsCache() == 0) { return R.failed("当前任务未进入等待队列,不能置顶"); } Long kilnId = currTask.getKilnId(); List inStockInfoList = inStockInfoServiceBiz.list(new QueryWrapper() .eq(InStockInfo.KILN_ID, kilnId) - .eq(InStockInfo.TYPE,1) - .eq(InStockInfo.STATUS,2) + .eq(InStockInfo.TYPE, 1) + .eq(InStockInfo.STATUS, 2) .orderByAsc(InStockInfo.IN_TIME)); - if (inStockInfoList.size()<2){ + if (inStockInfoList.size() < 2) { return R.failed("当前加工炉等待队列只有一个任务,无需置顶"); } - LocalDateTime inTime=null; + LocalDateTime inTime = null; inTime = inStockInfoList.get(0).getInTime(); InStockInfo inStockInfo = inStockInfoServiceBiz.getOne(new QueryWrapper().eq(InStockInfo.LOCATION_ID, currTask.getLocationId())); inStockInfo.setInTime(inTime.minusHours(1)); inStockInfoServiceBiz.updateById(inStockInfo); - return R.ok("当前任务置顶成功",""); + return R.ok("当前任务置顶成功", ""); } + /** * 上报apms创建生产单并开始处理 * @@ -615,13 +763,13 @@ public class CurrTaskServiceImpl extends BaseService implements CurrTaskService currTask.setSheetNo(processSheet.getData().getSheetNo()); currTaskServiceBiz.updateById(currTask); //多步骤任务除了第一步写入sheetNo - if (currTask.getIsAuto()==1){ + if (currTask.getIsAuto() == 1) { AutoExeTask autoExeTask = autoExeTaskServiceBiz.getById(currTask.getAutoExeTaskId()); CurrTask secondCurrTask = currTaskServiceBiz.getById(autoExeTask.getTTaskId()); secondCurrTask.setSheetNo(currTask.getSheetNo()); currTaskServiceBiz.updateById(secondCurrTask); //三步任务 - if (autoExeTask.getProcessFlowType()==2){ + if (autoExeTask.getProcessFlowType() == 2) { CurrTask threeCurrTask = currTaskServiceBiz.getById(autoExeTask.getThTaskId()); threeCurrTask.setSheetNo(currTask.getSheetNo()); currTaskServiceBiz.updateById(threeCurrTask); 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 e0f1047..c768666 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 @@ -1218,20 +1218,25 @@ public class AsynRunTaskService extends BaseService { * 单步骤任务都生成炉号 */ private void createStoveCode(CurrTask currTask) { - //单步骤任务 + //单步骤任务,直接生成炉号 if (currTask.getIsAuto() == 0) { String stoveCode = StoveCodeUtils.getStoveCode(currTask.getTargetPosition(), currTask.getPlcValue()); currTask.setStoveCode(stoveCode); currTaskServiceBiz.updateById(currTask); return; } - if (!(isFirstTask(currTask) && currTask.getKilnId() == 3)) { - //String stoveCode = CodeGeneratorHelper.getStoveCode(currTask.getTargetPosition(), currTask.getPlcValue().toString()); - String stoveCode = StoveCodeUtils.getStoveCode(currTask.getTargetPosition(), currTask.getPlcValue()); - currTask.setStoveCode(stoveCode); - currTaskServiceBiz.updateById(currTask); - } else { - logger.info(currTask.getId() + "任务为多步骤任务且第一步为清洗,不生成洗炉炉号."); + //多步骤任务,只有BMA,BMB步骤生成炉号 + else { + //获取加工炉 + KilnInfo kilnInfo = kilnInfoServiceBiz.getById(currTask.getKilnId()); + //只有BMA,BMB生成炉号 + if (kilnInfo.getType() == 1 || kilnInfo.getType() == 3) { + String stoveCode = StoveCodeUtils.getStoveCode(currTask.getTargetPosition(), currTask.getPlcValue()); + currTask.setStoveCode(stoveCode); + currTaskServiceBiz.updateById(currTask); + } else { + logger.info(currTask.getId() + "任务为多步骤任务但该步骤不生成洗炉炉号."); + } } } @@ -1256,8 +1261,9 @@ public class AsynRunTaskService extends BaseService { currTaskDetList.forEach(e -> { CreateItem createItem = new CreateItem(); createItem.setItemCode(e.getIdenCardNum()); + BigDecimal b = new BigDecimal(String.valueOf(e.getWeight())); + createItem.setWeight(b.doubleValue()); createItem.setQuantity(e.getQuantity().intValue()); - createItem.setWeight(e.getWeight().doubleValue()); createItems.add(createItem); }); //apmsCreateSheet.setStoveCode(code);