icd、删除计划时同时删除与之关联的表
This commit is contained in:
@@ -317,7 +317,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
.eq(ObjectUtil.isNotNull(param.getCheckResult()), PqDev::getCheckResult, param.getCheckResult())
|
||||
.eq(ObjectUtil.isNotNull(param.getReportState()), PqDev::getReportState, param.getReportState())
|
||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
|
||||
.orderByAsc(PqDev::getCreateTime)
|
||||
.orderByDesc(PqDev::getCreateTime)
|
||||
.orderByAsc(PqDev::getName)
|
||||
.list();
|
||||
|
||||
return pqDevList;
|
||||
|
||||
@@ -21,10 +21,7 @@ import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -43,7 +40,7 @@ public class PqIcdPathController extends BaseController{
|
||||
private final IPqIcdPathService pqIcdPathService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/listAll")
|
||||
@GetMapping("/listAll")
|
||||
@ApiOperation("获取所有icd")
|
||||
public HttpResult<List<PqIcdPath>> listAll() {
|
||||
String methodDescribe = getMethodDescribe("listAll");
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.gather.icd.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-02-11
|
||||
*/
|
||||
@Getter
|
||||
public enum IcdPathResponseEnum {
|
||||
|
||||
ICD_PATH_NAME_REPEAT("A004007", "icd名称重复");
|
||||
|
||||
private final String code;
|
||||
private final String message;
|
||||
|
||||
IcdPathResponseEnum(String code, String message) {
|
||||
this.message = message;
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -32,5 +31,10 @@ public class PqIcdPath extends BaseEntity implements Serializable {
|
||||
* icd存储地址
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
private Integer state;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,13 +13,42 @@ import java.util.List;
|
||||
*/
|
||||
public interface IPqIcdPathService extends IService<PqIcdPath> {
|
||||
|
||||
/**
|
||||
* 获取所有Icd
|
||||
*
|
||||
* @return 所有Icd
|
||||
*/
|
||||
List<PqIcdPath> listAll();
|
||||
|
||||
/**
|
||||
* 分页获取Icd
|
||||
*
|
||||
* @param param 分页查询参数
|
||||
* @return
|
||||
*/
|
||||
Page<PqIcdPath> listIcd(PqIcdPathParam.QueryParam param);
|
||||
|
||||
/**
|
||||
* 新增Icd
|
||||
*
|
||||
* @param param 新增Icd参数
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean addIcd(PqIcdPathParam param);
|
||||
|
||||
/**
|
||||
* 修改Icd
|
||||
*
|
||||
* @param param 修改Icd参数
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean updateIcd(PqIcdPathParam.UpdateParam param);
|
||||
|
||||
/**
|
||||
* 批量删除Icd
|
||||
*
|
||||
* @param ids Icd id列表
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean deleteIcd(List<String> ids);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
package com.njcn.gather.icd.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.icd.mapper.PqIcdPathMapper;
|
||||
import com.njcn.gather.icd.pojo.enums.IcdPathResponseEnum;
|
||||
import com.njcn.gather.icd.pojo.param.PqIcdPathParam;
|
||||
import com.njcn.gather.icd.pojo.po.PqIcdPath;
|
||||
import com.njcn.gather.icd.mapper.PqIcdPathMapper;
|
||||
import com.njcn.gather.icd.service.IPqIcdPathService;
|
||||
import com.njcn.gather.type.pojo.po.DevType;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@@ -23,26 +31,53 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
|
||||
|
||||
@Override
|
||||
public List<PqIcdPath> listAll() {
|
||||
return null;
|
||||
return this.lambdaQuery().eq(PqIcdPath::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PqIcdPath> listIcd(PqIcdPathParam.QueryParam param) {
|
||||
return null;
|
||||
LambdaQueryWrapper<PqIcdPath> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PqIcdPath::getState, DataStateEnum.ENABLE.getCode())
|
||||
.like(StrUtil.isNotBlank(param.getName()), PqIcdPath::getName, param.getName())
|
||||
.orderByDesc(PqIcdPath::getCreateTime);
|
||||
Page<PqIcdPath> page = this.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), wrapper);
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addIcd(PqIcdPathParam param) {
|
||||
return false;
|
||||
this.checkRepeat(param, false);
|
||||
PqIcdPath pqIcdPath = new PqIcdPath();
|
||||
BeanUtils.copyProperties(param, pqIcdPath);
|
||||
pqIcdPath.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.save(pqIcdPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateIcd(PqIcdPathParam.UpdateParam param) {
|
||||
return false;
|
||||
this.checkRepeat(param, true);
|
||||
PqIcdPath pqIcdPath = new PqIcdPath();
|
||||
BeanUtils.copyProperties(param, pqIcdPath);
|
||||
return this.updateById(pqIcdPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteIcd(List<String> ids) {
|
||||
return false;
|
||||
return this.lambdaUpdate().in(PqIcdPath::getId, ids).set(PqIcdPath::getState, DataStateEnum.DELETED.getCode()).update();
|
||||
}
|
||||
|
||||
private void checkRepeat(PqIcdPathParam param, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<PqIcdPath> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PqIcdPath::getName, param.getName())
|
||||
.eq(PqIcdPath::getState, DataStateEnum.ENABLE.getCode());
|
||||
if (isExcludeSelf) {
|
||||
if (param instanceof PqIcdPathParam.UpdateParam) {
|
||||
wrapper.ne(PqIcdPath::getId, ((PqIcdPathParam.UpdateParam) param).getId());
|
||||
}
|
||||
}
|
||||
int count = this.count(wrapper);
|
||||
if (count > 0) {
|
||||
throw new BusinessException(IcdPathResponseEnum.ICD_PATH_NAME_REPEAT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,6 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
// 修改检测计划、检测源关联
|
||||
adPlanSourceService.updateAdPlanSource(param.getId(), param.getSourceIds());
|
||||
|
||||
|
||||
adPlan.setTestState(pqDevService.bind(param.getId(), param.getDevIds()));
|
||||
|
||||
return this.updateById(adPlan);
|
||||
@@ -161,6 +160,10 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
// 删除检测计划、检测源关联
|
||||
adPlanSourceService.deleteAdPlanSourceByPlanIds(ids);
|
||||
|
||||
// 删除相关检测表格
|
||||
List<String> codeList = this.listByIds(ids).stream().map(plan->String.valueOf(plan.getCode())).collect(Collectors.toList());
|
||||
tableGenService.deleteTable(codeList);
|
||||
|
||||
return this.lambdaUpdate().in(AdPlan::getId, ids).set(AdPlan::getState, DataStateEnum.DELETED.getCode()).update();
|
||||
}
|
||||
|
||||
|
||||
@@ -20,10 +20,7 @@ import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -46,7 +43,7 @@ public class DevTypeController extends BaseController {
|
||||
private final IDevTypeService devTypeService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/listAll")
|
||||
@GetMapping("/listAll")
|
||||
@ApiOperation("获取所有设备类型")
|
||||
public HttpResult<List<DevType>> listAll() {
|
||||
String methodDescribe = getMethodDescribe("listAll");
|
||||
|
||||
@@ -10,7 +10,7 @@ import lombok.Getter;
|
||||
@Getter
|
||||
public enum DevTypeResponseEnum {
|
||||
|
||||
DEV_TYPE_REPEAT("A003007", "设备类型名称重复");
|
||||
DEV_TYPE_NAME_REPEAT("A003007", "设备类型名称重复");
|
||||
|
||||
private final String code;
|
||||
private final String message;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.gather.type.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -54,7 +55,7 @@ public class DevTypeServiceImpl extends ServiceImpl<DevTypeMapper, DevType> impl
|
||||
public Page<DevType> listDevType(DevTypeParam.QueryParam queryParam) {
|
||||
LambdaQueryWrapper<DevType> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(DevType::getState, DataStateEnum.ENABLE.getCode())
|
||||
.like(DevType::getName, queryParam.getName())
|
||||
.like(StrUtil.isNotBlank(queryParam.getName()), DevType::getName, queryParam.getName())
|
||||
.orderByDesc(DevType::getCreateTime);
|
||||
Page<DevType> page = this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), wrapper);
|
||||
return page;
|
||||
@@ -93,7 +94,7 @@ public class DevTypeServiceImpl extends ServiceImpl<DevTypeMapper, DevType> impl
|
||||
}
|
||||
int count = this.count(wrapper);
|
||||
if (count > 0) {
|
||||
throw new BusinessException(DevTypeResponseEnum.DEV_TYPE_REPEAT);
|
||||
throw new BusinessException(DevTypeResponseEnum.DEV_TYPE_NAME_REPEAT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user