Browse Source

update: 安全工器具类型新增机构字段

zhongwei
liwen 3 months ago
parent
commit
242fc8195e
  1. 6
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SafetyToolTypeEntity.java
  2. 4
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/SafetyToolTypeController.java
  3. 2
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ISafetyToolTypeService.java
  4. 39
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SafetyToolTypeServiceImpl.java
  5. 4
      hzims-service/safeproduct/src/main/resources/db/3.0.0.sql

6
hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/entity/SafetyToolTypeEntity.java

@ -49,4 +49,10 @@ public class SafetyToolTypeEntity extends TenantEntity {
@ApiModelProperty(value = "通知时间")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date sendTime;
@ApiModelProperty(value = "机构id")
private Long deptId;
@ApiModelProperty(value = "机构名称")
private String deptName;
}

4
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/controller/SafetyToolTypeController.java

@ -17,7 +17,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
@ -37,7 +36,7 @@ import java.util.Map;
@RequestMapping("/safetyToolType")
@Business(module = Constants.APP_NAME, value = "安全工器具类型", ignore = false)
@Api(tags = "安全工器具类型")
public class SafetyToolTypeController extends BladeController {
public class SafetyToolTypeController {
private final ISafetyToolTypeService safetyToolTypeService;
@ -122,7 +121,6 @@ public class SafetyToolTypeController extends BladeController {
return R.data(safetyToolTypeService.safetyToolTypes(req));
}
/**
* 查询所有类型并以id-name作为key-value返回
*/

2
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/ISafetyToolTypeService.java

@ -27,7 +27,7 @@ public interface ISafetyToolTypeService extends IService<SafetyToolTypeEntity> {
SafetyToolTypeVO detail(Long id);
IPage pageCondition(SafetyToolTypeListDTO req, Query query);
IPage<SafetyToolTypeVO> pageCondition(SafetyToolTypeListDTO req, Query query);
Map<String, String> getSelOption();

39
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/service/impl/SafetyToolTypeServiceImpl.java

@ -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;
}

4
hzims-service/safeproduct/src/main/resources/db/3.0.0.sql

@ -8,3 +8,7 @@ ALTER TABLE `hzims_inner_danger_info`
ALTER TABLE `hzims_risk_hazard_task`
ADD COLUMN `remark` text NULL ;
ALTER TABLE `hzims_safe_safety_tool_type`
ADD COLUMN `dept_id` bigint(20) DEFAULT NULL COMMENT '机构id',
ADD COLUMN `dept_name` varchar(20) DEFAULT NULL COMMENT '机构名称';
Loading…
Cancel
Save