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();
InvProductEntity invProductEntity = invProductService.findById(id);
if (null != invProductEntity) {
FilterInvProductDetailRequest detailRequest = new FilterInvProductDetailRequest();
detailRequest.setSupId(invProductEntity.getSupId());
detailRequest.setRelId(String.valueOf(invProductEntity.getRelIdFk()));
detailRequest.setInvCode(invProductEntity.getInvCode());
if (StrUtil.isBlank(invProductEntity.getBatchNo())) {
detailRequest.setBatchNo("empty");
} else {
detailRequest.setBatchNo(invProductEntity.getBatchNo());
}
// FilterInvProductDetailRequest detailRequest = new FilterInvProductDetailRequest();
// detailRequest.setSupId(invProductEntity.getSupId());
// detailRequest.setRelId(String.valueOf(invProductEntity.getRelIdFk()));
// detailRequest.setInvCode(invProductEntity.getInvCode());
// if (StrUtil.isBlank(invProductEntity.getBatchNo())) {
// detailRequest.setBatchNo("empty");
// } else {
// detailRequest.setBatchNo(invProductEntity.getBatchNo());
// }
invProductService.deleteById(id);
return ResultVOUtils.success("删除成功");
} else {

@ -76,9 +76,9 @@ public class InvProductBatchEntity implements Serializable {
/**
*
*/
@TableField(value = "produceDate")
@TableField(value = "productionDate")
@ApiModelProperty(value = "生产日期")
private String produceDate;
private String productionDate;
/**
@ -88,13 +88,20 @@ public class InvProductBatchEntity implements Serializable {
@ApiModelProperty(value = "失效日期")
private String expireDate;
/**
*
*/
@TableField(value = "outCount")
@ApiModelProperty(value = "出库数量")
private Integer outCount;
/**
*
*/
@TableField(value = "invCount")
@TableField(value = "inCount")
@ApiModelProperty(value = "入库数量")
private Integer invCount;
private Integer inCount;
/**
*
@ -107,9 +114,9 @@ public class InvProductBatchEntity implements Serializable {
/**
* ID
*/
@TableField(value = "supId")
@TableField(value = "customerId")
@ApiModelProperty(value = "供应商ID")
private String supId;
private String customerId;
/**
*
@ -146,5 +153,42 @@ public class InvProductBatchEntity implements Serializable {
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;
}

@ -12,8 +12,10 @@ import java.util.Date;
@Data
@TableName(value = "inv_product")
public class InvProductEntity {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private Long id;
/**
* ID
@ -22,58 +24,25 @@ public class InvProductEntity {
private Long relIdFk;
/**
*
*
*/
@TableField(value = "nameCode")
private String nameCode;
@TableField(value = "supId")
private String supId;
/**
*
*/
@TableField(value = "batchNo")
private String batchNo;
/**
*
*
*/
@TableField(value = "productionDate")
private String productionDate;
@TableField(value = "reCount")
private Integer reCount;
/**
*
*/
@TableField(value = "expireDate")
private String expireDate;
/**
*
*/
@TableField(value = "inCount")
private Integer inCount;
/**
*
*/
@TableField(value = "outCount")
private int outCount;
/**
*
*/
@TableField(value = "reCount")
private int reCount;
/**
* ID
*/
@TableField(value = "customerId")
private String customerId;
/**
* ID
*/
@TableField(value = "supId")
private String supId;
@TableField(value = "outCount")
private Integer outCount;
/**
*
@ -93,12 +62,6 @@ public class InvProductEntity {
@TableField(value = "invSpaceCode")
private String invSpaceCode;
/**
*
*/
@TableField(value = "createTime")
private Date createTime;
/**
*
@ -106,47 +69,5 @@ public class InvProductEntity {
@TableField(value = "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.basic.*;
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.system.SystemParamConfigEntity;
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.inv.InvPreProductDetailService;
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.InvProductServiceNew;
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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
@ -82,6 +85,8 @@ public class IoAddInoutService {
InvProductService invProductService;
@Resource
IoCheckInvService checkInvService;
@Autowired
private InvProductBatchService invProductBatchService;
//新增扫码单据处理
public BaseResponse dealProcess(IoOrderEntity orderEntity) {
@ -346,56 +351,30 @@ public class IoAddInoutService {
//校验库存
for (IoOrderDetailBizEntity bizEntity : bizEntities) {
if (StrUtil.isNotEmpty(bizEntity.getBatchNo())) {
List<InvProductEntity> invProductEntities = invProductService.selectByRelId(bizEntity.getBindRlFk(), bizEntity.getSupId(), null, orderEntity.getInvCode());
if (CollUtil.isNotEmpty(invProductEntities)) {
List<InvProductBatchEntity> invProductBatchEntities = invProductBatchService.selectByRelId(bizEntity.getBindRlFk(), bizEntity.getSupId(), null, orderEntity.getInvCode(),bizEntity.getBatchNo(),null);
if (CollUtil.isNotEmpty(invProductBatchEntities)) {
int count = 0;
for (InvProductEntity invProductEntity : invProductEntities) {
if (invProductEntity.getReCount() + count > IntUtil.value(bizEntity.getCount())) {
for (InvProductBatchEntity invProductBatchEntity : invProductBatchEntities) {
if (invProductBatchEntity.getReCount() + count > IntUtil.value(bizEntity.getCount())) {
IoOrderDetailBizEntity orderDetailBizEntity = new IoOrderDetailBizEntity();
BeanUtils.copyProperties(bizEntity, orderDetailBizEntity);
orderDetailBizEntity.setId(IdUtil.getSnowflakeNextId());
orderDetailBizEntity.setBatchNo(invProductBatchEntity.getBatchNo());
newBizList.add(orderDetailBizEntity);
break;
} else {
count = invProductEntity.getReCount();
count = invProductBatchEntity.getReCount();
IoOrderDetailBizEntity orderDetailBizEntity = new IoOrderDetailBizEntity();
BeanUtils.copyProperties(bizEntity, orderDetailBizEntity);
orderDetailBizEntity.setCount(count);
orderDetailBizEntity.setId(IdUtil.getSnowflakeNextId());
orderDetailBizEntity.setBatchNo(invProductBatchEntity.getBatchNo());
newBizList.add(orderDetailBizEntity);
}
}
} else {
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.batchInsertBizs(newBizList);

@ -77,44 +77,41 @@ public class IoGenInvService {
//生成库存产品表
for (IoOrderDetailResultEntity orderDetailResultEntity : orderDetailResultEntities) {
InvProductEntity invProductEntity = invProductService.selectByUnique(orderDetailResultEntity.getBindRlFk(), orderDetailResultEntity.getBatchNo(), orderDetailResultEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), orderDetailResultEntity.getPrice());
if (invProductEntity == null) {
invProductEntity = new InvProductEntity();
invProductEntity.setRelIdFk(orderDetailResultEntity.getBindRlFk());
invProductEntity.setNameCode(orderDetailResultEntity.getNameCode());
invProductEntity.setBatchNo(orderDetailResultEntity.getBatchNo());
invProductEntity.setProductionDate(orderDetailResultEntity.getProductDate());
invProductEntity.setExpireDate(orderDetailResultEntity.getExpireDate());
invProductEntity.setInCount(0);
invProductEntity.setOutCount(0);
invProductEntity.setSupId(orderDetailResultEntity.getSupId());
invProductEntity.setDeptCode(orderEntity.getDeptCode());
invProductEntity.setInvCode(orderEntity.getInvCode());
invProductEntity.setCreateTime(new Date());
invProductEntity.setUpdateTime(new Date());
invProductEntity.setPrice(orderDetailResultEntity.getPrice());
InvProductBatchEntity invProductBatchEntity = invProductBatchService.selectByUnique(orderDetailResultEntity.getBindRlFk(),
orderDetailResultEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), orderDetailResultEntity.getBatchNo(), orderDetailResultEntity.getPrice());
if (invProductBatchEntity == null) {
invProductBatchEntity = new InvProductBatchEntity();
invProductBatchEntity.setRelIdFk(String.valueOf(orderDetailResultEntity.getBindRlFk()));
invProductBatchEntity.setNameCode(orderDetailResultEntity.getNameCode());
invProductBatchEntity.setBatchNo(orderDetailResultEntity.getBatchNo());
invProductBatchEntity.setProductionDate(orderDetailResultEntity.getProductDate());
invProductBatchEntity.setExpireDate(orderDetailResultEntity.getExpireDate());
invProductBatchEntity.setOutCount(0);
invProductBatchEntity.setInCount(0);
invProductBatchEntity.setReCount(0);
invProductBatchEntity.setCustomerId(orderDetailResultEntity.getSupId());
invProductBatchEntity.setDeptCode(orderEntity.getDeptCode());
invProductBatchEntity.setInvCode(orderEntity.getInvCode());
invProductBatchEntity.setCreateTime(new Date());
invProductBatchEntity.setUpdateTime(new Date());
invProductBatchEntity.setPrice(orderDetailResultEntity.getPrice());
//添加产品表入院批次号
invProductEntity.setInBatchNo(orderEntity.getBillNo().substring(orderEntity.getBillNo().length() - 12));
invProductService.insert(invProductEntity);
invProductBatchEntity.setInBatchNo(orderEntity.getBillNo().substring(orderEntity.getBillNo().length() - 12));
}
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)) {
invProductEntity.setInCount(invProductEntity.getInCount() + orderDetailResultEntity.getCount());
invProductBatchEntity.setInCount(invProductBatchEntity.getInCount() + orderDetailResultEntity.getReCount());
}
invProductEntity.setReCount(invProductEntity.getInCount() - invProductEntity.getOutCount());
invProductEntity.setUpdateTime(new Date());
invProductService.update(invProductEntity);
invProductBatchEntity.setReCount(invProductBatchEntity.getInCount() - invProductBatchEntity.getOutCount());
invProductBatchEntity.setUpdateTime(new Date());
InvProductBatchEntity batchEntity = new InvProductBatchEntity();
BeanUtils.copyProperties(invProductEntity, batchEntity);
batchEntity.setId(null);
batchEntities.add(batchEntity);
batchEntities.add(invProductBatchEntity);
}
if (CollUtil.isNotEmpty(batchEntities)) {
invProductBatchService.saveBatch(batchEntities);
invProductBatchService.saveBatchEvent(batchEntities,bussinessTypeEntity.getMainAction());
}
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.InvPreinProductDetailService;
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.InvProductServiceNew;
import com.glxp.api.service.system.SyncUploadDataBustypeService;
@ -59,6 +60,7 @@ import com.glxp.api.vo.basic.InvProductNewVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
@ -112,6 +114,8 @@ public class IoOrderServiceImpl implements IoOrderService {
private HttpOkClient httpOkClient;
@Resource
private BasicCorpDao basicCorpDao;
@Autowired
private InvProductBatchService invProductBatchService;
@Override
public List<IoOrderEntity> selectAll() {
@ -289,23 +293,25 @@ public class IoOrderServiceImpl implements IoOrderService {
//删除普通库存
List<InvProductNewVo> invProductDetailEntities = invProductServiceNew.selectByOrderIdFk(billNo);
if (CollUtil.isNotEmpty(invProductDetailEntities)) {
List<InvProductBatchEntity> batchEntities = new ArrayList<>();
for (InvProductNewVo invProductDetailEntity : invProductDetailEntities) {
//更新库存
InvProductEntity invProductEntity = invProductService.selectByUnique(invProductDetailEntity.getRelIdFk(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(), invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode(), invProductDetailEntity.getPrice());
if (invProductEntity != null) {
InvProductBatchEntity invProductBatchEntity = invProductBatchService.selectByUnique(invProductDetailEntity.getRelIdFk(),
invProductDetailEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getPrice());
if (invProductBatchEntity != null) {
if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
int count = invProductEntity.getInCount() - invProductDetailEntity.getReCount();
invProductEntity.setInCount(count);
int count = invProductBatchEntity.getInCount() - invProductDetailEntity.getReCount();
invProductBatchEntity.setInCount(count);
} else if (ConstantType.TYPE_OUT.equals(invProductDetailEntity.getMainAction())) {
int count = invProductEntity.getOutCount() - invProductDetailEntity.getReCount();
invProductEntity.setOutCount(count);
int count = invProductBatchEntity.getOutCount() - invProductDetailEntity.getReCount();
invProductBatchEntity.setOutCount(count);
}
//计算实际数量
invProductEntity.setReCount(invProductEntity.getInCount() - invProductEntity.getOutCount());
invProductService.update(invProductEntity);
invProductBatchEntity.setReCount(invProductBatchEntity.getInCount() - invProductBatchEntity.getOutCount());
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());
if (invProductDetailEntity != null) {
List<InvProductBatchEntity> batchEntities = new ArrayList<>();
//更新产品表
InvProductEntity invProductEntity = invProductService.selectByUnique(invProductDetailEntity.getRelIdFk(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(),
invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode(), invProductDetailEntity.getPrice());
if (invProductEntity != null) {
InvProductBatchEntity invProductBatchEntity = invProductBatchService.selectByUnique(invProductDetailEntity.getRelIdFk(),
invProductDetailEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getPrice());
if (invProductBatchEntity != null) {
if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
int inCount = invProductEntity.getInCount() - remainScanCount;
invProductEntity.setInCount(inCount);
int count = invProductBatchEntity.getInCount() - remainScanCount;
invProductBatchEntity.setInCount(count);
} else if (ConstantType.TYPE_OUT.equals(invProductDetailEntity.getMainAction())) {
int outCount = invProductEntity.getOutCount() - remainScanCount;
invProductEntity.setOutCount(outCount);
int count = invProductBatchEntity.getOutCount() - remainScanCount;
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 {
List<InvProductNewVo> invProductDetailEntities = invProductServiceNew.selectByOrderIdFk(billNo);
if (CollUtil.isNotEmpty(invProductDetailEntities)) {
List<InvProductBatchEntity> batchEntities = new ArrayList<>();
for (InvProductNewVo invProductDetailEntity : invProductDetailEntities) {
InvProductEntity invProductEntity = invProductService.selectByUnique(invProductDetailEntity.getRelIdFk(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getSupId(),
invProductDetailEntity.getDeptCode(), invProductDetailEntity.getInvCode(), invProductDetailEntity.getPrice());
if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
int count = invProductEntity.getInCount() - invProductDetailEntity.getReCount();
invProductEntity.setInCount(count);
} else if (ConstantType.TYPE_OUT.equals(invProductDetailEntity.getMainAction())) {
int count = invProductEntity.getOutCount() - invProductDetailEntity.getReCount();
invProductEntity.setOutCount(count);
//更新库存
InvProductBatchEntity invProductBatchEntity = invProductBatchService.selectByUnique(invProductDetailEntity.getRelIdFk(),
invProductDetailEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), invProductDetailEntity.getBatchNo(), invProductDetailEntity.getPrice());
if (invProductBatchEntity != null) {
if (ConstantType.TYPE_PUT.equals(invProductDetailEntity.getMainAction())) {
int count = invProductBatchEntity.getInCount() - invProductDetailEntity.getReCount();
invProductBatchEntity.setInCount(count);
} else if (ConstantType.TYPE_OUT.equals(invProductDetailEntity.getMainAction())) {
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
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.setWorkPlaceCode(workPlaceCode);
@ -1050,11 +1068,11 @@ public class IoOrderServiceImpl implements IoOrderService {
filterOrderRequest.setFifoSplitTag(fifoSplitTag);
List<IoOrderResponse> ioOrderResponses = orderDao.filterList(filterOrderRequest);
if (ioOrderResponses.size() > 0){
if (ioOrderResponses.size() > 0) {
IoOrderResponse ioOrderResponse = ioOrderResponses.get(0);
return ioOrderResponse;
}
return null;
return null;
}
@ -1119,59 +1137,65 @@ public class IoOrderServiceImpl implements IoOrderService {
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(),
ioOrderDetailResultEntity.getSupId(), ioOrderEntity.getDeptCode(), ioOrderEntity.getInvCode(), ioOrderDetailResultEntity.getPrice());
if (invProductEntity == null) {
//没有该产品就填充数据
invProductEntity = new InvProductEntity();
invProductEntity.setRelIdFk(ioOrderDetailResultEntity.getBindRlFk());
invProductEntity.setNameCode(ioOrderDetailResultEntity.getNameCode());
invProductEntity.setBatchNo(ioOrderDetailResultEntity.getBatchNo());
invProductEntity.setProductionDate(ioOrderDetailResultEntity.getProductDate());
invProductEntity.setExpireDate(ioOrderDetailResultEntity.getExpireDate());
invProductEntity.setInCount(0);
invProductEntity.setOutCount(0);
invProductEntity.setSupId(ioOrderDetailResultEntity.getSupId());
invProductEntity.setDeptCode(ioOrderEntity.getDeptCode());
invProductEntity.setInvCode(ioOrderEntity.getInvCode());
invProductEntity.setPrice(ioOrderDetailResultEntity.getPrice());
invProductEntity.setCreateTime(new Date());
invProductEntity.setUpdateTime(new Date());
invProductEntity.setNowStock(0); //现存量
invProductEntity.setFrozenCount(0); //冻结量
invProductEntity.setPlanInCount(0);//预计入库量
invProductEntity.setPlanOutCount(0);//预计出库量
invProductEntity.setOnWayCount(0);//在途库存
invProductEntity.setAvailableStock(0);//可用库存
InvProductBatchEntity invProductBatchEntity = invProductBatchService.selectByUnique(orderDetailResultEntity.getBindRlFk(),
orderDetailResultEntity.getSupId(), orderEntity.getDeptCode(), orderEntity.getInvCode(), orderDetailResultEntity.getBatchNo(), orderDetailResultEntity.getPrice());
if (invProductBatchEntity == null) {
invProductBatchEntity = new InvProductBatchEntity();
invProductBatchEntity.setRelIdFk(String.valueOf(orderDetailResultEntity.getBindRlFk()));
invProductBatchEntity.setNameCode(orderDetailResultEntity.getNameCode());
invProductBatchEntity.setBatchNo(orderDetailResultEntity.getBatchNo());
invProductBatchEntity.setProductionDate(orderDetailResultEntity.getProductDate());
invProductBatchEntity.setExpireDate(orderDetailResultEntity.getExpireDate());
invProductBatchEntity.setOutCount(0);
invProductBatchEntity.setInCount(0);
invProductBatchEntity.setReCount(0);
invProductBatchEntity.setCustomerId(orderDetailResultEntity.getSupId());
invProductBatchEntity.setDeptCode(orderEntity.getDeptCode());
invProductBatchEntity.setInvCode(orderEntity.getInvCode());
invProductBatchEntity.setCreateTime(new Date());
invProductBatchEntity.setUpdateTime(new Date());
invProductBatchEntity.setNowStock(0); //现存量
invProductBatchEntity.setFrozenCount(0); //冻结量
invProductBatchEntity.setPlanInCount(0);//预计入库量
invProductBatchEntity.setPlanOutCount(0);//预计出库量
invProductBatchEntity.setOnWayCount(0);//在途库存
invProductBatchEntity.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) {
invProductEntity.setPlanOutCount((invProductEntity.getPlanOutCount() != null ? invProductEntity.getPlanOutCount() : 0) + ioOrderDetailResultEntity.getReCount());//预计出库量
invProductEntity.setFrozenCount((invProductEntity.getFrozenCount() != null ? invProductEntity.getFrozenCount() : 0) + ioOrderDetailResultEntity.getReCount());//预计出库量
} else if (ioOrderEntity.getStatus() == ConstantStatus.ORDER_STATUS_AUDITED) {
invProductEntity.setPlanOutCount((invProductEntity.getPlanOutCount() != null ? invProductEntity.getPlanOutCount() : 0) - ioOrderDetailResultEntity.getReCount());//预计出库量
invProductEntity.setFrozenCount((invProductEntity.getFrozenCount() != null ? invProductEntity.getFrozenCount() : 0) - ioOrderDetailResultEntity.getReCount());//预计出库量
if (orderEntity.getMainAction().equals(ConstantType.TYPE_OUT)) {
if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_CHECK_SUCCESS) {
invProductBatchEntity.setPlanOutCount((invProductBatchEntity.getPlanOutCount() != null ? invProductBatchEntity.getPlanOutCount() : 0) + orderDetailResultEntity.getReCount());//预计出库量
invProductBatchEntity.setFrozenCount((invProductBatchEntity.getFrozenCount() != null ? invProductBatchEntity.getFrozenCount() : 0) + orderDetailResultEntity.getReCount());//预计出库量
} else if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_AUDITED) {
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) {
invProductEntity.setPlanInCount((invProductEntity.getInCount() != null ? invProductEntity.getInCount() : 0) + ioOrderDetailResultEntity.getReCount());//预计出库量
} else if (ioOrderEntity.getStatus() == ConstantStatus.ORDER_STATUS_AUDITED) {
invProductEntity.setPlanInCount((invProductEntity.getInCount() != null ? invProductEntity.getInCount() : 0) - ioOrderDetailResultEntity.getReCount());//预计出库量
if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_CHECK_SUCCESS) {
invProductBatchEntity.setPlanInCount((invProductBatchEntity.getInCount() != null ? invProductBatchEntity.getInCount() : 0) + orderDetailResultEntity.getReCount());//预计出库量
} else if (orderEntity.getStatus() == ConstantStatus.ORDER_STATUS_AUDITED) {
invProductBatchEntity.setPlanInCount((invProductBatchEntity.getInCount() != null ? invProductBatchEntity.getInCount() : 0) - orderDetailResultEntity.getReCount());//预计出库量
}
}
//判断有没有id走插入或者更新方法
if (invProductEntity.getId() == null) {
invProductService.insert(invProductEntity);
if (invProductBatchEntity.getId() == null) {
invProductBatchService.save(invProductBatchEntity);
} else {
invProductService.update(invProductEntity);
invProductBatchService.updateById(invProductBatchEntity);
}
}
return true;
}

@ -1,9 +1,14 @@
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.QueryWrapper;
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.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.InventoryBatchAllocation;
import com.glxp.api.entity.inout.IoOrderDetailResultEntity;
@ -16,9 +21,13 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@ -27,13 +36,15 @@ public class InvProductBatchService extends ServiceImpl<InvProductBatchDao, InvP
@Resource
private InvProductBatchDao inventoryBatchMapper;
InvProductBatchDao invProductBatchDao;
@Resource
InvProductRecordService inventoryRecordService;
@Resource
InvProductService invProductService;
public Long createInventoryBatch(InvProductBatchEntity inventoryBatchDO) {
// 插入
inventoryBatchMapper.insert(inventoryBatchDO);
invProductBatchDao.insert(inventoryBatchDO);
// 返回
return inventoryBatchDO.getId();
}
@ -42,18 +53,18 @@ public class InvProductBatchService extends ServiceImpl<InvProductBatchDao, InvP
// 校验存在
validateInventoryBatchExists(inventoryBatchDO.getId());
// 更新
inventoryBatchMapper.updateById(inventoryBatchDO);
invProductBatchDao.updateById(inventoryBatchDO);
}
public void deleteInventoryBatch(Long id) {
// 校验存在
validateInventoryBatchExists(id);
// 删除
inventoryBatchMapper.deleteById(id);
invProductBatchDao.deleteById(id);
}
private void validateInventoryBatchExists(Long id) {
if (inventoryBatchMapper.selectById(id) == null) {
if (invProductBatchDao.selectById(id) == null) {
throw new JsonException("库存不存在");
}
}
@ -64,7 +75,7 @@ public class InvProductBatchService extends ServiceImpl<InvProductBatchDao, InvP
*/
public List<InventoryBatchAllocation> selectBatchesByFIFO(Long productId, Long warehouseId, Integer requiredQuantity) {
// 1. 按入库时间正序查询可用批次
List<InvProductBatchEntity> availableBatches = inventoryBatchMapper.selectList(new LambdaQueryWrapper<InvProductBatchEntity>()
List<InvProductBatchEntity> availableBatches = invProductBatchDao.selectList(new LambdaQueryWrapper<InvProductBatchEntity>()
.eq(InvProductBatchEntity::getRelIdFk, productId)
.eq(InvProductBatchEntity::getInvCode, warehouseId)
.gt(InvProductBatchEntity::getReCount, 0) // 修正数量大于0的批次
@ -114,14 +125,11 @@ public class InvProductBatchService extends ServiceImpl<InvProductBatchDao, InvP
updateInventoryBatch(batchDO);
// 创建出库流水
createOutboundRecord(order, item, allocation);
}
// 3. 更新主表库存
int totalOutQuantity = allocations.stream()
.mapToInt(InventoryBatchAllocation::getAllocatedQuantity)
.sum();
// todo 更新inv_product 主表
//更新主表库存inv_product
invProductService.updateInvProduct(batchDO.getRelIdFk(),batchDO.getCustomerId(),batchDO.getInvCode(),batchDO.getDeptCode(),allocation.getAllocatedQuantity());
}
}
@ -177,7 +185,7 @@ public class InvProductBatchService extends ServiceImpl<InvProductBatchDao, InvP
private void validateExpiry(List<IoOrderDetailResultEntity> items, IoOrderEntity orderDO) {
LocalDateTime now = LocalDateTime.now();
for (IoOrderDetailResultEntity item : items) {
List<InvProductBatchEntity> batches = inventoryBatchMapper.selectList(
List<InvProductBatchEntity> batches = invProductBatchDao.selectList(
new LambdaQueryWrapper<InvProductBatchEntity>()
.eq(InvProductBatchEntity::getRelIdFk, item.getBindRlFk())
.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.glxp.api.dao.inv.InvProductDao;
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.exception.JsonException;
import com.glxp.api.req.inv.FilterInvProductRequest;
import com.glxp.api.res.inv.InvProductResponse;
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) {
return invProductDao.selectOne(new QueryWrapper<InvProductEntity>().eq("relIdFk", relId)
.eq(StrUtil.isNotBlank(batchNo), "batchNo", batchNo).isNull(StrUtil.isEmpty(batchNo), "batchNo")
.eq("supId", supId)
public InvProductEntity selectByUnique(String relIdFk, String supId, String deptCode, String invCode, String invSpaceCode) {
return invProductDao.selectOne(new QueryWrapper<InvProductEntity>()
.eq(StrUtil.isNotBlank(relIdFk),"relIdFk", relIdFk)
.eq(StrUtil.isNotBlank(supId),"supId", supId)
.eq(StrUtil.isNotBlank(deptCode),"deptCode", deptCode)
.eq("invCode", invCode)
.eq(price != null, "price", price).isNull(price == null, "price").last("limit 1")
.eq(StrUtil.isNotBlank(invCode),"invCode", invCode)
.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.util.ResultVOUtils;
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.InvRemindMsgDao;
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.InvRemindMsgEntity;
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.util.MsDateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -40,6 +43,10 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService {
private InvProductDao invProductDao;
@Resource
private UdiRelevanceDao udiRelevanceDao;
@Autowired
private InvProductBatchDao invProductBatchDao;
@Autowired
private InvProductBatchService invProductBatchService;
@Override
public List<InvRemindMsgResponse> filterList(FilterInvRemindMsgRequest filterInvRemindMsgRequest) {
@ -71,38 +78,38 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService {
public void createRemindMsg(InvRemindSetEntity invRemindSetEntity) {
log.info("库存预警设置:{}", invRemindSetEntity.toString());
//查询库存数量
List<InvProductEntity> invProductList = invProductDao.selectInvProductInfo(invRemindSetEntity.getInvCode(), invRemindSetEntity.getInvSpaceCode(), invRemindSetEntity.getRelId());
if (CollUtil.isNotEmpty(invProductList)) {
List<InvProductEntity> invDataList = new CopyOnWriteArrayList<>(invProductList);
List<InvProductBatchEntity> invProductBatchEntityList = invProductBatchService.selectInvProductInfo(invRemindSetEntity.getInvCode(), invRemindSetEntity.getInvSpaceCode(), invRemindSetEntity.getRelId());
if (CollUtil.isNotEmpty(invProductBatchEntityList)) {
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) {
log.info("此库存产品在耗材字典中不存在,无法生成库存数量及近效期相关预警信息");
} else {
//初始化查询预警消息参数
FilterInvRemindMsgRequest invRemindMsgRequest = new FilterInvRemindMsgRequest();
invRemindMsgRequest.setRelId(invProductEntity.getRelIdFk().toString());
invRemindMsgRequest.setBatchNo(invProductEntity.getBatchNo());
invRemindMsgRequest.setDeptCode(invProductEntity.getDeptCode());
invRemindMsgRequest.setInvCode(invProductEntity.getInvCode());
invRemindMsgRequest.setInvSpaceCode(invProductEntity.getInvSpaceCode());
invRemindMsgRequest.setSupId(invProductEntity.getSupId());
invRemindMsgRequest.setRelId(invProductBatchEntity.getRelIdFk().toString());
invRemindMsgRequest.setBatchNo(invProductBatchEntity.getBatchNo());
invRemindMsgRequest.setDeptCode(invProductBatchEntity.getDeptCode());
invRemindMsgRequest.setInvCode(invProductBatchEntity.getInvCode());
invRemindMsgRequest.setInvSpaceCode(invProductBatchEntity.getInvSpaceCode());
invRemindMsgRequest.setSupId(invProductBatchEntity.getCustomerId());
//根据预警设置,添加类型参数
if (invRemindSetEntity.getLowStock() && null != invRemindSetEntity.getLowStockNum()) {
//开启低库存预警
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);
}
} else {
String logInfo = invRemindSetEntity.getLowStock() ? "产品 " + invProductEntity.getRelIdFk() + " 未设置低库存预警数量" : "产品 " + invProductEntity.getRelIdFk() + " 未开启低库存预警";
String logInfo = invRemindSetEntity.getLowStock() ? "产品 " + invProductBatchEntity.getRelIdFk() + " 未设置低库存预警数量" : "产品 " + invProductBatchEntity.getRelIdFk() + " 未开启低库存预警";
log.info(logInfo);
}
@ -110,11 +117,11 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService {
if (invRemindSetEntity.getLackStock()) {
//开启负库存预警
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);
}
}
@ -122,26 +129,26 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService {
if (invRemindSetEntity.getOverStock() && null != invRemindSetEntity.getOverStockNum()) {
//开启库存积压预警
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);
}
} else {
String logInfo = invRemindSetEntity.getOverStock() ? "产品 " + invProductEntity.getRelIdFk() + " 未设置库存积压预警数量" : "产品 " + invProductEntity.getRelIdFk() + " 未开启库存积压预警";
String logInfo = invRemindSetEntity.getOverStock() ? "产品 " + invProductBatchEntity.getRelIdFk() + " 未设置库存积压预警数量" : "产品 " + invProductBatchEntity.getRelIdFk() + " 未开启库存积压预警";
log.info(logInfo);
}
if (invRemindSetEntity.getExpireDate()) {
//开启产品过期预警
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);
}
}
@ -149,20 +156,20 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService {
if (invRemindSetEntity.getRecentDate() && null != invRemindSetEntity.getRecentDateTime()) {
//开启库存近效期预警
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());
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);
}
}
} else {
String logInfo = invRemindSetEntity.getRecentDate() ? "产品 " + invProductEntity.getRelIdFk() + " 未设置近效期预警时间" : "产品 " + invProductEntity.getRelIdFk() + " 未开启近效期预警";
String logInfo = invRemindSetEntity.getRecentDate() ? "产品 " + invProductBatchEntity.getRelIdFk() + " 未设置近效期预警时间" : "产品 " + invProductBatchEntity.getRelIdFk() + " 未开启近效期预警";
log.info(logInfo);
}
}
@ -220,20 +227,20 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService {
*
*
* @param invRemindMsgRequest
* @param invProductEntity
* @param invProductBatchEntity
* @return
*/
private InvRemindMsgEntity getInvRemindMsgEntity(FilterInvRemindMsgRequest invRemindMsgRequest, InvProductEntity invProductEntity) {
private InvRemindMsgEntity getInvRemindMsgEntity(FilterInvRemindMsgRequest invRemindMsgRequest, InvProductBatchEntity invProductBatchEntity) {
InvRemindMsgEntity msgEntity = invRemindMsgDao.selectRemindMsg(invRemindMsgRequest);
if (null == msgEntity) {
//数据库不存在对应的预警消息,生成新的预警消息
msgEntity = new InvRemindMsgEntity();
msgEntity.setRelId(invProductEntity.getRelIdFk().toString()); //耗材字典产品ID
msgEntity.setBatchNo(invProductEntity.getBatchNo()); //批次号
msgEntity.setSupId(invProductEntity.getSupId()); //供应商ID
msgEntity.setDeptCode(invProductEntity.getDeptCode()); //部门编码
msgEntity.setInvCode(invProductEntity.getInvCode()); //仓库编码
msgEntity.setInvSpaceCode(invProductEntity.getInvSpaceCode()); //货位号
msgEntity.setRelId(invProductBatchEntity.getRelIdFk().toString()); //耗材字典产品ID
msgEntity.setBatchNo(invProductBatchEntity.getBatchNo()); //批次号
msgEntity.setSupId(invProductBatchEntity.getCustomerId()); //供应商ID
msgEntity.setDeptCode(invProductBatchEntity.getDeptCode()); //部门编码
msgEntity.setInvCode(invProductBatchEntity.getInvCode()); //仓库编码
msgEntity.setInvSpaceCode(invProductBatchEntity.getInvSpaceCode()); //货位号
msgEntity.setType(Integer.valueOf(invRemindMsgRequest.getType())); //预警类型
Date date = new Date();
@ -241,11 +248,11 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService {
}
//更新预警消息的产品日期,数量等信息
msgEntity.setProductionDate(invProductEntity.getProductionDate());
msgEntity.setExpireDate(invProductEntity.getExpireDate());
msgEntity.setInCount(invProductEntity.getInCount());
msgEntity.setOutCount(invProductEntity.getOutCount());
msgEntity.setReCount(invProductEntity.getReCount());
msgEntity.setProductionDate(invProductBatchEntity.getProductionDate());
msgEntity.setExpireDate(invProductBatchEntity.getExpireDate());
msgEntity.setInCount(invProductBatchEntity.getInCount());
msgEntity.setOutCount(invProductBatchEntity.getOutCount());
msgEntity.setReCount(invProductBatchEntity.getReCount());
return msgEntity;
}

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

@ -4,9 +4,9 @@ server:
spring:
datasource:
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
password: Glxp@6066
password: 123456
hikari:
connection-timeout: 60000
maximum-pool-size: 20

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

@ -26,7 +26,7 @@
LEFT JOIN basic_products ON basic_products.uuid = basic_udirel.uuid
left join inv_product_detail ipd on ipd.relId = mad.relId
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>
<if test="orderIdFk != null and orderIdFk != ''">
AND mad.orderIdFk = #{orderIdFk}

@ -48,7 +48,7 @@
select od.*, bps.cpmctymc productName, bps.ggxh, bps.ylqxzcrbarmc, bps.zczbhhzbapzbh
from inv_count_order_detail od
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
where od.orderIdFk = #{orderIdFk}
group by od.id

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

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

@ -52,7 +52,7 @@
bp.basicPrductRemak8,
bp.packUnit,
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)
LEFT JOIN basic_corp ON ip.supId = basic_corp.erpId
LEFT JOIN auth_dept ON auth_dept.CODE = ip.deptCode
@ -172,7 +172,7 @@
sum(ip.inCount) inCount,
sum(ip.outCount) outCount,
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_products bp on bu.uuid = bp.uuid
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 ip.*
from inv_product ip
from inv_product_batch ip
left join inv_product_detail ipd on ip.relIdFk = ipd.relId
and ifnull(ip.batchNo, 'empty') = ifnull(ipd.batchNo, 'empty')
and ip.deptCode = ipd.deptCode
@ -303,7 +303,7 @@
inv_product.reCount,
basic_products.cpmctymc
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 COALESCE(inv_product.batchNo, 'empty') = COALESCE(inv_product_detail.batchNo, 'empty')
left join basic_udirel on inv_product_detail.relId = basic_udirel.id
@ -340,7 +340,7 @@
ip.inCount,
ip.outCount,
ip.reCount
from inv_product ip
from inv_product_batch ip
left join inv_product_detail ipd
on ip.relIdFk = ipd.relId and ifnull(ip.batchNo, 'empty') = ifnull(ipd.batchNo, 'empty')
<where>
@ -359,7 +359,7 @@
<select id="filterProductNames" resultType="com.glxp.api.res.inv.InvProductResponse">
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
ifnull(ip.batchNo, 'empty') = ifnull(ipd.batchNo, 'empty')
left join basic_udirel bu on bu.id = ip.relIdFk
@ -402,7 +402,7 @@
ip.deptCode,
ip.price,
ip.invCode
from inv_product ip
from inv_product_batch ip
inner join basic_udirel on ip.relIdFk = basic_udirel.id
inner join basic_products bp on basic_udirel.uuid = bp.uuid
left join basic_corp on ip.supId = basic_corp.erpId
@ -492,7 +492,7 @@
ip.deptCode,
ip.price,
ip.invCode
from inv_product ip
from inv_product_batch ip
inner join basic_udirel on ip.relIdFk = basic_udirel.id
inner join basic_products bp on basic_udirel.uuid = bp.uuid
left join basic_corp on ip.supId = basic_corp.erpId
@ -591,7 +591,7 @@
<select id="filterReCount" resultType="string">
select ip.supId
from inv_product ip
from inv_product_batch ip
<where>
AND ip.reCount > 0
<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_orderId`(`orderId` 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