diff --git a/src/main/java/com/glxp/api/controller/inv/InvCountOrderController.java b/src/main/java/com/glxp/api/controller/inv/InvCountOrderController.java index bfbef5d8e..be949b063 100644 --- a/src/main/java/com/glxp/api/controller/inv/InvCountOrderController.java +++ b/src/main/java/com/glxp/api/controller/inv/InvCountOrderController.java @@ -120,7 +120,7 @@ public class InvCountOrderController { * @return */ @AuthRuleAnnotation("") - @PostMapping("/invCount/order/updateCountOrderStatus") + @PostMapping("/inv/count/order/updateCountOrderStatus") public BaseResponse updateCountOrderStatus(@RequestBody FilterInvCountOrderRequest filterInvCountOrderRequest) { if (null == filterInvCountOrderRequest || StrUtil.isBlank(filterInvCountOrderRequest.getId()) || null == filterInvCountOrderRequest.getStatus()) { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); diff --git a/src/main/java/com/glxp/api/service/inv/impl/InvRemindMsgServiceImpl.java b/src/main/java/com/glxp/api/service/inv/impl/InvRemindMsgServiceImpl.java index 1971c47eb..c490b341e 100644 --- a/src/main/java/com/glxp/api/service/inv/impl/InvRemindMsgServiceImpl.java +++ b/src/main/java/com/glxp/api/service/inv/impl/InvRemindMsgServiceImpl.java @@ -2,6 +2,7 @@ package com.glxp.api.service.inv.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageHelper; import com.glxp.api.common.enums.ResultEnum; @@ -90,54 +91,62 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService { invRemindMsgRequest.setType("1"); //库存不足类型 InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity); //判断是否需要生成/刷新库存预警 - if (msgEntity.getNextRemindTime().getTime() > new Date().getTime() && msgEntity.getReCount() < invRemindSetEntity.getLowStockNum()) { - msgEntity.setStatus(1); //重置成为未确认消息 - msgEntity.setIgnoreStatus(0); //消息忽略状态修改为不忽略 - msgEntity.setUpdateTime(new Date()); - msgEntity.setNextRemindTime(new Date()); + if (msgEntity.getNextRemindTime().getTime() >= new Date().getTime() && invProductEntity.getReCount() < invRemindSetEntity.getLowStockNum()) { + //设置预警消息 + msgEntity.setMsg(StrUtil.format("库存数量已不足:{},当前库存数量:{} ", invRemindSetEntity.getLowStockNum(), invProductEntity.getReCount())); + saveMsg(msgEntity); } } - - InvRemindMsgEntity invRemindMsgEntity = invRemindMsgDao.selectOne(wrapper); - if (null == invRemindMsgEntity) { - invRemindMsgEntity = new InvRemindMsgEntity(); - invRemindMsgEntity.setCreateTime(new Date()); - invRemindMsgEntity.setInvCode(invRemindSetEntity.getInvCode()); - invRemindMsgEntity.setInvSpaceCode(invRemindSetEntity.getInvSpaceCode()); - if (StrUtil.isBlank(invRemindSetEntity.getRelId())) { - //按照产品统计 - invRemindMsgEntity.setRelId(invRemindSetEntity.getRelId()); - } else { - //按仓库统计 - //TODO 待完善 + if (invRemindSetEntity.getLackStock()) { + //开启负库存预警 + invRemindMsgRequest.setType("2");//负库存类型 + InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity); + //判断是否需要生成/刷新库存预警 + if (msgEntity.getNextRemindTime().getTime() >= new Date().getTime() && invProductEntity.getReCount() < 0) { + //设置预警消息 + msgEntity.setMsg(StrUtil.format("库存数量为负,当前库存数量:{}", invProductEntity.getReCount())); + saveMsg(msgEntity); } } - //生成或更新预警消息标识 - boolean flag = false; - - StringBuffer msg = new StringBuffer(); + if (invRemindSetEntity.getOverStock()) { + //开启库存积压预警 + invRemindMsgRequest.setType("3"); //库存积压类型 + 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 { 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.setInvCode(invProductEntity.getInvCode()); //仓库编码 msgEntity.setInvSpaceCode(invProductEntity.getInvSpaceCode()); //货位号 - msgEntity.setStatus(1); //消息状态:未确认 - msgEntity.setIgnoreStatus(0); //消息忽略状态:不忽略 msgEntity.setType(Integer.valueOf(invRemindMsgRequest.getType())); //预警类型 Date date = new Date(); msgEntity.setCreateTime(date); - msgEntity.setUpdateTime(date); - msgEntity.setNextRemindTime(date); } //更新预警消息的产品日期,数量等信息 diff --git a/src/main/java/com/glxp/api/task/InvRemindMsgTask.java b/src/main/java/com/glxp/api/task/InvRemindMsgTask.java index dc90292f7..5965e32a2 100644 --- a/src/main/java/com/glxp/api/task/InvRemindMsgTask.java +++ b/src/main/java/com/glxp/api/task/InvRemindMsgTask.java @@ -1,10 +1,7 @@ package com.glxp.api.task; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.thread.ThreadUtil; import com.glxp.api.dao.inv.InvRemindSetDao; import com.glxp.api.dao.schedule.ScheduledDao; -import com.glxp.api.entity.inv.InvRemindSetEntity; import com.glxp.api.entity.system.ScheduledEntity; import com.glxp.api.req.system.ScheduledRequest; import com.glxp.api.service.inv.InvRemindMsgService; @@ -15,7 +12,6 @@ import org.springframework.scheduling.support.CronTrigger; import org.springframework.stereotype.Component; import javax.annotation.Resource; -import java.util.List; @Slf4j @Component @@ -44,7 +40,7 @@ public class InvRemindMsgTask implements SchedulingConfigurer { } private void process() { - log.info("开始扫描库存信息,生成库存预警消息"); + /*log.info("开始扫描库存信息,生成库存预警消息"); List invRemindSetEntities = invRemindSetDao.selectList(null); if (CollUtil.isNotEmpty(invRemindSetEntities)) { log.info("库存预警设置条数:{}", invRemindSetEntities.size()); @@ -54,6 +50,6 @@ public class InvRemindMsgTask implements SchedulingConfigurer { } } else { log.info("无库存预警设置,结束库存扫描"); - } + }*/ } }