执行退货
This commit is contained in:
parent
394e9ef8c6
commit
0db75c9f03
@ -121,7 +121,7 @@ public class UserConstants
|
||||
* 库存事务类型
|
||||
*/
|
||||
public static final String TRANSACTION_TYPE_ITEM_RECPT = "ITEM_RECPT"; //原材料接收入库
|
||||
public static final String TRANSACTION_TYPE_ITEM_RV = "ITEM_RV"; //原材料退回供应商
|
||||
public static final String TRANSACTION_TYPE_ITEM_RTV = "ITEM_RTV"; //原材料退回供应商
|
||||
public static final String TRANSACTION_TYPE_ITEM_ISSUE = "ITEM_ISSUE"; //原材料领用出库
|
||||
public static final String TRANSACTION_TYPE_ITEM_RS = "ITEM_RS"; //原材料退库
|
||||
public static final String TRANSACTION_TYPE_WAREHOUSE_TRANS_OUT = "TRANS_OUT"; //移库,移出
|
||||
|
||||
@ -4,6 +4,8 @@ import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.ktg.common.constant.UserConstants;
|
||||
import com.ktg.mes.wm.domain.tx.RtVendorTxBean;
|
||||
import com.ktg.mes.wm.service.IStorageCoreService;
|
||||
import com.ktg.mes.wm.service.IWmRtVendorLineService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -41,6 +43,8 @@ public class WmRtVendorController extends BaseController
|
||||
@Autowired
|
||||
private IWmRtVendorLineService wmRtVendorLineService;
|
||||
|
||||
@Autowired
|
||||
private IStorageCoreService storageCoreService;
|
||||
/**
|
||||
* 查询供应商退货列表
|
||||
*/
|
||||
@ -135,6 +139,15 @@ public class WmRtVendorController extends BaseController
|
||||
}
|
||||
|
||||
//构造事务Bean
|
||||
List<RtVendorTxBean> beans = wmRtVendorService.getTxBeans(rtId);
|
||||
|
||||
//调用库存核心
|
||||
storageCoreService.processRtVendor(beans);
|
||||
|
||||
//更新单据状态
|
||||
WmRtVendor rtVendor = wmRtVendorService.selectWmRtVendorByRtId(rtId);
|
||||
rtVendor.setStatus(UserConstants.ORDER_STATUS_FINISHED);
|
||||
wmRtVendorService.updateWmRtVendor(rtVendor);
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@ -0,0 +1,315 @@
|
||||
package com.ktg.mes.wm.domain.tx;
|
||||
|
||||
import com.ktg.common.core.domain.BaseEntity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class RtVendorTxBean extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long materialStockId;
|
||||
|
||||
/** 产品物料ID */
|
||||
private Long itemId;
|
||||
|
||||
/** 产品物料编码 */
|
||||
private String itemCode;
|
||||
|
||||
/** 产品物料名称 */
|
||||
private String itemName;
|
||||
|
||||
/** 规格型号 */
|
||||
private String specification;
|
||||
|
||||
/** 单位 */
|
||||
private String unitOfMeasure;
|
||||
|
||||
/** 入库批次号 */
|
||||
private String batchCode;
|
||||
|
||||
/** 仓库ID */
|
||||
private Long warehouseId;
|
||||
|
||||
/** 仓库编码 */
|
||||
private String warehouseCode;
|
||||
|
||||
/** 仓库名称 */
|
||||
private String warehouseName;
|
||||
|
||||
/** 库区ID */
|
||||
private Long locationId;
|
||||
|
||||
/** 库区编码 */
|
||||
private String locationCode;
|
||||
|
||||
/** 库区名称 */
|
||||
private String locationName;
|
||||
|
||||
/** 库位ID */
|
||||
private Long areaId;
|
||||
|
||||
/** 库位编码 */
|
||||
private String areaCode;
|
||||
|
||||
/** 库位名称 */
|
||||
private String areaName;
|
||||
|
||||
/** 供应商ID */
|
||||
private Long vendorId;
|
||||
|
||||
/** 供应商编号 */
|
||||
private String vendorCode;
|
||||
|
||||
/** 供应商名称 */
|
||||
private String vendorName;
|
||||
|
||||
/** 供应商简称 */
|
||||
private String vendorNick;
|
||||
|
||||
/** 单据类型 */
|
||||
private String sourceDocType;
|
||||
|
||||
/** 单据ID */
|
||||
private Long sourceDocId;
|
||||
|
||||
/** 单据编号 */
|
||||
private String sourceDocCode;
|
||||
|
||||
/** 单据行ID */
|
||||
private Long sourceDocLineId;
|
||||
|
||||
/** 事务数量 */
|
||||
private BigDecimal transactionQuantity;
|
||||
|
||||
public Long getMaterialStockId() {
|
||||
return materialStockId;
|
||||
}
|
||||
|
||||
public void setMaterialStockId(Long materialStockId) {
|
||||
this.materialStockId = materialStockId;
|
||||
}
|
||||
|
||||
public Long getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
public void setItemId(Long itemId) {
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
public String getItemCode() {
|
||||
return itemCode;
|
||||
}
|
||||
|
||||
public void setItemCode(String itemCode) {
|
||||
this.itemCode = itemCode;
|
||||
}
|
||||
|
||||
public String getItemName() {
|
||||
return itemName;
|
||||
}
|
||||
|
||||
public void setItemName(String itemName) {
|
||||
this.itemName = itemName;
|
||||
}
|
||||
|
||||
public String getSpecification() {
|
||||
return specification;
|
||||
}
|
||||
|
||||
public void setSpecification(String specification) {
|
||||
this.specification = specification;
|
||||
}
|
||||
|
||||
public String getUnitOfMeasure() {
|
||||
return unitOfMeasure;
|
||||
}
|
||||
|
||||
public void setUnitOfMeasure(String unitOfMeasure) {
|
||||
this.unitOfMeasure = unitOfMeasure;
|
||||
}
|
||||
|
||||
public String getBatchCode() {
|
||||
return batchCode;
|
||||
}
|
||||
|
||||
public void setBatchCode(String batchCode) {
|
||||
this.batchCode = batchCode;
|
||||
}
|
||||
|
||||
public Long getWarehouseId() {
|
||||
return warehouseId;
|
||||
}
|
||||
|
||||
public void setWarehouseId(Long warehouseId) {
|
||||
this.warehouseId = warehouseId;
|
||||
}
|
||||
|
||||
public String getWarehouseCode() {
|
||||
return warehouseCode;
|
||||
}
|
||||
|
||||
public void setWarehouseCode(String warehouseCode) {
|
||||
this.warehouseCode = warehouseCode;
|
||||
}
|
||||
|
||||
public String getWarehouseName() {
|
||||
return warehouseName;
|
||||
}
|
||||
|
||||
public void setWarehouseName(String warehouseName) {
|
||||
this.warehouseName = warehouseName;
|
||||
}
|
||||
|
||||
public Long getLocationId() {
|
||||
return locationId;
|
||||
}
|
||||
|
||||
public void setLocationId(Long locationId) {
|
||||
this.locationId = locationId;
|
||||
}
|
||||
|
||||
public String getLocationCode() {
|
||||
return locationCode;
|
||||
}
|
||||
|
||||
public void setLocationCode(String locationCode) {
|
||||
this.locationCode = locationCode;
|
||||
}
|
||||
|
||||
public String getLocationName() {
|
||||
return locationName;
|
||||
}
|
||||
|
||||
public void setLocationName(String locationName) {
|
||||
this.locationName = locationName;
|
||||
}
|
||||
|
||||
public Long getAreaId() {
|
||||
return areaId;
|
||||
}
|
||||
|
||||
public void setAreaId(Long areaId) {
|
||||
this.areaId = areaId;
|
||||
}
|
||||
|
||||
public String getAreaCode() {
|
||||
return areaCode;
|
||||
}
|
||||
|
||||
public void setAreaCode(String areaCode) {
|
||||
this.areaCode = areaCode;
|
||||
}
|
||||
|
||||
public String getAreaName() {
|
||||
return areaName;
|
||||
}
|
||||
|
||||
public void setAreaName(String areaName) {
|
||||
this.areaName = areaName;
|
||||
}
|
||||
|
||||
public Long getVendorId() {
|
||||
return vendorId;
|
||||
}
|
||||
|
||||
public void setVendorId(Long vendorId) {
|
||||
this.vendorId = vendorId;
|
||||
}
|
||||
|
||||
public String getVendorCode() {
|
||||
return vendorCode;
|
||||
}
|
||||
|
||||
public void setVendorCode(String vendorCode) {
|
||||
this.vendorCode = vendorCode;
|
||||
}
|
||||
|
||||
public String getVendorName() {
|
||||
return vendorName;
|
||||
}
|
||||
|
||||
public void setVendorName(String vendorName) {
|
||||
this.vendorName = vendorName;
|
||||
}
|
||||
|
||||
public String getVendorNick() {
|
||||
return vendorNick;
|
||||
}
|
||||
|
||||
public void setVendorNick(String vendorNick) {
|
||||
this.vendorNick = vendorNick;
|
||||
}
|
||||
|
||||
public String getSourceDocType() {
|
||||
return sourceDocType;
|
||||
}
|
||||
|
||||
public void setSourceDocType(String sourceDocType) {
|
||||
this.sourceDocType = sourceDocType;
|
||||
}
|
||||
|
||||
public Long getSourceDocId() {
|
||||
return sourceDocId;
|
||||
}
|
||||
|
||||
public void setSourceDocId(Long sourceDocId) {
|
||||
this.sourceDocId = sourceDocId;
|
||||
}
|
||||
|
||||
public String getSourceDocCode() {
|
||||
return sourceDocCode;
|
||||
}
|
||||
|
||||
public void setSourceDocCode(String sourceDocCode) {
|
||||
this.sourceDocCode = sourceDocCode;
|
||||
}
|
||||
|
||||
public Long getSourceDocLineId() {
|
||||
return sourceDocLineId;
|
||||
}
|
||||
|
||||
public void setSourceDocLineId(Long sourceDocLineId) {
|
||||
this.sourceDocLineId = sourceDocLineId;
|
||||
}
|
||||
|
||||
public BigDecimal getTransactionQuantity() {
|
||||
return transactionQuantity;
|
||||
}
|
||||
|
||||
public void setTransactionQuantity(BigDecimal transactionQuantity) {
|
||||
this.transactionQuantity = transactionQuantity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RtVendorTxBean{" +
|
||||
"materialStockId=" + materialStockId +
|
||||
", itemId=" + itemId +
|
||||
", itemCode='" + itemCode + '\'' +
|
||||
", itemName='" + itemName + '\'' +
|
||||
", specification='" + specification + '\'' +
|
||||
", unitOfMeasure='" + unitOfMeasure + '\'' +
|
||||
", batchCode='" + batchCode + '\'' +
|
||||
", warehouseId=" + warehouseId +
|
||||
", warehouseCode='" + warehouseCode + '\'' +
|
||||
", warehouseName='" + warehouseName + '\'' +
|
||||
", locationId=" + locationId +
|
||||
", locationCode='" + locationCode + '\'' +
|
||||
", locationName='" + locationName + '\'' +
|
||||
", areaId=" + areaId +
|
||||
", areaCode='" + areaCode + '\'' +
|
||||
", areaName='" + areaName + '\'' +
|
||||
", vendorId=" + vendorId +
|
||||
", vendorCode='" + vendorCode + '\'' +
|
||||
", vendorName='" + vendorName + '\'' +
|
||||
", vendorNick='" + vendorNick + '\'' +
|
||||
", sourceDocType='" + sourceDocType + '\'' +
|
||||
", sourceDocId=" + sourceDocId +
|
||||
", sourceDocCode='" + sourceDocCode + '\'' +
|
||||
", sourceDocLineId=" + sourceDocLineId +
|
||||
", transactionQuantity=" + transactionQuantity +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@ -2,6 +2,7 @@ package com.ktg.mes.wm.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ktg.mes.wm.domain.WmRtVendor;
|
||||
import com.ktg.mes.wm.domain.tx.RtVendorTxBean;
|
||||
|
||||
/**
|
||||
* 供应商退货Mapper接口
|
||||
@ -65,4 +66,7 @@ public interface WmRtVendorMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteWmRtVendorByRtIds(Long[] rtIds);
|
||||
|
||||
|
||||
public List<RtVendorTxBean> getTxBeans(Long rtId);
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.ktg.mes.wm.service;
|
||||
|
||||
import com.ktg.mes.wm.domain.WmItemRecptLine;
|
||||
import com.ktg.mes.wm.domain.tx.ItemRecptTxBean;
|
||||
import com.ktg.mes.wm.domain.tx.RtVendorTxBean;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@ -15,5 +16,11 @@ public interface IStorageCoreService {
|
||||
*/
|
||||
public void processItemRecpt(List<ItemRecptTxBean> lines);
|
||||
|
||||
/**
|
||||
* 处理供应商退货单
|
||||
* @param lines
|
||||
*/
|
||||
public void processRtVendor(List<RtVendorTxBean> lines);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package com.ktg.mes.wm.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ktg.mes.wm.domain.WmRtVendor;
|
||||
import com.ktg.mes.wm.domain.tx.RtVendorTxBean;
|
||||
|
||||
/**
|
||||
* 供应商退货Service接口
|
||||
@ -65,4 +66,12 @@ public interface IWmRtVendorService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteWmRtVendorByRtId(Long rtId);
|
||||
|
||||
/**
|
||||
* 获取库存事务bean
|
||||
* @param rtId
|
||||
* @return
|
||||
*/
|
||||
public List<RtVendorTxBean> getTxBeans(Long rtId);
|
||||
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import com.ktg.common.exception.BussinessException;
|
||||
import com.ktg.common.utils.bean.BeanUtils;
|
||||
import com.ktg.mes.wm.domain.WmTransaction;
|
||||
import com.ktg.mes.wm.domain.tx.ItemRecptTxBean;
|
||||
import com.ktg.mes.wm.domain.tx.RtVendorTxBean;
|
||||
import com.ktg.mes.wm.service.IStorageCoreService;
|
||||
import com.ktg.mes.wm.service.IWmTransactionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -53,4 +54,23 @@ public class StorageCoreServiceImpl implements IStorageCoreService {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processRtVendor(List<RtVendorTxBean> lines) {
|
||||
String transactionType = UserConstants.TRANSACTION_TYPE_ITEM_RTV;
|
||||
if(CollUtil.isEmpty(lines)){
|
||||
throw new BussinessException("没有需要处理的退货单行");
|
||||
}
|
||||
|
||||
for(int i=0;i<lines.size();i++){
|
||||
RtVendorTxBean line = lines.get(i);
|
||||
WmTransaction transaction = new WmTransaction();
|
||||
transaction.setTransactionType(transactionType);
|
||||
BeanUtils.copyBeanProp(transaction,line);
|
||||
transaction.setTransactionFlag(-1); //库存减少
|
||||
transaction.setTransactionDate(new Date());
|
||||
wmTransactionService.processTransaction(transaction);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import java.util.List;
|
||||
import com.ktg.common.constant.UserConstants;
|
||||
import com.ktg.common.utils.DateUtils;
|
||||
import com.ktg.common.utils.StringUtils;
|
||||
import com.ktg.mes.wm.domain.tx.RtVendorTxBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ktg.mes.wm.mapper.WmRtVendorMapper;
|
||||
@ -106,4 +107,9 @@ public class WmRtVendorServiceImpl implements IWmRtVendorService
|
||||
{
|
||||
return wmRtVendorMapper.deleteWmRtVendorByRtId(rtId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RtVendorTxBean> getTxBeans(Long rtId) {
|
||||
return wmRtVendorMapper.getTxBeans(rtId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ import com.ktg.mes.md.domain.MdItem;
|
||||
import com.ktg.mes.md.mapper.MdItemMapper;
|
||||
import com.ktg.mes.wm.domain.WmMaterialStock;
|
||||
import com.ktg.mes.wm.mapper.WmMaterialStockMapper;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ktg.mes.wm.mapper.WmTransactionMapper;
|
||||
@ -46,7 +47,11 @@ public class WmTransactionServiceImpl implements IWmTransactionService
|
||||
BigDecimal quantity = wmTransaction.getTransactionQuantity().multiply(new BigDecimal(wmTransaction.getTransactionFlag()));
|
||||
if(StringUtils.isNotNull(ms)){
|
||||
//MS已存在
|
||||
stock.setQuantityOnhand(ms.getQuantityOnhand().add(quantity));
|
||||
BigDecimal resultQuantity =ms.getQuantityOnhand().add(quantity);
|
||||
if(resultQuantity.compareTo(new BigDecimal(0))<0){
|
||||
throw new BussinessException("库存数量不足!");
|
||||
}
|
||||
stock.setQuantityOnhand(resultQuantity);
|
||||
stock.setMaterialStockId(ms.getMaterialStockId());
|
||||
wmMaterialStockMapper.updateWmMaterialStock(stock);
|
||||
}else {
|
||||
@ -85,6 +90,10 @@ public class WmTransactionServiceImpl implements IWmTransactionService
|
||||
|
||||
public void initStock(WmTransaction transaction,WmMaterialStock stock){
|
||||
|
||||
if(StringUtils.isNotNull(transaction.getMaterialStockId())){
|
||||
WmMaterialStock st = wmMaterialStockMapper.selectWmMaterialStockByMaterialStockId(transaction.getMaterialStockId());
|
||||
BeanUtils.copyProperties(st,stock);
|
||||
}else{
|
||||
MdItem item =mdItemMapper.selectMdItemById(transaction.getItemId());
|
||||
stock.setItemTypeId(item.getItemTypeId());
|
||||
stock.setItemId(transaction.getItemId());
|
||||
@ -112,6 +121,7 @@ public class WmTransactionServiceImpl implements IWmTransactionService
|
||||
}
|
||||
stock.setExpireDate(transaction.getExpireDate());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -27,6 +27,38 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="RtVendorTxBean" id="RtVendorTxBeanResult">
|
||||
<result property="materialStockId" column="material_stock_id"></result>
|
||||
<result property="itemId" column="item_id"></result>
|
||||
<result property="itemCode" column="item_code"></result>
|
||||
<result property="itemName" column="item_name"></result>
|
||||
<result property="specification" column="specification"></result>
|
||||
<result property="unitOfMeasure" column="unit_of_measure"></result>
|
||||
<result property="batchCode" column="batch_code"></result>
|
||||
<result property="warehouseId" column="warehouse_id"></result>
|
||||
<result property="warehouseCode" column="warehouse_code"></result>
|
||||
<result property="warehouseName" column="warehouse_name"></result>
|
||||
<result property="locationId" column="location_id"></result>
|
||||
<result property="locationCode" column="location_code"></result>
|
||||
<result property="locationName" column="location_name"></result>
|
||||
<result property="areaId" column="area_id"></result>
|
||||
<result property="areaCode" column="area_code"></result>
|
||||
<result property="areaName" column="area_name"></result>
|
||||
<result property="vendorId" column="vendor_id"></result>
|
||||
<result property="vendorCode" column="vendor_code"></result>
|
||||
<result property="vendorName" column="vendor_name"></result>
|
||||
<result property="vendorNick" column="vendor_nick"></result>
|
||||
<result property="sourceDocType" column="source_doc_type"></result>
|
||||
<result property="sourceDocId" column="source_doc_id"></result>
|
||||
<result property="sourceDocCode" column="source_doc_code"></result>
|
||||
<result property="sourceDocLineId" column="source_doc_line_id"></result>
|
||||
<result property="transactionQuantity" column="transaction_quantity"></result>
|
||||
<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>
|
||||
|
||||
<sql id="selectWmRtVendorVo">
|
||||
select rt_id, rt_code, rt_name, po_code, vendor_id, vendor_code, vendor_name, vendor_nick, batch_code, rt_date, status, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from wm_rt_vendor
|
||||
</sql>
|
||||
@ -57,6 +89,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where rt_code = #{rtCode}
|
||||
</select>
|
||||
|
||||
<select id="getTxBeans" parameterType="Long" resultMap="RtVendorTxBeanResult">
|
||||
SELECT irl.material_stock_id,irl.`item_id`,irl.`item_code`,irl.`item_name`,irl.`specification`,irl.`unit_of_measure`,irl.`batch_code`,
|
||||
irl.`warehouse_id`,irl.`warehouse_code`,irl.`warehouse_name`,irl.`location_id`,irl.`location_code`,irl.`location_name`,irl.`area_id`,irl.`area_code`,irl.`area_name`,
|
||||
ir.`vendor_id`,ir.`vendor_code`,ir.`vendor_name`,ir.`vendor_nick`,
|
||||
'RTV' AS source_doc_type,ir.`rt_id` AS source_doc_id,ir.`rt_code` AS source_doc_code,irl.`line_id` AS source_doc_line_id,
|
||||
irl.`quantity_rted` AS transaction_quantity,
|
||||
ir.`create_by`,ir.`create_time`,ir.`update_by`,ir.`update_time`
|
||||
FROM wm_rt_vendor ir
|
||||
LEFT JOIN wm_rt_vendor_line irl
|
||||
ON ir.rt_id = irl.`rt_id`
|
||||
WHERE ir.`rt_id` = #{rtId}
|
||||
</select>
|
||||
|
||||
<insert id="insertWmRtVendor" parameterType="WmRtVendor" useGeneratedKeys="true" keyProperty="rtId">
|
||||
insert into wm_rt_vendor
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user