icd上传映射文件
This commit is contained in:
@@ -53,4 +53,9 @@ public class DetectionData {
|
|||||||
* 误差体系详情ID(比对式使用)
|
* 误差体系详情ID(比对式使用)
|
||||||
*/
|
*/
|
||||||
private String errorDtlId;
|
private String errorDtlId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 有效组数
|
||||||
|
*/
|
||||||
|
private Integer validGroupNum;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1750,8 +1750,16 @@ public class DetectionServiceImpl {
|
|||||||
result.setDataType(DataSourceEnum.WAVE_DATA.getValue());
|
result.setDataType(DataSourceEnum.WAVE_DATA.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, List<Double>> validData = this.getValidData(standardDevDataList, desc);
|
||||||
|
|
||||||
if (map.containsKey(TYPE_T)) {
|
if (map.containsKey(TYPE_T)) {
|
||||||
|
Integer validGroupNum = 0;
|
||||||
|
if (ObjectUtil.isNotNull(validData)) {
|
||||||
|
List<Double> tValidDataList = validData.get(TYPE_T);
|
||||||
|
validGroupNum = this.getValidGroupNum(tValidDataList, null, errSysDtls, fData, scale, dataRule);
|
||||||
|
}
|
||||||
List<DetectionData> tList = rangeComparisonList(map.get(TYPE_T).get(0), map.get(TYPE_T).get(1), errSysDtls, fData, scale, dataRule);
|
List<DetectionData> tList = rangeComparisonList(map.get(TYPE_T).get(0), map.get(TYPE_T).get(1), errSysDtls, fData, scale, dataRule);
|
||||||
|
this.setValidGroupNum(tList, validGroupNum);
|
||||||
result.setTValue(JSON.toJSONString(tList));
|
result.setTValue(JSON.toJSONString(tList));
|
||||||
result.setResultFlag(setResultFlag(tList));
|
result.setResultFlag(setResultFlag(tList));
|
||||||
} else {
|
} else {
|
||||||
@@ -1783,6 +1791,169 @@ public class DetectionServiceImpl {
|
|||||||
return StorageUtil.getInteger(resultFlag);
|
return StorageUtil.getInteger(resultFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<String, List<Double>> getValidData(List<DevData> dev, String desc) {
|
||||||
|
List<Double> aDev = new ArrayList<>();
|
||||||
|
List<Double> bDev = new ArrayList<>();
|
||||||
|
List<Double> cDev = new ArrayList<>();
|
||||||
|
List<Double> tDev = new ArrayList<>();
|
||||||
|
|
||||||
|
for (int i = 0; i < dev.size(); i++) {
|
||||||
|
List<DevData.SqlDataDTO> devSqlData = dev.get(i).getSqlData();
|
||||||
|
|
||||||
|
String finalDesc = desc;
|
||||||
|
List<DevData.SqlDataDTO.ListDTO> devList = devSqlData.stream().filter(j -> finalDesc.equals(j.getDesc()))
|
||||||
|
.map(DevData.SqlDataDTO::getList).collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (CollUtil.isEmpty(devList)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
aDev.addAll(devList.stream().filter(x -> ObjectUtil.isNotNull(x.getA()))
|
||||||
|
.map(x -> x.getA().doubleValue())
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
bDev.addAll(devList.stream().filter(x -> ObjectUtil.isNotNull(x.getB()))
|
||||||
|
.map(x -> x.getB().doubleValue())
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
cDev.addAll(devList.stream().filter(x -> ObjectUtil.isNotNull(x.getC()))
|
||||||
|
.map(x -> x.getC().doubleValue())
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
tDev.addAll(devList.stream().filter(x -> ObjectUtil.isNotNull(x.getT()))
|
||||||
|
.map(x -> x.getT().doubleValue())
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new HashMap() {
|
||||||
|
{
|
||||||
|
put(TYPE_A, aDev);
|
||||||
|
put(TYPE_B, bDev);
|
||||||
|
put(TYPE_C, cDev);
|
||||||
|
put(TYPE_T, tDev);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Map<Double, List<Double>>> getHarmValidData(List<DevData> dev, String fundCode, String harmCode, Integer harmonicFlag) {
|
||||||
|
// key为相别、value{key为谐波次数,value为按数据处理原则处理后的数据}
|
||||||
|
Map<String, Map<Double, List<Double>>> devMap = new HashMap<>(3);
|
||||||
|
|
||||||
|
List<Double> harmNum = new ArrayList<>();
|
||||||
|
if (1 == harmonicFlag) {
|
||||||
|
harmNum.addAll(Stream.iterate(0.5, x -> x + 1.0).limit(50).collect(Collectors.toList()));
|
||||||
|
} else {
|
||||||
|
harmNum.addAll(Stream.iterate(1.0, x -> x + 1.0).limit(50).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < dev.size(); i++) {
|
||||||
|
List<DevData.SqlDataDTO> devSqlData = dev.get(i).getSqlData();
|
||||||
|
|
||||||
|
Optional<DevData.SqlDataDTO> first1 = Optional.empty();
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(devSqlData)) {
|
||||||
|
first1 = devSqlData.stream().filter(j -> fundCode.equals(j.getDesc())).collect(Collectors.toList()).stream().findFirst();
|
||||||
|
}
|
||||||
|
|
||||||
|
DevData.SqlDataDTO fund1 = null;
|
||||||
|
if (first1.isPresent()) {
|
||||||
|
fund1 = first1.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<DevData.SqlDataHarmDTO> devHarmList = dev.get(i).getSqlDataHarm().stream().filter(x -> harmCode.equals(x.getDesc())).collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (CollUtil.isEmpty(devHarmList)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(devHarmList)) {
|
||||||
|
DevData.SqlDataHarmDTO devHarm = devHarmList.get(0);
|
||||||
|
if (ObjectUtil.isNotNull(fund1)) {
|
||||||
|
harmPut(TYPE_A, devMap, harmNum, devHarm, String.valueOf(fund1.getList().getA()), harmonicFlag);
|
||||||
|
harmPut(TYPE_B, devMap, harmNum, devHarm, String.valueOf(fund1.getList().getB()), harmonicFlag);
|
||||||
|
harmPut(TYPE_C, devMap, harmNum, devHarm, String.valueOf(fund1.getList().getC()), harmonicFlag);
|
||||||
|
} else {
|
||||||
|
harmPut(TYPE_A, devMap, harmNum, devHarm, "1.0", harmonicFlag);
|
||||||
|
harmPut(TYPE_B, devMap, harmNum, devHarm, "1.0", harmonicFlag);
|
||||||
|
harmPut(TYPE_C, devMap, harmNum, devHarm, "1.0", harmonicFlag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return devMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer getValidGroupNum(List<Double> devDataList, List<Double> U1List, List<PqErrSysDtls> errSysDtls, Double fData, Integer scale, DictDataEnum dataRule) {
|
||||||
|
int result = 0;
|
||||||
|
if (dataRule.getCode().equals(DictDataEnum.Own_value.getCode()) || dataRule.getCode().equals(DictDataEnum.SECTION_VALUE.getCode())) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < devDataList.size(); i++) {
|
||||||
|
Double U1 = CollUtil.isNotEmpty(U1List) ? U1List.get(i) : null;
|
||||||
|
Double stdDevData = BigDecimal.valueOf(devDataList.get(i)).setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||||
|
Double devData = BigDecimal.valueOf(devDataList.get(i)).setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||||
|
DetectionData detectionData = new DetectionData();
|
||||||
|
detectionData.setIsData(ResultEnum.NO_ERROR_SYS.getValue());
|
||||||
|
|
||||||
|
//获得误差体系
|
||||||
|
List<PqErrSysDtls> errSysDtls1 = errSysDtls.stream().filter(x -> rangeComparison(startRadiusEnd(x.getStartValue(), fData, stdDevData, x.getConditionType(), scale),
|
||||||
|
x.getStartFlag(),
|
||||||
|
startRadiusEnd(x.getEndValue(), fData, stdDevData, x.getConditionType(), scale),
|
||||||
|
x.getEndFlag(),
|
||||||
|
ObjectUtil.isNotNull(U1) ? stdDevData * U1 * 0.01 : stdDevData)).collect(Collectors.toList());
|
||||||
|
detectionData.setData(devData);
|
||||||
|
detectionData.setResultData(stdDevData);
|
||||||
|
if (CollUtil.isNotEmpty(errSysDtls1)) {
|
||||||
|
result++;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<Double, Integer> getHarmValidGroupNum(Map<Double, List<Double>> devDataMap, List<Double> U1List, List<PqErrSysDtls> errSysDtls, Double fData, Integer scale, DictDataEnum dataRule) {
|
||||||
|
Map<Double, Integer> resultMap = new HashMap<>();
|
||||||
|
devDataMap.forEach((harmNum, dataList) -> {
|
||||||
|
if (dataRule.getCode().equals(DictDataEnum.Own_value.getCode()) || dataRule.getCode().equals(DictDataEnum.SECTION_VALUE.getCode())) {
|
||||||
|
resultMap.put(harmNum, 1);
|
||||||
|
} else {
|
||||||
|
Integer validGroupNum = 0;
|
||||||
|
for (int i = 0; i < dataList.size(); i++) {
|
||||||
|
Double U1 = CollUtil.isNotEmpty(U1List) ? U1List.get(i) : null;
|
||||||
|
Double stdDevData = BigDecimal.valueOf(dataList.get(i)).setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||||
|
Double devData = BigDecimal.valueOf(dataList.get(i)).setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||||
|
DetectionData detectionData = new DetectionData();
|
||||||
|
detectionData.setIsData(ResultEnum.NO_ERROR_SYS.getValue());
|
||||||
|
|
||||||
|
//获得误差体系
|
||||||
|
List<PqErrSysDtls> errSysDtls1 = errSysDtls.stream().filter(x -> rangeComparison(startRadiusEnd(x.getStartValue(), fData, stdDevData, x.getConditionType(), scale),
|
||||||
|
x.getStartFlag(),
|
||||||
|
startRadiusEnd(x.getEndValue(), fData, stdDevData, x.getConditionType(), scale),
|
||||||
|
x.getEndFlag(),
|
||||||
|
ObjectUtil.isNotNull(U1) ? stdDevData * U1 * 0.01 : stdDevData)).collect(Collectors.toList());
|
||||||
|
detectionData.setData(devData);
|
||||||
|
detectionData.setResultData(stdDevData);
|
||||||
|
if (CollUtil.isNotEmpty(errSysDtls1)) {
|
||||||
|
validGroupNum++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resultMap.put(harmNum, validGroupNum);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setValidGroupNum(List<DetectionData> tList, Integer validGroupNum) {
|
||||||
|
tList.forEach(detectionData -> {
|
||||||
|
detectionData.setValidGroupNum(validGroupNum);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setHarmValidGroupNum(List<DetectionData> integerBooleanA, Map<Double, Integer> harmValidGroupNumA) {
|
||||||
|
integerBooleanA.forEach(detectionData -> {
|
||||||
|
Double harmNum = detectionData.getNum();
|
||||||
|
Integer validGroupNum = harmValidGroupNumA.get(harmNum);
|
||||||
|
detectionData.setValidGroupNum(validGroupNum);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理谐波数据
|
* 处理谐波数据
|
||||||
@@ -1869,9 +2040,22 @@ public class DetectionServiceImpl {
|
|||||||
result.setDataType(DataSourceEnum.WAVE_DATA.getValue());
|
result.setDataType(DataSourceEnum.WAVE_DATA.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, Map<Double, List<Double>>> harmValidData = this.getHarmValidData(standardDevDataList, fundCode, harmCode, harmonicFlag);
|
||||||
|
|
||||||
List<DetectionData> integerBooleanA = harmRangeComparison(devMap.get(TYPE_A).get(0), devMap.get(TYPE_A).get(1), errSysDtls, type, fData, scale, dataRule);
|
List<DetectionData> integerBooleanA = harmRangeComparison(devMap.get(TYPE_A).get(0), devMap.get(TYPE_A).get(1), errSysDtls, type, fData, scale, dataRule);
|
||||||
List<DetectionData> integerBooleanB = harmRangeComparison(devMap.get(TYPE_B).get(0), devMap.get(TYPE_B).get(1), errSysDtls, type, fData, scale, dataRule);
|
List<DetectionData> integerBooleanB = harmRangeComparison(devMap.get(TYPE_B).get(0), devMap.get(TYPE_B).get(1), errSysDtls, type, fData, scale, dataRule);
|
||||||
List<DetectionData> integerBooleanC = harmRangeComparison(devMap.get(TYPE_C).get(0), devMap.get(TYPE_C).get(1), errSysDtls, type, fData, scale, dataRule);
|
List<DetectionData> integerBooleanC = harmRangeComparison(devMap.get(TYPE_C).get(0), devMap.get(TYPE_C).get(1), errSysDtls, type, fData, scale, dataRule);
|
||||||
|
|
||||||
|
Map<String, Map<Double, List<Double>>> U1ListMap = this.getU1ListMap(standardDevDataList, fundCode, harmCode, harmonicFlag);
|
||||||
|
Map<Double, Integer> harmValidGroupNumA = this.getHarmValidGroupNum(harmValidData.get(TYPE_A), U1ListMap.get(TYPE_A).get(0.0), errSysDtls, fData, scale, dataRule);
|
||||||
|
this.setHarmValidGroupNum(integerBooleanA, harmValidGroupNumA);
|
||||||
|
|
||||||
|
Map<Double, Integer> harmValidGroupNumB = this.getHarmValidGroupNum(harmValidData.get(TYPE_B), U1ListMap.get(TYPE_B).get(0.0), errSysDtls, fData, scale, dataRule);
|
||||||
|
this.setHarmValidGroupNum(integerBooleanB, harmValidGroupNumB);
|
||||||
|
|
||||||
|
Map<Double, Integer> harmValidGroupNumC = this.getHarmValidGroupNum(harmValidData.get(TYPE_C), U1ListMap.get(TYPE_C).get(0.0), errSysDtls, fData, scale, dataRule);
|
||||||
|
this.setHarmValidGroupNum(integerBooleanC, harmValidGroupNumC);
|
||||||
|
|
||||||
reflectHarmonic(true, "a", integerBooleanA, result, harmonicFlag);
|
reflectHarmonic(true, "a", integerBooleanA, result, harmonicFlag);
|
||||||
reflectHarmonic(true, "b", integerBooleanB, result, harmonicFlag);
|
reflectHarmonic(true, "b", integerBooleanB, result, harmonicFlag);
|
||||||
reflectHarmonic(true, "c", integerBooleanC, result, harmonicFlag);
|
reflectHarmonic(true, "c", integerBooleanC, result, harmonicFlag);
|
||||||
@@ -1888,6 +2072,59 @@ public class DetectionServiceImpl {
|
|||||||
return StorageUtil.getInteger(resultFlag);
|
return StorageUtil.getInteger(resultFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<String, Map<Double, List<Double>>> getU1ListMap(List<DevData> devDataList, String fundCode, String harmCode, Integer harmonicFlag) {
|
||||||
|
Map<String, Map<Double, List<Double>>> resultMap = new HashMap<>(3);
|
||||||
|
|
||||||
|
// key为相别、value{key为谐波次数,value为按数据处理原则处理后的数据}
|
||||||
|
Map<String, Map<Double, List<Double>>> devMap = new HashMap<>(3);
|
||||||
|
|
||||||
|
List<Double> harmNum = new ArrayList<>();
|
||||||
|
if (1 == harmonicFlag) {
|
||||||
|
harmNum.addAll(Stream.iterate(0.5, x -> x + 1.0).limit(50).collect(Collectors.toList()));
|
||||||
|
} else {
|
||||||
|
harmNum.addAll(Stream.iterate(1.0, x -> x + 1.0).limit(50).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < devDataList.size(); i++) {
|
||||||
|
List<DevData.SqlDataDTO> standardDevSqlData = devDataList.get(i).getSqlData();
|
||||||
|
|
||||||
|
Optional<DevData.SqlDataDTO> first1 = Optional.empty();
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(standardDevSqlData)) {
|
||||||
|
first1 = standardDevSqlData.stream().filter(j -> fundCode.equals(j.getDesc())).collect(Collectors.toList()).stream().findFirst();
|
||||||
|
}
|
||||||
|
|
||||||
|
DevData.SqlDataDTO fund1 = null;
|
||||||
|
if (first1.isPresent()) {
|
||||||
|
fund1 = first1.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<DevData.SqlDataHarmDTO> devHarmList = devDataList.get(i).getSqlDataHarm().stream().filter(x -> harmCode.equals(x.getDesc())).collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (CollUtil.isEmpty(devHarmList)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(devHarmList)) {
|
||||||
|
DevData.SqlDataHarmDTO devHarm = devHarmList.get(0);
|
||||||
|
if (ObjectUtil.isNotNull(fund1)) {
|
||||||
|
harmPut(TYPE_A, devMap, harmNum, devHarm, String.valueOf(fund1.getList().getA()), harmonicFlag);
|
||||||
|
harmPut(TYPE_B, devMap, harmNum, devHarm, String.valueOf(fund1.getList().getB()), harmonicFlag);
|
||||||
|
harmPut(TYPE_C, devMap, harmNum, devHarm, String.valueOf(fund1.getList().getC()), harmonicFlag);
|
||||||
|
} else {
|
||||||
|
harmPut(TYPE_A, devMap, harmNum, devHarm, "1.0", harmonicFlag);
|
||||||
|
harmPut(TYPE_B, devMap, harmNum, devHarm, "1.0", harmonicFlag);
|
||||||
|
harmPut(TYPE_C, devMap, harmNum, devHarm, "1.0", harmonicFlag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resultMap.put(TYPE_A, devMap.get(TYPE_A));
|
||||||
|
resultMap.put(TYPE_B, devMap.get(TYPE_C));
|
||||||
|
resultMap.put(TYPE_C, devMap.get(TYPE_C));
|
||||||
|
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理非谐波类取值
|
* 处理非谐波类取值
|
||||||
@@ -1908,6 +2145,7 @@ public class DetectionServiceImpl {
|
|||||||
List<Double> cStandardDev = new ArrayList<>();
|
List<Double> cStandardDev = new ArrayList<>();
|
||||||
List<Double> tDev = new ArrayList<>();
|
List<Double> tDev = new ArrayList<>();
|
||||||
List<Double> tStandardDev = new ArrayList<>();
|
List<Double> tStandardDev = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < dev.size(); i++) {
|
for (int i = 0; i < dev.size(); i++) {
|
||||||
List<DevData.SqlDataDTO> devSqlData = dev.get(i).getSqlData();
|
List<DevData.SqlDataDTO> devSqlData = dev.get(i).getSqlData();
|
||||||
List<DevData.SqlDataDTO> standardDevSqlData = standardDev.get(i).getSqlData();
|
List<DevData.SqlDataDTO> standardDevSqlData = standardDev.get(i).getSqlData();
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class PqIcdPathController extends BaseController {
|
|||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@ApiOperation("新增icd")
|
@ApiOperation("新增icd")
|
||||||
@ApiImplicitParam(name = "param", value = "icd新增参数", required = true)
|
@ApiImplicitParam(name = "param", value = "icd新增参数", required = true)
|
||||||
public HttpResult<Boolean> add(@RequestBody @Validated PqIcdPathParam param) {
|
public HttpResult<Boolean> add(PqIcdPathParam param) {
|
||||||
String methodDescribe = getMethodDescribe("add");
|
String methodDescribe = getMethodDescribe("add");
|
||||||
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
|
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
|
||||||
|
|
||||||
@@ -76,7 +76,7 @@ public class PqIcdPathController extends BaseController {
|
|||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
@ApiOperation("修改icd")
|
@ApiOperation("修改icd")
|
||||||
@ApiImplicitParam(name = "param", value = "icd修改参数", required = true)
|
@ApiImplicitParam(name = "param", value = "icd修改参数", required = true)
|
||||||
public HttpResult<Boolean> update(@RequestBody @Validated PqIcdPathParam.UpdateParam param) {
|
public HttpResult<Boolean> update(PqIcdPathParam.UpdateParam param) {
|
||||||
String methodDescribe = getMethodDescribe("update");
|
String methodDescribe = getMethodDescribe("update");
|
||||||
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, param);
|
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, param);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.njcn.gather.icd.pojo.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author caozehui
|
||||||
|
* @data 2025-11-11
|
||||||
|
*/
|
||||||
|
public enum IcdResponseEnum {
|
||||||
|
FILE_NOT_NULL("A018001", "映射文件不能为空"),
|
||||||
|
FILE_TYPE_ERROR("A018002", "映射文件类型错误"),
|
||||||
|
FILE_SIZE_ERROR("A018003", "映射文件大小超出限制");
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
IcdResponseEnum(String code, String message) {
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import com.njcn.web.pojo.param.BaseParam;
|
|||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import javax.validation.constraints.Pattern;
|
import javax.validation.constraints.Pattern;
|
||||||
@@ -32,6 +33,9 @@ public class PqIcdPathParam {
|
|||||||
@ApiModelProperty(value = "角型接线时是否使用相别的指标来进行检测,0表示否,1表示是", required = true)
|
@ApiModelProperty(value = "角型接线时是否使用相别的指标来进行检测,0表示否,1表示是", required = true)
|
||||||
private Integer usePhaseIndex;
|
private Integer usePhaseIndex;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "映射文件", required = true)
|
||||||
|
private MultipartFile mappingFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询实体
|
* 分页查询实体
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.njcn.gather.icd.pojo.po;
|
package com.njcn.gather.icd.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -46,5 +47,18 @@ public class PqIcdPath extends BaseEntity implements Serializable {
|
|||||||
* 角型接线时是否使用相别的指标来进行检测,0表示否,1表示是
|
* 角型接线时是否使用相别的指标来进行检测,0表示否,1表示是
|
||||||
*/
|
*/
|
||||||
private Integer usePhaseIndex;
|
private Integer usePhaseIndex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 映射文件路径
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private FileVO mappingFile;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class FileVO{
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String url;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.njcn.gather.icd.service.impl;
|
package com.njcn.gather.icd.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
@@ -7,17 +8,26 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.gather.icd.mapper.PqIcdPathMapper;
|
import com.njcn.gather.icd.mapper.PqIcdPathMapper;
|
||||||
|
import com.njcn.gather.icd.pojo.enums.IcdResponseEnum;
|
||||||
import com.njcn.gather.icd.pojo.param.PqIcdPathParam;
|
import com.njcn.gather.icd.pojo.param.PqIcdPathParam;
|
||||||
import com.njcn.gather.icd.pojo.po.PqIcdPath;
|
import com.njcn.gather.icd.pojo.po.PqIcdPath;
|
||||||
import com.njcn.gather.icd.service.IPqIcdPathService;
|
import com.njcn.gather.icd.service.IPqIcdPathService;
|
||||||
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
|
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
|
||||||
|
import com.njcn.gather.report.pojo.enums.ReportResponseEnum;
|
||||||
import com.njcn.web.factory.PageFactory;
|
import com.njcn.web.factory.PageFactory;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
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.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.BufferedOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,6 +51,13 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
|
|||||||
.like(StrUtil.isNotBlank(param.getName()), PqIcdPath::getName, param.getName())
|
.like(StrUtil.isNotBlank(param.getName()), PqIcdPath::getName, param.getName())
|
||||||
.orderByDesc(PqIcdPath::getCreateTime);
|
.orderByDesc(PqIcdPath::getCreateTime);
|
||||||
Page<PqIcdPath> page = this.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), wrapper);
|
Page<PqIcdPath> page = this.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), wrapper);
|
||||||
|
String commInstallPath = this.getCommInstallPath();
|
||||||
|
page.getRecords().forEach(pqIcdPath -> {
|
||||||
|
PqIcdPath.FileVO fileVO = new PqIcdPath.FileVO();
|
||||||
|
fileVO.setUrl(commInstallPath + "\\DeviceControl\\Config\\" + pqIcdPath.getName() + ".txt");
|
||||||
|
fileVO.setName(pqIcdPath.getName()+ ".txt");
|
||||||
|
pqIcdPath.setMappingFile(fileVO);
|
||||||
|
});
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,9 +69,63 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
|
|||||||
PqIcdPath pqIcdPath = new PqIcdPath();
|
PqIcdPath pqIcdPath = new PqIcdPath();
|
||||||
BeanUtils.copyProperties(param, pqIcdPath);
|
BeanUtils.copyProperties(param, pqIcdPath);
|
||||||
pqIcdPath.setState(DataStateEnum.ENABLE.getCode());
|
pqIcdPath.setState(DataStateEnum.ENABLE.getCode());
|
||||||
|
|
||||||
|
String commInstallPath = this.getCommInstallPath();
|
||||||
|
long FILE_SIZE_LIMIT = 1 * 1024 * 1024;
|
||||||
|
MultipartFile mappingFile = param.getMappingFile();
|
||||||
|
|
||||||
|
// if (ObjectUtil.isNotNull(mappingFile) && !mappingFile.isEmpty()) {
|
||||||
|
// String mappingFilename = mappingFile.getOriginalFilename();
|
||||||
|
//
|
||||||
|
// if (!mappingFilename.endsWith(".txt")) {
|
||||||
|
// throw new BusinessException(IcdResponseEnum.FILE_TYPE_ERROR);
|
||||||
|
// }
|
||||||
|
// if (mappingFile.getSize() > FILE_SIZE_LIMIT) {
|
||||||
|
// throw new BusinessException(IcdResponseEnum.FILE_SIZE_ERROR);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
// // 如果文件存在,则先删除
|
||||||
|
// String mappingFilePath = commInstallPath + "\\DeviceControl\\Config" + mappingFilename;
|
||||||
|
// Path path = Paths.get(mappingFilePath);
|
||||||
|
// File file = path.toFile();
|
||||||
|
// if (file.exists()) {
|
||||||
|
// file.delete();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // 保存文件
|
||||||
|
// byte[] bytes = mappingFile.getBytes();
|
||||||
|
// BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(mappingFilePath));
|
||||||
|
// bufferedOutputStream.write(bytes);
|
||||||
|
// bufferedOutputStream.flush();
|
||||||
|
//
|
||||||
|
// bufferedOutputStream.close();
|
||||||
|
// } catch (IOException e) {
|
||||||
|
// throw new BusinessException(ReportResponseEnum.FILE_UPLOAD_FAILED);
|
||||||
|
// }
|
||||||
|
// } else {
|
||||||
|
// throw new BusinessException(IcdResponseEnum.FILE_NOT_NULL);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 以管理员身份运行bat脚本
|
||||||
|
String batFilePath = commInstallPath + "\\重启通讯服务.bat";
|
||||||
|
try {
|
||||||
|
Runtime.getRuntime().exec(batFilePath);
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("重启通讯服务失败", e);
|
||||||
|
}
|
||||||
|
|
||||||
return this.save(pqIcdPath);
|
return this.save(pqIcdPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getCommInstallPath() {
|
||||||
|
// String workDir = System.getProperty("user.dir");
|
||||||
|
String workDir = "D:\\program\\CN_Gather";
|
||||||
|
// 获取映射文件存放文件夹
|
||||||
|
String dirPath = workDir.substring(0, workDir.lastIndexOf("\\")) + "\\9100";
|
||||||
|
return dirPath;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public boolean updateIcd(PqIcdPathParam.UpdateParam param) {
|
public boolean updateIcd(PqIcdPathParam.UpdateParam param) {
|
||||||
@@ -62,6 +133,40 @@ public class PqIcdPathServiceImpl extends ServiceImpl<PqIcdPathMapper, PqIcdPath
|
|||||||
this.checkRepeat(param, true);
|
this.checkRepeat(param, true);
|
||||||
PqIcdPath pqIcdPath = new PqIcdPath();
|
PqIcdPath pqIcdPath = new PqIcdPath();
|
||||||
BeanUtils.copyProperties(param, pqIcdPath);
|
BeanUtils.copyProperties(param, pqIcdPath);
|
||||||
|
|
||||||
|
String commInstallPath = this.getCommInstallPath();
|
||||||
|
long FILE_SIZE_LIMIT = 1 * 1024 * 1024;
|
||||||
|
MultipartFile mappingFile = param.getMappingFile();
|
||||||
|
if (ObjectUtil.isNotNull(mappingFile) && !mappingFile.isEmpty()) {
|
||||||
|
String mappingFilename = mappingFile.getOriginalFilename();
|
||||||
|
|
||||||
|
if (!mappingFilename.endsWith(".txt")) {
|
||||||
|
throw new BusinessException(IcdResponseEnum.FILE_TYPE_ERROR);
|
||||||
|
}
|
||||||
|
if (mappingFile.getSize() > FILE_SIZE_LIMIT) {
|
||||||
|
throw new BusinessException(IcdResponseEnum.FILE_SIZE_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 如果文件存在,则先删除
|
||||||
|
String mappingFilePath = commInstallPath + "\\DeviceControl\\Config" + mappingFilename;
|
||||||
|
Path path = Paths.get(mappingFilePath);
|
||||||
|
File file = path.toFile();
|
||||||
|
if (file.exists()) {
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存文件
|
||||||
|
byte[] bytes = mappingFile.getBytes();
|
||||||
|
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(mappingFilePath));
|
||||||
|
bufferedOutputStream.write(bytes);
|
||||||
|
bufferedOutputStream.flush();
|
||||||
|
|
||||||
|
bufferedOutputStream.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new BusinessException(ReportResponseEnum.FILE_UPLOAD_FAILED);
|
||||||
|
}
|
||||||
|
}
|
||||||
return this.updateById(pqIcdPath);
|
return this.updateById(pqIcdPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -789,6 +789,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
if (Objects.isNull(pqDevVO)) {
|
if (Objects.isNull(pqDevVO)) {
|
||||||
throw new BusinessException(ReportResponseEnum.DEVICE_NOT_EXIST);
|
throw new BusinessException(ReportResponseEnum.DEVICE_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
if (CheckStateEnum.CHECKED.getValue().compareTo(pqDevVO.getCheckState()) <= 0) {
|
||||||
devReportParam.setDevId(devId);
|
devReportParam.setDevId(devId);
|
||||||
// 获取设备型号
|
// 获取设备型号
|
||||||
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
DevType devType = devTypeService.getById(pqDevVO.getDevType());
|
||||||
@@ -845,6 +846,7 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
|
|||||||
log.error(ReportResponseEnum.GENERATE_REPORT_ERROR.getMessage(), e);
|
log.error(ReportResponseEnum.GENERATE_REPORT_ERROR.getMessage(), e);
|
||||||
throw new BusinessException(ReportResponseEnum.GENERATE_REPORT_ERROR);
|
throw new BusinessException(ReportResponseEnum.GENERATE_REPORT_ERROR);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user