diff --git a/op-modules/op-plan/src/main/java/com/op/plan/controller/ProWetMaterialPlanController.java b/op-modules/op-plan/src/main/java/com/op/plan/controller/ProWetMaterialPlanController.java index a3bebd10..395b0241 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/controller/ProWetMaterialPlanController.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/controller/ProWetMaterialPlanController.java @@ -183,15 +183,15 @@ public class ProWetMaterialPlanController extends BaseController { public AjaxResult remove(@PathVariable String[] ids) { return toAjax(proWetMaterialPlanService.deleteProWetMaterialPlanByIds(ids)); } - /** - * 提交湿料计划同步WCS - * @param - * @return - */ - @Log(title = "湿料计划同步", businessType = BusinessType.EXPORT) - @GetMapping("/syncWCS/{id}") - @RequiresPermissions("mes:plan:add") - public AjaxResult syncWCS(@PathVariable String id) { - return proWetMaterialPlanService.syncWCS(id); - } +// /** +// * 提交湿料计划同步WCS +// * @param +// * @return +// */ +// @Log(title = "湿料计划同步", businessType = BusinessType.EXPORT) +// @GetMapping("/syncWCS/{id}") +// @RequiresPermissions("mes:plan:add") +// public AjaxResult syncWCS(@PathVariable String id) { +// return proWetMaterialPlanService.syncWCS(id); +// } } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/service/IProWetMaterialPlanService.java b/op-modules/op-plan/src/main/java/com/op/plan/service/IProWetMaterialPlanService.java index c98d7b87..f99e2ea9 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/service/IProWetMaterialPlanService.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/service/IProWetMaterialPlanService.java @@ -126,5 +126,5 @@ public interface IProWetMaterialPlanService { */ AjaxResult checkChangePlan(String id); - AjaxResult syncWCS(@PathVariable String id); +// AjaxResult syncWCS(@PathVariable String id); } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java b/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java index 2946d3d3..c19f9da0 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java @@ -14,6 +14,7 @@ import com.op.common.core.utils.DateUtils; import com.op.common.core.utils.StringUtils; import com.op.common.core.utils.uuid.IdUtils; import com.op.common.core.web.domain.AjaxResult; +import com.op.common.security.utils.SecurityUtils; import com.op.plan.domain.*; import com.op.plan.domain.dto.ProOrderDTO; import com.op.plan.domain.dto.SplitOrderDTO; @@ -241,10 +242,14 @@ public class ProOrderServiceImpl implements IProOrderService { @Transactional(rollbackFor = Exception.class) @DS("#header.poolName") public AjaxResult syncSAP() { - SapProOrder sapqo = proOrderMapper.getMaxCreatetime(); - if (sapqo == null) { - sapqo.setCreateTime(DateUtils.getNowDate()); - } + SapProOrder sapqo = new SapProOrder();//proOrderMapper.getMaxCreatetime(); + //if (sapqo == null) { + // sapqo.setCreateTime(DateUtils.getNowDate()); + //} + + Calendar calendar = Calendar.getInstance(); //创建Calendar 的实例 + calendar.add(Calendar.DAY_OF_MONTH,-1); //当前时间减去一天,即一天前的时间 + sapqo.setCreateTime(calendar.getTime()); //获取当前所选工厂 HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); String key = "#header.poolName"; @@ -261,24 +266,37 @@ public class ProOrderServiceImpl implements IProOrderService { proOrder = new ProOrder(); BeanUtils.copyProperties(sapProOrder, proOrder); //pro_order_workorder - - List orderExit = proOrderWorkorderMapper.selectWorkOrderByOrderCode(proOrder.getOrderCode()); - if (CollectionUtils.isEmpty(orderExit)) {//不存在就插入 + Date nowDate = DateUtils.getNowDate(); + ProOrder orderExit = proOrderMapper.selectProOrderByOrderCode(proOrder.getOrderCode()); + if (orderExit==null) {//不存在就插入 + proOrder.setId(IdUtils.fastSimpleUUID()); + //proOrder.setCreateTime(nowDate); + proOrder.setCreateBy(SecurityUtils.getUsername()); proOrderMapper.insertProOrder(proOrder); - } else if ("w0".equals(orderExit.get(0).getStatus())) { - //如果工单没下达,则更新pro_order - proOrderMapper.updateProOrder(proOrder); - List orderCodes = this.getListByPCode(proOrder); - if (!CollectionUtils.isEmpty(orderCodes)) { - List idstr = orderCodes.stream().map(order -> order.getId()).collect(Collectors.toList()); - String[] ids = idstr.stream().toArray(String[]::new); - //删除工单pro_order_workorder - proOrderWorkorderMapper.deleteProOrderWorkorderByWorkorderIds(ids); - //删除批次pro_order_workorder_batch - proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderIds(ids); + } else {//存在,如果没下发,更新,否则不允许更新,关闭订单 + proOrder.setId(orderExit.getId()); + proOrder.setQuantitySplit(0L); + ProOrderWorkorder owork = new ProOrderWorkorder(); + owork.setOrderCode(proOrder.getOrderCode()); + owork.setStatus("w1"); + List workOrders = proOrderWorkorderMapper.selectProOrderWorkorderList(owork); + if (CollectionUtils.isEmpty(workOrders)) {//更新 + proOrder.setUpdateTime(nowDate); + proOrder.setUpdateBy(SecurityUtils.getUsername()); + //如果工单没下达,则更新pro_order + proOrderMapper.updateProOrder(proOrder); + List orderCodes = this.getListByPCode(proOrder); + if (!CollectionUtils.isEmpty(orderCodes)) { + List idstr = orderCodes.stream().map(order -> order.getId()).collect(Collectors.toList()); + String[] ids = idstr.stream().toArray(String[]::new); + //删除工单pro_order_workorder + proOrderWorkorderMapper.deleteProOrderWorkorderByWorkorderIds(ids); + //删除批次pro_order_workorder_batch + proOrderWorkorderBatchMapper.deleteProOrderWorkorderBatchByWorkorderIds(ids); + } + } else {//关闭订单 + //TODO;不更新 } - } else if ("w1".equals(orderExit.get(0).getStatus())) { - //TODO;不更新 } } return success(); diff --git a/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProWetMaterialPlanServiceImpl.java b/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProWetMaterialPlanServiceImpl.java index e043679d..41a6bbac 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProWetMaterialPlanServiceImpl.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProWetMaterialPlanServiceImpl.java @@ -47,9 +47,9 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService private ProOrderWorkorderMapper proOrderWorkorderMapper; @Autowired private ProWetMaterialPlanDetailMapper proWetMaterialPlanDetailMapper; - - @Value("${wcs.url1}") - public String materialPlanSyncUrl; +// +// @Value("${wcs.url1}") +// public String materialPlanSyncUrl; /** * 查询湿料计划管理 * @@ -307,65 +307,65 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService * ] * } */ - @Override - @DS("#header.poolName") - @Transactional(rollbackFor = Exception.class) - public AjaxResult syncWCS(@PathVariable String id) { - - //获取湿料计划 - WCSDTO wcsdto = new WCSDTO(); - wcsdto.setReqCode(id);//主计划id - wcsdto.setReqTime(DateUtils.getNowDate()); - List planDetails = proWetMaterialPlanDetailMapper.selectDetailListById(id); - - //罐 - List gList = planDetails.stream().map(ProWetMaterialPlanDetail::getBucketCode) - .distinct().collect(Collectors.toList()); - //罐-料 - Map glMap = planDetails.stream() - .collect(Collectors.toMap(ProWetMaterialPlanDetail::getBucketCode, - ProWetMaterialPlanDetail::getMaterialCode, (k1, k2) -> k1)); - - List data = new ArrayList<>(); - WCSDataDTO wCSDataDTO = null; - for (String g : gList) { - wCSDataDTO = new WCSDataDTO(); - wCSDataDTO.setSku(glMap.get(g));//罐 - wCSDataDTO.setLoadNo(g);//料 - List unLoadItems = new ArrayList<>();//上位机集合 - //罐-工单 - List ggList = planDetails.stream() - .filter(plan -> plan.getBucketCode().equals(g)) - .collect(Collectors.toList()); - WCSDataItemsDTO wCSDataItemsDTO = null; - for (ProWetMaterialPlanDetail gg : ggList) { - //根据工单查收坯机编码 - String bucketCode = proOrderWorkorderMapper.getBucketCodeByWorkId(gg.getWorkorderId()); - if (StringUtils.isNotBlank(bucketCode)) { - wCSDataItemsDTO = new WCSDataItemsDTO(); - wCSDataItemsDTO.setUnloadNo(bucketCode); - unLoadItems.add(wCSDataItemsDTO); - } - } - wCSDataDTO.setUnLoadItems(unLoadItems); - } - wcsdto.setData(data); - try { - String sendResult = HttpUtils.sendPost(materialPlanSyncUrl, JSON.toJSONString(wcsdto)); - WCSDTO resultdto = JSON.parseObject(sendResult, WCSDTO.class); - if ("1".equals(resultdto.getCode())) { - return error(resultdto.getMessage()); - } - }catch (Exception e){ - return error("调用接口异常"); - } - - ProWetMaterialPlan detail = new ProWetMaterialPlan(); - detail.setId(id); - detail.setSyncFlag("Y");//已经同步的标识 - proWetMaterialPlanMapper.updateProWetMaterialPlan(detail); - return success(); - } +// @Override +// @DS("#header.poolName") +// @Transactional(rollbackFor = Exception.class) +// public AjaxResult syncWCS(@PathVariable String id) { +// +// //获取湿料计划 +// WCSDTO wcsdto = new WCSDTO(); +// wcsdto.setReqCode(id);//主计划id +// wcsdto.setReqTime(DateUtils.getNowDate()); +// List planDetails = proWetMaterialPlanDetailMapper.selectDetailListById(id); +// +// //罐 +// List gList = planDetails.stream().map(ProWetMaterialPlanDetail::getBucketCode) +// .distinct().collect(Collectors.toList()); +// //罐-料 +// Map glMap = planDetails.stream() +// .collect(Collectors.toMap(ProWetMaterialPlanDetail::getBucketCode, +// ProWetMaterialPlanDetail::getMaterialCode, (k1, k2) -> k1)); +// +// List data = new ArrayList<>(); +// WCSDataDTO wCSDataDTO = null; +// for (String g : gList) { +// wCSDataDTO = new WCSDataDTO(); +// wCSDataDTO.setSku(glMap.get(g));//罐 +// wCSDataDTO.setLoadNo(g);//料 +// List unLoadItems = new ArrayList<>();//上位机集合 +// //罐-工单 +// List ggList = planDetails.stream() +// .filter(plan -> plan.getBucketCode().equals(g)) +// .collect(Collectors.toList()); +// WCSDataItemsDTO wCSDataItemsDTO = null; +// for (ProWetMaterialPlanDetail gg : ggList) { +// //根据工单查收坯机编码 +// String bucketCode = proOrderWorkorderMapper.getBucketCodeByWorkId(gg.getWorkorderId()); +// if (StringUtils.isNotBlank(bucketCode)) { +// wCSDataItemsDTO = new WCSDataItemsDTO(); +// wCSDataItemsDTO.setUnloadNo(bucketCode); +// unLoadItems.add(wCSDataItemsDTO); +// } +// } +// wCSDataDTO.setUnLoadItems(unLoadItems); +// } +// wcsdto.setData(data); +// try { +// String sendResult = HttpUtils.sendPost(materialPlanSyncUrl, JSON.toJSONString(wcsdto)); +// WCSDTO resultdto = JSON.parseObject(sendResult, WCSDTO.class); +// if ("1".equals(resultdto.getCode())) { +// return error(resultdto.getMessage()); +// } +// }catch (Exception e){ +// return error("调用接口异常"); +// } +// +// ProWetMaterialPlan detail = new ProWetMaterialPlan(); +// detail.setId(id); +// detail.setSyncFlag("Y");//已经同步的标识 +// proWetMaterialPlanMapper.updateProWetMaterialPlan(detail); +// return success(); +// } /** * 创建湿料(主)计划 diff --git a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderBatchMapper.xml b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderBatchMapper.xml index 856339c5..2b2ea98f 100644 --- a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderBatchMapper.xml +++ b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderBatchMapper.xml @@ -132,9 +132,12 @@ delete from pro_order_workorder_batch where workorder_id in - - #{workorderId} - + ( + select workorder_id from pro_order_workorder where order_id in + + #{workorderId} + + ) diff --git a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderMapper.xml b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderMapper.xml index ad5b4a61..412d8733 100644 --- a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderMapper.xml +++ b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderMapper.xml @@ -384,7 +384,7 @@ - delete from pro_order_workorder where workorder_id in + delete from pro_order_workorder where order_id in #{workorderId} diff --git a/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapOrderServiceImpl.java b/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapOrderServiceImpl.java index 9e2ec540..9f17929e 100644 --- a/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapOrderServiceImpl.java +++ b/op-modules/op-sap/src/main/java/com/op/sap/service/impl/SapOrderServiceImpl.java @@ -40,7 +40,7 @@ public class SapOrderServiceImpl implements SapOrderService { JCoTable maraTable = func.getTableParameterList().getTable("ZMES_PRO"); JCoRecordMetaData metaData = maraTable.getRecordMetaData(); System.out.println("###" + metaData.toString()); - SapProOrder proOrder = new SapProOrder(); + List proOrderList = new ArrayList<>(); // 循环输出 Table 数据 for (int i = 0; i < maraTable.getNumRows(); i++) { @@ -62,6 +62,7 @@ public class SapOrderServiceImpl implements SapOrderService { System.out.println("订单号:" + AUFNR + " - 订单类型:" + AUART + " - 上级订单编号:" + MAUFNR + " - 物料号:" + PLNBEZ + " - 物料描述(短文本):" + MAKTX + " - 订单的计划工厂:" + PWERK + " - 订单数量总计:" + GAMNG + " - 基本计量单位:" + GMEIN + " - 任务清单组码:" + PLNNR + " - 基本开始日期:" + GSTRP + " - 基本完成日期:" + GLTRP + " - 输入者:" + ERNAM + " - 创建日期:" + ERDAT + " - 系统状态:" + STTXT); + SapProOrder proOrder = new SapProOrder(); proOrder.setId(IdUtils.fastSimpleUUID()); proOrder.setPlanFactoryCode(PWERK); proOrder.setOrderCode(AUFNR); @@ -78,7 +79,7 @@ public class SapOrderServiceImpl implements SapOrderService { proOrder.setCreateTime(DateUtils.dateTime("yyyy-MM-dd", ERDAT)); proOrder.setUpdateBy(ERNAM); proOrder.setUpdateTime(DateUtils.dateTime("yyyy-MM-dd", ERDAT)); - proOrder.setStatus("0"); + proOrder.setStatus("o0"); proOrderList.add(proOrder); // remotePlanService.sapAddOrder(proOrder); // remoteMesService.sapAddOrder(proOrder);