|
|
|
@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.google.zxing.BarcodeFormat; |
|
|
|
|
import com.hnac.hzims.message.dto.PlanMsgRecordDto; |
|
|
|
|
import com.hnac.hzims.safeproduct.constants.RedisConstants; |
|
|
|
|
import com.hnac.hzims.safeproduct.dto.SafetyToolBatchRecheckDTO; |
|
|
|
|
import com.hnac.hzims.safeproduct.dto.SafetyToolDTO; |
|
|
|
|
import com.hnac.hzims.safeproduct.entity.SafeProductPdf; |
|
|
|
@ -44,6 +45,7 @@ import org.springblade.system.user.entity.User;
|
|
|
|
|
import org.springblade.system.user.feign.IUserClient; |
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
|
import org.springframework.data.redis.core.ZSetOperations; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
import org.springframework.util.Assert; |
|
|
|
@ -126,7 +128,6 @@ public class SafetyToolServiceImpl extends BaseServiceImpl<SafetyToolMapper, Saf
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void doBatchRecheck(SafetyToolBatchRecheckDTO req) { |
|
|
|
|
//更新工器具记录数据
|
|
|
|
|
Date checkTime = Func.isNotEmpty(req.getCheckTime()) ? req.getCheckTime() : new Date(); |
|
|
|
|
Long userId = AuthUtil.getUserId(); |
|
|
|
|
String userName = AuthUtil.getUserName(); |
|
|
|
@ -134,24 +135,22 @@ public class SafetyToolServiceImpl extends BaseServiceImpl<SafetyToolMapper, Saf
|
|
|
|
|
for (SafetyToolEntity item : safetyTools) { |
|
|
|
|
item.setLastCheckTime(checkTime); |
|
|
|
|
item.setNextCheckTime(DateUtil.plusDays(checkTime, Long.valueOf(item.getSafeTime().toString()))); |
|
|
|
|
} |
|
|
|
|
if (!super.updateBatchById(safetyTools)) { |
|
|
|
|
throw new ServiceException("数据库update操作失败!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//插入复核记录
|
|
|
|
|
List<SafetyToolRecheckEntity> safetyToolRechecks = new ArrayList<>(safetyTools.size()); |
|
|
|
|
for (SafetyToolEntity item : safetyTools) { |
|
|
|
|
super.updateById(item); |
|
|
|
|
SafetyToolRecheckEntity entity = new SafetyToolRecheckEntity(); |
|
|
|
|
entity.setCheckUserName(userName); |
|
|
|
|
entity.setCheckUserId(userId); |
|
|
|
|
entity.setToolId(item.getId()); |
|
|
|
|
entity.setCheckTime(checkTime); |
|
|
|
|
entity.setRemark(req.getRemark()); |
|
|
|
|
safetyToolRechecks.add(entity); |
|
|
|
|
} |
|
|
|
|
if (safetyToolRecheckMapper.insertBatch(safetyToolRechecks) == 0) { |
|
|
|
|
throw new ServiceException("数据库insert操作失败!"); |
|
|
|
|
safetyToolRecheckMapper.insert(entity); |
|
|
|
|
// 计算下次推送时间
|
|
|
|
|
Date noticeDate = DateUtil.minusDays(item.getNextCheckTime(), item.getAdvanceNoticeDays()); |
|
|
|
|
String redisKey = RedisConstants.TOOLS_REMIND_MSG + ":" + item.getId(); |
|
|
|
|
// 删除提醒记录
|
|
|
|
|
redisTemplate.delete(redisKey); |
|
|
|
|
// 创建新的提醒记录
|
|
|
|
|
redisTemplate.opsForZSet().add(redisKey,item,noticeDate.getTime()); |
|
|
|
|
log.info("key为:"+redisTemplate.keys(RedisConstants.TOOLS_REMIND_MSG+"*")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|