From 73a04deb022a6debf741b89b445eedb4253461f9 Mon Sep 17 00:00:00 2001 From: xs Date: Tue, 22 Oct 2024 10:55:47 +0800 Subject: [PATCH] =?UTF-8?q?3.3.0=20MES:=20=E9=87=87=E8=B4=AD=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E5=8D=95=E5=AF=BC=E5=85=A5=E5=92=8C=E5=90=8C=E6=AD=A5?= =?UTF-8?q?ERP=E5=8A=9F=E8=83=BD=E6=8C=89=E6=96=B0=E8=A6=81=E6=B1=82?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AE=8C=E6=88=90=20=E5=8E=9F=E6=9D=90?= =?UTF-8?q?=E6=96=99=E6=9D=A1=E7=A0=81=E7=BC=96=E8=BE=91=E5=AE=8C=E5=96=84?= =?UTF-8?q?=20=E7=94=9F=E4=BA=A7=E7=AE=A1=E7=90=86=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hw/common/core/constant/MesConstants.java | 6 + .../com/hw/common/core/utils/uuid/Seq.java | 18 +- .../mes/controller/MesImportController.java | 9 +- .../MesPurchaseApplyController.java | 120 +++++ .../com/hw/mes/domain/MesPurchaseApply.java | 116 +++++ .../hw/mes/domain/MesPurchaseApplyDetail.java | 242 ++++++++++ .../MesPurchaseRequisitionTemplate.java | 14 + .../java/com/hw/mes/domain/MesSaleOrder.java | 11 + .../mapper/MesPurchaseApplyDetailMapper.java | 61 +++ .../hw/mes/mapper/MesPurchaseApplyMapper.java | 98 ++++ .../mes/service/IMesPurchaseApplyService.java | 82 ++++ .../impl/MesProductOrderServiceImpl.java | 108 +++-- .../impl/MesPurchaseApplyServiceImpl.java | 309 ++++++++++++ .../mes/MesPurchaseApplyDetailMapper.xml | 116 +++++ .../mapper/mes/MesPurchaseApplyMapper.xml | 145 ++++++ .../mapper/mes/MesSaleOrderMapper.xml | 3 +- hw-ui/src/api/mes/purchaseApply.js | 56 +++ hw-ui/src/views/mes/barcode/index.vue | 55 ++- .../views/mes/productOrder/addSaleOrder.vue | 17 +- hw-ui/src/views/mes/productOrder/index.vue | 56 ++- hw-ui/src/views/mes/purchaseApply/index.vue | 451 ++++++++++++++++++ 21 files changed, 2009 insertions(+), 84 deletions(-) create mode 100644 hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesPurchaseApplyController.java create mode 100644 hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesPurchaseApply.java create mode 100644 hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesPurchaseApplyDetail.java create mode 100644 hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesPurchaseApplyDetailMapper.java create mode 100644 hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesPurchaseApplyMapper.java create mode 100644 hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesPurchaseApplyService.java create mode 100644 hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesPurchaseApplyServiceImpl.java create mode 100644 hw-modules/hw-mes/src/main/resources/mapper/mes/MesPurchaseApplyDetailMapper.xml create mode 100644 hw-modules/hw-mes/src/main/resources/mapper/mes/MesPurchaseApplyMapper.xml create mode 100644 hw-ui/src/api/mes/purchaseApply.js create mode 100644 hw-ui/src/views/mes/purchaseApply/index.vue diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/MesConstants.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/MesConstants.java index eed184d6..2610be73 100644 --- a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/MesConstants.java +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/MesConstants.java @@ -304,4 +304,10 @@ public class MesConstants { * 物料自动出库标识 */ public static final String MES_MATERIAL_AUTO_OUTSTOCK_FLAG_YES="1"; + + /** + * 采购申请单同步ERP状态 + */ + public static final String MES_PURCHASE_APPALY_SYNC_YES="1";//已同步 + public static final String MES_PURCHASE_APPALY_SYNC_NO="0";//未同步 } diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/uuid/Seq.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/uuid/Seq.java index f2e85ce6..24c27d76 100644 --- a/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/uuid/Seq.java +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/uuid/Seq.java @@ -313,13 +313,13 @@ public class Seq { // 虚拟采购订单信息的记录标识 public static final String mesVirtualPurchaseOrderCode = "VP"; - // 采购申请任务编号 + // 采购申请提资单任务编号 public static final String mesPurchaseApplyProcessSeqType = "purchaseApplyProcess"; - // 采购申请任务编号序列数 + // 采购申请提资单任务编号序列数 private static AtomicInteger mesPurchaseApplyProcessSeq = new AtomicInteger(1); - // 采购申请任务编号的记录标识 + // 采购申请提资单任务编号的记录标识 public static final String mesPurchaseApplyProcessCode = "CG"; @@ -366,6 +366,16 @@ public class Seq { public static final String mesInternalVirtualProductBarcodeCode = "VT"; + + // 采购申请单任务编号 + public static final String mesPurchaseApplySeqType = "purchaseApply"; + + // 采购申请单任务编号序列数 + private static AtomicInteger mesPurchaseApplySeq = new AtomicInteger(1); + + // 采购申请单任务编号的记录标识 + public static final String mesPurchaseApplyCode = "PA"; + /** * 获取通用序列号 * @@ -490,6 +500,8 @@ public class Seq { atomicInt = mesInternalVirtualProductBarcodeSeq; }else if (mesInternalBarcodeSeqType.equals(type)) { atomicInt = mesInternalBarcodeSeq; + }else if (mesPurchaseApplySeqType.equals(type)) { + atomicInt = mesPurchaseApplySeq; } return getId(atomicInt, 3, code); } 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 index e4a38341..22442120 100644 --- 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 @@ -9,6 +9,7 @@ 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 com.hw.mes.service.IMesPurchaseApplyService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -30,6 +31,9 @@ public class MesImportController extends BaseController { @Autowired private IMesImportService mesImportService; + @Autowired + private IMesPurchaseApplyService mesPurchaseApplyService; + /** * 采购申请单excel导入 @@ -40,9 +44,8 @@ public class MesImportController extends BaseController { { 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); + Long purchaseApplyId = mesPurchaseApplyService.importPurchaseApply(purchaseRequisitionTemplateList); + return success(purchaseApplyId); } /** diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesPurchaseApplyController.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesPurchaseApplyController.java new file mode 100644 index 00000000..e2485c16 --- /dev/null +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesPurchaseApplyController.java @@ -0,0 +1,120 @@ +package com.hw.mes.controller; + +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.hw.common.log.annotation.Log; +import com.hw.common.log.enums.BusinessType; +import com.hw.common.security.annotation.RequiresPermissions; +import com.hw.mes.domain.MesPurchaseApply; +import com.hw.mes.service.IMesPurchaseApplyService; +import com.hw.common.core.web.controller.BaseController; +import com.hw.common.core.web.domain.AjaxResult; +import com.hw.common.core.utils.poi.ExcelUtil; +import com.hw.common.core.web.page.TableDataInfo; + +/** + * 采购申请单Controller + * + * @author xins + * @date 2024-10-21 + */ +@RestController +@RequestMapping("/purchaseApply") +public class MesPurchaseApplyController extends BaseController +{ + @Autowired + private IMesPurchaseApplyService mesPurchaseApplyService; + + /** + * 查询采购申请单列表 + */ + @RequiresPermissions("mes:purchaseApply:list") + @GetMapping("/list") + public TableDataInfo list(MesPurchaseApply mesPurchaseApply) + { + startPage(); + List list = mesPurchaseApplyService.selectMesPurchaseApplyList(mesPurchaseApply); + return getDataTable(list); + } + + /** + * 导出采购申请单列表 + */ + @RequiresPermissions("mes:purchaseApply:export") + @Log(title = "采购申请单", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, MesPurchaseApply mesPurchaseApply) + { + List list = mesPurchaseApplyService.selectMesPurchaseApplyList(mesPurchaseApply); + ExcelUtil util = new ExcelUtil(MesPurchaseApply.class); + util.exportExcel(response, list, "采购申请单数据"); + } + + /** + * 获取采购申请单详细信息 + */ + @RequiresPermissions("mes:purchaseApply:query") + @GetMapping(value = "/{purchaseApplyId}") + public AjaxResult getInfo(@PathVariable("purchaseApplyId") Long purchaseApplyId) + { + return success(mesPurchaseApplyService.selectMesPurchaseApplyByPurchaseApplyId(purchaseApplyId)); + } + + /** + * 新增采购申请单 + */ + @RequiresPermissions("mes:purchaseApply:add") + @Log(title = "采购申请单", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody MesPurchaseApply mesPurchaseApply) + { + return toAjax(mesPurchaseApplyService.insertMesPurchaseApply(mesPurchaseApply)); + } + + /** + * 修改采购申请单 + */ + @RequiresPermissions("mes:purchaseApply:edit") + @Log(title = "采购申请单", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody MesPurchaseApply mesPurchaseApply) + { + return toAjax(mesPurchaseApplyService.updateMesPurchaseApply(mesPurchaseApply)); + } + + /** + * 删除采购申请单 + */ + @RequiresPermissions("mes:purchaseApply:remove") + @Log(title = "采购申请单", businessType = BusinessType.DELETE) + @DeleteMapping("/{purchaseApplyIds}") + public AjaxResult remove(@PathVariable Long[] purchaseApplyIds) + { + return toAjax(mesPurchaseApplyService.deleteMesPurchaseApplyByPurchaseApplyIds(purchaseApplyIds)); + } + + + + + /** + * 同步采购申请单 + */ + @RequiresPermissions("mes:purchaseApply:sync") + @Log(title = "采购申请单", businessType = BusinessType.UPDATE) + @PostMapping("/syncPurchaseApply") + public AjaxResult syncPurchaseApply(@RequestBody MesPurchaseApply mesPurchaseApply) + { + return toAjax(mesPurchaseApplyService.syncMesPurchaseApply(mesPurchaseApply)); + } + +} diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesPurchaseApply.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesPurchaseApply.java new file mode 100644 index 00000000..7e0038bb --- /dev/null +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesPurchaseApply.java @@ -0,0 +1,116 @@ +package com.hw.mes.domain; + +import java.util.List; +import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.hw.common.core.annotation.Excel; +import com.hw.common.core.web.domain.BaseEntity; + +/** + * 采购申请单对象 mes_purchase_apply + * + * @author xins + * @date 2024-10-21 + */ +public class MesPurchaseApply extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键标识 */ + private Long purchaseApplyId; + + /** 任务编号 */ + @Excel(name = "任务编号") + private String taskCode; + + /** 京源项目 */ + @Excel(name = "京源项目") + private String tondBase; + + /** 同步状态(0未同步1已同步) */ + @Excel(name = "同步状态(0未同步1已同步)") + private String syncStatus; + + /** 同步ERP时间 */ + @JsonFormat(pattern = "yyyy-MM-dd") + @Excel(name = "同步ERP时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date syncTime; + + /** 采购申请单详细信息;从ERP同步过来的信息,需要与物料信息关联,需要确认接口同步过来的信息内容信息 */ + private List mesPurchaseApplyDetailList; + + public void setPurchaseApplyId(Long purchaseApplyId) + { + this.purchaseApplyId = purchaseApplyId; + } + + public Long getPurchaseApplyId() + { + return purchaseApplyId; + } + public void setTaskCode(String taskCode) + { + this.taskCode = taskCode; + } + + public String getTaskCode() + { + return taskCode; + } + public void setTondBase(String tondBase) + { + this.tondBase = tondBase; + } + + public String getTondBase() + { + return tondBase; + } + public void setSyncStatus(String syncStatus) + { + this.syncStatus = syncStatus; + } + + public String getSyncStatus() + { + return syncStatus; + } + public void setSyncTime(Date syncTime) + { + this.syncTime = syncTime; + } + + public Date getSyncTime() + { + return syncTime; + } + + public List getMesPurchaseApplyDetailList() + { + return mesPurchaseApplyDetailList; + } + + public void setMesPurchaseApplyDetailList(List mesPurchaseApplyDetailList) + { + this.mesPurchaseApplyDetailList = mesPurchaseApplyDetailList; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("purchaseApplyId", getPurchaseApplyId()) + .append("taskCode", getTaskCode()) + .append("tondBase", getTondBase()) + .append("syncStatus", getSyncStatus()) + .append("syncTime", getSyncTime()) + .append("remark", getRemark()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("mesPurchaseApplyDetailList", getMesPurchaseApplyDetailList()) + .toString(); + } +} diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesPurchaseApplyDetail.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesPurchaseApplyDetail.java new file mode 100644 index 00000000..6578fad8 --- /dev/null +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesPurchaseApplyDetail.java @@ -0,0 +1,242 @@ +package com.hw.mes.domain; + +import java.math.BigDecimal; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.hw.common.core.annotation.Excel; +import com.hw.common.core.web.domain.BaseEntity; + +/** + * 采购申请单详细信息;从ERP同步过来的信息,需要与物料信息关联,需要确认接口同步过来的信息内容对象 mes_purchase_apply_detail + * + * @author xins + * @date 2024-10-21 + */ +public class MesPurchaseApplyDetail extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 主键标识 */ + private Long purchaseApplyDetailId; + + /** 采购申请单ID */ + @Excel(name = "采购申请单ID") + private Long purchaseApplyId; + + private String tondBase; + + /** ERP物料ID */ + @Excel(name = "ERP物料ID") + private Long erpMaterialId; + + /** 物料ID */ + @Excel(name = "物料ID") + private Long materialId; + + /** 物料编码;对应FMaterialId */ + @Excel(name = "物料编码;对应FMaterialId") + private String materialCode; + + /** 物料名称 */ + @Excel(name = "物料名称") + private String materialName; + + /** 物料规格;FMaterialDesc */ + @Excel(name = "物料规格;FMaterialDesc") + private String materialSpec; + + private String unitName; + + /** 物料单位编码;FUnitId */ + @Excel(name = "物料单位编码;FUnitId") + private String unitCode; + + /** 价格单位;FPriceUnitId */ + @Excel(name = "价格单位;FPriceUnitId") + private String priceUnitCode; + + /** 需要数量;FReqQty */ + @Excel(name = "需要数量;FReqQty") + private BigDecimal reqQty; + + /** 生产厂家 */ + @Excel(name = "生产厂家") + private String produceSupplier; + + /** 含税单价;FTAXPRICE */ + @Excel(name = "含税单价;FTAXPRICE") + private BigDecimal taxPrice; + + /** 含税总价 */ + @Excel(name = "含税总价") + private BigDecimal taxTotalPrice; + + /** 原需要数量 */ + @Excel(name = "原需要数量") + private BigDecimal oriReqQty; + + public void setPurchaseApplyDetailId(Long purchaseApplyDetailId) + { + this.purchaseApplyDetailId = purchaseApplyDetailId; + } + + public Long getPurchaseApplyDetailId() + { + return purchaseApplyDetailId; + } + public void setPurchaseApplyId(Long purchaseApplyId) + { + this.purchaseApplyId = purchaseApplyId; + } + + public Long getPurchaseApplyId() + { + return purchaseApplyId; + } + + public String getTondBase() { + return tondBase; + } + + public void setTondBase(String tondBase) { + this.tondBase = tondBase; + } + + public void setErpMaterialId(Long erpMaterialId) + { + this.erpMaterialId = erpMaterialId; + } + + public Long getErpMaterialId() + { + return erpMaterialId; + } + public void setMaterialId(Long materialId) + { + this.materialId = materialId; + } + + public Long getMaterialId() + { + return materialId; + } + public void setMaterialCode(String materialCode) + { + this.materialCode = materialCode; + } + + public String getMaterialCode() + { + return materialCode; + } + public void setMaterialName(String materialName) + { + this.materialName = materialName; + } + + public String getMaterialName() + { + return materialName; + } + public void setMaterialSpec(String materialSpec) + { + this.materialSpec = materialSpec; + } + + public String getMaterialSpec() + { + return materialSpec; + } + + public String getUnitName() { + return unitName; + } + + public void setUnitName(String unitName) { + this.unitName = unitName; + } + + public void setUnitCode(String unitCode) + { + this.unitCode = unitCode; + } + + public String getUnitCode() + { + return unitCode; + } + public void setPriceUnitCode(String priceUnitCode) + { + this.priceUnitCode = priceUnitCode; + } + + public String getPriceUnitCode() + { + return priceUnitCode; + } + public void setReqQty(BigDecimal reqQty) + { + this.reqQty = reqQty; + } + + public BigDecimal getReqQty() + { + return reqQty; + } + public void setProduceSupplier(String produceSupplier) + { + this.produceSupplier = produceSupplier; + } + + public String getProduceSupplier() + { + return produceSupplier; + } + public void setTaxPrice(BigDecimal taxPrice) + { + this.taxPrice = taxPrice; + } + + public BigDecimal getTaxPrice() + { + return taxPrice; + } + public void setTaxTotalPrice(BigDecimal taxTotalPrice) + { + this.taxTotalPrice = taxTotalPrice; + } + + public BigDecimal getTaxTotalPrice() + { + return taxTotalPrice; + } + public void setOriReqQty(BigDecimal oriReqQty) + { + this.oriReqQty = oriReqQty; + } + + public BigDecimal getOriReqQty() + { + return oriReqQty; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("purchaseApplyDetailId", getPurchaseApplyDetailId()) + .append("purchaseApplyId", getPurchaseApplyId()) + .append("erpMaterialId", getErpMaterialId()) + .append("materialId", getMaterialId()) + .append("materialCode", getMaterialCode()) + .append("materialName", getMaterialName()) + .append("materialSpec", getMaterialSpec()) + .append("unitCode", getUnitCode()) + .append("priceUnitCode", getPriceUnitCode()) + .append("reqQty", getReqQty()) + .append("produceSupplier", getProduceSupplier()) + .append("taxPrice", getTaxPrice()) + .append("taxTotalPrice", getTaxTotalPrice()) + .append("oriReqQty", getOriReqQty()) + .toString(); + } +} 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 index 04b1f5dc..eb9043a7 100644 --- 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 @@ -65,6 +65,12 @@ public class MesPurchaseRequisitionTemplate { @Excel(name = "含税总价(元)") private BigDecimal taxTotalPrice; + /** + * 京源项目 + */ + @Excel(name = "京源项目") + private String tondBase; + public Long getSerialNumber() { return serialNumber; } @@ -129,6 +135,14 @@ public class MesPurchaseRequisitionTemplate { this.taxTotalPrice = taxTotalPrice; } + public String getTondBase() { + return tondBase; + } + + public void setTondBase(String tondBase) { + this.tondBase = tondBase; + } + @Override public String toString() { return "MesPurchaseRequisitionTemplate{" + diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesSaleOrder.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesSaleOrder.java index faa3587a..6b4c026e 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesSaleOrder.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesSaleOrder.java @@ -196,6 +196,9 @@ public class MesSaleOrder extends BaseEntity { */ private String selectFlag; + private Long virtualSaleOrderId; + + public String getMaterialModel() { return materialModel; } @@ -452,6 +455,14 @@ public class MesSaleOrder extends BaseEntity { this.selectFlag = selectFlag; } + public Long getVirtualSaleOrderId() { + return virtualSaleOrderId; + } + + public void setVirtualSaleOrderId(Long virtualSaleOrderId) { + this.virtualSaleOrderId = virtualSaleOrderId; + } + @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesPurchaseApplyDetailMapper.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesPurchaseApplyDetailMapper.java new file mode 100644 index 00000000..4b7c0e7c --- /dev/null +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesPurchaseApplyDetailMapper.java @@ -0,0 +1,61 @@ +package com.hw.mes.mapper; + +import java.util.List; +import com.hw.mes.domain.MesPurchaseApplyDetail; + +/** + * 采购申请单详细信息;从ERP同步过来的信息,需要与物料信息关联,需要确认接口同步过来的信息内容Mapper接口 + * + * @author xins + * @date 2024-10-22 + */ +public interface MesPurchaseApplyDetailMapper +{ + /** + * 查询采购申请单详细信息;从ERP同步过来的信息,需要与物料信息关联,需要确认接口同步过来的信息内容 + * + * @param purchaseApplyDetailId 采购申请单详细信息;从ERP同步过来的信息,需要与物料信息关联,需要确认接口同步过来的信息内容主键 + * @return 采购申请单详细信息;从ERP同步过来的信息,需要与物料信息关联,需要确认接口同步过来的信息内容 + */ + public MesPurchaseApplyDetail selectMesPurchaseApplyDetailByPurchaseApplyDetailId(Long purchaseApplyDetailId); + + /** + * 查询采购申请单详细信息;从ERP同步过来的信息,需要与物料信息关联,需要确认接口同步过来的信息内容列表 + * + * @param mesPurchaseApplyDetail 采购申请单详细信息;从ERP同步过来的信息,需要与物料信息关联,需要确认接口同步过来的信息内容 + * @return 采购申请单详细信息;从ERP同步过来的信息,需要与物料信息关联,需要确认接口同步过来的信息内容集合 + */ + public List selectMesPurchaseApplyDetailList(MesPurchaseApplyDetail mesPurchaseApplyDetail); + + /** + * 新增采购申请单详细信息;从ERP同步过来的信息,需要与物料信息关联,需要确认接口同步过来的信息内容 + * + * @param mesPurchaseApplyDetail 采购申请单详细信息;从ERP同步过来的信息,需要与物料信息关联,需要确认接口同步过来的信息内容 + * @return 结果 + */ + public int insertMesPurchaseApplyDetail(MesPurchaseApplyDetail mesPurchaseApplyDetail); + + /** + * 修改采购申请单详细信息;从ERP同步过来的信息,需要与物料信息关联,需要确认接口同步过来的信息内容 + * + * @param mesPurchaseApplyDetail 采购申请单详细信息;从ERP同步过来的信息,需要与物料信息关联,需要确认接口同步过来的信息内容 + * @return 结果 + */ + public int updateMesPurchaseApplyDetail(MesPurchaseApplyDetail mesPurchaseApplyDetail); + + /** + * 删除采购申请单详细信息;从ERP同步过来的信息,需要与物料信息关联,需要确认接口同步过来的信息内容 + * + * @param purchaseApplyDetailId 采购申请单详细信息;从ERP同步过来的信息,需要与物料信息关联,需要确认接口同步过来的信息内容主键 + * @return 结果 + */ + public int deleteMesPurchaseApplyDetailByPurchaseApplyDetailId(Long purchaseApplyDetailId); + + /** + * 批量删除采购申请单详细信息;从ERP同步过来的信息,需要与物料信息关联,需要确认接口同步过来的信息内容 + * + * @param purchaseApplyDetailIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteMesPurchaseApplyDetailByPurchaseApplyDetailIds(Long[] purchaseApplyDetailIds); +} diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesPurchaseApplyMapper.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesPurchaseApplyMapper.java new file mode 100644 index 00000000..cd18c8d3 --- /dev/null +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesPurchaseApplyMapper.java @@ -0,0 +1,98 @@ +package com.hw.mes.mapper; + +import java.util.List; +import com.hw.mes.domain.MesPurchaseApply; +import com.hw.mes.domain.MesPurchaseApplyDetail; + +/** + * 采购申请单Mapper接口 + * + * @author xins + * @date 2024-10-21 + */ +public interface MesPurchaseApplyMapper +{ + /** + * 查询采购申请单,join detail + * + * @param purchaseApplyId 采购申请单主键 + * @return 采购申请单 + */ + public MesPurchaseApply selectMesPurchaseApplyByPurchaseApplyId(Long purchaseApplyId); + + /** + * 查询采购申请单列表 + * + * @param mesPurchaseApply 采购申请单 + * @return 采购申请单集合 + */ + public List selectMesPurchaseApplyList(MesPurchaseApply mesPurchaseApply); + + /** + * 新增采购申请单 + * + * @param mesPurchaseApply 采购申请单 + * @return 结果 + */ + public int insertMesPurchaseApply(MesPurchaseApply mesPurchaseApply); + + /** + * 修改采购申请单 + * + * @param mesPurchaseApply 采购申请单 + * @return 结果 + */ + public int updateMesPurchaseApply(MesPurchaseApply mesPurchaseApply); + + /** + * 删除采购申请单 + * + * @param purchaseApplyId 采购申请单主键 + * @return 结果 + */ + public int deleteMesPurchaseApplyByPurchaseApplyId(Long purchaseApplyId); + + /** + * 批量删除采购申请单 + * + * @param purchaseApplyIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteMesPurchaseApplyByPurchaseApplyIds(Long[] purchaseApplyIds); + + /** + * 批量删除采购申请单详细信息;从ERP同步过来的信息,需要与物料信息关联,需要确认接口同步过来的信息内容 + * + * @param purchaseApplyIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteMesPurchaseApplyDetailByPurchaseApplyIds(Long[] purchaseApplyIds); + + /** + * 批量新增采购申请单详细信息;从ERP同步过来的信息,需要与物料信息关联,需要确认接口同步过来的信息内容 + * + * @param mesPurchaseApplyDetailList 采购申请单详细信息;从ERP同步过来的信息,需要与物料信息关联,需要确认接口同步过来的信息内容列表 + * @return 结果 + */ + public int batchMesPurchaseApplyDetail(List mesPurchaseApplyDetailList); + + + /** + * 通过采购申请单主键删除采购申请单详细信息;从ERP同步过来的信息,需要与物料信息关联,需要确认接口同步过来的信息内容信息 + * + * @param purchaseApplyId 采购申请单ID + * @return 结果 + */ + public int deleteMesPurchaseApplyDetailByPurchaseApplyId(Long purchaseApplyId); + + + /** + * 查询采购申请单 + * + * @param purchaseApplyId 采购申请单主键 + * @return 采购申请单 + */ + public MesPurchaseApply selectOnlyMesPurchaseApplyByPurchaseApplyId(Long purchaseApplyId); + + +} diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesPurchaseApplyService.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesPurchaseApplyService.java new file mode 100644 index 00000000..6e1a9129 --- /dev/null +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesPurchaseApplyService.java @@ -0,0 +1,82 @@ +package com.hw.mes.service; + +import java.util.List; + +import com.hw.common.core.exception.ServiceException; +import com.hw.mes.domain.MesPurchaseApply; +import com.hw.mes.domain.MesPurchaseRequisitionTemplate; +import org.springframework.transaction.annotation.Transactional; + +/** + * 采购申请单Service接口 + * + * @author xins + * @date 2024-10-21 + */ +public interface IMesPurchaseApplyService +{ + /** + * 查询采购申请单 + * + * @param purchaseApplyId 采购申请单主键 + * @return 采购申请单 + */ + public MesPurchaseApply selectMesPurchaseApplyByPurchaseApplyId(Long purchaseApplyId); + + /** + * 查询采购申请单列表 + * + * @param mesPurchaseApply 采购申请单 + * @return 采购申请单集合 + */ + public List selectMesPurchaseApplyList(MesPurchaseApply mesPurchaseApply); + + /** + * 新增采购申请单 + * + * @param mesPurchaseApply 采购申请单 + * @return 结果 + */ + public int insertMesPurchaseApply(MesPurchaseApply mesPurchaseApply); + + /** + * 修改采购申请单 + * + * @param mesPurchaseApply 采购申请单 + * @return 结果 + */ + public int updateMesPurchaseApply(MesPurchaseApply mesPurchaseApply); + + /** + * 批量删除采购申请单 + * + * @param purchaseApplyIds 需要删除的采购申请单主键集合 + * @return 结果 + */ + public int deleteMesPurchaseApplyByPurchaseApplyIds(Long[] purchaseApplyIds); + + /** + * 删除采购申请单信息 + * + * @param purchaseApplyId 采购申请单主键 + * @return 结果 + */ + public int deleteMesPurchaseApplyByPurchaseApplyId(Long purchaseApplyId); + + + /** + * 导入采购申请单 + * @param purchaseRequisitionTemplateList + * @return + */ + public Long importPurchaseApply(List purchaseRequisitionTemplateList); + + + /** + * 同步采购申请单 + * + * @param mesPurchaseApply 采购申请单 + * @return 结果 + */ + public int syncMesPurchaseApply(MesPurchaseApply mesPurchaseApply); +} 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 608fd210..81f79fb3 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 @@ -12,8 +12,10 @@ 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.domain.MesSaleOrder; import com.hw.mes.mapper.MesMaterialBomMapper; import com.hw.mes.mapper.MesProductPlanMapper; +import com.hw.mes.mapper.MesSaleOrderMapper; import com.hw.mes.service.IMesMaterialBomService; import org.apache.commons.lang3.time.DateFormatUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -44,6 +46,9 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService { @Autowired private MesMaterialBomMapper mesMaterialBomMapper; + @Autowired + private MesSaleOrderMapper mesSaleOrderMapper; + /** * 查询生产工单 * @@ -104,39 +109,15 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService { } else { //校验同一工艺路线时间重叠 checkSameProcessTimeClash(mesProductOrder); - //销售订单添加工单:校验是否超出销售数量 - if (mesProductOrder.getSaleOrderFlag().equals("1") && StringUtils.isNotNull(mesProductOrder.getSaleOrderId())) { - checkSalesQuantity(mesProductOrder); - } else { - mesProductOrder.setSaleAmount(mesProductOrder.getPlanAmount()); - } - if (mesProductOrder.getSaleOrderId() == null) { - mesProductOrder.setSaleOrderId(0L); - } - if (mesProductOrder.getSaleType().equals(MesConstants.MES_PRODUCT_ORDER_SALE)) { - mesProductOrder.setProduceMaterialId(null); - } else { - if (mesProductOrder.getProduceMaterialId() == null) { - throw new ServiceException("请选择生产物料"); - } - - //校验此生产物料是否在销售订单成品物料的生产bom中 - MesMaterialBom queryMaterialBom = new MesMaterialBom(); - queryMaterialBom.setMaterialId(mesProductOrder.getProduceMaterialId()); - queryMaterialBom.setParentId(mesProductOrder.getMaterialBomId()); - queryMaterialBom.setActiveFlag(MesConstants.MES_MATERIAL_BOM_ACTIVE_FLAG_NORMAL); - List mesMaterialBoms = mesMaterialBomMapper.selectMesMaterialBomList(queryMaterialBom); - if (mesMaterialBoms == null || mesMaterialBoms.isEmpty()) { - throw new ServiceException("所选择生产物料不在选择的成品bom中"); - } - - } + //销售订单添加工单:校验是否超出销售数量;校验对内生产所选物料的bom + checkProductOrder(mesProductOrder); } return mesProductOrderMapper.insertMesProductOrder(mesProductOrder); } + /** * 修改生产工单 * @@ -176,19 +157,82 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService { // } // } - //校验同一工艺路线时间重叠 - checkSameProcessTimeClash(mesProductOrder); + if (mesProductOrder.getSaleType().equals(MesConstants.MES_PRODUCT_ORDER_PACKING)) { + mesProductOrder.setDispatchId(5L);//包装工艺路线ID + mesProductOrder.setSaleOrderId(0L); + mesProductOrder.setSaleOrderFlag(MesConstants.MES_ORDER_BIND_SAFE_FLAG_NO); + mesProductOrder.setMaterialId(0L); + mesProductOrder.setMaterialBomId(0L); + mesProductOrder.setSaleAmount(mesProductOrder.getPlanAmount()); + } else { + //校验同一工艺路线时间重叠 + checkSameProcessTimeClash(mesProductOrder); + //销售订单修改工单:校验是否超出销售数量;校验对内生产所选物料的bom + checkProductOrder(mesProductOrder); - //销售订单修改工单:校验是否超出销售数量 + } + + mesProductOrder.setUpdateBy(SecurityUtils.getUsername()); + mesProductOrder.setUpdateTime(DateUtils.getNowDate()); + return mesProductOrderMapper.updateMesProductOrder(mesProductOrder); + } + + private void checkProductOrder(MesProductOrder mesProductOrder) { if (StringUtils.isNotEmpty(mesProductOrder.getSaleOrderFlag()) && mesProductOrder.getSaleOrderFlag().equals("1") && StringUtils.isNotNull(mesProductOrder.getSaleOrderId())) { checkSalesQuantity(mesProductOrder); + checkVirtualSaleOrder(mesProductOrder.getSaleOrderId(), mesProductOrder.getSaleType(), mesProductOrder.getCabinetChannel()); + } else { + mesProductOrder.setSaleAmount(mesProductOrder.getPlanAmount()); + } + if (mesProductOrder.getSaleOrderId() == null) { + mesProductOrder.setSaleOrderId(0L); + } + + if (mesProductOrder.getSaleType().equals(MesConstants.MES_PRODUCT_ORDER_SALE)) { + mesProductOrder.setProduceMaterialId(null); + } else { + if (mesProductOrder.getProduceMaterialId() == null) { + throw new ServiceException("请选择生产物料"); + } + + //校验此生产物料是否在销售订单成品物料的生产bom中 + MesMaterialBom queryMaterialBom = new MesMaterialBom(); + queryMaterialBom.setMaterialId(mesProductOrder.getProduceMaterialId()); + queryMaterialBom.setParentId(mesProductOrder.getMaterialBomId()); +// queryMaterialBom.setActiveFlag(MesConstants.MES_MATERIAL_BOM_ACTIVE_FLAG_NORMAL); + List mesMaterialBoms = mesMaterialBomMapper.selectMesMaterialBomList(queryMaterialBom); + if (mesMaterialBoms == null || mesMaterialBoms.isEmpty()) { + throw new ServiceException("所选择生产物料不在选择的成品bom中"); + } } - mesProductOrder.setUpdateTime(DateUtils.getNowDate()); - return mesProductOrderMapper.updateMesProductOrder(mesProductOrder); } + + /** + * 在生产管理新建时,如果选择的销售订单为虚拟的,销售类型必须是外部销售,柜体渠道必须是外部采购 + * + * @param saleOrderId + * @param saleType + * @param cabinetChannel + */ + private void checkVirtualSaleOrder(Long saleOrderId, String saleType, String cabinetChannel) { + MesSaleOrder mesSaleOrder = mesSaleOrderMapper.selectMesSaleOrderBySaleOrderId(saleOrderId); + String saleOrderClassfication = mesSaleOrder.getSaleOrderClassfication(); + if (saleOrderClassfication.equals(MesConstants.MES_SALE_ORDER_CLASSFICATION_VIRTUAL)) { + if (!saleType.equals(MesConstants.MES_PRODUCT_ORDER_SALE)) { + throw new ServiceException("所选销售订单为合并的虚拟订单,销售类型需要选择外部销售"); + } + + if (!cabinetChannel.equals(MesConstants.MES_PRODUCT_ORDER_CABINET_CHANNEL_PURCHASE)) { + throw new ServiceException("所选销售订单为合并的虚拟订单,柜体渠道需要选择外部采购"); + } + } + + } + + /** * 校验当前任务的开始时间是否小于前置任务的结束时间 * diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesPurchaseApplyServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesPurchaseApplyServiceImpl.java new file mode 100644 index 00000000..f8a24b17 --- /dev/null +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesPurchaseApplyServiceImpl.java @@ -0,0 +1,309 @@ +package com.hw.mes.service.impl; + +import java.util.Date; +import java.util.List; + +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import com.hw.common.core.constant.Constants; +import com.hw.common.core.constant.MesConstants; +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.DateUtils; +import com.hw.common.core.utils.uuid.Seq; +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.domain.MesBaseMaterialInfo; +import com.hw.mes.domain.MesBaseUnitInfo; +import com.hw.mes.domain.MesPurchaseRequisitionTemplate; +import com.hw.mes.mapper.MesBaseMaterialInfoMapper; +import com.hw.mes.mapper.MesBaseUnitInfoMapper; +import com.hw.mes.mapper.MesPurchaseApplyDetailMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; + +import com.hw.common.core.utils.StringUtils; +import org.springframework.transaction.annotation.Transactional; +import com.hw.mes.domain.MesPurchaseApplyDetail; +import com.hw.mes.mapper.MesPurchaseApplyMapper; +import com.hw.mes.domain.MesPurchaseApply; +import com.hw.mes.service.IMesPurchaseApplyService; + +import javax.annotation.Resource; + +/** + * 采购申请单Service业务层处理 + * + * @author xins + * @date 2024-10-21 + */ +@Service +public class MesPurchaseApplyServiceImpl implements IMesPurchaseApplyService { + @Autowired + private MesPurchaseApplyMapper mesPurchaseApplyMapper; + + @Autowired + private MesPurchaseApplyDetailMapper mesPurchaseApplyDetailMapper; + + @Autowired + private MesBaseMaterialInfoMapper mesBaseMaterialInfoMapper; + + @Autowired + private MesBaseUnitInfoMapper mesBaseUnitInfoMapper; + + @Resource + private RemoteJindieService remoteJindieService; + + /** + * 查询采购申请单 + * + * @param purchaseApplyId 采购申请单主键 + * @return 采购申请单 + */ + @Override + public MesPurchaseApply selectMesPurchaseApplyByPurchaseApplyId(Long purchaseApplyId) { + return mesPurchaseApplyMapper.selectMesPurchaseApplyByPurchaseApplyId(purchaseApplyId); + } + + /** + * 查询采购申请单列表 + * + * @param mesPurchaseApply 采购申请单 + * @return 采购申请单 + */ + @Override + public List selectMesPurchaseApplyList(MesPurchaseApply mesPurchaseApply) { + return mesPurchaseApplyMapper.selectMesPurchaseApplyList(mesPurchaseApply); + } + + /** + * 新增采购申请单 + * + * @param mesPurchaseApply 采购申请单 + * @return 结果 + */ + @Transactional + @Override + public int insertMesPurchaseApply(MesPurchaseApply mesPurchaseApply) { + mesPurchaseApply.setCreateTime(DateUtils.getNowDate()); + int rows = mesPurchaseApplyMapper.insertMesPurchaseApply(mesPurchaseApply); + insertMesPurchaseApplyDetail(mesPurchaseApply); + return rows; + } + + /** + * 修改采购申请单 + * + * @param mesPurchaseApply 采购申请单 + * @return 结果 + */ + @Transactional + @Override + public int updateMesPurchaseApply(MesPurchaseApply mesPurchaseApply) { + mesPurchaseApply.setUpdateTime(DateUtils.getNowDate()); + mesPurchaseApplyMapper.deleteMesPurchaseApplyDetailByPurchaseApplyId(mesPurchaseApply.getPurchaseApplyId()); + insertMesPurchaseApplyDetail(mesPurchaseApply); + return mesPurchaseApplyMapper.updateMesPurchaseApply(mesPurchaseApply); + } + + /** + * 批量删除采购申请单 + * + * @param purchaseApplyIds 需要删除的采购申请单主键 + * @return 结果 + */ + @Transactional + @Override + public int deleteMesPurchaseApplyByPurchaseApplyIds(Long[] purchaseApplyIds) { + mesPurchaseApplyMapper.deleteMesPurchaseApplyDetailByPurchaseApplyIds(purchaseApplyIds); + return mesPurchaseApplyMapper.deleteMesPurchaseApplyByPurchaseApplyIds(purchaseApplyIds); + } + + /** + * 删除采购申请单信息 + * + * @param purchaseApplyId 采购申请单主键 + * @return 结果 + */ + @Transactional + @Override + public int deleteMesPurchaseApplyByPurchaseApplyId(Long purchaseApplyId) { + mesPurchaseApplyMapper.deleteMesPurchaseApplyDetailByPurchaseApplyId(purchaseApplyId); + return mesPurchaseApplyMapper.deleteMesPurchaseApplyByPurchaseApplyId(purchaseApplyId); + } + + /** + * 新增采购申请单详细信息;从ERP同步过来的信息,需要与物料信息关联,需要确认接口同步过来的信息内容信息 + * + * @param mesPurchaseApply 采购申请单对象 + */ + public void insertMesPurchaseApplyDetail(MesPurchaseApply mesPurchaseApply) { + List mesPurchaseApplyDetailList = mesPurchaseApply.getMesPurchaseApplyDetailList(); + Long purchaseApplyId = mesPurchaseApply.getPurchaseApplyId(); + if (StringUtils.isNotNull(mesPurchaseApplyDetailList)) { + List list = new ArrayList(); + for (MesPurchaseApplyDetail mesPurchaseApplyDetail : mesPurchaseApplyDetailList) { + mesPurchaseApplyDetail.setPurchaseApplyId(purchaseApplyId); + list.add(mesPurchaseApplyDetail); + } + if (list.size() > 0) { + mesPurchaseApplyMapper.batchMesPurchaseApplyDetail(list); + } + } + } + + + /** + * 导入采购申请单 + * + * @param purchaseRequisitionTemplateList + * @return + */ + @Override + @Transactional(rollbackFor = ServiceException.class) + public Long importPurchaseApply(List purchaseRequisitionTemplateList) { + if (StringUtils.isNull(purchaseRequisitionTemplateList) || purchaseRequisitionTemplateList.size() == 0) { + throw new ServiceException("导入采购申请单数据不能为空!"); + } + int successNum = 0; + int failureNum = 0; + StringBuilder successMsg = new StringBuilder(); + StringBuilder failureMsg = new StringBuilder(); + + Date currentDate = new Date(); + String userName = SecurityUtils.getUsername(); + MesPurchaseApply mesPurchaseApply = new MesPurchaseApply(); + mesPurchaseApply.setTaskCode(Seq.getId(Seq.mesPurchaseApplySeqType, Seq.mesPurchaseApplyCode)); + mesPurchaseApply.setSyncStatus(MesConstants.MES_PURCHASE_APPALY_SYNC_NO); + mesPurchaseApply.setCreateTime(currentDate); + mesPurchaseApply.setCreateBy(userName); + mesPurchaseApplyMapper.insertMesPurchaseApply(mesPurchaseApply); + + List toInsertedPurchaseApplyDetails = new ArrayList<>(); + + 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 = mesBaseMaterialInfoMapper.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) { + MesBaseUnitInfo baseUnitInfo = mesBaseUnitInfoMapper.selectMesBaseUnitInfoByErpId(findMaterialInfo.getMaterialUnitId()); + MesBaseUnitInfo priceUnitIdUnitInfo = mesBaseUnitInfoMapper.selectMesBaseUnitInfoByErpId(findMaterialInfo.getPurchasePriceUnitId()); + + + MesPurchaseApplyDetail mesPurchaseApplyDetail = new MesPurchaseApplyDetail(); + mesPurchaseApplyDetail.setTondBase(purchaseRequisitionTemplate.getTondBase()); + mesPurchaseApplyDetail.setErpMaterialId(findMaterialInfo.getErpId()); + mesPurchaseApplyDetail.setMaterialId(findMaterialInfo.getMaterialId()); + mesPurchaseApplyDetail.setMaterialCode(findMaterialInfo.getMaterialCode()); + mesPurchaseApplyDetail.setMaterialName(materialName); + mesPurchaseApplyDetail.setMaterialSpec(findMaterialInfo.getMaterialSpec()); + mesPurchaseApplyDetail.setUnitName(purchaseRequisitionTemplate.getUnit()); + mesPurchaseApplyDetail.setUnitCode(baseUnitInfo.getUnitCode()); + mesPurchaseApplyDetail.setPriceUnitCode(priceUnitIdUnitInfo.getUnitCode()); + mesPurchaseApplyDetail.setReqQty(purchaseRequisitionTemplate.getAmount()); + mesPurchaseApplyDetail.setProduceSupplier(purchaseRequisitionTemplate.getManufacturer()); + mesPurchaseApplyDetail.setTaxPrice(purchaseRequisitionTemplate.getTaxUnitPrice()); + mesPurchaseApplyDetail.setTaxTotalPrice(purchaseRequisitionTemplate.getTaxTotalPrice()); + mesPurchaseApplyDetail.setOriReqQty(purchaseRequisitionTemplate.getAmount()); + mesPurchaseApplyDetail.setPurchaseApplyId(mesPurchaseApply.getPurchaseApplyId()); + toInsertedPurchaseApplyDetails.add(mesPurchaseApplyDetail); + + successNum++; + } 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).append(e.getMessage()); +// log.error(msg, e); + } + } + + + if (failureNum > 0) { + failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:"); + throw new ServiceException(failureMsg.toString()); + } + + successMsg.append("
").append("采购申请单全部信息导入成功"); + mesPurchaseApplyMapper.batchMesPurchaseApplyDetail(toInsertedPurchaseApplyDetails); + return mesPurchaseApply.getPurchaseApplyId(); + } + + + /** + * 同步采购申请单 + * + * @param mesPurchaseApply 采购申请单 + * @return 结果 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public int syncMesPurchaseApply(MesPurchaseApply mesPurchaseApply) { + Date currentDate = new Date(); + MesPurchaseApply dbMesPurchaseApply = mesPurchaseApplyMapper.selectOnlyMesPurchaseApplyByPurchaseApplyId(mesPurchaseApply.getPurchaseApplyId()); + if(dbMesPurchaseApply.getSyncStatus().equals(MesConstants.MES_PURCHASE_APPALY_SYNC_YES)){ + throw new ServiceException("此采购申请单已经同步"); + } + + mesPurchaseApply.setUpdateTime(currentDate); + mesPurchaseApply.setSyncTime(currentDate); + mesPurchaseApply.setSyncStatus(MesConstants.MES_PURCHASE_APPALY_SYNC_YES); + mesPurchaseApply.setUpdateBy(SecurityUtils.getUsername()); + mesPurchaseApplyMapper.updateMesPurchaseApply(mesPurchaseApply); + + JSONArray jsonArray = new JSONArray(); + + List mesPurchaseApplyDetailList = mesPurchaseApply.getMesPurchaseApplyDetailList(); + for (MesPurchaseApplyDetail mesPurchaseApplyDetail : mesPurchaseApplyDetailList) { + JSONObject data = new JSONObject(); + data.put("FMaterialId", mesPurchaseApplyDetail.getMaterialCode()); + data.put("FMaterialDesc", mesPurchaseApplyDetail.getMaterialSpec()); + data.put("FUnitId", mesPurchaseApplyDetail.getUnitCode()); + data.put("FPriceUnitId", mesPurchaseApplyDetail.getPriceUnitCode()); + data.put("FReqQty", mesPurchaseApplyDetail.getReqQty()); + data.put("FTAXPRICE", mesPurchaseApplyDetail.getTaxPrice()); + jsonArray.add(data); + + if (mesPurchaseApplyDetail.getReqQty().compareTo(mesPurchaseApplyDetail.getOriReqQty()) != 0) { + mesPurchaseApplyDetailMapper.updateMesPurchaseApplyDetail(mesPurchaseApplyDetail); + } + + } + + String params = jsonArray.toJSONString(); + R ajaxResult = remoteJindieService.singleSavePurchaseRequisition(params, SecurityConstants.INNER); + ajaxResult.getCode(); + if (ajaxResult.getCode() != Constants.SUCCESS) { + throw new ServiceException(ajaxResult.getMsg()); + } + + return mesPurchaseApplyMapper.updateMesPurchaseApply(mesPurchaseApply); + } + +} diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesPurchaseApplyDetailMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesPurchaseApplyDetailMapper.xml new file mode 100644 index 00000000..93a669cb --- /dev/null +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesPurchaseApplyDetailMapper.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + select purchase_apply_detail_id, purchase_apply_id, erp_material_id, material_id, material_code, material_name, material_spec, unit_code, price_unit_code, req_qty, produce_supplier, tax_price, tax_total_price, ori_req_qty from mes_purchase_apply_detail + + + + + + + + insert into mes_purchase_apply_detail + + purchase_apply_id, + erp_material_id, + material_id, + material_code, + material_name, + material_spec, + unit_code, + price_unit_code, + req_qty, + produce_supplier, + tax_price, + tax_total_price, + ori_req_qty, + + + #{purchaseApplyId}, + #{erpMaterialId}, + #{materialId}, + #{materialCode}, + #{materialName}, + #{materialSpec}, + #{unitCode}, + #{priceUnitCode}, + #{reqQty}, + #{produceSupplier}, + #{taxPrice}, + #{taxTotalPrice}, + #{oriReqQty}, + + + + + update mes_purchase_apply_detail + + purchase_apply_id = #{purchaseApplyId}, + erp_material_id = #{erpMaterialId}, + material_id = #{materialId}, + material_code = #{materialCode}, + material_name = #{materialName}, + material_spec = #{materialSpec}, + unit_code = #{unitCode}, + price_unit_code = #{priceUnitCode}, + req_qty = #{reqQty}, + produce_supplier = #{produceSupplier}, + tax_price = #{taxPrice}, + tax_total_price = #{taxTotalPrice}, + ori_req_qty = #{oriReqQty}, + + where purchase_apply_detail_id = #{purchaseApplyDetailId} + + + + delete from mes_purchase_apply_detail where purchase_apply_detail_id = #{purchaseApplyDetailId} + + + + delete from mes_purchase_apply_detail where purchase_apply_detail_id in + + #{purchaseApplyDetailId} + + + \ No newline at end of file diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesPurchaseApplyMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesPurchaseApplyMapper.xml new file mode 100644 index 00000000..55552b67 --- /dev/null +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesPurchaseApplyMapper.xml @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select purchase_apply_id, task_code, tond_base, sync_status, sync_time, remark, create_by, create_time, update_by, update_time from mes_purchase_apply + + + + + + + + insert into mes_purchase_apply + + task_code, + tond_base, + sync_status, + sync_time, + remark, + create_by, + create_time, + update_by, + update_time, + + + #{taskCode}, + #{tondBase}, + #{syncStatus}, + #{syncTime}, + #{remark}, + #{createBy}, + #{createTime}, + #{updateBy}, + #{updateTime}, + + + + + update mes_purchase_apply + + task_code = #{taskCode}, + tond_base = #{tondBase}, + sync_status = #{syncStatus}, + sync_time = #{syncTime}, + remark = #{remark}, + create_by = #{createBy}, + create_time = #{createTime}, + update_by = #{updateBy}, + update_time = #{updateTime}, + + where purchase_apply_id = #{purchaseApplyId} + + + + delete from mes_purchase_apply where purchase_apply_id = #{purchaseApplyId} + + + + delete from mes_purchase_apply where purchase_apply_id in + + #{purchaseApplyId} + + + + + delete from mes_purchase_apply_detail where purchase_apply_id in + + #{purchaseApplyId} + + + + + delete from mes_purchase_apply_detail where purchase_apply_id = #{purchaseApplyId} + + + + insert into mes_purchase_apply_detail( purchase_apply_detail_id, purchase_apply_id,tond_base, erp_material_id, material_id, material_code, material_name, material_spec, unit_name,unit_code, price_unit_code, req_qty, produce_supplier, tax_price, tax_total_price, ori_req_qty) values + + ( #{item.purchaseApplyDetailId}, #{item.purchaseApplyId},#{item.tondBase}, #{item.erpMaterialId}, #{item.materialId}, #{item.materialCode}, #{item.materialName}, #{item.materialSpec}, #{item.unitName}, #{item.unitCode}, #{item.priceUnitCode}, #{item.reqQty}, #{item.produceSupplier}, #{item.taxPrice}, #{item.taxTotalPrice}, #{item.oriReqQty}) + + + + + + + + + \ No newline at end of file diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesSaleOrderMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesSaleOrderMapper.xml index 5c7cf405..eeed4a60 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesSaleOrderMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesSaleOrderMapper.xml @@ -266,8 +266,9 @@ and replace(mbmi.material_spec,' ','') like concat('%', #{materialSpec}, '%') and mso.is_release = #{isRelease} + and mso.sale_order_id = #{saleOrderId} and mso.sale_order_classfication = #{saleOrderClassfication} - and exists (select 1 from mes_sale_order_relate msor where mso.sale_order_id = msor.relate_sale_order_id) + and exists (select 1 from mes_sale_order_relate msor where mso.sale_order_id = msor.relate_sale_order_id and msor.sale_order_id=#{virtualSaleOrderId}) and not exists (select 1 from mes_sale_order_relate msor where mso.sale_order_id = msor.relate_sale_order_id) diff --git a/hw-ui/src/api/mes/purchaseApply.js b/hw-ui/src/api/mes/purchaseApply.js new file mode 100644 index 00000000..b5cd5086 --- /dev/null +++ b/hw-ui/src/api/mes/purchaseApply.js @@ -0,0 +1,56 @@ +import request from '@/utils/request' + +// 查询采购申请单列表 +export function listPurchaseApply(query) { + return request({ + url: '/mes/purchaseApply/list', + method: 'get', + params: query + }) +} + +// 查询采购申请单详细 +export function getPurchaseApply(purchaseApplyId) { + return request({ + url: '/mes/purchaseApply/' + purchaseApplyId, + method: 'get' + }) +} + +// 新增采购申请单 +export function addPurchaseApply(data) { + return request({ + url: '/mes/purchaseApply', + method: 'post', + data: data + }) +} + +// 修改采购申请单 +export function updatePurchaseApply(data) { + return request({ + url: '/mes/purchaseApply', + method: 'put', + data: data + }) +} + +// 删除采购申请单 +export function delPurchaseApply(purchaseApplyId) { + return request({ + url: '/mes/purchaseApply/' + purchaseApplyId, + method: 'delete' + }) +} + + + + +// 同步采购申请单 +export function syncPurchaseApply(data) { + return request({ + url: '/mes/purchaseApply/syncPurchaseApply', + method: 'post', + data: data + }) +} diff --git a/hw-ui/src/views/mes/barcode/index.vue b/hw-ui/src/views/mes/barcode/index.vue index 668cf6af..960f10e3 100644 --- a/hw-ui/src/views/mes/barcode/index.vue +++ b/hw-ui/src/views/mes/barcode/index.vue @@ -230,7 +230,8 @@ type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" - v-if="scope.row.printFlag !==PRINT_FLAG.YES &&scope.row.barcodeType === BARCODE_TYPE.RAW" + v-if="scope.row.printFlag !==PRINT_FLAG.YES && scope.row.barcodeType === BARCODE_TYPE.RAW && + scope.row.purchaseOrderId && scope.row.purchaseOrderId!==null && scope.row.purchaseOrderId > 0" v-hasPermi="['mes:barcode:edit']" >编辑 @@ -278,8 +279,9 @@ - - + + @@ -323,7 +325,7 @@ - + @@ -392,7 +394,7 @@ @@ -670,10 +672,10 @@