change - 修改销售订单绑定采购订单

master
yinq 3 months ago
parent 83b4ef2ab9
commit 733a748704

@ -176,27 +176,28 @@ public class MesPurchaseOrderController extends BaseController
/** /**
* *
* @param saleOrderId * @param purchaseOrderList
* @param purchaseOrderIds
* @return * @return
*/ */
@RequiresPermissions("mes:purchaseOrder:bind") @RequiresPermissions("mes:purchaseOrder:bind")
@Log(title = "采购订单信息", businessType = BusinessType.ALLOCATE) @Log(title = "采购订单信息", businessType = BusinessType.ALLOCATE)
@PutMapping("/saveSalesBindPurchase") @PutMapping("/saveSalesBindPurchase")
public AjaxResult saveSalesBindPurchase(Long saleOrderId, Long[] purchaseOrderIds) { public AjaxResult saveSalesBindPurchase(@RequestBody List<MesPurchaseOrder> purchaseOrderList) {
return success(mesPurchaseOrderService.saveSalesBindPurchase(saleOrderId, purchaseOrderIds)); return success(mesPurchaseOrderService.saveSalesBindPurchase(purchaseOrderList));
} }
/** /**
* *
* @param orderBindIds *
* @param saleOrderId
* @param purchaseOrderIds
* @return * @return
*/ */
@RequiresPermissions("mes:purchaseOrder:bind") @RequiresPermissions("mes:purchaseOrder:bind")
@Log(title = "采购订单信息", businessType = BusinessType.UNALLOCATE) @Log(title = "采购订单信息", businessType = BusinessType.UNALLOCATE)
@PostMapping("/removeSalesBindPurchase") @PostMapping("/removeSalesBindPurchase")
public AjaxResult removeSalesBindPurchase(Long[] orderBindIds) { public AjaxResult removeSalesBindPurchase(Long saleOrderId, Long[] purchaseOrderIds) {
return toAjax(mesPurchaseOrderService.removeSalesBindPurchase(orderBindIds)); return toAjax(mesPurchaseOrderService.removeSalesBindPurchase(saleOrderId, purchaseOrderIds));
} }
} }

@ -146,6 +146,50 @@ public class MesPurchaseOrder extends BaseEntity {
/**采购销售订单绑定主键*/ /**采购销售订单绑定主键*/
private Long orderBindId; private Long orderBindId;
/** 已绑定数 */
private BigDecimal boundAmount;
/** 销售订单已绑定数 */
private BigDecimal saleBindAmount;
/** 安全库存数 */
private BigDecimal safeAmount;
/** 条码数 */
private BigDecimal barcodeAmount;
public BigDecimal getBoundAmount() {
return boundAmount;
}
public void setBoundAmount(BigDecimal boundAmount) {
this.boundAmount = boundAmount;
}
public BigDecimal getSaleBindAmount() {
return saleBindAmount;
}
public void setSaleBindAmount(BigDecimal saleBindAmount) {
this.saleBindAmount = saleBindAmount;
}
public BigDecimal getSafeAmount() {
return safeAmount;
}
public void setSafeAmount(BigDecimal safeAmount) {
this.safeAmount = safeAmount;
}
public BigDecimal getBarcodeAmount() {
return barcodeAmount;
}
public void setBarcodeAmount(BigDecimal barcodeAmount) {
this.barcodeAmount = barcodeAmount;
}
public Long getSaleOrderId() { public Long getSaleOrderId() {
return saleOrderId; return saleOrderId;
} }

@ -92,16 +92,17 @@ public interface IMesPurchaseOrderService
/** /**
* *
* @param saleOrderId * @param purchaseOrderList
* @param purchaseOrderIds
* @return * @return
*/ */
public int saveSalesBindPurchase(Long saleOrderId, Long[] purchaseOrderIds); public int saveSalesBindPurchase(List<MesPurchaseOrder> purchaseOrderList);
/** /**
* *
* @param orderBindIds *
* @param saleOrderId
* @param purchaseOrderIds
* @return * @return
*/ */
public int removeSalesBindPurchase(Long[] orderBindIds); public int removeSalesBindPurchase(Long saleOrderId, Long[] purchaseOrderIds);
} }

@ -14,13 +14,9 @@ import com.hw.mes.api.domain.MesBaseBarcodeInfo;
import com.hw.mes.api.domain.MesBaseMaterialInfo; import com.hw.mes.api.domain.MesBaseMaterialInfo;
import com.hw.mes.domain.MesOrderBind; import com.hw.mes.domain.MesOrderBind;
import com.hw.mes.domain.MesSaleOrder; import com.hw.mes.domain.MesSaleOrder;
import com.hw.mes.mapper.MesBaseBarcodeInfoMapper; import com.hw.mes.mapper.*;
import com.hw.mes.mapper.MesBaseMaterialInfoMapper;
import com.hw.mes.mapper.MesSaleOrderMapper;
import com.hw.mes.service.IMesBaseMaterialInfoService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.hw.mes.mapper.MesPurchaseOrderMapper;
import com.hw.mes.domain.MesPurchaseOrder; import com.hw.mes.domain.MesPurchaseOrder;
import com.hw.mes.service.IMesPurchaseOrderService; import com.hw.mes.service.IMesPurchaseOrderService;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -45,6 +41,9 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService {
@Autowired @Autowired
private MesSaleOrderMapper mesSaleOrderMapper; private MesSaleOrderMapper mesSaleOrderMapper;
@Autowired
private MesOrderBindMapper mesOrderBindMapper;
/** /**
* *
* *
@ -237,13 +236,13 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService {
/** /**
* *
* @param saleOrderId * @param purchaseOrderList
* @param purchaseOrderIds
* @return * @return
*/ */
@Override @Override
public int saveSalesBindPurchase(Long saleOrderId, Long[] purchaseOrderIds) { @Transactional(rollbackFor = ServiceException.class)
List<MesOrderBind> orderBindList = new ArrayList<>(); public int saveSalesBindPurchase(List<MesPurchaseOrder> purchaseOrderList) {
Long saleOrderId = purchaseOrderList.get(0).getSaleOrderId();
if (StringUtils.isNull(saleOrderId)){ if (StringUtils.isNull(saleOrderId)){
return 0; return 0;
} }
@ -254,41 +253,69 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService {
String productName = mesSaleOrder.getMaterialName(); String productName = mesSaleOrder.getMaterialName();
Date currentDate = new Date(); Date currentDate = new Date();
String userName = SecurityUtils.getUsername(); String userName = SecurityUtils.getUsername();
for (Long purchaseOrderId : purchaseOrderIds) { for (MesPurchaseOrder purchaseOrder : purchaseOrderList) {
MesOrderBind orderBind = new MesOrderBind(); Long purchaseOrderId = purchaseOrder.getPurchaseOrderId();
MesPurchaseOrder mesPurchaseOrder = mesPurchaseOrderMapper.selectMesPurchaseOrderByPurchaseOrderId(purchaseOrderId); MesOrderBind selectOrderBind = new MesOrderBind();
Long materialId = mesPurchaseOrder.getMaterialId(); selectOrderBind.setSafeFlag(MesConstants.MES_ORDER_BIND_SAFE_FLAG_NO);
String materialCode = mesPurchaseOrder.getMaterialCode(); selectOrderBind.setSaleOrderId(saleOrderId);
String materialName = mesPurchaseOrder.getMaterialName(); selectOrderBind.setPurchaseOrderId(purchaseOrderId);
String poNo = mesPurchaseOrder.getPoNo(); List<MesOrderBind> bindList = mesOrderBindMapper.selectMesOrderBindList(selectOrderBind);
BigDecimal orderAmount = mesPurchaseOrder.getOrderAmount(); if (bindList.size() == 0){
MesOrderBind orderBind = new MesOrderBind();
orderBind.setSafeFlag(MesConstants.MES_ORDER_BIND_SAFE_FLAG_NO); MesPurchaseOrder mesPurchaseOrder = mesPurchaseOrderMapper.selectMesPurchaseOrderByPurchaseOrderId(purchaseOrderId);
orderBind.setSaleOrderId(saleOrderId); Long materialId = mesPurchaseOrder.getMaterialId();
orderBind.setSaleOrderCode(saleorderCode); String materialCode = mesPurchaseOrder.getMaterialCode();
orderBind.setProductId(productId); String materialName = mesPurchaseOrder.getMaterialName();
orderBind.setProductCode(productCode); String poNo = mesPurchaseOrder.getPoNo();
orderBind.setProductName(productName); BigDecimal orderAmount = mesPurchaseOrder.getOrderAmount();
orderBind.setPurchaseOrderId(purchaseOrderId); orderBind.setSafeFlag(MesConstants.MES_ORDER_BIND_SAFE_FLAG_NO);
orderBind.setMaterialId(materialId); orderBind.setSaleOrderId(saleOrderId);
orderBind.setMaterialCode(materialCode); orderBind.setSaleOrderCode(saleorderCode);
orderBind.setMaterialName(materialName); orderBind.setProductId(productId);
orderBind.setBindAmount(orderAmount); orderBind.setProductCode(productCode);
orderBind.setPoNo(poNo); orderBind.setProductName(productName);
orderBind.setCreateTime(currentDate); orderBind.setPurchaseOrderId(purchaseOrderId);
orderBind.setCreateBy(userName); orderBind.setMaterialId(materialId);
orderBindList.add(orderBind); orderBind.setMaterialCode(materialCode);
orderBind.setMaterialName(materialName);
orderBind.setBindAmount(purchaseOrder.getSaleBindAmount());
orderBind.setPoNo(poNo);
orderBind.setCreateTime(currentDate);
orderBind.setCreateBy(userName);
mesOrderBindMapper.insertMesOrderBind(orderBind);
} else {
MesOrderBind bind = bindList.get(0);
bind.setBindAmount(purchaseOrder.getSaleBindAmount());
bind.setUpdateBy(SecurityUtils.getUsername());
bind.setUpdateTime(DateUtils.getNowDate());
mesOrderBindMapper.updateMesOrderBind(bind);
}
} }
return mesPurchaseOrderMapper.batchMesOrderBind(orderBindList); return 1;
} }
/** /**
* *
* @param orderBindIds *
* @param saleOrderId
* @param purchaseOrderIds
* @return * @return
*/ */
@Override @Override
public int removeSalesBindPurchase(Long[] orderBindIds) { @Transactional(rollbackFor = ServiceException.class)
public int removeSalesBindPurchase(Long saleOrderId, Long[] purchaseOrderIds) {
List<Long> list = new ArrayList<>();
for (Long purchaseOrderId : purchaseOrderIds) {
MesOrderBind selectOrderBind = new MesOrderBind();
selectOrderBind.setSafeFlag(MesConstants.MES_ORDER_BIND_SAFE_FLAG_NO);
selectOrderBind.setSaleOrderId(saleOrderId);
selectOrderBind.setPurchaseOrderId(purchaseOrderId);
List<MesOrderBind> bindList = mesOrderBindMapper.selectMesOrderBindList(selectOrderBind);
if (bindList.size() > 0){
list.add(bindList.get(0).getOrderBindId());
}
}
Long[] orderBindIds = list.toArray(new Long[0]);
return mesPurchaseOrderMapper.deleteMesOrderBindByOrderBindIds(orderBindIds); return mesPurchaseOrderMapper.deleteMesOrderBindByOrderBindIds(orderBindIds);
} }

@ -39,6 +39,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="specificationParameter" column="specification_parameter" /> <result property="specificationParameter" column="specification_parameter" />
<result property="materialSpec" column="material_spec" /> <result property="materialSpec" column="material_spec" />
<result property="orderBindId" column="order_bind_id" /> <result property="orderBindId" column="order_bind_id" />
<result property="boundAmount" column="bound_amount" />
<result property="saleBindAmount" column="sale_bind_amount" />
<result property="safeAmount" column="safe_amount" />
<result property="barcodeAmount" column="barcode_amount" />
</resultMap> </resultMap>
<resultMap id="MesPurchaseOrderMesOrderBindResult" type="MesPurchaseOrder" extends="MesPurchaseOrderResult"> <resultMap id="MesPurchaseOrderMesOrderBindResult" type="MesPurchaseOrder" extends="MesPurchaseOrderResult">
@ -221,25 +225,43 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="unbindPurchaseOrderList" parameterType="MesPurchaseOrder" resultMap="MesPurchaseOrderResult"> <select id="unbindPurchaseOrderList" parameterType="MesPurchaseOrder" resultMap="MesPurchaseOrderResult">
select mpo.purchase_order_id, select mpo.purchase_order_id,
mpo.erp_id, mpo.erp_id,
mpo.fentry_id, mpo.fentry_id,
mpo.po_no, mpo.po_no,
mpo.document_status, mpo.document_status,
mpo.material_id, mpo.material_id,
mpo.material_code, mpo.material_code,
mpo.material_name, mpo.material_name,
mbmi.material_spec, mbmi.material_spec,
mpo.order_amount, mpo.aux_prop_id,
mpo.aux_prop_id, mpo.specification_parameter,
mpo.specification_parameter mpo.order_amount,
(select ifnull(sum(mob.bind_amount), 0)
from mes_order_bind mob
where mob.purchase_order_id = mpo.purchase_order_id
and mob.safe_flag = '0') bound_amount,
(select ifnull(sum(mob.bind_amount), 0)
from mes_order_bind mob
where mob.purchase_order_id = mpo.purchase_order_id
and sale_order_id = #{saleOrderId}
and mob.safe_flag = '0') sale_bind_amount,
(select ifnull(sum(bind_amount), 0)
from mes_order_bind mob
where mob.purchase_order_id = mpo.purchase_order_id
and mob.safe_flag = '1') safe_amount,
(select ifnull(sum(mob.barcode_amount), 0)
from mes_order_bind mob
where mob.purchase_order_id = mpo.purchase_order_id
and mob.safe_flag = '1') barcode_amount
from mes_purchase_order mpo from mes_purchase_order mpo
left join mes_base_material_info mbmi on mbmi.material_id = mpo.material_id left join mes_base_material_info mbmi on mbmi.material_id = mpo.material_id
<where> <where>
not exists(select 1 from mes_order_bind o where o.purchase_order_id = mpo.purchase_order_id and o.sale_order_id = #{saleOrderId})
<if test="poNo != null and poNo != ''"> and mpo.po_no = #{poNo}</if> <if test="poNo != null and poNo != ''"> and mpo.po_no = #{poNo}</if>
<if test="materialCode != null and materialCode != ''"> and mpo.material_code = #{materialCode}</if> <if test="materialCode != null and materialCode != ''"> and mpo.material_code = #{materialCode}</if>
<if test="materialName != null and materialName != ''"> and mpo.material_name like concat('%', #{materialName}, '%')</if> <if test="materialName != null and materialName != ''"> and mpo.material_name like concat('%', #{materialName}, '%')</if>
<if test="specificationParameter != null and specificationParameter != ''"> and mpo.specification_parameter like concat('%', #{specificationParameter}, '%')</if>
</where> </where>
order by sale_bind_amount desc
</select> </select>
<select id="saleBindPurchaseOrderList" parameterType="MesPurchaseOrder" resultMap="MesPurchaseOrderResult"> <select id="saleBindPurchaseOrderList" parameterType="MesPurchaseOrder" resultMap="MesPurchaseOrderResult">

@ -35,7 +35,7 @@ public class PrinterController {
@PostMapping("/printBarcodes") @PostMapping("/printBarcodes")
public R<MesBaseBarcodeInfo> printBarcodes(@RequestBody PrinterVo printerVo) { public R<MesBaseBarcodeInfo> printBarcodes(@RequestBody PrinterVo printerVo) {
try { try {
String hostIp = IpUtils.getIpAddr(); String hostIp = "ZDesigner ZT510-203dpi ZPL";
String printType = printerVo.getPrintType(); String printType = printerVo.getPrintType();
List<PrintContentVo> printContentVos = printerVo.getPrintContentVos(); List<PrintContentVo> printContentVos = printerVo.getPrintContentVos();
if(printType.equals(PrinterVo.PRINT_TYPE_RAW_LABEL)){ if(printType.equals(PrinterVo.PRINT_TYPE_RAW_LABEL)){

@ -97,7 +97,7 @@ export function saveSalesBindPurchase(data) {
return request({ return request({
url: '/mes/purchaseOrder/saveSalesBindPurchase', url: '/mes/purchaseOrder/saveSalesBindPurchase',
method: 'put', method: 'put',
params: data data: data
}) })
} }

Loading…
Cancel
Save