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

master
yinq 3 months ago
parent 83b4ef2ab9
commit 733a748704

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

@ -146,6 +146,50 @@ public class MesPurchaseOrder extends BaseEntity {
/**采购销售订单绑定主键*/
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() {
return saleOrderId;
}

@ -92,16 +92,17 @@ public interface IMesPurchaseOrderService
/**
*
* @param saleOrderId
* @param purchaseOrderIds
* @param purchaseOrderList
* @return
*/
public int saveSalesBindPurchase(Long saleOrderId, Long[] purchaseOrderIds);
public int saveSalesBindPurchase(List<MesPurchaseOrder> purchaseOrderList);
/**
*
* @param orderBindIds
*
* @param saleOrderId
* @param purchaseOrderIds
* @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.domain.MesOrderBind;
import com.hw.mes.domain.MesSaleOrder;
import com.hw.mes.mapper.MesBaseBarcodeInfoMapper;
import com.hw.mes.mapper.MesBaseMaterialInfoMapper;
import com.hw.mes.mapper.MesSaleOrderMapper;
import com.hw.mes.service.IMesBaseMaterialInfoService;
import com.hw.mes.mapper.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hw.mes.mapper.MesPurchaseOrderMapper;
import com.hw.mes.domain.MesPurchaseOrder;
import com.hw.mes.service.IMesPurchaseOrderService;
import org.springframework.transaction.annotation.Transactional;
@ -45,6 +41,9 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService {
@Autowired
private MesSaleOrderMapper mesSaleOrderMapper;
@Autowired
private MesOrderBindMapper mesOrderBindMapper;
/**
*
*
@ -237,13 +236,13 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService {
/**
*
* @param saleOrderId
* @param purchaseOrderIds
* @param purchaseOrderList
* @return
*/
@Override
public int saveSalesBindPurchase(Long saleOrderId, Long[] purchaseOrderIds) {
List<MesOrderBind> orderBindList = new ArrayList<>();
@Transactional(rollbackFor = ServiceException.class)
public int saveSalesBindPurchase(List<MesPurchaseOrder> purchaseOrderList) {
Long saleOrderId = purchaseOrderList.get(0).getSaleOrderId();
if (StringUtils.isNull(saleOrderId)){
return 0;
}
@ -254,7 +253,14 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService {
String productName = mesSaleOrder.getMaterialName();
Date currentDate = new Date();
String userName = SecurityUtils.getUsername();
for (Long purchaseOrderId : purchaseOrderIds) {
for (MesPurchaseOrder purchaseOrder : purchaseOrderList) {
Long purchaseOrderId = purchaseOrder.getPurchaseOrderId();
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){
MesOrderBind orderBind = new MesOrderBind();
MesPurchaseOrder mesPurchaseOrder = mesPurchaseOrderMapper.selectMesPurchaseOrderByPurchaseOrderId(purchaseOrderId);
Long materialId = mesPurchaseOrder.getMaterialId();
@ -262,7 +268,6 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService {
String materialName = mesPurchaseOrder.getMaterialName();
String poNo = mesPurchaseOrder.getPoNo();
BigDecimal orderAmount = mesPurchaseOrder.getOrderAmount();
orderBind.setSafeFlag(MesConstants.MES_ORDER_BIND_SAFE_FLAG_NO);
orderBind.setSaleOrderId(saleOrderId);
orderBind.setSaleOrderCode(saleorderCode);
@ -273,22 +278,44 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService {
orderBind.setMaterialId(materialId);
orderBind.setMaterialCode(materialCode);
orderBind.setMaterialName(materialName);
orderBind.setBindAmount(orderAmount);
orderBind.setBindAmount(purchaseOrder.getSaleBindAmount());
orderBind.setPoNo(poNo);
orderBind.setCreateTime(currentDate);
orderBind.setCreateBy(userName);
orderBindList.add(orderBind);
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
*/
@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);
}

@ -39,6 +39,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="specificationParameter" column="specification_parameter" />
<result property="materialSpec" column="material_spec" />
<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 id="MesPurchaseOrderMesOrderBindResult" type="MesPurchaseOrder" extends="MesPurchaseOrderResult">
@ -229,17 +233,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mpo.material_code,
mpo.material_name,
mbmi.material_spec,
mpo.order_amount,
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
left join mes_base_material_info mbmi on mbmi.material_id = mpo.material_id
<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="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="specificationParameter != null and specificationParameter != ''"> and mpo.specification_parameter like concat('%', #{specificationParameter}, '%')</if>
</where>
order by sale_bind_amount desc
</select>
<select id="saleBindPurchaseOrderList" parameterType="MesPurchaseOrder" resultMap="MesPurchaseOrderResult">

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

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

Loading…
Cancel
Save