生产消耗和产品产出

This commit is contained in:
DESKTOP-J7ED0MB\yinjinlu 2022-10-09 15:47:19 +08:00
parent c17501d4da
commit 2d54e31e32
7 changed files with 759 additions and 2 deletions

View File

@ -132,6 +132,9 @@ public class UserConstants
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_ITEM_CONSUME = "ITEM_CONSUME";//物料生产消耗
public static final String TRANSACTION_TYPE_PRODUCT_PRODUCE = "PRODUCT_PRODUCE";//产品生产
public static final String TRANSACTION_TYPE_PRODUCT_RECPT_OUT = "PRODUCT_RECPT_OUT"; //产品入库-出库事务
public static final String TRANSACTION_TYPE_PRODUCT_RECPT_IN = "PRODUCT_RECPT_IN"; //产品入库-入库事务

View File

@ -1,11 +1,17 @@
package com.ktg.mes.pro.controller;
import java.math.BigDecimal;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ktg.mes.pro.domain.ProFeedback;
import com.ktg.mes.pro.domain.ProTask;
import com.ktg.mes.pro.service.IProTaskService;
import com.ktg.mes.pro.service.IProWorkorderService;
import com.ktg.mes.wm.service.IStorageCoreService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
@ -35,6 +41,15 @@ public class ProFeedbackController extends BaseController
@Autowired
private IProFeedbackService proFeedbackService;
@Autowired
private IProTaskService proTaskService;
@Autowired
private IProWorkorderService proWorkorderService;
@Autowired
private IStorageCoreService storageCoreService;
/**
* 查询生产报工记录列表
*/
@ -102,4 +117,38 @@ public class ProFeedbackController extends BaseController
{
return toAjax(proFeedbackService.deleteProFeedbackByRecordIds(recordIds));
}
/**
* 执行报工
* 1.更新生产任务和生产工单的进度
* 2.物料消耗
* 3.产品产出
* @param recordId
* @return
*/
@PreAuthorize("@ss.hasPermi('mes:pro:feedback:edit')")
@Log(title = "生产报工执行", businessType = BusinessType.UPDATE)
@Transactional
@PutMapping("/{recordId}")
public AjaxResult execute(@PathVariable("recordId") Long recordId){
ProFeedback feedback= proFeedbackService.selectProFeedbackByRecordId(recordId);
//更新生产任务的生产数量
ProTask task = proTaskService.selectProTaskByTaskId(feedback.getTaskId());
BigDecimal quantityProduced,quantityQuanlify,quantityUnquanlify;
quantityQuanlify = task.getQuantityQuanlify()==null? new BigDecimal(0):task.getQuantityQuanlify();
quantityUnquanlify = task.getQuantityUnquanlify() ==null? new BigDecimal(0):task.getQuantityUnquanlify();
quantityProduced = task.getQuantityProduced()==null? new BigDecimal(0):task.getQuantityProduced();
task.setQuantityProduced(quantityProduced.add(feedback.getQuantityFeedback()));
task.setQuantityQuanlify(quantityQuanlify.add(feedback.getQuantityQualified()));
task.setQuantityUnquanlify(quantityUnquanlify.add(feedback.getQuantityUnquanlified()));
proTaskService.updateProTask(task);
//如果是最后一道工序则更新当前工单的已生产数量
return AjaxResult.success();
}
}

View File

@ -164,6 +164,12 @@ public class WmTransaction extends BaseEntity
@Excel(name = "库存有效期", width = 30, dateFormat = "yyyy-MM-dd")
private Date expireDate;
/**
* 是否检查库存量
* 如果设置为True则库存不允许为负
*/
private boolean storageCheckFlag;
/** 预留字段1 */
@Excel(name = "预留字段1")
private String attr1;
@ -530,6 +536,14 @@ public class WmTransaction extends BaseEntity
return attr4;
}
public boolean isStorageCheckFlag() {
return storageCheckFlag;
}
public void setStorageCheckFlag(boolean storageCheckFlag) {
this.storageCheckFlag = storageCheckFlag;
}
@Override
public String toString() {
return "WmTransaction{" +
@ -568,6 +582,7 @@ public class WmTransaction extends BaseEntity
", workorderCode='" + workorderCode + '\'' +
", recptDate=" + recptDate +
", expireDate=" + expireDate +
", storageCheckFlag=" + storageCheckFlag +
", attr1='" + attr1 + '\'' +
", attr2='" + attr2 + '\'' +
", attr3=" + attr3 +

View File

@ -0,0 +1,293 @@
package com.ktg.mes.wm.domain.tx;
import com.ktg.common.core.domain.BaseEntity;
import java.math.BigDecimal;
public class ItemConsumeTxBean 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;
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 Long getWorkorderId() {
return workorderId;
}
public void setWorkorderId(Long workorderId) {
this.workorderId = workorderId;
}
public String getWorkorderCode() {
return workorderCode;
}
public void setWorkorderCode(String workorderCode) {
this.workorderCode = workorderCode;
}
/** 事务数量 */
private BigDecimal transactionQuantity;
/** 生产工单ID **/
private Long workorderId;
@Override
public String toString() {
return "ItemConsumeTxBean{" +
"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 +
", workorderId=" + workorderId +
", workorderCode='" + workorderCode + '\'' +
'}';
}
/** 生产工单编号 **/
private String workorderCode;
}

View File

@ -0,0 +1,326 @@
package com.ktg.mes.wm.domain.tx;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ktg.common.annotation.Excel;
import com.ktg.common.core.domain.BaseEntity;
import java.math.BigDecimal;
import java.util.Date;
public class ProductProductTxBean extends BaseEntity {
private static final long serialVersionUID = 1L;
/** 产品物料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;
/** 生产工单ID */
@Excel(name = "生产工单ID")
private Long workorderId;
/** 生产工单编码 */
@Excel(name = "生产工单编码")
private String workorderCode;
/** 生产工单名称 */
@Excel(name = "生产工单名称")
private String workorderName;
/** 生产日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "生产日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date produceDate;
/** 库存有效期 */
@JsonFormat(pattern = "yyyy-MM-dd")
private Date expireDate;
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 Long getWorkorderId() {
return workorderId;
}
public void setWorkorderId(Long workorderId) {
this.workorderId = workorderId;
}
public String getWorkorderCode() {
return workorderCode;
}
public void setWorkorderCode(String workorderCode) {
this.workorderCode = workorderCode;
}
public String getWorkorderName() {
return workorderName;
}
public void setWorkorderName(String workorderName) {
this.workorderName = workorderName;
}
public Date getProduceDate() {
return produceDate;
}
public void setProduceDate(Date produceDate) {
this.produceDate = produceDate;
}
@Override
public String toString() {
return "ProductProductTxBean{" +
"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 +
", workorderId=" + workorderId +
", workorderCode='" + workorderCode + '\'' +
", workorderName='" + workorderName + '\'' +
", produceDate=" + produceDate +
", expireDate=" + expireDate +
'}';
}
public Date getExpireDate() {
return expireDate;
}
public void setExpireDate(Date expireDate) {
this.expireDate = expireDate;
}
}

View File

@ -33,7 +33,7 @@ public class StorageCoreServiceImpl implements IStorageCoreService {
private IWmStorageAreaService wmStorageAreaService;
/**
* 处理入库单行
* 采购入库
* @param lines
*/
@Override
@ -181,6 +181,76 @@ public class StorageCoreServiceImpl implements IStorageCoreService {
}
}
/**
* 库存消耗
*
*/
public void processItemConsume(List<ItemConsumeTxBean> lines){
if(CollUtil.isEmpty(lines)){
throw new BussinessException("没有需要处理的原料消耗单行");
}
String transactionType = UserConstants.TRANSACTION_TYPE_ITEM_CONSUME;
for(int i=0;i<lines.size();i++){
ItemConsumeTxBean line = lines.get(i);
WmTransaction transaction = new WmTransaction();
transaction.setTransactionType(transactionType);
BeanUtils.copyBeanProp(transaction,line);
transaction.setTransactionFlag(-1); //库存减少
transaction.setStorageCheckFlag(false);//库存可以为负
transaction.setTransactionDate(new Date());
WmWarehouse warehouse = wmWarehouseService.selectWmWarehouseByWarehouseCode(UserConstants.VIRTUAL_WH);
transaction.setWarehouseId(warehouse.getWarehouseId());
transaction.setWarehouseCode(warehouse.getWarehouseCode());
transaction.setWarehouseName(warehouse.getWarehouseName());
WmStorageLocation location = wmStorageLocationService.selectWmStorageLocationByLocationCode(UserConstants.VIRTUAL_WS);
transaction.setLocationId(location.getLocationId());
transaction.setLocationCode(location.getLocationCode());
transaction.setLocationName(location.getLocationName());
WmStorageArea area = wmStorageAreaService.selectWmStorageAreaByAreaCode(UserConstants.VIRTUAL_WA);
transaction.setAreaId(area.getAreaId());
transaction.setAreaCode(area.getAreaCode());
transaction.setAreaName(area.getAreaName());
wmTransactionService.processTransaction(transaction);
}
}
/**
* 产品产出
*
*/
public void processProductProduce(List<ProductProductTxBean> lines){
if(CollUtil.isEmpty(lines)){
throw new BussinessException("没有需要处理的产品产出单行");
}
String transactionType = UserConstants.TRANSACTION_TYPE_PRODUCT_PRODUCE;
for(int i=0;i<lines.size();i++){
ProductProductTxBean line = lines.get(i);
WmTransaction transaction = new WmTransaction();
transaction.setTransactionType(transactionType);
BeanUtils.copyBeanProp(transaction,line);
transaction.setTransactionFlag(1); //库存增加
transaction.setTransactionDate(new Date());
WmWarehouse warehouse = wmWarehouseService.selectWmWarehouseByWarehouseCode(UserConstants.VIRTUAL_WH);
transaction.setWarehouseId(warehouse.getWarehouseId());
transaction.setWarehouseCode(warehouse.getWarehouseCode());
transaction.setWarehouseName(warehouse.getWarehouseName());
WmStorageLocation location = wmStorageLocationService.selectWmStorageLocationByLocationCode(UserConstants.VIRTUAL_WS);
transaction.setLocationId(location.getLocationId());
transaction.setLocationCode(location.getLocationCode());
transaction.setLocationName(location.getLocationName());
WmStorageArea area = wmStorageAreaService.selectWmStorageAreaByAreaCode(UserConstants.VIRTUAL_WA);
transaction.setAreaId(area.getAreaId());
transaction.setAreaCode(area.getAreaCode());
transaction.setAreaName(area.getAreaName());
wmTransactionService.processTransaction(transaction);
}
}
/**
* 产品入库
* @param lines
@ -216,6 +286,7 @@ public class StorageCoreServiceImpl implements IStorageCoreService {
transaction_out.setAreaName(area.getAreaName());
transaction_out.setTransactionFlag(-1);//库存减少
transaction_out.setStorageCheckFlag(false); //针对未及时报工的情况允许线边库的库存临时为负
wmTransactionService.processTransaction(transaction_out);
//构造一条目的库存增加的事务

View File

@ -48,7 +48,7 @@ public class WmTransactionServiceImpl implements IWmTransactionService
if(StringUtils.isNotNull(ms)){
//MS已存在
BigDecimal resultQuantity =ms.getQuantityOnhand().add(quantity);
if(resultQuantity.compareTo(new BigDecimal(0))<0){
if(wmTransaction.isStorageCheckFlag() && resultQuantity.compareTo(new BigDecimal(0))<0){
throw new BussinessException("库存数量不足!");
}
stock.setQuantityOnhand(resultQuantity);