|
|
@ -2,6 +2,7 @@ package com.glxp.api.service.inv.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
import com.glxp.api.common.enums.ResultEnum;
|
|
|
|
import com.glxp.api.common.enums.ResultEnum;
|
|
|
@ -90,54 +91,62 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService {
|
|
|
|
invRemindMsgRequest.setType("1"); //库存不足类型
|
|
|
|
invRemindMsgRequest.setType("1"); //库存不足类型
|
|
|
|
InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity);
|
|
|
|
InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity);
|
|
|
|
//判断是否需要生成/刷新库存预警
|
|
|
|
//判断是否需要生成/刷新库存预警
|
|
|
|
if (msgEntity.getNextRemindTime().getTime() > new Date().getTime() && msgEntity.getReCount() < invRemindSetEntity.getLowStockNum()) {
|
|
|
|
if (msgEntity.getNextRemindTime().getTime() >= new Date().getTime() && invProductEntity.getReCount() < invRemindSetEntity.getLowStockNum()) {
|
|
|
|
msgEntity.setStatus(1); //重置成为未确认消息
|
|
|
|
//设置预警消息
|
|
|
|
msgEntity.setIgnoreStatus(0); //消息忽略状态修改为不忽略
|
|
|
|
msgEntity.setMsg(StrUtil.format("库存数量已不足:{},当前库存数量:{} ", invRemindSetEntity.getLowStockNum(), invProductEntity.getReCount()));
|
|
|
|
msgEntity.setUpdateTime(new Date());
|
|
|
|
saveMsg(msgEntity);
|
|
|
|
msgEntity.setNextRemindTime(new Date());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (invRemindSetEntity.getLackStock()) {
|
|
|
|
InvRemindMsgEntity invRemindMsgEntity = invRemindMsgDao.selectOne(wrapper);
|
|
|
|
//开启负库存预警
|
|
|
|
if (null == invRemindMsgEntity) {
|
|
|
|
invRemindMsgRequest.setType("2");//负库存类型
|
|
|
|
invRemindMsgEntity = new InvRemindMsgEntity();
|
|
|
|
InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity);
|
|
|
|
invRemindMsgEntity.setCreateTime(new Date());
|
|
|
|
//判断是否需要生成/刷新库存预警
|
|
|
|
invRemindMsgEntity.setInvCode(invRemindSetEntity.getInvCode());
|
|
|
|
if (msgEntity.getNextRemindTime().getTime() >= new Date().getTime() && invProductEntity.getReCount() < 0) {
|
|
|
|
invRemindMsgEntity.setInvSpaceCode(invRemindSetEntity.getInvSpaceCode());
|
|
|
|
//设置预警消息
|
|
|
|
if (StrUtil.isBlank(invRemindSetEntity.getRelId())) {
|
|
|
|
msgEntity.setMsg(StrUtil.format("库存数量为负,当前库存数量:{}", invProductEntity.getReCount()));
|
|
|
|
//按照产品统计
|
|
|
|
saveMsg(msgEntity);
|
|
|
|
invRemindMsgEntity.setRelId(invRemindSetEntity.getRelId());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
//按仓库统计
|
|
|
|
|
|
|
|
//TODO 待完善
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//生成或更新预警消息标识
|
|
|
|
if (invRemindSetEntity.getOverStock()) {
|
|
|
|
boolean flag = false;
|
|
|
|
//开启库存积压预警
|
|
|
|
|
|
|
|
invRemindMsgRequest.setType("3"); //库存积压类型
|
|
|
|
StringBuffer msg = new StringBuffer();
|
|
|
|
InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity);
|
|
|
|
|
|
|
|
//判断是否需要生成/刷新库存预警
|
|
|
|
|
|
|
|
if (msgEntity.getNextRemindTime().getTime() > new Date().getTime() && invProductEntity.getReCount() > invRemindSetEntity.getOverStockNum()) {
|
|
|
|
|
|
|
|
|
|
|
|
//根据库存信息设置,计算或升成库存预警
|
|
|
|
|
|
|
|
if (invRemindSetEntity.getLowStock()) {
|
|
|
|
|
|
|
|
//开启低库存预警
|
|
|
|
|
|
|
|
if (invProductEntity.getReCount() < invRemindSetEntity.getLowStockNum()) {
|
|
|
|
|
|
|
|
invRemindMsgEntity.setReCount(invRemindMsgEntity.getReCount());
|
|
|
|
|
|
|
|
invRemindMsgEntity.setInCount(invProductEntity.getInCount());
|
|
|
|
|
|
|
|
invRemindMsgEntity.setOutCount(invProductEntity.getOutCount());
|
|
|
|
|
|
|
|
//invRemindMsgEntity.set
|
|
|
|
|
|
|
|
msg.append("库存过低,当前库存数量:").append(invProductEntity.getReCount()).append("\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flag = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
log.info("此仓库或产品库存信息不存在");
|
|
|
|
log.info("此仓库或产品库存信息不存在");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 新增或更新预警消息
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param msgEntity
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private void saveMsg(InvRemindMsgEntity msgEntity) {
|
|
|
|
|
|
|
|
msgEntity.setStatus(1); //重置成为未确认消息
|
|
|
|
|
|
|
|
msgEntity.setIgnoreStatus(0); //消息忽略状态修改为不忽略
|
|
|
|
|
|
|
|
msgEntity.setHandleMsg(null); //处理方式重置为空
|
|
|
|
|
|
|
|
msgEntity.setUpdateTime(new Date());
|
|
|
|
|
|
|
|
msgEntity.setNextRemindTime(new Date());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (null == msgEntity.getId()) {
|
|
|
|
|
|
|
|
log.info("新增库存预警消息:{}", JSONUtil.toJsonStr(msgEntity));
|
|
|
|
|
|
|
|
invRemindMsgDao.insert(msgEntity);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
log.info("更新库存预警消息:{}", JSONUtil.toJsonStr(msgEntity));
|
|
|
|
|
|
|
|
invRemindMsgDao.updateById(msgEntity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询或生成预警消息提醒
|
|
|
|
* 查询或生成预警消息提醒
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -155,14 +164,10 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService {
|
|
|
|
msgEntity.setDeptCode(invProductEntity.getDeptCode()); //部门编码
|
|
|
|
msgEntity.setDeptCode(invProductEntity.getDeptCode()); //部门编码
|
|
|
|
msgEntity.setInvCode(invProductEntity.getInvCode()); //仓库编码
|
|
|
|
msgEntity.setInvCode(invProductEntity.getInvCode()); //仓库编码
|
|
|
|
msgEntity.setInvSpaceCode(invProductEntity.getInvSpaceCode()); //货位号
|
|
|
|
msgEntity.setInvSpaceCode(invProductEntity.getInvSpaceCode()); //货位号
|
|
|
|
msgEntity.setStatus(1); //消息状态:未确认
|
|
|
|
|
|
|
|
msgEntity.setIgnoreStatus(0); //消息忽略状态:不忽略
|
|
|
|
|
|
|
|
msgEntity.setType(Integer.valueOf(invRemindMsgRequest.getType())); //预警类型
|
|
|
|
msgEntity.setType(Integer.valueOf(invRemindMsgRequest.getType())); //预警类型
|
|
|
|
|
|
|
|
|
|
|
|
Date date = new Date();
|
|
|
|
Date date = new Date();
|
|
|
|
msgEntity.setCreateTime(date);
|
|
|
|
msgEntity.setCreateTime(date);
|
|
|
|
msgEntity.setUpdateTime(date);
|
|
|
|
|
|
|
|
msgEntity.setNextRemindTime(date);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//更新预警消息的产品日期,数量等信息
|
|
|
|
//更新预警消息的产品日期,数量等信息
|
|
|
|