diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorkConsumeServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorkConsumeServiceImpl.java index 2a11d2ed..18a59502 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorkConsumeServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/MesReportWorkConsumeServiceImpl.java @@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.op.mes.mapper.MesReportWorkConsumeMapper; import com.op.mes.service.IMesReportWorkConsumeService; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; /** @@ -169,6 +170,7 @@ public class MesReportWorkConsumeServiceImpl implements IMesReportWorkConsumeSer @Override @DS("#header.poolName") + @Transactional(rollbackFor = IllegalArgumentException.class) public int submitConsumePS(List mesReportWorkConsumes) { //根据belong_work_order找到sap工单(子子母) @@ -177,54 +179,61 @@ public class MesReportWorkConsumeServiceImpl implements IMesReportWorkConsumeSer return 0; } + Date nowTime = DateUtils.getNowDate(); + String updateBy = SecurityUtils.getUsername(); + for (MesReportWorkConsume mesReportWorkConsume : mesReportWorkConsumes) { + mesReportWorkConsume.setUpdateTime(nowTime); + mesReportWorkConsume.setUpdateBy(updateBy); + } + List updates = mesReportWorkConsumes + .stream() + .filter(u -> u.getCreateTime() != null).collect(Collectors.toList()); + List adds = mesReportWorkConsumes + .stream() + .filter(u -> u.getCreateTime() == null).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(adds)) { + Map consumeInfoMap = new HashMap<>(); + for (MesReportWorkConsume add : adds) { + MesReportWorkConsume newConsumeInfo = consumeInfoMap.get(add.getWorkorderCode()); + if (newConsumeInfo == null) { + MesReportWorkConsume mapItem = mesReportWorkConsumeMapper.getNewConsumeInfo(add.getWorkorderCode()); + consumeInfoMap.put(add.getWorkorderCode(), mapItem); + } + newConsumeInfo = consumeInfoMap.get(add.getWorkorderCode()); + + add.setRecordId(IdUtils.fastSimpleUUID()); + add.setReportCode(newConsumeInfo.getReportCode()); + add.setWorkorderCode(newConsumeInfo.getWorkorderCode()); + add.setCreateTime(nowTime); + add.setCreateTime(nowTime); + add.setAttr1("1");//新增标识 + add.setParentOrder(newConsumeInfo.getParentOrder()); + } + int addNum = mesReportWorkConsumeMapper.addConsumePS(adds); + System.out.println("addNum:" + addNum); + } + int updateNum = mesReportWorkConsumeMapper.submitConsumePS(updates); + System.out.println("updateNum:" + updateNum); + /**修改sap物料损耗组成**/ R updateBomsSap = this.updateAttr1BomsSap(workOrders); if(updateBomsSap.getCode()== 500){ - return 0; - }else { - Date nowTime = DateUtils.getNowDate(); - String updateBy = SecurityUtils.getUsername(); - for (MesReportWorkConsume mesReportWorkConsume : mesReportWorkConsumes) { - mesReportWorkConsume.setUpdateTime(nowTime); - mesReportWorkConsume.setUpdateBy(updateBy); - } - List updates = mesReportWorkConsumes - .stream() - .filter(u -> u.getCreateTime() != null).collect(Collectors.toList()); - List adds = mesReportWorkConsumes - .stream() - .filter(u -> u.getCreateTime() == null).collect(Collectors.toList()); - if (!CollectionUtils.isEmpty(adds)) { - Map consumeInfoMap = new HashMap<>(); - for (MesReportWorkConsume add : adds) { - MesReportWorkConsume newConsumeInfo = consumeInfoMap.get(add.getWorkorderCode()); - if (newConsumeInfo == null) { - MesReportWorkConsume mapItem = mesReportWorkConsumeMapper.getNewConsumeInfo(add.getWorkorderCode()); - consumeInfoMap.put(add.getWorkorderCode(), mapItem); - } - newConsumeInfo = consumeInfoMap.get(add.getWorkorderCode()); - - add.setRecordId(IdUtils.fastSimpleUUID()); - add.setReportCode(newConsumeInfo.getReportCode()); - add.setWorkorderCode(newConsumeInfo.getWorkorderCode()); - add.setCreateTime(nowTime); - add.setCreateTime(nowTime); - add.setAttr1("1");//新增标识 - add.setParentOrder(newConsumeInfo.getParentOrder()); - } - int addNum = mesReportWorkConsumeMapper.addConsumePS(adds); - System.out.println("addNum:" + addNum); - } - int updateNum = mesReportWorkConsumeMapper.submitConsumePS(updates); - System.out.println("addNum:" + updateNum); - return updateNum; + throw new IllegalArgumentException("修改组件异常"); } + return 1; + } //修改报工物料组成 private R updateAttr1BomsSap(List workOrderCodes) { //是否有变动的物料损耗组成 - List updateBoms = mesReportWorkMapper.getUpdateAttr1Boms(workOrderCodes.get(workOrderCodes.size()-1)); + MesReportWork workorder = workOrderCodes.get(workOrderCodes.size()-1); + if(workorder == null ){ + logger.info(workorder.getWorkorderCode() + + "报工损耗物料组件修改请求:null"); + return R.fail(); + } + List updateBoms = mesReportWorkMapper.getUpdateAttr1Boms(workorder); if(!CollectionUtils.isEmpty(updateBoms)){ List> mapList = new ArrayList<>(); Map mapBom = null; @@ -238,14 +247,14 @@ public class MesReportWorkConsumeServiceImpl implements IMesReportWorkConsumeSer mapList.add(mapBom); } - logger.info(workOrderCodes.get(workOrderCodes.size()-1).getWorkorderCode() + logger.info(workorder.getWorkorderCode() + "报工损耗物料组件修改请求:" + JSONObject.toJSONString(mapList)); R bomUpdateR = remoteSapService.shopOrderBomUpdate(mapList); - logger.info(workOrderCodes.get(workOrderCodes.size()-1).getWorkorderCode() + logger.info(workorder.getWorkorderCode() + "报工损耗物料组件修改结果:" + JSONObject.toJSONString(bomUpdateR)); return bomUpdateR; } - return R.ok(); + return R.fail(); } @Override diff --git a/op-modules/op-quality/src/main/java/com/op/quality/controller/QcCheckTaskIncomeController.java b/op-modules/op-quality/src/main/java/com/op/quality/controller/QcCheckTaskIncomeController.java index 71c9810a..c0d601a9 100644 --- a/op-modules/op-quality/src/main/java/com/op/quality/controller/QcCheckTaskIncomeController.java +++ b/op-modules/op-quality/src/main/java/com/op/quality/controller/QcCheckTaskIncomeController.java @@ -12,6 +12,7 @@ import java.util.stream.Collectors; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; @@ -193,12 +194,17 @@ public class QcCheckTaskIncomeController extends BaseController { return AjaxResult.error(JSONObject.toJSONString(incomeR)); } logger.info("来料信息查询结果:" + JSONObject.toJSONString(incomeR)); - List incomeAll = (List)incomeR.getData(); + List incomeAll = JSONArray.parseArray(JSONObject.toJSONString(incomeR.getData()),QcCheckTaskIncomeDTO.class); //已经生成过检验任务的采购订单 List todayIncomeLists = qcCheckTaskIncomeService.getTodayIncomeLists(); - List newIncomes = incomeAll.stream() - .filter(item -> !todayIncomeLists.contains(item.getOrderNo())) - .collect(Collectors.toList()); + List newIncomes= null; + if(CollectionUtils.isEmpty(todayIncomeLists)){ + newIncomes = incomeAll; + }else{ + newIncomes = incomeAll.stream() + .filter(item -> !todayIncomeLists.contains(item.getOrderNo())) + .collect(Collectors.toList()); + } int successNum = 0;//成功任务数 int failNum = 0;//失败任务数