1.解决检测完成,可能有脏数据引发的不符合问题
2.优化检测树单位,解决自动生成表缺少部分字段
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
Sort int(4) NOT NULL COMMENT '总检测脚本中的测试项序号',
|
||||
AD_Type CHAR(32) NOT NULL COMMENT '检测指标,字典表',
|
||||
Data_Type CHAR(32) NOT NULL COMMENT '数据指标,只有数据源为分钟统计时候才会使用(最大、最小、平均、CP95,默认平均值),字典表',
|
||||
Result_Flag int(1) COMMENT '1不合格 2合格 4无法处理',
|
||||
A_Value varchar(30) DEFAULT NULL COMMENT 'A相值',
|
||||
B_Value varchar(30) DEFAULT NULL COMMENT 'B相值',
|
||||
C_Value varchar(30) DEFAULT NULL COMMENT 'C相值',
|
||||
@@ -37,7 +38,7 @@
|
||||
B_Value json NULL COMMENT 'B相值',
|
||||
C_Value json NULL COMMENT 'C相值',
|
||||
T_Value json NULL COMMENT 'T相值(没有相别的则存这里)',
|
||||
PRIMARY KEY (Monitor_Id, Script_Id, Sort, AD_Type)
|
||||
PRIMARY KEY (Monitor_Id, Script_Id, Sort, AD_Type,Data_Type)
|
||||
) COMMENT='监测数据表';
|
||||
</update>
|
||||
|
||||
|
||||
@@ -23,8 +23,9 @@ public interface DetectionDataDealService extends IReplenishMybatisService<AdHar
|
||||
/**
|
||||
* 根据终端id查询终端所有监测项目是否合格
|
||||
* @param ids
|
||||
* @param valueType
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
Map<String,Integer> devResult(List<String> ids,String code);
|
||||
Map<String,Integer> devResult(List<String> ids,List<String> valueType,String code);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,9 @@ import com.njcn.gather.storage.pojo.po.AdNonHarmonicResult;
|
||||
import com.njcn.gather.storage.pojo.vo.RawDataVO;
|
||||
import com.njcn.gather.storage.pojo.vo.RawResultDataVO;
|
||||
import com.njcn.gather.storage.service.AdHarmonicService;
|
||||
import io.swagger.models.auth.In;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -40,6 +42,7 @@ import java.util.stream.Collectors;
|
||||
public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarmonicResult> implements AdHarmonicService {
|
||||
|
||||
private final AdNonHarmonicMapper adNonHarmonicMapper;
|
||||
private final IDictDataService dictDataService;
|
||||
|
||||
@Override
|
||||
public List<AdBaseResult> get(String scriptId, List<Integer> sort, String deviceId, String chnNum, Integer code) {
|
||||
@@ -129,42 +132,51 @@ public class AdHarmonicServiceImpl extends ServiceImpl<AdHarmonicMappper, AdHarm
|
||||
.orderByAsc(AdHarmonicResult::getTimeId);
|
||||
|
||||
List<AdHarmonicResult> adHarmonicResults = this.getBaseMapper().selectJoinList(AdHarmonicResult.class, wrapper);
|
||||
List<Double> harmNum = param.getHarmNum();
|
||||
|
||||
Map<String, RawResultDataVO> info=new LinkedHashMap<>(3);
|
||||
RawResultDataVO dataVO;
|
||||
for (AdHarmonicResult harmonicResult : adHarmonicResults) {
|
||||
for (Double i : harmNum) {
|
||||
dataVO = new RawResultDataVO();
|
||||
dataVO.setHarmNum(i);
|
||||
dataVO.setIsData(harmonicResult.getResultFlag());
|
||||
dataVO.setUnit("%");
|
||||
try {
|
||||
Field fieldA = harmonicResult.getClass().getDeclaredField("aValue" + isHarmOrInHarm(i).intValue());
|
||||
fieldA.setAccessible(true);
|
||||
RawResultDataVO.DetectionData a = JSON.parseObject(fieldA.get(harmonicResult)+"", RawResultDataVO.DetectionData.class);
|
||||
dataVO.setDataA(a);
|
||||
if(CollUtil.isNotEmpty(adHarmonicResults)){
|
||||
List<Double> harmNum = param.getHarmNum();
|
||||
RawResultDataVO dataVO;
|
||||
DictData dictData = dictDataService.getDictDataById(adHarmonicResults.get(0).getAdType());
|
||||
String unit;
|
||||
if(DictDataEnum.I2_50.getCode().equals(dictData.getCode())||DictDataEnum.SI_1_49.getCode().equals(dictData.getCode())){
|
||||
unit="A";
|
||||
}else{
|
||||
unit="%";
|
||||
}
|
||||
for (AdHarmonicResult harmonicResult : adHarmonicResults) {
|
||||
for (Double i : harmNum) {
|
||||
dataVO = new RawResultDataVO();
|
||||
dataVO.setHarmNum(i);
|
||||
dataVO.setIsData(harmonicResult.getResultFlag());
|
||||
dataVO.setUnit(unit);
|
||||
try {
|
||||
Field fieldA = harmonicResult.getClass().getDeclaredField("aValue" + isHarmOrInHarm(i).intValue());
|
||||
fieldA.setAccessible(true);
|
||||
RawResultDataVO.DetectionData a = JSON.parseObject(fieldA.get(harmonicResult)+"", RawResultDataVO.DetectionData.class);
|
||||
dataVO.setDataA(a);
|
||||
|
||||
Field fieldB = harmonicResult.getClass().getDeclaredField("bValue" + isHarmOrInHarm(i).intValue());
|
||||
fieldB.setAccessible(true);
|
||||
RawResultDataVO.DetectionData b = JSON.parseObject(fieldB.get(harmonicResult)+"", RawResultDataVO.DetectionData.class);
|
||||
dataVO.setDataB(b);
|
||||
Field fieldB = harmonicResult.getClass().getDeclaredField("bValue" + isHarmOrInHarm(i).intValue());
|
||||
fieldB.setAccessible(true);
|
||||
RawResultDataVO.DetectionData b = JSON.parseObject(fieldB.get(harmonicResult)+"", RawResultDataVO.DetectionData.class);
|
||||
dataVO.setDataB(b);
|
||||
|
||||
Field fieldC = harmonicResult.getClass().getDeclaredField("cValue" + isHarmOrInHarm(i).intValue());
|
||||
fieldC.setAccessible(true);
|
||||
RawResultDataVO.DetectionData c = JSON.parseObject(fieldC.get(harmonicResult)+"", RawResultDataVO.DetectionData.class);
|
||||
dataVO.setDataC(c);
|
||||
if(ObjectUtil.isNotNull(a)){
|
||||
dataVO.setRadius(a.getRadius());
|
||||
Field fieldC = harmonicResult.getClass().getDeclaredField("cValue" + isHarmOrInHarm(i).intValue());
|
||||
fieldC.setAccessible(true);
|
||||
RawResultDataVO.DetectionData c = JSON.parseObject(fieldC.get(harmonicResult)+"", RawResultDataVO.DetectionData.class);
|
||||
dataVO.setDataC(c);
|
||||
if(ObjectUtil.isNotNull(a)){
|
||||
dataVO.setRadius(a.getRadius());
|
||||
}
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
} catch (NoSuchFieldException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
info.put(String.valueOf(i),dataVO) ;
|
||||
}
|
||||
info.put(String.valueOf(i),dataVO) ;
|
||||
}
|
||||
}
|
||||
|
||||
DynamicTableNameHandler.remove();
|
||||
return info;
|
||||
}
|
||||
|
||||
@@ -94,12 +94,13 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Integer> devResult(List<String> ids,String code) {
|
||||
public Map<String, Integer> devResult(List<String> ids,List<String> valueType,String code) {
|
||||
List<AdNonHarmonicResult> noHarm=new ArrayList<>();
|
||||
for (String id : ids) {
|
||||
DynamicTableNameHandler.setTableName("ad_non_harmonic_result_" + code);
|
||||
noHarm.addAll(adNonHarmonicService.list( new LambdaQueryWrapper<AdNonHarmonicResult>()
|
||||
.like(AdNonHarmonicResult::getMonitorId,id)
|
||||
.in(CollUtil.isNotEmpty(valueType),AdNonHarmonicResult::getAdType,valueType)
|
||||
)) ;
|
||||
}
|
||||
DynamicTableNameHandler.remove();
|
||||
@@ -108,6 +109,7 @@ public class DetectionDataServiceImpl extends ReplenishMybatisServiceImpl<Detect
|
||||
DynamicTableNameHandler.setTableName("ad_harmonic_result_" + code);
|
||||
harm.addAll(this.list( new LambdaQueryWrapper<AdHarmonicResult>()
|
||||
.like(AdHarmonicResult::getMonitorId,id)
|
||||
.in(CollUtil.isNotEmpty(valueType),AdHarmonicResult::getAdType,valueType)
|
||||
)) ;
|
||||
}
|
||||
DynamicTableNameHandler.remove();
|
||||
|
||||
Reference in New Issue
Block a user