diff --git a/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/RemoteJindieService.java b/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/RemoteJindieService.java index da65c40..3997266 100644 --- a/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/RemoteJindieService.java +++ b/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/RemoteJindieService.java @@ -3,6 +3,7 @@ package com.hw.jindie.api; import com.hw.common.core.constant.SecurityConstants; import com.hw.common.core.constant.ServiceNameConstants; import com.hw.common.core.domain.R; +import com.hw.common.core.web.domain.AjaxResult; import com.hw.jindie.api.domain.vo.ErpSyncInfoVo; import com.hw.jindie.api.factory.RemoteJindieFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; @@ -39,4 +40,8 @@ public interface RemoteJindieService { @PostMapping("/jindie/syncPurchaseOrderFromErp") R syncPurchaseOrderFromErp(@RequestBody ErpSyncInfoVo erpSyncInfoVo,@RequestHeader(SecurityConstants.FROM_SOURCE) String source); + /** 采购申请单excel导入*/ + @PostMapping("/jindie/singleSavePurchaseRequisition") + R singleSavePurchaseRequisition(@RequestBody String params, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); + } diff --git a/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/factory/RemoteJindieFallbackFactory.java b/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/factory/RemoteJindieFallbackFactory.java index 504314c..befa477 100644 --- a/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/factory/RemoteJindieFallbackFactory.java +++ b/hw-api/hw-api-jindie/src/main/java/com/hw/jindie/api/factory/RemoteJindieFallbackFactory.java @@ -1,6 +1,7 @@ package com.hw.jindie.api.factory; import com.hw.common.core.domain.R; +import com.hw.common.core.web.domain.AjaxResult; import com.hw.jindie.api.RemoteJindieService; import com.hw.jindie.api.domain.vo.ErpSyncInfoVo; import org.springframework.cloud.openfeign.FallbackFactory; @@ -39,6 +40,11 @@ public class RemoteJindieFallbackFactory implements FallbackFactory syncPurchaseOrderFromErp(ErpSyncInfoVo erpSyncInfoVo,String source) { return R.fail("同步采购订单信息失败:" + throwable.getMessage()); } + + @Override + public R singleSavePurchaseRequisition(String params, String source) { + return R.fail("采购申请单excel导入失败:" + throwable.getMessage()); + } }; } } diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/controller/KingdeeErpSyncController.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/controller/KingdeeErpSyncController.java index 55aa14b..999ea49 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/controller/KingdeeErpSyncController.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/controller/KingdeeErpSyncController.java @@ -118,6 +118,8 @@ public class KingdeeErpSyncController { * @return {"msg": "{"IsSuccess": true,"Errors": [],"SuccessEntitys": [{"Id": "154898","Number": "CGSQ010785","DIndex": 0}]}", "code": 200} */ @PostMapping(("/singleSavePurchaseRequisition")) + @Log(title = "ERP采购申请单", businessType = BusinessType.INSERT) + @InnerAuth public AjaxResult singleSavePurchaseRequisition(@RequestBody String params) { try { return AjaxResult.success(kingdeeErpService.singleSavePurchaseRequisition(params)); diff --git a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/impl/KingdeeErpService.java b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/impl/KingdeeErpService.java index 37a25b5..4a86c05 100644 --- a/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/impl/KingdeeErpService.java +++ b/hw-modules/hw-jindie/src/main/java/com/hw/jindie/service/impl/KingdeeErpService.java @@ -45,8 +45,9 @@ public class KingdeeErpService { JSONObject FEntity = new JSONObject(); String FMaterialId = (String) objectParams.get("FMaterialId");//物料编码 String FUnitId = (String) objectParams.get("FUnitId");//单位 -// String FMaterialDesc = (String) objectParams.get("FMaterialDesc");//物料说明 + String FMaterialDesc = (String) objectParams.get("FMaterialDesc");//物料说明 Double FReqQty = (Double) objectParams.get("FReqQty");//采购数量 + Double FTAXPRICE = (Double) objectParams.get("FTAXPRICE");//含税单价 try { //业务对象标识 String formId = KingdeeConfig.PUR_Requisition; @@ -63,11 +64,11 @@ public class KingdeeErpService { FEntity.put("FREQSTOCKUNITID", FUnitIdObject); //库存单位(必填项) FEntity.put("FReqQty", FReqQty); //申请数量 -// FEntity.put("FMaterialDesc", FMaterialDesc); //物料说明 + FEntity.put("FMaterialDesc", FMaterialDesc); //物料说明 // FEntity.put("FReceiveOrgId", KingdeeConfig.getFApplicationOrgId()); //收料组织 // FEntity.put("FApproveQty", FReqQty); //批准数量 // FEntity.put("FEvaluatePrice", 0.0); //单价 -// FEntity.put("FTAXPRICE", 0.0); //含税单价 + FEntity.put("FTAXPRICE", FTAXPRICE); //含税单价 // FEntity.put("FTAXRATE", 0.0); //税率% // FEntity.put("FPriceUnitQty", FReqQty); //计价数量 // FEntity.put("FREQSTOCKQTY", FReqQty); //库存单位数量 diff --git a/hw-modules/hw-mes/pom.xml b/hw-modules/hw-mes/pom.xml index 38aa0ac..47ff443 100644 --- a/hw-modules/hw-mes/pom.xml +++ b/hw-modules/hw-mes/pom.xml @@ -84,6 +84,12 @@ 3.6.3 compile + + com.hw + hw-api-jindie + 3.6.3 + compile + diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesImportController.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesImportController.java new file mode 100644 index 0000000..24da116 --- /dev/null +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesImportController.java @@ -0,0 +1,49 @@ +package com.hw.mes.controller; + +import com.hw.common.core.utils.poi.ExcelUtil; +import com.hw.common.core.web.controller.BaseController; +import com.hw.common.core.web.domain.AjaxResult; +import com.hw.common.log.annotation.Log; +import com.hw.common.log.enums.BusinessType; +import com.hw.common.security.utils.SecurityUtils; +import com.hw.mes.domain.MesPurchaseRequisitionTemplate; +import com.hw.mes.service.IMesBasePalletInfoService; +import com.hw.mes.service.IMesImportService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +/** + * MES excel导入Controller + * + * @author Yinq + * @date 2024-07-18 + */ +@RestController +@RequestMapping("/import") +public class MesImportController extends BaseController { + + @Autowired + private IMesImportService mesImportService; + + + /** + * 采购申请单excel导入 + */ + @Log(title = "采购申请单", businessType = BusinessType.IMPORT) + @PostMapping(("/purchaseRequisitionImportData")) + public AjaxResult purchaseRequisitionImportData(MultipartFile file, boolean updateSupport) throws Exception + { + ExcelUtil util = new ExcelUtil<>(MesPurchaseRequisitionTemplate.class); + List purchaseRequisitionTemplateList = util.importExcel(file.getInputStream()); + String operName = SecurityUtils.getUsername(); + String message = mesImportService.importPurchaseRequisition(purchaseRequisitionTemplateList, operName); + return success(message); + } + + +} diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesProductOrderController.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesProductOrderController.java index c221d90..f33806f 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesProductOrderController.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesProductOrderController.java @@ -3,6 +3,7 @@ package com.hw.mes.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; +import com.hw.common.core.utils.StringUtils; import com.hw.common.security.utils.SecurityUtils; import com.hw.mes.domain.MesSaleOrder; import com.hw.mes.service.IMesSaleOrderService; @@ -109,17 +110,13 @@ public class MesProductOrderController extends BaseController { } /** - * 批量修改生产工单 + * 批量修改生产工单、生产派工 * @param productOrderList * @return */ @PostMapping("/batchEditingProductOrder") public AjaxResult batchEditingProductOrder(@RequestBody List productOrderList) { - int result = 0; - for (MesProductOrder productOrder : productOrderList) { - productOrder.setUpdateBy(SecurityUtils.getLoginUser().getUsername()); - result = mesProductOrderService.updateMesProductOrder(productOrder); - } + int result = mesProductOrderService.batchEditingProductOrder(productOrderList); return toAjax(result); } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProductOrder.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProductOrder.java index dd884d6..ea1bff9 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProductOrder.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProductOrder.java @@ -2,6 +2,7 @@ package com.hw.mes.domain; import java.math.BigDecimal; import java.util.Date; +import java.util.List; import com.fasterxml.jackson.annotation.JsonFormat; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -209,6 +210,43 @@ public class MesProductOrder extends BaseEntity { @Excel(name = "前置生产工单编号") private String preOrderCode; + /** MesProductPlan主键标识 */ + private Long planId; + + /** + * MesProductPlan计划编号 + */ + private String planCode; + + /** + * 时间范围-计划开始结束时间 + */ + private List planDateRange; + + public List getPlanDateRange() { + return planDateRange; + } + + public void setPlanDateRange(List planDateRange) { + this.planDateRange = planDateRange; + } + + public Long getPlanId() { + return planId; + } + + public void setPlanId(Long planId) { + this.planId = planId; + } + + public String getPlanCode() { + return planCode; + } + + public void setPlanCode(String planCode) { + this.planCode = planCode; + } + public String getPreOrderCode() { return preOrderCode; } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesPurchaseRequisitionTemplate.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesPurchaseRequisitionTemplate.java new file mode 100644 index 0000000..04b1f5d --- /dev/null +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesPurchaseRequisitionTemplate.java @@ -0,0 +1,145 @@ +package com.hw.mes.domain; + +import com.hw.common.core.annotation.Excel; +import com.hw.common.core.web.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.math.BigDecimal; +import java.util.List; + +/** + * 采购申请单导入模板 + * + * @author Yinq + * @date 2024-01-25 + */ +public class MesPurchaseRequisitionTemplate { + private static final long serialVersionUID = 1L; + + /** + * 序号 + */ + @Excel(name = "序号") + private Long serialNumber; + + /** + * 物料名称 + */ + @Excel(name = "名称") + private String materialName; + + /** + * 产品规格型号 + */ + @Excel(name = "产品规格型号") + private String productModel; + + /** + * 单位 + */ + @Excel(name = "单位") + private String unit; + + /** + * 数量 + */ + @Excel(name = "数量") + private BigDecimal amount; + + /** + * 生产厂家 + */ + @Excel(name = "生产厂家") + private String manufacturer; + + /** + * 含税单价(元) + */ + @Excel(name = "含税单(元)") + private BigDecimal taxUnitPrice; + + /** + * 含税总价(元) + */ + @Excel(name = "含税总价(元)") + private BigDecimal taxTotalPrice; + + public Long getSerialNumber() { + return serialNumber; + } + + public void setSerialNumber(Long serialNumber) { + this.serialNumber = serialNumber; + } + + public String getMaterialName() { + return materialName; + } + + public void setMaterialName(String materialName) { + this.materialName = materialName; + } + + public String getProductModel() { + return productModel; + } + + public void setProductModel(String productModel) { + this.productModel = productModel; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public BigDecimal getAmount() { + return amount; + } + + public void setAmount(BigDecimal amount) { + this.amount = amount; + } + + public String getManufacturer() { + return manufacturer; + } + + public void setManufacturer(String manufacturer) { + this.manufacturer = manufacturer; + } + + public BigDecimal getTaxUnitPrice() { + return taxUnitPrice; + } + + public void setTaxUnitPrice(BigDecimal taxUnitPrice) { + this.taxUnitPrice = taxUnitPrice; + } + + public BigDecimal getTaxTotalPrice() { + return taxTotalPrice; + } + + public void setTaxTotalPrice(BigDecimal taxTotalPrice) { + this.taxTotalPrice = taxTotalPrice; + } + + @Override + public String toString() { + return "MesPurchaseRequisitionTemplate{" + + "serialNumber=" + serialNumber + + ", materialName='" + materialName + '\'' + + ", productModel='" + productModel + '\'' + + ", unit='" + unit + '\'' + + ", amount=" + amount + + ", manufacturer='" + manufacturer + '\'' + + ", taxUnitPrice=" + taxUnitPrice + + ", taxTotalPrice=" + taxTotalPrice + + '}'; + } +} diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesImportService.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesImportService.java new file mode 100644 index 0000000..b93e660 --- /dev/null +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesImportService.java @@ -0,0 +1,24 @@ +package com.hw.mes.service; + +import com.hw.mes.domain.MesPurchaseRequisitionTemplate; + +import java.util.List; + +/** + * excel导入Service接口 + * + * @author Yinq + * @date 2024-01-26 + */ +public interface IMesImportService +{ + + + /** + * 采购申请单导入 + * @param purchaseRequisitionTemplateList 数据列表 + * @param operName 操作用户 + * @return + */ + String importPurchaseRequisition(List purchaseRequisitionTemplateList, String operName); +} diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductOrderService.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductOrderService.java index c1c0681..27e13ce 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductOrderService.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductOrderService.java @@ -95,4 +95,12 @@ public interface IMesProductOrderService * @return */ public List selectAllListTaskList(MesProductOrder mesProductOrder); + + /** + * 批量修改生产工单、生产派工 + * @param productOrderList + * @return + */ + public int batchEditingProductOrder(List productOrderList); + } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesImportImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesImportImpl.java new file mode 100644 index 0000000..84db9e1 --- /dev/null +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesImportImpl.java @@ -0,0 +1,117 @@ +package com.hw.mes.service.impl; + +import com.alibaba.fastjson2.JSONObject; +import com.hw.common.core.constant.SecurityConstants; +import com.hw.common.core.domain.R; +import com.hw.common.core.exception.ServiceException; +import com.hw.common.core.utils.StringUtils; +import com.hw.common.core.utils.bean.BeanValidators; +import com.hw.common.core.web.domain.AjaxResult; +import com.hw.common.security.utils.SecurityUtils; +import com.hw.jindie.api.RemoteJindieService; +import com.hw.mes.api.RemoteMesService; +import com.hw.mes.api.domain.MesBaseMaterialInfo; +import com.hw.mes.domain.MesPurchaseRequisitionTemplate; + +import com.hw.mes.service.IMesBaseMaterialInfoService; +import com.hw.mes.service.IMesImportService; +import com.hw.system.api.domain.SysUser; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +/** + * excel导入Service业务层处理 + * + * @author Yinq + * @date 2024-01-25 + */ +@Service +public class MesImportImpl implements IMesImportService { + + @Autowired + private IMesBaseMaterialInfoService materialInfoService; + + @Autowired + private RemoteJindieService remoteJindieService; + + + private static final Logger log = LoggerFactory.getLogger(MesImportImpl.class); + + /** + * 采购申请单导入 + * + * @param purchaseRequisitionTemplateList 数据列表 + * @param operName 操作用户 + * @return + */ + @Override + public String importPurchaseRequisition(List purchaseRequisitionTemplateList, String operName) { + if (StringUtils.isNull(purchaseRequisitionTemplateList) || purchaseRequisitionTemplateList.size() == 0) { + throw new ServiceException("导入采购申请单数据不能为空!"); + } + int successNum = 0; + int failureNum = 0; + StringBuilder successMsg = new StringBuilder(); + StringBuilder failureMsg = new StringBuilder(); + for (MesPurchaseRequisitionTemplate purchaseRequisitionTemplate : purchaseRequisitionTemplateList) { + try { + String materialName = purchaseRequisitionTemplate.getMaterialName(); + String productModel = purchaseRequisitionTemplate.getProductModel(); + //产品规格型号把excel中的除.的符号都去掉(包括空格换行) + productModel = productModel.replaceAll("[^\\w.]", ""); + MesBaseMaterialInfo materialInfo = new MesBaseMaterialInfo(); + materialInfo.setMaterialName(materialName); + List materialInfoList = materialInfoService.selectMesBaseMaterialInfoList(materialInfo); + + int successFlag = 0; + MesBaseMaterialInfo findMaterialInfo = new MesBaseMaterialInfo(); + for (MesBaseMaterialInfo baseMaterialInfo : materialInfoList) { + String materialSpec = baseMaterialInfo.getMaterialSpec(); + materialSpec = materialSpec.replaceAll("[^\\w.]", ""); + if (materialSpec.equals(productModel)) { + successFlag++; + findMaterialInfo = baseMaterialInfo; + } + } + if (successFlag == 1) { + //导入ERP + JSONObject data = new JSONObject(); + data.put("FMaterialId", findMaterialInfo.getMaterialCode()); + data.put("FMaterialDesc", findMaterialInfo.getMaterialSpec()); + data.put("FUnitId", purchaseRequisitionTemplate.getUnit()); + data.put("FReqQty", purchaseRequisitionTemplate.getAmount()); + data.put("FTAXPRICE", purchaseRequisitionTemplate.getTaxUnitPrice()); + String params = data.toJSONString(); + R ajaxResult = remoteJindieService.singleSavePurchaseRequisition(params, SecurityConstants.INNER); + successNum++; + successMsg.append("
").append(materialName).append(" 导入成功"); + log.info(purchaseRequisitionTemplate.toString(), ajaxResult); + } else if (successFlag > 1) { + failureNum++; + failureMsg.append("
").append(failureNum).append(" 查出多条物料记录 导入失败"); + } else { + failureNum++; + failureMsg.append("
").append(failureNum).append(" 未找到物料记录 导入失败"); + } + } catch (Exception e) { + failureNum++; + String msg = "
" + failureNum + " 导入失败:"; + failureMsg.append(msg + e.getMessage()); + log.error(msg, e); + } + } + if (failureNum > 0) { + failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); + throw new ServiceException(failureMsg.toString()); + } else { + successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:"); + } + return successMsg.toString(); + } + +} diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductOrderServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductOrderServiceImpl.java index c59549f..849d09d 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductOrderServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductOrderServiceImpl.java @@ -11,14 +11,20 @@ import com.hw.common.core.exception.ServiceException; import com.hw.common.core.utils.DateUtils; import com.hw.common.core.utils.StringUtils; import com.hw.common.core.utils.uuid.Seq; +import com.hw.common.security.utils.SecurityUtils; import com.hw.mes.domain.MesMaterialBom; +import com.hw.mes.domain.MesProductPlan; +import com.hw.mes.mapper.MesProductPlanMapper; import com.hw.mes.service.IMesMaterialBomService; +import org.apache.commons.lang3.time.DateFormatUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.hw.mes.mapper.MesProductOrderMapper; import com.hw.mes.domain.MesProductOrder; import com.hw.mes.service.IMesProductOrderService; +import static com.hw.common.core.utils.DateUtils.YYYY_MM_DD_HH_MM_SS; + /** * 生产工单Service业务层处理 * @@ -33,6 +39,9 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService { @Autowired private IMesMaterialBomService mesMaterialBomService; + @Autowired + private MesProductPlanMapper mesProductPlanMapper; + /** * 查询生产工单 * @@ -241,10 +250,76 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService { if (topLevelOrder != null) { traverseChildren(result, topLevelOrder, visited); } + + //查找生产派工 + List productOrderList = new ArrayList<>(); + for (MesProductOrder order : result) { + Long orderId = order.getProductOrderId(); + + List planDateRange = new ArrayList<>(); + if (StringUtils.isNotNull(order.getPlanBeginTime())){ + planDateRange.add(DateFormatUtils.format(order.getPlanBeginTime(), YYYY_MM_DD_HH_MM_SS)); + } + if (StringUtils.isNotNull(order.getPlanEndTime())){ + planDateRange.add(DateFormatUtils.format(order.getPlanEndTime(), YYYY_MM_DD_HH_MM_SS)); + } + order.setPlanDateRange(planDateRange); + + MesProductPlan productPlan = new MesProductPlan(); + productPlan.setProductOrderId(orderId); + List productPlanList = mesProductPlanMapper.selectMesProductPlanList(productPlan); + for (MesProductPlan mesProductPlan : productPlanList) { + MesProductOrder productOrder = new MesProductOrder(); + List dateRange = new ArrayList<>(); + if (StringUtils.isNotNull(mesProductPlan.getPlanBeginTime())){ + dateRange.add(DateFormatUtils.format(mesProductPlan.getPlanBeginTime(), YYYY_MM_DD_HH_MM_SS)); + } + if (StringUtils.isNotNull(mesProductPlan.getPlanEndTime())){ + dateRange.add(DateFormatUtils.format(mesProductPlan.getPlanEndTime(), YYYY_MM_DD_HH_MM_SS)); + } + productOrder.setPlanDateRange(dateRange); + productOrder.setProductOrderId(mesProductPlan.getPlanId()); + productOrder.setPlanCode(mesProductPlan.getPlanCode()); + productOrder.setPreOrderId(order.getProductOrderId()); + productOrder.setPlanBeginTime(mesProductPlan.getPlanBeginTime()); + productOrder.setPlanEndTime(mesProductPlan.getPlanEndTime()); + productOrder.setPlanAmount(mesProductPlan.getPlanAmount()); + productOrder.setPlanId(mesProductPlan.getPlanId()); + productOrderList.add(productOrder); + } + order.setPreOrderId(0L); + } + result.addAll(productOrderList); // 返回包含所有关联订单的结果列表 return result; } + + /** + * 批量修改生产工单、生产派工 + * @param productOrderList + * @return + */ + @Override + public int batchEditingProductOrder(List productOrderList) { + int result = 0; + for (MesProductOrder productOrder : productOrderList) { + productOrder.setUpdateBy(SecurityUtils.getLoginUser().getUsername()); + if (StringUtils.isNull(productOrder.getPlanId())){ + result = mesProductOrderMapper.updateMesProductOrder(productOrder); + } else { + MesProductPlan productPlan = new MesProductPlan(); + productPlan.setPlanId(productOrder.getPlanId()); + productPlan.setPlanBeginTime(productOrder.getPlanBeginTime()); + productPlan.setPlanEndTime(productOrder.getPlanEndTime()); + if (StringUtils.isNotNull(productPlan.getPlanBeginTime()) || StringUtils.isNotNull(productPlan.getPlanEndTime())){ + result = mesProductPlanMapper.updateMesProductPlan(productPlan); + } + } + } + return result; + } + // 递归查找最顶级节点 private MesProductOrder findTopLevelOrder(Long productOrderId) { MesProductOrder currentOrder = mesProductOrderMapper.selectMesProductOrderByProductOrderId(productOrderId); @@ -266,6 +341,7 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService { // 获取所有以当前订单为父级ID的子订单列表 List children = mesProductOrderMapper.selectMesProductOrderListByPreOrderId(currentOrder.getProductOrderId()); for (MesProductOrder child : children) { + child.setPreOrderCode(currentOrder.getOrderCode()); // 递归遍历每个子订单 traverseChildren(result, child, visited); } diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseMaterialInfoMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseMaterialInfoMapper.xml index b5839d0..a550d89 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseMaterialInfoMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseMaterialInfoMapper.xml @@ -57,7 +57,6 @@ bmi.material_spec, bmi.net_weight, bmi.gross_weight, - bmi.bind_flag, bmi.factory_id, bmi.create_org_id, bmi.use_org_id, diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductPlanMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductPlanMapper.xml index 3cd7b2e..efdbcf5 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductPlanMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductPlanMapper.xml @@ -124,6 +124,7 @@ and mpp.product_order_id = #{productOrderId} and mpp.plan_code = #{planCode} and mpp.dispatch_code = #{dispatchCode} + and po.order_code = #{orderCode} and mpp.material_id = #{materialId} and mpp.material_bom_id = #{materialBomId} and mpp.process_id = #{processId} diff --git a/hw-ui/src/views/mes/productOrder/productionScheduling.vue b/hw-ui/src/views/mes/productOrder/productionScheduling.vue index 5d5eb5c..89bdd52 100644 --- a/hw-ui/src/views/mes/productOrder/productionScheduling.vue +++ b/hw-ui/src/views/mes/productOrder/productionScheduling.vue @@ -76,6 +76,8 @@ :tree-props="{children: 'children', hasChildren: 'hasChildren'}" > + + @@ -109,6 +111,13 @@ + + +