生产退库库存核心
This commit is contained in:
parent
a21cfdf96c
commit
3ce6be7849
@ -122,10 +122,13 @@ public class UserConstants
|
||||
*/
|
||||
public static final String TRANSACTION_TYPE_ITEM_RECPT = "ITEM_RECPT"; //原材料接收入库
|
||||
public static final String TRANSACTION_TYPE_ITEM_RTV = "ITEM_RTV"; //原材料退回供应商
|
||||
public static final String TRANSACTION_TYPE_ITEM_ISSUE_OUT = "ITEM_ISSUE_OUT"; //生产领用
|
||||
public static final String TRANSACTION_TYPE_ITEM_ISSUE_IN = "ITEM_ISSUE_IN";
|
||||
|
||||
public static final String TRANSACTION_TYPE_ITEM_RS = "ITEM_RS"; //生产退库
|
||||
public static final String TRANSACTION_TYPE_ITEM_ISSUE_OUT = "ITEM_ISSUE_OUT"; //生产领用-出库事务
|
||||
public static final String TRANSACTION_TYPE_ITEM_ISSUE_IN = "ITEM_ISSUE_IN"; //生产领用-入库事务
|
||||
|
||||
public static final String TRANSACTION_TYPE_ITEM_RT_ISSUE_OUT = "ITEM_RT_ISSUE_OUT"; //生产退库-出库事务
|
||||
public static final String TRANSACTION_TYPE_ITEM_RT_ISSUE_IN = "ITEM_RT_ISSUE_IN"; //生产退库-入库事务
|
||||
|
||||
public static final String TRANSACTION_TYPE_WAREHOUSE_TRANS_OUT = "TRANS_OUT"; //移库,移出
|
||||
public static final String TRANSACTION_TYPE_WAREHOUSE_TRANS_IN = "TRANS_IN"; //移库,移入
|
||||
public static final String TRANSACTION_TYPE_PRODUCT_ISSUE = "PRODUCT_ISSUE"; //销售出库
|
||||
|
@ -3,11 +3,11 @@ package com.ktg.mes.wm.controller;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.ktg.common.constant.UserConstants;
|
||||
import com.ktg.common.utils.StringUtils;
|
||||
import com.ktg.mes.wm.domain.WmStorageArea;
|
||||
import com.ktg.mes.wm.domain.WmStorageLocation;
|
||||
import com.ktg.mes.wm.domain.WmWarehouse;
|
||||
import com.ktg.mes.wm.domain.*;
|
||||
import com.ktg.mes.wm.domain.tx.RtIssueTxBean;
|
||||
import com.ktg.mes.wm.service.*;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -24,7 +24,6 @@ import com.ktg.common.annotation.Log;
|
||||
import com.ktg.common.core.controller.BaseController;
|
||||
import com.ktg.common.core.domain.AjaxResult;
|
||||
import com.ktg.common.enums.BusinessType;
|
||||
import com.ktg.mes.wm.domain.WmRtIssue;
|
||||
import com.ktg.common.utils.poi.ExcelUtil;
|
||||
import com.ktg.common.core.page.TableDataInfo;
|
||||
|
||||
@ -44,6 +43,7 @@ public class WmRtIssueController extends BaseController
|
||||
@Autowired
|
||||
private IWmRtIssueLineService wmRtIssueLineService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private IWmWarehouseService wmWarehouseService;
|
||||
|
||||
@ -166,4 +166,32 @@ public class WmRtIssueController extends BaseController
|
||||
}
|
||||
return toAjax(wmRtIssueService.deleteWmRtIssueByRtIds(rtIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行退料
|
||||
* @param rtId
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('mes:wm:rtissue:edit')")
|
||||
@Log(title = "生产退料单头", businessType = BusinessType.UPDATE)
|
||||
@Transactional
|
||||
@PutMapping("/{rtId}")
|
||||
public AjaxResult execute(@PathVariable Long rtId){
|
||||
WmRtIssue rtIssue = wmRtIssueService.selectWmRtIssueByRtId(rtId);
|
||||
WmRtIssueLine param = new WmRtIssueLine();
|
||||
param.setRtId(rtId);
|
||||
List<WmRtIssueLine> lines = wmRtIssueLineService.selectWmRtIssueLineList(param);
|
||||
if(CollUtil.isEmpty(lines)){
|
||||
return AjaxResult.error("请选择要退料的物资");
|
||||
}
|
||||
|
||||
List<RtIssueTxBean> beans = wmRtIssueService.getTxBeans(rtId);
|
||||
|
||||
|
||||
|
||||
rtIssue.setStatus(UserConstants.ORDER_STATUS_FINISHED);
|
||||
wmRtIssueService.updateWmRtIssue(rtIssue);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,282 @@
|
||||
package com.ktg.mes.wm.domain.tx;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.ktg.common.core.domain.BaseEntity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
public class RtIssueTxBean 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;
|
||||
|
||||
/** 单据类型 */
|
||||
private String sourceDocType;
|
||||
|
||||
/** 单据ID */
|
||||
private Long sourceDocId;
|
||||
|
||||
/** 单据编号 */
|
||||
private String sourceDocCode;
|
||||
|
||||
/** 单据行ID */
|
||||
private Long sourceDocLineId;
|
||||
|
||||
/** 事务数量 */
|
||||
private BigDecimal transactionQuantity;
|
||||
|
||||
/** 入库日期 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss")
|
||||
private Date recptDate;
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
||||
public Date getRecptDate() {
|
||||
return recptDate;
|
||||
}
|
||||
|
||||
public void setRecptDate(Date recptDate) {
|
||||
this.recptDate = recptDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RtIssueTxBean{" +
|
||||
"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 + '\'' +
|
||||
", sourceDocType='" + sourceDocType + '\'' +
|
||||
", sourceDocId=" + sourceDocId +
|
||||
", sourceDocCode='" + sourceDocCode + '\'' +
|
||||
", sourceDocLineId=" + sourceDocLineId +
|
||||
", transactionQuantity=" + transactionQuantity +
|
||||
", recptDate=" + recptDate +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package com.ktg.mes.wm.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ktg.mes.wm.domain.WmRtIssue;
|
||||
import com.ktg.mes.wm.domain.tx.RtIssueTxBean;
|
||||
|
||||
/**
|
||||
* 生产退料单头Mapper接口
|
||||
@ -27,6 +28,13 @@ public interface WmRtIssueMapper
|
||||
*/
|
||||
public List<WmRtIssue> selectWmRtIssueList(WmRtIssue wmRtIssue);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param rtId
|
||||
* @return
|
||||
*/
|
||||
public List<RtIssueTxBean> getTxBeans(Long rtId);
|
||||
|
||||
/**
|
||||
* 检查编号是否重复
|
||||
* @param wmRtIssue
|
||||
|
@ -3,6 +3,7 @@ package com.ktg.mes.wm.service;
|
||||
import com.ktg.mes.wm.domain.WmItemRecptLine;
|
||||
import com.ktg.mes.wm.domain.tx.IssueTxBean;
|
||||
import com.ktg.mes.wm.domain.tx.ItemRecptTxBean;
|
||||
import com.ktg.mes.wm.domain.tx.RtIssueTxBean;
|
||||
import com.ktg.mes.wm.domain.tx.RtVendorTxBean;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -29,4 +30,10 @@ public interface IStorageCoreService {
|
||||
*/
|
||||
public void processIssue(List<IssueTxBean> lines);
|
||||
|
||||
/**
|
||||
* 处理生产退料
|
||||
* @param lines
|
||||
*/
|
||||
public void processRtIssue(List<RtIssueTxBean> lines);
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.ktg.mes.wm.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ktg.mes.wm.domain.WmRtIssue;
|
||||
import com.ktg.mes.wm.domain.tx.RtIssueTxBean;
|
||||
|
||||
/**
|
||||
* 生产退料单头Service接口
|
||||
@ -65,4 +66,12 @@ public interface IWmRtIssueService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteWmRtIssueByRtId(Long rtId);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param rtId
|
||||
* @return
|
||||
*/
|
||||
public List<RtIssueTxBean> getTxBeans(Long rtId);
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import com.ktg.mes.wm.domain.WmTransaction;
|
||||
import com.ktg.mes.wm.domain.WmWarehouse;
|
||||
import com.ktg.mes.wm.domain.tx.IssueTxBean;
|
||||
import com.ktg.mes.wm.domain.tx.ItemRecptTxBean;
|
||||
import com.ktg.mes.wm.domain.tx.RtIssueTxBean;
|
||||
import com.ktg.mes.wm.domain.tx.RtVendorTxBean;
|
||||
import com.ktg.mes.wm.service.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -116,4 +117,36 @@ public class StorageCoreServiceImpl implements IStorageCoreService {
|
||||
wmTransactionService.processTransaction(transaction_in);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processRtIssue(List<RtIssueTxBean> lines) {
|
||||
if(CollUtil.isEmpty(lines)){
|
||||
throw new BussinessException("没有需要处理的退料单行");
|
||||
}
|
||||
|
||||
String transactionType_out = UserConstants.TRANSACTION_TYPE_ITEM_RT_ISSUE_OUT;
|
||||
String transactionType_in = UserConstants.TRANSACTION_TYPE_ITEM_RT_ISSUE_IN;
|
||||
for(int i=0;i<lines.size();i++){
|
||||
RtIssueTxBean line = lines.get(i);
|
||||
|
||||
//构造一条目的库存减少的事务
|
||||
WmTransaction transaction_out = new WmTransaction();
|
||||
transaction_out.setTransactionType(transactionType_out);
|
||||
BeanUtils.copyBeanProp(transaction_out,line);
|
||||
transaction_out.setTransactionFlag(-1);//库存减少
|
||||
wmTransactionService.processTransaction(transaction_out);
|
||||
|
||||
//构造一条目的库存增加的事务
|
||||
WmTransaction transaction_in = new WmTransaction();
|
||||
transaction_in.setTransactionType(transactionType_in);
|
||||
BeanUtils.copyBeanProp(transaction_in,line);
|
||||
transaction_in.setTransactionFlag(1);//库存增加
|
||||
transaction_in.setTransactionDate(new Date());
|
||||
//由于是新增的库存记录所以需要将查询出来的库存记录ID置为空
|
||||
transaction_in.setMaterialStockId(null);
|
||||
//设置入库相关联的出库事务ID
|
||||
transaction_in.setRelatedTransactionId(transaction_out.getTransactionId());
|
||||
wmTransactionService.processTransaction(transaction_in);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.RtIssueTxBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ktg.mes.wm.mapper.WmRtIssueMapper;
|
||||
@ -106,4 +107,9 @@ public class WmRtIssueServiceImpl implements IWmRtIssueService
|
||||
{
|
||||
return wmRtIssueMapper.deleteWmRtIssueByRtId(rtId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RtIssueTxBean> getTxBeans(Long rtId) {
|
||||
return wmRtIssueMapper.getTxBeans(rtId);
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="RtIssueTxBean" id="RtIssueTxBeanResult">
|
||||
<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="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="recptDate" column="recpt_date"></result>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectWmRtIssueVo">
|
||||
select rt_id, rt_code, rt_name, workorder_id, workorder_code, warehouse_id, warehouse_code, warehouse_name, location_id, location_code, location_name, area_id, area_code, area_name, rt_date, status, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from wm_rt_issue
|
||||
</sql>
|
||||
@ -67,6 +92,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where rt_code = #{rtCode}
|
||||
</select>
|
||||
|
||||
<select id="getTxBeans" parameterType="Long" resultMap="RtIssueTxBeanResult">
|
||||
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`,
|
||||
'RTISSUE' 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_rt AS transaction_quantity,
|
||||
ir.rt_date as recptDate
|
||||
FROM wm_rt_issue ir
|
||||
LEFT JOIN wm_rt_issue_line irl
|
||||
ON ir.rt_id = irl.rt_id
|
||||
WHERE ir.rt_id = #{rtId}
|
||||
</select>
|
||||
|
||||
<insert id="insertWmRtIssue" parameterType="WmRtIssue" useGeneratedKeys="true" keyProperty="rtId">
|
||||
insert into wm_rt_issue
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
Loading…
Reference in New Issue
Block a user