|  |  | @ -3,7 +3,6 @@ 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 cn.hutool.json.JSONUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  | 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; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.common.res.BaseResponse; |  |  |  | import com.glxp.api.common.res.BaseResponse; | 
			
		
	
	
		
		
			
				
					|  |  | @ -16,6 +15,7 @@ import com.glxp.api.entity.inv.InvRemindSetEntity; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.req.inv.FilterInvRemindMsgRequest; |  |  |  | import com.glxp.api.req.inv.FilterInvRemindMsgRequest; | 
			
		
	
		
		
			
				
					
					|  |  |  | import com.glxp.api.res.inv.InvRemindMsgResponse; |  |  |  | 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.DateUtil; | 
			
		
	
		
		
			
				
					
					|  |  |  | import lombok.extern.slf4j.Slf4j; |  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.springframework.stereotype.Service; |  |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
		
			
				
					
					|  |  |  | import org.springframework.transaction.annotation.Transactional; |  |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
	
		
		
			
				
					|  |  | @ -70,13 +70,6 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService { | 
			
		
	
		
		
			
				
					
					|  |  |  |             List<InvProductEntity> invDataList = new CopyOnWriteArrayList<>(invProductList); |  |  |  |             List<InvProductEntity> invDataList = new CopyOnWriteArrayList<>(invProductList); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             invDataList.parallelStream().forEach(invProductEntity -> { |  |  |  |             invDataList.parallelStream().forEach(invProductEntity -> { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 //根据预警设置,查询对应的预警消息
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 QueryWrapper<InvRemindMsgEntity> wrapper = new QueryWrapper<>(); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 wrapper.eq(StrUtil.isNotBlank(invRemindSetEntity.getRelId()), "relId", invRemindSetEntity.getRelId()) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                         .eq("invCode", invRemindSetEntity.getInvCode()) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                         .eq(StrUtil.isNotBlank(invRemindSetEntity.getInvSpaceCode()), "invSpaceCode", invRemindSetEntity.getInvSpaceCode()); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 //初始化查询预警消息参数
 |  |  |  |                 //初始化查询预警消息参数
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                 FilterInvRemindMsgRequest invRemindMsgRequest = new FilterInvRemindMsgRequest(); |  |  |  |                 FilterInvRemindMsgRequest invRemindMsgRequest = new FilterInvRemindMsgRequest(); | 
			
		
	
		
		
			
				
					
					|  |  |  |                 invRemindMsgRequest.setRelId(invProductEntity.getRelIdFk().toString()); |  |  |  |                 invRemindMsgRequest.setRelId(invProductEntity.getRelIdFk().toString()); | 
			
		
	
	
		
		
			
				
					|  |  | @ -88,7 +81,7 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 //根据预警设置,添加类型参数
 |  |  |  |                 //根据预警设置,添加类型参数
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                 if (invRemindSetEntity.getLowStock()) { |  |  |  |                 if (invRemindSetEntity.getLowStock()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                     //开启低库存预警
 |  |  |  |                     //开启低库存预警
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                     invRemindMsgRequest.setType("1"); //库存不足类型
 |  |  |  |                     invRemindMsgRequest.setType("1"); //库存不足预警
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                     InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity); |  |  |  |                     InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |                     //判断是否需要生成/刷新库存预警
 |  |  |  |                     //判断是否需要生成/刷新库存预警
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                     if (msgEntity.getNextRemindTime().getTime() >= new Date().getTime() && invProductEntity.getReCount() < invRemindSetEntity.getLowStockNum()) { |  |  |  |                     if (msgEntity.getNextRemindTime().getTime() >= new Date().getTime() && invProductEntity.getReCount() < invRemindSetEntity.getLowStockNum()) { | 
			
		
	
	
		
		
			
				
					|  |  | @ -100,7 +93,7 @@ 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, invProductEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |                     //判断是否需要生成/刷新库存预警
 |  |  |  |                     //判断是否需要生成/刷新库存预警
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                     if (msgEntity.getNextRemindTime().getTime() >= new Date().getTime() && invProductEntity.getReCount() < 0) { |  |  |  |                     if (msgEntity.getNextRemindTime().getTime() >= new Date().getTime() && invProductEntity.getReCount() < 0) { | 
			
		
	
	
		
		
			
				
					|  |  | @ -112,20 +105,72 @@ public class InvRemindMsgServiceImpl implements InvRemindMsgService { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                 if (invRemindSetEntity.getOverStock()) { |  |  |  |                 if (invRemindSetEntity.getOverStock()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                     //开启库存积压预警
 |  |  |  |                     //开启库存积压预警
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                     invRemindMsgRequest.setType("3"); //库存积压类型
 |  |  |  |                     invRemindMsgRequest.setType("3"); //库存积压预警
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                     InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity); |  |  |  |                     InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |                     //判断是否需要生成/刷新库存预警
 |  |  |  |                     //判断是否需要生成/刷新库存预警
 | 
			
		
	
		
		
			
				
					
					|  |  |  |                     if (msgEntity.getNextRemindTime().getTime() > new Date().getTime() && invProductEntity.getReCount() > invRemindSetEntity.getOverStockNum()) { |  |  |  |                     if (msgEntity.getNextRemindTime().getTime() > new Date().getTime() && invProductEntity.getReCount() > invRemindSetEntity.getOverStockNum()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         //设置预警消息
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         msgEntity.setMsg(StrUtil.format("库存积压,当前库存数量:{}", invProductEntity.getReCount())); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         saveMsg(msgEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (invRemindSetEntity.getExpireDate()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     //开启产品过期预警
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     invRemindMsgRequest.setType("4"); //库存过期预警
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     //判断是否需要生成/刷新库存预警
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     if (msgEntity.getNextRemindTime().getTime() > new Date().getTime() && StrUtil.isNotBlank(invProductEntity.getExpireDate()) && DateUtil.compareExpire(invProductEntity.getExpireDate(), null)) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         //设置预警消息
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         msgEntity.setMsg(StrUtil.format("产品已过期,产品失效日期:{}", invProductEntity.getExpireDate())); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         saveMsg(msgEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |                     } |  |  |  |                     } | 
			
		
	
		
		
			
				
					
					|  |  |  |                 } |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 if (invRemindSetEntity.getRecentDate()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     //开启库存近效期预警
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     invRemindMsgRequest.setType("5"); //库存近效期预警
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     InvRemindMsgEntity msgEntity = getInvRemindMsgEntity(invRemindMsgRequest, invProductEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     //判断是否需要生成/刷新库存预警
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     if (msgEntity.getNextRemindTime().getTime() > new Date().getTime() && StrUtil.isNotBlank(invProductEntity.getExpireDate())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         //计算产品记录失效的天数
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         long recentDay = Long.parseLong(DateUtil.getDate("yyMMdd")) - Long.parseLong(invProductEntity.getExpireDate()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         if (invRemindSetEntity.getRecentDateDay() > recentDay) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             //设置预警消息
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             msgEntity.setMsg(StrUtil.format("库存即将过期,产品失效日期:{}", invProductEntity.getExpireDate())); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             saveMsg(msgEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |             }); |  |  |  |             }); | 
			
		
	
		
		
			
				
					
					|  |  |  |         } else { |  |  |  |         } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |             log.info("此仓库或产品库存信息不存在"); |  |  |  |             log.info("此仓库或产品库存信息不存在"); | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     @Override | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public BaseResponse ignoreMsg(Integer id, Integer ignoreStatus) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         InvRemindMsgEntity msgEntity = invRemindMsgDao.selectById(id); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //根据忽略状态,更新忽略时间
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Date updateTime = msgEntity.getUpdateTime(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         switch (ignoreStatus) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             case 1:  //忽略7天
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 msgEntity.setNextRemindTime(DateUtil.getBeforeDay(updateTime, 7 * 24)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 break; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             case 2: //忽略15天
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 msgEntity.setNextRemindTime(DateUtil.getBeforeDay(updateTime, 15 * 24)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 break; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             case 3: //忽略30天
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 msgEntity.setNextRemindTime(DateUtil.getBeforeDay(updateTime, 30 * 24)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 break; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             default: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 break; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         msgEntity.setIgnoreStatus(ignoreStatus); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         invRemindMsgDao.updateById(msgEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return ResultVOUtils.success("已忽略提醒"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     /** |  |  |  |     /** | 
			
		
	
		
		
			
				
					
					|  |  |  |      * 新增或更新预警消息 |  |  |  |      * 新增或更新预警消息 | 
			
		
	
		
		
			
				
					
					|  |  |  |      * |  |  |  |      * | 
			
		
	
	
		
		
			
				
					|  |  | 
 |