MES:
采购申请单导入和同步ERP功能按新要求修改完成
原材料条码编辑完善
生产管理完善
master
xs 5 months ago
parent 5e7340b2db
commit 73a04deb02

@ -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";//未同步
}

@ -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);
}

@ -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<MesPurchaseRequisitionTemplate> util = new ExcelUtil<>(MesPurchaseRequisitionTemplate.class);
List<MesPurchaseRequisitionTemplate> 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);
}
/**

@ -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<MesPurchaseApply> 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<MesPurchaseApply> list = mesPurchaseApplyService.selectMesPurchaseApplyList(mesPurchaseApply);
ExcelUtil<MesPurchaseApply> util = new ExcelUtil<MesPurchaseApply>(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));
}
}

@ -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<MesPurchaseApplyDetail> 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<MesPurchaseApplyDetail> getMesPurchaseApplyDetailList()
{
return mesPurchaseApplyDetailList;
}
public void setMesPurchaseApplyDetailList(List<MesPurchaseApplyDetail> 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();
}
}

@ -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();
}
}

@ -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{" +

@ -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)

@ -0,0 +1,61 @@
package com.hw.mes.mapper;
import java.util.List;
import com.hw.mes.domain.MesPurchaseApplyDetail;
/**
* ;ERPMapper
*
* @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<MesPurchaseApplyDetail> 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);
}

@ -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<MesPurchaseApply> 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<MesPurchaseApplyDetail> mesPurchaseApplyDetailList);
/**
* ;ERP
*
* @param purchaseApplyId ID
* @return
*/
public int deleteMesPurchaseApplyDetailByPurchaseApplyId(Long purchaseApplyId);
/**
*
*
* @param purchaseApplyId
* @return
*/
public MesPurchaseApply selectOnlyMesPurchaseApplyByPurchaseApplyId(Long purchaseApplyId);
}

@ -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<MesPurchaseApply> 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<MesPurchaseRequisitionTemplate> purchaseRequisitionTemplateList);
/**
*
*
* @param mesPurchaseApply
* @return
*/
public int syncMesPurchaseApply(MesPurchaseApply mesPurchaseApply);
}

@ -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<MesMaterialBom> 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<MesMaterialBom> 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("所选销售订单为合并的虚拟订单,柜体渠道需要选择外部采购");
}
}
}
/**
*
*

@ -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<MesPurchaseApply> 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<MesPurchaseApplyDetail> mesPurchaseApplyDetailList = mesPurchaseApply.getMesPurchaseApplyDetailList();
Long purchaseApplyId = mesPurchaseApply.getPurchaseApplyId();
if (StringUtils.isNotNull(mesPurchaseApplyDetailList)) {
List<MesPurchaseApplyDetail> list = new ArrayList<MesPurchaseApplyDetail>();
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<MesPurchaseRequisitionTemplate> 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<MesPurchaseApplyDetail> 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<MesBaseMaterialInfo> 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("<br/>").append(failureNum).append(" 查出多条物料记录 导入失败");
} else {
failureNum++;
failureMsg.append("<br/>").append(failureNum).append(" 未找到物料记录 导入失败");
}
} catch (Exception e) {
failureNum++;
String msg = "<br/>" + 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("<br/>").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<MesPurchaseApplyDetail> 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> ajaxResult = remoteJindieService.singleSavePurchaseRequisition(params, SecurityConstants.INNER);
ajaxResult.getCode();
if (ajaxResult.getCode() != Constants.SUCCESS) {
throw new ServiceException(ajaxResult.getMsg());
}
return mesPurchaseApplyMapper.updateMesPurchaseApply(mesPurchaseApply);
}
}

@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hw.mes.mapper.MesPurchaseApplyDetailMapper">
<resultMap type="MesPurchaseApplyDetail" id="MesPurchaseApplyDetailResult">
<result property="purchaseApplyDetailId" column="purchase_apply_detail_id" />
<result property="purchaseApplyId" column="purchase_apply_id" />
<result property="erpMaterialId" column="erp_material_id" />
<result property="materialId" column="material_id" />
<result property="materialCode" column="material_code" />
<result property="materialName" column="material_name" />
<result property="materialSpec" column="material_spec" />
<result property="unitCode" column="unit_code" />
<result property="priceUnitCode" column="price_unit_code" />
<result property="reqQty" column="req_qty" />
<result property="produceSupplier" column="produce_supplier" />
<result property="taxPrice" column="tax_price" />
<result property="taxTotalPrice" column="tax_total_price" />
<result property="oriReqQty" column="ori_req_qty" />
</resultMap>
<sql id="selectMesPurchaseApplyDetailVo">
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
</sql>
<select id="selectMesPurchaseApplyDetailList" parameterType="MesPurchaseApplyDetail" resultMap="MesPurchaseApplyDetailResult">
<include refid="selectMesPurchaseApplyDetailVo"/>
<where>
<if test="purchaseApplyId != null "> and purchase_apply_id = #{purchaseApplyId}</if>
<if test="erpMaterialId != null "> and erp_material_id = #{erpMaterialId}</if>
<if test="materialId != null "> and material_id = #{materialId}</if>
<if test="materialCode != null and materialCode != ''"> and material_code = #{materialCode}</if>
<if test="materialName != null and materialName != ''"> and material_name like concat('%', #{materialName}, '%')</if>
<if test="materialSpec != null and materialSpec != ''"> and material_spec = #{materialSpec}</if>
<if test="unitCode != null and unitCode != ''"> and unit_code = #{unitCode}</if>
<if test="priceUnitCode != null and priceUnitCode != ''"> and price_unit_code = #{priceUnitCode}</if>
<if test="reqQty != null "> and req_qty = #{reqQty}</if>
<if test="produceSupplier != null and produceSupplier != ''"> and produce_supplier = #{produceSupplier}</if>
<if test="taxPrice != null "> and tax_price = #{taxPrice}</if>
<if test="taxTotalPrice != null "> and tax_total_price = #{taxTotalPrice}</if>
<if test="oriReqQty != null "> and ori_req_qty = #{oriReqQty}</if>
</where>
</select>
<select id="selectMesPurchaseApplyDetailByPurchaseApplyDetailId" parameterType="Long" resultMap="MesPurchaseApplyDetailResult">
<include refid="selectMesPurchaseApplyDetailVo"/>
where purchase_apply_detail_id = #{purchaseApplyDetailId}
</select>
<insert id="insertMesPurchaseApplyDetail" parameterType="MesPurchaseApplyDetail" useGeneratedKeys="true" keyProperty="purchaseApplyDetailId">
insert into mes_purchase_apply_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="purchaseApplyId != null">purchase_apply_id,</if>
<if test="erpMaterialId != null">erp_material_id,</if>
<if test="materialId != null">material_id,</if>
<if test="materialCode != null and materialCode != ''">material_code,</if>
<if test="materialName != null">material_name,</if>
<if test="materialSpec != null and materialSpec != ''">material_spec,</if>
<if test="unitCode != null and unitCode != ''">unit_code,</if>
<if test="priceUnitCode != null">price_unit_code,</if>
<if test="reqQty != null">req_qty,</if>
<if test="produceSupplier != null">produce_supplier,</if>
<if test="taxPrice != null">tax_price,</if>
<if test="taxTotalPrice != null">tax_total_price,</if>
<if test="oriReqQty != null">ori_req_qty,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="purchaseApplyId != null">#{purchaseApplyId},</if>
<if test="erpMaterialId != null">#{erpMaterialId},</if>
<if test="materialId != null">#{materialId},</if>
<if test="materialCode != null and materialCode != ''">#{materialCode},</if>
<if test="materialName != null">#{materialName},</if>
<if test="materialSpec != null and materialSpec != ''">#{materialSpec},</if>
<if test="unitCode != null and unitCode != ''">#{unitCode},</if>
<if test="priceUnitCode != null">#{priceUnitCode},</if>
<if test="reqQty != null">#{reqQty},</if>
<if test="produceSupplier != null">#{produceSupplier},</if>
<if test="taxPrice != null">#{taxPrice},</if>
<if test="taxTotalPrice != null">#{taxTotalPrice},</if>
<if test="oriReqQty != null">#{oriReqQty},</if>
</trim>
</insert>
<update id="updateMesPurchaseApplyDetail" parameterType="MesPurchaseApplyDetail">
update mes_purchase_apply_detail
<trim prefix="SET" suffixOverrides=",">
<if test="purchaseApplyId != null">purchase_apply_id = #{purchaseApplyId},</if>
<if test="erpMaterialId != null">erp_material_id = #{erpMaterialId},</if>
<if test="materialId != null">material_id = #{materialId},</if>
<if test="materialCode != null and materialCode != ''">material_code = #{materialCode},</if>
<if test="materialName != null">material_name = #{materialName},</if>
<if test="materialSpec != null and materialSpec != ''">material_spec = #{materialSpec},</if>
<if test="unitCode != null and unitCode != ''">unit_code = #{unitCode},</if>
<if test="priceUnitCode != null">price_unit_code = #{priceUnitCode},</if>
<if test="reqQty != null">req_qty = #{reqQty},</if>
<if test="produceSupplier != null">produce_supplier = #{produceSupplier},</if>
<if test="taxPrice != null">tax_price = #{taxPrice},</if>
<if test="taxTotalPrice != null">tax_total_price = #{taxTotalPrice},</if>
<if test="oriReqQty != null">ori_req_qty = #{oriReqQty},</if>
</trim>
where purchase_apply_detail_id = #{purchaseApplyDetailId}
</update>
<delete id="deleteMesPurchaseApplyDetailByPurchaseApplyDetailId" parameterType="Long">
delete from mes_purchase_apply_detail where purchase_apply_detail_id = #{purchaseApplyDetailId}
</delete>
<delete id="deleteMesPurchaseApplyDetailByPurchaseApplyDetailIds" parameterType="String">
delete from mes_purchase_apply_detail where purchase_apply_detail_id in
<foreach item="purchaseApplyDetailId" collection="array" open="(" separator="," close=")">
#{purchaseApplyDetailId}
</foreach>
</delete>
</mapper>

@ -0,0 +1,145 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hw.mes.mapper.MesPurchaseApplyMapper">
<resultMap type="MesPurchaseApply" id="MesPurchaseApplyResult">
<result property="purchaseApplyId" column="purchase_apply_id" />
<result property="taskCode" column="task_code" />
<result property="tondBase" column="tond_base" />
<result property="syncStatus" column="sync_status" />
<result property="syncTime" column="sync_time" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<resultMap id="MesPurchaseApplyMesPurchaseApplyDetailResult" type="MesPurchaseApply" extends="MesPurchaseApplyResult">
<collection property="mesPurchaseApplyDetailList" notNullColumn="sub_purchase_apply_detail_id" javaType="java.util.List" resultMap="MesPurchaseApplyDetailResult" />
</resultMap>
<resultMap type="MesPurchaseApplyDetail" id="MesPurchaseApplyDetailResult">
<result property="purchaseApplyDetailId" column="sub_purchase_apply_detail_id" />
<result property="purchaseApplyId" column="sub_purchase_apply_id" />
<result property="erpMaterialId" column="sub_erp_material_id" />
<result property="materialId" column="sub_material_id" />
<result property="materialCode" column="sub_material_code" />
<result property="materialName" column="sub_material_name" />
<result property="materialSpec" column="sub_material_spec" />
<result property="unitCode" column="sub_unit_code" />
<result property="unitName" column="sub_unit_name" />
<result property="priceUnitCode" column="sub_price_unit_code" />
<result property="reqQty" column="sub_req_qty" />
<result property="produceSupplier" column="sub_produce_supplier" />
<result property="taxPrice" column="sub_tax_price" />
<result property="taxTotalPrice" column="sub_tax_total_price" />
<result property="oriReqQty" column="sub_ori_req_qty" />
<result property="tondBase" column="sub_tond_base" />
</resultMap>
<sql id="selectMesPurchaseApplyVo">
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
</sql>
<select id="selectMesPurchaseApplyList" parameterType="MesPurchaseApply" resultMap="MesPurchaseApplyResult">
<include refid="selectMesPurchaseApplyVo"/>
<where>
<if test="taskCode != null and taskCode != ''"> and task_code like concat('%', #{taskCode},'%')</if>
<if test="tondBase != null and tondBase != ''"> and tond_base = #{tondBase}</if>
<if test="syncStatus != null and syncStatus != ''"> and sync_status = #{syncStatus}</if>
<if test="syncTime != null "> and sync_time = #{syncTime}</if>
</where>
</select>
<select id="selectMesPurchaseApplyByPurchaseApplyId" parameterType="Long" resultMap="MesPurchaseApplyMesPurchaseApplyDetailResult">
select a.purchase_apply_id, a.task_code, a.tond_base, a.sync_status, a.sync_time, a.remark, a.create_by, a.create_time, a.update_by, a.update_time,
b.purchase_apply_detail_id as sub_purchase_apply_detail_id, b.purchase_apply_id as sub_purchase_apply_id, b.erp_material_id as sub_erp_material_id, b.material_id as sub_material_id, b.material_code as sub_material_code, b.material_name as sub_material_name, b.material_spec as sub_material_spec, b.unit_code as sub_unit_code,b.unit_name as sub_unit_name, b.price_unit_code as sub_price_unit_code, b.req_qty as sub_req_qty, b.produce_supplier as sub_produce_supplier, b.tax_price as sub_tax_price, b.tax_total_price as sub_tax_total_price, b.ori_req_qty as sub_ori_req_qty,b.tond_base as sub_tond_base
from mes_purchase_apply a
left join mes_purchase_apply_detail b on b.purchase_apply_id = a.purchase_apply_id
where a.purchase_apply_id = #{purchaseApplyId}
</select>
<insert id="insertMesPurchaseApply" parameterType="MesPurchaseApply" useGeneratedKeys="true" keyProperty="purchaseApplyId">
insert into mes_purchase_apply
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="taskCode != null and taskCode != ''">task_code,</if>
<if test="tondBase != null">tond_base,</if>
<if test="syncStatus != null and syncStatus != ''">sync_status,</if>
<if test="syncTime != null">sync_time,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="taskCode != null and taskCode != ''">#{taskCode},</if>
<if test="tondBase != null">#{tondBase},</if>
<if test="syncStatus != null and syncStatus != ''">#{syncStatus},</if>
<if test="syncTime != null">#{syncTime},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateMesPurchaseApply" parameterType="MesPurchaseApply">
update mes_purchase_apply
<trim prefix="SET" suffixOverrides=",">
<if test="taskCode != null and taskCode != ''">task_code = #{taskCode},</if>
<if test="tondBase != null">tond_base = #{tondBase},</if>
<if test="syncStatus != null and syncStatus != ''">sync_status = #{syncStatus},</if>
<if test="syncTime != null">sync_time = #{syncTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where purchase_apply_id = #{purchaseApplyId}
</update>
<delete id="deleteMesPurchaseApplyByPurchaseApplyId" parameterType="Long">
delete from mes_purchase_apply where purchase_apply_id = #{purchaseApplyId}
</delete>
<delete id="deleteMesPurchaseApplyByPurchaseApplyIds" parameterType="String">
delete from mes_purchase_apply where purchase_apply_id in
<foreach item="purchaseApplyId" collection="array" open="(" separator="," close=")">
#{purchaseApplyId}
</foreach>
</delete>
<delete id="deleteMesPurchaseApplyDetailByPurchaseApplyIds" parameterType="String">
delete from mes_purchase_apply_detail where purchase_apply_id in
<foreach item="purchaseApplyId" collection="array" open="(" separator="," close=")">
#{purchaseApplyId}
</foreach>
</delete>
<delete id="deleteMesPurchaseApplyDetailByPurchaseApplyId" parameterType="Long">
delete from mes_purchase_apply_detail where purchase_apply_id = #{purchaseApplyId}
</delete>
<insert id="batchMesPurchaseApplyDetail">
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
<foreach item="item" index="index" collection="list" separator=",">
( #{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})
</foreach>
</insert>
<select id="selectOnlyMesPurchaseApplyByPurchaseApplyId" parameterType="Long" resultMap="MesPurchaseApplyResult">
select a.purchase_apply_id, a.task_code, a.tond_base, a.sync_status, a.sync_time
from mes_purchase_apply a
where a.purchase_apply_id = #{purchaseApplyId}
</select>
</mapper>

@ -266,8 +266,9 @@
<if test="materialSpec != null and materialSpec != '' ">and replace(mbmi.material_spec,' ','') like concat('%', #{materialSpec},
'%')</if>
<if test="isRelease != null and isRelease != ''">and mso.is_release = #{isRelease}</if>
<if test="saleOrderId != null">and mso.sale_order_id = #{saleOrderId}</if>
<if test="saleOrderClassfication != null and saleOrderClassfication != ''">and mso.sale_order_classfication = #{saleOrderClassfication}</if>
<if test="relateFlag != null and relateFlag != ''">and exists (select 1 from mes_sale_order_relate msor where mso.sale_order_id = msor.relate_sale_order_id)</if>
<if test="relateFlag != null and relateFlag != ''">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})</if>
<if test="selectFlag != null and selectFlag != ''">and not exists (select 1 from mes_sale_order_relate msor where mso.sale_order_id = msor.relate_sale_order_id)</if>
</where>

@ -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
})
}

@ -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']"
>编辑
</el-button>
@ -278,8 +279,9 @@
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="采购订单号" prop="poNo">
<el-input v-model="form.poNo" placeholder="请点击右侧检索采购订单" readonly>
<el-button slot="append" icon="el-icon-search" @click="handlePurchaseOrderAdd"></el-button>
<el-input v-model="form.poNo" placeholder="请点击右侧检索采购订单" disabled>
<el-button slot="append" icon="el-icon-search" @click="handlePurchaseOrderAdd"
v-if="!form.barcodeId || form.barcodeId===''"></el-button>
</el-input>
</el-form-item>
@ -323,7 +325,7 @@
<el-input v-model="form.amount" placeholder="请在物料信息中维护"/>
</el-form-item>
<el-form-item prop="barcodeAmount">
<el-form-item prop="barcodeAmount" v-if="!form.barcodeId || form.barcodeId===''">
<span slot="label">
<el-tooltip content="需要打印条码的数量如果需要贴10个物料条码则需要生成10个" placement="top">
<i class="el-icon-question"></i>
@ -392,7 +394,7 @@
<el-dialog title="选择采购订单信息" :visible.sync="purchaseOrderOpen" append-to-body>
<select-orderBind ref="purchaseOrderRef" v-if="purchaseOrderOpen" :defineData="barcodeData"></select-orderBind>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitPurchaseOrderForm"> </el-button>
<el-button type="primary" @click="submitPurchaseOrderForm"> </el-button>
<el-button @click="purchaseOrderOpen = false"> </el-button>
</div>
</el-dialog>
@ -670,10 +672,10 @@
<script>
import {
listBarcode, getBarcode, delBarcode, addBarcode, reprintBarcodes,
listBarcode, getBarcode, delBarcode, addBarcode, updateBarcode, reprintBarcodes,
printBarcodes, getMaterialInfoByErpId, selectProductBarcodeInfoByBarcodeInfo,
addInternalBarcode, regenerateBarcode, checkRawStock, addNoPurchaseBarcode, addRegularBarcode,
mergeAddBarcode,mergeUpdateBarcode
mergeAddBarcode, mergeUpdateBarcode
} from "@/api/mes/barcode";
import {checkWarehouseMaterials} from "@/api/wms/wmswarehouse";
@ -1332,10 +1334,15 @@ export default {
});
} else {
if (row.purchaseOrderId === 0) {
this.resetNoPurchase();
} else {
if (row.purchaseOrderId && row.purchaseOrderId!=null && row.purchaseOrderId > 0) {//
this.reset();
getBarcode(barcodeId).then(response => {
this.form = response.data
this.open = true;
this.title = "修改原材料条码信息";
});
} else {//
}
}
@ -1347,13 +1354,23 @@ export default {
this.$refs["form"].validate(valid => {
if (valid) {
this.submitLoading = true;
addBarcode(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(e => {
this.submitLoading = false;
});
if (this.form.barcodeId && this.form.barcodeId !== '') {
updateBarcode(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
}).finally(e => {
this.submitLoading = false;
});
} else {
addBarcode(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
}).finally(e => {
this.submitLoading = false;
});
}
}
});
@ -1774,7 +1791,7 @@ export default {
this.$modal.msgError("请选择至少2条采购信息");
return;
}
if(this.materialRelateForm.barcodeId && this.materialRelateForm.barcodeId!=''){
if (this.materialRelateForm.barcodeId && this.materialRelateForm.barcodeId != '') {
mergeUpdateBarcode(this.materialRelateForm).then(response => {
this.$modal.msgSuccess("修改成功");
this.materialRelateOpen = false;
@ -1782,7 +1799,7 @@ export default {
}).finally(e => {
this.submitLoading = false;
});
}else{
} else {
mergeAddBarcode(this.materialRelateForm).then(response => {
this.$modal.msgSuccess("新增成功");
this.materialRelateOpen = false;

@ -112,16 +112,20 @@
</template>
</el-table-column>
<el-table-column label="销售订单编号" align="center" prop="saleorderCode" v-if="columns[3].visible">
<el-table-column label="销售订单编号" align="center" prop="saleorderCode" >
<template slot-scope="scope">
<el-button
type="text"
class="wrap-text-button"
@mouseover="hover = true"
@mouseleave="hover = false"
@click="getRelateList(scope.row)">
@click="getRelateList(scope.row)"
v-if="scope.row.saleOrderClassfication!=='1'"
>
{{ scope.row.saleorderCode }}
</el-button>
<p v-if="scope.row.saleOrderClassfication==='1'">{{ scope.row.saleorderCode }}</p>
</template>
</el-table-column>
<el-table-column label="单据状态" align="center" prop="documentStatus" v-if="columns[5].visible" >
@ -136,8 +140,8 @@
<el-table-column label="物料名称" align="center" prop="materialName" v-if="columns[10].visible"/>
<el-table-column label="物料规格" align="center" prop="materialSpec"/>
<el-table-column label="订单数量" align="center" prop="orderAmount" v-if="columns[12].visible"/>
<el-table-column label="完成数量" align="center" prop="completeAmount" v-if="columns[13].visible"/>
<el-table-column label="已发布数量" align="center" prop="releaseQty" v-if="columns[14].visible"/>
<el-table-column label="完成数量" align="center" prop="completeAmount" v-if="columns[13].visible"/>
<el-table-column label="是否已下达计划" align="center" prop="isRelease" v-if="columns[15].visible" >
<template slot-scope="scope">
<dict-tag :options="dict.type.is_release" :value="scope.row.isRelease"/>
@ -409,8 +413,8 @@ export default {
{ key: 10, label: `物料名称`, visible: true },
{ key: 11, label: `物料组`, visible: false },
{ key: 12, label: `订单计划数量`, visible: true },
{ key: 13, label: `完成数量`, visible: false },
{ key: 14, label: `已发布数量`, visible: false },
{ key: 13, label: `完成数量`, visible: true },
{ key: 14, label: `已发布数量`, visible: true },
{ key: 15, label: `是否已下达计划`, visible: false },
{ key: 16, label: `审核日期`, visible: false },
{ key: 17, label: `ERP最后修改日期`, visible: false },
@ -555,12 +559,13 @@ export default {
},
/** 查询销售订单信息列表 */
getRelateList() {
getRelateList(row) {
this.relateOpen = true;
this.relateTitle = "关联销售订单信息";
this.relateLoading = true;
this.relateQueryParams.selectFlag = null;
this.relateQueryParams.relateFlag = "1";
this.relateQueryParams.virtualSaleOrderId = row.saleOrderId;
getSaleOrders(this.relateQueryParams).then(response => {
this.relateSaleOrderList = response.rows;
this.relateTotal = response.total;

@ -333,7 +333,7 @@
<el-input v-model="form.orderCode" placeholder="请输入任务编号" :disabled="true"/>
</el-form-item>
<el-form-item label="销售类型" prop="saleType">
<el-radio-group v-model="form.saleType">
<el-radio-group v-model="form.saleType" @input="changeSaleType">
<el-radio
v-for="dict in dict.type.mes_sale_type"
:key="dict.value"
@ -372,6 +372,7 @@
:key="item.materialBomId"
:label="item.materialNameDesc"
:value="item.materialBomId"
:disabled = "item.activeFlag!=='1'"
></el-option>
</el-select>
</el-form-item>
@ -385,7 +386,7 @@
<el-form-item label="工艺路线" prop="dispatchId" v-if="form.saleType !== MES_SALE_TYPE.MES_SALE_TYPE_PACKING">
<el-select v-model="form.dispatchId" filterable placeholder="请选择工艺路线" clearable>
<el-select v-model="form.dispatchId" filterable placeholder="请选择工艺路线" :disabled="dispatchDisabled" clearable>
<el-option
v-for="item in routeList"
:key="item.routeId"
@ -461,7 +462,7 @@
<el-input v-model="form.orderCode" :disabled="true"/>
</el-form-item>
<el-form-item label="销售类型" prop="saleType">
<el-radio-group v-model="form.saleType">
<el-radio-group v-model="form.saleType" @input="changeSaleType">
<el-radio
v-for="dict in dict.type.mes_sale_type"
:key="dict.value"
@ -482,6 +483,7 @@
:key="item.materialBomId"
:label="item.materialNameDesc"
:value="item.materialBomId"
:disabled = "item.activeFlag!=='1'"
></el-option>
</el-select>
</el-form-item>
@ -492,7 +494,7 @@
</el-input>
</el-form-item>
<el-form-item label="工艺路线" prop="dispatchId" v-if="form.saleType !== MES_SALE_TYPE.MES_SALE_TYPE_PACKING">
<el-select v-model="form.dispatchId" filterable placeholder="请选择工艺路线" clearable>
<el-select v-model="form.dispatchId" filterable placeholder="请选择工艺路线" :disabled="dispatchDisabled" clearable>
<el-option
v-for="item in routeList"
:key="item.routeId"
@ -851,6 +853,7 @@ export default {
saleOrderDisabled: true,
materialDisabled: true,
productOrderDisabled: true,
dispatchDisabled:false,
//
MES_SALE_TYPE: {
MES_SALE_TYPE_EXTERNAL: '1',//
@ -989,6 +992,8 @@ export default {
// }
this.saleOrderOpen = true;
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.productOrderId)
@ -1015,7 +1020,7 @@ export default {
getMaterialVisionList(this.form.materialId).then(response => {
this.materialBomList = response.data
if (this.materialBomList.length !== 0) {
this.form.materialBomId = this.materialBomList[0].materialBomId
// this.form.materialBomId = this.materialBomList[0].materialBomId
} else {
this.form.materialBomId = null;
this.$modal.msgError("该物料未维护BOM信息");
@ -1066,27 +1071,36 @@ export default {
},
changeSaleType(value) {
this.form.saleOrderId = null;
this.form.saleorderCode = null;
this.form.saleorderLinenumber = null;
this.form.materialId = null;
this.form.materialCode = null;
this.form.materialName = null;
this.form.saleAmount = null;
this.form.planBeginTime = null;
this.form.planEndTime = null;
this.form.planDeliveryDate = null;
this.form.materialBomId = null;
this.form.dispatchId = null;
this.form.saleOrderFlag = '1';//
this.saleOrderDisabled = false;
if(value === this.MES_SALE_TYPE.MES_SALE_TYPE_INTERNAL){//
this.form.dispatchId = 3;//线
this.form.materialBomId = null;
this.dispatchDisabled = true;
}else if (value === this.MES_SALE_TYPE.MES_SALE_TYPE_EXTERNAL){//
this.form.dispatchId = null;
this.dispatchDisabled = false;
this.form.materialBomId = null;
}
// this.form.saleOrderId = null;
// this.form.saleorderCode = null;
// this.form.saleorderLinenumber = null;
// this.form.materialId = null;
// this.form.materialCode = null;
// this.form.materialName = null;
// this.form.saleAmount = null;
// this.form.planBeginTime = null;
// this.form.planEndTime = null;
// this.form.planDeliveryDate = null;
// this.form.materialBomId = null;
// this.form.dispatchId = null;
// this.form.saleOrderFlag = '1';//
// this.saleOrderDisabled = false;
},
getMaterialVisionList() {
getMaterialVisionList(this.form.materialId).then(response => {
this.materialBomList = response.data
if (this.materialBomList.length !== 0) {
this.form.materialBomId = this.materialBomList[0].materialBomId;
// this.form.materialBomId = this.materialBomList[0].materialBomId;
} else {
this.form.materialBomId = null;
this.$modal.msgError("该物料未维护BOM信息");
@ -1149,6 +1163,7 @@ export default {
})
if (response.data.saleOrderFlag === "0") {
this.noOrderOpen = true;
this.materialDisabled = false;
} else {
this.open = true;
}
@ -1251,6 +1266,7 @@ export default {
this.submitLoading = true;
//
if (this.form.saleOrderFlag === '1' && this.form.saleAmount < this.form.planAmount) {
this.submitLoading = false;
return this.$modal.msgError("计划数量不能大于销售数量!");
}
if (this.form.productOrderId != null) {

@ -0,0 +1,451 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px">
<el-form-item label="任务编号" prop="taskCode">
<el-input
v-model="queryParams.taskCode"
placeholder="请输入任务编号"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="同步ERP状态" prop="syncStatus">
<el-select v-model="queryParams.syncStatus" placeholder="请选择销售类型" clearable>
<el-option
v-for="dict in dict.type.mes_purchase_apply_sync_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-upload2"
size="mini"
@click="handleImport"
>采购申请单导入
</el-button>
</el-col>
</el-row>
<el-table v-loading="loading" :data="purchaseApplyList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="任务编号" align="center" prop="taskCode" />
<!--el-table-column label="京源项目" align="center" prop="tondBase" /-->
<el-table-column label="同步ERP状态" align="center" prop="syncStatus" >
<template slot-scope="scope">
<dict-tag :options="dict.type.mes_purchase_apply_sync_status" :value="scope.row.syncStatus"/>
</template>
</el-table-column>
<el-table-column label="同步ERP时间" align="center" prop="syncTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.syncTime, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-info"
@click="handleUpdate(scope.row)"
v-hasPermi="['mes:purchaseApply:edit']"
>查看</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 查看采购申请单对话框 -->
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
<el-form ref="form" :model="form" label-width="120px">
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-form-item label="任务编号" prop="taskCode">
<el-input v-model="form.taskCode" disabled style="width: 220px"/>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-form-item label="同步ERP状态" prop="syncStatus">
<el-select v-model="form.syncStatus" disabled>
<el-option
v-for="dict in dict.type.mes_purchase_apply_sync_status"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="1.5">
<el-form-item label="同步ERP时间" prop="syncTime">
<el-date-picker clearable
v-model="form.syncTime"
type="date"
value-format="yyyy-MM-dd" style="width: 220px" disabled
>
</el-date-picker>
</el-form-item>
</el-col>
</el-row>
<el-divider content-position="center">采购申请单详细信息</el-divider>
<el-table :data="mesPurchaseApplyDetailList" :row-class-name="rowMesPurchaseApplyDetailIndex" @selection-change="handleMesPurchaseApplyDetailSelectionChange" ref="mesPurchaseApplyDetail">
<el-table-column label="序号" align="center" prop="index" width="50"/>
<el-table-column label="物料编码" prop="materialCode">
</el-table-column>
<el-table-column label="物料名称" prop="materialName">
</el-table-column>
<el-table-column label="产品规格型号" prop="materialSpec">
</el-table-column>
<el-table-column label="单位" prop="unitName">
</el-table-column>
<el-table-column label="原需要数量" prop="oriReqQty">
</el-table-column>
<el-table-column label="需要数量" prop="reqQty">
<template slot-scope="scope">
<el-input v-model="scope.row.reqQty" placeholder="请输入需要数量" ></el-input>
</template>
</el-table-column>
<el-table-column label="生产厂家" prop="produceSupplier">
</el-table-column>
<el-table-column label="含税单价" prop="taxPrice">
</el-table-column>
<el-table-column label="含税总价" prop="taxTotalPrice">
</el-table-column>
<el-table-column label="京源项目" prop="tondBase">
</el-table-column>
</el-table>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm" v-if="form.syncStatus!=='1'"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
<el-upload
ref="upload"
:limit="1"
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<!-- <div class="el-upload__tip" slot="tip">-->
<!-- <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据-->
<!-- </div>-->
<span>仅允许导入xlsxlsx格式文件</span>
<!-- <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate"></el-link>-->
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm"> </el-button>
<el-button @click="upload.open = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
listPurchaseApply,
getPurchaseApply,
delPurchaseApply,
addPurchaseApply,
updatePurchaseApply,
syncPurchaseApply
} from "@/api/mes/purchaseApply";
import {getToken} from "@/utils/auth";
export default {
name: "PurchaseApply",
dicts: ['mes_purchase_apply_sync_status'],
data() {
return {
//
loading: true,
//
ids: [],
//
checkedMesPurchaseApplyDetail: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
purchaseApplyList: [],
// ;ERP
mesPurchaseApplyDetailList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
taskCode: null,
tondBase: null,
syncStatus: null,
syncTime: null,
},
//
form: {},
//
rules: {
taskCode: [
{ required: true, message: "任务编号不能为空", trigger: "blur" }
],
syncStatus: [
{ required: true, message: "同步状态(0未同步1已同步)不能为空", trigger: "change" }
],
},
upload: {
//
open: false,
//
title: "",
//
isUploading: false,
//
updateSupport: 0,
//
headers: {Authorization: "Bearer " + getToken()},
//
url: process.env.VUE_APP_BASE_API + "/mes/import/purchaseRequisitionImportData"
},
};
},
created() {
this.getList();
},
methods: {
/** 查询采购申请单列表 */
getList() {
this.loading = true;
listPurchaseApply(this.queryParams).then(response => {
this.purchaseApplyList = response.rows;
this.total = response.total;
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
purchaseApplyId: null,
taskCode: null,
tondBase: null,
syncStatus: null,
syncTime: null,
remark: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null
};
this.mesPurchaseApplyDetailList = [];
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.purchaseApplyId)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加采购申请单";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const purchaseApplyId = row.purchaseApplyId || this.ids
getPurchaseApply(purchaseApplyId).then(response => {
this.form = response.data;
this.mesPurchaseApplyDetailList = response.data.mesPurchaseApplyDetailList;
this.open = true;
this.title = "查看采购申请单";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
this.form.mesPurchaseApplyDetailList = this.mesPurchaseApplyDetailList;
if (this.form.purchaseApplyId != null) {
syncPurchaseApply(this.form).then(response => {
this.$modal.msgSuccess("同步成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const purchaseApplyIds = row.purchaseApplyId || this.ids;
this.$modal.confirm('是否确认删除采购申请单编号为"' + purchaseApplyIds + '"的数据项?').then(function() {
return delPurchaseApply(purchaseApplyIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 采购申请单详细信息;从ERP同步过来的信息需要与物料信息关联需要确认接口同步过来的信息内容序号 */
rowMesPurchaseApplyDetailIndex({ row, rowIndex }) {
row.index = rowIndex + 1;
},
/** 采购申请单详细信息;从ERP同步过来的信息需要与物料信息关联需要确认接口同步过来的信息内容添加按钮操作 */
handleAddMesPurchaseApplyDetail() {
let obj = {};
obj.erpMaterialId = "";
obj.materialId = "";
obj.materialCode = "";
obj.materialName = "";
obj.materialSpec = "";
obj.unitCode = "";
obj.priceUnitCode = "";
obj.reqQty = "";
obj.produceSupplier = "";
obj.taxPrice = "";
obj.taxTotalPrice = "";
obj.oriReqQty = "";
this.mesPurchaseApplyDetailList.push(obj);
},
/** 采购申请单详细信息;从ERP同步过来的信息需要与物料信息关联需要确认接口同步过来的信息内容删除按钮操作 */
handleDeleteMesPurchaseApplyDetail() {
if (this.checkedMesPurchaseApplyDetail.length == 0) {
this.$modal.msgError("请先选择要删除的采购申请单详细信息;从ERP同步过来的信息需要与物料信息关联需要确认接口同步过来的信息内容数据");
} else {
const mesPurchaseApplyDetailList = this.mesPurchaseApplyDetailList;
const checkedMesPurchaseApplyDetail = this.checkedMesPurchaseApplyDetail;
this.mesPurchaseApplyDetailList = mesPurchaseApplyDetailList.filter(function(item) {
return checkedMesPurchaseApplyDetail.indexOf(item.index) == -1
});
}
},
/** 复选框选中数据 */
handleMesPurchaseApplyDetailSelectionChange(selection) {
this.checkedMesPurchaseApplyDetail = selection.map(item => item.index)
},
/** 导出按钮操作 */
handleExport() {
this.download('mes/purchaseApply/export', {
...this.queryParams
}, `purchaseApply_${new Date().getTime()}.xlsx`)
},
/** 导入按钮操作 */
handleImport() {
this.upload.title = "用户导入";
this.upload.open = true;
},
/** 下载模板操作 */
importTemplate() {
this.download('system/user/importTemplate', {}, `template_${new Date().getTime()}.xlsx`)
},
//
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true;
},
//
handleFileSuccess(response, file, fileList) {
this.upload.open = false;
this.upload.isUploading = false;
this.$refs.upload.clearFiles();
if(response.code === 200){
this.$modal.msgSuccess("导入成功");
this.getList();
this.reset();
const purchaseApplyId = response.data
getPurchaseApply(purchaseApplyId).then(response => {
this.form = response.data;
this.mesPurchaseApplyDetailList = response.data.mesPurchaseApplyDetailList;
this.open = true;
this.title = "查看采购申请单";
});
}
// this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "", {dangerouslyUseHTMLString: true});
},
//
submitFileForm() {
this.$refs.upload.submit();
},
}
};
</script>
Loading…
Cancel
Save