|
|
|
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.inspect.base.core.utils.ServletUtils; |
|
|
|
import com.inspect.metadata.alg.domain.BasedataAlgSubtype; |
|
|
|
import com.inspect.metadata.alg.service.IBasedataAlgSubtypeService; |
|
|
|
import com.inspect.metadata.area.controller.BaseDataAreaController; |
|
|
|
import com.inspect.metadata.area.domain.BaseDataArea; |
|
|
|
import com.inspect.metadata.eqpbook.domain.BasedataEqpBook; |
|
|
|
import com.inspect.metadata.eqpbook.domain.BasedataEqpBookChannel; |
|
|
|
@ -23,6 +24,7 @@ import com.inspect.metadata.eqpbook.task.FeignTaskClient; |
|
|
|
import com.inspect.metadata.montdata.domain.BasedataMontPatDevStaData; |
|
|
|
import com.inspect.metadata.mqutil.FeignMsgClient; |
|
|
|
import com.inspect.metadata.patrolpointmnt.domain.BasedataPatrolPoint; |
|
|
|
import com.inspect.metadata.patrolpointmnt.mapper.BasedataPatrolPointMapper; |
|
|
|
import com.inspect.metadata.patrolpointmnt.service.IBasedataPatrolPointService; |
|
|
|
import com.inspect.metadata.station.service.IBasedataStationService; |
|
|
|
import com.inspect.metadata.threshold.domain.BasedataThresholdModification; |
|
|
|
@ -89,6 +91,11 @@ public class BasedataEqpBookController extends BaseController { |
|
|
|
private IBasedataThresholdModificationService basedataThresholdModificationService; |
|
|
|
@Autowired |
|
|
|
private FeignTaskClient feignTaskClient; |
|
|
|
@Autowired |
|
|
|
private BaseDataAreaController baseDataAreaController; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private BasedataPatrolPointMapper basedataPatrolpointMapper; |
|
|
|
|
|
|
|
@GetMapping({"/list"}) |
|
|
|
public TableDataInfo list(BasedataEqpBook basedataEqpbook) { |
|
|
|
@ -853,10 +860,44 @@ public class BasedataEqpBookController extends BaseController { |
|
|
|
|
|
|
|
@GetMapping({"/subtypeData"}) |
|
|
|
public TableDataInfo subtypeData(BasedataPatrolPoint basedataPatrolpoint) { |
|
|
|
// List<String> errors = new ArrayList<>(); |
|
|
|
// this.startPage(); |
|
|
|
// List<BasedataPatrolPoint> subtypeList = this.basedataEqpBookService.getSubtypeData(basedataPatrolpoint); |
|
|
|
List<BasedataPatrolPoint> stdList = new ArrayList<>(); |
|
|
|
// 前端传的算法编码 |
|
|
|
List<Long> algTypeCodeList = basedataPatrolpoint.getAlgTypeCodeList(); |
|
|
|
// 获取算法分类字典(dictCode=字典编码,dictValue=逗号分隔的子类型ID) |
|
|
|
List<SysDictData> algCategoryDict = getSysDictDataList("threshold_alg_type"); |
|
|
|
// 构建字典编码(所有可配阈值的算法) -> 子类型ID集合的映射 (例如,"886" -> {"1", "2"}) |
|
|
|
Map<Long, Set<String>> labelToSubtypeIds = algCategoryDict.stream() |
|
|
|
.collect(Collectors.toMap( |
|
|
|
SysDictData::getDictCode, |
|
|
|
item -> Arrays.stream(item.getDictValue().split(",")) |
|
|
|
.filter(StringUtils::isNotBlank) |
|
|
|
.collect(Collectors.toSet()) |
|
|
|
)); |
|
|
|
logger.info("[META] labelToSubtypeIds : {}", labelToSubtypeIds); |
|
|
|
if (algTypeCodeList == null || algTypeCodeList.size() == 0) { |
|
|
|
algTypeCodeList = new ArrayList<>(labelToSubtypeIds.keySet()); |
|
|
|
} |
|
|
|
|
|
|
|
// 合并所有允许的子类型ID |
|
|
|
Set<String> allowedSubtypeIds = algTypeCodeList.stream() |
|
|
|
.filter(Objects::nonNull) |
|
|
|
.flatMap(dictCode -> labelToSubtypeIds.getOrDefault(dictCode, Collections.emptySet()).stream()) |
|
|
|
.collect(Collectors.toSet()); |
|
|
|
|
|
|
|
// subtypeList = subtypeList.stream().filter(point -> { |
|
|
|
// String algSubtypeIds = point.getAlgSubtypeIds(); |
|
|
|
// if (StringUtils.isBlank(algSubtypeIds)) { |
|
|
|
// return false; |
|
|
|
// } |
|
|
|
// return Arrays.stream(algSubtypeIds.split(",")).anyMatch(allowedSubtypeIds::contains); |
|
|
|
// }).collect(Collectors.toList()); |
|
|
|
this.startPage(); |
|
|
|
basedataPatrolpoint.setAlgSubtypeIds(StringUtils.join(allowedSubtypeIds, ",")); |
|
|
|
List<BasedataPatrolPoint> subtypeList = this.basedataEqpBookService.getSubtypeData(basedataPatrolpoint); |
|
|
|
List<BasedataPatrolPoint> stdList = new ArrayList<>(); |
|
|
|
|
|
|
|
// 查询区域信息 |
|
|
|
for (BasedataPatrolPoint bp : subtypeList) { |
|
|
|
List<BasedataThresholdModification> subTypeDOList = new ArrayList<>(); |
|
|
|
List<JSONObject> jsonArray = JSONArray.parseArray(bp.getAlarmThreshold(), JSONObject.class); |
|
|
|
@ -866,22 +907,35 @@ public class BasedataEqpBookController extends BaseController { |
|
|
|
} else { |
|
|
|
subs = new String[]{bp.getAlgSubtypeIds()}; |
|
|
|
} |
|
|
|
|
|
|
|
Long relationAreaId = bp.getRelationAreaId(); |
|
|
|
if (relationAreaId != null) { |
|
|
|
BaseDataArea areaQuery = new BaseDataArea(); |
|
|
|
areaQuery.setAreaIdS(String.valueOf(relationAreaId)); |
|
|
|
AjaxResult ajaxResult = baseDataAreaController.selectAreaNameSForTaskByAreaIdSRelation(areaQuery); |
|
|
|
if (ajaxResult.get("code").equals(200)) { |
|
|
|
bp.setAreaName(ajaxResult.get("data").toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
if(jsonArray == null || subs.length != jsonArray.size()) { |
|
|
|
logger.info("问题巡检点位id,{}", bp.getPatrolPointId()); |
|
|
|
// errors.add(bp.getPatrolPointId()+""); |
|
|
|
continue; |
|
|
|
} |
|
|
|
List<String> algSubtypeNames = new ArrayList<>(); |
|
|
|
for (int k = 0; k < subs.length; ++k) { |
|
|
|
if ("52".equals(subs[k]) || "53".equals(subs[k])) { |
|
|
|
BasedataAlgSubtype basedataAlgSubtype = this.basedataAlgSubtypeService.selectBasedataAlgSubtypeByAlgSubtypeId(Long.valueOf(subs[k])); |
|
|
|
if (null != basedataAlgSubtype && (basedataPatrolpoint.getAlgSubtypeName() == null || "".equals(basedataPatrolpoint.getAlgSubtypeName()) || basedataAlgSubtype.getAlgSubtypeName().contains(basedataPatrolpoint.getAlgSubtypeName()))) { |
|
|
|
BasedataThresholdModification std = new BasedataThresholdModification(); |
|
|
|
std.setPatrolPointId(bp.getPatrolPointId()); |
|
|
|
std.setAlgSubtypeId(subs[k]); |
|
|
|
std.setAlgSubtypeName(basedataAlgSubtype.getAlgSubtypeName()); |
|
|
|
std.setUpperValue(jsonArray.get(k).getString("upperValue")); |
|
|
|
std.setLowerValue(jsonArray.get(k).getString("lowerValue")); |
|
|
|
subTypeDOList.add(std); |
|
|
|
} |
|
|
|
BasedataAlgSubtype basedataAlgSubtype = this.basedataAlgSubtypeService.selectBasedataAlgSubtypeByAlgSubtypeId(Long.valueOf(subs[k])); |
|
|
|
if (null != basedataAlgSubtype) { |
|
|
|
BasedataThresholdModification std = new BasedataThresholdModification(); |
|
|
|
std.setPatrolPointId(bp.getPatrolPointId()); |
|
|
|
std.setAlgSubtypeId(subs[k]); |
|
|
|
std.setAlgSubtypeName(basedataAlgSubtype.getAlgSubtypeName()); |
|
|
|
std.setUpperValue(jsonArray.get(k).getString("upperValue")); |
|
|
|
std.setLowerValue(jsonArray.get(k).getString("lowerValue")); |
|
|
|
subTypeDOList.add(std); |
|
|
|
algSubtypeNames.add(basedataAlgSubtype.getAlgSubtypeName()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
bp.setAlgSubtypeName(StringUtils.join(algSubtypeNames, ",")); |
|
|
|
if (!subTypeDOList.isEmpty()) { |
|
|
|
bp.setSubTypeDOList(subTypeDOList); |
|
|
|
stdList.add(bp); |
|
|
|
@ -900,18 +954,26 @@ public class BasedataEqpBookController extends BaseController { |
|
|
|
return rspData; |
|
|
|
} |
|
|
|
|
|
|
|
private List<SysDictData> getSysDictDataList(String dictType) { |
|
|
|
return basedataPatrolpointMapper.selectDictDataByType(dictType); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping({"/subtypeUpdate"}) |
|
|
|
public AjaxResult subtypeUpdate(@RequestBody BasedataPatrolPoint bp) { |
|
|
|
List<JSONObject> jsonArray = JSONArray.parseArray(bp.getAlarmThreshold(), JSONObject.class); |
|
|
|
public AjaxResult subtypeUpdate(@RequestBody List<JSONObject> jsonObjects) { |
|
|
|
for (JSONObject jsonObject : jsonObjects) { |
|
|
|
BasedataPatrolPoint bp = jsonObject.toJavaObject(BasedataPatrolPoint.class); |
|
|
|
List<JSONObject> jsonArray = JSONArray.parseArray(bp.getAlarmThreshold(), JSONObject.class); |
|
|
|
|
|
|
|
for (int i = 0; i < bp.getSubTypeDOList().size(); ++i) { |
|
|
|
jsonArray.get(i).put("upperValue", bp.getSubTypeDOList().get(i).getUpperValue()); |
|
|
|
jsonArray.get(i).put("lowerValue", bp.getSubTypeDOList().get(i).getLowerValue()); |
|
|
|
this.basedataThresholdModificationService.insertBasedataThresholdModification(bp.getSubTypeDOList().get(i)); |
|
|
|
} |
|
|
|
for (int i = 0; i < bp.getSubTypeDOList().size(); ++i) { |
|
|
|
jsonArray.get(i).put("upperValue", bp.getSubTypeDOList().get(i).getUpperValue()); |
|
|
|
jsonArray.get(i).put("lowerValue", bp.getSubTypeDOList().get(i).getLowerValue()); |
|
|
|
this.basedataThresholdModificationService.insertBasedataThresholdModification(bp.getSubTypeDOList().get(i)); |
|
|
|
} |
|
|
|
|
|
|
|
bp.setAlarmThreshold(jsonArray.toString().replaceFirst(",$", StringUtils.EMPTY)); |
|
|
|
return this.toAjax(this.basedataPatrolPointService.updateBasedataPatrolPoint(bp)); |
|
|
|
bp.setAlarmThreshold(jsonArray.toString().replaceFirst(",$", StringUtils.EMPTY)); |
|
|
|
int i = this.basedataPatrolPointService.updateBasedataPatrolPoint(bp); |
|
|
|
} |
|
|
|
return this.toAjax(true); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping({"/subtypeUpdateRecord"}) |
|
|
|
|