整理代码

This commit is contained in:
caozehui
2025-03-26 10:01:56 +08:00
parent 4ef5c982de
commit 9a7d841d9c
29 changed files with 174 additions and 513 deletions

View File

@@ -1,20 +0,0 @@
package com.njcn.gather.source.pojo.enums;
import lombok.Getter;
/**
* @author caozehui
* @data 2025-03-10
*/
@Getter
public enum SourceResponseEnum {
SOURCE_BOUND_NOT_DELETE("A030001", "源已被计划所绑定,无法删除!");
private String code;
private String message;
SourceResponseEnum(String code, String message) {
this.code = code;
this.message = message;
}
}

View File

@@ -11,25 +11,26 @@ 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.device.pojo.enums.CommonEnum;
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
import com.njcn.gather.source.mapper.PqSourceMapper;
import com.njcn.gather.source.pojo.enums.SourceResponseEnum;
import com.njcn.gather.source.pojo.param.PqSourceParam;
import com.njcn.gather.source.pojo.po.PqSource;
import com.njcn.gather.source.pojo.po.SourceInitialize;
import com.njcn.gather.source.pojo.po.SourceParam;
import com.njcn.gather.source.service.IPqSourceService;
import com.njcn.gather.type.pojo.po.DevType;
import com.njcn.gather.type.service.IDevTypeService;
import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.service.IDictDataService;
import com.njcn.gather.type.service.IDevTypeService;
import com.njcn.web.factory.PageFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
@@ -87,8 +88,8 @@ public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> i
@Transactional
public boolean deletePqSource(List<String> ids) {
Integer count = this.baseMapper.getCountBoundByIds(ids);
if(count > 0){
throw new BusinessException(SourceResponseEnum.SOURCE_BOUND_NOT_DELETE);
if (count > 0) {
throw new BusinessException(DetectionResponseEnum.SOURCE_BOUND_NOT_DELETE);
}
return this.lambdaUpdate().in(PqSource::getId, ids).set(PqSource::getState, DataStateEnum.DELETED.getCode()).update();
}
@@ -133,7 +134,7 @@ public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> i
.peek(p -> p.setChildren(getInitializeChildren(p, list)))
.sorted(Comparator.comparingInt(SourceInitialize.Initialize::getSort))
.collect(Collectors.toList());
if(CollUtil.isNotEmpty(sourceParams)){
if (CollUtil.isNotEmpty(sourceParams)) {
SourceInitialize initialize = new SourceInitialize();
SourceInitialize.Initialize source = sourceParams.get(0);
initialize.setSourceId(source.getValue());
@@ -194,6 +195,6 @@ public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> i
}
}
}
throw new BusinessException(DevResponseEnum.PQ_SOURCE_GEN_NAME_ERROR);
throw new BusinessException(DetectionResponseEnum.PQ_SOURCE_GEN_NAME_ERROR);
}
}