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