feat: inv

dev_2.5_inv
chenhc 5 months ago
parent 7415b0c02d
commit 755c7cddcf

@ -230,15 +230,15 @@ public class InvProductController extends BaseController {
String id = deleteRequest.getId(); String id = deleteRequest.getId();
InvProductEntity invProductEntity = invProductService.findById(id); InvProductEntity invProductEntity = invProductService.findById(id);
if (null != invProductEntity) { if (null != invProductEntity) {
FilterInvProductDetailRequest detailRequest = new FilterInvProductDetailRequest(); // FilterInvProductDetailRequest detailRequest = new FilterInvProductDetailRequest();
detailRequest.setSupId(invProductEntity.getSupId()); // detailRequest.setSupId(invProductEntity.getSupId());
detailRequest.setRelId(String.valueOf(invProductEntity.getRelIdFk())); // detailRequest.setRelId(String.valueOf(invProductEntity.getRelIdFk()));
detailRequest.setInvCode(invProductEntity.getInvCode()); // detailRequest.setInvCode(invProductEntity.getInvCode());
if (StrUtil.isBlank(invProductEntity.getBatchNo())) { // if (StrUtil.isBlank(invProductEntity.getBatchNo())) {
detailRequest.setBatchNo("empty"); // detailRequest.setBatchNo("empty");
} else { // } else {
detailRequest.setBatchNo(invProductEntity.getBatchNo()); // detailRequest.setBatchNo(invProductEntity.getBatchNo());
} // }
invProductService.deleteById(id); invProductService.deleteById(id);
return ResultVOUtils.success("删除成功"); return ResultVOUtils.success("删除成功");
} else { } else {

@ -76,9 +76,9 @@ public class InvProductBatchEntity implements Serializable {
/** /**
* *
*/ */
@TableField(value = "produceDate") @TableField(value = "productionDate")
@ApiModelProperty(value = "生产日期") @ApiModelProperty(value = "生产日期")
private String produceDate; private String productionDate;
/** /**
@ -88,13 +88,20 @@ public class InvProductBatchEntity implements Serializable {
@ApiModelProperty(value = "失效日期") @ApiModelProperty(value = "失效日期")
private String expireDate; private String expireDate;
/**
*
*/
@TableField(value = "outCount")
@ApiModelProperty(value = "出库数量")
private Integer outCount;
/** /**
* *
*/ */
@TableField(value = "invCount") @TableField(value = "inCount")
@ApiModelProperty(value = "入库数量") @ApiModelProperty(value = "入库数量")
private Integer invCount; private Integer inCount;
/** /**
* *
@ -107,9 +114,9 @@ public class InvProductBatchEntity implements Serializable {
/** /**
* ID * ID
*/ */
@TableField(value = "supId") @TableField(value = "customerId")
@ApiModelProperty(value = "供应商ID") @ApiModelProperty(value = "供应商ID")
private String supId; private String customerId;
/** /**
* *
@ -146,5 +153,42 @@ public class InvProductBatchEntity implements Serializable {
private Integer status; private Integer status;
/**
*
*/
@TableField(value = "nowStock")
private Integer nowStock;
/**
*
*/
@TableField(value = "frozenCount")
private Integer frozenCount;
/**
*
*/
@TableField(value = "planInCount")
private Integer planInCount;
/**
*
*/
@TableField(value = "planOutCount")
private Integer planOutCount;
/**
*
*/
@TableField(value = "onWayCount")
private Integer onWayCount;
/**
*
*/
@TableField(value = "availableStock")
private Integer availableStock;
/**
*
*/
private String invSpaceCode;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

@ -12,8 +12,10 @@ import java.util.Date;
@Data @Data
@TableName(value = "inv_product") @TableName(value = "inv_product")
public class InvProductEntity { public class InvProductEntity {
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private Integer id; private Long id;
/** /**
* ID * ID
@ -22,58 +24,25 @@ public class InvProductEntity {
private Long relIdFk; private Long relIdFk;
/** /**
* *
*/ */
@TableField(value = "nameCode") @TableField(value = "supId")
private String nameCode; private String supId;
/**
*
*/
@TableField(value = "batchNo")
private String batchNo;
/** /**
* *
*/ */
@TableField(value = "productionDate") @TableField(value = "reCount")
private String productionDate; private Integer reCount;
/**
*
*/
@TableField(value = "expireDate")
private String expireDate;
/**
*
*/
@TableField(value = "inCount") @TableField(value = "inCount")
private Integer inCount; private Integer inCount;
/**
*
*/
@TableField(value = "outCount")
private int outCount;
/**
*
*/
@TableField(value = "reCount")
private int reCount;
/**
* ID
*/
@TableField(value = "customerId")
private String customerId;
/** @TableField(value = "outCount")
* ID private Integer outCount;
*/
@TableField(value = "supId")
private String supId;
/** /**
* *
@ -93,12 +62,6 @@ public class InvProductEntity {
@TableField(value = "invSpaceCode") @TableField(value = "invSpaceCode")
private String invSpaceCode; private String invSpaceCode;
/**
*
*/
@TableField(value = "createTime")
private Date createTime;
/** /**
* *
@ -106,47 +69,5 @@ public class InvProductEntity {
@TableField(value = "updateTime") @TableField(value = "updateTime")
private Date updateTime; private Date updateTime;
/**
*
*/
@TableField(value = "nowStock")
private Integer nowStock;
/**
*
*/
@TableField(value = "frozenCount")
private Integer frozenCount;
/**
*
*/
@TableField(value = "planInCount")
private Integer planInCount;
/**
*
*/
@TableField(value = "planOutCount")
private Integer planOutCount;
/**
*
*/
@TableField(value = "onWayCount")
private Integer onWayCount;
/**
*
*/
@TableField(value = "availableStock")
private Integer availableStock;
/**
*
*/
@TableField(value = "price")
private BigDecimal price;
@TableField(value = "inBatchNo")
private String inBatchNo;
} }

@ -15,6 +15,7 @@ import com.glxp.api.dao.inout.IoOrderDetailCodeDao;
import com.glxp.api.entity.auth.InvWarehouseEntity; import com.glxp.api.entity.auth.InvWarehouseEntity;
import com.glxp.api.entity.basic.*; import com.glxp.api.entity.basic.*;
import com.glxp.api.entity.inout.*; import com.glxp.api.entity.inout.*;
import com.glxp.api.entity.inv.InvProductBatchEntity;
import com.glxp.api.entity.inv.InvProductEntity; import com.glxp.api.entity.inv.InvProductEntity;
import com.glxp.api.entity.system.SystemParamConfigEntity; import com.glxp.api.entity.system.SystemParamConfigEntity;
import com.glxp.api.req.basic.FilterCompanyProductRelevanceRequest; import com.glxp.api.req.basic.FilterCompanyProductRelevanceRequest;
@ -25,6 +26,7 @@ import com.glxp.api.service.basic.*;
import com.glxp.api.service.inout.impl.IoCodeService; import com.glxp.api.service.inout.impl.IoCodeService;
import com.glxp.api.service.inv.InvPreProductDetailService; import com.glxp.api.service.inv.InvPreProductDetailService;
import com.glxp.api.service.inv.InvPreinProductDetailService; import com.glxp.api.service.inv.InvPreinProductDetailService;
import com.glxp.api.service.inv.impl.InvProductBatchService;
import com.glxp.api.service.inv.impl.InvProductService; import com.glxp.api.service.inv.impl.InvProductService;
import com.glxp.api.service.inv.impl.InvProductServiceNew; import com.glxp.api.service.inv.impl.InvProductServiceNew;
import com.glxp.api.service.system.SystemParamConfigService; import com.glxp.api.service.system.SystemParamConfigService;
@ -33,6 +35,7 @@ import com.glxp.api.util.udi.FilterUdiUtils;
import com.glxp.api.vo.basic.InvProductNewVo; import com.glxp.api.vo.basic.InvProductNewVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
@ -82,6 +85,8 @@ public class IoAddInoutService {
InvProductService invProductService; InvProductService invProductService;
@Resource @Resource
IoCheckInvService checkInvService; IoCheckInvService checkInvService;
@Autowired
private InvProductBatchService invProductBatchService;
//新增扫码单据处理 //新增扫码单据处理
public BaseResponse dealProcess(IoOrderEntity orderEntity) { public BaseResponse dealProcess(IoOrderEntity orderEntity) {
@ -346,56 +351,30 @@ public class IoAddInoutService {
//校验库存 //校验库存
for (IoOrderDetailBizEntity bizEntity : bizEntities) { for (IoOrderDetailBizEntity bizEntity : bizEntities) {
if (StrUtil.isNotEmpty(bizEntity.getBatchNo())) { List<InvProductBatchEntity> invProductBatchEntities = invProductBatchService.selectByRelId(bizEntity.getBindRlFk(), bizEntity.getSupId(), null, orderEntity.getInvCode(),bizEntity.getBatchNo(),null);
List<InvProductEntity> invProductEntities = invProductService.selectByRelId(bizEntity.getBindRlFk(), bizEntity.getSupId(), null, orderEntity.getInvCode()); if (CollUtil.isNotEmpty(invProductBatchEntities)) {
if (CollUtil.isNotEmpty(invProductEntities)) {
int count = 0; int count = 0;
for (InvProductEntity invProductEntity : invProductEntities) { for (InvProductBatchEntity invProductBatchEntity : invProductBatchEntities) {
if (invProductEntity.getReCount() + count > IntUtil.value(bizEntity.getCount())) { if (invProductBatchEntity.getReCount() + count > IntUtil.value(bizEntity.getCount())) {
IoOrderDetailBizEntity orderDetailBizEntity = new IoOrderDetailBizEntity(); IoOrderDetailBizEntity orderDetailBizEntity = new IoOrderDetailBizEntity();
BeanUtils.copyProperties(bizEntity, orderDetailBizEntity); BeanUtils.copyProperties(bizEntity, orderDetailBizEntity);
orderDetailBizEntity.setId(IdUtil.getSnowflakeNextId()); orderDetailBizEntity.setId(IdUtil.getSnowflakeNextId());
orderDetailBizEntity.setBatchNo(invProductBatchEntity.getBatchNo());
newBizList.add(orderDetailBizEntity); newBizList.add(orderDetailBizEntity);
break; break;
} else { } else {
count = invProductEntity.getReCount(); count = invProductBatchEntity.getReCount();
IoOrderDetailBizEntity orderDetailBizEntity = new IoOrderDetailBizEntity(); IoOrderDetailBizEntity orderDetailBizEntity = new IoOrderDetailBizEntity();
BeanUtils.copyProperties(bizEntity, orderDetailBizEntity); BeanUtils.copyProperties(bizEntity, orderDetailBizEntity);
orderDetailBizEntity.setCount(count); orderDetailBizEntity.setCount(count);
orderDetailBizEntity.setId(IdUtil.getSnowflakeNextId()); orderDetailBizEntity.setId(IdUtil.getSnowflakeNextId());
orderDetailBizEntity.setBatchNo(invProductBatchEntity.getBatchNo());
newBizList.add(orderDetailBizEntity); newBizList.add(orderDetailBizEntity);
} }
} }
} else { } else {
newBizList.add(bizEntity); newBizList.add(bizEntity);
} }
} else if (StrUtil.isEmpty(bizEntity.getBatchNo())) {
List<InvProductEntity> invProductEntities = invProductService.selectByRelId(bizEntity.getBindRlFk(), bizEntity.getSupId(), null, orderEntity.getInvCode());
if (CollUtil.isNotEmpty(invProductEntities)) {
int count = 0;
for (InvProductEntity invProductEntity : invProductEntities) {
if (invProductEntity.getReCount() + count > IntUtil.value(bizEntity.getCount())) {
IoOrderDetailBizEntity orderDetailBizEntity = new IoOrderDetailBizEntity();
BeanUtils.copyProperties(bizEntity, orderDetailBizEntity);
orderDetailBizEntity.setId(IdUtil.getSnowflakeNextId());
orderDetailBizEntity.setBatchNo(invProductEntity.getBatchNo());
newBizList.add(orderDetailBizEntity);
break;
} else {
count = invProductEntity.getReCount();
IoOrderDetailBizEntity orderDetailBizEntity = new IoOrderDetailBizEntity();
BeanUtils.copyProperties(bizEntity, orderDetailBizEntity);
orderDetailBizEntity.setCount(count);
orderDetailBizEntity.setId(IdUtil.getSnowflakeNextId());
orderDetailBizEntity.setBatchNo(invProductEntity.getBatchNo());
newBizList.add(orderDetailBizEntity);
}
}
} else {
newBizList.add(bizEntity);
}
}
} }
orderDetailBizService.deleteByOrderId(orderEntity.getBillNo()); orderDetailBizService.deleteByOrderId(orderEntity.getBillNo());
orderDetailBizService.batchInsertBizs(newBizList); orderDetailBizService.batchInsertBizs(newBizList);

@ -77,44 +77,41 @@ public class IoGenInvService {
//生成库存产品表 //生成库存产品表
for (IoOrderDetailResultEntity orderDetailResultEntity : orderDetailResultEntities) { for (IoOrderDetailResultEntity orderDetailResultEntity : orderDetailResultEntities) {
InvProductEntity invProductEntity = invProductService.selectByUnique(orderDetailResultEntity.getBindRlFk(), orderDetailResultEntity.getBatchNo(), orderDetailResultEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), orderDetailResultEntity.getPrice()); InvProductBatchEntity invProductBatchEntity = invProductBatchService.selectByUnique(orderDetailResultEntity.getBindRlFk(),
if (invProductEntity == null) { orderDetailResultEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), orderDetailResultEntity.getBatchNo(), orderDetailResultEntity.getPrice());
invProductEntity = new InvProductEntity(); if (invProductBatchEntity == null) {
invProductEntity.setRelIdFk(orderDetailResultEntity.getBindRlFk()); invProductBatchEntity = new InvProductBatchEntity();
invProductEntity.setNameCode(orderDetailResultEntity.getNameCode()); invProductBatchEntity.setRelIdFk(String.valueOf(orderDetailResultEntity.getBindRlFk()));
invProductEntity.setBatchNo(orderDetailResultEntity.getBatchNo()); invProductBatchEntity.setNameCode(orderDetailResultEntity.getNameCode());
invProductEntity.setProductionDate(orderDetailResultEntity.getProductDate()); invProductBatchEntity.setBatchNo(orderDetailResultEntity.getBatchNo());
invProductEntity.setExpireDate(orderDetailResultEntity.getExpireDate()); invProductBatchEntity.setProductionDate(orderDetailResultEntity.getProductDate());
invProductEntity.setInCount(0); invProductBatchEntity.setExpireDate(orderDetailResultEntity.getExpireDate());
invProductEntity.setOutCount(0); invProductBatchEntity.setOutCount(0);
invProductEntity.setSupId(orderDetailResultEntity.getSupId()); invProductBatchEntity.setInCount(0);
invProductEntity.setDeptCode(orderEntity.getDeptCode()); invProductBatchEntity.setReCount(0);
invProductEntity.setInvCode(orderEntity.getInvCode()); invProductBatchEntity.setCustomerId(orderDetailResultEntity.getSupId());
invProductEntity.setCreateTime(new Date()); invProductBatchEntity.setDeptCode(orderEntity.getDeptCode());
invProductEntity.setUpdateTime(new Date()); invProductBatchEntity.setInvCode(orderEntity.getInvCode());
invProductEntity.setPrice(orderDetailResultEntity.getPrice()); invProductBatchEntity.setCreateTime(new Date());
invProductBatchEntity.setUpdateTime(new Date());
invProductBatchEntity.setPrice(orderDetailResultEntity.getPrice());
//添加产品表入院批次号 //添加产品表入院批次号
invProductEntity.setInBatchNo(orderEntity.getBillNo().substring(orderEntity.getBillNo().length() - 12)); invProductBatchEntity.setInBatchNo(orderEntity.getBillNo().substring(orderEntity.getBillNo().length() - 12));
invProductService.insert(invProductEntity);
} }
if (orderEntity.getMainAction().equals(ConstantType.TYPE_OUT)) { if (orderEntity.getMainAction().equals(ConstantType.TYPE_OUT)) {
invProductEntity.setOutCount(invProductEntity.getOutCount() + orderDetailResultEntity.getCount()); invProductBatchEntity.setOutCount(invProductBatchEntity.getOutCount() + orderDetailResultEntity.getReCount());
} else if (orderEntity.getMainAction().equals(ConstantType.TYPE_PUT)) { } else if (orderEntity.getMainAction().equals(ConstantType.TYPE_PUT)) {
invProductEntity.setInCount(invProductEntity.getInCount() + orderDetailResultEntity.getCount()); invProductBatchEntity.setInCount(invProductBatchEntity.getInCount() + orderDetailResultEntity.getReCount());
} }
invProductEntity.setReCount(invProductEntity.getInCount() - invProductEntity.getOutCount()); invProductBatchEntity.setReCount(invProductBatchEntity.getInCount() - invProductBatchEntity.getOutCount());
invProductEntity.setUpdateTime(new Date()); invProductBatchEntity.setUpdateTime(new Date());
invProductService.update(invProductEntity);
InvProductBatchEntity batchEntity = new InvProductBatchEntity(); batchEntities.add(invProductBatchEntity);
BeanUtils.copyProperties(invProductEntity, batchEntity);
batchEntity.setId(null);
batchEntities.add(batchEntity);
} }
if (CollUtil.isNotEmpty(batchEntities)) { if (CollUtil.isNotEmpty(batchEntities)) {
invProductBatchService.saveBatch(batchEntities); invProductBatchService.saveBatchEvent(batchEntities,bussinessTypeEntity.getMainAction());
} }
BasicBusTypePreEntity basicBusTypePreEntity = basicBusTypePreService.findByOriginAction(orderEntity.getAction()); BasicBusTypePreEntity basicBusTypePreEntity = basicBusTypePreService.findByOriginAction(orderEntity.getAction());

@ -46,6 +46,7 @@ import com.glxp.api.service.inv.InvPreProductDetailService;
import com.glxp.api.service.inv.InvPreProductService; import com.glxp.api.service.inv.InvPreProductService;
import com.glxp.api.service.inv.InvPreinProductDetailService; import com.glxp.api.service.inv.InvPreinProductDetailService;
import com.glxp.api.service.inv.InvPreinProductService; import com.glxp.api.service.inv.InvPreinProductService;
import com.glxp.api.service.inv.impl.InvProductBatchService;
import com.glxp.api.service.inv.impl.InvProductService; import com.glxp.api.service.inv.impl.InvProductService;
import com.glxp.api.service.inv.impl.InvProductServiceNew; import com.glxp.api.service.inv.impl.InvProductServiceNew;
import com.glxp.api.service.system.SyncUploadDataBustypeService; import com.glxp.api.service.system.SyncUploadDataBustypeService;
@ -59,6 +60,7 @@ import com.glxp.api.vo.basic.InvProductNewVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -112,6 +114,8 @@ public class IoOrderServiceImpl implements IoOrderService {
private HttpOkClient httpOkClient; private HttpOkClient httpOkClient;
@Resource @Resource
private BasicCorpDao basicCorpDao; private BasicCorpDao basicCorpDao;
@Autowired
private InvProductBatchService invProductBatchService;
@Override @Override
public List<IoOrderEntity> selectAll() { public List<IoOrderEntity> selectAll() {
@ -289,23 +293,25 @@ public class IoOrderServiceImpl implements IoOrderService {
//删除普通库存 //删除普通库存
List<InvProductNewVo> invProductDetailEntities = invProductServiceNew.selectByOrderIdFk(billNo); List<InvProductNewVo> invProductDetailEntities = invProductServiceNew.selectByOrderIdFk(billNo);
if (CollUtil.isNotEmpty(invProductDetailEntities)) { if (CollUtil.isNotEmpty(invProductDetailEntities)) {
List<InvProductBatchEntity> batchEntities = new ArrayList<>();
for (InvProductNewVo invProductDetailEntity : invProductDetailEntities) { for (InvProductNewVo invProductDetailEntity : invProductDetailEntities) {
//更新库存 //更新库存
InvProductEntity invProductEntity = invProductService.selectByUnique(invProductDetailEntity.getRelIdFk(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(), invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode(), invProductDetailEntity.getPrice()); InvProductBatchEntity invProductBatchEntity = invProductBatchService.selectByUnique(invProductDetailEntity.getRelIdFk(),
if (invProductEntity != null) { invProductDetailEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getPrice());
if (invProductBatchEntity != null) {
if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) { if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
int count = invProductEntity.getInCount() - invProductDetailEntity.getReCount(); int count = invProductBatchEntity.getInCount() - invProductDetailEntity.getReCount();
invProductEntity.setInCount(count); invProductBatchEntity.setInCount(count);
} else if (ConstantType.TYPE_OUT.equals(invProductDetailEntity.getMainAction())) { } else if (ConstantType.TYPE_OUT.equals(invProductDetailEntity.getMainAction())) {
int count = invProductEntity.getOutCount() - invProductDetailEntity.getReCount(); int count = invProductBatchEntity.getOutCount() - invProductDetailEntity.getReCount();
invProductEntity.setOutCount(count); invProductBatchEntity.setOutCount(count);
} }
//计算实际数量 //计算实际数量
invProductEntity.setReCount(invProductEntity.getInCount() - invProductEntity.getOutCount()); invProductBatchEntity.setReCount(invProductBatchEntity.getInCount() - invProductBatchEntity.getOutCount());
invProductService.update(invProductEntity); batchEntities.add(invProductBatchEntity);
} }
} }
invProductBatchService.saveBatchEvent(batchEntities,basicBussinessTypeEntity.getMainAction());
} }
} }
} }
@ -449,21 +455,28 @@ public class IoOrderServiceImpl implements IoOrderService {
InvProductNewVo invProductDetailEntity = invProductServiceNew.selectByCode(codeEntity.getOrderId(), codeEntity.getCode(), codeEntity.getPrice()); InvProductNewVo invProductDetailEntity = invProductServiceNew.selectByCode(codeEntity.getOrderId(), codeEntity.getCode(), codeEntity.getPrice());
if (invProductDetailEntity != null) { if (invProductDetailEntity != null) {
List<InvProductBatchEntity> batchEntities = new ArrayList<>();
//更新产品表 //更新产品表
InvProductEntity invProductEntity = invProductService.selectByUnique(invProductDetailEntity.getRelIdFk(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(), InvProductBatchEntity invProductBatchEntity = invProductBatchService.selectByUnique(invProductDetailEntity.getRelIdFk(),
invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode(), invProductDetailEntity.getPrice()); invProductDetailEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getPrice());
if (invProductEntity != null) { if (invProductBatchEntity != null) {
if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) { if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
int inCount = invProductEntity.getInCount() - remainScanCount; int count = invProductBatchEntity.getInCount() - remainScanCount;
invProductEntity.setInCount(inCount); invProductBatchEntity.setInCount(count);
} else if (ConstantType.TYPE_OUT.equals(invProductDetailEntity.getMainAction())) { } else if (ConstantType.TYPE_OUT.equals(invProductDetailEntity.getMainAction())) {
int outCount = invProductEntity.getOutCount() - remainScanCount; int count = invProductBatchEntity.getOutCount() - remainScanCount;
invProductEntity.setOutCount(outCount); invProductBatchEntity.setOutCount(count);
} }
invProductEntity.setReCount(invProductEntity.getInCount() - invProductEntity.getOutCount()); //计算实际数量
invProductBatchEntity.setReCount(invProductBatchEntity.getInCount() - invProductBatchEntity.getOutCount());
batchEntities.add(invProductBatchEntity);
} }
invProductService.update(invProductEntity);
invProductBatchService.saveBatchEvent(batchEntities,basicBussinessTypeEntity.getMainAction());
} }
} }
@ -556,20 +569,25 @@ public class IoOrderServiceImpl implements IoOrderService {
} else { } else {
List<InvProductNewVo> invProductDetailEntities = invProductServiceNew.selectByOrderIdFk(billNo); List<InvProductNewVo> invProductDetailEntities = invProductServiceNew.selectByOrderIdFk(billNo);
if (CollUtil.isNotEmpty(invProductDetailEntities)) { if (CollUtil.isNotEmpty(invProductDetailEntities)) {
List<InvProductBatchEntity> batchEntities = new ArrayList<>();
for (InvProductNewVo invProductDetailEntity : invProductDetailEntities) { for (InvProductNewVo invProductDetailEntity : invProductDetailEntities) {
InvProductEntity invProductEntity = invProductService.selectByUnique(invProductDetailEntity.getRelIdFk(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(), //更新库存
invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode(), invProductDetailEntity.getPrice()); InvProductBatchEntity invProductBatchEntity = invProductBatchService.selectByUnique(invProductDetailEntity.getRelIdFk(),
invProductDetailEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getPrice());
if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) { if (invProductBatchEntity != null) {
int count = invProductEntity.getInCount() - invProductDetailEntity.getReCount(); if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
invProductEntity.setInCount(count); int count = invProductBatchEntity.getInCount() - invProductDetailEntity.getReCount();
} else if (ConstantType.TYPE_OUT.equals(invProductDetailEntity.getMainAction())) { invProductBatchEntity.setInCount(count);
int count = invProductEntity.getOutCount() - invProductDetailEntity.getReCount(); } else if (ConstantType.TYPE_OUT.equals(invProductDetailEntity.getMainAction())) {
invProductEntity.setOutCount(count); int count = invProductBatchEntity.getOutCount() - invProductDetailEntity.getReCount();
invProductBatchEntity.setOutCount(count);
}
//计算实际数量
invProductBatchEntity.setReCount(invProductBatchEntity.getInCount() - invProductBatchEntity.getOutCount());
batchEntities.add(invProductBatchEntity);
} }
invProductEntity.setReCount(invProductEntity.getInCount() - invProductEntity.getOutCount());
invProductService.update(invProductEntity);
} }
invProductBatchService.saveBatchEvent(batchEntities,bussinessTypeEntity.getMainAction());
} }
} }
@ -1040,7 +1058,7 @@ public class IoOrderServiceImpl implements IoOrderService {
} }
@Override @Override
public IoOrderResponse findByWorkPlaceCode(String workPlaceCode,String getWorkPlaceQueueCode,Long userId,String action,Integer fifoSplitTag) { public IoOrderResponse findByWorkPlaceCode(String workPlaceCode, String getWorkPlaceQueueCode, Long userId, String action, Integer fifoSplitTag) {
//根据用户和状态查找处理中的订单查询单据表 //根据用户和状态查找处理中的订单查询单据表
FilterOrderRequest filterOrderRequest = new FilterOrderRequest(); FilterOrderRequest filterOrderRequest = new FilterOrderRequest();
filterOrderRequest.setWorkPlaceCode(workPlaceCode); filterOrderRequest.setWorkPlaceCode(workPlaceCode);
@ -1050,11 +1068,11 @@ public class IoOrderServiceImpl implements IoOrderService {
filterOrderRequest.setFifoSplitTag(fifoSplitTag); filterOrderRequest.setFifoSplitTag(fifoSplitTag);
List<IoOrderResponse> ioOrderResponses = orderDao.filterList(filterOrderRequest); List<IoOrderResponse> ioOrderResponses = orderDao.filterList(filterOrderRequest);
if (ioOrderResponses.size() > 0){ if (ioOrderResponses.size() > 0) {
IoOrderResponse ioOrderResponse = ioOrderResponses.get(0); IoOrderResponse ioOrderResponse = ioOrderResponses.get(0);
return ioOrderResponse; return ioOrderResponse;
} }
return null; return null;
} }
@ -1119,59 +1137,65 @@ public class IoOrderServiceImpl implements IoOrderService {
return orderDao.getfilterOrderList(filterOrderRequest); return orderDao.getfilterOrderList(filterOrderRequest);
} }
public Boolean setInvProductEntityList(List<IoOrderDetailResultEntity> ioOrderDetailResultEntityList, IoOrderEntity ioOrderEntity) { public Boolean setInvProductEntityList(List<IoOrderDetailResultEntity> ioOrderDetailResultEntityList, IoOrderEntity orderEntity) {
for (IoOrderDetailResultEntity ioOrderDetailResultEntity : ioOrderDetailResultEntityList) { for (IoOrderDetailResultEntity orderDetailResultEntity : ioOrderDetailResultEntityList) {
//查询该产品是不是存在 //查询该产品是不是存在
InvProductEntity invProductEntity = invProductService.selectByUnique(ioOrderDetailResultEntity.getBindRlFk(), ioOrderDetailResultEntity.getBatchNo(), InvProductBatchEntity invProductBatchEntity = invProductBatchService.selectByUnique(orderDetailResultEntity.getBindRlFk(),
ioOrderDetailResultEntity.getSupId(), ioOrderEntity.getDeptCode(), ioOrderEntity.getInvCode(), ioOrderDetailResultEntity.getPrice()); orderDetailResultEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), orderDetailResultEntity.getBatchNo(), orderDetailResultEntity.getPrice());
if (invProductEntity == null) { if (invProductBatchEntity == null) {
//没有该产品就填充数据 invProductBatchEntity = new InvProductBatchEntity();
invProductEntity = new InvProductEntity(); invProductBatchEntity.setRelIdFk(String.valueOf(orderDetailResultEntity.getBindRlFk()));
invProductEntity.setRelIdFk(ioOrderDetailResultEntity.getBindRlFk()); invProductBatchEntity.setNameCode(orderDetailResultEntity.getNameCode());
invProductEntity.setNameCode(ioOrderDetailResultEntity.getNameCode()); invProductBatchEntity.setBatchNo(orderDetailResultEntity.getBatchNo());
invProductEntity.setBatchNo(ioOrderDetailResultEntity.getBatchNo()); invProductBatchEntity.setProductionDate(orderDetailResultEntity.getProductDate());
invProductEntity.setProductionDate(ioOrderDetailResultEntity.getProductDate()); invProductBatchEntity.setExpireDate(orderDetailResultEntity.getExpireDate());
invProductEntity.setExpireDate(ioOrderDetailResultEntity.getExpireDate()); invProductBatchEntity.setOutCount(0);
invProductEntity.setInCount(0); invProductBatchEntity.setInCount(0);
invProductEntity.setOutCount(0); invProductBatchEntity.setReCount(0);
invProductEntity.setSupId(ioOrderDetailResultEntity.getSupId()); invProductBatchEntity.setCustomerId(orderDetailResultEntity.getSupId());
invProductEntity.setDeptCode(ioOrderEntity.getDeptCode()); invProductBatchEntity.setDeptCode(orderEntity.getDeptCode());
invProductEntity.setInvCode(ioOrderEntity.getInvCode()); invProductBatchEntity.setInvCode(orderEntity.getInvCode());
invProductEntity.setPrice(ioOrderDetailResultEntity.getPrice()); invProductBatchEntity.setCreateTime(new Date());
invProductEntity.setCreateTime(new Date()); invProductBatchEntity.setUpdateTime(new Date());
invProductEntity.setUpdateTime(new Date()); invProductBatchEntity.setNowStock(0); //现存量
invProductEntity.setNowStock(0); //现存量 invProductBatchEntity.setFrozenCount(0); //冻结量
invProductEntity.setFrozenCount(0); //冻结量 invProductBatchEntity.setPlanInCount(0);//预计入库量
invProductEntity.setPlanInCount(0);//预计入库量 invProductBatchEntity.setPlanOutCount(0);//预计出库量
invProductEntity.setPlanOutCount(0);//预计出库量 invProductBatchEntity.setOnWayCount(0);//在途库存
invProductEntity.setOnWayCount(0);//在途库存 invProductBatchEntity.setAvailableStock(0);//可用库存
invProductEntity.setAvailableStock(0);//可用库存 invProductBatchEntity.setPrice(orderDetailResultEntity.getPrice());
//添加产品表入院批次号
invProductBatchEntity.setInBatchNo(orderEntity.getBillNo().substring(orderEntity.getBillNo().length() - 12));
} }
if (ioOrderEntity.getMainAction().equals(ConstantType.TYPE_PUT)) {
//出库
if (ioOrderEntity.getStatus() == ConstantStatus.ORDER_STATUS_CHECK_SUCCESS) { if (orderEntity.getMainAction().equals(ConstantType.TYPE_OUT)) {
invProductEntity.setPlanOutCount((invProductEntity.getPlanOutCount() != null ? invProductEntity.getPlanOutCount() : 0) + ioOrderDetailResultEntity.getReCount());//预计出库量 if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_CHECK_SUCCESS) {
invProductEntity.setFrozenCount((invProductEntity.getFrozenCount() != null ? invProductEntity.getFrozenCount() : 0) + ioOrderDetailResultEntity.getReCount());//预计出库量 invProductBatchEntity.setPlanOutCount((invProductBatchEntity.getPlanOutCount() != null ? invProductBatchEntity.getPlanOutCount() : 0) + orderDetailResultEntity.getReCount());//预计出库量
} else if (ioOrderEntity.getStatus() == ConstantStatus.ORDER_STATUS_AUDITED) { invProductBatchEntity.setFrozenCount((invProductBatchEntity.getFrozenCount() != null ? invProductBatchEntity.getFrozenCount() : 0) + orderDetailResultEntity.getReCount());//预计出库量
invProductEntity.setPlanOutCount((invProductEntity.getPlanOutCount() != null ? invProductEntity.getPlanOutCount() : 0) - ioOrderDetailResultEntity.getReCount());//预计出库量 } else if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_AUDITED) {
invProductEntity.setFrozenCount((invProductEntity.getFrozenCount() != null ? invProductEntity.getFrozenCount() : 0) - ioOrderDetailResultEntity.getReCount());//预计出库量 invProductBatchEntity.setPlanOutCount((invProductBatchEntity.getPlanOutCount() != null ? invProductBatchEntity.getPlanOutCount() : 0) - orderDetailResultEntity.getReCount());//预计出库量
invProductBatchEntity.setFrozenCount((invProductBatchEntity.getFrozenCount() != null ? invProductBatchEntity.getFrozenCount() : 0) - orderDetailResultEntity.getReCount());//预计出库量
} }
} else if (ioOrderEntity.getMainAction().equals(ConstantType.TYPE_OUT)) {
} else if (orderEntity.getMainAction().equals(ConstantType.TYPE_PUT)) {
//入库 //入库
if (ioOrderEntity.getStatus() == ConstantStatus.ORDER_STATUS_CHECK_SUCCESS) { if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_CHECK_SUCCESS) {
invProductEntity.setPlanInCount((invProductEntity.getInCount() != null ? invProductEntity.getInCount() : 0) + ioOrderDetailResultEntity.getReCount());//预计出库量 invProductBatchEntity.setPlanInCount((invProductBatchEntity.getInCount() != null ? invProductBatchEntity.getInCount() : 0) + orderDetailResultEntity.getReCount());//预计出库量
} else if (ioOrderEntity.getStatus() == ConstantStatus.ORDER_STATUS_AUDITED) { } else if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_AUDITED) {
invProductEntity.setPlanInCount((invProductEntity.getInCount() != null ? invProductEntity.getInCount() : 0) - ioOrderDetailResultEntity.getReCount());//预计出库量 invProductBatchEntity.setPlanInCount((invProductBatchEntity.getInCount() != null ? invProductBatchEntity.getInCount() : 0) - orderDetailResultEntity.getReCount());//预计出库量
} }
} }
//判断有没有id走插入或者更新方法 //判断有没有id走插入或者更新方法
if (invProductEntity.getId() == null) { if (invProductBatchEntity.getId() == null) {
invProductService.insert(invProductEntity); invProductBatchService.save(invProductBatchEntity);
} else { } else {
invProductService.update(invProductEntity); invProductBatchService.updateById(invProductBatchEntity);
} }
} }
return true; return true;
} }

@ -1,9 +1,14 @@
package com.glxp.api.service.inv.impl; package com.glxp.api.service.inv.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.glxp.api.constant.ConstantType;
import com.glxp.api.dao.inv.InvProductBatchDao; import com.glxp.api.dao.inv.InvProductBatchDao;
import com.glxp.api.dao.inv.InvProductRecordMapper; import com.glxp.api.dao.inv.InvProductRecordMapper;
import com.glxp.api.entity.basic.BasicBussinessTypeEntity;
import com.glxp.api.entity.inv.InvProductEntity;
import com.glxp.api.entity.inv.InvProductRecord; import com.glxp.api.entity.inv.InvProductRecord;
import com.glxp.api.entity.inv.InventoryBatchAllocation; import com.glxp.api.entity.inv.InventoryBatchAllocation;
import com.glxp.api.entity.inout.IoOrderDetailResultEntity; import com.glxp.api.entity.inout.IoOrderDetailResultEntity;
@ -16,9 +21,13 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service @Service
@ -27,13 +36,15 @@ public class InvProductBatchService extends ServiceImpl<InvProductBatchDao, InvP
@Resource @Resource
private InvProductBatchDao inventoryBatchMapper; InvProductBatchDao invProductBatchDao;
@Resource @Resource
InvProductRecordService inventoryRecordService; InvProductRecordService inventoryRecordService;
@Resource
InvProductService invProductService;
public Long createInventoryBatch(InvProductBatchEntity inventoryBatchDO) { public Long createInventoryBatch(InvProductBatchEntity inventoryBatchDO) {
// 插入 // 插入
inventoryBatchMapper.insert(inventoryBatchDO); invProductBatchDao.insert(inventoryBatchDO);
// 返回 // 返回
return inventoryBatchDO.getId(); return inventoryBatchDO.getId();
} }
@ -42,18 +53,18 @@ public class InvProductBatchService extends ServiceImpl<InvProductBatchDao, InvP
// 校验存在 // 校验存在
validateInventoryBatchExists(inventoryBatchDO.getId()); validateInventoryBatchExists(inventoryBatchDO.getId());
// 更新 // 更新
inventoryBatchMapper.updateById(inventoryBatchDO); invProductBatchDao.updateById(inventoryBatchDO);
} }
public void deleteInventoryBatch(Long id) { public void deleteInventoryBatch(Long id) {
// 校验存在 // 校验存在
validateInventoryBatchExists(id); validateInventoryBatchExists(id);
// 删除 // 删除
inventoryBatchMapper.deleteById(id); invProductBatchDao.deleteById(id);
} }
private void validateInventoryBatchExists(Long id) { private void validateInventoryBatchExists(Long id) {
if (inventoryBatchMapper.selectById(id) == null) { if (invProductBatchDao.selectById(id) == null) {
throw new JsonException("库存不存在"); throw new JsonException("库存不存在");
} }
} }
@ -64,7 +75,7 @@ public class InvProductBatchService extends ServiceImpl<InvProductBatchDao, InvP
*/ */
public List<InventoryBatchAllocation> selectBatchesByFIFO(Long productId, Long warehouseId, Integer requiredQuantity) { public List<InventoryBatchAllocation> selectBatchesByFIFO(Long productId, Long warehouseId, Integer requiredQuantity) {
// 1. 按入库时间正序查询可用批次 // 1. 按入库时间正序查询可用批次
List<InvProductBatchEntity> availableBatches = inventoryBatchMapper.selectList(new LambdaQueryWrapper<InvProductBatchEntity>() List<InvProductBatchEntity> availableBatches = invProductBatchDao.selectList(new LambdaQueryWrapper<InvProductBatchEntity>()
.eq(InvProductBatchEntity::getRelIdFk, productId) .eq(InvProductBatchEntity::getRelIdFk, productId)
.eq(InvProductBatchEntity::getInvCode, warehouseId) .eq(InvProductBatchEntity::getInvCode, warehouseId)
.gt(InvProductBatchEntity::getReCount, 0) // 修正数量大于0的批次 .gt(InvProductBatchEntity::getReCount, 0) // 修正数量大于0的批次
@ -114,14 +125,11 @@ public class InvProductBatchService extends ServiceImpl<InvProductBatchDao, InvP
updateInventoryBatch(batchDO); updateInventoryBatch(batchDO);
// 创建出库流水 // 创建出库流水
createOutboundRecord(order, item, allocation); createOutboundRecord(order, item, allocation);
}
// 3. 更新主表库存 //更新主表库存inv_product
int totalOutQuantity = allocations.stream() invProductService.updateInvProduct(batchDO.getRelIdFk(),batchDO.getCustomerId(),batchDO.getInvCode(),batchDO.getDeptCode(),allocation.getAllocatedQuantity());
.mapToInt(InventoryBatchAllocation::getAllocatedQuantity)
.sum();
// todo 更新inv_product 主表
}
} }
@ -177,7 +185,7 @@ public class InvProductBatchService extends ServiceImpl<InvProductBatchDao, InvP
private void validateExpiry(List<IoOrderDetailResultEntity> items, IoOrderEntity orderDO) { private void validateExpiry(List<IoOrderDetailResultEntity> items, IoOrderEntity orderDO) {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
for (IoOrderDetailResultEntity item : items) { for (IoOrderDetailResultEntity item : items) {
List<InvProductBatchEntity> batches = inventoryBatchMapper.selectList( List<InvProductBatchEntity> batches = invProductBatchDao.selectList(
new LambdaQueryWrapper<InvProductBatchEntity>() new LambdaQueryWrapper<InvProductBatchEntity>()
.eq(InvProductBatchEntity::getRelIdFk, item.getBindRlFk()) .eq(InvProductBatchEntity::getRelIdFk, item.getBindRlFk())
.eq(InvProductBatchEntity::getInvCode, orderDO.getWarehouseId()) .eq(InvProductBatchEntity::getInvCode, orderDO.getWarehouseId())
@ -223,4 +231,73 @@ public class InvProductBatchService extends ServiceImpl<InvProductBatchDao, InvP
} }
public List<InvProductBatchEntity> selectByRelId(Long relId, String supId, String deptCode, String invCode, String batchNo, BigDecimal price) {
return invProductBatchDao.selectList(new QueryWrapper<InvProductBatchEntity>()
.eq("relIdFk", relId)
.eq("supId", supId)
.eq(StrUtil.isNotEmpty(deptCode), "deptCode", deptCode)
.eq(StrUtil.isNotEmpty(batchNo), "batch", batchNo)
.eq(price != null, "price", price)
.eq("invCode", invCode).gt("reCount", 0)
.orderByAsc("inBatchNo")
);
}
public InvProductBatchEntity selectByUnique(Long relId, String supId, String deptCode, String invCode, String batchNo, BigDecimal price) {
InvProductBatchEntity invProductBatchEntity = invProductBatchDao.selectOne(new QueryWrapper<InvProductBatchEntity>()
.eq("relIdFk", relId)
.eq("supId", supId)
.eq(StrUtil.isNotEmpty(deptCode), "deptCode", deptCode)
.eq(StrUtil.isNotEmpty(batchNo), "batchNo", batchNo)
.eq(price != null, "price", price)
.eq("invCode", invCode).gt("reCount", 0).or().gt("planInCount", 0).or().gt("planOutCount", 0)
.orderByAsc("inBatchNo").last("limit 1"));
return invProductBatchEntity;
}
public boolean saveBatchEvent(List<InvProductBatchEntity> batchEntities,String mainAction) {
List<InvProductEntity> invProductSaveOrUpdateBatch = new ArrayList<>();
for (int i = 0; i < batchEntities.size(); i++) {
InvProductBatchEntity invProductBatchEntity = batchEntities.get(i);
//检查是否有生成主表
InvProductEntity invProductEntity = invProductService.selectByUnique(invProductBatchEntity.getRelIdFk(), invProductBatchEntity.getCustomerId(), invProductBatchEntity.getDeptCode(), invProductBatchEntity.getInvCode(), null);
if (invProductEntity == null) {
invProductEntity = new InvProductEntity();
invProductEntity.setRelIdFk(Long.valueOf(invProductBatchEntity.getRelIdFk()));
invProductEntity.setInCount(0);
invProductEntity.setOutCount(0);
invProductEntity.setReCount(0);
invProductEntity.setSupId(invProductBatchEntity.getCustomerId());
invProductEntity.setDeptCode(invProductBatchEntity.getDeptCode());
invProductEntity.setInvCode(invProductBatchEntity.getInvCode());
}
if (ConstantType.TYPE_PUT.equals(mainAction)) {
invProductEntity.setInCount(invProductEntity.getInCount() + invProductBatchEntity.getInCount());
invProductEntity.setReCount(invProductEntity.getInCount() - invProductEntity.getOutCount());
} else if (ConstantType.TYPE_OUT.equals(mainAction)) {
invProductEntity.setOutCount(invProductEntity.getOutCount() + invProductBatchEntity.getOutCount());
invProductEntity.setReCount(invProductEntity.getInCount() - invProductEntity.getOutCount());
}
invProductBatchEntity.setStatus(invProductBatchEntity.getReCount() > 0 ? 1 : 0);
invProductEntity.setUpdateTime(new Date());
invProductSaveOrUpdateBatch.add(invProductEntity);
}
invProductService.saveOrUpdateBatch(invProductSaveOrUpdateBatch);
return saveOrUpdateBatch(batchEntities);
}
public List<InvProductBatchEntity> selectInvProductInfo(String invCode, String invSpaceCode, String relId) {
return invProductBatchDao.selectList(new QueryWrapper<InvProductBatchEntity>()
.eq("relIdFk", relId)
.eq(StrUtil.isNotEmpty(invSpaceCode), "invSpaceCode", invSpaceCode)
.eq(StrUtil.isNotEmpty(invCode), "invCode", invCode)
.orderByAsc("inBatchNo")
);
}
} }

@ -6,7 +6,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.glxp.api.dao.inv.InvProductDao; import com.glxp.api.dao.inv.InvProductDao;
import com.glxp.api.dao.inv.InvProductNewDao; import com.glxp.api.dao.inv.InvProductNewDao;
import com.glxp.api.entity.basic.BasicBussinessTypeEntity;
import com.glxp.api.entity.inv.InvProductEntity; import com.glxp.api.entity.inv.InvProductEntity;
import com.glxp.api.exception.JsonException;
import com.glxp.api.req.inv.FilterInvProductRequest; import com.glxp.api.req.inv.FilterInvProductRequest;
import com.glxp.api.res.inv.InvProductResponse; import com.glxp.api.res.inv.InvProductResponse;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -38,13 +40,14 @@ public class InvProductService extends ServiceImpl<InvProductDao, InvProductEnti
} }
public InvProductEntity selectByUnique(Long relId, String batchNo, String supId, String deptCode, String invCode, BigDecimal price) { public InvProductEntity selectByUnique(String relIdFk, String supId, String deptCode, String invCode, String invSpaceCode) {
return invProductDao.selectOne(new QueryWrapper<InvProductEntity>().eq("relIdFk", relId) return invProductDao.selectOne(new QueryWrapper<InvProductEntity>()
.eq(StrUtil.isNotBlank(batchNo), "batchNo", batchNo).isNull(StrUtil.isEmpty(batchNo), "batchNo") .eq(StrUtil.isNotBlank(relIdFk),"relIdFk", relIdFk)
.eq("supId", supId) .eq(StrUtil.isNotBlank(supId),"supId", supId)
.eq(StrUtil.isNotBlank(deptCode),"deptCode", deptCode) .eq(StrUtil.isNotBlank(deptCode),"deptCode", deptCode)
.eq("invCode", invCode) .eq(StrUtil.isNotBlank(invCode),"invCode", invCode)
.eq(price != null, "price", price).isNull(price == null, "price").last("limit 1") .eq(StrUtil.isNotBlank(invSpaceCode),"invSpaceCode", invSpaceCode)
.last("limit 1")
); );
} }
@ -189,6 +192,19 @@ public class InvProductService extends ServiceImpl<InvProductDao, InvProductEnti
} }
public void updateInvProduct(String relIdFk, String supId, String invCode, String deptCode,Integer allocatedQuantity) {
InvProductEntity invProductEntity = selectByUnique(relIdFk, supId, deptCode, invCode, null);
if (null == invProductEntity) {
throw new JsonException("主库存记录表,不存在字典外键:["+relIdFk+"]");
}
//库存剩余数量
int reCount = invProductEntity.getReCount();
if (reCount < allocatedQuantity){
throw new JsonException("主库存记录表,库存不足["+relIdFk+"]");
}
invProductEntity.setReCount(reCount - allocatedQuantity);
update(invProductEntity);
}
} }

@ -9,9 +9,11 @@ import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils; import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.dao.basic.UdiRelevanceDao; import com.glxp.api.dao.basic.UdiRelevanceDao;
import com.glxp.api.dao.inv.InvProductBatchDao;
import com.glxp.api.dao.inv.InvProductDao; import com.glxp.api.dao.inv.InvProductDao;
import com.glxp.api.dao.inv.InvRemindMsgDao; import com.glxp.api.dao.inv.InvRemindMsgDao;
import com.glxp.api.entity.basic.UdiRelevanceEntity; import com.glxp.api.entity.basic.UdiRelevanceEntity;
import com.glxp.api.entity.inv.InvProductBatchEntity;
import com.glxp.api.entity.inv.InvProductEntity; import com.glxp.api.entity.inv.InvProductEntity;
import com.glxp.api.entity.inv.InvRemindMsgEntity; import com.glxp.api.entity.inv.InvRemindMsgEntity;
import com.glxp.api.entity.inv.InvRemindSetEntity; import com.glxp.api.entity.inv.InvRemindSetEntity;
@ -20,6 +22,7 @@ import com.glxp.api.res.inv.InvRemindMsgResponse;
import com.glxp.api.service.inv.InvRemindMsgService; import com.glxp.api.service.inv.InvRemindMsgService;
import com.glxp.api.util.MsDateUtil; import com.glxp.api.util.MsDateUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -40,6 +43,10 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService {
private InvProductDao invProductDao; private InvProductDao invProductDao;
@Resource @Resource
private UdiRelevanceDao udiRelevanceDao; private UdiRelevanceDao udiRelevanceDao;
@Autowired
private InvProductBatchDao invProductBatchDao;
@Autowired
private InvProductBatchService invProductBatchService;
@Override @Override
public List<InvRemindMsgResponse> filterList(FilterInvRemindMsgRequest filterInvRemindMsgRequest) { public List<InvRemindMsgResponse> filterList(FilterInvRemindMsgRequest filterInvRemindMsgRequest) {
@ -71,38 +78,38 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService {
public void createRemindMsg(InvRemindSetEntity invRemindSetEntity) { public void createRemindMsg(InvRemindSetEntity invRemindSetEntity) {
log.info("库存预警设置:{}", invRemindSetEntity.toString()); log.info("库存预警设置:{}", invRemindSetEntity.toString());
//查询库存数量 //查询库存数量
List<InvProductEntity> invProductList = invProductDao.selectInvProductInfo(invRemindSetEntity.getInvCode(), invRemindSetEntity.getInvSpaceCode(), invRemindSetEntity.getRelId()); List<InvProductBatchEntity> invProductBatchEntityList = invProductBatchService.selectInvProductInfo(invRemindSetEntity.getInvCode(), invRemindSetEntity.getInvSpaceCode(), invRemindSetEntity.getRelId());
if (CollUtil.isNotEmpty(invProductList)) { if (CollUtil.isNotEmpty(invProductBatchEntityList)) {
List<InvProductEntity> invDataList = new CopyOnWriteArrayList<>(invProductList); CopyOnWriteArrayList<InvProductBatchEntity> invDataList = new CopyOnWriteArrayList<>(invProductBatchEntityList);
invDataList.parallelStream().forEach(invProductEntity -> { invDataList.parallelStream().forEach(invProductBatchEntity -> {
//查询产品在耗材字典中设置的预警参数 //查询产品在耗材字典中设置的预警参数
UdiRelevanceEntity udiRelevanceEntity = udiRelevanceDao.selectRemindParams(invProductEntity.getRelIdFk()); UdiRelevanceEntity udiRelevanceEntity = udiRelevanceDao.selectRemindParams(Long.valueOf(invProductBatchEntity.getRelIdFk()));
if (null == udiRelevanceEntity) { if (null == udiRelevanceEntity) {
log.info("此库存产品在耗材字典中不存在,无法生成库存数量及近效期相关预警信息"); log.info("此库存产品在耗材字典中不存在,无法生成库存数量及近效期相关预警信息");
} else { } else {
//初始化查询预警消息参数 //初始化查询预警消息参数
FilterInvRemindMsgRequest invRemindMsgRequest = new FilterInvRemindMsgRequest(); FilterInvRemindMsgRequest invRemindMsgRequest = new FilterInvRemindMsgRequest();
invRemindMsgRequest.setRelId(invProductEntity.getRelIdFk().toString()); invRemindMsgRequest.setRelId(invProductBatchEntity.getRelIdFk().toString());
invRemindMsgRequest.setBatchNo(invProductEntity.getBatchNo()); invRemindMsgRequest.setBatchNo(invProductBatchEntity.getBatchNo());
invRemindMsgRequest.setDeptCode(invProductEntity.getDeptCode()); invRemindMsgRequest.setDeptCode(invProductBatchEntity.getDeptCode());
invRemindMsgRequest.setInvCode(invProductEntity.getInvCode()); invRemindMsgRequest.setInvCode(invProductBatchEntity.getInvCode());
invRemindMsgRequest.setInvSpaceCode(invProductEntity.getInvSpaceCode()); invRemindMsgRequest.setInvSpaceCode(invProductBatchEntity.getInvSpaceCode());
invRemindMsgRequest.setSupId(invProductEntity.getSupId()); invRemindMsgRequest.setSupId(invProductBatchEntity.getCustomerId());
//根据预警设置,添加类型参数 //根据预警设置,添加类型参数
if (invRemindSetEntity.getLowStock() && null != invRemindSetEntity.getLowStockNum()) { if (invRemindSetEntity.getLowStock() && null != invRemindSetEntity.getLowStockNum()) {
//开启低库存预警 //开启低库存预警
invRemindMsgRequest.setType("1"); //库存不足预警 invRemindMsgRequest.setType("1"); //库存不足预警
InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity); InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductBatchEntity);
//判断是否需要生成/刷新库存预警 //判断是否需要生成/刷新库存预警
if ((null == msgEntity.getNextRemindTime() || msgEntity.getNextRemindTime().getTime() <= new Date().getTime()) && invRemindSetEntity.getLowStockNum() > invProductEntity.getReCount()) { if ((null == msgEntity.getNextRemindTime() || msgEntity.getNextRemindTime().getTime() <= new Date().getTime()) && invRemindSetEntity.getLowStockNum() > invProductBatchEntity.getReCount()) {
//设置预警消息 //设置预警消息
msgEntity.setMsg(StrUtil.format("库存数量已不足:{},当前库存数量:{} ", invRemindSetEntity.getLowStockNum(), invProductEntity.getReCount())); msgEntity.setMsg(StrUtil.format("库存数量已不足:{},当前库存数量:{} ", invRemindSetEntity.getLowStockNum(), invProductBatchEntity.getReCount()));
saveMsg(msgEntity); saveMsg(msgEntity);
} }
} else { } else {
String logInfo = invRemindSetEntity.getLowStock() ? "产品 " + invProductEntity.getRelIdFk() + " 未设置低库存预警数量" : "产品 " + invProductEntity.getRelIdFk() + " 未开启低库存预警"; String logInfo = invRemindSetEntity.getLowStock() ? "产品 " + invProductBatchEntity.getRelIdFk() + " 未设置低库存预警数量" : "产品 " + invProductBatchEntity.getRelIdFk() + " 未开启低库存预警";
log.info(logInfo); log.info(logInfo);
} }
@ -110,11 +117,11 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService {
if (invRemindSetEntity.getLackStock()) { if (invRemindSetEntity.getLackStock()) {
//开启负库存预警 //开启负库存预警
invRemindMsgRequest.setType("2");//库存负数预警 invRemindMsgRequest.setType("2");//库存负数预警
InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity); InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductBatchEntity);
//判断是否需要生成/刷新库存预警 //判断是否需要生成/刷新库存预警
if ((null == msgEntity.getNextRemindTime() || msgEntity.getNextRemindTime().getTime() <= new Date().getTime()) && invProductEntity.getReCount() < 0) { if ((null == msgEntity.getNextRemindTime() || msgEntity.getNextRemindTime().getTime() <= new Date().getTime()) && invProductBatchEntity.getReCount() < 0) {
//设置预警消息 //设置预警消息
msgEntity.setMsg(StrUtil.format("库存数量为负,当前库存数量:{}", invProductEntity.getReCount())); msgEntity.setMsg(StrUtil.format("库存数量为负,当前库存数量:{}", invProductBatchEntity.getReCount()));
saveMsg(msgEntity); saveMsg(msgEntity);
} }
} }
@ -122,26 +129,26 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService {
if (invRemindSetEntity.getOverStock() && null != invRemindSetEntity.getOverStockNum()) { if (invRemindSetEntity.getOverStock() && null != invRemindSetEntity.getOverStockNum()) {
//开启库存积压预警 //开启库存积压预警
invRemindMsgRequest.setType("3"); //库存积压预警 invRemindMsgRequest.setType("3"); //库存积压预警
InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity); InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductBatchEntity);
//判断是否需要生成/刷新库存预警 //判断是否需要生成/刷新库存预警
if ((null == msgEntity.getNextRemindTime() || msgEntity.getNextRemindTime().getTime() <= new Date().getTime()) && invProductEntity.getReCount() > invRemindSetEntity.getOverStockNum()) { if ((null == msgEntity.getNextRemindTime() || msgEntity.getNextRemindTime().getTime() <= new Date().getTime()) && invProductBatchEntity.getReCount() > invRemindSetEntity.getOverStockNum()) {
//设置预警消息 //设置预警消息
msgEntity.setMsg(StrUtil.format("库存积压,当前库存数量:{}", invProductEntity.getReCount())); msgEntity.setMsg(StrUtil.format("库存积压,当前库存数量:{}", invProductBatchEntity.getReCount()));
saveMsg(msgEntity); saveMsg(msgEntity);
} }
} else { } else {
String logInfo = invRemindSetEntity.getOverStock() ? "产品 " + invProductEntity.getRelIdFk() + " 未设置库存积压预警数量" : "产品 " + invProductEntity.getRelIdFk() + " 未开启库存积压预警"; String logInfo = invRemindSetEntity.getOverStock() ? "产品 " + invProductBatchEntity.getRelIdFk() + " 未设置库存积压预警数量" : "产品 " + invProductBatchEntity.getRelIdFk() + " 未开启库存积压预警";
log.info(logInfo); log.info(logInfo);
} }
if (invRemindSetEntity.getExpireDate()) { if (invRemindSetEntity.getExpireDate()) {
//开启产品过期预警 //开启产品过期预警
invRemindMsgRequest.setType("4"); //库存过期预警 invRemindMsgRequest.setType("4"); //库存过期预警
InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity); InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductBatchEntity);
//判断是否需要生成/刷新库存预警 //判断是否需要生成/刷新库存预警
if ((null == msgEntity.getNextRemindTime() || msgEntity.getNextRemindTime().getTime() <= new Date().getTime()) && StrUtil.isNotBlank(invProductEntity.getExpireDate()) && MsDateUtil.compareExpire(invProductEntity.getExpireDate(), null)) { if ((null == msgEntity.getNextRemindTime() || msgEntity.getNextRemindTime().getTime() <= new Date().getTime()) && StrUtil.isNotBlank(invProductBatchEntity.getExpireDate()) && MsDateUtil.compareExpire(invProductBatchEntity.getExpireDate(), null)) {
//设置预警消息 //设置预警消息
msgEntity.setMsg(StrUtil.format("产品已过期,产品失效日期:{}", invProductEntity.getExpireDate())); msgEntity.setMsg(StrUtil.format("产品已过期,产品失效日期:{}", invProductBatchEntity.getExpireDate()));
saveMsg(msgEntity); saveMsg(msgEntity);
} }
} }
@ -149,20 +156,20 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService {
if (invRemindSetEntity.getRecentDate() && null != invRemindSetEntity.getRecentDateTime()) { if (invRemindSetEntity.getRecentDate() && null != invRemindSetEntity.getRecentDateTime()) {
//开启库存近效期预警 //开启库存近效期预警
invRemindMsgRequest.setType("5"); //库存近效期预警 invRemindMsgRequest.setType("5"); //库存近效期预警
InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity); InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductBatchEntity);
//判断是否需要生成/刷新库存预警 //判断是否需要生成/刷新库存预警
if ((null == msgEntity.getNextRemindTime() || msgEntity.getNextRemindTime().getTime() <= new Date().getTime()) && StrUtil.isNotBlank(invProductEntity.getExpireDate())) { if ((null == msgEntity.getNextRemindTime() || msgEntity.getNextRemindTime().getTime() <= new Date().getTime()) && StrUtil.isNotBlank(invProductBatchEntity.getExpireDate())) {
//当前时间 - 近效期预警时间 > 产品失效日期,则进行预警 //当前时间 - 近效期预警时间 > 产品失效日期,则进行预警
DateTime dateTime = cn.hutool.core.date.DateUtil.offsetHour(new Date(), invRemindSetEntity.getRecentDateTime()); DateTime dateTime = cn.hutool.core.date.DateUtil.offsetHour(new Date(), invRemindSetEntity.getRecentDateTime());
if (Long.parseLong(dateTime.toString("yyMMdd")) > Long.parseLong(invProductEntity.getExpireDate())) { if (Long.parseLong(dateTime.toString("yyMMdd")) > Long.parseLong(invProductBatchEntity.getExpireDate())) {
//设置预警消息 //设置预警消息
msgEntity.setMsg(StrUtil.format("库存即将过期,产品失效日期:{}", invProductEntity.getExpireDate())); msgEntity.setMsg(StrUtil.format("库存即将过期,产品失效日期:{}", invProductBatchEntity.getExpireDate()));
saveMsg(msgEntity); saveMsg(msgEntity);
} }
} }
} else { } else {
String logInfo = invRemindSetEntity.getRecentDate() ? "产品 " + invProductEntity.getRelIdFk() + " 未设置近效期预警时间" : "产品 " + invProductEntity.getRelIdFk() + " 未开启近效期预警"; String logInfo = invRemindSetEntity.getRecentDate() ? "产品 " + invProductBatchEntity.getRelIdFk() + " 未设置近效期预警时间" : "产品 " + invProductBatchEntity.getRelIdFk() + " 未开启近效期预警";
log.info(logInfo); log.info(logInfo);
} }
} }
@ -220,20 +227,20 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService {
* *
* *
* @param invRemindMsgRequest * @param invRemindMsgRequest
* @param invProductEntity * @param invProductBatchEntity
* @return * @return
*/ */
private InvRemindMsgEntity getInvRemindMsgEntity(FilterInvRemindMsgRequest invRemindMsgRequest, InvProductEntity invProductEntity) { private InvRemindMsgEntity getInvRemindMsgEntity(FilterInvRemindMsgRequest invRemindMsgRequest, InvProductBatchEntity invProductBatchEntity) {
InvRemindMsgEntity msgEntity = invRemindMsgDao.selectRemindMsg(invRemindMsgRequest); InvRemindMsgEntity msgEntity = invRemindMsgDao.selectRemindMsg(invRemindMsgRequest);
if (null == msgEntity) { if (null == msgEntity) {
//数据库不存在对应的预警消息,生成新的预警消息 //数据库不存在对应的预警消息,生成新的预警消息
msgEntity = new InvRemindMsgEntity(); msgEntity = new InvRemindMsgEntity();
msgEntity.setRelId(invProductEntity.getRelIdFk().toString()); //耗材字典产品ID msgEntity.setRelId(invProductBatchEntity.getRelIdFk().toString()); //耗材字典产品ID
msgEntity.setBatchNo(invProductEntity.getBatchNo()); //批次号 msgEntity.setBatchNo(invProductBatchEntity.getBatchNo()); //批次号
msgEntity.setSupId(invProductEntity.getSupId()); //供应商ID msgEntity.setSupId(invProductBatchEntity.getCustomerId()); //供应商ID
msgEntity.setDeptCode(invProductEntity.getDeptCode()); //部门编码 msgEntity.setDeptCode(invProductBatchEntity.getDeptCode()); //部门编码
msgEntity.setInvCode(invProductEntity.getInvCode()); //仓库编码 msgEntity.setInvCode(invProductBatchEntity.getInvCode()); //仓库编码
msgEntity.setInvSpaceCode(invProductEntity.getInvSpaceCode()); //货位号 msgEntity.setInvSpaceCode(invProductBatchEntity.getInvSpaceCode()); //货位号
msgEntity.setType(Integer.valueOf(invRemindMsgRequest.getType())); //预警类型 msgEntity.setType(Integer.valueOf(invRemindMsgRequest.getType())); //预警类型
Date date = new Date(); Date date = new Date();
@ -241,11 +248,11 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService {
} }
//更新预警消息的产品日期,数量等信息 //更新预警消息的产品日期,数量等信息
msgEntity.setProductionDate(invProductEntity.getProductionDate()); msgEntity.setProductionDate(invProductBatchEntity.getProductionDate());
msgEntity.setExpireDate(invProductEntity.getExpireDate()); msgEntity.setExpireDate(invProductBatchEntity.getExpireDate());
msgEntity.setInCount(invProductEntity.getInCount()); msgEntity.setInCount(invProductBatchEntity.getInCount());
msgEntity.setOutCount(invProductEntity.getOutCount()); msgEntity.setOutCount(invProductBatchEntity.getOutCount());
msgEntity.setReCount(invProductEntity.getReCount()); msgEntity.setReCount(invProductBatchEntity.getReCount());
return msgEntity; return msgEntity;
} }

@ -4,6 +4,7 @@ import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.dao.schedule.ScheduledDao; import com.glxp.api.dao.schedule.ScheduledDao;
import com.glxp.api.entity.inv.InvPreProductEntity; import com.glxp.api.entity.inv.InvPreProductEntity;
import com.glxp.api.entity.inv.InvPreinProductEntity; import com.glxp.api.entity.inv.InvPreinProductEntity;
import com.glxp.api.entity.inv.InvProductBatchEntity;
import com.glxp.api.entity.inv.InvProductEntity; import com.glxp.api.entity.inv.InvProductEntity;
import com.glxp.api.entity.system.ScheduledEntity; import com.glxp.api.entity.system.ScheduledEntity;
import com.glxp.api.http.sync.SpGetHttpClient; import com.glxp.api.http.sync.SpGetHttpClient;
@ -12,6 +13,7 @@ import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.inv.InvProductResponse; import com.glxp.api.res.inv.InvProductResponse;
import com.glxp.api.service.inv.InvPreProductService; import com.glxp.api.service.inv.InvPreProductService;
import com.glxp.api.service.inv.InvPreinProductService; import com.glxp.api.service.inv.InvPreinProductService;
import com.glxp.api.service.inv.impl.InvProductBatchService;
import com.glxp.api.service.inv.impl.InvProductService; import com.glxp.api.service.inv.impl.InvProductService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.SchedulingConfigurer; import org.springframework.scheduling.annotation.SchedulingConfigurer;
@ -70,6 +72,8 @@ public class VailInvTask implements SchedulingConfigurer {
@Resource @Resource
InvProductService invProductService; InvProductService invProductService;
@Resource @Resource
InvProductBatchService invProductBatchService;
@Resource
InvPreinProductService invPreinProductService; InvPreinProductService invPreinProductService;
@Resource @Resource
InvPreProductService invPreProductService; InvPreProductService invPreProductService;
@ -83,9 +87,9 @@ public class VailInvTask implements SchedulingConfigurer {
if (baseResponse.getCode() == 20000) { if (baseResponse.getCode() == 20000) {
List<InvProductResponse> list = baseResponse.getData().getList(); List<InvProductResponse> list = baseResponse.getData().getList();
list.forEach(invProductResponse -> { list.forEach(invProductResponse -> {
InvProductEntity invProductEntity = invProductService.selectByUnique(Long.getLong(invProductResponse.getRelIdFk()), invProductResponse.getBatchNo(), InvProductBatchEntity invProductBatchEntity = invProductBatchService.selectByUnique(Long.getLong(invProductResponse.getRelIdFk()),
invProductResponse.getSupId(), invProductResponse.getDeptCode(), invProductResponse.getInvCode(), invProductResponse.getPrice()); invProductResponse.getSupId(), invProductResponse.getDeptCode(), invProductResponse.getInvCode(), invProductResponse.getBatchNo(), invProductResponse.getPrice());
if (invProductEntity.getInCount() != invProductResponse.getInCount() || invProductEntity.getOutCount() != invProductResponse.getOutCount()) { if (invProductBatchEntity.getInCount() != invProductResponse.getInCount() || invProductBatchEntity.getOutCount() != invProductResponse.getOutCount()) {
buffer.append(invProductResponse.getCpmctymc() + "," buffer.append(invProductResponse.getCpmctymc() + ","
+ invProductResponse.getNameCode() + "," + invProductResponse.getNameCode() + ","
+ invProductResponse.getBatchNo() + "," + invProductResponse.getBatchNo() + ","

@ -4,9 +4,9 @@ server:
spring: spring:
datasource: datasource:
driver-class-name: com.p6spy.engine.spy.P6SpyDriver driver-class-name: com.p6spy.engine.spy.P6SpyDriver
jdbc-url: jdbc:p6spy:mysql://192.168.0.206:3306/udiwms81?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true jdbc-url: jdbc:p6spy:mysql://192.168.0.66:3306/udi_wms_cl?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
username: root username: root
password: Glxp@6066 password: 123456
hikari: hikari:
connection-timeout: 60000 connection-timeout: 60000
maximum-pool-size: 20 maximum-pool-size: 20

@ -9,7 +9,7 @@
ip.expireDate, ip.expireDate,
bp.zczbhhzbapzbh, bp.zczbhhzbapzbh,
bp.ylqxzcrbarmc bp.ylqxzcrbarmc
from inv_product ip from inv_product_batch ip
left join basic_udirel bu on bu.id = ip.relIdFk left join basic_udirel bu on bu.id = ip.relIdFk
left join basic_products bp on bu.uuid = bp.uuid left join basic_products bp on bu.uuid = bp.uuid
where ip.relIdFk = #{relId} where ip.relIdFk = #{relId}

@ -26,7 +26,7 @@
LEFT JOIN basic_products ON basic_products.uuid = basic_udirel.uuid LEFT JOIN basic_products ON basic_products.uuid = basic_udirel.uuid
left join inv_product_detail ipd on ipd.relId = mad.relId left join inv_product_detail ipd on ipd.relId = mad.relId
and ipd.invCode = ma.invCode and ipd.invSpaceCode = ma.invSpaceCode and ipd.invCode = ma.invCode and ipd.invSpaceCode = ma.invSpaceCode
left join inv_product ip on ipd.relId = ip.relIdFk and ip.batchNo = ipd.batchNo left join inv_product_batch ip on ipd.relId = ip.relIdFk and ip.batchNo = ipd.batchNo
<where> <where>
<if test="orderIdFk != null and orderIdFk != ''"> <if test="orderIdFk != null and orderIdFk != ''">
AND mad.orderIdFk = #{orderIdFk} AND mad.orderIdFk = #{orderIdFk}

@ -48,7 +48,7 @@
select od.*, bps.cpmctymc productName, bps.ggxh, bps.ylqxzcrbarmc, bps.zczbhhzbapzbh select od.*, bps.cpmctymc productName, bps.ggxh, bps.ylqxzcrbarmc, bps.zczbhhzbapzbh
from inv_count_order_detail od from inv_count_order_detail od
left join inv_count_order ico on od.orderIdFk = ico.orderId left join inv_count_order ico on od.orderIdFk = ico.orderId
left join inv_product ip on od.productId = ip.relIdFk left join inv_product_batch ip on od.productId = ip.relIdFk
left join basic_products bps on od.nameCode = bps.nameCode left join basic_products bps on od.nameCode = bps.nameCode
where od.orderIdFk = #{orderIdFk} where od.orderIdFk = #{orderIdFk}
group by od.id group by od.id

@ -43,7 +43,7 @@
bp.majorStatus, bp.majorStatus,
bp.physicType, bp.physicType,
bp.medicareType bp.medicareType
from inv_product ipp from inv_product_batch ipp
inner join basic_udirel on ipp.relIdFk = basic_udirel.id inner join basic_udirel on ipp.relIdFk = basic_udirel.id
inner join basic_products bp on basic_udirel.uuid = bp.uuid inner join basic_products bp on basic_udirel.uuid = bp.uuid
left join basic_corp on ipp.supId = basic_corp.erpId left join basic_corp on ipp.supId = basic_corp.erpId
@ -212,7 +212,7 @@
ad.name deptName, ad.name deptName,
aw.name invName, aw.name invName,
sp.name invSpaceName sp.name invSpaceName
from inv_product pd from inv_product_batch pd
left join basic_udirel bu on pd.relIdFk = bu.id left join basic_udirel bu on pd.relIdFk = bu.id
left join basic_products bp on bp.uuid = bu.uuid left join basic_products bp on bp.uuid = bu.uuid
left join auth_dept ad on pd.deptCode = ad.code left join auth_dept ad on pd.deptCode = ad.code
@ -257,7 +257,7 @@
inCount, inCount,
outCount, outCount,
reCount reCount
from inv_product pd from inv_product_batch pd
left join basic_udirel bu on pd.relIdFk = bu.id left join basic_udirel bu on pd.relIdFk = bu.id
left join basic_products bp on bp.uuid = bu.uuid left join basic_products bp on bp.uuid = bu.uuid
left join auth_dept ad on pd.deptCode = ad.code left join auth_dept ad on pd.deptCode = ad.code
@ -320,7 +320,7 @@
<select id="getInventoryQuantity" resultType="java.lang.Integer"> <select id="getInventoryQuantity" resultType="java.lang.Integer">
SELECT reCount SELECT reCount
FROM inv_product ipd FROM inv_product_batch ipd
WHERE invCode = #{invCode} WHERE invCode = #{invCode}
and (invSpaceCode is null or invSpaceCode = '') and (invSpaceCode is null or invSpaceCode = '')
</select> </select>
@ -344,7 +344,7 @@
bp.manufactory, bp.manufactory,
corp.name AS supName corp.name AS supName
FROM FROM
inv_product t1 inv_product_batch t1
LEFT JOIN basic_udirel bu ON bu.id = t1.relIdFk LEFT JOIN basic_udirel bu ON bu.id = t1.relIdFk
LEFT JOIN basic_products bp ON bp.uuid = bu.uuid LEFT JOIN basic_products bp ON bp.uuid = bu.uuid
LEFT JOIN auth_dept dept ON dept.code = t1.deptCode LEFT JOIN auth_dept dept ON dept.code = t1.deptCode

@ -62,7 +62,7 @@
bp.ggxh, bp.ggxh,
bp.cpmctymc AS productName bp.cpmctymc AS productName
FROM FROM
inv_product ip inv_product_batch ip
LEFT JOIN basic_udirel bu ON ip.relIdFk = bu.id LEFT JOIN basic_udirel bu ON ip.relIdFk = bu.id
LEFT JOIN basic_products bp ON bu.uuid = bp.uuid LEFT JOIN basic_products bp ON bu.uuid = bp.uuid
LEFT JOIN inv_product_detail ipd LEFT JOIN inv_product_detail ipd

@ -52,7 +52,7 @@
bp.basicPrductRemak8, bp.basicPrductRemak8,
bp.packUnit, bp.packUnit,
ip.price ip.price
from inv_product ip from inv_product_batch ip
INNER JOIN basic_products bp ON ip.relIdFk = (SELECT id FROM basic_udirel WHERE uuid = bp.uuid limit 1) INNER JOIN basic_products bp ON ip.relIdFk = (SELECT id FROM basic_udirel WHERE uuid = bp.uuid limit 1)
LEFT JOIN basic_corp ON ip.supId = basic_corp.erpId LEFT JOIN basic_corp ON ip.supId = basic_corp.erpId
LEFT JOIN auth_dept ON auth_dept.CODE = ip.deptCode LEFT JOIN auth_dept ON auth_dept.CODE = ip.deptCode
@ -172,7 +172,7 @@
sum(ip.inCount) inCount, sum(ip.inCount) inCount,
sum(ip.outCount) outCount, sum(ip.outCount) outCount,
sum(ip.reCount) reCount sum(ip.reCount) reCount
from inv_product ip from inv_product_batch ip
inner join basic_udirel bu on ip.relIdFk = bu.id inner join basic_udirel bu on ip.relIdFk = bu.id
inner join basic_products bp on bu.uuid = bp.uuid inner join basic_products bp on bu.uuid = bp.uuid
left join basic_corp bc on ip.supId = bc.erpId left join basic_corp bc on ip.supId = bc.erpId
@ -265,7 +265,7 @@
<select id="selectProductInfo" resultType="com.glxp.api.entity.inv.InvProductEntity"> <select id="selectProductInfo" resultType="com.glxp.api.entity.inv.InvProductEntity">
select ip.* select ip.*
from inv_product ip from inv_product_batch ip
left join inv_product_detail ipd on ip.relIdFk = ipd.relId left join inv_product_detail ipd on ip.relIdFk = ipd.relId
and ifnull(ip.batchNo, 'empty') = ifnull(ipd.batchNo, 'empty') and ifnull(ip.batchNo, 'empty') = ifnull(ipd.batchNo, 'empty')
and ip.deptCode = ipd.deptCode and ip.deptCode = ipd.deptCode
@ -303,7 +303,7 @@
inv_product.reCount, inv_product.reCount,
basic_products.cpmctymc basic_products.cpmctymc
from inv_product_detail from inv_product_detail
left join inv_product on inv_product_detail.relId = inv_product.relIdFk left join inv_product_batch on inv_product_detail.relId = inv_product.relIdFk
and inv_product.invCode = inv_product_detail.invCode and inv_product.invCode = inv_product_detail.invCode
AND COALESCE(inv_product.batchNo, 'empty') = COALESCE(inv_product_detail.batchNo, 'empty') AND COALESCE(inv_product.batchNo, 'empty') = COALESCE(inv_product_detail.batchNo, 'empty')
left join basic_udirel on inv_product_detail.relId = basic_udirel.id left join basic_udirel on inv_product_detail.relId = basic_udirel.id
@ -340,7 +340,7 @@
ip.inCount, ip.inCount,
ip.outCount, ip.outCount,
ip.reCount ip.reCount
from inv_product ip from inv_product_batch ip
left join inv_product_detail ipd left join inv_product_detail ipd
on ip.relIdFk = ipd.relId and ifnull(ip.batchNo, 'empty') = ifnull(ipd.batchNo, 'empty') on ip.relIdFk = ipd.relId and ifnull(ip.batchNo, 'empty') = ifnull(ipd.batchNo, 'empty')
<where> <where>
@ -359,7 +359,7 @@
<select id="filterProductNames" resultType="com.glxp.api.res.inv.InvProductResponse"> <select id="filterProductNames" resultType="com.glxp.api.res.inv.InvProductResponse">
select ip.relIdFk, bp.cpmctymc, bp.ggxh, bp.ylqxzcrbarmc, bp.zczbhhzbapzbh select ip.relIdFk, bp.cpmctymc, bp.ggxh, bp.ylqxzcrbarmc, bp.zczbhhzbapzbh
from inv_product ip from inv_product_batch ip
left join inv_product_detail ipd on ip.relIdFk = ipd.relId and ip.invCode = ipd.invCode and left join inv_product_detail ipd on ip.relIdFk = ipd.relId and ip.invCode = ipd.invCode and
ifnull(ip.batchNo, 'empty') = ifnull(ipd.batchNo, 'empty') ifnull(ip.batchNo, 'empty') = ifnull(ipd.batchNo, 'empty')
left join basic_udirel bu on bu.id = ip.relIdFk left join basic_udirel bu on bu.id = ip.relIdFk
@ -402,7 +402,7 @@
ip.deptCode, ip.deptCode,
ip.price, ip.price,
ip.invCode ip.invCode
from inv_product ip from inv_product_batch ip
inner join basic_udirel on ip.relIdFk = basic_udirel.id inner join basic_udirel on ip.relIdFk = basic_udirel.id
inner join basic_products bp on basic_udirel.uuid = bp.uuid inner join basic_products bp on basic_udirel.uuid = bp.uuid
left join basic_corp on ip.supId = basic_corp.erpId left join basic_corp on ip.supId = basic_corp.erpId
@ -492,7 +492,7 @@
ip.deptCode, ip.deptCode,
ip.price, ip.price,
ip.invCode ip.invCode
from inv_product ip from inv_product_batch ip
inner join basic_udirel on ip.relIdFk = basic_udirel.id inner join basic_udirel on ip.relIdFk = basic_udirel.id
inner join basic_products bp on basic_udirel.uuid = bp.uuid inner join basic_products bp on basic_udirel.uuid = bp.uuid
left join basic_corp on ip.supId = basic_corp.erpId left join basic_corp on ip.supId = basic_corp.erpId
@ -591,7 +591,7 @@
<select id="filterReCount" resultType="string"> <select id="filterReCount" resultType="string">
select ip.supId select ip.supId
from inv_product ip from inv_product_batch ip
<where> <where>
AND ip.reCount > 0 AND ip.reCount > 0
<if test="relId != null and relId != ''"> <if test="relId != null and relId != ''">

@ -5552,4 +5552,21 @@ CREATE TABLE IF NOT EXISTS `inv_product_record` (
INDEX `idx_productId`(`productId` ASC) USING BTREE, INDEX `idx_productId`(`productId` ASC) USING BTREE,
INDEX `idx_orderId`(`orderId` ASC) USING BTREE, INDEX `idx_orderId`(`orderId` ASC) USING BTREE,
INDEX `idx_createTime`(`createTime` ASC) USING BTREE INDEX `idx_createTime`(`createTime` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '库存流水表' ROW_FORMAT = DYNAMIC; ) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '库存流水表' ROW_FORMAT = DYNAMIC;
CALL Pro_Temp_ColumnWork('inv_product_batch', 'nowStock', 'int ', 1);
CALL Pro_Temp_ColumnWork('inv_product_batch', 'frozenCount', 'int ', 1);
CALL Pro_Temp_ColumnWork('inv_product_batch', 'planInCount', 'int ', 1);
CALL Pro_Temp_ColumnWork('inv_product_batch', 'planOutCount', 'int ', 1);
CALL Pro_Temp_ColumnWork('inv_product_batch', 'outCount', 'int ', 1);
CALL Pro_Temp_ColumnWork('inv_product_batch', 'onWayCount', 'int ', 1);
CALL Pro_Temp_ColumnWork('inv_product_batch', 'availableStock', 'int ', 1);
CALL Pro_Temp_ColumnWork('inv_product_batch', 'invSpaceCode',
'varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT ''货位编码''', 1);
CALL Pro_Temp_ColumnWork('inv_product_batch', 'productionDate',
'varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT ''生产日期''', 1);
CALL Pro_Temp_ColumnWork('inv_product_batch', 'customerId',
'varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT ''客户id''', 1);

Loading…
Cancel
Save