|
|
|
@ -1,7 +1,9 @@
|
|
|
|
|
package com.hnac.hzims.safeproduct.service.impl; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import com.hnac.hzims.safeproduct.dto.SafetyToolTypeBatchConfigDTO; |
|
|
|
|
import com.hnac.hzims.safeproduct.dto.SafetyToolTypeDTO; |
|
|
|
@ -13,14 +15,15 @@ import com.hnac.hzims.safeproduct.mapper.SafetyToolTypeUserMapper;
|
|
|
|
|
import com.hnac.hzims.safeproduct.service.ISafetyToolTypeService; |
|
|
|
|
import com.hnac.hzims.safeproduct.vo.SafetyToolTypeVO; |
|
|
|
|
import com.hnac.hzims.safeproduct.wrapper.SafetyToolTypeWrapper; |
|
|
|
|
import com.hnac.hzinfo.exception.HzServiceException; |
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.springblade.core.mp.support.Condition; |
|
|
|
|
import org.springblade.core.mp.support.Query; |
|
|
|
|
import org.springblade.core.tool.api.ResultCode; |
|
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
@ -40,24 +43,26 @@ import java.util.stream.Collectors;
|
|
|
|
|
public class SafetyToolTypeServiceImpl extends ServiceImpl<SafetyToolTypeMapper, SafetyToolTypeEntity> implements ISafetyToolTypeService { |
|
|
|
|
|
|
|
|
|
private final SafetyToolTypeMapper safetyToolTypeMapper; |
|
|
|
|
|
|
|
|
|
private final SafetyToolTypeUserMapper safetyToolTypeUserMapper; |
|
|
|
|
private final RedisTemplate redisTemplate; |
|
|
|
|
|
|
|
|
|
@Value("${hzims.safeProduct.safeTool.sadeToolKey}") |
|
|
|
|
private String sadeToolKey; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public long doSave(SafetyToolTypeDTO req) { |
|
|
|
|
// 同厂站名称唯一性校验
|
|
|
|
|
QueryWrapper<SafetyToolTypeEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.lambda().eq(SafetyToolTypeEntity::getTypeName, req.getTypeName()) |
|
|
|
|
.eq(SafetyToolTypeEntity::getDeptId, req.getDeptId()); |
|
|
|
|
SafetyToolTypeEntity safetyToolType = this.getOne(queryWrapper); |
|
|
|
|
if (ObjectUtil.isNotEmpty(safetyToolType)) { |
|
|
|
|
throw new HzServiceException(ResultCode.PARAM_VALID_ERROR, "同厂站的安全工器具类型名称不可重复"); |
|
|
|
|
} |
|
|
|
|
if (!super.save(req)) { |
|
|
|
|
throw new RuntimeException("数据库insert操作失败!"); |
|
|
|
|
throw new HzServiceException(ResultCode.FAILURE, "安全工器具类型新增失败"); |
|
|
|
|
} |
|
|
|
|
insertBatchToolTypeUser(req.getId(), req.getUserIds()); |
|
|
|
|
/**将对象存入redis中 定时任务轮询查询提醒通知用户**/ |
|
|
|
|
// Instant instant = req.getSendTime().toInstant();
|
|
|
|
|
// ZoneId zoneId = ZoneId.systemDefault();
|
|
|
|
|
// LocalDateTime sendTime = instant.atZone(zoneId).toLocalDateTime();
|
|
|
|
|
//redisTemplate.opsForZSet().add(sadeToolKey,req, sendTime.toEpochSecond(ZoneOffset.of("+8")));
|
|
|
|
|
//log.info("---- 安全工器具推送对象 ---- size = " + redisTemplate.opsForZSet().size(sadeToolKey));
|
|
|
|
|
return req.getId(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -89,6 +94,15 @@ public class SafetyToolTypeServiceImpl extends ServiceImpl<SafetyToolTypeMapper,
|
|
|
|
|
@Override |
|
|
|
|
public void doEdit(SafetyToolTypeDTO req) { |
|
|
|
|
this.queryAndCheckExists(req.getId()); |
|
|
|
|
// 同厂站名称唯一性校验
|
|
|
|
|
QueryWrapper<SafetyToolTypeEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.lambda().ne(SafetyToolTypeEntity::getId, req.getId()).and(q -> { |
|
|
|
|
q.eq(SafetyToolTypeEntity::getTypeName, req.getTypeName()).eq(SafetyToolTypeEntity::getDeptId, req.getDeptId()); |
|
|
|
|
}); |
|
|
|
|
SafetyToolTypeEntity safetyToolType = this.getOne(queryWrapper); |
|
|
|
|
if (ObjectUtil.isNotEmpty(safetyToolType)) { |
|
|
|
|
throw new HzServiceException(ResultCode.PARAM_VALID_ERROR, "同厂站的安全工器具类型名称不可重复"); |
|
|
|
|
} |
|
|
|
|
super.updateById(req); |
|
|
|
|
safetyToolTypeUserMapper.deleteByTypeId(req.getId()); |
|
|
|
|
insertBatchToolTypeUser(req.getId(), req.getUserIds()); |
|
|
|
@ -109,7 +123,7 @@ public class SafetyToolTypeServiceImpl extends ServiceImpl<SafetyToolTypeMapper,
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage pageCondition(SafetyToolTypeListDTO req, Query query) { |
|
|
|
|
public IPage<SafetyToolTypeVO> pageCondition(SafetyToolTypeListDTO req, Query query) { |
|
|
|
|
QueryWrapper<SafetyToolTypeEntity> queryWrapper = new QueryWrapper<SafetyToolTypeEntity>() {{ |
|
|
|
|
if (null != req.getSendType()) { |
|
|
|
|
eq("send_type", req.getSendType()); |
|
|
|
@ -124,8 +138,9 @@ public class SafetyToolTypeServiceImpl extends ServiceImpl<SafetyToolTypeMapper,
|
|
|
|
|
le("send_time", req.getEndSendTime()); |
|
|
|
|
} |
|
|
|
|
}}; |
|
|
|
|
IPage pages = super.page(Condition.getPage(query), queryWrapper); |
|
|
|
|
pages.setRecords(SafetyToolTypeWrapper.build().listVO(pages.getRecords())); |
|
|
|
|
IPage<SafetyToolTypeEntity> safetyToolTypePages = super.page(Condition.getPage(query), queryWrapper); |
|
|
|
|
IPage<SafetyToolTypeVO> pages = new Page<>(); |
|
|
|
|
pages.setRecords(SafetyToolTypeWrapper.build().listVO(safetyToolTypePages.getRecords())); |
|
|
|
|
return pages; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|