diff --git a/op-modules/op-mes/src/main/java/com/op/mes/controller/ProOrderController.java b/op-modules/op-mes/src/main/java/com/op/mes/controller/ProOrderController.java index d0ffac94..04ec2e22 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/controller/ProOrderController.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/controller/ProOrderController.java @@ -130,6 +130,7 @@ public class ProOrderController extends BaseController { public AjaxResult add(@RequestBody ProOrder proOrder) { return toAjax(proOrderService.insertProOrder(proOrder)); } + /** * 定时任务新增订单 */ @@ -137,14 +138,14 @@ public class ProOrderController extends BaseController { @PostMapping("/sapAddOrder") public R sapAddOrder(@RequestBody ProOrder proOrder) { try { - if (proOrder!=null){ + if (proOrder != null) { proOrderService.insertSapProOrder(proOrder); } - }catch (Exception e){ + } catch (Exception e) { return R.fail(e.getMessage()); } - return R.ok(); + return R.ok(); } diff --git a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/ProOrderServiceImpl.java b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/ProOrderServiceImpl.java index 27c19ae1..cab45b2b 100644 --- a/op-modules/op-mes/src/main/java/com/op/mes/service/impl/ProOrderServiceImpl.java +++ b/op-modules/op-mes/src/main/java/com/op/mes/service/impl/ProOrderServiceImpl.java @@ -82,13 +82,13 @@ public class ProOrderServiceImpl implements IProOrderService { ProOrder product = new ProOrder(); BeanUtils.copyProperties(splitOrderDTO.getProduct(), product); // 设置通用属性 - ProOrderWorkorder proOrderWorkorder = setCommonWorkAttribute(product, splitOrderDTO.getProductDate(), splitOrderDTO.getProdLineCode(), splitOrderDTO.getShiftId(),splitOrderDTO.getRouteCode()); + ProOrderWorkorder proOrderWorkorder = setCommonWorkAttribute(product, splitOrderDTO.getProductDate(), splitOrderDTO.getProdLineCode(), splitOrderDTO.getShiftId(), splitOrderDTO.getRouteCode()); // 生成对应工单表 // 一级 ProOrderWorkorder firWorkOrder = setWorkOrder(proOrderWorkorder, product); // code int endCode = getEndCode(product.getId()); - firWorkOrder.setWorkorderCode(product.getOrderCode()+"-"+endCode); + firWorkOrder.setWorkorderCode(product.getOrderCode() + "-" + endCode); // 更新到数据库 proOrderWorkorderMapper.insertProOrderWorkorder(firWorkOrder); @@ -108,7 +108,7 @@ public class ProOrderServiceImpl implements IProOrderService { proOrderWorkorder.setParentOrder(firWorkOrder.getWorkorderCode()); ProOrderWorkorder secWorkOrder = setWorkOrder(proOrderWorkorder, product); // code - secWorkOrder.setWorkorderCode(product.getOrderCode()+"-"+(endCode+1)); + secWorkOrder.setWorkorderCode(product.getOrderCode() + "-" + (endCode + 1)); // 更新到数据库 proOrderWorkorderMapper.insertProOrderWorkorder(secWorkOrder); // 生成批次表并更新到数据库 @@ -127,7 +127,7 @@ public class ProOrderServiceImpl implements IProOrderService { // 设置为底层节点 thiWorkOrder.setIsEnd(1); // code - thiWorkOrder.setWorkorderCode(product.getOrderCode()+"-"+(endCode+2)); + thiWorkOrder.setWorkorderCode(product.getOrderCode() + "-" + (endCode + 2)); // 更新到数据库 proOrderWorkorderMapper.insertProOrderWorkorder(thiWorkOrder); // 生成批次表并更新到数据库 @@ -135,7 +135,7 @@ public class ProOrderServiceImpl implements IProOrderService { } // 设置为底层节点 - if (checkEnd == 1){ + if (checkEnd == 1) { updateWorker.setWorkorderId(secWorkOrder.getWorkorderId()); updateWorker.setIsEnd(1); proOrderWorkorderMapper.updateProOrderWorkorder(updateWorker); @@ -144,7 +144,7 @@ public class ProOrderServiceImpl implements IProOrderService { } // 设置为底层节点 - if (checkEnd == 1){ + if (checkEnd == 1) { updateWorker.setWorkorderId(firWorkOrder.getWorkorderId()); updateWorker.setIsEnd(1); proOrderWorkorderMapper.updateProOrderWorkorder(updateWorker); @@ -250,11 +250,11 @@ public class ProOrderServiceImpl implements IProOrderService { @Override @DS("#header.poolName") public LineAndShiftVo getProdLineShift(String type) { - if (type.equals("white")){ - LineAndShiftVo lineAndShiftVo = new LineAndShiftVo(proOrderMapper.selectProdLine(), proOrderMapper.selectProShift(),proRouteMapper.selectAllRoute()); + if (type.equals("white")) { + LineAndShiftVo lineAndShiftVo = new LineAndShiftVo(proOrderMapper.selectProdLine(), proOrderMapper.selectProShift(), proRouteMapper.selectAllRoute()); return lineAndShiftVo; } - LineAndShiftVo lineAndShiftVo = new LineAndShiftVo(proOrderMapper.selectPackageLine(), proOrderMapper.selectProShift(),proRouteMapper.selectAllRoute()); + LineAndShiftVo lineAndShiftVo = new LineAndShiftVo(proOrderMapper.selectPackageLine(), proOrderMapper.selectProShift(), proRouteMapper.selectAllRoute()); return lineAndShiftVo; } @@ -297,7 +297,7 @@ public class ProOrderServiceImpl implements IProOrderService { proOrder.setParentOrder("0"); proOrder.setStatus("o0"); proOrder.setOrderType(proOrder.getProdType()); - proOrder.setOrderCode("DD"+ DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSSsss, date)); + proOrder.setOrderCode("DD" + DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSSsss, date)); proOrder.setCreateBy(SecurityContextHolder.getUserName()); proOrder.setCreateTime(date); proOrder.setUpdateBy(SecurityContextHolder.getUserName()); @@ -353,7 +353,7 @@ public class ProOrderServiceImpl implements IProOrderService { * @param proOrder * @return */ - private ProOrderWorkorder setCommonWorkAttribute(ProOrder proOrder, Date date, String proLineCode, String shiftId,String routeCode) { + private ProOrderWorkorder setCommonWorkAttribute(ProOrder proOrder, Date date, String proLineCode, String shiftId, String routeCode) { ProOrderWorkorder proOrderWorkorder = new ProOrderWorkorder(); // 更新者 proOrderWorkorder.setUpdateBy(SecurityContextHolder.getUserName()); @@ -462,12 +462,13 @@ public class ProOrderServiceImpl implements IProOrderService { /** * 获取工单尾号code + * * @param id * @return */ - private int getEndCode(String id){ + private int getEndCode(String id) { String workOrderCode = proOrderWorkorderMapper.selectEndWorkOrder(id); - if (workOrderCode == null || workOrderCode.equals("")){ + if (workOrderCode == null || workOrderCode.equals("")) { return 1; } @@ -477,7 +478,7 @@ public class ProOrderServiceImpl implements IProOrderService { String substring = workOrderCode.substring(hyphenIndex + 1); // 从 '-' 的下一位开始截取到字符串的末尾 // 将截取到的字符串转换为整数 int endCode = Integer.parseInt(substring); - return endCode+1; + return endCode + 1; } else { return 1; } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrder.java b/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrder.java index cb3f5e7c..a19e0700 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrder.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrder.java @@ -113,6 +113,28 @@ public class ProOrder extends TreeEntity { @Excel(name = "物料名称") private String prodSpc; + // 计划生产日期开始 + private String planDateStart; + + // 计划生产日期结束 + private String planDateEnd; + + public String getPlanDateStart() { + return planDateStart; + } + + public void setPlanDateStart(String planDateStart) { + this.planDateStart = planDateStart; + } + + public String getPlanDateEnd() { + return planDateEnd; + } + + public void setPlanDateEnd(String planDateEnd) { + this.planDateEnd = planDateEnd; + } + public String getProdSpc() { return prodSpc; } @@ -267,6 +289,8 @@ public class ProOrder extends TreeEntity { .append("updateTime", getUpdateTime()) .append("prodType", getProdType()) .append("prodSpc", getProdSpc()) + .append("planDateStart",getPlanDateStart()) + .append("planDateEnd",getPlanDateEnd()) .toString(); } } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrderWorkorder.java b/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrderWorkorder.java index 5cd51ab6..b698d984 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrderWorkorder.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrderWorkorder.java @@ -78,7 +78,11 @@ public class ProOrderWorkorder extends TreeEntity { @JsonFormat(pattern = "yyyy-MM-dd") @Excel(name = "工单生产日期", width = 30, dateFormat = "yyyy-MM-dd") private Date productDate; + + // 工单生产日期开始 private String productDateStart; + + // 工单生产日期结束 private String productDateEnd; /** 班次 */ @Excel(name = "班次") diff --git a/op-modules/op-plan/src/main/java/com/op/plan/domain/dto/ProOrderDTO.java b/op-modules/op-plan/src/main/java/com/op/plan/domain/dto/ProOrderDTO.java index fbf468b9..c85166b5 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/domain/dto/ProOrderDTO.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/domain/dto/ProOrderDTO.java @@ -61,8 +61,45 @@ public class ProOrderDTO { /** 物料型号 */ private String ProdSpc; + private String planFactoryCode; + + public String getPlanFactoryCode() { + return planFactoryCode; + } + + public void setPlanFactoryCode(String planFactoryCode) { + this.planFactoryCode = planFactoryCode; + } + private List children; + @Override + public String toString() { + return "ProOrderDTO{" + + "id='" + id + '\'' + + ", factoryCode='" + factoryCode + '\'' + + ", orderType='" + orderType + '\'' + + ", orderCode='" + orderCode + '\'' + + ", prodCode='" + prodCode + '\'' + + ", prodDesc='" + prodDesc + '\'' + + ", quantity=" + quantity + + ", quantitySplit=" + quantitySplit + + ", unit='" + unit + '\'' + + ", workerOrder='" + workerOrder + '\'' + + ", planProDate=" + planProDate + + ", planComplete=" + planComplete + + ", atrr1='" + atrr1 + '\'' + + ", atrr2='" + atrr2 + '\'' + + ", atrr3='" + atrr3 + '\'' + + ", status='" + status + '\'' + + ", parentOrder='" + parentOrder + '\'' + + ", prodType='" + prodType + '\'' + + ", ProdSpc='" + ProdSpc + '\'' + + ", planFactoryCode='" + planFactoryCode + '\'' + + ", children=" + children + + '}'; + } + public String getId() { return id; } @@ -223,32 +260,6 @@ public class ProOrderDTO { this.children = children; } - @Override - public String toString() { - return "ProOrderDTO{" + - "id='" + id + '\'' + - ", factoryCode='" + factoryCode + '\'' + - ", orderType='" + orderType + '\'' + - ", orderCode='" + orderCode + '\'' + - ", prodCode='" + prodCode + '\'' + - ", prodDesc='" + prodDesc + '\'' + - ", quantity=" + quantity + - ", quantitySplit=" + quantitySplit + - ", unit='" + unit + '\'' + - ", workerOrder='" + workerOrder + '\'' + - ", planProDate=" + planProDate + - ", planComplete=" + planComplete + - ", atrr1='" + atrr1 + '\'' + - ", atrr2='" + atrr2 + '\'' + - ", atrr3='" + atrr3 + '\'' + - ", status='" + status + '\'' + - ", parentOrder='" + parentOrder + '\'' + - ", prodType='" + prodType + '\'' + - ", ProdSpc='" + ProdSpc + '\'' + - ", children=" + children + - '}'; - } - public ProOrderDTO() { } } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProWetMaterialPlanMapper.java b/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProWetMaterialPlanMapper.java index 7f472287..8282edc0 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProWetMaterialPlanMapper.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProWetMaterialPlanMapper.java @@ -64,15 +64,6 @@ public interface ProWetMaterialPlanMapper { */ public int deleteProWetMaterialPlanByIds(String[] ids); - /** - * 根据时间范围查询范围内的计划列表 - * - * @param startTime - * @param endTime - * @return - */ - List selectProWetMaterialPlanListByTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime); - /** * 通过班次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 6542a050..152ae9f4 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 @@ -75,90 +75,52 @@ public class ProOrderServiceImpl implements IProOrderService { // 如果不重复 if (checkout) { - // 判断是否为底层节点 - int checkEnd = 0; - // 创建ProOrderWorkorder对象用于数据更新减少io - ProOrderWorkorder updateWorker = new ProOrderWorkorder(); - ProOrder product = new ProOrder(); - BeanUtils.copyProperties(splitOrderDTO.getProduct(), product); - // 设置通用属性 - ProOrderWorkorder proOrderWorkorder = setCommonWorkAttribute(product, splitOrderDTO.getProductDate(), splitOrderDTO.getProdLineCode(), splitOrderDTO.getShiftId(),splitOrderDTO.getRouteCode()); - // 生成对应工单表 - // 一级 - ProOrderWorkorder firWorkOrder = setWorkOrder(proOrderWorkorder, product); - // code - int endCode = getEndCode(product.getId()); - firWorkOrder.setWorkorderCode(product.getOrderCode()+"-"+endCode); - // 更新到数据库 - proOrderWorkorderMapper.insertProOrderWorkorder(firWorkOrder); - - // 创建通用批次表对象 + // 创建订单对象,并将信息copy进去 + ProOrder proOrder = new ProOrder(); + BeanUtils.copyProperties(splitOrderDTO.getProduct(), proOrder); + // 设置工单通用属性 + ProOrderWorkorder proOrderWorkorder = setCommonWorkAttribute(proOrder, splitOrderDTO.getProductDate(), splitOrderDTO.getProdLineCode(), splitOrderDTO.getShiftId(), splitOrderDTO.getRouteCode()); + // 创建批次表通用对象 ProOrderWorkorderBatch workBatch = setCommonBatchAttribute(); - // 生成批次表并更新到数据库 - setBatch(workBatch, splitOrderDTO.getFormFields(), firWorkOrder.getWorkorderId()); - - // 二级 - if (splitOrderDTO.getProduct().getChildren() != null) { - // 判断加1 - checkEnd += 1; - - List secProOrderList = splitOrderDTO.getProduct().getChildren(); - BeanUtils.copyProperties(secProOrderList.get(0), product); - // 设置父工单 - proOrderWorkorder.setParentOrder(firWorkOrder.getWorkorderCode()); - ProOrderWorkorder secWorkOrder = setWorkOrder(proOrderWorkorder, product); - // code - secWorkOrder.setWorkorderCode(product.getOrderCode()+"-"+(endCode+1)); - // 更新到数据库 - proOrderWorkorderMapper.insertProOrderWorkorder(secWorkOrder); - // 生成批次表并更新到数据库 - setBatch(workBatch, splitOrderDTO.getFormFields(), secWorkOrder.getWorkorderId()); - - // 三级 - if (secProOrderList.get(0).getChildren() != null) { - // 判断加1 - checkEnd += 1; - - List thiProOrderList = secProOrderList.get(0).getChildren(); - BeanUtils.copyProperties(thiProOrderList.get(0), product); - // 设置父工单 - proOrderWorkorder.setParentOrder(secWorkOrder.getWorkorderCode()); - ProOrderWorkorder thiWorkOrder = setWorkOrder(proOrderWorkorder, product); - // 设置为底层节点 - thiWorkOrder.setIsEnd(1); - // code - thiWorkOrder.setWorkorderCode(product.getOrderCode()+"-"+(endCode+2)); - // 更新到数据库 - proOrderWorkorderMapper.insertProOrderWorkorder(thiWorkOrder); - // 生成批次表并更新到数据库 - setBatch(workBatch, splitOrderDTO.getFormFields(), thiWorkOrder.getWorkorderId()); - } - - // 设置为底层节点 - if (checkEnd == 1){ - updateWorker.setWorkorderId(secWorkOrder.getWorkorderId()); - updateWorker.setIsEnd(1); - proOrderWorkorderMapper.updateProOrderWorkorder(updateWorker); + // code + int endCode = getEndCode(proOrder.getId()); + + // 父工单code + StringBuilder parentOrder = new StringBuilder("0"); + boolean run = true; + while (run) { + // 先进行当前订单拆分操作 + // 1.设置工单信息,并更新订单信息至数据库 + ProOrderWorkorder workOrder = setWorkOrder(proOrderWorkorder, proOrder); + // 2.设置工单编码 + workOrder.setWorkorderCode(proOrder.getOrderCode() + "-" + endCode); + // 3.设置父工单 + workOrder.setParentOrder(parentOrder.toString()); + // 将工单信息更新至数据库 + proOrderWorkorderMapper.insertProOrderWorkorder(workOrder); + // 生成批次表信息并更新至数据库 + setBatch(workBatch, splitOrderDTO.getFormFields(), workOrder.getWorkorderId()); + + // 如果存在子节点 + if (proOrder.getChildren() != null) { + ProOrderDTO newProOrder = (ProOrderDTO) proOrder.getChildren().get(0); + // 将child信息重新赋值给proOrder + BeanUtils.copyProperties(newProOrder, proOrder); + // 存放父工单code + parentOrder.delete(0, parentOrder.length()); + parentOrder.append(workOrder.getWorkorderCode()); + // code自增 + endCode++; + } else { + // 设置子节点is_end字段信息 + workOrder.setIsEnd(1); + // 更新数据库记录信息 + proOrderWorkorderMapper.updateProOrderWorkorder(workOrder); + // 结束循环 + run = false; } - - } - - // 设置为底层节点 - if (checkEnd == 1){ - updateWorker.setWorkorderId(firWorkOrder.getWorkorderId()); - updateWorker.setIsEnd(1); - proOrderWorkorderMapper.updateProOrderWorkorder(updateWorker); - } - - // 母工单设置底层节点(只有母工单的情况下) - if (checkEnd == 0) { - firWorkOrder.setIsEnd(1); - // 更新到数据库 - proOrderWorkorderMapper.updateProOrderWorkorder(firWorkOrder); } - return success(); - } return error(500, "批次号不能重复"); @@ -175,45 +137,46 @@ public class ProOrderServiceImpl implements IProOrderService { public AjaxResult getWorkOrderList(String id) { // 通过订单id查询所有工单信息list List proOrderWorkorderList = proOrderWorkorderMapper.selectFirWorkOrder(id); - // 母工单循环遍历 - for (int i = 0; i < proOrderWorkorderList.size(); i++) { - // 通过班次id查询班次名称 - String shiftDesc = proOrderMapper.selectShiftNameById(proOrderWorkorderList.get(i).getShiftId()); - // 通过设备code查询出机型名称 - String prodLineName = proOrderMapper.selectProdLineName(proOrderWorkorderList.get(i).getProdLineCode()); - // 通过工单id查询批次号 - List batchCodeList = proOrderMapper.selectBatchCodesById(proOrderWorkorderList.get(i).getWorkorderId()); - List batchCodes = new ArrayList<>(); - // 格式化数据 - for (int j = 0; j < batchCodeList.size(); j++) { - batchCodes.add(new StringBuilder(batchCodeList.get(j)).append(";").append("\n")); - } - // 通过母工单workorder_id查询子工单 - // 二级 - List secProOrderWorkorder = proOrderWorkorderMapper.selectChildWorkOrder(proOrderWorkorderList.get(i).getWorkorderCode()); - if (secProOrderWorkorder.size() > 0 && secProOrderWorkorder != null) { - // 三级 - List thiProOrderWorkorders = proOrderWorkorderMapper.selectChildWorkOrder(secProOrderWorkorder.get(0).getWorkorderCode()); - if (thiProOrderWorkorders.size() > 0 && thiProOrderWorkorders != null) { - // 将三级放入二级child - thiProOrderWorkorders.get(0).setShiftDesc(shiftDesc); - thiProOrderWorkorders.get(0).setProdLineCode(prodLineName); - thiProOrderWorkorders.get(0).setBatchCodeList(batchCodes); - secProOrderWorkorder.get(0).setChildren(thiProOrderWorkorders); - } - // 将二级放入到母工单child - secProOrderWorkorder.get(0).setShiftDesc(shiftDesc); - secProOrderWorkorder.get(0).setProdLineCode(prodLineName); - secProOrderWorkorder.get(0).setBatchCodeList(batchCodes); - proOrderWorkorderList.get(i).setChildren(secProOrderWorkorder); - } - proOrderWorkorderList.get(i).setShiftDesc(shiftDesc); - proOrderWorkorderList.get(i).setProdLineCode(prodLineName); - proOrderWorkorderList.get(i).setBatchCodeList(batchCodes); + + for (ProOrderWorkorder proOrderWorkorder : proOrderWorkorderList) { + formatProOrderWorkorder(proOrderWorkorder); } + return success(proOrderWorkorderList); } + /** + * 格式化工单信息(递归处理) + * + * @param proOrderWorkorder + */ + private void formatProOrderWorkorder(ProOrderWorkorder proOrderWorkorder) { + // 通过班次id查询班次名称 + String shiftDesc = proOrderMapper.selectShiftNameById(proOrderWorkorder.getShiftId()); + // 通过设备code查询出机型名称 + String prodLineName = proOrderMapper.selectProdLineName(proOrderWorkorder.getProdLineCode()); + // 通过工单id查询批次号 + List batchCodeList = proOrderMapper.selectBatchCodesById(proOrderWorkorder.getWorkorderId()); + List batchCodes = new ArrayList<>(); + // 格式化数据 + for (String batchCode : batchCodeList) { + batchCodes.add(new StringBuilder(batchCode).append(";").append("\n")); + } + // 将查询结果设置到当前工单对象 + proOrderWorkorder.setShiftDesc(shiftDesc); + proOrderWorkorder.setProdLineCode(prodLineName); + proOrderWorkorder.setBatchCodeList(batchCodes); + + // 通过母工单workorder_id查询子工单 + List childWorkorders = proOrderWorkorderMapper.selectChildWorkOrder(proOrderWorkorder.getWorkorderCode()); + if (!childWorkorders.isEmpty()) { + for (ProOrderWorkorder childWorkorder : childWorkorders) { + formatProOrderWorkorder(childWorkorder); // 递归处理子工单 + } + proOrderWorkorder.setChildren(childWorkorders); // 设置子工单列表 + } + } + /** * 获取当前订单信息列表 * @@ -223,25 +186,32 @@ public class ProOrderServiceImpl implements IProOrderService { @Override @DS("#header.poolName") public AjaxResult getOrderList(String id) { - // 注意判空不为空则放入 (避免空指针) // 通过母工单id查询母订单详情 ProOrder proOrder = proOrderMapper.selectProOrderById(id); - // 查询二级 - List secProOrderList = proOrderMapper.selectChildProOrderByCode(proOrder.getOrderCode()); - if (secProOrderList != null || secProOrderList.size() > 0) { - // 查询三级 - List thiProOrderList = proOrderMapper.selectChildProOrderByCode(secProOrderList.get(0).getOrderCode()); - if (thiProOrderList != null || thiProOrderList.size() > 0) { - // 将三级Order放入二级 - secProOrderList.get(0).setChildren(thiProOrderList); - } - } - // 将二级Order放入母订单 - proOrder.setChildren(secProOrderList); + // 递归查询子订单 + recursiveQueryChildOrder(proOrder); return success(proOrder); } + /** + * 查询订单方法(递归) + * + * @param proOrder + */ + private void recursiveQueryChildOrder(ProOrder proOrder) { + // 查询子订单列表 + List childOrders = proOrderMapper.selectChildProOrderByCode(proOrder.getOrderCode()); + if (!childOrders.isEmpty()) { + // 递归处理子订单 + for (ProOrder childOrder : childOrders) { + recursiveQueryChildOrder(childOrder); + } + // 将子订单列表设置到当前订单对象 + proOrder.setChildren(childOrders); + } + } + /** * 获取成型机 * @@ -250,13 +220,13 @@ public class ProOrderServiceImpl implements IProOrderService { @Override @DS("#header.poolName") public LineAndShiftVo getProdLineShift(String type) { - if (type.equals("white")){ + if (type.equals("white")) { LineAndShiftVo lineAndShiftVo = new LineAndShiftVo(proOrderMapper.selectProdLine(), - proOrderMapper.selectProShift(),proRouteMapper.selectAllRoute()); + proOrderMapper.selectProShift(), proRouteMapper.selectAllRoute()); return lineAndShiftVo; } LineAndShiftVo lineAndShiftVo = new LineAndShiftVo(proOrderMapper.selectPackageLine(), - proOrderMapper.selectProShift(),proRouteMapper.selectAllRoute()); + proOrderMapper.selectProShift(), proRouteMapper.selectAllRoute()); return lineAndShiftVo; } @@ -299,7 +269,7 @@ public class ProOrderServiceImpl implements IProOrderService { proOrder.setParentOrder("0"); proOrder.setStatus("o0"); proOrder.setOrderType(proOrder.getProdType()); - proOrder.setOrderCode("DD"+ DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSSsss, date)); + proOrder.setOrderCode("DD" + DateUtils.parseDateToStr(DateUtils.YYYYMMDDHHMMSSsss, date)); proOrder.setCreateBy(SecurityContextHolder.getUserName()); proOrder.setCreateTime(date); proOrder.setUpdateBy(SecurityContextHolder.getUserName()); @@ -355,7 +325,7 @@ public class ProOrderServiceImpl implements IProOrderService { * @param proOrder * @return */ - private ProOrderWorkorder setCommonWorkAttribute(ProOrder proOrder, Date date, String proLineCode, String shiftId,String routeCode) { + private ProOrderWorkorder setCommonWorkAttribute(ProOrder proOrder, Date date, String proLineCode, String shiftId, String routeCode) { ProOrderWorkorder proOrderWorkorder = new ProOrderWorkorder(); // 更新者 proOrderWorkorder.setUpdateBy(SecurityContextHolder.getUserName()); @@ -382,6 +352,8 @@ public class ProOrderServiceImpl implements IProOrderService { proOrderWorkorder.setStatus("w0"); // 工艺编码 proOrderWorkorder.setRouteCode(routeCode); + // 工厂编码 + proOrderWorkorder.setFactoryCode(proOrder.getPlanFactoryCode()); return proOrderWorkorder; } @@ -448,11 +420,11 @@ public class ProOrderServiceImpl implements IProOrderService { private void setBatch(ProOrderWorkorderBatch workBatch, List batchList, String workOrderId) { // 工单id workBatch.setWorkorderId(workOrderId); + // 产品类型 - for (int i = 0; i < batchList.size(); i++) { + for (Batch batch : batchList) { // 生成批次id workBatch.setBatchId(IdUtils.fastSimpleUUID()); - Batch batch = batchList.get(i); // 获取批次号 workBatch.setBatchCode(batch.getBatchCode()); // 获取批次数量 @@ -460,16 +432,30 @@ public class ProOrderServiceImpl implements IProOrderService { // 更新至数据库 proOrderWorkorderBatchMapper.insertProOrderWorkorderBatch(workBatch); } + +// // 产品类型 +// for (int i = 0; i < batchList.size(); i++) { +// // 生成批次id +// workBatch.setBatchId(IdUtils.fastSimpleUUID()); +// Batch batch = batchList.get(i); +// // 获取批次号 +// workBatch.setBatchCode(batch.getBatchCode()); +// // 获取批次数量 +// workBatch.setBatchQuantity(batch.getBatchQuantity()); +// // 更新至数据库 +// proOrderWorkorderBatchMapper.insertProOrderWorkorderBatch(workBatch); +// } } /** * 获取工单尾号code + * * @param id * @return */ - private int getEndCode(String id){ + private int getEndCode(String id) { String workOrderCode = proOrderWorkorderMapper.selectEndWorkOrder(id); - if (workOrderCode == null || workOrderCode.equals("")){ + if (workOrderCode == null || workOrderCode.equals("")) { return 1; } @@ -479,7 +465,7 @@ public class ProOrderServiceImpl implements IProOrderService { String substring = workOrderCode.substring(hyphenIndex + 1); // 从 '-' 的下一位开始截取到字符串的末尾 // 将截取到的字符串转换为整数 int endCode = Integer.parseInt(substring); - return endCode+1; + return endCode + 1; } else { return 1; } 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 bfa70daa..1cd58c0e 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 @@ -61,9 +61,6 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService @Override @DS("#header.poolName") public List selectProWetMaterialPlanList(ProWetMaterialPlan proWetMaterialPlan) { - if (proWetMaterialPlan.getStartTime() != null && proWetMaterialPlan.getEndTime() != null) { - return proWetMaterialPlanMapper.selectProWetMaterialPlanListByTime(proWetMaterialPlan.getStartTime(), proWetMaterialPlan.getEndTime()); - } return proWetMaterialPlanMapper.selectProWetMaterialPlanList(proWetMaterialPlan); } @@ -132,9 +129,9 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService } List workorderList = proOrderWorkorderMapper.selectWorkOrderByTime(productDate); // 循环遍历 - for (int i = 0; i < workorderList.size(); i++) { + for (ProOrderWorkorder proOrderWorkorder : workorderList) { // 通过班次id获取班次名称 - workorderList.get(i).setShiftDesc(proWetMaterialPlanMapper.selectShiftById(workorderList.get(i).getShiftId())); + proOrderWorkorder.setShiftDesc(proWetMaterialPlanMapper.selectShiftById(proOrderWorkorder.getShiftId())); } return success(workorderList); } @@ -195,15 +192,15 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService // 将主计划更新至数据库 proWetMaterialPlanMapper.insertProWetMaterialPlan(proWetMaterialPlan); // 循环创建湿料计划详情 - for (int i = 0; i < proOrderWorkorderList.size(); i++) { + for (ProOrderWorkorder proOrderWorkorder : proOrderWorkorderList) { // 将湿料计划详情更新至数据库 - proWetMaterialPlanDetailMapper.insertProWetMaterialPlanDetail(createProWetMaterialPlanDetail(proOrderWorkorderList.get(i), proWetMaterialPlan.getId())); + proWetMaterialPlanDetailMapper.insertProWetMaterialPlanDetail(createProWetMaterialPlanDetail(proOrderWorkorder, proWetMaterialPlan.getId())); } } else { // 循环创建湿料计划详情 - for (int i = 0; i < proOrderWorkorderList.size(); i++) { + for (ProOrderWorkorder proOrderWorkorder : proOrderWorkorderList) { // 将湿料计划详情更新至数据库 - proWetMaterialPlanDetailMapper.insertProWetMaterialPlanDetail(createProWetMaterialPlanDetail(proOrderWorkorderList.get(i), planId)); + proWetMaterialPlanDetailMapper.insertProWetMaterialPlanDetail(createProWetMaterialPlanDetail(proOrderWorkorder, planId)); } } return success(); @@ -220,9 +217,9 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService public AjaxResult getWetMaterialPlanDetailListById(String id) { List detailList = proWetMaterialPlanDetailMapper.selectProWetMaterialPlanDetailListById(id); // 获取班次名称和料罐名称 - for (int i = 0; i < detailList.size(); i++) { - detailList.get(i).setShiftDesc(proWetMaterialPlanMapper.selectShiftById(String.valueOf(detailList.get(i).getShiftId()))); - detailList.get(i).setBucketName(proWetMaterialPlanMapper.selectBucketNameById(detailList.get(i).getBucketId())); + for (ProWetMaterialPlanDetail detail : detailList) { + detail.setShiftDesc(proWetMaterialPlanMapper.selectShiftById(String.valueOf(detail.getShiftId()))); + detail.setBucketName(proWetMaterialPlanMapper.selectBucketNameById(detail.getBucketId())); } return success(detailList); } @@ -248,8 +245,8 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService proWetMaterialPlanMapper.updateProWetMaterialPlan(proWetMaterialPlan); // 循环将详情信息更新至数据库 - for (int i = 0; i < detailList.size(); i++) { - proWetMaterialPlanDetailMapper.updateProWetMaterialPlanDetail(detailList.get(i)); + for (ProWetMaterialPlanDetail detail : detailList) { + proWetMaterialPlanDetailMapper.updateProWetMaterialPlanDetail(detail); } return success(); } @@ -275,7 +272,7 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService // TODO 订单类型 //proWetMaterialPlan.setOrderType(); // TODO 计划工厂编码 - //proWetMaterialPlan.setFactoryCode(); + //proWetMaterialPlan.setFactoryCode(proOrderWorkorder.getFactoryCode()); // 计划日期 proWetMaterialPlan.setPlanTime(proOrderWorkorder.getPlanTime()); // 同步状态(1已同步0未同步) @@ -300,8 +297,8 @@ public class ProWetMaterialPlanServiceImpl implements IProWetMaterialPlanService detail.setId(IdUtils.fastSimpleUUID()); // 产品名称 detail.setProductName(workorder.getProductName()); - // TODO 计划工厂编码 - //detail.setFactoryCode(); + // 计划工厂编码(获得的是工单的计划工厂) + detail.setFactoryCode(workorder.getFactoryCode()); // 主计划id detail.setWetMaterialPlanId(id); // 工单id diff --git a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderMapper.xml b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderMapper.xml index f7ac6670..9cb25977 100644 --- a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderMapper.xml +++ b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderMapper.xml @@ -60,6 +60,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and parent_order = #{parentOrder} and prod_type = #{prodType} and prod_spc = #{prodSpc} + and CONVERT(varchar(10),plan_pro_date, 120) >= '${planDateStart}' + and '${planDateEnd}%' >= CONVERT(varchar(10),plan_pro_date, 120) ORDER BY plan_pro_date DESC diff --git a/op-modules/op-plan/src/main/resources/mapper/plan/ProWetMaterialPlanMapper.xml b/op-modules/op-plan/src/main/resources/mapper/plan/ProWetMaterialPlanMapper.xml index 0628c6bc..0cdb35b6 100644 --- a/op-modules/op-plan/src/main/resources/mapper/plan/ProWetMaterialPlanMapper.xml +++ b/op-modules/op-plan/src/main/resources/mapper/plan/ProWetMaterialPlanMapper.xml @@ -36,7 +36,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -44,11 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where id = #{id} - +