22 Commits

Author SHA1 Message Date
  yinhuaiwei 85ebcd5938 fix: 通过devType和devNo结合,优化联合任务的判断 6 hours ago
  yinhuaiwei 14ce490073 feat: 新增检修区域,包含检修区域的任务将不执行 6 hours ago
  wangguangyuan ee6c7c4771 fix:灵州省侧装置模型文件标签名大小写修改 8 hours ago
  wangguangyuan dc3aed852e Merge branch 'master' of http://git.ht-atia.cn/qinyanlei/inspect 1 day ago
  wangguangyuan 5cdaaf0081 fix:灵州省侧装置模型文件修改 1 day ago
  yinhuaiwei 737fac07cd fix: 包装点位无人机gis_meter2算法异常时的描述值 2 days ago
  yinhuaiwei 282bd328fb fix: 包装点位纠偏算法的状态 2 days ago
  yinhuaiwei 5e566cd058 fix: 对纠偏算法的结果解析进行修正 5 days ago
  yinhuaiwei d0c7d93e9d fix: 算法异常(code=2001|2002)不展示读数 5 days ago
  yinhuaiwei 25b246a011 feat: patrol_task表新增specified_alg字段,用于任务指定如纠偏等算法类型(可根据注释“任务指定算法类型”查看逻辑路径);去掉纠偏算法合并逻辑 6 days ago
  yinhuaiwei 6a85ad7b2e fix: 点位管理返回alarmThreshold字段,便于优化点位算法阈值回显 2 weeks ago
  yinhuaiwei 4494a7ee99 refactor: 重构任务详情点位巡检情况汇总的逻辑,记录至patrol_task_status的新增summary字段 3 weeks ago
  yinhuaiwei 9e6a264143 feat: 1.巡视详情和巡视归档可读数类算法,添加单位;2.优化纠偏算法的展示;3.巡视详情新增总-已巡检-未巡检点位数量统计 3 weeks ago
  wangguangyuan 4396b1bdb4 fix:1.阈值管理支持批量,2.巡视方案剔除未配置预置位的点位 3 weeks ago
  wangguangyuan 4ed94ad548 fix:1.联合任务归档task_patrolled_id改成mainId,2.分析失败的结果状态归为异常,3.纠偏的缺陷结果不需要在缺陷详情中展示 3 weeks ago
  wangguangyuan 6627a7fa37 Merge branch 'master' of http://git.ht-atia.cn/qinyanlei/inspect 4 weeks ago
  wangguangyuan 534bcf6ad0 feat:1.联合任务归档,2.新增点位监控编号后台处理,3.阈值管理 4 weeks ago
  yinhuaiwei c95db43c0b fix: 修复阈值管理查看历史记录接口异常 4 weeks ago
  wangguangyuan 88fb9e316f feat:1.新版巡视方案代码,2.纠偏算法不归档 4 weeks ago
  yinhuaiwei d70541349f fix: 修复阈值管理接口异常 1 month ago
  yinhuaiwei 4793c7cdbe feat: 支持多设备联合任务下发;纠偏算法合并到其他算法展示 1 month ago
  yinhuaiwei 9fb6e82c2e feat: 新增部分算法、任务状态、任务类型的枚举类;新增字符串转BigDecimal公共方法 1 month ago
75 changed files with 3106 additions and 1022 deletions
Unified View
  1. +20
    -1
      inspect-base/inspect-base-core/src/main/java/com/inspect/base/core/constant/AlgConstants.java
  2. +2
    -0
      inspect-base/inspect-base-core/src/main/java/com/inspect/base/core/domain/maintain/MaintainRegion.java
  3. +25
    -0
      inspect-base/inspect-base-core/src/main/java/com/inspect/base/core/enums/AlgTypeEnum.java
  4. +45
    -0
      inspect-base/inspect-base-core/src/main/java/com/inspect/base/core/enums/DevTypeEnum.java
  5. +4
    -2
      inspect-base/inspect-base-core/src/main/java/com/inspect/base/core/enums/ResStatusEnum.java
  6. +22
    -7
      inspect-base/inspect-base-core/src/main/java/com/inspect/base/core/enums/TaskStatus.java
  7. +21
    -0
      inspect-base/inspect-base-core/src/main/java/com/inspect/base/core/enums/TaskType.java
  8. +33
    -0
      inspect-base/inspect-base-core/src/main/java/com/inspect/base/core/utils/BigDecimalUtil.java
  9. +4
    -0
      inspect-base/inspect-base-system/src/main/java/com/inspect/system/base/openDomain/PatrolDeviceXml.java
  10. +1
    -0
      inspect-job/src/main/java/com/inspect/job/domain/task/PatrolTask.java
  11. +4
    -0
      inspect-job/src/main/java/com/inspect/job/domain/task/PatrolTaskExecRecord.java
  12. +21
    -25
      inspect-job/src/main/java/com/inspect/job/task/JobMainTask.java
  13. +25
    -12
      inspect-main/inspect-main-task-exec/src/main/java/com/inspect/exec/controller/PatrolTaskExecController.java
  14. +29
    -5
      inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/controller/ResultAnalysisController.java
  15. +0
    -18
      inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/domain/AlgValue.java
  16. +3
    -1
      inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/domain/ResultAnalysis.java
  17. +17
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/domain/ResultAnalysisSummaryDTO.java
  18. +3
    -4
      inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/mapper/ResultAnalysisMapper.java
  19. +3
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/service/IResultAnalysisService.java
  20. +16
    -12
      inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/service/impl/AnalyseResponseServiceImpl.java
  21. +13
    -5
      inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/service/impl/ResultAnalysisServiceImpl.java
  22. +69
    -70
      inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/utils/ResultAnalysisUtils.java
  23. +3
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/fegin/FeignBasedataAreaService.java
  24. +6
    -3
      inspect-main/inspect-main-task/src/main/java/com/inspect/insreport/controller/InspectionReportController.java
  25. +3
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/insreportdata/domain/InspectionReportData.java
  26. +23
    -14
      inspect-main/inspect-main-task/src/main/java/com/inspect/maintain/controller/MaintainRegionController.java
  27. +4
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/maintain/domain/PatrolMaintainModuleXml.java
  28. +2
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/maintain/mapper/MaintainRegionMapper.java
  29. +4
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/maintain/service/IMaintainRegionService.java
  30. +26
    -3
      inspect-main/inspect-main-task/src/main/java/com/inspect/maintain/service/impl/MaintainRegionServiceImpl.java
  31. +98
    -155
      inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/controller/PatrolResultController.java
  32. +4
    -20
      inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/domain/PatrolResultRef.java
  33. +8
    -1
      inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/mapper/PatrolResultMapper.java
  34. +8
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/IPatrolResultService.java
  35. +136
    -65
      inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/impl/PatrolResultServiceImpl.java
  36. +5
    -29
      inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/domain/PatrolTaskResultMain.java
  37. +2
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/mapper/PatrolTaskResultMainMapper.java
  38. +1
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/service/IPatrolTaskResultMainService.java
  39. +4
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/service/impl/PatrolTaskResultMainServiceImpl.java
  40. +747
    -222
      inspect-main/inspect-main-task/src/main/java/com/inspect/task/controller/PatrolTaskController.java
  41. +9
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/task/domain/PatrolData.java
  42. +6
    -50
      inspect-main/inspect-main-task/src/main/java/com/inspect/task/domain/PatrolTask.java
  43. +4
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/task/domain/PatrolTaskModuleXml.java
  44. +2
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/task/domain/SendTask.java
  45. +6
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/task/mapper/PatrolTaskMapper.java
  46. +7
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/task/service/IPatrolTaskService.java
  47. +29
    -5
      inspect-main/inspect-main-task/src/main/java/com/inspect/task/service/impl/PatrolTaskServiceImpl.java
  48. +2
    -47
      inspect-main/inspect-main-task/src/main/java/com/inspect/taskinfo/domain/PatrolTaskInfo.java
  49. +120
    -29
      inspect-main/inspect-main-task/src/main/java/com/inspect/taskstatus/controller/PatrolTaskStatusController.java
  50. +10
    -54
      inspect-main/inspect-main-task/src/main/java/com/inspect/taskstatus/domain/PatrolTaskStatus.java
  51. +11
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/taskstatus/mapper/PatrolTaskStatusMapper.java
  52. +10
    -0
      inspect-main/inspect-main-task/src/main/java/com/inspect/taskstatus/service/IPatrolTaskStatusService.java
  53. +348
    -73
      inspect-main/inspect-main-task/src/main/java/com/inspect/taskstatus/service/impl/PatrolTaskStatusServiceImpl.java
  54. +5
    -3
      inspect-main/inspect-main-task/src/main/resources/mapper/task/InspectionReportDataMapper.xml
  55. +37
    -4
      inspect-main/inspect-main-task/src/main/resources/mapper/task/MaintainRegionMapper.xml
  56. +204
    -8
      inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolResultMapper.xml
  57. +3
    -2
      inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolTaskInfoMapper.xml
  58. +97
    -3
      inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolTaskMapper.xml
  59. +18
    -6
      inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolTaskResultMainMapper.xml
  60. +240
    -7
      inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolTaskStatusMapper.xml
  61. +22
    -0
      inspect-main/inspect-main-task/src/main/resources/mapper/task/ResultAnalysisMapper.xml
  62. +49
    -0
      inspect-metadata/src/main/java/com/inspect/metadata/area/controller/BaseDataAreaController.java
  63. +55
    -0
      inspect-metadata/src/main/java/com/inspect/metadata/area/domain/BaseDataArea.java
  64. +97
    -29
      inspect-metadata/src/main/java/com/inspect/metadata/eqpbook/controller/BasedataEqpBookController.java
  65. +9
    -1
      inspect-metadata/src/main/java/com/inspect/metadata/patrolpointmnt/controller/BasedataPatrolPointController.java
  66. +7
    -0
      inspect-metadata/src/main/java/com/inspect/metadata/patrolpointmnt/domain/BasedataPatrolPoint.java
  67. +2
    -0
      inspect-metadata/src/main/java/com/inspect/metadata/patrolpointmnt/mapper/BasedataPatrolPointMapper.java
  68. +12
    -7
      inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/controller/BasedataDeviceController.java
  69. +10
    -0
      inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/domain/vo/AreaDeviceTreeSelect.java
  70. +1
    -1
      inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/service/IBasedataDeviceService.java
  71. +144
    -6
      inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/service/impl/BasedataDeviceServiceImpl.java
  72. +4
    -0
      inspect-metadata/src/main/java/com/inspect/metadata/threshold/domain/BasedataThresholdModification.java
  73. +10
    -4
      inspect-metadata/src/main/resources/mapper/eqpbook/BasedataEqpBookMapper.xml
  74. +45
    -0
      inspect-metadata/src/main/resources/mapper/patrolpointmnt/BasedataPatrolPointMapper.xml
  75. +7
    -9
      inspect-metadata/src/main/resources/mapper/threshold/BasedataThresholdModificationMapper.xml

+ 20
- 1
inspect-base/inspect-base-core/src/main/java/com/inspect/base/core/constant/AlgConstants.java View File

@ -2,10 +2,13 @@ package com.inspect.base.core.constant;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class AlgConstants { public class AlgConstants {
public static final String METER = "meter"; public static final String METER = "meter";
public static final String GIS_METER_2 = "gis_meter2"; public static final String GIS_METER_2 = "gis_meter2";
public static final String GIS_METER = "gis_meter";
public static final String INFRA_1800 = "infra_1800"; public static final String INFRA_1800 = "infra_1800";
public static final String INFRA_YU3 = "infra_yu3"; public static final String INFRA_YU3 = "infra_yu3";
public static final String INFRA_CAMERA = "infra_camera"; public static final String INFRA_CAMERA = "infra_camera";
@ -13,6 +16,8 @@ public class AlgConstants {
public static final String INFRARED = "infrared"; public static final String INFRARED = "infrared";
public static final String INFRARED2 = "infrared2"; public static final String INFRARED2 = "infrared2";
public static final String XB = "xb"; public static final String XB = "xb";
// 纠偏算法
public static final String CORRECTION = "correction";
public static final String ALG_SUBTYPE_CODE = "alg_subtype_code"; public static final String ALG_SUBTYPE_CODE = "alg_subtype_code";
@ -29,7 +34,7 @@ public class AlgConstants {
INFRARED2, INFRARED2,
"isolator", "isolator",
"gis_meter", "gis_meter",
"correction",
CORRECTION,
"switch", "switch",
GIS_METER_2 GIS_METER_2
); );
@ -45,4 +50,18 @@ public class AlgConstants {
INFRA_CAMERA, INFRA_CAMERA,
INFRA_CAMERA_REVERSE INFRA_CAMERA_REVERSE
); );
/**
* 表计类型的算法
*/
public static final List<String> ALG_METER_LIST = Arrays.asList(
METER,
"gis_meter",
GIS_METER_2
);
/**
* 可读数的算法红外和表计
*/
public static final List<String> READABLE_ALG_LIST = Stream.concat(ALG_INFRARED_LIST.stream(), ALG_METER_LIST.stream()).collect(Collectors.toList());
} }

+ 2
- 0
inspect-base/inspect-base-core/src/main/java/com/inspect/base/core/domain/maintain/MaintainRegion.java View File

@ -60,6 +60,8 @@ public class MaintainRegion extends BaseEntity {
name = "检修设备列表 格式:多个 ID,采用“,”分隔" name = "检修设备列表 格式:多个 ID,采用“,”分隔"
) )
private String deviceList; private String deviceList;
private String deviceNames;
@Excel( @Excel(
name = "坐标框(像素点)格式:x1,y1,z1; x2,y2,z2; x3,y3,z3; x4,y4,z4" name = "坐标框(像素点)格式:x1,y1,z1; x2,y2,z2; x3,y3,z3; x4,y4,z4"
) )


+ 25
- 0
inspect-base/inspect-base-core/src/main/java/com/inspect/base/core/enums/AlgTypeEnum.java View File

@ -0,0 +1,25 @@
package com.inspect.base.core.enums;
public enum AlgTypeEnum {
// 表计
METER("1", "表计"),
// 外观
APPEARANCE("2", "外观"),
// 红外
INFRARED("3", "红外");
private final String code;
private final String info;
AlgTypeEnum(String code, String info) {
this.code = code;
this.info = info;
}
public String getCode() {
return this.code;
}
public String getInfo() {
return this.info;
}
}

+ 45
- 0
inspect-base/inspect-base-core/src/main/java/com/inspect/base/core/enums/DevTypeEnum.java View File

@ -0,0 +1,45 @@
package com.inspect.base.core.enums;
/**
* 设备类型
*/
public enum DevTypeEnum {
// 机器人
ROBOT("0", "机器人"),
// 室外轮式机器人
ROBOT_OUT("1", "室外轮式机器人"),
// 室内轮式机器人
ROBOT_IN("2", "室内轮式机器人"),
// 挂轨机器人
ROBOT_HANG("3", "挂轨机器人"),
// 高清视频
VIDEO("10", "高清视频"),
// 硬盘录像机
DVR("11", "硬盘录像机"),
// 智能分析主机
ANALYZE_HOST("12", "智能分析主机"),
// 无人机
DRONE("13", "无人机"),
// 声纹
VOICE("14", "声纹"),
// 巡视主机
HOST("20", "巡视主机");
private final String code;
private final String info;
DevTypeEnum(String code, String info) {
this.code = code;
this.info = info;
}
public String getCode() {
return this.code;
}
public String getInfo() {
return this.info;
}
}

+ 4
- 2
inspect-base/inspect-base-core/src/main/java/com/inspect/base/core/enums/ResStatusEnum.java View File

@ -6,10 +6,12 @@ package com.inspect.base.core.enums;
* @create 2026-03-27 15:53 * @create 2026-03-27 15:53
**/ **/
public enum ResStatusEnum { public enum ResStatusEnum {
UNCONFIRM("0", "未确认"), UNCONFIRM("0", "未确认"),
CONFIRM("1", "已确认"), CONFIRM("1", "已确认"),
CANCEL("2", "已撤销");
CANCEL("2", "已撤销"),
CORRECT("3", "需要纠偏"),
CORRECTED("4", "完成纠偏");
private final String code; private final String code;
private final String info; private final String info;


+ 22
- 7
inspect-base/inspect-base-core/src/main/java/com/inspect/base/core/enums/TaskStatus.java View File

@ -4,18 +4,33 @@ import lombok.Getter;
@Getter @Getter
public enum TaskStatus { public enum TaskStatus {
DONE("1", "已经执行"),
RUNNING("2", "正在执行"),
PAUSED("3", "暂停执行"),
HALTED("4", "终止执行"),
PENDING("5", "尚未执行"),
EXPIRED("6", "超过期限");
DONE("1", "已经执行", 5),
RUNNING("2", "正在执行", 0),
PAUSED("3", "暂停执行", 1),
HALTED("4", "终止执行", 3),
PENDING("5", "尚未执行", 4),
EXPIRED("6", "超过期限", 2);
private final String code; private final String code;
private final String info; private final String info;
// 状态优先级
private final Integer priority;
TaskStatus(String code, String info) {
TaskStatus(String code, String info, Integer priority) {
this.code = code; this.code = code;
this.info = info; this.info = info;
this.priority = priority;
}
public static TaskStatus fromCode(String code) {
if (code == null) {
return null;
}
for (TaskStatus s : values()) {
if (s.code.equals(code)) {
return s;
}
}
return null;
} }
} }

+ 21
- 0
inspect-base/inspect-base-core/src/main/java/com/inspect/base/core/enums/TaskType.java View File

@ -0,0 +1,21 @@
package com.inspect.base.core.enums;
import lombok.Getter;
/**
* 任务类型枚举
*/
@Getter
public enum TaskType {
ORDINARY("0", "普通任务"),
MAIN("1", "主任务"),
SUB("2", "子任务");
private final String code;
private final String value;
TaskType(String code, String value) {
this.code = code;
this.value = value;
}
}

+ 33
- 0
inspect-base/inspect-base-core/src/main/java/com/inspect/base/core/utils/BigDecimalUtil.java View File

@ -1,6 +1,7 @@
package com.inspect.base.core.utils; package com.inspect.base.core.utils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
public class BigDecimalUtil { public class BigDecimalUtil {
public static double round(double f) { public static double round(double f) {
@ -18,4 +19,36 @@ public class BigDecimalUtil {
return Double.valueOf(s); return Double.valueOf(s);
} }
/**
* 字符串转BigDecimal
*/
public static BigDecimal toBigDecimal(String str) {
if (str == null || str.isEmpty()) {
return BigDecimal.ZERO;
}
try {
String cleanStr = str.replace("%", "").trim();
return new BigDecimal(cleanStr);
} catch (Exception e) {
return BigDecimal.ZERO;
}
}
/**
* 结果保留X位小数
*/
public static String toOneDecimal(String str, int scale) {
if (str == null || str.trim().isEmpty()) {
return str;
}
try {
return new BigDecimal(str.trim())
.setScale(scale, RoundingMode.DOWN)
.toString();
} catch (NumberFormatException e) {
return str;
}
}
} }

+ 4
- 0
inspect-base/inspect-base-system/src/main/java/com/inspect/system/base/openDomain/PatrolDeviceXml.java View File

@ -3,6 +3,7 @@ package com.inspect.system.base.openDomain;
import java.util.List; import java.util.List;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement( @XmlRootElement(
@ -10,6 +11,9 @@ import javax.xml.bind.annotation.XmlRootElement;
) )
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class PatrolDeviceXml { public class PatrolDeviceXml {
@XmlElement(
name = "Item"
)
List<BasedataEqpBookXml> item; List<BasedataEqpBookXml> item;
public List<BasedataEqpBookXml> getItem() { public List<BasedataEqpBookXml> getItem() {


+ 1
- 0
inspect-job/src/main/java/com/inspect/job/domain/task/PatrolTask.java View File

@ -99,6 +99,7 @@ public class PatrolTask extends BaseEntity {
private String areaName; private String areaName;
private List<PatrolTaskInfo> eqPointList; private List<PatrolTaskInfo> eqPointList;
private List<PatrolTaskStatus> patrolTaskStatusList; private List<PatrolTaskStatus> patrolTaskStatusList;
private String specifiedAlg;
@Override @Override
public boolean equals(Object object) { public boolean equals(Object object) {


+ 4
- 0
inspect-job/src/main/java/com/inspect/job/domain/task/PatrolTaskExecRecord.java View File

@ -52,4 +52,8 @@ public class PatrolTaskExecRecord extends BaseEntity {
private Integer finishNumber; private Integer finishNumber;
private Integer cursorNumber; private Integer cursorNumber;
private Integer rebootTimes; private Integer rebootTimes;
/**
* 任务指定算法类型
*/
private String specifiedAlg;
} }

+ 21
- 25
inspect-job/src/main/java/com/inspect/job/task/JobMainTask.java View File

@ -490,7 +490,7 @@ public class JobMainTask {
private PatrolTaskExecRecord prePointExec(PatrolTaskExecRecord taskExecRecord, PatrolTaskInfo patrolTaskInfo, int infoListSize) { private PatrolTaskExecRecord prePointExec(PatrolTaskExecRecord taskExecRecord, PatrolTaskInfo patrolTaskInfo, int infoListSize) {
String uuid = UUID.randomUUID().toString().trim().replaceAll(StringUtils.DASH, StringUtils.EMPTY); String uuid = UUID.randomUUID().toString().trim().replaceAll(StringUtils.DASH, StringUtils.EMPTY);
final PatrolPresetPosSlim presetPos = queryPatrolPresetPos(uuid, patrolTaskInfo.getDeviceId()); final PatrolPresetPosSlim presetPos = queryPatrolPresetPos(uuid, patrolTaskInfo.getDeviceId());
if(StringUtils.isNotEmpty(presetPos.getAddress())) {
if (StringUtils.isNotEmpty(presetPos.getAddress())) {
log.info("prePointExec remake infrared address: raw: {}", presetPos.getAddress()); log.info("prePointExec remake infrared address: raw: {}", presetPos.getAddress());
String infraredAddress = getInfraredAddress(3, presetPos); String infraredAddress = getInfraredAddress(3, presetPos);
presetPos.setAddress(infraredAddress); presetPos.setAddress(infraredAddress);
@ -527,7 +527,6 @@ public class JobMainTask {
String taskPatrolId = taskExecRecord.getTaskPatrolId(); String taskPatrolId = taskExecRecord.getTaskPatrolId();
if (PresetAction.PHOTO.getCode().equals(presetAction.getActionType())) { if (PresetAction.PHOTO.getCode().equals(presetAction.getActionType())) {
final String chanType = presetPos.getChannelType(); final String chanType = presetPos.getChannelType();
fileTypes.append("ir".equals(chanType) ? "1" : "vl".equals(chanType) ? "2" : "").append(",");
//boolean bOk = false; //boolean bOk = false;
try { try {
log.info("PHOTO_PRESET_TYPE taskPatrolId: {}, chanType: {}, patrolPointId: {}, channelCode: {}, videoNvrCode: {}", log.info("PHOTO_PRESET_TYPE taskPatrolId: {}, chanType: {}, patrolPointId: {}, channelCode: {}, videoNvrCode: {}",
@ -537,6 +536,7 @@ public class JobMainTask {
presetPos.getChannelCode(), presetPos.getChannelCode(),
presetPos.getVideoNvrCode()); presetPos.getVideoNvrCode());
if ("vl".equals(chanType)) { if ("vl".equals(chanType)) {
fileTypes.append(2).append(",");
String paramUrl = liveIVS_URL + "/api/v1/device/channelsnap?serial=" String paramUrl = liveIVS_URL + "/api/v1/device/channelsnap?serial="
+ presetPos.getVideoNvrCode() + presetPos.getVideoNvrCode()
+ "&realtime=true&code=" + presetPos.getChannelCode() + "&realtime=true&code=" + presetPos.getChannelCode()
@ -558,6 +558,9 @@ public class JobMainTask {
recordPersist(taskExecRecord, infoListSize, patrolTaskInfo, presetPos, fileTypes, filePaths); recordPersist(taskExecRecord, infoListSize, patrolTaskInfo, presetPos, fileTypes, filePaths);
} else if ("ir".equals(chanType)) { } else if ("ir".equals(chanType)) {
Map<String, String> algSubtypeIdMap = taskExecClient.getAlgTypeListByPatrolPointId(String.valueOf(presetPos.getPatrolPointId())); Map<String, String> algSubtypeIdMap = taskExecClient.getAlgTypeListByPatrolPointId(String.valueOf(presetPos.getPatrolPointId()));
// 任务指定算法类型巡视详情的图片类型加载
boolean isSpecifiedAlg = StringUtils.isNotEmpty(taskExecRecord.getSpecifiedAlg());
fileTypes.append(isSpecifiedAlg ? "2" : "1").append(",");
String paramUrl = liveIVS_URL String paramUrl = liveIVS_URL
+ "/api/v1/device/channelsnap?serial=" + presetPos.getVideoNvrCode() + "/api/v1/device/channelsnap?serial=" + presetPos.getVideoNvrCode()
+ "&realtime=true&code=" + presetPos.getChannelCode(); + "&realtime=true&code=" + presetPos.getChannelCode();
@ -1099,7 +1102,6 @@ public class JobMainTask {
String immediatelyExecTaskTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS")); String immediatelyExecTaskTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"));
redisService.setCacheObjectOfTask(RedisConst.IMMEDIATELY_EXEC_TASK_TIME, patrolTask.getTaskCode(), immediatelyExecTaskTime); redisService.setCacheObjectOfTask(RedisConst.IMMEDIATELY_EXEC_TASK_TIME, patrolTask.getTaskCode(), immediatelyExecTaskTime);
log.info("SET TASK_CURRENT_CODE: key: {}, value: {}", RedisConst.TASK_CURRENT_CODE + patrolTask.getTaskCode(), RedisConst.TASK_CODE + patrolTask.getTaskCode() + StringUtils.AT + immediatelyExecTaskTime); log.info("SET TASK_CURRENT_CODE: key: {}, value: {}", RedisConst.TASK_CURRENT_CODE + patrolTask.getTaskCode(), RedisConst.TASK_CODE + patrolTask.getTaskCode() + StringUtils.AT + immediatelyExecTaskTime);
redisService.setCacheObjectOfTask(RedisConst.TASK_CURRENT_CODE, patrolTask.getTaskCode(), RedisConst.TASK_CODE + patrolTask.getTaskCode() + StringUtils.AT + immediatelyExecTaskTime, 4L, TimeUnit.HOURS);
resetRecordCounter(patrolTask.getTaskCode()); resetRecordCounter(patrolTask.getTaskCode());
log.info("TASK REC CNT: {}", cameraPatrolTasks.size());//devType是2的设备数 log.info("TASK REC CNT: {}", cameraPatrolTasks.size());//devType是2的设备数
setRedisRecordCount(patrolTask.getTaskCode(), cameraPatrolTasks.size()); setRedisRecordCount(patrolTask.getTaskCode(), cameraPatrolTasks.size());
@ -1134,6 +1136,7 @@ public class JobMainTask {
patrolTaskExecRecord.setDeviceId("0"); patrolTaskExecRecord.setDeviceId("0");
patrolTaskExecRecord.setExecPointId(0L); patrolTaskExecRecord.setExecPointId(0L);
patrolTaskExecRecord.setTotalNumber(taskInfos.isEmpty() ? 1 : taskInfos.size()); patrolTaskExecRecord.setTotalNumber(taskInfos.isEmpty() ? 1 : taskInfos.size());
patrolTaskExecRecord.setSpecifiedAlg(patrolTask.getSpecifiedAlg());
log.info("taskName: {}, taskCode: {}, taskPatrolledId: {}", log.info("taskName: {}, taskCode: {}, taskPatrolledId: {}",
patrolTaskExecRecord.getTaskName(), patrolTaskExecRecord.getTaskCode(), patrolTaskExecRecord.getTaskPatrolId()); patrolTaskExecRecord.getTaskName(), patrolTaskExecRecord.getTaskCode(), patrolTaskExecRecord.getTaskPatrolId());
taskExecClient.addPatrolTaskExecRecord(patrolTaskExecRecord); taskExecClient.addPatrolTaskExecRecord(patrolTaskExecRecord);
@ -1306,13 +1309,19 @@ public class JobMainTask {
// } // }
// } // }
private int calcTaskAlgorithmTotalNumber(List<PatrolTaskInfo> patrolTaskInfoList) {
private int calcTaskAlgorithmTotalNumber(List<PatrolTaskInfo> patrolTaskInfoList, String specifiedAlg) {
int totalAlgorithmNumber = 0; int totalAlgorithmNumber = 0;
for (PatrolTaskInfo patrolTaskInfo : patrolTaskInfoList) { for (PatrolTaskInfo patrolTaskInfo : patrolTaskInfoList) {
String result = taskExecClient.getAlgSubtypeIdsByPatrolPointId(patrolTaskInfo.getDeviceId());
if (StringUtils.isNotEmpty(result)) {
String[] algSubtypeIds = result.split(StringUtils.COMMA);
// 任务指定算法类型累加任务点位算法个数
if (StringUtils.isNotEmpty(specifiedAlg)) {
String[] algSubtypeIds = specifiedAlg.split(StringUtils.COMMA);
totalAlgorithmNumber += algSubtypeIds.length; totalAlgorithmNumber += algSubtypeIds.length;
} else {
String result = taskExecClient.getAlgSubtypeIdsByPatrolPointId(patrolTaskInfo.getDeviceId());
if (StringUtils.isNotEmpty(result)) {
String[] algSubtypeIds = result.split(StringUtils.COMMA);
totalAlgorithmNumber += algSubtypeIds.length;
}
} }
} }
@ -1325,7 +1334,7 @@ public class JobMainTask {
deviceMap.computeIfAbsent(patrolTaskInfo.getDeviceCode(), k -> new ArrayList<>()).add(patrolTaskInfo); deviceMap.computeIfAbsent(patrolTaskInfo.getDeviceCode(), k -> new ArrayList<>()).add(patrolTaskInfo);
} }
int totalAlgorithmNumber = calcTaskAlgorithmTotalNumber(patrolTaskInfoList);
int totalAlgorithmNumber = calcTaskAlgorithmTotalNumber(patrolTaskInfoList, patrolTaskExecRecord.getSpecifiedAlg());
patrolTaskExecRecord.setTotalAlgorithmNumber(totalAlgorithmNumber); patrolTaskExecRecord.setTotalAlgorithmNumber(totalAlgorithmNumber);
asyncTaskPatrolPointCnt.set(0); asyncTaskPatrolPointCnt.set(0);
@ -1423,6 +1432,7 @@ public class JobMainTask {
patrolTaskExecRecord.getOldTaskPatrolId(), patrolTaskExecRecord.getOldTaskPatrolId(),
isConsummate ? "false" : "true"); isConsummate ? "false" : "true");
} }
public List<List<PatrolTaskInfo>> optimizedGroup(List<PatrolTaskInfo> list) { public List<List<PatrolTaskInfo>> optimizedGroup(List<PatrolTaskInfo> list) {
Map<String, List<PatrolTaskInfo>> deviceMap = new HashMap<>(); Map<String, List<PatrolTaskInfo>> deviceMap = new HashMap<>();
@ -1455,7 +1465,6 @@ public class JobMainTask {
return result; return result;
} }
private void execRemoveMaintainArea(List<PatrolTaskInfo> patrolTaskInfoList, List<MaintainRegion> maintAreaList, List<String> deviceIds) { private void execRemoveMaintainArea(List<PatrolTaskInfo> patrolTaskInfoList, List<MaintainRegion> maintAreaList, List<String> deviceIds) {
for (MaintainRegion area : maintAreaList) { for (MaintainRegion area : maintAreaList) {
if (area.getStartTime().getTime() < System.currentTimeMillis() && area.getEndTime().getTime() > System.currentTimeMillis()) { if (area.getStartTime().getTime() < System.currentTimeMillis() && area.getEndTime().getTime() > System.currentTimeMillis()) {
@ -1547,7 +1556,6 @@ public class JobMainTask {
return record != null && TaskStatus.RUNNING.getCode().equals(record.getTaskState()); return record != null && TaskStatus.RUNNING.getCode().equals(record.getTaskState());
} }
@SuppressWarnings({"unused"}) @SuppressWarnings({"unused"})
public void generalTask() { public void generalTask() {
log.info("***************************** JobTaskTimer generalTask *************************************"); log.info("***************************** JobTaskTimer generalTask *************************************");
@ -1969,6 +1977,7 @@ public class JobMainTask {
.deviceId("0") .deviceId("0")
.execPointId(0L) .execPointId(0L)
.totalNumber(taskInfos.isEmpty() ? 1 : taskInfos.size()) .totalNumber(taskInfos.isEmpty() ? 1 : taskInfos.size())
.specifiedAlg(patrolTask.getSpecifiedAlg())
.build(); .build();
try { try {
taskExecClient.addPatrolTaskExecRecord(patrolTaskExecRecord); taskExecClient.addPatrolTaskExecRecord(patrolTaskExecRecord);
@ -1984,19 +1993,6 @@ public class JobMainTask {
} }
} }
// private void incrementRedisRecordCounter() {
// Integer redisRecCnt = redisService.getCacheObject(RedisConst.TASK_RECORD_CNT);
// if (redisRecCnt == null) {
// redisRecCnt = 1;
// redisService.setCacheObject(RedisConst.TASK_RECORD_CNT, redisRecCnt);
// } else {
// redisRecCnt++;
// redisService.setCacheObject(RedisConst.TASK_RECORD_CNT, redisRecCnt);
// }
//
// log.info(Color.YELLOW + "[JOB] redisRecCnt: {}" + Color.END, redisRecCnt);
// }
@SuppressWarnings({"unused"}) @SuppressWarnings({"unused"})
public void execRepeatDayTask(List<PatrolTask> patrolTaskList) { public void execRepeatDayTask(List<PatrolTask> patrolTaskList) {
log.info("***************************** JobTaskTimer execRepeatDayTask with parameters *************************************"); log.info("***************************** JobTaskTimer execRepeatDayTask with parameters *************************************");
@ -2056,14 +2052,14 @@ public class JobMainTask {
if (!patrolTaskControlList.isEmpty()) { if (!patrolTaskControlList.isEmpty()) {
log.info(Color.YELLOW + "PATROL_TASK_LIST_DEVICE: {}, task list size: {}" + Color.END, redisKey, patrolTaskControlList.size()); log.info(Color.YELLOW + "PATROL_TASK_LIST_DEVICE: {}, task list size: {}" + Color.END, redisKey, patrolTaskControlList.size());
redisService.setCacheObjectOfTask(RedisConst.TASK_CURRENT_CODE, taskCode, redisKey, 5L, TimeUnit.MINUTES);
redisService.setCacheObjectOfTask(RedisConst.TASK_CURRENT_CODE, taskCode, redisKey, 1L, TimeUnit.HOURS);
// 执行机器狗无人机设备任务 // 执行机器狗无人机设备任务
taskExecClient.execDeviceTask(patrolTaskControlList); taskExecClient.execDeviceTask(patrolTaskControlList);
} }
if (!patrolTaskListEx.isEmpty()) { if (!patrolTaskListEx.isEmpty()) {
log.info(Color.YELLOW + "PATROL_TASK_LIST_VL: {}, task list size: {}" + Color.END, redisKey, patrolTaskListEx.size()); log.info(Color.YELLOW + "PATROL_TASK_LIST_VL: {}, task list size: {}" + Color.END, redisKey, patrolTaskListEx.size());
redisService.setCacheObjectOfTask(RedisConst.TASK_CURRENT_CODE, taskCode, redisKey, 5L, TimeUnit.MINUTES);
redisService.setCacheObjectOfTask(RedisConst.TASK_CURRENT_CODE, taskCode, redisKey, 1L, TimeUnit.HOURS);
execEveryDayTask(patrolTaskListEx); execEveryDayTask(patrolTaskListEx);
} }
// if (patrolTaskList != null && !patrolTaskList.isEmpty()) { // if (patrolTaskList != null && !patrolTaskList.isEmpty()) {


+ 25
- 12
inspect-main/inspect-main-task-exec/src/main/java/com/inspect/exec/controller/PatrolTaskExecController.java View File

@ -48,6 +48,7 @@ import com.inspect.task.service.IPatrolTaskService;
import com.inspect.taskinfo.domain.PatrolTaskInfo; import com.inspect.taskinfo.domain.PatrolTaskInfo;
import com.inspect.taskinfo.service.IPatrolTaskInfoService; import com.inspect.taskinfo.service.IPatrolTaskInfoService;
import com.inspect.taskstatus.client.FeignTaskClient; import com.inspect.taskstatus.client.FeignTaskClient;
import com.inspect.taskstatus.controller.PatrolTaskStatusController;
import com.inspect.taskstatus.domain.PatrolTaskStatus; import com.inspect.taskstatus.domain.PatrolTaskStatus;
import com.inspect.taskstatus.service.IPatrolTaskStatusService; import com.inspect.taskstatus.service.IPatrolTaskStatusService;
@ -88,6 +89,9 @@ public class PatrolTaskExecController extends BaseController {
@Resource @Resource
private FeignTaskClient feignTaskClient; private FeignTaskClient feignTaskClient;
@Resource
private PatrolTaskStatusController patrolTaskStatusController;
public PatrolTaskExecController(IPatrolTaskInfoService patrolTaskInfoService, IPatrolTaskService patrolTaskService, RedisService redisService, IPatrolTaskStatusService patrolTaskStatusService, IDBPatrolPointService dbPatrolPointService, IPatrolPresetPosService patrolPresetPosService, IPatrolPresetActionService patrolPresetActionService, IPatrolTaskExecRecordService patrolTaskExecRecordService, IPatrolTaskPointExecRecordService patrolTaskPointExecRecordService, IMaintainRegionService maintainRegionService, IPatrolPresetParamService patrolPresetParamService, ISilenceTaskPointExecRecordService silenceTaskPointExecRecordService, IEqpBookChannelService eqpBookChannelService, IPatrolResultService patrolResultService, IEqpBookService eqpBookService) { public PatrolTaskExecController(IPatrolTaskInfoService patrolTaskInfoService, IPatrolTaskService patrolTaskService, RedisService redisService, IPatrolTaskStatusService patrolTaskStatusService, IDBPatrolPointService dbPatrolPointService, IPatrolPresetPosService patrolPresetPosService, IPatrolPresetActionService patrolPresetActionService, IPatrolTaskExecRecordService patrolTaskExecRecordService, IPatrolTaskPointExecRecordService patrolTaskPointExecRecordService, IMaintainRegionService maintainRegionService, IPatrolPresetParamService patrolPresetParamService, ISilenceTaskPointExecRecordService silenceTaskPointExecRecordService, IEqpBookChannelService eqpBookChannelService, IPatrolResultService patrolResultService, IEqpBookService eqpBookService) {
this.patrolTaskInfoService = patrolTaskInfoService; this.patrolTaskInfoService = patrolTaskInfoService;
this.patrolTaskService = patrolTaskService; this.patrolTaskService = patrolTaskService;
@ -830,19 +834,28 @@ public class PatrolTaskExecController extends BaseController {
} }
if (StringUtils.isNotEmpty(receiveCode)) { if (StringUtils.isNotEmpty(receiveCode)) {
log.info("定时任务--无人机-机器人任务构建, receiveCode: {}, devType: {}, devNo: {}", receiveCode, patrolTask.getDevType(), patrolTask.getDevNo()); log.info("定时任务--无人机-机器人任务构建, receiveCode: {}, devType: {}, devNo: {}", receiveCode, patrolTask.getDevType(), patrolTask.getDevNo());
SendTask sendTask = new SendTask();
sendTask.setReceiveCode(receiveCode);
sendTask.setSendCode(sendCode);
sendTask.setCode(patrolTask.getTaskId() + "");
sendTask.setType("41");
sendTask.setCommand("1");
String pilotTaskCmd = JSONObject.toJSONString(sendTask);
pilotTaskCmds.add(pilotTaskCmd);
// 判断任务点位是否在检修区域内
if (patrolTaskStatusController.isWithinMaintainRegion(patrolTask.getTaskCode(), patrolTask.getDevNo())) {
log.info("该任务点位在检修区域内 taskCode: {},sendCode: {}", patrolTask.getTaskCode(), patrolTask.getDevNo());
} else {
SendTask sendTask = new SendTask();
sendTask.setReceiveCode(receiveCode);
sendTask.setSendCode(sendCode);
sendTask.setCode(patrolTask.getTaskId() + "");
sendTask.setType("41");
sendTask.setCommand("1");
String pilotTaskCmd = JSONObject.toJSONString(sendTask);
pilotTaskCmds.add(pilotTaskCmd);
}
} }
} }
if (pilotTaskCmds.isEmpty()) {
redisService.deleteObjectOfTask(RedisConst.TASK_CURRENT_CODE, patrolTask.getTaskCode());
}
// 下发无人机-机器人任务 // 下发无人机-机器人任务
for(String pilotTaskCmd : pilotTaskCmds) {
for (String pilotTaskCmd : pilotTaskCmds) {
log.info("定时任务--无人机-机器人任务执行, pilotTaskCmd: {}", pilotTaskCmd); log.info("定时任务--无人机-机器人任务执行, pilotTaskCmd: {}", pilotTaskCmd);
try { try {
this.feignTaskClient.sendCommand(pilotTaskCmd); this.feignTaskClient.sendCommand(pilotTaskCmd);
@ -854,10 +867,9 @@ public class PatrolTaskExecController extends BaseController {
} }
} }
private void extracted(String key, String taskCode) { private void extracted(String key, String taskCode) {
log.info(Color.RED + "[EXEC] Add new task [{}]" + Color.END, key);//日志里没搜到 log.info(Color.RED + "[EXEC] Add new task [{}]" + Color.END, key);//日志里没搜到
redisService.setCacheObjectOfTask(RedisConst.TASK_CURRENT_CODE, taskCode, key, 5L, TimeUnit.MINUTES);
redisService.setCacheObjectOfTask(RedisConst.TASK_CURRENT_CODE, taskCode, key, 4L, TimeUnit.HOURS);
log.info("[EXEC] key: {}", key); log.info("[EXEC] key: {}", key);
List<PatrolTask> cameraPatrolTasks = redisService.getCacheObject(key); List<PatrolTask> cameraPatrolTasks = redisService.getCacheObject(key);
if (!cameraPatrolTasks.isEmpty()) { if (!cameraPatrolTasks.isEmpty()) {
@ -927,6 +939,7 @@ public class PatrolTaskExecController extends BaseController {
.endTime(task.getEndTime()) .endTime(task.getEndTime())
.areaId(task.getAreaId()) .areaId(task.getAreaId())
.areaName(task.getAreaName()) .areaName(task.getAreaName())
.specifiedAlg(task.getSpecifiedAlg())
.build(); .build();
patrolTaskList.add(patrolTask); patrolTaskList.add(patrolTask);
return patrolTaskList; return patrolTaskList;
@ -934,7 +947,7 @@ public class PatrolTaskExecController extends BaseController {
private List<PatrolTask> filterPatrolTaskList(PatrolTask taskParam) { private List<PatrolTask> filterPatrolTaskList(PatrolTask taskParam) {
List<PatrolTask> patrolTaskListEx = patrolTaskService.selectPatrolTaskList(taskParam); List<PatrolTask> patrolTaskListEx = patrolTaskService.selectPatrolTaskList(taskParam);
if(patrolTaskListEx.isEmpty())
if (patrolTaskListEx.isEmpty())
return new ArrayList<>(); return new ArrayList<>();
PatrolTask task = patrolTaskListEx.get(0); PatrolTask task = patrolTaskListEx.get(0);


+ 29
- 5
inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/controller/ResultAnalysisController.java View File

@ -5,7 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.inspect.analysis.domain.*; import com.inspect.analysis.domain.*;
import com.inspect.analysis.service.IResultAnalysisService; import com.inspect.analysis.service.IResultAnalysisService;
import com.inspect.base.core.constant.Color;
import com.inspect.base.core.constant.AlgConstants;
import com.inspect.base.core.domain.Response; import com.inspect.base.core.domain.Response;
import com.inspect.base.core.enums.PointStatusEnum; import com.inspect.base.core.enums.PointStatusEnum;
import com.inspect.base.core.utils.StringUtils; import com.inspect.base.core.utils.StringUtils;
@ -17,6 +17,7 @@ import com.inspect.base.core.web.page.TableDataInfo;
import com.inspect.base.core.web.page.TableSupport; import com.inspect.base.core.web.page.TableSupport;
import com.inspect.common.log.annotation.Log; import com.inspect.common.log.annotation.Log;
import com.inspect.common.log.enums.BizType; import com.inspect.common.log.enums.BizType;
import com.inspect.fegin.FeignBasedataAreaService;
import com.inspect.message.MessageUtils; import com.inspect.message.MessageUtils;
import com.inspect.partrolresult.domain.AlgInfo; import com.inspect.partrolresult.domain.AlgInfo;
import com.inspect.partrolresult.domain.PatrolResult; import com.inspect.partrolresult.domain.PatrolResult;
@ -49,6 +50,7 @@ public class ResultAnalysisController extends BaseController {
private final IPatrolTaskService patrolTaskService; private final IPatrolTaskService patrolTaskService;
private final IPatrolTaskInfoService iPatrolTaskInfoService; private final IPatrolTaskInfoService iPatrolTaskInfoService;
private final IPatrolResultService patrolResultService; private final IPatrolResultService patrolResultService;
private final FeignBasedataAreaService feignBasedataAreaService;
@Resource @Resource
private MessageUtils messageUtils; private MessageUtils messageUtils;
@ -56,11 +58,12 @@ public class ResultAnalysisController extends BaseController {
@Resource @Resource
private PatrolResultMapper patrolResultMapper; private PatrolResultMapper patrolResultMapper;
public ResultAnalysisController(IResultAnalysisService resultAnalysisService, IPatrolTaskService patrolTaskService, IPatrolTaskInfoService iPatrolTaskInfoService, IPatrolResultService patrolResultService) {
public ResultAnalysisController(IResultAnalysisService resultAnalysisService, IPatrolTaskService patrolTaskService, IPatrolTaskInfoService iPatrolTaskInfoService, IPatrolResultService patrolResultService, FeignBasedataAreaService feignBasedataAreaService) {
this.resultAnalysisService = resultAnalysisService; this.resultAnalysisService = resultAnalysisService;
this.patrolTaskService = patrolTaskService; this.patrolTaskService = patrolTaskService;
this.iPatrolTaskInfoService = iPatrolTaskInfoService; this.iPatrolTaskInfoService = iPatrolTaskInfoService;
this.patrolResultService = patrolResultService; this.patrolResultService = patrolResultService;
this.feignBasedataAreaService = feignBasedataAreaService;
} }
public String recursionGetNameId(String devId) { public String recursionGetNameId(String devId) {
@ -709,10 +712,15 @@ public class ResultAnalysisController extends BaseController {
patrolData.setImg(data.getImg()); patrolData.setImg(data.getImg());
} }
} }
String areaId = value.stream().map(PatrolData::getAreaId).distinct().findFirst().orElse("");
logger.info("defectList缺陷记录,{}",areaId);
// 用新的区域树
String areaNameS = getAreaNameSByAreaIdSRelation(areaId);
logger.info("defectList缺陷记录,{}",areaNameS);
String imageNormalPath = imageNormalMap.getOrDefault(taskPatrolId + "_" + objectId + "_" + algType, ""); String imageNormalPath = imageNormalMap.getOrDefault(taskPatrolId + "_" + objectId + "_" + algType, "");
patrolData.setImageNormalUrlPath(imageNormalPath); patrolData.setImageNormalUrlPath(imageNormalPath);
patrolData.setAlgName(value.stream().map(item -> item.getAlgName() != null ? item.getAlgName() : "").distinct().findFirst().orElse("")); patrolData.setAlgName(value.stream().map(item -> item.getAlgName() != null ? item.getAlgName() : "").distinct().findFirst().orElse(""));
patrolData.setAreaName(value.stream().map(item -> item.getAreaName() != null ? item.getAreaName() : "").distinct().findFirst().orElse(""));
patrolData.setAreaName(areaNameS);
patrolData.setBrightDesc(value.stream().map(item -> item.getBrightDesc() != null ? item.getBrightDesc() : "").distinct().findFirst().orElse("")); patrolData.setBrightDesc(value.stream().map(item -> item.getBrightDesc() != null ? item.getBrightDesc() : "").distinct().findFirst().orElse(""));
patrolData.setBrightImgAnalyse(value.stream().map(item -> item.getBrightImgAnalyse() != null ? item.getBrightImgAnalyse() : "").distinct().findFirst().orElse("")); patrolData.setBrightImgAnalyse(value.stream().map(item -> item.getBrightImgAnalyse() != null ? item.getBrightImgAnalyse() : "").distinct().findFirst().orElse(""));
patrolData.setBrightResStatus(value.stream().map(item -> item.getBrightResStatus() != null ? item.getBrightResStatus() : "").distinct().findFirst().orElse("")); patrolData.setBrightResStatus(value.stream().map(item -> item.getBrightResStatus() != null ? item.getBrightResStatus() : "").distinct().findFirst().orElse(""));
@ -753,6 +761,17 @@ public class ResultAnalysisController extends BaseController {
return rspData; return rspData;
} }
/**
* 新的关系树
* @param areaIdS
* @return
*/
private String getAreaNameSByAreaIdSRelation(String areaIdS) {
AjaxResult ajaxResult = feignBasedataAreaService.selectAreaNameSForTaskByAreaIdSRelation((new JSONObject()).fluentPut("areaIdS", areaIdS));
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult));
return jsonObject.get("data").toString();
}
//初筛大模型一起查询 //初筛大模型一起查询
@GetMapping({"/list_v2_ex"}) @GetMapping({"/list_v2_ex"})
public TableDataInfo listV2Ex(PatrolTaskStatus patrolTaskStatus) { public TableDataInfo listV2Ex(PatrolTaskStatus patrolTaskStatus) {
@ -796,10 +815,15 @@ public class ResultAnalysisController extends BaseController {
item -> new GroupKey(item.getObjectId(), item.getAlgType()) item -> new GroupKey(item.getObjectId(), item.getAlgType())
)); ));
List<PatrolData> resultList = new ArrayList<>(); List<PatrolData> resultList = new ArrayList<>();
groupedFilterList.forEach((key, value) -> {
for (Map.Entry<GroupKey, List<PatrolData>> groupKeyListEntry : groupedFilterList.entrySet()) {
GroupKey key = groupKeyListEntry.getKey();
List<PatrolData> value = groupKeyListEntry.getValue();
PatrolData patrolData = new PatrolData(); PatrolData patrolData = new PatrolData();
patrolData.setObjectId(key.objectId); patrolData.setObjectId(key.objectId);
patrolData.setAlgType(key.algType); patrolData.setAlgType(key.algType);
if (AlgConstants.CORRECTION.equals(key.algType)) {
continue;
}
patrolData.setDesc(value.stream().map(PatrolData::getDesc).distinct().collect(Collectors.joining(","))); patrolData.setDesc(value.stream().map(PatrolData::getDesc).distinct().collect(Collectors.joining(",")));
for (PatrolData data : value) { for (PatrolData data : value) {
// 初筛有缺陷 展示初筛结果图片 // 初筛有缺陷 展示初筛结果图片
@ -839,7 +863,7 @@ public class ResultAnalysisController extends BaseController {
patrolData.setWarnStatus(value.stream().map(item -> item.getWarnStatus() != null ? item.getWarnStatus() : "").distinct().findFirst().orElse("")); patrolData.setWarnStatus(value.stream().map(item -> item.getWarnStatus() != null ? item.getWarnStatus() : "").distinct().findFirst().orElse(""));
resultList.add(patrolData); resultList.add(patrolData);
});
}
Collections.sort(resultList); Collections.sort(resultList);


+ 0
- 18
inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/domain/AlgValue.java View File

@ -5,8 +5,6 @@ import com.inspect.base.core.utils.StringUtils;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Objects; import java.util.Objects;
@Setter @Setter
@ -57,22 +55,6 @@ public class AlgValue {
return valueOnlyPrecise; return valueOnlyPrecise;
} }
/**
* 结果保留一位小数
*/
public String toOneDecimal(String str) {
if (str == null || str.trim().isEmpty()) {
return str;
}
try {
return new BigDecimal(str.trim())
.setScale(1, RoundingMode.DOWN)
.toString();
} catch (NumberFormatException e) {
return str;
}
}
public AlgValue(String max, String min) { public AlgValue(String max, String min) {
this.max = max; this.max = max;
this.min = min; this.min = min;


+ 3
- 1
inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/domain/ResultAnalysis.java View File

@ -1,6 +1,5 @@
package com.inspect.analysis.domain; package com.inspect.analysis.domain;
import com.inspect.analysis.constant.AnalyseConstants;
import com.inspect.base.core.annotation.Excel; import com.inspect.base.core.annotation.Excel;
import com.inspect.base.core.utils.StringUtils; import com.inspect.base.core.utils.StringUtils;
import com.inspect.base.core.web.domain.BaseEntity; import com.inspect.base.core.web.domain.BaseEntity;
@ -65,6 +64,7 @@ public class ResultAnalysis extends BaseEntity {
private int csYcNum; private int csYcNum;
private int aiQxNum; private int aiQxNum;
private int aiYcNum; private int aiYcNum;
private int qxNum;
private String pointName; private String pointName;
private String deviceName; private String deviceName;
private String abnormal; private String abnormal;
@ -72,6 +72,7 @@ public class ResultAnalysis extends BaseEntity {
private String deviceSource; private String deviceSource;
private String filterDesc; private String filterDesc;
private String desc; private String desc;
private List<String> taskPatrolIds;
public ResultAnalysis(String businessId) { public ResultAnalysis(String businessId) {
this.businessId = businessId; this.businessId = businessId;
@ -448,6 +449,7 @@ public class ResultAnalysis extends BaseEntity {
", resultContent='" + resultContent + '\'' + ", resultContent='" + resultContent + '\'' +
", resStatus='" + resStatus + '\'' + ", resStatus='" + resStatus + '\'' +
", pointStatus='" + pointStatus + '\'' + ", pointStatus='" + pointStatus + '\'' +
", pointStatusList='" + pointStatusList + '\'' +
", beginTime='" + beginTime + '\'' + ", beginTime='" + beginTime + '\'' +
", endTime='" + endTime + '\'' + ", endTime='" + endTime + '\'' +
", createTime='" + super.getCreateTime() + '\'' + ", createTime='" + super.getCreateTime() + '\'' +


+ 17
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/domain/ResultAnalysisSummaryDTO.java View File

@ -0,0 +1,17 @@
package com.inspect.analysis.domain;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString
public class ResultAnalysisSummaryDTO {
private String taskPatrolId;
private int qxNum; // 注意COUNT/SUM 返回的是数值类型
private int csQxNum;
private int aiQxNum;
private int csYcNum;
private int aiYcNum;
}

+ 3
- 4
inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/mapper/ResultAnalysisMapper.java View File

@ -1,9 +1,6 @@
package com.inspect.analysis.mapper; package com.inspect.analysis.mapper;
import com.inspect.analysis.domain.AlgPatrolPoint;
import com.inspect.analysis.domain.AnalyseLog;
import com.inspect.analysis.domain.AnalyseSummaryAlarmModel;
import com.inspect.analysis.domain.ResultAnalysis;
import com.inspect.analysis.domain.*;
import com.inspect.partrolresult.domain.PatrolResult; import com.inspect.partrolresult.domain.PatrolResult;
import com.inspect.task.domain.PatrolData; import com.inspect.task.domain.PatrolData;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -83,4 +80,6 @@ public interface ResultAnalysisMapper {
List<ResultAnalysis> selectResultAnalysisListBatch(@Param("list") List<String> taskPatrolIds, @Param("resultType") String resultType); List<ResultAnalysis> selectResultAnalysisListBatch(@Param("list") List<String> taskPatrolIds, @Param("resultType") String resultType);
void updateResultAnalysisByCondition(ResultAnalysis analysis); void updateResultAnalysisByCondition(ResultAnalysis analysis);
List<ResultAnalysisSummaryDTO> countResultAnalysisSummary(@Param("list") List<String> taskPatrolIds);
} }

+ 3
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/service/IResultAnalysisService.java View File

@ -3,6 +3,7 @@ package com.inspect.analysis.service;
import com.inspect.analysis.domain.AlgPatrolPoint; import com.inspect.analysis.domain.AlgPatrolPoint;
import com.inspect.analysis.domain.AnalyseSummaryAlarmModel; import com.inspect.analysis.domain.AnalyseSummaryAlarmModel;
import com.inspect.analysis.domain.ResultAnalysis; import com.inspect.analysis.domain.ResultAnalysis;
import com.inspect.analysis.domain.ResultAnalysisSummaryDTO;
import com.inspect.partrolresult.domain.PatrolResult; import com.inspect.partrolresult.domain.PatrolResult;
import com.inspect.task.domain.PatrolData; import com.inspect.task.domain.PatrolData;
@ -59,4 +60,6 @@ public interface IResultAnalysisService {
Long getDefectCountGroupByPoint(String defectFilter, String defectIsToday, String type); Long getDefectCountGroupByPoint(String defectFilter, String defectIsToday, String type);
void updateResultAnalysisByCondition(ResultAnalysis analysis); void updateResultAnalysisByCondition(ResultAnalysis analysis);
List<ResultAnalysisSummaryDTO> countResultAnalysisSummary(List<String> taskPatrolIds);
} }

+ 16
- 12
inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/service/impl/AnalyseResponseServiceImpl.java View File

@ -17,6 +17,7 @@ import com.inspect.base.core.constant.Color;
import com.inspect.base.core.constant.RedisConst; import com.inspect.base.core.constant.RedisConst;
import com.inspect.base.core.constant.Tags; import com.inspect.base.core.constant.Tags;
import com.inspect.base.core.enums.TaskStatus; import com.inspect.base.core.enums.TaskStatus;
import com.inspect.base.core.utils.BigDecimalUtil;
import com.inspect.base.core.utils.DateUtils; import com.inspect.base.core.utils.DateUtils;
import com.inspect.base.core.utils.StringUtils; import com.inspect.base.core.utils.StringUtils;
import com.inspect.base.redis.service.RedisService; import com.inspect.base.redis.service.RedisService;
@ -39,6 +40,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -751,11 +753,7 @@ public class AnalyseResponseServiceImpl implements IAnalyseResponseService {
private Map<String, PatrolResult> selectObj2PatrolResultMap(String filter, String patrolTaskId, String deviceId) { private Map<String, PatrolResult> selectObj2PatrolResultMap(String filter, String patrolTaskId, String deviceId) {
log.info("OBJ_TO_PATROL_RESULT_S taskPatrolId: {}, filter: {}, deviceId: {}", patrolTaskId, filter, deviceId); log.info("OBJ_TO_PATROL_RESULT_S taskPatrolId: {}, filter: {}, deviceId: {}", patrolTaskId, filter, deviceId);
List<PatrolTaskResultMain> resultMainList =
patrolTaskResultMainService.selectPatrolTaskResultMainList(new PatrolTaskResultMain(patrolTaskId));
assert resultMainList != null;
assert !resultMainList.isEmpty();
PatrolTaskResultMain resultMain = resultMainList.get(0);
PatrolTaskResultMain resultMain = patrolTaskResultMainService.selectPatrolTaskResultMainOne(patrolTaskId);
PatrolResult patrolResult = new PatrolResult(); PatrolResult patrolResult = new PatrolResult();
patrolResult.setMainId(String.valueOf(resultMain.getLineId())); patrolResult.setMainId(String.valueOf(resultMain.getLineId()));
patrolResult.setDeviceId(deviceId); patrolResult.setDeviceId(deviceId);
@ -804,6 +802,11 @@ public class AnalyseResponseServiceImpl implements IAnalyseResponseService {
// 兼容算法结果传过来多个算法 // 兼容算法结果传过来多个算法
continue; continue;
} }
// 红外算法保留一位小数其他可读数算法增加读数单位
String resValue = resultAnalysisUtils.addUnit2Value(resultAnalysis.getResValue(), resultAnalysis.getAlgType(), patrolResult.getUnit());
resultAnalysis.setResValue(resValue);
resultAnalysisList.add(resultAnalysis); resultAnalysisList.add(resultAnalysis);
valueJoiner.add(resultAnalysis.getResValue()); valueJoiner.add(resultAnalysis.getResValue());
String pointStatus = resultAnalysis.getPointStatus(); String pointStatus = resultAnalysis.getPointStatus();
@ -902,7 +905,7 @@ public class AnalyseResponseServiceImpl implements IAnalyseResponseService {
// 处理正常结果以及兼容处理无机人表计gis_meter2纠偏correction的异常结果 // 处理正常结果以及兼容处理无机人表计gis_meter2纠偏correction的异常结果
if (resultAnalysisUtils.checkCode(analyseResPoint.getCode(), analyseResPoint.getDesc(), resultAnalysis) if (resultAnalysisUtils.checkCode(analyseResPoint.getCode(), analyseResPoint.getDesc(), resultAnalysis)
|| (AlgConstants.GIS_METER_2.equals(analyseResPoint.getType())) || (AlgConstants.GIS_METER_2.equals(analyseResPoint.getType()))
|| ("correction".equals(analyseResPoint.getType()) && Arrays.asList("2001", "2002", "2003").contains(analyseResPoint.getCode()) )) {
|| (AlgConstants.CORRECTION.equals(analyseResPoint.getType()) && Arrays.asList("2001", "2002", "2003").contains(analyseResPoint.getCode()) )) {
AlgValue algValue = selectAlgMap(objectId, analyseResPoint.getType()); AlgValue algValue = selectAlgMap(objectId, analyseResPoint.getType());
resultAnalysisUtils.parseAlg(analyseResPoint.getType(), algValue, value, analyseResPoint.getDesc(), resultAnalysis); resultAnalysisUtils.parseAlg(analyseResPoint.getType(), algValue, value, analyseResPoint.getDesc(), resultAnalysis);
// 合并辅助值字段 // 合并辅助值字段
@ -930,8 +933,9 @@ public class AnalyseResponseServiceImpl implements IAnalyseResponseService {
if (!patrolTaskStatusList.isEmpty()) { if (!patrolTaskStatusList.isEmpty()) {
patrolTaskStatus = patrolTaskStatusList.get(0); patrolTaskStatus = patrolTaskStatusList.get(0);
patrolTaskStatus.setTaskEstimatedTime(algorithmProgress); patrolTaskStatus.setTaskEstimatedTime(algorithmProgress);
if ("100.0".equals(algorithmProgress)) {
patrolTaskStatus.setEndTime(DateUtil.formatDateTime(new Date()));
BigDecimal algorithmProgressBD = BigDecimalUtil.toBigDecimal(algorithmProgress);
BigDecimal oneHundredBD = new BigDecimal(100);
if (algorithmProgressBD.compareTo(oneHundredBD) == 0) {
log.info(Color.GREEN + "DONE CALC_REMOTE_ALGORITHM_PROGRESS taskPatrolledId: {}, objectId: {}, curNumber: {}, totalNumer: {}, algorithmProgress: {}, db-taskProgress: {}" + Color.END, log.info(Color.GREEN + "DONE CALC_REMOTE_ALGORITHM_PROGRESS taskPatrolledId: {}, objectId: {}, curNumber: {}, totalNumer: {}, algorithmProgress: {}, db-taskProgress: {}" + Color.END,
taskPatrolledId, taskPatrolledId,
objectId, objectId,
@ -939,11 +943,11 @@ public class AnalyseResponseServiceImpl implements IAnalyseResponseService {
totalNumber, totalNumber,
algorithmProgress, algorithmProgress,
patrolTaskStatus.getTaskProgress()); patrolTaskStatus.getTaskProgress());
//patrolTaskStatus.setTaskProgress("100.0");
if("100.0".equals(patrolTaskStatus.getTaskProgress())) {
BigDecimal taskProgressBD = BigDecimalUtil.toBigDecimal(patrolTaskStatus.getTaskProgress());
if (taskProgressBD.compareTo(oneHundredBD) == 0) {
patrolTaskStatus.setTaskState(TaskStatus.DONE.getCode()); patrolTaskStatus.setTaskState(TaskStatus.DONE.getCode());
} }
patrolTaskStatusService.updatePatrolTaskStatus(patrolTaskStatus);
patrolTaskStatusService.updateTaskProgress(patrolTaskStatus.getLineId(), patrolTaskStatus.getTaskProgress(), patrolTaskStatus.getTaskEstimatedTime(), patrolTaskStatus.getTaskState());
} else { } else {
log.info(Color.GREEN + "RUNNING CALC_REMOTE_ALGORITHM_PROGRESS taskPatrolledId: {}, objectId: {}, curNumber: {}, totalNumer: {}, algorithmProgress: {}, status: {}" + Color.END, log.info(Color.GREEN + "RUNNING CALC_REMOTE_ALGORITHM_PROGRESS taskPatrolledId: {}, objectId: {}, curNumber: {}, totalNumer: {}, algorithmProgress: {}, status: {}" + Color.END,
taskPatrolledId, taskPatrolledId,
@ -955,7 +959,7 @@ public class AnalyseResponseServiceImpl implements IAnalyseResponseService {
if (TaskStatus.RUNNING.getCode().equals(patrolTaskStatus.getTaskState())) { if (TaskStatus.RUNNING.getCode().equals(patrolTaskStatus.getTaskState())) {
patrolTaskStatus.setTaskState(TaskStatus.RUNNING.getCode()); patrolTaskStatus.setTaskState(TaskStatus.RUNNING.getCode());
patrolTaskStatusService.updatePatrolTaskStatus(patrolTaskStatus);
patrolTaskStatusService.updateTaskProgress(patrolTaskStatus.getLineId(), patrolTaskStatus.getTaskProgress(), patrolTaskStatus.getTaskEstimatedTime(), patrolTaskStatus.getTaskState());
} }
} }
} }


+ 13
- 5
inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/service/impl/ResultAnalysisServiceImpl.java View File

@ -3,10 +3,14 @@ package com.inspect.analysis.service.impl;
import com.inspect.analysis.domain.AlgPatrolPoint; import com.inspect.analysis.domain.AlgPatrolPoint;
import com.inspect.analysis.domain.AnalyseSummaryAlarmModel; import com.inspect.analysis.domain.AnalyseSummaryAlarmModel;
import com.inspect.analysis.domain.ResultAnalysis; import com.inspect.analysis.domain.ResultAnalysis;
import com.inspect.analysis.domain.ResultAnalysisSummaryDTO;
import com.inspect.analysis.mapper.ResultAnalysisMapper; import com.inspect.analysis.mapper.ResultAnalysisMapper;
import com.inspect.analysis.service.IResultAnalysisService; import com.inspect.analysis.service.IResultAnalysisService;
import com.inspect.base.core.utils.StringUtils; import com.inspect.base.core.utils.StringUtils;
import com.inspect.partrolresult.domain.PatrolResult; import com.inspect.partrolresult.domain.PatrolResult;
import com.inspect.task.domain.PatrolData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -14,11 +18,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.inspect.task.domain.PatrolData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service @Service
@Slf4j @Slf4j
public class ResultAnalysisServiceImpl implements IResultAnalysisService { public class ResultAnalysisServiceImpl implements IResultAnalysisService {
@ -103,6 +102,14 @@ public class ResultAnalysisServiceImpl implements IResultAnalysisService {
this.resultAnalysisMapper.updateResultAnalysisByCondition(analysis); this.resultAnalysisMapper.updateResultAnalysisByCondition(analysis);
} }
@Override
public List<ResultAnalysisSummaryDTO> countResultAnalysisSummary(List<String> taskPatrolledIds) {
if (taskPatrolledIds.size() == 0) {
return null;
}
return resultAnalysisMapper.countResultAnalysisSummary(taskPatrolledIds);
}
public int deleteResultAnalysisByLineIds(Long[] lineIds) { public int deleteResultAnalysisByLineIds(Long[] lineIds) {
return this.resultAnalysisMapper.deleteResultAnalysisByLineIds(lineIds); return this.resultAnalysisMapper.deleteResultAnalysisByLineIds(lineIds);
} }
@ -115,6 +122,7 @@ public class ResultAnalysisServiceImpl implements IResultAnalysisService {
return this.resultAnalysisMapper.selectTaskAbnormalData(resultAnalysis); return this.resultAnalysisMapper.selectTaskAbnormalData(resultAnalysis);
} }
@Override
public Map<String, ResultAnalysis> selectTaskAbnormalDataBatch(List<String> taskPatrolledIds) { public Map<String, ResultAnalysis> selectTaskAbnormalDataBatch(List<String> taskPatrolledIds) {
if (taskPatrolledIds == null || taskPatrolledIds.isEmpty()) { if (taskPatrolledIds == null || taskPatrolledIds.isEmpty()) {
return new HashMap<>(); return new HashMap<>();


+ 69
- 70
inspect-main/inspect-main-task/src/main/java/com/inspect/analysis/utils/ResultAnalysisUtils.java View File

@ -1,5 +1,6 @@
package com.inspect.analysis.utils; package com.inspect.analysis.utils;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.inspect.analysis.constant.AnalyseConstants; import com.inspect.analysis.constant.AnalyseConstants;
@ -8,6 +9,8 @@ import com.inspect.analysis.domain.AnalyseResPoint;
import com.inspect.analysis.domain.ResultAnalysis; import com.inspect.analysis.domain.ResultAnalysis;
import com.inspect.base.core.constant.AlgConstants; import com.inspect.base.core.constant.AlgConstants;
import com.inspect.base.core.enums.PointStatusEnum; import com.inspect.base.core.enums.PointStatusEnum;
import com.inspect.base.core.enums.ResultTypeEnum;
import com.inspect.base.core.utils.BigDecimalUtil;
import com.inspect.base.core.utils.StringUtils; import com.inspect.base.core.utils.StringUtils;
import com.inspect.message.MessageUtils; import com.inspect.message.MessageUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -16,8 +19,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Slf4j @Slf4j
@Component @Component
@ -28,7 +33,8 @@ public class ResultAnalysisUtils {
/** /**
* 检查返回结果 * 检查返回结果
* code除了2000,其他值均为异常
* code: 2000-正确 2001-图像数据错误 2002-算法分析失败
* 图像数据错误是指未能获取到图像数据算法分析失败是指算法本身分析过程中出错
*/ */
public boolean checkCode(String code, String desc, ResultAnalysis resultAnalysis) { public boolean checkCode(String code, String desc, ResultAnalysis resultAnalysis) {
if (AnalyseConstants.ANALYSE_OK.equals(code)) { if (AnalyseConstants.ANALYSE_OK.equals(code)) {
@ -53,6 +59,9 @@ public class ResultAnalysisUtils {
resultAnalysis.setResultType("2"); resultAnalysis.setResultType("2");
resultAnalysis.setResStatus("0"); resultAnalysis.setResStatus("0");
resultAnalysis.setCreateTime(new Date()); resultAnalysis.setCreateTime(new Date());
if(!Arrays.asList(AlgConstants.CORRECTION, AlgConstants.GIS_METER_2).contains(resultAnalysis.getAlgType())) {
resultAnalysis.setResValue("");
}
return false; return false;
} }
@ -60,18 +69,13 @@ public class ResultAnalysisUtils {
* 解析算法结果 * 解析算法结果
* pointStatus点位状态: 点位状态 0-异常 1-正常 2-待人工确认 3-已撤销忽略 4-跟踪告警 5-确认告警 6-缺陷 * pointStatus点位状态: 点位状态 0-异常 1-正常 2-待人工确认 3-已撤销忽略 4-跟踪告警 5-确认告警 6-缺陷
* resultType分析结果: 0-缺陷 1-正常 2-异常 * resultType分析结果: 0-缺陷 1-正常 2-异常
* resStatus告警确认状态: 0-未确认 1-已确认 2-已撤销
* resStatus告警确认状态: 0-未确认 1-已确认 2-已撤销 3-需要纠偏 4-完成纠偏
*/ */
public void parseAlg(String algType, AlgValue algValue, String value, String defaultDesc, ResultAnalysis resultAnalysis) { public void parseAlg(String algType, AlgValue algValue, String value, String defaultDesc, ResultAnalysis resultAnalysis) {
log.info("PARSE_ALG algType: {}, algValue: {}, value: {}, defaultDesc: {}", algType, algValue, value, defaultDesc); log.info("PARSE_ALG algType: {}, algValue: {}, value: {}, defaultDesc: {}", algType, algValue, value, defaultDesc);
// 初筛红外 // 初筛红外
if ("1".equals(resultAnalysis.getFilter()) && algType != null &&
(algType.equals("infrared") ||
algType.equals("infra_1800") ||
algType.equals("infra_yu3") ||
algType.equals("infra_camera") ||
algType.equals("infra_camera_reverse"))) {
if ("1".equals(resultAnalysis.getFilter()) && AlgConstants.ALG_INFRARED_LIST.contains(algType)) {
// 绍兴初筛红外改成正常 // 绍兴初筛红外改成正常
resultAnalysis.setResultType("1"); resultAnalysis.setResultType("1");
resultAnalysis.setPointStatus("1"); resultAnalysis.setPointStatus("1");
@ -81,14 +85,14 @@ public class ResultAnalysisUtils {
return; return;
} }
if (value == null) {
if (value == null || value == "null") {
value = ""; value = "";
} }
final String correctionValue = value; final String correctionValue = value;
// 读取字符串中的整数或浮点数注意集合下只取第一个值有坑原值使用correctionValue // 读取字符串中的整数或浮点数注意集合下只取第一个值有坑原值使用correctionValue
value = algValue.formatValue(value); value = algValue.formatValue(value);
// 这个不知道为什么加上
// 初筛时不做算法值的具体解析
if ("1".equals(resultAnalysis.getFilter())) { if ("1".equals(resultAnalysis.getFilter())) {
algType = ""; algType = "";
} }
@ -206,47 +210,45 @@ public class ResultAnalysisUtils {
boolean hasDefect = false; boolean hasDefect = false;
boolean hasAbnormal = false; boolean hasAbnormal = false;
try { try {
ObjectMapper mapper = new ObjectMapper();
// 1. 解析 JSON // 1. 解析 JSON
List<String> originalList = mapper.readValue(correctionValue, new TypeReference<List<String>>() {
});
String[] values = JSON.parseArray(correctionValue, String.class).toArray(new String[0]);
// 2. 转换非空 "正常"空值 "读数失败"超限 "表计超限" // 2. 转换非空 "正常"空值 "读数失败"超限 "表计超限"
List<String> descList = new ArrayList<>(originalList.size());
for (String item : originalList) {
String[] descs = new String[values.length];
for (int i = 0; i < values.length; i++) {
String item = values[i];
if (StringUtils.isEmpty(item)) { if (StringUtils.isEmpty(item)) {
hasAbnormal = true; hasAbnormal = true;
descList.add("读数失败");
values[i] = "--";
descs[i] = "读数失败";
} else { } else {
if (algValue.isAlarm(item)) { if (algValue.isAlarm(item)) {
hasDefect = true; hasDefect = true;
descList.add("表计超限");
descs[i] = "表计超限";
} else { } else {
descList.add("正常");
descs[i] = "正常";
} }
} }
} }
String descStr = mapper.writeValueAsString(descList);
if (hasDefect) {
String valueStr = String.join(",", values);
String descStr = String.join(",", descs);
defaultDesc = descStr;
resultAnalysis.setResValue(valueStr);
// 无人机表计所有读数失败都应该是缺陷
if (hasDefect || hasAbnormal) {
resultAnalysis.setPointStatus(PointStatusEnum.DEFECT.getCode()); resultAnalysis.setPointStatus(PointStatusEnum.DEFECT.getCode());
resultAnalysis.setResStatus("0"); resultAnalysis.setResStatus("0");
resultAnalysis.setResultType("0"); resultAnalysis.setResultType("0");
defaultDesc = descStr;
} else { } else {
if (hasAbnormal) {
resultAnalysis.setPointStatus("0");
resultAnalysis.setResStatus("0");
resultAnalysis.setResultType("2");
defaultDesc = descStr;
} else {
resultAnalysis.setPointStatus("1");
resultAnalysis.setResStatus("0");
resultAnalysis.setResultType("1");
defaultDesc = messageUtils.get("正常");
}
resultAnalysis.setPointStatus("1");
resultAnalysis.setResStatus("0");
resultAnalysis.setResultType("1");
} }
} catch (Exception e) { } catch (Exception e) {
log.error("PARSE_ALG_GIS_METER_2_ERROR correctionValue: {}", correctionValue, e); log.error("PARSE_ALG_GIS_METER_2_ERROR correctionValue: {}", correctionValue, e);
defaultDesc = "解析异常"; defaultDesc = "解析异常";
resultAnalysis.setPointStatus(PointStatusEnum.DEFECT.getCode());
resultAnalysis.setResStatus("0");
resultAnalysis.setResultType("0");
} }
} else if (algType.equals("sound")) { } else if (algType.equals("sound")) {
if (value.equals("1")) { if (value.equals("1")) {
@ -262,22 +264,7 @@ public class ResultAnalysisUtils {
} }
} else if ( } else if (
AlgConstants.ALG_INFRARED_LIST.contains(algType) || AlgConstants.ALG_INFRARED_LIST.contains(algType) ||
algType.equals("xb")) {
// String device = "";
// if (algType.equals("infrared")) {
// device = messageUtils.get("红外");
// } else if (algType.equals("infra_1800")) {
// log.info("红外1800===============");
// device = messageUtils.get("红外1800");
// } else if (algType.equals("infra_yu3")) {
// device = messageUtils.get("无人机红外");
// } else if (algType.equals("infra_camera")) {
// device = messageUtils.get("摄像头红外");
// } else if (algType.equals("infra_camera_reverse")) {
// device = messageUtils.get("摄像头红外灰度反算");
// } else if (algType.equals("xb")) {
// device = messageUtils.get("形变");
// }
algType.equals("xb")) {
if (!algValue.isAlarm(value)) { if (!algValue.isAlarm(value)) {
log.info("infrared no alarm value: {}, algValue: {}", value, algValue); log.info("infrared no alarm value: {}, algValue: {}", value, algValue);
resultAnalysis.setResStatus("1"); resultAnalysis.setResStatus("1");
@ -294,10 +281,8 @@ public class ResultAnalysisUtils {
//defaultDesc = device + messageUtils.get("告警"); //defaultDesc = device + messageUtils.get("告警");
defaultDesc = messageUtils.get("温度异常告警"); defaultDesc = messageUtils.get("温度异常告警");
} }
// 红外类型的算法读数保留一位小数
resultAnalysis.setResValue(algValue.toOneDecimal(value));
if (messageUtils.get("分析失败").equals(defaultDesc)) { if (messageUtils.get("分析失败").equals(defaultDesc)) {
defaultDesc = "-";
defaultDesc = "--";
} }
} else if (algType.equals("isolator")) { } else if (algType.equals("isolator")) {
log.info("ALG_TYPE isolator value: {}", value); log.info("ALG_TYPE isolator value: {}", value);
@ -322,6 +307,7 @@ public class ResultAnalysisUtils {
defaultDesc = "未检测到刀闸"; defaultDesc = "未检测到刀闸";
} }
} else if (algType.equals("correction")) { } else if (algType.equals("correction")) {
log.info("correction correction, {}", resultAnalysis.getResValue());
log.info("parseAlg algType correction 2000 resCode: {}, correctionValue: {}", resultAnalysis.getResCode(), correctionValue); log.info("parseAlg algType correction 2000 resCode: {}, correctionValue: {}", resultAnalysis.getResCode(), correctionValue);
if ("2000".equals(resultAnalysis.getResCode())) { if ("2000".equals(resultAnalysis.getResCode())) {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
@ -351,16 +337,15 @@ public class ResultAnalysisUtils {
resultAnalysis.setResultType("1"); resultAnalysis.setResultType("1");
resultAnalysis.setResStatus("2"); resultAnalysis.setResStatus("2");
resultAnalysis.setResValue(""); resultAnalysis.setResValue("");
defaultDesc = messageUtils.get("正常");
defaultDesc = messageUtils.get("无需纠偏");
} else { } else {
log.info("2000 correction need value0: {}, value1: {}, value2: {}, value3: {}", value0, value1, value2, value3); log.info("2000 correction need value0: {}, value1: {}, value2: {}, value3: {}", value0, value1, value2, value3);
resultAnalysis.setPointStatus("1"); resultAnalysis.setPointStatus("1");
resultAnalysis.setResultType("1"); resultAnalysis.setResultType("1");
//resultAnalysis.setResStatus("3");
//defaultDesc = "请进行纠偏"; //defaultDesc = "请进行纠偏";
resultAnalysis.setResStatus("2"); resultAnalysis.setResStatus("2");
resultAnalysis.setResValue(""); resultAnalysis.setResValue("");
defaultDesc = "正常";
defaultDesc = "无需纠偏";
} }
} else { } else {
log.info("parseAlg algType correction correctionValue abnormal"); log.info("parseAlg algType correction correctionValue abnormal");
@ -430,6 +415,9 @@ public class ResultAnalysisUtils {
defaultDesc = messageUtils.get("未知异常"); defaultDesc = messageUtils.get("未知异常");
resultAnalysis.setResDesc(defaultDesc); resultAnalysis.setResDesc(defaultDesc);
} }
// 纠偏分析结果均为正常
resultAnalysis.setResultType(ResultTypeEnum.NORMAL.getCode());
resultAnalysis.setPointStatus(PointStatusEnum.NORMAL.getCode());
} else { } else {
log.info("parseAlg algType: {}", algType); log.info("parseAlg algType: {}", algType);
if (value.equals("0")) { if (value.equals("0")) {
@ -446,6 +434,7 @@ public class ResultAnalysisUtils {
} }
if (StringUtils.isNotEmpty(defaultDesc) && defaultDesc.contains(messageUtils.get("分析失败"))) { if (StringUtils.isNotEmpty(defaultDesc) && defaultDesc.contains(messageUtils.get("分析失败"))) {
resultAnalysis.setResultType("2"); resultAnalysis.setResultType("2");
resultAnalysis.setPointStatus(PointStatusEnum.ABNORMAL.getCode());
} }
} }
resultAnalysis.setDescription(defaultDesc); resultAnalysis.setDescription(defaultDesc);
@ -455,6 +444,7 @@ public class ResultAnalysisUtils {
/** /**
* 将分析结果的辅助值进行合并展示 * 将分析结果的辅助值进行合并展示
*
* @param analyseResPoint * @param analyseResPoint
* @param resultAnalysis * @param resultAnalysis
*/ */
@ -463,7 +453,7 @@ public class ResultAnalysisUtils {
if (StringUtils.isNotEmpty(value2)) { if (StringUtils.isNotEmpty(value2)) {
log.info("mergeValue analyseResPoint value2: {}", value2); log.info("mergeValue analyseResPoint value2: {}", value2);
String value = analyseResPoint.getValue(); String value = analyseResPoint.getValue();
if(!NumberUtils.isCreatable(value2)) {
if (!NumberUtils.isCreatable(value2)) {
value2 = "null"; value2 = "null";
} }
String val = String.join(",", value, value2); String val = String.join(",", value, value2);
@ -471,21 +461,30 @@ public class ResultAnalysisUtils {
} }
} }
public static void main(String[] args) {
String value = "[[121,108],[121,108]]";
ObjectMapper mapper = new ObjectMapper();
List<List<Double>> list;
try {
list = mapper.readValue(value, new TypeReference<List<List<Double>>>() {
});
System.out.println("parseAlg algType correction value: " + list);
} catch (Exception e) {
System.out.println("parseAlg algType correction value exception");
list = new ArrayList<>();
}
if(list.size() == 2 && list.get(0).size() == 2 && list.get(1).size() == 2) {
System.out.println("parseAlg algType correction value");
/**
* 添加单位
*
* @param resValue 读数
* @param algType 算法类型
* @param unit 单位
* @return
*/
public String addUnit2Value(String resValue, String algType, String unit) {
if (StringUtils.isNotEmpty(resValue) && StringUtils.isNotEmpty(unit) && AlgConstants.READABLE_ALG_LIST.contains(algType)) {
log.info("addUnit2Value resValue: {}, algType: {}, unit: {}", resValue, algType, unit);
String[] valueArr = resValue.split(",");
String values = Arrays.stream(valueArr).map(val -> {
boolean isNumber = val.matches("^-?\\d+(\\.\\d+)?$");
if (isNumber) {
if (AlgConstants.ALG_INFRARED_LIST.contains(algType)) {
return BigDecimalUtil.toOneDecimal(val, 1) + unit;
}
return val + unit;
}
return val;
}).collect(Collectors.joining(","));
return values;
} }
return resValue;
} }
} }

+ 3
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/fegin/FeignBasedataAreaService.java View File

@ -11,6 +11,9 @@ public interface FeignBasedataAreaService {
@GetMapping({"/area/selectAreaNameSForTaskByAreaIdS"}) @GetMapping({"/area/selectAreaNameSForTaskByAreaIdS"})
AjaxResult selectAreaNameSForTaskByAreaIdS(@RequestParam("baseDataArea") JSONObject var1); AjaxResult selectAreaNameSForTaskByAreaIdS(@RequestParam("baseDataArea") JSONObject var1);
@GetMapping({"/area/selectAreaNameSForTaskByAreaIdSRelation"})
AjaxResult selectAreaNameSForTaskByAreaIdSRelation(@RequestParam("baseDataArea") JSONObject var1);
@GetMapping({"/area/list"}) @GetMapping({"/area/list"})
AjaxResult list(@RequestParam("baseDataArea") JSONObject var1); AjaxResult list(@RequestParam("baseDataArea") JSONObject var1);


+ 6
- 3
inspect-main/inspect-main-task/src/main/java/com/inspect/insreport/controller/InspectionReportController.java View File

@ -260,18 +260,21 @@ public class InspectionReportController extends BaseController {
if (StringUtils.isEmpty(reportData.getTaskPatrolledId())) { if (StringUtils.isEmpty(reportData.getTaskPatrolledId())) {
reportData.setTaskPatrolledId(inspectionReport.getTaskPatrolledId()); reportData.setTaskPatrolledId(inspectionReport.getTaskPatrolledId());
} }
if (StringUtils.isEmpty(reportData.getTaskResultId())) {
reportData.setTaskResultId(inspectionReport.getTaskResultId());
}
} }
// inspectionReport.setInfo(inspectionReportDataList); // inspectionReport.setInfo(inspectionReportDataList);
Map<String, List<Map<String, List<InspectionReportData>>>> resultTaskInfoMap = new HashMap<>(); Map<String, List<Map<String, List<InspectionReportData>>>> resultTaskInfoMap = new HashMap<>();
// pointStatus 分组再按 taskPatrolledId_taskName 分组
// key: pointStatusvalue: {taskPatrolledId_taskName -> List<InspectionReportData>}
// pointStatus 分组再按 taskResultId_taskName 分组
// key: pointStatusvalue: {taskResultId_taskName -> List<InspectionReportData>}
Map<String, Map<String, List<InspectionReportData>>> detailGrouped = Map<String, Map<String, List<InspectionReportData>>> detailGrouped =
inspectionReportDataList.stream() inspectionReportDataList.stream()
.collect(Collectors.groupingBy( .collect(Collectors.groupingBy(
item -> item.getPointStatus() == null ? "unknown" : item.getPointStatus(), item -> item.getPointStatus() == null ? "unknown" : item.getPointStatus(),
Collectors.groupingBy(item -> item.getTaskPatrolledId() + "_" + item.getTaskName())
Collectors.groupingBy(item -> item.getTaskResultId() + "_" + item.getTaskName())
)); ));
// 将分组结果转换为所需的格式 // 将分组结果转换为所需的格式
for (Map.Entry<String, Map<String, List<InspectionReportData>>> stringMapEntry : detailGrouped.entrySet()) { for (Map.Entry<String, Map<String, List<InspectionReportData>>> stringMapEntry : detailGrouped.entrySet()) {


+ 3
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/insreportdata/domain/InspectionReportData.java View File

@ -74,6 +74,8 @@ public class InspectionReportData extends BaseEntity {
private String taskPatrolledId; private String taskPatrolledId;
private String taskResultId;
@Override @Override
public boolean equals(Object object) { public boolean equals(Object object) {
if (this == object) return true; if (this == object) return true;
@ -107,6 +109,7 @@ public class InspectionReportData extends BaseEntity {
", algName='" + algName + '\'' + ", algName='" + algName + '\'' +
", taskName='" + taskName + '\'' + ", taskName='" + taskName + '\'' +
", taskPatrolledId='" + taskPatrolledId + '\'' + ", taskPatrolledId='" + taskPatrolledId + '\'' +
", taskResultId='" + taskResultId + '\'' +
'}'; '}';
} }
} }

+ 23
- 14
inspect-main/inspect-main-task/src/main/java/com/inspect/maintain/controller/MaintainRegionController.java View File

@ -153,20 +153,7 @@ public class MaintainRegionController extends BaseController {
) )
@PostMapping({"/remove/{lineIds}"}) @PostMapping({"/remove/{lineIds}"})
public AjaxResult remove(@PathVariable Long[] lineIds) { public AjaxResult remove(@PathVariable Long[] lineIds) {
maintainRegionService.deleteMaintainRegionByLineIds(lineIds);
(new Thread(() -> {
logger.info("[MAINTAIN] remove maintain area to upper start");
try {
Thread.sleep(2000L);
syncMaintainRegionToUpperSystem(new MaintainRegion());
} catch (InterruptedException e) {
e.printStackTrace();
}
logger.info("[MAINTAIN] remove maintain area to upper end");
})).start();
return toAjax(1);
return toAjax(maintainRegionService.deleteMaintainRegionByLineIds(lineIds));
} }
@PostMapping({"/add"}) @PostMapping({"/add"})
@ -275,6 +262,11 @@ public class MaintainRegionController extends BaseController {
return toAjax(1); return toAjax(1);
} }
/**
* 下发指令同步检修区域至设备
* @param maintainRegion
* @return
*/
@GetMapping({"/issue"}) @GetMapping({"/issue"})
public AjaxResult issueList(MaintainRegion maintainRegion) { public AjaxResult issueList(MaintainRegion maintainRegion) {
if (StringUtils.isNotEmpty(maintainRegion.getIds())) { if (StringUtils.isNotEmpty(maintainRegion.getIds())) {
@ -645,4 +637,21 @@ public class MaintainRegionController extends BaseController {
logger.info("[MAINTAIN] SYNC maintain region to upper system jsonString: {}", jsonString); logger.info("[MAINTAIN] SYNC maintain region to upper system jsonString: {}", jsonString);
syncDataToUpstreamService.postMessage(jsonString); syncDataToUpstreamService.postMessage(jsonString);
} }
@PostMapping("/save")
public AjaxResult save(@RequestBody MaintainRegion maintainRegion) {
if (!maintainRegionService.checkConfigCodeUnique(maintainRegion.getConfigCode())) {
return error("新增检修区域'" + maintainRegion.getConfigCode() + "'失败,检修区域编码已存在");
}
if (StringUtils.isEmpty(maintainRegion.getEnable())) {
maintainRegion.setEnable("1");
}
if (StringUtils.isEmpty(maintainRegion.getDeviceLevel())) {
maintainRegion.setDeviceLevel("0");
}
return toAjax(maintainRegionService.insertMaintainRegionWithConfigCode(maintainRegion));
}
} }

+ 4
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/maintain/domain/PatrolMaintainModuleXml.java View File

@ -6,6 +6,7 @@ import lombok.Setter;
import java.util.List; import java.util.List;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@Setter @Setter
@ -15,6 +16,9 @@ import javax.xml.bind.annotation.XmlRootElement;
) )
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class PatrolMaintainModuleXml { public class PatrolMaintainModuleXml {
@XmlElement(
name = "Item"
)
List<MaintainAreaXML> item; List<MaintainAreaXML> item;
} }

+ 2
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/maintain/mapper/MaintainRegionMapper.java View File

@ -18,4 +18,6 @@ public interface MaintainRegionMapper {
int deleteMaintainRegionByLineId(Long id); int deleteMaintainRegionByLineId(Long id);
int deleteMaintainRegionByLineIds(Long[] ids); int deleteMaintainRegionByLineIds(Long[] ids);
MaintainRegion checkConfigCodeUnique(String configCode);
} }

+ 4
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/maintain/service/IMaintainRegionService.java View File

@ -16,4 +16,8 @@ public interface IMaintainRegionService {
int deleteMaintainRegionByLineIds(Long[] lineIds); int deleteMaintainRegionByLineIds(Long[] lineIds);
int deleteMaintainRegionByLineId(Long lineId); int deleteMaintainRegionByLineId(Long lineId);
boolean checkConfigCodeUnique(String configCode);
int insertMaintainRegionWithConfigCode(MaintainRegion maintainRegion);
} }

+ 26
- 3
inspect-main/inspect-main-task/src/main/java/com/inspect/maintain/service/impl/MaintainRegionServiceImpl.java View File

@ -3,13 +3,12 @@ package com.inspect.maintain.service.impl;
import com.inspect.base.core.domain.maintain.MaintainRegion; import com.inspect.base.core.domain.maintain.MaintainRegion;
import com.inspect.maintain.mapper.MaintainRegionMapper; import com.inspect.maintain.mapper.MaintainRegionMapper;
import com.inspect.maintain.service.IMaintainRegionService; import com.inspect.maintain.service.IMaintainRegionService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service @Service
public class MaintainRegionServiceImpl implements IMaintainRegionService { public class MaintainRegionServiceImpl implements IMaintainRegionService {
private final MaintainRegionMapper maintainRegionMapper; private final MaintainRegionMapper maintainRegionMapper;
@ -42,4 +41,28 @@ public class MaintainRegionServiceImpl implements IMaintainRegionService {
public int deleteMaintainRegionByLineId(Long lineId) { public int deleteMaintainRegionByLineId(Long lineId) {
return this.maintainRegionMapper.deleteMaintainRegionByLineId(lineId); return this.maintainRegionMapper.deleteMaintainRegionByLineId(lineId);
} }
@Override
public boolean checkConfigCodeUnique(String configCode) {
MaintainRegion maintainRegion = this.maintainRegionMapper.checkConfigCodeUnique(configCode);
if (maintainRegion == null) {
return true;
}
return false;
}
@Override
@Transactional(rollbackFor = Exception.class)
public int insertMaintainRegionWithConfigCode(MaintainRegion maintainRegion) {
maintainRegion.setCreateTime(new Date());
int rows = this.maintainRegionMapper.insertMaintainRegion(maintainRegion);
if (rows > 0) {
Long lineId = maintainRegion.getLineId();
maintainRegion.setConfigCode(String.valueOf(lineId));
maintainRegionMapper.updateMaintainRegion(maintainRegion);
}
return rows;
}
} }

+ 98
- 155
inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/controller/PatrolResultController.java View File

@ -10,10 +10,11 @@ import com.inspect.base.core.constant.AlgConstants;
import com.inspect.base.core.constant.Color; import com.inspect.base.core.constant.Color;
import com.inspect.base.core.constant.RedisConst; import com.inspect.base.core.constant.RedisConst;
import com.inspect.base.core.domain.DataMsg; import com.inspect.base.core.domain.DataMsg;
import com.inspect.base.core.domain.maintain.MaintainRegion;
import com.inspect.base.core.enums.StaEnum; import com.inspect.base.core.enums.StaEnum;
import com.inspect.base.core.enums.TaskStatus; import com.inspect.base.core.enums.TaskStatus;
import com.inspect.base.core.enums.TaskType;
import com.inspect.base.core.exception.ServiceException; import com.inspect.base.core.exception.ServiceException;
import com.inspect.base.core.service.SyncDataToUpstreamService;
import com.inspect.base.core.sftp.SftpClient; import com.inspect.base.core.sftp.SftpClient;
import com.inspect.base.core.sftp.SftpUploadEntity; import com.inspect.base.core.sftp.SftpUploadEntity;
import com.inspect.base.core.utils.DateUtils; import com.inspect.base.core.utils.DateUtils;
@ -26,21 +27,19 @@ import com.inspect.base.core.utils.xml.GenXmlByBean;
import com.inspect.base.core.web.controller.BaseController; import com.inspect.base.core.web.controller.BaseController;
import com.inspect.base.core.web.domain.AjaxResult; import com.inspect.base.core.web.domain.AjaxResult;
import com.inspect.base.core.web.page.TableDataInfo; import com.inspect.base.core.web.page.TableDataInfo;
import com.inspect.base.redis.service.RedisService;
import com.inspect.common.log.annotation.Log; import com.inspect.common.log.annotation.Log;
import com.inspect.common.log.enums.BizType; import com.inspect.common.log.enums.BizType;
import com.inspect.base.redis.service.RedisService;
import com.inspect.fegin.FeignMinioService; import com.inspect.fegin.FeignMinioService;
import com.inspect.fegin.MultipartFileUtils; import com.inspect.fegin.MultipartFileUtils;
import com.inspect.fegin.UploadResponse; import com.inspect.fegin.UploadResponse;
import com.inspect.infrared.InfraredImageParser; import com.inspect.infrared.InfraredImageParser;
import com.inspect.infrared.InfraredRequestParam; import com.inspect.infrared.InfraredRequestParam;
import com.inspect.infrared.InfraredResponse; import com.inspect.infrared.InfraredResponse;
import com.inspect.base.core.domain.maintain.MaintainRegion;
import com.inspect.maintain.domain.MaintainAreaXML; import com.inspect.maintain.domain.MaintainAreaXML;
import com.inspect.maintain.domain.PatrolMaintainModuleXml; import com.inspect.maintain.domain.PatrolMaintainModuleXml;
import com.inspect.maintain.service.IMaintainRegionService; import com.inspect.maintain.service.IMaintainRegionService;
import com.inspect.message.MessageUtils; import com.inspect.message.MessageUtils;
import com.inspect.mqtt.services.Warn.IUploadServer;
import com.inspect.partrolresult.client.BaseDataClient; import com.inspect.partrolresult.client.BaseDataClient;
import com.inspect.partrolresult.client.WebsocketService; import com.inspect.partrolresult.client.WebsocketService;
import com.inspect.partrolresult.domain.*; import com.inspect.partrolresult.domain.*;
@ -48,7 +47,6 @@ import com.inspect.partrolresult.mapper.DeviceStateMapper;
import com.inspect.partrolresult.mapper.PatrolResultMapper; import com.inspect.partrolresult.mapper.PatrolResultMapper;
import com.inspect.partrolresult.service.IAnalyseRequestService; import com.inspect.partrolresult.service.IAnalyseRequestService;
import com.inspect.partrolresult.service.IPatrolResultService; import com.inspect.partrolresult.service.IPatrolResultService;
import com.inspect.partrolresult.util.ImageUtil;
import com.inspect.partrolresultAux.domain.PatrolResultAux; import com.inspect.partrolresultAux.domain.PatrolResultAux;
import com.inspect.partrolresultAux.service.IPatrolResultAuxService; import com.inspect.partrolresultAux.service.IPatrolResultAuxService;
import com.inspect.resultmain.domain.PatrolTaskResultMain; import com.inspect.resultmain.domain.PatrolTaskResultMain;
@ -65,7 +63,16 @@ import com.inspect.taskftp.domain.PatrolTaskFtp;
import com.inspect.taskftp.service.IPatrolTaskFtpService; import com.inspect.taskftp.service.IPatrolTaskFtpService;
import com.inspect.taskstatus.domain.PatrolTaskStatus; import com.inspect.taskstatus.domain.PatrolTaskStatus;
import com.inspect.taskstatus.service.IPatrolTaskStatusService; import com.inspect.taskstatus.service.IPatrolTaskStatusService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -75,41 +82,20 @@ import java.net.URL;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.*;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
@RestController @RestController
@RequestMapping({"/partrolresult"}) @RequestMapping({"/partrolresult"})
public class PatrolResultController extends BaseController { public class PatrolResultController extends BaseController {
private static final ExecutorService executor = Executors.newFixedThreadPool(100); private static final ExecutorService executor = Executors.newFixedThreadPool(100);
@Resource
DeviceStateMapper deviceStateMapper;
@Resource
ResultStatistics resultStatistics;
@Value("${sftp.ip}") @Value("${sftp.ip}")
private String ip; private String ip;
@Value("${sftp.port}") @Value("${sftp.port}")
@ -120,7 +106,6 @@ public class PatrolResultController extends BaseController {
private String password; private String password;
@Value("${INTRANET_FTP_VIEW_ADDRESS}") @Value("${INTRANET_FTP_VIEW_ADDRESS}")
private String intranetFtpAddress; private String intranetFtpAddress;
@Resource @Resource
private IPatrolResultService patrolResultService; private IPatrolResultService patrolResultService;
@Resource @Resource
@ -133,14 +118,8 @@ public class PatrolResultController extends BaseController {
private IPatrolTaskStatusService patrolTaskStatusService; private IPatrolTaskStatusService patrolTaskStatusService;
@Resource @Resource
private IPatrolTaskStatusService iPatrolTaskStatusService; private IPatrolTaskStatusService iPatrolTaskStatusService;
@Resource @Resource
private IResultAnalysisService resultAnalysisService; private IResultAnalysisService resultAnalysisService;
@Resource
SyncDataToUpstreamService syncDataToUpstreamService;
@Resource
IUploadServer iUploadServer;
@Resource @Resource
private IPatrolTaskResultMainService iPatrolTaskResultMainService; private IPatrolTaskResultMainService iPatrolTaskResultMainService;
@Resource @Resource
@ -152,16 +131,11 @@ public class PatrolResultController extends BaseController {
@Resource @Resource
private SftpClient sftpClient; private SftpClient sftpClient;
@Resource @Resource
DeviceStateMapper deviceStateMapper;
@Resource
private IPatrolTaskResultMainService patrolTaskResultMainService; private IPatrolTaskResultMainService patrolTaskResultMainService;
@Resource @Resource
private IMaintainRegionService maintainRegionService; private IMaintainRegionService maintainRegionService;
@Resource @Resource
private BaseDataClient baseDataClient; private BaseDataClient baseDataClient;
@Resource
ResultStatistics resultStatistics;
@Resource @Resource
private PatrolResultMapper patrolResultMapper; private PatrolResultMapper patrolResultMapper;
@ -693,7 +667,6 @@ public class PatrolResultController extends BaseController {
} }
private void remoteAnalysisServiceStart(final String ANALYSIS_URL, final String params) { private void remoteAnalysisServiceStart(final String ANALYSIS_URL, final String params) {
logger.info("[ALG] CALL ALG BIG MODEL, URL: {}, PARAM: {}", ANALYSIS_URL, params); logger.info("[ALG] CALL ALG BIG MODEL, URL: {}, PARAM: {}", ANALYSIS_URL, params);
executor.submit(() -> { executor.submit(() -> {
@ -719,6 +692,7 @@ public class PatrolResultController extends BaseController {
String ids = ""; String ids = "";
for (PatrolResult patrolResult : patrolResultList) { for (PatrolResult patrolResult : patrolResultList) {
PatrolTask task = patrolTaskService.selectPatrolTaskByTaskId(Long.valueOf(patrolResult.getTaskCode()));
logger.info("callRemoteAlgorithm taskPatrolledId: {}, patrolResult: {}", patrolResult.getTaskPatrolledId(), patrolResult); logger.info("callRemoteAlgorithm taskPatrolledId: {}, patrolResult: {}", patrolResult.getTaskPatrolledId(), patrolResult);
List<AnalyseReqItem> filterList = new ArrayList<>(); //初筛 List<AnalyseReqItem> filterList = new ArrayList<>(); //初筛
List<AnalyseReqItem> bigModelList = new ArrayList<>(); //大模型 List<AnalyseReqItem> bigModelList = new ArrayList<>(); //大模型
@ -728,32 +702,13 @@ public class PatrolResultController extends BaseController {
AnalyseReqItem analyseReqItem = new AnalyseReqItem(); AnalyseReqItem analyseReqItem = new AnalyseReqItem();
analyseReqItem.setObjectId(patrolResult.getDeviceId()); analyseReqItem.setObjectId(patrolResult.getDeviceId());
//根据basedata_patrolpoint中的patrol_point_id(对应patrol_result表中的device_id)查询该预置位配置的算法列表
Map<String, String> algSubtypeIdMap = patrolResultService.selectAlgorithmType(patrolResult.getDeviceId());
List<String> algSubtypeIdList = new ArrayList<>();
logger.info("callRemoteAlgorithm algorithmTypeMap: {}", algSubtypeIdMap);
if (algSubtypeIdMap != null) {
String subIdStr = algSubtypeIdMap.get("alg_subtype_ids");
if (subIdStr.contains(StringUtils.COMMA)) {
String[] subIds = subIdStr.split(StringUtils.COMMA);
for (String subId : subIds) {
if (StringUtils.isNotEmpty(subId)) {
algSubtypeIdList.add(subId);
}
}
} else {
algSubtypeIdList.add(subIdStr);
}
}
PatrolResult patrolResultTemp = new PatrolResult();
if (!algSubtypeIdList.isEmpty()) {
patrolResultTemp.setAlgId(algSubtypeIdList);
}
List<AlgInfo> algInfoList = new ArrayList<>();
if (patrolResultTemp.getAlgId() != null && !patrolResultTemp.getAlgId().isEmpty()) {
algInfoList = patrolResultService.selectAlgInfo(patrolResultTemp);
List<AlgInfo> algInfoList;
if (StringUtils.isNotEmpty(task.getSpecifiedAlg())) {
// 任务指定算法类型获取指定算法类型的对象
algInfoList = patrolResultService.selectAlgInfoByCode(task.getSpecifiedAlg());
} else {
// 根据basedata_patrolpoint中的patrol_point_id(对应patrol_result表中的device_id)查询该预置位配置的算法列表
algInfoList = patrolResultService.selectPointAlgInfo(patrolResult.getDeviceId());
} }
logger.info("callRemoteAlgorithm algInfoList: {}", algInfoList); logger.info("callRemoteAlgorithm algInfoList: {}", algInfoList);
@ -948,8 +903,6 @@ public class PatrolResultController extends BaseController {
logger.info(Color.CYAN + "callRemoteAlgorithm filter size: {}, filterList: {}" + Color.END, filterList.size(), filterList); logger.info(Color.CYAN + "callRemoteAlgorithm filter size: {}, filterList: {}" + Color.END, filterList.size(), filterList);
logger.info(Color.CYAN + "callRemoteAlgorithm bigModel size: {}, bigModelList: {}" + Color.END, bigModelList.size(), bigModelList); logger.info(Color.CYAN + "callRemoteAlgorithm bigModel size: {}, bigModelList: {}" + Color.END, bigModelList.size(), bigModelList);
// 查询任务指定的分析主机厂商
PatrolTask task = patrolTaskService.selectPatrolTaskByTaskId(Long.valueOf(patrolResult.getTaskCode()));
String drafter = task.getDrafter(); String drafter = task.getDrafter();
//qinyl 初筛逻辑处理 //qinyl 初筛逻辑处理
if (!filterList.isEmpty()) { if (!filterList.isEmpty()) {
@ -1143,7 +1096,7 @@ public class PatrolResultController extends BaseController {
} catch (Exception e) { } catch (Exception e) {
logger.error("error", e); logger.error("error", e);
} }
PatrolTask patrolTaskDb = patrolTaskListOfDb.get(0);
if (StringUtils.isNotEmpty(patrolTaskStatusItem.getTaskPatrolledId())) { if (StringUtils.isNotEmpty(patrolTaskStatusItem.getTaskPatrolledId())) {
String str = ""; String str = "";
@ -1166,21 +1119,13 @@ public class PatrolResultController extends BaseController {
if (!patrolTaskStatusList.isEmpty()) { if (!patrolTaskStatusList.isEmpty()) {
PatrolTaskStatus patrolTaskStatusOfDb = patrolTaskStatusList.get(0); PatrolTaskStatus patrolTaskStatusOfDb = patrolTaskStatusList.get(0);
// 除了db非完成或终止或暂停状态当db状态与上报状态不一致时更新db状态 // 除了db非完成或终止或暂停状态当db状态与上报状态不一致时更新db状态
// sendCode.isEmpty为摄像机
if (!Arrays.asList(TaskStatus.DONE.getCode(), TaskStatus.HALTED.getCode()).contains(patrolTaskStatusOfDb.getTaskState()) if (!Arrays.asList(TaskStatus.DONE.getCode(), TaskStatus.HALTED.getCode()).contains(patrolTaskStatusOfDb.getTaskState())
&& !patrolTaskStatusItem.getTaskState().equals(TaskStatus.DONE.getCode())
&& !patrolTaskStatusOfDb.getTaskState().equals(patrolTaskStatusItem.getTaskState())
&& !sendCode.isEmpty()
&& !Arrays.asList(TaskStatus.DONE.getCode(), patrolTaskStatusOfDb.getTaskState()).contains(patrolTaskStatusItem.getTaskState())
&& !sendCode.equals("摄像头")
) { ) {
logger.info("GET_INFO_41 UPDATE TASK_STATE old: {} TO new: {}", patrolTaskStatusOfDb.getTaskState(), patrolTaskStatusItem.getTaskState()); logger.info("GET_INFO_41 UPDATE TASK_STATE old: {} TO new: {}", patrolTaskStatusOfDb.getTaskState(), patrolTaskStatusItem.getTaskState());
patrolTaskStatusOfDb.setTaskState(patrolTaskStatusItem.getTaskState()); patrolTaskStatusOfDb.setTaskState(patrolTaskStatusItem.getTaskState());
// 如果上报状态为终止或超期限制状态时需更新终止时间
if(patrolTaskStatusItem.getTaskState().equals(TaskStatus.HALTED.getCode())|| patrolTaskStatusItem.getTaskState().equals(TaskStatus.EXPIRED.getCode())) {
String endTime = DateUtils.parseDateToStr(DateUtils.yyyyMMddHHmmss2, new Date());
patrolTaskStatusItem.setEndTime(endTime);
patrolTaskStatusOfDb.setEndTime(endTime);
}
iPatrolTaskStatusService.updatePatrolTaskStatusOfTaskState(patrolTaskStatusOfDb);
iPatrolTaskStatusService.updateTaskProgress(patrolTaskStatusOfDb.getLineId(), patrolTaskStatusOfDb.getTaskProgress(), null, patrolTaskStatusOfDb.getTaskState());
} }
double runProgress = 0.0; double runProgress = 0.0;
double dbProgress = 0.0; double dbProgress = 0.0;
@ -1214,9 +1159,6 @@ public class PatrolResultController extends BaseController {
calProgressInDb); calProgressInDb);
if (runProgress > dbProgress) { if (runProgress > dbProgress) {
patrolTaskStatusItem.setLineId(patrolTaskStatusOfDb.getLineId()); patrolTaskStatusItem.setLineId(patrolTaskStatusOfDb.getLineId());
if (patrolTaskStatusItem.getTaskName().contains("联合") && !patrolTaskStatusItem.getTaskName().startsWith(sendCode)) {
patrolTaskStatusItem.setTaskName(sendCode + "-" + patrolTaskStatusItem.getTaskName());
}
logger.info(Color.CYAN + "updating patrol_task_status taskPatrolledId: {}, progress: {}, taskState: {}" + Color.END, logger.info(Color.CYAN + "updating patrol_task_status taskPatrolledId: {}, progress: {}, taskState: {}" + Color.END,
patrolTaskStatusItem.getTaskPatrolledId(), patrolTaskStatusItem.getTaskPatrolledId(),
runProgress, runProgress,
@ -1240,14 +1182,12 @@ public class PatrolResultController extends BaseController {
RedisConst.TASK_CURRENT_CODE + patrolTaskStatusItem.getTaskCode()); RedisConst.TASK_CURRENT_CODE + patrolTaskStatusItem.getTaskCode());
PatrolTaskStatus taskStatus = statusList.get(0); PatrolTaskStatus taskStatus = statusList.get(0);
taskStatus.setTaskProgress(String.valueOf(runProgress)); taskStatus.setTaskProgress(String.valueOf(runProgress));
iPatrolTaskStatusService.updatePatrolTaskStatusOfTaskProgress(taskStatus);
// 仅当智巡进度100%+算法进度100%才更新任务状态为完成 // 仅当智巡进度100%+算法进度100%才更新任务状态为完成
if ("100.0".equals(calProgressInDb)) { if ("100.0".equals(calProgressInDb)) {
logger.info("!!!!!!!!!!!!!!!!!! set task_status done!!!"); logger.info("!!!!!!!!!!!!!!!!!! set task_status done!!!");
taskStatus.setTaskState(TaskStatus.DONE.getCode()); taskStatus.setTaskState(TaskStatus.DONE.getCode());
iPatrolTaskStatusService.updatePatrolTaskStatusOfTaskState(taskStatus);
} }
redisService.deleteObjectOfTask(RedisConst.TASK_CURRENT_CODE, taskStatus.getTaskCode());
iPatrolTaskStatusService.updateTaskProgress(taskStatus.getLineId(), taskStatus.getTaskProgress(), null, taskStatus.getTaskState());
} }
} else { } else {
List<PatrolTaskStatus> statusList = patrolTaskStatusService.selectPatrolTaskStatusList(PatrolTaskStatus.builder().taskPatrolledId(patrolTaskStatusItem.getTaskPatrolledId()).build()); List<PatrolTaskStatus> statusList = patrolTaskStatusService.selectPatrolTaskStatusList(PatrolTaskStatus.builder().taskPatrolledId(patrolTaskStatusItem.getTaskPatrolledId()).build());
@ -1263,7 +1203,7 @@ public class PatrolResultController extends BaseController {
patrolTaskStatusOfDb.getTaskEstimatedTime()); patrolTaskStatusOfDb.getTaskEstimatedTime());
patrolTaskStatusItem.setTaskState(TaskStatus.RUNNING.getCode()); patrolTaskStatusItem.setTaskState(TaskStatus.RUNNING.getCode());
patrolTaskStatusItem.setTaskProgress(String.valueOf(runProgress)); patrolTaskStatusItem.setTaskProgress(String.valueOf(runProgress));
i = iPatrolTaskStatusService.updatePatrolTaskStatusRunning(patrolTaskStatusItem);
iPatrolTaskStatusService.updateTaskProgress(patrolTaskStatusItem.getLineId(), patrolTaskStatusItem.getTaskProgress(), null, patrolTaskStatusItem.getTaskState());
} }
} }
} }
@ -1283,10 +1223,45 @@ public class PatrolResultController extends BaseController {
patrolTaskStatusItem.setCreateTime(new Date()); patrolTaskStatusItem.setCreateTime(new Date());
patrolTaskStatusItem.setStartTime(new Date()); patrolTaskStatusItem.setStartTime(new Date());
patrolTaskStatusItem.setTaskEstimatedTime(""); patrolTaskStatusItem.setTaskEstimatedTime("");
if (patrolTaskStatusItem.getTaskName().contains("联合") && !patrolTaskStatusItem.getTaskName().startsWith(sendCode)) {
patrolTaskStatusItem.setTaskName(sendCode + "-" + patrolTaskStatusItem.getTaskName());
patrolTaskStatusItem.setTaskType(TaskType.ORDINARY.getCode());
String devType = patrolTaskDb.getDevType();
String taskCode = patrolTaskDb.getTaskCode();
String[] devTypeArray = Arrays.stream(devType.split(",")).distinct().toArray(String[]::new);
// note 联合任务任务包含多个设备类型 或者 单个非摄像头的设备类型有多个设备编码
if (devTypeArray.length > 1 || (devTypeArray.length == 1 && devTypeArray[0]!= "2" && patrolTaskDb.getDevNo().split(",").length > 1 )) {
// 当taskCode为多设备且redis中正在执行该taskCode的任务时新增或ignore主任务
final String taskCurrentCode = redisService.getCacheObjectOfTask(RedisConst.TASK_CURRENT_CODE, taskCode);
logger.info(Color.CYAN + "task is union task, taskCode: {}, devType: {}, taskCurrentCode: {}" + Color.END, taskCode, devType, taskCurrentCode);
if (StringUtils.isNotEmpty(taskCurrentCode)) {
String execTime = taskCurrentCode.substring(taskCurrentCode.lastIndexOf("@") + 1);
String taskPatrolledId = taskCode + "_" + execTime + "_uni";
PatrolTaskStatus patrolTaskStatusMain = PatrolTaskStatus.builder()
.createTime(patrolTaskStatusItem.getCreateTime())
.startTime(patrolTaskStatusItem.getStartTime())
.taskPatrolledId(taskPatrolledId)
.taskCode(taskCode)
.posType("-1")
.taskState(TaskStatus.RUNNING.getCode())
.taskName(patrolTaskDb.getTaskName())
.taskProgress("0")
.taskEstimatedTime("0")
.taskType(TaskType.MAIN.getCode())
.build();
patrolTaskStatusItem.setTaskName(sendCode + "@" + patrolTaskStatusItem.getTaskName());
patrolTaskStatusItem.setMainId(patrolTaskStatusMain.getTaskPatrolledId());
patrolTaskStatusItem.setTaskType(TaskType.SUB.getCode());
int row = iPatrolTaskStatusService.insertIgnorePatrolTaskStatus(patrolTaskStatusMain);
if (row > 0) {
logger.info("主任务{}, patrolTaskStatusMain: {} 插入成功", patrolTaskStatusMain.getLineId(), patrolTaskStatusMain);
} else {
logger.info("主任务{}, taskPatrolledId: {} 已存在,忽略", patrolTaskStatusMain.getLineId(), patrolTaskStatusMain.getTaskPatrolledId());
}
}
} }
// 普通任务或子任务
i = iPatrolTaskStatusService.insertPatrolTaskStatus(patrolTaskStatusItem); i = iPatrolTaskStatusService.insertPatrolTaskStatus(patrolTaskStatusItem);
} }
} }
@ -1406,64 +1381,26 @@ public class PatrolResultController extends BaseController {
// } // }
// } // }
} }
List<PatrolTask> tasks = patrolTaskService.selectPatrolTaskList(PatrolTask.builder().taskCode(code).build()); List<PatrolTask> tasks = patrolTaskService.selectPatrolTaskList(PatrolTask.builder().taskCode(code).build());
String datetype; String datetype;
if (!tasks.isEmpty()) {
PatrolTaskResultMain taskResultMain = new PatrolTaskResultMain();
taskResultMain.setTaskId(String.valueOf(tasks.get(0).getTaskId()));
taskResultMain.setTaskPatrolledId(patrolResultList.get(0).getTaskPatrolledId());
logger.info("taskResultMain: {}", taskResultMain);
List<PatrolTaskResultMain> patrolTaskResultMainList = iPatrolTaskResultMainService.selectPatrolTaskResultMainList(taskResultMain);
if (!patrolTaskResultMainList.isEmpty()) {
mainID = patrolTaskResultMainList.get(0).getLineId().intValue();
logger.info("exist PatrolTaskResultMain Id: {}", mainID);
} else {
PatrolTaskResultMain patrolTaskResultMain = new PatrolTaskResultMain();
patrolTaskResultMain.setTaskId(String.valueOf(tasks.get(0).getTaskId()));
patrolTaskResultMain.setCreateBy("admin");
patrolTaskResultMain.setCreateTime(new Date());
if (StringUtils.isNotEmpty(tasks.get(0).getAreaName())) {
patrolTaskResultMain.setAreaName(tasks.get(0).getAreaName());
}
patrolTaskResultMain.setFileStatus("0");
patrolTaskResultMain.setTaskPatrolledId(patrolResultList.get(0).getTaskPatrolledId());
int devCount = tasks.get(0).getDevNo().split(StringUtils.COMMA).length;
if (devCount > 1) {
PatrolTaskResultMain resultMainQuery = new PatrolTaskResultMain();
resultMainQuery.setTaskId(String.valueOf(tasks.get(0).getTaskId()));
//select unified_task_patrolled_id from patrol_task_result_main where task_id = #{taskId} and file_status = 0 and (now() - create_time) &lt;= 120 ORDER BY line_id desc limit 1
String unifiedTaskPatrolledId = iPatrolTaskResultMainService.selectUnifiedTaskPatrolledId(resultMainQuery);
if (unifiedTaskPatrolledId != null) {
patrolTaskResultMain.setUnifiedTaskPatrolledId(unifiedTaskPatrolledId);
} else {
patrolTaskResultMain.setUnifiedTaskPatrolledId(taskResultMain.getTaskId() + "_" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()));
}
} else {
patrolTaskResultMain.setUnifiedTaskPatrolledId(taskResultMain.getTaskId() + "_" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()));
}
patrolTaskResultMain.setTaskCode(tasks.get(0).getTaskCode());
patrolTaskResultMain.setTaskName(tasks.get(0).getTaskName());
patrolTaskResultMain.setTaskType(tasks.get(0).getType());
patrolTaskResultMain.setTaskTime(tasks.get(0).getCreateTime());
if (StringUtils.isNotEmpty(tasks.get(0).getAreaId())) {
Map<String, String> map = patrolResultService.selectAreaByAudit(tasks.get(0).getAreaId());
if (map != null && map.get("area_name") != null) {
patrolTaskResultMain.setIntervalName(map.get("area_name"));
}
}
datetype = toDevType(patrolDeviceCodeList);
if (StringUtils.isNotEmpty(datetype)) {
patrolTaskResultMain.setDevType(datetype);
} else {
patrolTaskResultMain.setDevType(tasks.get(0).getDevType());
}
mainID = iPatrolTaskResultMainService.insertPatrolTaskResultMain(patrolTaskResultMain);//
logger.info("insert PatrolTaskResultMain Id: {}", mainID);
}
// 创建巡视归档记录taskMain
PatrolTaskStatus mainTaskStatus = iPatrolTaskStatusService.selectPatrolTaskStatusMain(patrolResultList.get(0).getTaskPatrolledId());
logger.info("mainTaskStatus: {}", mainTaskStatus);
if (mainTaskStatus == null) {
logger.info("GET_INFO_61 ROBOT_TASK_STATUS CODE {} NO EXIST, SKIP IT!", patrolResultList.get(0).getTaskCode());
return toAjax(i);
}
PatrolTaskResultMain taskResultMain = new PatrolTaskResultMain();
taskResultMain.setTaskId(String.valueOf(tasks.get(0).getTaskId()));
taskResultMain.setTaskPatrolledId(mainTaskStatus.getTaskPatrolledId());
logger.info("taskResultMain: {}", taskResultMain);
List<PatrolTaskResultMain> patrolTaskResultMainList = iPatrolTaskResultMainService.selectPatrolTaskResultMainList(taskResultMain);
if (!patrolTaskResultMainList.isEmpty()) {
mainID = patrolTaskResultMainList.get(0).getLineId().intValue();
logger.info("exist PatrolTaskResultMain Id: {}", mainID);
} else {
mainID = iPatrolTaskStatusService.generateTaskResultMain(mainTaskStatus);
logger.info("insert PatrolTaskResultMain Id: {}", mainID);
} }
List<PatrolResult> algrithomPatrolResultList = new ArrayList<>(); List<PatrolResult> algrithomPatrolResultList = new ArrayList<>();
@ -1661,6 +1598,9 @@ public class PatrolResultController extends BaseController {
} }
logger.info("SEND_MESSAGE NEW patrolResult: {}", patrolResult); logger.info("SEND_MESSAGE NEW patrolResult: {}", patrolResult);
Map<String, String> map = resultAnalysisService.selectPointInfoById(patrolResult.getDeviceId());
String unit = map.get("purpose");
patrolResult.setUnit(unit);
i = patrolResultService.insertPatrolResult(patrolResult);// i = patrolResultService.insertPatrolResult(patrolResult);//
resultStatistics.compare(patrolResult); resultStatistics.compare(patrolResult);
// if (!"2".equals(Jqtype)) { // if (!"2".equals(Jqtype)) {
@ -1671,11 +1611,13 @@ public class PatrolResultController extends BaseController {
if (!algrithomPatrolResultList.isEmpty()) { if (!algrithomPatrolResultList.isEmpty()) {
logger.info(Color.CYAN + "+++++++ callAlgorithm start +++++++" + Color.END); logger.info(Color.CYAN + "+++++++ callAlgorithm start +++++++" + Color.END);
// 非摄像头的设备任务需要从数据库统计执行点位数量
if (jsonRootBean.getTotalNumber() == null && !tasks.isEmpty()) { if (jsonRootBean.getTotalNumber() == null && !tasks.isEmpty()) {
logger.info("jsonRootBean.getTotalNumber not NULL: {}", algrithomPatrolResultList); logger.info("jsonRootBean.getTotalNumber not NULL: {}", algrithomPatrolResultList);
String taskId = String.valueOf(tasks.get(0).getTaskId());
logger.info("taskId: {}", taskId);
List<String> algList = patrolResultMapper.selectAlgList(taskId);
String taskCode = String.valueOf(tasks.get(0).getTaskId());
logger.info("taskCode: {}, sendCode: {}", taskCode, sendCode);
// 获取设备标识以便统计执行点位数量
List<String> algList = patrolResultService.selectAlgList(taskCode, sendCode, tasks.get(0).getSpecifiedAlg());
logger.info("algList: {}", algList.toString()); logger.info("algList: {}", algList.toString());
int algCount = 0; int algCount = 0;
for (String alg : algList) { for (String alg : algList) {
@ -1819,7 +1761,6 @@ public class PatrolResultController extends BaseController {
return AjaxResult.success(patrolTaskList); return AjaxResult.success(patrolTaskList);
} }
@GetMapping({"/getEqpBookListInfoForXml"}) @GetMapping({"/getEqpBookListInfoForXml"})
public String getEqpBookListInfo(BasedataEqpBookMoMain basedataEqpBook) { public String getEqpBookListInfo(BasedataEqpBookMoMain basedataEqpBook) {
logger.info("--------getEqpBookListInfo 1!!!!!!"); logger.info("--------getEqpBookListInfo 1!!!!!!");
@ -1901,7 +1842,9 @@ public class PatrolResultController extends BaseController {
basedataEqpBook.setAlgId(algId); basedataEqpBook.setAlgId(algId);
new SimpleDateFormat("yyyyMMdd"); new SimpleDateFormat("yyyyMMdd");
basedataEqpBook.setType(null); basedataEqpBook.setType(null);
List<BasedataEqpBookMoMain> list = patrolResultService.selectBasedataEqpBookList(basedataEqpBook);
// List<BasedataEqpBookMoMain> list = patrolResultService.selectBasedataEqpBookList(basedataEqpBook);
List<BasedataEqpBookMoMain> list = patrolResultService.selectCamera(basedataEqpBook);
logger.info("--------getEqpBookListInfo new list size:{}!!!!!!", list.size());
ArrayList items; ArrayList items;
if (null != list && !list.isEmpty()) { if (null != list && !list.isEmpty()) {
items = new ArrayList<>(); items = new ArrayList<>();


+ 4
- 20
inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/domain/PatrolResultRef.java View File

@ -2,13 +2,16 @@ package com.inspect.partrolresult.domain;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.ToString;
import java.util.Objects; import java.util.Objects;
@Setter @Setter
@Getter @Getter
@ToString
public class PatrolResultRef { public class PatrolResultRef {
private String lineId; private String lineId;
private Long mainId;
private String deviceId; private String deviceId;
private String devType; private String devType;
private String deviceSource; private String deviceSource;
@ -23,6 +26,7 @@ public class PatrolResultRef {
private String resultType; private String resultType;
private String valueUnit; private String valueUnit;
private String unit;
private String resultContent; private String resultContent;
private String resStatus; private String resStatus;
private String resImgUrl; private String resImgUrl;
@ -50,24 +54,4 @@ public class PatrolResultRef {
public int hashCode() { public int hashCode() {
return Objects.hash(lineId, deviceId, devType, deviceSource, time, value, algType, algName, threshold, filePath, description, pointStatus, valueUnit, resultContent); return Objects.hash(lineId, deviceId, devType, deviceSource, time, value, algType, algName, threshold, filePath, description, pointStatus, valueUnit, resultContent);
} }
@Override
public String toString() {
return "PatrolResultRef{" +
"lineId='" + lineId + '\'' +
", deviceId='" + deviceId + '\'' +
", devType='" + devType + '\'' +
", deviceSource='" + deviceSource + '\'' +
", time='" + time + '\'' +
", value='" + value + '\'' +
", algType='" + algType + '\'' +
", algName='" + algName + '\'' +
", threshold='" + threshold + '\'' +
", filePath='" + filePath + '\'' +
", description='" + description + '\'' +
", pointStatus='" + pointStatus + '\'' +
", valueUnit='" + valueUnit + '\'' +
", resultContent='" + resultContent + '\'' +
'}';
}
} }

+ 8
- 1
inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/mapper/PatrolResultMapper.java View File

@ -38,6 +38,8 @@ public interface PatrolResultMapper {
List<BasedataEqpBookMoMain> selectBasedataEqpBookList(BasedataEqpBookMoMain basedataEqpBookMoMain); List<BasedataEqpBookMoMain> selectBasedataEqpBookList(BasedataEqpBookMoMain basedataEqpBookMoMain);
List<BasedataEqpBookMoMain> selectCamera(BasedataEqpBookMoMain basedataEqpBook);
List<PatrolResult> selectPatroByAllDev(PatrolResult patrolResult); List<PatrolResult> selectPatroByAllDev(PatrolResult patrolResult);
List<PatrolResult> selectPatroByAllDevByMainIds(PatrolResult patrolResult); List<PatrolResult> selectPatroByAllDevByMainIds(PatrolResult patrolResult);
@ -118,6 +120,11 @@ public interface PatrolResultMapper {
Map<String, String> selectDeviceNameById(BasePointAreaInfo basePointAreaInfo); Map<String, String> selectDeviceNameById(BasePointAreaInfo basePointAreaInfo);
List<String> selectAlgList(String taskId);
List<String> selectAlgList(@Param("taskCode") String taskCode, @Param("sendCode") String sendCode, @Param("devType") String devType);
List<PatrolData> selectPatrolDataResultByTaskCodeV3(ResultAnalysis resultAnalysis);
List<AlgInfo> selectPointAlgInfo(String patrolPointId);
List<AlgInfo> selectAlgInfoByCode(String codes);
} }

+ 8
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/IPatrolResultService.java View File

@ -34,6 +34,8 @@ public interface IPatrolResultService {
List<BasedataEqpBookMoMain> selectBasedataEqpBookList(BasedataEqpBookMoMain basedataEqpbookMomain); List<BasedataEqpBookMoMain> selectBasedataEqpBookList(BasedataEqpBookMoMain basedataEqpbookMomain);
List<BasedataEqpBookMoMain> selectCamera(BasedataEqpBookMoMain basedataEqpBook);
List<PatrolResult> selectPatroByAllDev(PatrolResult patrolResult); List<PatrolResult> selectPatroByAllDev(PatrolResult patrolResult);
List<PatrolResult> selectPatroByAllDevByMainIds(PatrolResult patrolResult); List<PatrolResult> selectPatroByAllDevByMainIds(PatrolResult patrolResult);
@ -101,4 +103,10 @@ public interface IPatrolResultService {
List<PatrolResult> selectPatrolResultListByMainIds(List<Long> mainIds); List<PatrolResult> selectPatrolResultListByMainIds(List<Long> mainIds);
InspectionReport getInspectionReport(List<Long> lineIds, PatrolTaskResultMain patrolTaskResultMain); InspectionReport getInspectionReport(List<Long> lineIds, PatrolTaskResultMain patrolTaskResultMain);
List<AlgInfo> selectPointAlgInfo(String patrolPointId);
List<AlgInfo> selectAlgInfoByCode(String codes);
List<String> selectAlgList(String taskCode, String sendCode, String specifiedAlg);
} }

+ 136
- 65
inspect-main/inspect-main-task/src/main/java/com/inspect/partrolresult/service/impl/PatrolResultServiceImpl.java View File

@ -7,7 +7,9 @@ import com.inspect.analysis.domain.AlgValue;
import com.inspect.analysis.domain.AnalyseResPoint; import com.inspect.analysis.domain.AnalyseResPoint;
import com.inspect.analysis.domain.ResultAnalysis; import com.inspect.analysis.domain.ResultAnalysis;
import com.inspect.analysis.mapper.ResultAnalysisMapper; import com.inspect.analysis.mapper.ResultAnalysisMapper;
import com.inspect.analysis.utils.ResultAnalysisUtils;
import com.inspect.base.core.constant.AlgConstants; import com.inspect.base.core.constant.AlgConstants;
import com.inspect.base.core.enums.TaskType;
import com.inspect.base.core.exception.ServiceException; import com.inspect.base.core.exception.ServiceException;
import com.inspect.base.core.utils.DateUtils; import com.inspect.base.core.utils.DateUtils;
import com.inspect.base.core.utils.StringUtils; import com.inspect.base.core.utils.StringUtils;
@ -34,11 +36,6 @@ import com.inspect.task.domain.PatrolTask;
import com.inspect.task.mapper.PatrolTaskMapper; import com.inspect.task.mapper.PatrolTaskMapper;
import com.inspect.taskstatus.domain.PatrolTaskStatus; import com.inspect.taskstatus.domain.PatrolTaskStatus;
import com.inspect.taskstatus.mapper.PatrolTaskStatusMapper; import com.inspect.taskstatus.mapper.PatrolTaskStatusMapper;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import io.seata.common.util.CollectionUtils; import io.seata.common.util.CollectionUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -48,20 +45,30 @@ import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@Service @Service
@RefreshScope @RefreshScope
public class PatrolResultServiceImpl implements IPatrolResultService { public class PatrolResultServiceImpl implements IPatrolResultService {
private static final Logger log = LoggerFactory.getLogger(PatrolResultServiceImpl.class); private static final Logger log = LoggerFactory.getLogger(PatrolResultServiceImpl.class);
@Value("${inspect.task.report.voltage:±800kv}")
private String voltage;
@Value("${inspect.task.report.all:0}")
private String exportReportFlag;
private final PatrolResultMapper patrolResultMapper;
private static final Set<String> validAlgTypes = new HashSet<>(Arrays.asList(
AlgConstants.METER,
AlgConstants.XB,
AlgConstants.INFRA_1800,
AlgConstants.INFRA_YU3,
AlgConstants.INFRA_CAMERA,
AlgConstants.INFRA_CAMERA_REVERSE,
AlgConstants.INFRARED,
AlgConstants.INFRARED2,
AlgConstants.GIS_METER_2,
AlgConstants.GIS_METER
));
final final
PatrolResultDefaultValueMapper patrolResultDefaultvalueMapper; PatrolResultDefaultValueMapper patrolResultDefaultvalueMapper;
private final PatrolResultMapper patrolResultMapper;
private final PatrolTaskResultMainMapper patrolTaskResultMainMapper; private final PatrolTaskResultMainMapper patrolTaskResultMainMapper;
private final PatrolTaskStatusMapper patrolTaskStatusMapper; private final PatrolTaskStatusMapper patrolTaskStatusMapper;
private final PatrolTaskMapper patrolTaskMapper; private final PatrolTaskMapper patrolTaskMapper;
@ -69,20 +76,15 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
private final InspectionReportImgMapper inspectionReportImgMapper; private final InspectionReportImgMapper inspectionReportImgMapper;
private final InspectionReportDataMapper inspectionReportDataMapper; private final InspectionReportDataMapper inspectionReportDataMapper;
private final ResultAnalysisMapper resultAnalysisMapper; private final ResultAnalysisMapper resultAnalysisMapper;
private final FeignBasedataAreaService feignBasedataAreaService; private final FeignBasedataAreaService feignBasedataAreaService;
@Value("${inspect.task.report.voltage:±800kv}")
private String voltage;
@Value("${inspect.task.report.all:0}")
private String exportReportFlag;
@Autowired @Autowired
private MessageUtils messageUtils; private MessageUtils messageUtils;
private static final Set<String> validAlgTypes = new HashSet<>(Arrays.asList(
AlgConstants.METER,
AlgConstants.XB,
AlgConstants.INFRA_1800,
AlgConstants.INFRA_YU3,
AlgConstants.INFRA_CAMERA,
AlgConstants.INFRA_CAMERA_REVERSE
));;
@Resource
private ResultAnalysisUtils resultAnalysisUtils;
public PatrolResultServiceImpl(PatrolResultMapper patrolResultMapper, PatrolResultDefaultValueMapper patrolResultDefaultvalueMapper, PatrolTaskResultMainMapper patrolTaskResultMainMapper, PatrolTaskStatusMapper patrolTaskStatusMapper, PatrolTaskMapper patrolTaskMapper, InspectionReportMapper inspectionReportMapper, InspectionReportImgMapper inspectionReportImgMapper, InspectionReportDataMapper inspectionReportDataMapper, ResultAnalysisMapper resultAnalysisMapper, FeignBasedataAreaService feignBasedataAreaService) { public PatrolResultServiceImpl(PatrolResultMapper patrolResultMapper, PatrolResultDefaultValueMapper patrolResultDefaultvalueMapper, PatrolTaskResultMainMapper patrolTaskResultMainMapper, PatrolTaskStatusMapper patrolTaskStatusMapper, PatrolTaskMapper patrolTaskMapper, InspectionReportMapper inspectionReportMapper, InspectionReportImgMapper inspectionReportImgMapper, InspectionReportDataMapper inspectionReportDataMapper, ResultAnalysisMapper resultAnalysisMapper, FeignBasedataAreaService feignBasedataAreaService) {
this.patrolResultMapper = patrolResultMapper; this.patrolResultMapper = patrolResultMapper;
@ -130,11 +132,21 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
return patrolResultMapper.selectPatrolDataResultByTaskCode(patrolResult); return patrolResultMapper.selectPatrolDataResultByTaskCode(patrolResult);
} }
@Override
public List<PatrolData> selectPatrolDataResultByTaskCodeV2(ResultAnalysis resultAnalysis) { public List<PatrolData> selectPatrolDataResultByTaskCodeV2(ResultAnalysis resultAnalysis) {
return this.patrolResultMapper.selectPatrolDataResultByTaskCodeV2(resultAnalysis);
PatrolTaskStatus patrolTaskStatus = patrolTaskStatusMapper.selectPatrolTaskStatusByTaskPatrolledId(resultAnalysis.getTaskPatrolId());
if (patrolTaskStatus != null) {
if (patrolTaskStatus.getTaskType().equals(TaskType.MAIN.getCode())) {
List<String> taskPatrolIds = patrolTaskStatus.getChildren().stream().map(PatrolTaskStatus::getTaskPatrolledId).collect(Collectors.toList());
resultAnalysis.setTaskPatrolIds(taskPatrolIds);
} else {
resultAnalysis.setTaskPatrolIds(Collections.singletonList(patrolTaskStatus.getTaskPatrolledId()));
}
}
log.info("---------------[TASK] query resultAnalysis {}", resultAnalysis);
return this.patrolResultMapper.selectPatrolDataResultByTaskCodeV3(resultAnalysis);
} }
public List<PatrolData> selectPatrolDataResultByTaskCodeList(PatrolTaskStatus patrolTaskStatus) { public List<PatrolData> selectPatrolDataResultByTaskCodeList(PatrolTaskStatus patrolTaskStatus) {
return patrolResultMapper.selectPatrolDataResultByTaskCodeList(patrolTaskStatus); return patrolResultMapper.selectPatrolDataResultByTaskCodeList(patrolTaskStatus);
} }
@ -143,6 +155,11 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
return patrolResultMapper.selectBasedataEqpBookList(patrolResult); return patrolResultMapper.selectBasedataEqpBookList(patrolResult);
} }
@Override
public List<BasedataEqpBookMoMain> selectCamera(BasedataEqpBookMoMain basedataEqpBook) {
return patrolResultMapper.selectCamera(basedataEqpBook);
}
public List<PatrolResult> selectPatroByAllDev(PatrolResult patrolResult) { public List<PatrolResult> selectPatroByAllDev(PatrolResult patrolResult) {
return patrolResultMapper.selectPatroByAllDev(patrolResult); return patrolResultMapper.selectPatroByAllDev(patrolResult);
} }
@ -366,7 +383,6 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
// return saveReportData(resultList, resultMain, lineIds); // return saveReportData(resultList, resultMain, lineIds);
} }
@Transactional @Transactional
public List<Long> saveReportLingzhou_v2(PatrolTaskResultMain resultMain, List<Long> lineIds, Long currentLineId, List<PatrolResult> resultList) { public List<Long> saveReportLingzhou_v2(PatrolTaskResultMain resultMain, List<Long> lineIds, Long currentLineId, List<PatrolResult> resultList) {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
@ -504,6 +520,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
@Transactional @Transactional
public List<Long> saveReportShaoxing(PatrolTaskResultMain resultMain, List<Long> lineIds, List<PatrolResult> resultList) { public List<Long> saveReportShaoxing(PatrolTaskResultMain resultMain, List<Long> lineIds, List<PatrolResult> resultList) {
log.info("saveReportShaoxing PatrolTaskResultMain:{},lineIds:{},resultList:{} ", resultMain, lineIds, resultList);
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
List<Long> reportIds = new ArrayList<>(); List<Long> reportIds = new ArrayList<>();
// 获取站信息 // 获取站信息
@ -535,7 +552,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
List<String> taskNames = resultList.stream().map(PatrolResult::getTaskName).distinct().collect(Collectors.toList()); List<String> taskNames = resultList.stream().map(PatrolResult::getTaskName).distinct().collect(Collectors.toList());
String taskName = StringUtils.join(taskNames, ","); String taskName = StringUtils.join(taskNames, ",");
boolean isMultipleTasks = CollectionUtils.isNotEmpty(taskPatrolledIds) && taskPatrolledIds.size() > 1;
boolean isMultipleTasks = CollectionUtils.isNotEmpty(lineIds) && lineIds.size() > 1;
if (isMultipleTasks) { if (isMultipleTasks) {
// 说明多个任务合并任务名称修改为巡视日期-巡视报告 例如2026年3月23日-巡视报告 // 说明多个任务合并任务名称修改为巡视日期-巡视报告 例如2026年3月23日-巡视报告
Date date = CollectionUtils.isNotEmpty(startTimes) ? startTimes.get(0) : new Date(); Date date = CollectionUtils.isNotEmpty(startTimes) ? startTimes.get(0) : new Date();
@ -557,10 +574,16 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
patrolResultRefs = patrolResultRefs.stream().filter((item) -> "0".equals(item.getResultType())).collect(Collectors.toList()); patrolResultRefs = patrolResultRefs.stream().filter((item) -> "0".equals(item.getResultType())).collect(Collectors.toList());
// 分组按点位ID和算法类型进行分组 // 分组按点位ID和算法类型进行分组
groupKeyListMap = patrolResultRefs.stream().collect(Collectors.groupingBy(item -> new GroupKey(item.getDeviceId(), item.getAlgType(), item.getTaskPatrolledId()))); groupKeyListMap = patrolResultRefs.stream().collect(Collectors.groupingBy(item -> new GroupKey(item.getDeviceId(), item.getAlgType(), item.getTaskPatrolledId())));
groupKeyListMap.forEach((key, value) -> {
for (Map.Entry<GroupKey, List<PatrolResultRef>> entry : groupKeyListMap.entrySet()) {
GroupKey key = entry.getKey();
List<PatrolResultRef> value = entry.getValue();
PatrolResultRef patrolResultRef = new PatrolResultRef(); PatrolResultRef patrolResultRef = new PatrolResultRef();
patrolResultRef.setDeviceId(key.objectId); patrolResultRef.setDeviceId(key.objectId);
patrolResultRef.setAlgType(key.algType); patrolResultRef.setAlgType(key.algType);
// 纠偏算法不归档
if (AlgConstants.CORRECTION.equals(key.algType)) {
continue;
}
patrolResultRef.setDescription(value.stream().sorted(Comparator.comparing(PatrolResultRef::getFilter).reversed()).map(PatrolResultRef::getDescription).collect(Collectors.joining(","))); patrolResultRef.setDescription(value.stream().sorted(Comparator.comparing(PatrolResultRef::getFilter).reversed()).map(PatrolResultRef::getDescription).collect(Collectors.joining(",")));
patrolResultRef.setValue(value.stream().sorted(Comparator.comparing(PatrolResultRef::getFilter).reversed()).map(PatrolResultRef::getValue).collect(Collectors.joining(","))); patrolResultRef.setValue(value.stream().sorted(Comparator.comparing(PatrolResultRef::getFilter).reversed()).map(PatrolResultRef::getValue).collect(Collectors.joining(",")));
for (PatrolResultRef resultRef : value) { for (PatrolResultRef resultRef : value) {
@ -584,7 +607,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
patrolResultRef.setAlgName(value.get(0).getAlgName()); patrolResultRef.setAlgName(value.get(0).getAlgName());
patrolResultRef.setResultType("0"); patrolResultRef.setResultType("0");
resultRefs.add(patrolResultRef); resultRefs.add(patrolResultRef);
});
}
patrolResultRefs = resultRefs; patrolResultRefs = resultRefs;
startTime = PrintUtil.useTime("导出报告:筛选缺陷数据", startTime); startTime = PrintUtil.useTime("导出报告:筛选缺陷数据", startTime);
} else { } else {
@ -594,6 +617,10 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
List<PatrolResultRef> value = entry.getValue(); List<PatrolResultRef> value = entry.getValue();
GroupKey key = entry.getKey(); GroupKey key = entry.getKey();
String algType = key.algType; String algType = key.algType;
// 纠偏算法不归档
if (AlgConstants.CORRECTION.equals(algType)) {
continue;
}
List<PatrolResultRef> filterResults = value.stream().filter(item -> "1".equals(item.getFilter())).collect(Collectors.toList()); List<PatrolResultRef> filterResults = value.stream().filter(item -> "1".equals(item.getFilter())).collect(Collectors.toList());
List<PatrolResultRef> AIResults = value.stream().filter(item -> "0".equals(item.getFilter())).collect(Collectors.toList()); List<PatrolResultRef> AIResults = value.stream().filter(item -> "0".equals(item.getFilter())).collect(Collectors.toList());
PatrolResultRef filterResult = filterResults.isEmpty() ? null : filterResults.get(0); PatrolResultRef filterResult = filterResults.isEmpty() ? null : filterResults.get(0);
@ -713,11 +740,13 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
resultMain.setCheckTime(new Date()); resultMain.setCheckTime(new Date());
resultMain.setFileStatus("1"); resultMain.setFileStatus("1");
String mainId = String.valueOf(resultMain.getLineId()); String mainId = String.valueOf(resultMain.getLineId());
// 查询当前的结果信息 // 查询当前的结果信息
PatrolResult patrolResult = resultList.stream().filter(item -> mainId.equals(item.getMainId())).findFirst().orElse(null); PatrolResult patrolResult = resultList.stream().filter(item -> mainId.equals(item.getMainId())).findFirst().orElse(null);
assert patrolResult != null; assert patrolResult != null;
String taskCode = patrolResult.getTaskCode(); String taskCode = patrolResult.getTaskCode();
String taskPatrolId = patrolResult.getTaskPatrolledId();
PatrolTaskResultMain main = patrolTaskResultMainMapper.selectPatrolTaskResultMainByLineId(lineId);
String taskPatrolId = main.getTaskPatrolledId();
if (StringUtils.isEmpty(taskPatrolId)) { if (StringUtils.isEmpty(taskPatrolId)) {
throw new ServiceException("LACK PLAN ID: " + mainId); throw new ServiceException("LACK PLAN ID: " + mainId);
} else { } else {
@ -750,7 +779,8 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
report.setFilter("0"); report.setFilter("0");
report.setStationType(stationType); report.setStationType(stationType);
inspectionReportMapper.insertInspectionReport(report); inspectionReportMapper.insertInspectionReport(report);
batchInsertReportData_shaoxing(String.valueOf(report.getLineId()), patrolResultRefs, basePointAreaInfoList, taskPatrolledIds);
// 为每个报告生成数据
batchInsertReportData_shaoxing(String.valueOf(report.getLineId()), patrolResultRefs, basePointAreaInfoList, lineIds);
reportIds.add(report.getLineId()); reportIds.add(report.getLineId());
} }
} }
@ -922,7 +952,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
if ("0".equals(exportReportFlag) && aiQxNum == 0 && csQxNum == 0) { if ("0".equals(exportReportFlag) && aiQxNum == 0 && csQxNum == 0) {
continue; continue;
} }
Map<String,PatrolResultRef> keyPatrolResultRef = new HashMap<>();
Map<String, PatrolResultRef> keyPatrolResultRef = new HashMap<>();
List<PatrolResultRef> patrolResultRefs = patrolResultMapper.selectResultRefByLineIds(lineIds, "0"); List<PatrolResultRef> patrolResultRefs = patrolResultMapper.selectResultRefByLineIds(lineIds, "0");
List<PatrolResultRef> patrolResultRefsFilter = patrolResultMapper.selectResultRefByLineIds(lineIds, "1"); List<PatrolResultRef> patrolResultRefsFilter = patrolResultMapper.selectResultRefByLineIds(lineIds, "1");
for (PatrolResultRef AIRef : patrolResultRefs) { for (PatrolResultRef AIRef : patrolResultRefs) {
@ -940,7 +970,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
report.setInspectionStartTime(startTimes.get(0)); report.setInspectionStartTime(startTimes.get(0));
report.setInspectionEndTime(DateUtils.parseDate(endTimes.get(endTimes.size() - 1))); report.setInspectionEndTime(DateUtils.parseDate(endTimes.get(endTimes.size() - 1)));
report.setTaskId(String.valueOf(task.getTaskId())); report.setTaskId(String.valueOf(task.getTaskId()));
report.setEnvInfo(StringUtils.join(envoList,","));
report.setEnvInfo(StringUtils.join(envoList, ","));
report.setTaskPatrolledId(taskPatrolId); report.setTaskPatrolledId(taskPatrolId);
report.setInspectionTaskName(taskName); report.setInspectionTaskName(taskName);
report.setDescription(resultMain.getTaskResult()); report.setDescription(resultMain.getTaskResult());
@ -973,18 +1003,18 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
String AiNum = statisticsAnalyseNumV2(mainId, "0"); String AiNum = statisticsAnalyseNumV2(mainId, "0");
String[] nums = new String[]{AiNum, filterNum}; String[] nums = new String[]{AiNum, filterNum};
startTime = PrintUtil.useTime("统计分析数据", startTime); startTime = PrintUtil.useTime("统计分析数据", startTime);
if(resultList.isEmpty()) {
if (resultList.isEmpty()) {
throw new ServiceException("缺少巡检结果:" + mainId); throw new ServiceException("缺少巡检结果:" + mainId);
} else { } else {
PatrolResult patrolResult = resultList.get(0); PatrolResult patrolResult = resultList.get(0);
String taskCode = patrolResult.getTaskCode(); String taskCode = patrolResult.getTaskCode();
String taskPatrolId = patrolResult.getTaskPatrolledId(); String taskPatrolId = patrolResult.getTaskPatrolledId();
if(StringUtils.isEmpty(taskPatrolId)) {
if (StringUtils.isEmpty(taskPatrolId)) {
throw new ServiceException("缺少执行ID:" + mainId); throw new ServiceException("缺少执行ID:" + mainId);
} else { } else {
List<PatrolTaskStatus> taskStatuses = this.patrolTaskStatusMapper.selectPatrolTaskStatusList(new PatrolTaskStatus(taskPatrolId)); List<PatrolTaskStatus> taskStatuses = this.patrolTaskStatusMapper.selectPatrolTaskStatusList(new PatrolTaskStatus(taskPatrolId));
startTime = PrintUtil.useTime("查询状态数据", startTime); startTime = PrintUtil.useTime("查询状态数据", startTime);
if(taskStatuses.isEmpty()) {
if (taskStatuses.isEmpty()) {
throw new ServiceException("缺少状态数据:" + mainId); throw new ServiceException("缺少状态数据:" + mainId);
} else { } else {
PatrolTaskStatus taskStatus = taskStatuses.get(0); PatrolTaskStatus taskStatus = taskStatuses.get(0);
@ -992,7 +1022,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
patrolTask.setTaskCode(taskCode); patrolTask.setTaskCode(taskCode);
List<PatrolTask> list = this.patrolTaskMapper.selectPatrolTaskList(patrolTask); List<PatrolTask> list = this.patrolTaskMapper.selectPatrolTaskList(patrolTask);
startTime = PrintUtil.useTime("查询任务计划", startTime); startTime = PrintUtil.useTime("查询任务计划", startTime);
if(list.isEmpty()) {
if (list.isEmpty()) {
throw new ServiceException("任务计划丢失:" + taskCode); throw new ServiceException("任务计划丢失:" + taskCode);
} else { } else {
PatrolTask task = list.get(0); PatrolTask task = list.get(0);
@ -1005,31 +1035,31 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
ResultAnalysis ras = resultAnalysisMapper.selectTaskAbnormalData(resultAnalysis); ResultAnalysis ras = resultAnalysisMapper.selectTaskAbnormalData(resultAnalysis);
int ii = 0; int ii = 0;
int iii = 0; int iii = 0;
if(0 == ras.getCsQxNum()) {
if (0 == ras.getCsQxNum()) {
ras.setFilter("0"); ras.setFilter("0");
ii = 0; ii = 0;
iii = 0; iii = 0;
} }
if(0 == ras.getAiQxNum()) {
if (0 == ras.getAiQxNum()) {
ras.setFilter("1"); ras.setFilter("1");
ii = 0; ii = 0;
iii = 1; iii = 1;
} }
if(0 != ras.getCsQxNum() && 0 != ras.getAiQxNum()) {
if (0 != ras.getCsQxNum() && 0 != ras.getAiQxNum()) {
ras.setFilter("2"); ras.setFilter("2");
ii = 2; ii = 2;
} }
Long[] ids = new Long[ii]; Long[] ids = new Long[ii];
List list1 = new ArrayList<>(); List list1 = new ArrayList<>();
for(int i = 0; i < 2; ++i) {
if(0 != ras.getCsQxNum() && 0 != ras.getAiQxNum()) {
for (int i = 0; i < 2; ++i) {
if (0 != ras.getCsQxNum() && 0 != ras.getAiQxNum()) {
iii = i; iii = i;
} }
if(i != Integer.parseInt(ras.getFilter())) {
if (i != Integer.parseInt(ras.getFilter())) {
InspectionReport report = new InspectionReport(); InspectionReport report = new InspectionReport();
resetReport(report, nums[iii], mainId, task, taskStatus); resetReport(report, nums[iii], mainId, task, taskStatus);
report.setFilter(iii + ""); report.setFilter(iii + "");
@ -1056,6 +1086,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
} }
} }
} }
private void resetReport(InspectionReport report, String analyseNum, String mainId, PatrolTask task, PatrolTaskStatus taskStatus) { private void resetReport(InspectionReport report, String analyseNum, String mainId, PatrolTask task, PatrolTaskStatus taskStatus) {
report.setPatrolStatistics(analyseNum); report.setPatrolStatistics(analyseNum);
//report.setInspectionDate(task.getCreateTime()); //report.setInspectionDate(task.getCreateTime());
@ -1071,7 +1102,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
// List<PatrolResultRef> patrolResultRefs = patrolResultMapper.selectResultRefByLineId(mainId); // List<PatrolResultRef> patrolResultRefs = patrolResultMapper.selectResultRefByLineId(mainId);
// List<PatrolResultRef> patrolResultRefs = patrolResultMapper.selectResultRefByLineIds(mainIds, filter); // List<PatrolResultRef> patrolResultRefs = patrolResultMapper.selectResultRefByLineIds(mainIds, filter);
if ("0".equals(exportReportFlag)) { if ("0".equals(exportReportFlag)) {
List <PatrolResultRef> resultRefs = new ArrayList<>();
List<PatrolResultRef> resultRefs = new ArrayList<>();
// 只导出缺陷 // 只导出缺陷
patrolResultRefs = patrolResultRefs.stream().filter((item) -> "0".equals(item.getResultType())).collect(Collectors.toList()); patrolResultRefs = patrolResultRefs.stream().filter((item) -> "0".equals(item.getResultType())).collect(Collectors.toList());
// 分组按点位ID和算法类型进行分组 // 分组按点位ID和算法类型进行分组
@ -1148,7 +1179,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
} }
reportData.setAlgName(patrolResultRef.getAlgName()); reportData.setAlgName(patrolResultRef.getAlgName());
String threshold = patrolResultRef.getThreshold(); String threshold = patrolResultRef.getThreshold();
if(StringUtils.isBlank(threshold)) {
if (StringUtils.isBlank(threshold)) {
threshold = ""; threshold = "";
} }
if ("1".equals(patrolResultRef.getResultType()) && threshold.contains("sub_53")) { if ("1".equals(patrolResultRef.getResultType()) && threshold.contains("sub_53")) {
@ -1182,7 +1213,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
// ++okNum; // ++okNum;
// } // }
log.info("[RESULT] resultType: {}, patrolResultRef: {}", resultType, patrolResultRef); log.info("[RESULT] resultType: {}, patrolResultRef: {}", resultType, patrolResultRef);
if(resultType == null) {
if (resultType == null) {
continue; continue;
} else if (resultType.equals("0")) { } else if (resultType.equals("0")) {
reportData.setPointStatus(messageUtils.get("缺陷")); reportData.setPointStatus(messageUtils.get("缺陷"));
@ -1242,11 +1273,11 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
} }
} }
public void batchInsertReportData_shaoxing(String reportId, List<PatrolResultRef> patrolResultRefs, List<BasePointAreaInfo> basePointAreaInfoList, List<String> taskPatrolledIds) {
Map<String, Map<String, Long>> taskCounterMap = new HashMap<>();
public void batchInsertReportData_shaoxing(String reportId, List<PatrolResultRef> patrolResultRefs, List<BasePointAreaInfo> basePointAreaInfoList, List<Long> lineIds) {
Map<Long, Map<String, Long>> taskCounterMap = new HashMap<>();
// 为每个任务初始化计数器 // 为每个任务初始化计数器
for (String item : taskPatrolledIds) {
for (Long item : lineIds) {
Map<String, Long> counter = new HashMap<>(); Map<String, Long> counter = new HashMap<>();
counter.put("defect", 0L); counter.put("defect", 0L);
counter.put("ok", 0L); counter.put("ok", 0L);
@ -1268,6 +1299,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
// 获取该结果所属的任务名 // 获取该结果所属的任务名
String resultTaskName = patrolResultRef.getTaskName(); String resultTaskName = patrolResultRef.getTaskName();
String taskPatrolledId = patrolResultRef.getTaskPatrolledId(); String taskPatrolledId = patrolResultRef.getTaskPatrolledId();
Long mainId = patrolResultRef.getMainId();
BasePointAreaInfo basePointAreaInfo; BasePointAreaInfo basePointAreaInfo;
try { try {
basePointAreaInfo = basePointAreaInfoList.stream().filter((item) -> item != null && patrolResultRef.getDeviceId().equals(item.getDeviceId())).findFirst().get(); basePointAreaInfo = basePointAreaInfoList.stream().filter((item) -> item != null && patrolResultRef.getDeviceId().equals(item.getDeviceId())).findFirst().get();
@ -1287,6 +1319,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
reportData.setAcquisitionTime(DateUtils.parse(DateUtils.yyyyMMddHHmmss2, patrolResultRef.getTime())); reportData.setAcquisitionTime(DateUtils.parse(DateUtils.yyyyMMddHHmmss2, patrolResultRef.getTime()));
reportData.setTaskName(resultTaskName); reportData.setTaskName(resultTaskName);
reportData.setTaskPatrolledId(taskPatrolledId); reportData.setTaskPatrolledId(taskPatrolledId);
reportData.setTaskResultId(String.valueOf(mainId));
if ("1".equals(patrolResultRef.getResultType()) && validAlgTypes.contains(patrolResultRef.getAlgType())) { if ("1".equals(patrolResultRef.getResultType()) && validAlgTypes.contains(patrolResultRef.getAlgType())) {
reportData.setInspectionResults(patrolResultRef.getValue()); reportData.setInspectionResults(patrolResultRef.getValue());
} else { } else {
@ -1294,7 +1327,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
} }
reportData.setAlgName(patrolResultRef.getAlgName()); reportData.setAlgName(patrolResultRef.getAlgName());
String threshold = patrolResultRef.getThreshold(); String threshold = patrolResultRef.getThreshold();
if(StringUtils.isBlank(threshold)) {
if (StringUtils.isBlank(threshold)) {
threshold = ""; threshold = "";
} }
if ("1".equals(patrolResultRef.getResultType()) && threshold.contains("sub_53")) { if ("1".equals(patrolResultRef.getResultType()) && threshold.contains("sub_53")) {
@ -1309,15 +1342,19 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
reportData.setInspectionResults(patrolResultRef.getValue()); reportData.setInspectionResults(patrolResultRef.getValue());
} }
// 给读数增加单位
String resValue = resultAnalysisUtils.addUnit2Value(reportData.getInspectionResults(), patrolResultRef.getAlgType(), patrolResultRef.getUnit());
reportData.setInspectionResults(resValue);
String pointStatus = patrolResultRef.getPointStatus(); String pointStatus = patrolResultRef.getPointStatus();
String resultType = patrolResultRef.getResultType(); String resultType = patrolResultRef.getResultType();
log.info("[RESULT] resultType: {}, patrolResultRef: {}", resultType, patrolResultRef); log.info("[RESULT] resultType: {}, patrolResultRef: {}", resultType, patrolResultRef);
if(resultType == null) {
if (resultType == null) {
continue; continue;
} else if (resultType.equals("0")) { } else if (resultType.equals("0")) {
reportData.setPointStatus(messageUtils.get("缺陷")); reportData.setPointStatus(messageUtils.get("缺陷"));
// 按任务统计异常编号 // 按任务统计异常编号
Map<String, Long> counter = taskCounterMap.get(taskPatrolledId);
Map<String, Long> counter = taskCounterMap.get(mainId);
if (counter != null) { if (counter != null) {
counter.put("defect", counter.get("defect") + 1); counter.put("defect", counter.get("defect") + 1);
reportData.setCode(counter.get("defect")); reportData.setCode(counter.get("defect"));
@ -1328,7 +1365,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
} else if (resultType.equals("1")) { } else if (resultType.equals("1")) {
reportData.setPointStatus(messageUtils.get("正常")); reportData.setPointStatus(messageUtils.get("正常"));
// 按任务统计异常编号 // 按任务统计异常编号
Map<String, Long> counter = taskCounterMap.get(taskPatrolledId);
Map<String, Long> counter = taskCounterMap.get(mainId);
if (counter != null) { if (counter != null) {
counter.put("ok", counter.get("ok") + 1); counter.put("ok", counter.get("ok") + 1);
reportData.setCode(counter.get("ok")); reportData.setCode(counter.get("ok"));
@ -1339,7 +1376,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
} else { } else {
reportData.setPointStatus(messageUtils.get("异常")); reportData.setPointStatus(messageUtils.get("异常"));
// 按任务统计异常编号 // 按任务统计异常编号
Map<String, Long> counter = taskCounterMap.get(taskPatrolledId);
Map<String, Long> counter = taskCounterMap.get(mainId);
if (counter != null) { if (counter != null) {
counter.put("fail", counter.get("fail") + 1); counter.put("fail", counter.get("fail") + 1);
reportData.setCode(counter.get("fail")); reportData.setCode(counter.get("fail"));
@ -1394,7 +1431,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
public void batchInsertReportData_Lingzhou(String reportId, List<BasePointAreaInfo> basePointAreaInfoList, String filter, List<PatrolResultRef> patrolResultRefs) { public void batchInsertReportData_Lingzhou(String reportId, List<BasePointAreaInfo> basePointAreaInfoList, String filter, List<PatrolResultRef> patrolResultRefs) {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
if ("0".equals(exportReportFlag)) { if ("0".equals(exportReportFlag)) {
List <PatrolResultRef> resultRefs = new ArrayList<>();
List<PatrolResultRef> resultRefs = new ArrayList<>();
// 只导出缺陷 // 只导出缺陷
patrolResultRefs = patrolResultRefs.stream().filter((item) -> "0".equals(item.getResultType())).collect(Collectors.toList()); patrolResultRefs = patrolResultRefs.stream().filter((item) -> "0".equals(item.getResultType())).collect(Collectors.toList());
// 分组按点位ID和算法类型进行分组 // 分组按点位ID和算法类型进行分组
@ -1424,6 +1461,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
patrolResultRef.setTime(value.stream().map(item -> item.getTime() != null ? item.getTime() : "").distinct().findFirst().orElse("")); patrolResultRef.setTime(value.stream().map(item -> item.getTime() != null ? item.getTime() : "").distinct().findFirst().orElse(""));
patrolResultRef.setThreshold(value.stream().map(item -> item.getThreshold() != null ? item.getThreshold() : "").distinct().findFirst().orElse("")); patrolResultRef.setThreshold(value.stream().map(item -> item.getThreshold() != null ? item.getThreshold() : "").distinct().findFirst().orElse(""));
patrolResultRef.setAlgName(value.get(0).getAlgName()); patrolResultRef.setAlgName(value.get(0).getAlgName());
patrolResultRef.setAlgType(value.get(0).getAlgType());
patrolResultRef.setResultType("0"); patrolResultRef.setResultType("0");
resultRefs.add(patrolResultRef); resultRefs.add(patrolResultRef);
}); });
@ -1466,7 +1504,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
} }
reportData.setAlgName(patrolResultRef.getAlgName()); reportData.setAlgName(patrolResultRef.getAlgName());
String threshold = patrolResultRef.getThreshold(); String threshold = patrolResultRef.getThreshold();
if(StringUtils.isBlank(threshold)) {
if (StringUtils.isBlank(threshold)) {
threshold = ""; threshold = "";
} }
if ("1".equals(patrolResultRef.getResultType()) && threshold.contains("sub_53")) { if ("1".equals(patrolResultRef.getResultType()) && threshold.contains("sub_53")) {
@ -1483,7 +1521,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
String resultType = patrolResultRef.getResultType(); String resultType = patrolResultRef.getResultType();
log.info("[RESULT] resultType: {}, patrolResultRef: {}", resultType, patrolResultRef); log.info("[RESULT] resultType: {}, patrolResultRef: {}", resultType, patrolResultRef);
if(resultType == null) {
if (resultType == null) {
continue; continue;
} else if (resultType.equals("0")) { } else if (resultType.equals("0")) {
reportData.setPointStatus(messageUtils.get("缺陷")); reportData.setPointStatus(messageUtils.get("缺陷"));
@ -1559,7 +1597,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
List<InspectionReportImg> reportImages = new ArrayList<>(); List<InspectionReportImg> reportImages = new ArrayList<>();
int i; int i;
for(i = 0; i < patrolResultRefs.size(); ++i) {
for (i = 0; i < patrolResultRefs.size(); ++i) {
PatrolResultRef ref = patrolResultRefs.get(i); PatrolResultRef ref = patrolResultRefs.get(i);
ref.setAlgName(algInfos.stream().filter((alg) -> { ref.setAlgName(algInfos.stream().filter((alg) -> {
return alg.getAlgSubtypeCode().equals(ref.getAlgType()); return alg.getAlgSubtypeCode().equals(ref.getAlgType());
@ -1730,7 +1768,6 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
return String.format(messageUtils.get("缺陷总数:%d个"), confirmNum); return String.format(messageUtils.get("缺陷总数:%d个"), confirmNum);
} }
public String statisticsAnalyseNumLingZhou(List<Long> lineIds) { public String statisticsAnalyseNumLingZhou(List<Long> lineIds) {
int okNum = 0; int okNum = 0;
int failNum = 0; int failNum = 0;
@ -1777,7 +1814,6 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
} }
} }
public String statisticsAnalyseNumShaoxing(List<Long> lineIds) { public String statisticsAnalyseNumShaoxing(List<Long> lineIds) {
int okNum = 0; int okNum = 0;
int failNum = 0; int failNum = 0;
@ -1850,7 +1886,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
int totalNum = analyses.size(); int totalNum = analyses.size();
int lastNum = totalNum - failNum - confirmNum; int lastNum = totalNum - failNum - confirmNum;
if(lastNum != okNum) {
if (lastNum != okNum) {
; ;
} }
@ -1928,7 +1964,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
report.setStationType(stationType); report.setStationType(stationType);
Map<GroupKey, List<PatrolResultRef>> groupKeyListMap; Map<GroupKey, List<PatrolResultRef>> groupKeyListMap;
if ("0".equals(exportReportFlag)) { if ("0".equals(exportReportFlag)) {
List <PatrolResultRef> resultRefs = new ArrayList<>();
List<PatrolResultRef> resultRefs = new ArrayList<>();
// 只导出缺陷 // 只导出缺陷
patrolResultRefs = patrolResultRefs.stream().filter((item) -> "0".equals(item.getResultType())).collect(Collectors.toList()); patrolResultRefs = patrolResultRefs.stream().filter((item) -> "0".equals(item.getResultType())).collect(Collectors.toList());
// 分组按点位ID和算法类型进行分组 // 分组按点位ID和算法类型进行分组
@ -2093,7 +2129,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
} }
reportData.setAlgName(patrolResultRef.getAlgName()); reportData.setAlgName(patrolResultRef.getAlgName());
String threshold = patrolResultRef.getThreshold(); String threshold = patrolResultRef.getThreshold();
if(StringUtils.isBlank(threshold)) {
if (StringUtils.isBlank(threshold)) {
threshold = ""; threshold = "";
} }
if ("1".equals(patrolResultRef.getResultType()) && threshold.contains("sub_53")) { if ("1".equals(patrolResultRef.getResultType()) && threshold.contains("sub_53")) {
@ -2110,7 +2146,7 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
String resultType = patrolResultRef.getResultType(); String resultType = patrolResultRef.getResultType();
// log.info("[RESULT] resultType: {}, patrolResultRef: {}", resultType, patrolResultRef); // log.info("[RESULT] resultType: {}, patrolResultRef: {}", resultType, patrolResultRef);
if(resultType == null) {
if (resultType == null) {
continue; continue;
} else if (resultType.equals("0")) { } else if (resultType.equals("0")) {
reportData.setPointStatus(messageUtils.get("缺陷")); reportData.setPointStatus(messageUtils.get("缺陷"));
@ -2155,6 +2191,32 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
return report; return report;
} }
@Override
public List<AlgInfo> selectPointAlgInfo(String patrolPointId) {
return patrolResultMapper.selectPointAlgInfo(patrolPointId);
}
@Override
public List<AlgInfo> selectAlgInfoByCode(String codes) {
return patrolResultMapper.selectAlgInfoByCode(codes);
}
/**
* 根据以下条件返回任务的全部或某设备类型的点位及其算法
* @param sendCode 任务编码
* @param specifiedAlg 设备唯一标识
* @return 任务指定算法
*/
@Override
public List<String> selectAlgList(String taskCode, String sendCode, String specifiedAlg) {
String devType = "摄像头".equals(sendCode) ? "2" : null;
List<String> algList = patrolResultMapper.selectAlgList(taskCode, sendCode, devType);
if (StringUtils.isNotEmpty(specifiedAlg)) {
return algList.stream().map(item -> specifiedAlg).collect(Collectors.toList());
}
return algList;
}
private PatrolResultRef mergePatrolResultRef(PatrolResultRef filterResult, PatrolResultRef AIResult, String resultType) { private PatrolResultRef mergePatrolResultRef(PatrolResultRef filterResult, PatrolResultRef AIResult, String resultType) {
PatrolResultRef merged = new PatrolResultRef(); PatrolResultRef merged = new PatrolResultRef();
merged.setDeviceId(filterResult.getDeviceId()); merged.setDeviceId(filterResult.getDeviceId());
@ -2200,6 +2262,15 @@ public class PatrolResultServiceImpl implements IPatrolResultService {
public int hashCode() { public int hashCode() {
return Objects.hash(objectId, algType, taskPatrolled); return Objects.hash(objectId, algType, taskPatrolled);
} }
@Override
public String toString() {
return "GroupKey{" +
"objectId='" + objectId + '\'' +
", algType='" + algType + '\'' +
", taskPatrolled='" + taskPatrolled + '\'' +
'}';
}
} }
public static void main(String[] args) { public static void main(String[] args) {


+ 5
- 29
inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/domain/PatrolTaskResultMain.java View File

@ -1,19 +1,18 @@
package com.inspect.resultmain.domain; package com.inspect.resultmain.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.inspect.base.core.annotation.Excel; import com.inspect.base.core.annotation.Excel;
import com.inspect.base.core.web.domain.BaseEntity; import com.inspect.base.core.web.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@Setter @Setter
@Getter @Getter
@ToString
public class PatrolTaskResultMain extends BaseEntity { public class PatrolTaskResultMain extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Long lineId; private Long lineId;
@ -95,27 +94,4 @@ public class PatrolTaskResultMain extends BaseEntity {
public PatrolTaskResultMain(String taskPatrolledId) { public PatrolTaskResultMain(String taskPatrolledId) {
this.taskPatrolledId = taskPatrolledId; this.taskPatrolledId = taskPatrolledId;
} }
@Override
public String toString() {
return "PatrolTaskResultMain{" +
"lineId=" + lineId +
", taskId='" + taskId + '\'' +
", taskName='" + taskName + '\'' +
", taskCode='" + taskCode + '\'' +
", createBy='" + createBy + '\'' +
", fileStatus='" + fileStatus + '\'' +
", areaName='" + areaName + '\'' +
", taskType='" + taskType + '\'' +
", taskTime=" + taskTime +
", intervalName='" + intervalName + '\'' +
", devType='" + devType + '\'' +
", taskResult='" + taskResult + '\'' +
", requestId='" + requestId + '\'' +
", checkPerson='" + checkPerson + '\'' +
", taskPatrolledId='" + taskPatrolledId + '\'' +
", taskPatrolledIds='" + taskPatrolledIds + '\'' +
", checkTime=" + checkTime +
'}';
}
} }

+ 2
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/mapper/PatrolTaskResultMainMapper.java View File

@ -33,4 +33,6 @@ public interface PatrolTaskResultMainMapper {
List<Long> selectLineIds(Long lineId); List<Long> selectLineIds(Long lineId);
List<Long> selectLineIdsByList(@Param("lineIds") List<Long> lineIds); List<Long> selectLineIdsByList(@Param("lineIds") List<Long> lineIds);
PatrolTaskResultMain selectPatrolTaskResultMainOne(String patrolTaskId);
} }

+ 1
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/service/IPatrolTaskResultMainService.java View File

@ -31,4 +31,5 @@ public interface IPatrolTaskResultMainService {
List<Long> selectLineIdsByList(List<Long> lineIds); List<Long> selectLineIdsByList(List<Long> lineIds);
PatrolTaskResultMain selectPatrolTaskResultMainOne(String patrolTaskId);
} }

+ 4
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/resultmain/service/impl/PatrolTaskResultMainServiceImpl.java View File

@ -74,4 +74,8 @@ public class PatrolTaskResultMainServiceImpl implements IPatrolTaskResultMainSer
return this.patrolTaskResultMainMapper.selectLineIdsByList(lineIds); return this.patrolTaskResultMainMapper.selectLineIdsByList(lineIds);
} }
@Override
public PatrolTaskResultMain selectPatrolTaskResultMainOne(String patrolTaskId) {
return this.patrolTaskResultMainMapper.selectPatrolTaskResultMainOne(patrolTaskId);
}
} }

+ 747
- 222
inspect-main/inspect-main-task/src/main/java/com/inspect/task/controller/PatrolTaskController.java
File diff suppressed because it is too large
View File


+ 9
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/task/domain/PatrolData.java View File

@ -74,6 +74,7 @@ public class PatrolData implements Comparable<PatrolData> {
private String brightResStatus; private String brightResStatus;
private String areaName; private String areaName;
private String areaId;
private String algType; private String algType;
private String objectId; private String objectId;
private String imageNormalUrlPath; private String imageNormalUrlPath;
@ -374,6 +375,14 @@ public class PatrolData implements Comparable<PatrolData> {
this.taskPatrolId = taskPatrolId; this.taskPatrolId = taskPatrolId;
} }
public String getAreaId() {
return areaId;
}
public void setAreaId(String areaId) {
this.areaId = areaId;
}
protected boolean canEqual(Object other) { protected boolean canEqual(Object other) {
return other instanceof PatrolData; return other instanceof PatrolData;
} }


+ 6
- 50
inspect-main/inspect-main-task/src/main/java/com/inspect/task/domain/PatrolTask.java View File

@ -17,6 +17,7 @@ import lombok.*;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@ToString
public class PatrolTask extends BaseEntity { public class PatrolTask extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -186,57 +187,12 @@ public class PatrolTask extends BaseEntity {
private List<VideoPos> videoPosList; private List<VideoPos> videoPosList;
private List<PatrolTaskStatus> patrolTaskStatusList; private List<PatrolTaskStatus> patrolTaskStatusList;
private List<PrevPoint> prevPoints; private List<PrevPoint> prevPoints;
private List<String> patrolPointIds;
private String specifiedAlg;
// 任务总点位数量 // 任务总点位数量
private int totalPoints; private int totalPoints;
@Override
public String toString() {
return "PatrolTask{" +
"taskId=" + taskId +
", stationName='" + stationName + '\'' +
", stationCode='" + stationCode + '\'' +
", type='" + type + '\'' +
", taskCode='" + taskCode + '\'' +
", taskName='" + taskName + '\'' +
", priority='" + priority + '\'' +
", deviceLevel='" + deviceLevel + '\'' +
", deviceList='" + deviceList + '\'' +
", fixedStartTime=" + fixedStartTime +
", cycleMonth='" + cycleMonth + '\'' +
", cycleWeek='" + cycleWeek + '\'' +
", cycleExecuteTime='" + cycleExecuteTime + '\'' +
", cycleStartTime=" + cycleStartTime +
", cycleEndTime=" + cycleEndTime +
", intervalNumber=" + intervalNumber +
", intervalType='" + intervalType + '\'' +
", intervalExecuteTime='" + intervalExecuteTime + '\'' +
", intervalStartTime=" + intervalStartTime +
", intervalEndTime=" + intervalEndTime +
", invalidStartTime=" + invalidStartTime +
", invalidEndTime=" + invalidEndTime +
", isEnable='" + isEnable + '\'' +
", linkageState='" + linkageState + '\'' +
", devType='" + devType + '\'' +
", drafter='" + drafter + '\'' +
", executionStatus='" + executionStatus + '\'' +
", fileStatus='" + fileStatus + '\'' +
", isUp='" + isUp + '\'' +
", taskCycle='" + taskCycle + '\'' +
", devNo='" + devNo + '\'' +
", storage='" + storage + '\'' +
", taskProgress='" + taskProgress + '\'' +
", taskState='" + taskState + '\'' +
", executionMode='" + executionMode + '\'' +
", beginTime='" + beginTime + '\'' +
", endTime='" + endTime + '\'' +
", areaId='" + areaId + '\'' +
", areaName='" + areaName + '\'' +
", areaIdS='" + areaIdS + '\'' +
", eqPointList=" + eqpointList +
", videoPosList=" + videoPosList +
", patrolTaskStatusList=" + patrolTaskStatusList +
", prevPoints=" + prevPoints +
", totalPoints=" + totalPoints +
'}';
}
private String deviceType;
private String pointType;
} }

+ 4
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/task/domain/PatrolTaskModuleXml.java View File

@ -6,6 +6,7 @@ import lombok.Setter;
import java.util.List; import java.util.List;
import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
@Setter @Setter
@ -15,6 +16,9 @@ import javax.xml.bind.annotation.XmlRootElement;
) )
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class PatrolTaskModuleXml { public class PatrolTaskModuleXml {
@XmlElement(
name = "Item"
)
List<PatrolTaskXML> item; List<PatrolTaskXML> item;
} }

+ 2
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/task/domain/SendTask.java View File

@ -29,6 +29,8 @@ public class SendTask {
name = "Command" name = "Command"
) )
private String command; private String command;
private String Time;
@JSONField( @JSONField(
name = "Type" name = "Type"
) )


+ 6
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/task/mapper/PatrolTaskMapper.java View File

@ -54,4 +54,10 @@ public interface PatrolTaskMapper {
List<JSONObject> selectPatrolTaskStatus(@Param("taskCodes") Set<String> patrolTaskCodes); List<JSONObject> selectPatrolTaskStatus(@Param("taskCodes") Set<String> patrolTaskCodes);
String selectStationNo(); String selectStationNo();
List<JSONObject> selectBasedataPatrolPointList(@Param("patrolPointIds") List<String> patrolPointIds);
List<JSONObject> selectBasedataPatrolPointPresetList(@Param("patrolPointIds") List<String> patrolPointIds);
List<JSONObject> selectPatrolPresetPosList(@Param("patrolPointIds") List<String> patrolPointIds);
} }

+ 7
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/task/service/IPatrolTaskService.java View File

@ -1,5 +1,6 @@
package com.inspect.task.service; package com.inspect.task.service;
import com.alibaba.fastjson.JSONObject;
import com.inspect.task.domain.DeviceConvert; import com.inspect.task.domain.DeviceConvert;
import com.inspect.task.domain.PatrolData; import com.inspect.task.domain.PatrolData;
import com.inspect.task.domain.PatrolTask; import com.inspect.task.domain.PatrolTask;
@ -56,4 +57,10 @@ public interface IPatrolTaskService {
void executeAsync(PatrolTaskStatus taskStatus); void executeAsync(PatrolTaskStatus taskStatus);
void executeTask(); void executeTask();
List<JSONObject> selectBasedataPatrolPointList(List<String> patrolPointIds);
List<JSONObject> selectBasedataPatrolPointPresetList(List<String> patrolPointIds);
List<JSONObject> selectPatrolPresetPosList(List<String> patrolPointIds);
} }

+ 29
- 5
inspect-main/inspect-main-task/src/main/java/com/inspect/task/service/impl/PatrolTaskServiceImpl.java View File

@ -5,6 +5,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.inspect.analysis.domain.ResultAnalysis; import com.inspect.analysis.domain.ResultAnalysis;
import com.inspect.analysis.mapper.ResultAnalysisMapper; import com.inspect.analysis.mapper.ResultAnalysisMapper;
import com.inspect.base.core.constant.AlgConstants;
import com.inspect.base.core.sftp.SftpClient; import com.inspect.base.core.sftp.SftpClient;
import com.inspect.base.core.sftp.SftpUploadEntity; import com.inspect.base.core.sftp.SftpUploadEntity;
import com.inspect.base.core.utils.DateUtils; import com.inspect.base.core.utils.DateUtils;
@ -27,7 +28,6 @@ import java.util.stream.Collectors;
import com.inspect.taskstatus.domain.PatrolTaskStatus; import com.inspect.taskstatus.domain.PatrolTaskStatus;
import com.inspect.taskstatus.mapper.PatrolTaskStatusMapper; import com.inspect.taskstatus.mapper.PatrolTaskStatusMapper;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
@ -203,9 +203,19 @@ public class PatrolTaskServiceImpl implements IPatrolTaskService {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
List<List<Integer>> list; List<List<Integer>> list;
ResultAnalysis resultAnalysis = new ResultAnalysis();
resultAnalysis.setTaskPatrolId(patrolData.getTaskPatrolId());
resultAnalysis.setObjectId(patrolData.getPointId());
resultAnalysis.setAlgType(AlgConstants.CORRECTION);
try { try {
list = mapper.readValue(patrolData.getResValue(), new TypeReference<List<List<Integer>>>() {
});
List<ResultAnalysis> resultAnalysisList = resultAnalysisMapper.selectResultAnalysisList(resultAnalysis);
if (!resultAnalysisList.isEmpty()) {
resultAnalysis = resultAnalysisList.get(0);
list = mapper.readValue(resultAnalysis.getResValue(), new TypeReference<List<List<Integer>>>() {
});
} else {
list = new ArrayList<>();
}
log.info("controller correctionAlgorithm correction value: {}", list); log.info("controller correctionAlgorithm correction value: {}", list);
} catch (Exception e) { } catch (Exception e) {
log.info("controller correctionAlgorithm correction value exception"); log.info("controller correctionAlgorithm correction value exception");
@ -265,8 +275,6 @@ public class PatrolTaskServiceImpl implements IPatrolTaskService {
// 更新结果 // 更新结果
if (!StringUtils.isEmpty(patrolData.getLineId()) && filePath != "") { if (!StringUtils.isEmpty(patrolData.getLineId()) && filePath != "") {
ResultAnalysis resultAnalysis = new ResultAnalysis();
resultAnalysis.setLineId(Long.valueOf(patrolData.getLineId()));
resultAnalysis.setResStatus("4"); resultAnalysis.setResStatus("4");
resultAnalysis.setDescription("已完成纠偏"); resultAnalysis.setDescription("已完成纠偏");
resultAnalysis.setOriginalValue(filePath); resultAnalysis.setOriginalValue(filePath);
@ -346,4 +354,20 @@ public class PatrolTaskServiceImpl implements IPatrolTaskService {
} }
log.info("=============================定时任务归档结束============================================="); log.info("=============================定时任务归档结束=============================================");
} }
// 根据点位id查询点位信息
@Override
public List<JSONObject> selectBasedataPatrolPointList(List<String> patrolPointIds) {
return patrolTaskMapper.selectBasedataPatrolPointList(patrolPointIds);
}
@Override
public List<JSONObject> selectBasedataPatrolPointPresetList(List<String> patrolPointIds) {
return patrolTaskMapper.selectBasedataPatrolPointPresetList(patrolPointIds);
}
@Override
public List<JSONObject> selectPatrolPresetPosList(List<String> patrolPointIds) {
return patrolTaskMapper.selectPatrolPresetPosList(patrolPointIds);
}
} }

+ 2
- 47
inspect-main/inspect-main-task/src/main/java/com/inspect/taskinfo/domain/PatrolTaskInfo.java View File

@ -15,6 +15,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ToString
public class PatrolTaskInfo extends BaseEntity { public class PatrolTaskInfo extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Long lineId; private Long lineId;
@ -93,55 +94,9 @@ public class PatrolTaskInfo extends BaseEntity {
private String alarmType; private String alarmType;
private String taskType; private String taskType;
private String areaName; private String areaName;
private Long areaId;
@JsonFormat( @JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss" pattern = "yyyy-MM-dd HH:mm:ss"
) )
private Date createTime; private Date createTime;
@Override
public String toString() {
return "PatrolTaskInfo{" +
"lineId=" + lineId +
", lineIds='" + lineIds + '\'' +
", taskMajorId='" + taskMajorId + '\'' +
", deviceId='" + deviceId + '\'' +
", deviceName='" + deviceName + '\'' +
", componentId='" + componentId + '\'' +
", componentName='" + componentName + '\'' +
", bayId='" + bayId + '\'' +
", bayName='" + bayName + '\'' +
", mainDeviceId='" + mainDeviceId + '\'' +
", phyAssetId='" + phyAssetId + '\'' +
", presetCode='" + presetCode + '\'' +
", parentId='" + parentId + '\'' +
", ebookId='" + ebookId + '\'' +
", ebookName='" + ebookName + '\'' +
", mainDeviceName='" + mainDeviceName + '\'' +
", videoPos='" + videoPos + '\'' +
", dataType=" + dataType +
", photoUrl='" + photoUrl + '\'' +
", warnLevel='" + warnLevel + '\'' +
", videoUrl='" + videoUrl + '\'' +
", defectType='" + defectType + '\'' +
", beginTime='" + beginTime + '\'' +
", endTime='" + endTime + '\'' +
", status='" + status + '\'' +
", pointStatus='" + pointStatus + '\'' +
", suggestion='" + suggestion + '\'' +
", desc='" + desc + '\'' +
", taskName='" + taskName + '\'' +
", priority='" + priority + '\'' +
", resultContent='" + resultContent + '\'' +
", deviceCode='" + deviceCode + '\'' +
", devName='" + devName + '\'' +
", devNo='" + devNo + '\'' +
", areName='" + areName + '\'' +
", devType='" + devType + '\'' +
", phase='" + phase + '\'' +
", alarmType='" + alarmType + '\'' +
", taskType='" + taskType + '\'' +
", areaName='" + areaName + '\'' +
", createTime=" + createTime +
'}';
}
} }

+ 120
- 29
inspect-main/inspect-main-task/src/main/java/com/inspect/taskstatus/controller/PatrolTaskStatusController.java View File

@ -3,9 +3,13 @@ package com.inspect.taskstatus.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.inspect.analysis.domain.ResultAnalysis; import com.inspect.analysis.domain.ResultAnalysis;
import com.inspect.analysis.domain.ResultAnalysisSummaryDTO;
import com.inspect.analysis.service.IResultAnalysisService; import com.inspect.analysis.service.IResultAnalysisService;
import com.inspect.base.core.constant.AlgConstants;
import com.inspect.base.core.constant.RedisConst; import com.inspect.base.core.constant.RedisConst;
import com.inspect.base.core.domain.maintain.MaintainRegion;
import com.inspect.base.core.enums.TaskStatus; import com.inspect.base.core.enums.TaskStatus;
import com.inspect.base.core.enums.TaskType;
import com.inspect.base.core.utils.DateUtils; import com.inspect.base.core.utils.DateUtils;
import com.inspect.base.core.utils.DescUtil; import com.inspect.base.core.utils.DescUtil;
import com.inspect.base.core.utils.StringUtils; import com.inspect.base.core.utils.StringUtils;
@ -21,6 +25,7 @@ import com.inspect.calender.enums.TaskStateEnum;
import com.inspect.calender.service.TaskCalendarGenerator; import com.inspect.calender.service.TaskCalendarGenerator;
import com.inspect.common.log.annotation.Log; import com.inspect.common.log.annotation.Log;
import com.inspect.common.log.enums.BizType; import com.inspect.common.log.enums.BizType;
import com.inspect.maintain.service.IMaintainRegionService;
import com.inspect.partrolresult.service.IPatrolResultService; import com.inspect.partrolresult.service.IPatrolResultService;
import com.inspect.resultmain.domain.PatrolTaskResultMain; import com.inspect.resultmain.domain.PatrolTaskResultMain;
import com.inspect.resultmain.service.IPatrolTaskResultMainService; import com.inspect.resultmain.service.IPatrolTaskResultMainService;
@ -29,6 +34,7 @@ import com.inspect.task.controller.PatrolTaskController;
import com.inspect.task.domain.PatrolTask; import com.inspect.task.domain.PatrolTask;
import com.inspect.task.domain.SendTask; import com.inspect.task.domain.SendTask;
import com.inspect.task.service.IPatrolTaskService; import com.inspect.task.service.IPatrolTaskService;
import com.inspect.taskinfo.domain.PatrolTaskInfo;
import com.inspect.taskinfo.service.IPatrolTaskInfoService; import com.inspect.taskinfo.service.IPatrolTaskInfoService;
import com.inspect.taskstatus.client.FeignJobTaskClient; import com.inspect.taskstatus.client.FeignJobTaskClient;
import com.inspect.taskstatus.client.FeignTaskClient; import com.inspect.taskstatus.client.FeignTaskClient;
@ -45,6 +51,7 @@ import java.text.ParseException;
import java.time.*; import java.time.*;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@RestController @RestController
@ -70,6 +77,9 @@ public class PatrolTaskStatusController extends BaseController {
@Resource @Resource
private TaskCalendarGenerator taskCalendarGenerator; private TaskCalendarGenerator taskCalendarGenerator;
@Resource
private IMaintainRegionService maintainRegionService;
public PatrolTaskStatusController( public PatrolTaskStatusController(
PatrolTaskController patrolTaskController, PatrolTaskController patrolTaskController,
IPatrolTaskStatusService patrolTaskStatusService, IPatrolTaskStatusService patrolTaskStatusService,
@ -171,7 +181,7 @@ public class PatrolTaskStatusController extends BaseController {
// 更新结果 // 更新结果
List<String> taskPatrolIds = list.stream().filter(item -> !item.getTaskState().equals(TaskStateEnum.PENDING.getCode())).map(PatrolTaskStatus::getTaskPatrolledId).collect(Collectors.toList()); List<String> taskPatrolIds = list.stream().filter(item -> !item.getTaskState().equals(TaskStateEnum.PENDING.getCode())).map(PatrolTaskStatus::getTaskPatrolledId).collect(Collectors.toList());
if(taskPatrolIds.size() > 0) {
if (taskPatrolIds.size() > 0) {
List<PatrolTaskResultMain> resultMains = patrolTaskResultMainService.selectMainFileStatus(taskPatrolIds); List<PatrolTaskResultMain> resultMains = patrolTaskResultMainService.selectMainFileStatus(taskPatrolIds);
List<String> taskCodeIds = list.stream().map(PatrolTaskStatus::getTaskCode).collect(Collectors.toList()); List<String> taskCodeIds = list.stream().map(PatrolTaskStatus::getTaskCode).collect(Collectors.toList());
List<Map<String, Object>> pointList = patrolTaskInfoService.selectPatrolTaskInfoCount(taskCodeIds); List<Map<String, Object>> pointList = patrolTaskInfoService.selectPatrolTaskInfoCount(taskCodeIds);
@ -226,30 +236,34 @@ public class PatrolTaskStatusController extends BaseController {
@GetMapping({"/list"}) @GetMapping({"/list"})
public TableDataInfo list(PatrolTaskStatus patrolTaskStatus) { public TableDataInfo list(PatrolTaskStatus patrolTaskStatus) {
this.startPage(); this.startPage();
patrolTaskStatus.setFilterTaskType("2");
// 分页查询执行任务列表
List<PatrolTaskStatus> list = patrolTaskStatusService.selectPatrolTaskStatusList(patrolTaskStatus); List<PatrolTaskStatus> list = patrolTaskStatusService.selectPatrolTaskStatusList(patrolTaskStatus);
if (list == null || list.size() == 0) { if (list == null || list.size() == 0) {
return this.getDataTable(list); return this.getDataTable(list);
} }
// 收集执行id
List<String> taskPatrolIds = list.stream().map(PatrolTaskStatus::getTaskPatrolledId).collect(Collectors.toList()); List<String> taskPatrolIds = list.stream().map(PatrolTaskStatus::getTaskPatrolledId).collect(Collectors.toList());
// 查询归档信息
List<PatrolTaskResultMain> resultMains = patrolTaskResultMainService.selectMainFileStatus(taskPatrolIds); List<PatrolTaskResultMain> resultMains = patrolTaskResultMainService.selectMainFileStatus(taskPatrolIds);
// 收集任务code
List<String> taskCodeIds = list.stream().map(PatrolTaskStatus::getTaskCode).collect(Collectors.toList()); List<String> taskCodeIds = list.stream().map(PatrolTaskStatus::getTaskCode).collect(Collectors.toList());
// 查询任务详情
List<Map<String, Object>> pointList = patrolTaskInfoService.selectPatrolTaskInfoCount(taskCodeIds); List<Map<String, Object>> pointList = patrolTaskInfoService.selectPatrolTaskInfoCount(taskCodeIds);
Map<String, String> pointMap = pointList.stream().collect(Collectors.toMap((item) -> { Map<String, String> pointMap = pointList.stream().collect(Collectors.toMap((item) -> {
return (String) item.get("taskMajorId"); return (String) item.get("taskMajorId");
}, (item) -> { }, (item) -> {
return String.valueOf(item.get("num")); return String.valueOf(item.get("num"));
})); }));
Map<String, ResultAnalysis> abnormalDataBatchMap = resultAnalysisService.selectTaskAbnormalDataBatch(taskPatrolIds);
List<ResultAnalysis> allQxAnalysisList = resultAnalysisService.selectResultAnalysisListBatch(taskPatrolIds, "0");
Map<String, Map<GroupKey, List<ResultAnalysis>>> groupedAnalysisMap = allQxAnalysisList.stream()
.collect(Collectors.groupingBy(
ResultAnalysis::getTaskPatrolId,
Collectors.groupingBy(data -> new GroupKey(data.getObjectId(), data.getAlgType()))
));
// 填充每个任务的扩展统计信息
list.forEach((item) -> { list.forEach((item) -> {
item.setPatrolStatus("1"); item.setPatrolStatus("1");
item.setPointCount(pointMap.get(item.getTaskCode())); item.setPointCount(pointMap.get(item.getTaskCode()));
// 任务指定算法类型当为纠偏时返回值便于前端做样式处理
if (AlgConstants.CORRECTION.equals(item.getSpecifiedAlg())) {
item.setAlgName(AlgConstants.CORRECTION);
}
// 根据任务进度和归档信息设置文件状态
if (!item.getTaskProgress().contains("100")) { if (!item.getTaskProgress().contains("100")) {
item.setFileStatus("0"); item.setFileStatus("0");
} else { } else {
@ -262,14 +276,25 @@ public class PatrolTaskStatusController extends BaseController {
item.setFileStatus("0"); item.setFileStatus("0");
} }
} }
// 异常数据统计
ResultAnalysis resultAnalysis = abnormalDataBatchMap.getOrDefault(item.getTaskPatrolledId(), new ResultAnalysis());
item.setCsQxNum(resultAnalysis.getCsQxNum());
item.setAiQxNum(resultAnalysis.getAiQxNum());
item.setCsYcNum(resultAnalysis.getCsYcNum());
item.setAiYcNum(resultAnalysis.getAiYcNum());
Map<GroupKey, List<ResultAnalysis>> groupKeyListMap = groupedAnalysisMap.get(item.getTaskPatrolledId());
item.setQxNum(groupKeyListMap == null ? 0 : groupKeyListMap.size());
List<ResultAnalysisSummaryDTO> summaryDTOList;
if (item.getTaskType().equals(TaskType.MAIN.getCode())) {
List<String> taskPatrolledIds = item.getChildren().stream().map(PatrolTaskStatus::getTaskPatrolledId).collect(Collectors.toList());
summaryDTOList = resultAnalysisService.countResultAnalysisSummary(taskPatrolledIds);
} else {
summaryDTOList = resultAnalysisService.countResultAnalysisSummary(Collections.singletonList(item.getTaskPatrolledId()));
}
if (summaryDTOList != null && !summaryDTOList.isEmpty()) {
summaryDTOList.forEach(summaryDTO -> {
if (summaryDTO != null) {
// 使用 Optional 或三元运算符防止 null 值累加
item.setCsQxNum(item.getCsQxNum() + summaryDTO.getCsQxNum());
item.setAiQxNum(item.getAiQxNum() + summaryDTO.getAiQxNum());
item.setCsYcNum(item.getCsYcNum() + summaryDTO.getCsYcNum());
item.setAiYcNum(item.getAiYcNum() + summaryDTO.getAiYcNum());
item.setQxNum(item.getQxNum() + summaryDTO.getQxNum());
}
});
}
if (StringUtils.isEmpty(item.getTaskEstimatedTime())) { if (StringUtils.isEmpty(item.getTaskEstimatedTime())) {
item.setTaskEstimatedTime("0"); item.setTaskEstimatedTime("0");
} }
@ -774,14 +799,19 @@ public class PatrolTaskStatusController extends BaseController {
} }
if (StringUtils.isNotEmpty(receiveCode)) { if (StringUtils.isNotEmpty(receiveCode)) {
log.info("无人机-机器人任务构建, receiveCode: {}, devType: {}, devNo: {}", receiveCode, patrolTask.getDevType(), patrolTask.getDevNo()); log.info("无人机-机器人任务构建, receiveCode: {}, devType: {}, devNo: {}", receiveCode, patrolTask.getDevType(), patrolTask.getDevNo());
SendTask sendTask = new SendTask();
sendTask.setReceiveCode(receiveCode);
sendTask.setSendCode(sendCode);
sendTask.setCode(patrolTask.getTaskId() + "");
sendTask.setType("41");
sendTask.setCommand("1");
String pilotTaskCmd = JSONObject.toJSONString(sendTask);
pilotTaskCmds.add(pilotTaskCmd);
// 判断任务点位是否在检修区域内
if (isWithinMaintainRegion(patrolTask.getTaskCode(), patrolTask.getDevNo())) {
log.info("该任务点位在检修区域内 taskCode: {},sendCode: {}", patrolTask.getTaskCode(), patrolTask.getDevNo());
} else {
SendTask sendTask = new SendTask();
sendTask.setReceiveCode(receiveCode);
sendTask.setSendCode(sendCode);
sendTask.setCode(patrolTask.getTaskCode());
sendTask.setType("41");
sendTask.setCommand("1");
String pilotTaskCmd = JSONObject.toJSONString(sendTask);
pilotTaskCmds.add(pilotTaskCmd);
}
} else { } else {
log.info("可见光任务构建, 第 {} 个, devNo: {}", i + 1, devNos[i]); log.info("可见光任务构建, 第 {} 个, devNo: {}", i + 1, devNos[i]);
devTypeList.add(devTypes[i]); devTypeList.add(devTypes[i]);
@ -789,8 +819,13 @@ public class PatrolTaskStatusController extends BaseController {
} }
} }
if (!(pilotTaskCmds.isEmpty() || devTypeList.isEmpty() || devNoList.isEmpty())) {
String immediatelyExecTaskTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"));
redisService.setCacheObjectOfTask(RedisConst.TASK_CURRENT_CODE, patrolTask.getTaskCode(), RedisConst.TASK_CODE + patrolTask.getTaskCode() + StringUtils.AT + immediatelyExecTaskTime, 1L, TimeUnit.HOURS);
}
// 下发无人机任务 // 下发无人机任务
for(String pilotTaskCmd : pilotTaskCmds) {
for (String pilotTaskCmd : pilotTaskCmds) {
log.info("无人机-机器人任务下发, pilotTaskCmd: {}", pilotTaskCmd); log.info("无人机-机器人任务下发, pilotTaskCmd: {}", pilotTaskCmd);
try { try {
this.feignTaskClient.sendCommand(pilotTaskCmd); this.feignTaskClient.sendCommand(pilotTaskCmd);
@ -824,6 +859,25 @@ public class PatrolTaskStatusController extends BaseController {
String command = params.getCommand(); String command = params.getCommand();
log.info("[TASK] task_status_change cmd: {}, task: {}", command, patrolTaskStatus); log.info("[TASK] task_status_change cmd: {}, task: {}", command, patrolTaskStatus);
if (patrolTaskStatus.getTaskType().equals(TaskType.MAIN.getCode())) {
for (PatrolTaskStatus status : patrolTaskStatus.getChildren()) {
execCommand(command, status);
}
} else {
execCommand(command, patrolTaskStatus);
}
return toAjax(1);
}
// 执行修改任务状态命令
private void execCommand(String command, PatrolTaskStatus patrolTaskStatus) {
log.info("[TASK] task_status_change cmd: {}, task: {}", command, patrolTaskStatus);
// 任务为完成终止过期状态时不允许改变状态
if (Arrays.asList(TaskStatus.DONE.getCode(), TaskStatus.HALTED.getCode(), TaskStatus.EXPIRED.getCode()).contains(patrolTaskStatus.getTaskState())) {
log.info("[TASK] STATUS CHANGE IS NOT ALLOWED cmd: {}, task: {}", command, patrolTaskStatus);
return;
}
if (TaskStatus.DONE.getCode().equals(command)) { if (TaskStatus.DONE.getCode().equals(command)) {
patrolTaskStatus.setTaskState(TaskStatus.RUNNING.getCode()); patrolTaskStatus.setTaskState(TaskStatus.RUNNING.getCode());
} else if (TaskStatus.RUNNING.getCode().equals(command)) { } else if (TaskStatus.RUNNING.getCode().equals(command)) {
@ -836,10 +890,9 @@ public class PatrolTaskStatusController extends BaseController {
feignJobTaskClient.resumeExecTask(patrolTaskStatus.getTaskPatrolledId()); feignJobTaskClient.resumeExecTask(patrolTaskStatus.getTaskPatrolledId());
} }
int res = patrolTaskStatusService.updatePatrolTaskStatus(patrolTaskStatus);
patrolTaskStatusService.updateTaskProgress(patrolTaskStatus.getLineId(), null, null, patrolTaskStatus.getTaskState());
patrolTaskStatus.setCommand(command); patrolTaskStatus.setCommand(command);
issuePatrolTask(patrolTaskStatus); issuePatrolTask(patrolTaskStatus);
return toAjax(res);
} }
public void issuePatrolTask(PatrolTaskStatus patrolTaskStatus) { public void issuePatrolTask(PatrolTaskStatus patrolTaskStatus) {
@ -910,7 +963,7 @@ public class PatrolTaskStatusController extends BaseController {
Set<String> wrjCode = new HashSet<>();//droneCode Set<String> wrjCode = new HashSet<>();//droneCode
for (BasedataEqpBookMoMain book : bookList) { for (BasedataEqpBookMoMain book : bookList) {
final String type = book.getType(); final String type = book.getType();
if(StringUtils.isEmpty(type)) {
if (StringUtils.isEmpty(type)) {
continue; continue;
} }
if (!type.equals("1") && !type.equals("2") && !type.equals("3") && !type.equals("13")) { if (!type.equals("1") && !type.equals("2") && !type.equals("3") && !type.equals("13")) {
@ -1000,4 +1053,42 @@ public class PatrolTaskStatusController extends BaseController {
return AjaxResult.success(); return AjaxResult.success();
} }
/**
* 判断任务点位是否在检修区域内
*
* @param taskCode
* @return
*/
public boolean isWithinMaintainRegion(String taskCode, String devNo) {
Date currentDate = new Date();
MaintainRegion maintainRegion = MaintainRegion.builder()
.startTime(currentDate)
.endTime(currentDate)
.enable("1")
.build();
List<MaintainRegion> maintainRegionList = maintainRegionService.selectMaintainRegionList(maintainRegion);
log.info("[TASK] MAINTAIN REGION: {}", maintainRegionList);
List<String> maintainIds = maintainRegionList.stream()
.map(MaintainRegion::getDeviceList)
.flatMap(ids -> Arrays.stream(ids.split(StringUtils.COMMA)))
.collect(Collectors.toList());
PatrolTaskInfo patrolTaskInfo = PatrolTaskInfo.builder()
.taskMajorId(taskCode)
.devNo(devNo)
.build();
List<PatrolTaskInfo> patrolTaskInfoList = patrolTaskInfoService.selectPatrolTask(patrolTaskInfo);
log.info("[TASK] PATROL TASK INFO: {}", patrolTaskInfoList);
boolean isWithin = false;
for (PatrolTaskInfo info : patrolTaskInfoList) {
final Long areaId = info.getAreaId();
if (maintainIds.contains(String.valueOf(areaId))) {
isWithin = true;
break;
}
}
return isWithin;
}
} }

+ 10
- 54
inspect-main/inspect-main-task/src/main/java/com/inspect/taskstatus/domain/PatrolTaskStatus.java View File

@ -5,16 +5,15 @@ import com.inspect.base.core.web.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date; import java.util.Date;
import java.util.List;
import lombok.*; import lombok.*;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@Setter @Setter
@Getter @Getter
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@ToString
public class PatrolTaskStatus extends BaseEntity { public class PatrolTaskStatus extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Long lineId; private Long lineId;
@ -82,6 +81,13 @@ public class PatrolTaskStatus extends BaseEntity {
name = "巡检类型" name = "巡检类型"
) )
private String patrolType; private String patrolType;
// 主任务id
private String mainId;
private String taskType;
private String filterTaskType;
// 汇总信息
private String summary;
private List<PatrolTaskStatus> children;
private String timeType; private String timeType;
private String timeConditions; private String timeConditions;
private String beginTime; private String beginTime;
@ -107,12 +113,11 @@ public class PatrolTaskStatus extends BaseEntity {
private int csYcNum; private int csYcNum;
private int aiQxNum; private int aiQxNum;
private int aiYcNum; private int aiYcNum;
private int qxNum; private int qxNum;
private String resultType; private String resultType;
private String pointStatus; private String pointStatus;
private String algName; private String algName;
private String specifiedAlg;
public PatrolTaskStatus(String taskPatrolledId) { public PatrolTaskStatus(String taskPatrolledId) {
this.taskPatrolledId = taskPatrolledId; this.taskPatrolledId = taskPatrolledId;
@ -120,53 +125,4 @@ public class PatrolTaskStatus extends BaseEntity {
public PatrolTaskStatus() { public PatrolTaskStatus() {
} }
@Override
public String toString() {
return "PatrolTaskStatus{" +
"lineId=" + lineId +
", taskPatrolledId='" + taskPatrolledId + '\'' +
", taskName='" + taskName + '\'' +
", areaTaskName='" + areaTaskName + '\'' +
", taskCode='" + taskCode + '\'' +
", taskState='" + taskState + '\'' +
", planStartTime=" + planStartTime +
", startTime=" + startTime +
", taskProgress='" + taskProgress + '\'' +
", taskEstimatedTime='" + taskEstimatedTime + '\'' +
", description='" + description + '\'' +
", posType='" + posType + '\'' +
", code='" + code + '\'' +
", pos='" + pos + '\'' +
", patrolType='" + patrolType + '\'' +
", timeType='" + timeType + '\'' +
", timeConditions='" + timeConditions + '\'' +
", beginTime='" + beginTime + '\'' +
", endTime='" + endTime + '\'' +
", createTime=" + createTime +
", patrolStatus='" + patrolStatus + '\'' +
", year=" + year +
", devNo='" + devNo + '\'' +
", command='" + command + '\'' +
", pointCount='" + pointCount + '\'' +
", execType='" + execType + '\'' +
", fileStatus='" + fileStatus + '\'' +
", filter='" + filter + '\'' +
", pointName='" + pointName + '\'' +
", deviceName='" + deviceName + '\'' +
", abnormal='" + abnormal + '\'' +
", channelName='" + channelName + '\'' +
", deviceSource='" + deviceSource + '\'' +
", filterDesc='" + filterDesc + '\'' +
", desc='" + desc + '\'' +
", csQxNum=" + csQxNum +
", csYcNum=" + csYcNum +
", aiQxNum=" + aiQxNum +
", aiYcNum=" + aiYcNum +
", qxNum=" + qxNum +
", resultType='" + resultType + '\'' +
", pointStatus='" + pointStatus + '\'' +
", algName='" + algName + '\'' +
'}';
}
} }

+ 11
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/taskstatus/mapper/PatrolTaskStatusMapper.java View File

@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map;
@Mapper @Mapper
public interface PatrolTaskStatusMapper { public interface PatrolTaskStatusMapper {
@ -46,4 +47,14 @@ public interface PatrolTaskStatusMapper {
List<DailyTaskStatsDTO> selectDailyStatsByYearAndMonth(@Param("year") Integer year, @Param("month") Integer month); List<DailyTaskStatsDTO> selectDailyStatsByYearAndMonth(@Param("year") Integer year, @Param("month") Integer month);
List<DailyTaskStatsDTO> selectDailyStatsByYearAndMonthAndDay(@Param("year") Integer year, @Param("month") Integer month, @Param("day") Integer day); List<DailyTaskStatsDTO> selectDailyStatsByYearAndMonthAndDay(@Param("year") Integer year, @Param("month") Integer month, @Param("day") Integer day);
int insertIgnorePatrolTaskStatus(PatrolTaskStatus patrolTaskStatusMain);
List<PatrolTaskStatus> selectPatrolTaskStatusListByMainId(String taskPatrolledId);
PatrolTaskStatus selectPatrolTaskStatusMain(String taskPatrolledId);
List<Map<String, String>> selectTotalPointsAndAlgs(String taskCode);
List<Map<String, String>> selectExecutedPointsAndAlgs(String taskPatrolledId);
} }

+ 10
- 0
inspect-main/inspect-main-task/src/main/java/com/inspect/taskstatus/service/IPatrolTaskStatusService.java View File

@ -33,4 +33,14 @@ public interface IPatrolTaskStatusService {
int deletePatrolTaskStatusByLineIds(Long[] lineIds); int deletePatrolTaskStatusByLineIds(Long[] lineIds);
int deletePatrolTaskStatusByLineId(Long lineId); int deletePatrolTaskStatusByLineId(Long lineId);
int insertIgnorePatrolTaskStatus(PatrolTaskStatus patrolTaskStatusMain);
void updateTaskProgress(Long lineId, String taskProgress, String taskEstimatedTime, String taskState);
List<PatrolTaskStatus> selectPatrolTaskStatusListByMainId(String taskPatrolledId);
int generateTaskResultMain(PatrolTaskStatus patrolTaskStatusMain);
PatrolTaskStatus selectPatrolTaskStatusMain(String taskPatrolledId);
} }

+ 348
- 73
inspect-main/inspect-main-task/src/main/java/com/inspect/taskstatus/service/impl/PatrolTaskStatusServiceImpl.java View File

@ -1,89 +1,364 @@
package com.inspect.taskstatus.service.impl; package com.inspect.taskstatus.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.inspect.annotation.TaskStatusChange; import com.inspect.annotation.TaskStatusChange;
import com.inspect.base.core.constant.Color; import com.inspect.base.core.constant.Color;
import com.inspect.base.core.constant.RedisConst;
import com.inspect.base.core.enums.TaskStatus;
import com.inspect.base.core.enums.TaskType;
import com.inspect.base.core.utils.BigDecimalUtil;
import com.inspect.base.core.utils.DateUtils;
import com.inspect.base.core.utils.StringUtils;
import com.inspect.base.redis.service.RedisService;
import com.inspect.partrolresult.mapper.PatrolResultMapper;
import com.inspect.partrolresult.service.IPatrolResultService;
import com.inspect.resultmain.domain.PatrolTaskResultMain;
import com.inspect.resultmain.service.IPatrolTaskResultMainService;
import com.inspect.task.domain.PatrolTask;
import com.inspect.task.service.IPatrolTaskService;
import com.inspect.taskstatus.domain.PatrolTaskStatus; import com.inspect.taskstatus.domain.PatrolTaskStatus;
import com.inspect.taskstatus.domain.TaskCount; import com.inspect.taskstatus.domain.TaskCount;
import com.inspect.taskstatus.mapper.PatrolTaskStatusMapper; import com.inspect.taskstatus.mapper.PatrolTaskStatusMapper;
import com.inspect.taskstatus.service.IPatrolTaskStatusService; import com.inspect.taskstatus.service.IPatrolTaskStatusService;
import java.util.Date;
import java.util.List;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
@Service @Service
public class PatrolTaskStatusServiceImpl implements IPatrolTaskStatusService { public class PatrolTaskStatusServiceImpl implements IPatrolTaskStatusService {
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final PatrolTaskStatusMapper patrolTaskStatusMapper;
@Autowired
public PatrolTaskStatusServiceImpl(PatrolTaskStatusMapper patrolTaskStatusMapper) {
this.patrolTaskStatusMapper = patrolTaskStatusMapper;
}
public PatrolTaskStatus selectPatrolTaskStatusByLineId(Long lineId) {
return this.patrolTaskStatusMapper.selectPatrolTaskStatusByLineId(lineId);
}
public PatrolTaskStatus selectPatrolTaskStatusByTaskPatrolledId(String taskPatrolledId) {
return this.patrolTaskStatusMapper.selectPatrolTaskStatusByTaskPatrolledId(taskPatrolledId);
}
public List<PatrolTaskStatus> selectPatrolTaskStatusList(PatrolTaskStatus patrolTaskStatus) {
return this.patrolTaskStatusMapper.selectPatrolTaskStatusList(patrolTaskStatus);
}
public List<PatrolTaskStatus> selectPatrolTaskStatusCount(PatrolTaskStatus patrolTaskStatus) {
return this.patrolTaskStatusMapper.selectPatrolTaskStatusCount(patrolTaskStatus);
}
public List<TaskCount> selectCountList(PatrolTaskStatus patrolTaskStatus) {
return this.patrolTaskStatusMapper.selectCountList(patrolTaskStatus);
}
public List<TaskCount> selectCountListByDate(PatrolTaskStatus patrolTaskStatus) {
return this.patrolTaskStatusMapper.selectCountListByDate(patrolTaskStatus);
}
@TaskStatusChange(targetState = "1", async = true) // "1"表示已完成状态
public int insertPatrolTaskStatus(PatrolTaskStatus patrolTaskStatus) {
patrolTaskStatus.setCreateTime(new Date());
patrolTaskStatus.setStartTime(new Date());
return this.patrolTaskStatusMapper.insertPatrolTaskStatus(patrolTaskStatus);
}
@TaskStatusChange(targetState = "1", async = true) // "1"表示已完成状态
public int updatePatrolTaskStatus(PatrolTaskStatus patrolTaskStatus) {
log.info(Color.RED + "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" + Color.END);
log.info("patrolTaskStatus: {}", patrolTaskStatus);
return this.patrolTaskStatusMapper.updatePatrolTaskStatus(patrolTaskStatus);
}
public int updatePatrolTaskStatusOfTaskProgress(PatrolTaskStatus patrolTaskStatus) {
return this.patrolTaskStatusMapper.updatePatrolTaskStatusOfTaskProgress(patrolTaskStatus);
}
@TaskStatusChange(targetState = "1", async = true) // "1"表示已完成状态
public int updatePatrolTaskStatusOfTaskState(PatrolTaskStatus patrolTaskStatus) {
return this.patrolTaskStatusMapper.updatePatrolTaskStatusOfTaskState(patrolTaskStatus);
}
public int updatePatrolTaskStatusOfTaskStateAndEndTime(PatrolTaskStatus patrolTaskStatus) {
return this.patrolTaskStatusMapper.updatePatrolTaskStatusOfTaskStateAndEndTime(patrolTaskStatus);
}
public int updatePatrolTaskStatusRunning(PatrolTaskStatus patrolTaskStatus) {
return this.patrolTaskStatusMapper.updatePatrolTaskStatusRunning(patrolTaskStatus);
}
public int deletePatrolTaskStatusByLineIds(Long[] lineIds) {
return this.patrolTaskStatusMapper.deletePatrolTaskStatusByLineIds(lineIds);
}
public int deletePatrolTaskStatusByLineId(Long lineId) {
return this.patrolTaskStatusMapper.deletePatrolTaskStatusByLineId(lineId);
}
private final Logger log = LoggerFactory.getLogger(this.getClass());
private final PatrolTaskStatusMapper patrolTaskStatusMapper;
@Resource
private RedisService redisService;
@Resource
private IPatrolTaskService patrolTaskService;
@Resource
private IPatrolTaskResultMainService patrolTaskResultMainService;
@Resource
private IPatrolResultService patrolResultService;
@Autowired
public PatrolTaskStatusServiceImpl(PatrolTaskStatusMapper patrolTaskStatusMapper) {
this.patrolTaskStatusMapper = patrolTaskStatusMapper;
}
public PatrolTaskStatus selectPatrolTaskStatusByLineId(Long lineId) {
return this.patrolTaskStatusMapper.selectPatrolTaskStatusByLineId(lineId);
}
public PatrolTaskStatus selectPatrolTaskStatusByTaskPatrolledId(String taskPatrolledId) {
return this.patrolTaskStatusMapper.selectPatrolTaskStatusByTaskPatrolledId(taskPatrolledId);
}
public List<PatrolTaskStatus> selectPatrolTaskStatusList(PatrolTaskStatus patrolTaskStatus) {
return this.patrolTaskStatusMapper.selectPatrolTaskStatusList(patrolTaskStatus);
}
public List<PatrolTaskStatus> selectPatrolTaskStatusCount(PatrolTaskStatus patrolTaskStatus) {
return this.patrolTaskStatusMapper.selectPatrolTaskStatusCount(patrolTaskStatus);
}
public List<TaskCount> selectCountList(PatrolTaskStatus patrolTaskStatus) {
return this.patrolTaskStatusMapper.selectCountList(patrolTaskStatus);
}
@Override
public List<TaskCount> selectCountListByDate(PatrolTaskStatus patrolTaskStatus) {
return this.patrolTaskStatusMapper.selectCountListByDate(patrolTaskStatus);
}
@TaskStatusChange(targetState = "1", async = true) // "1"表示已完成状态
public int insertPatrolTaskStatus(PatrolTaskStatus patrolTaskStatus) {
patrolTaskStatus.setCreateTime(new Date());
patrolTaskStatus.setStartTime(new Date());
return this.patrolTaskStatusMapper.insertPatrolTaskStatus(patrolTaskStatus);
}
@Override
@TaskStatusChange(targetState = "1", async = true) // "1"表示已完成状态
public int updatePatrolTaskStatus(PatrolTaskStatus patrolTaskStatus) {
log.info(Color.RED + "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" + Color.END);
log.info("patrolTaskStatus: {}", patrolTaskStatus);
return this.patrolTaskStatusMapper.updatePatrolTaskStatus(patrolTaskStatus);
}
public int updatePatrolTaskStatusOfTaskProgress(PatrolTaskStatus patrolTaskStatus) {
return this.patrolTaskStatusMapper.updatePatrolTaskStatusOfTaskProgress(patrolTaskStatus);
}
@TaskStatusChange(targetState = "1", async = true) // "1"表示已完成状态
public int updatePatrolTaskStatusOfTaskState(PatrolTaskStatus patrolTaskStatus) {
return this.patrolTaskStatusMapper.updatePatrolTaskStatusOfTaskState(patrolTaskStatus);
}
public int updatePatrolTaskStatusOfTaskStateAndEndTime(PatrolTaskStatus patrolTaskStatus) {
return this.patrolTaskStatusMapper.updatePatrolTaskStatusOfTaskStateAndEndTime(patrolTaskStatus);
}
public int updatePatrolTaskStatusRunning(PatrolTaskStatus patrolTaskStatus) {
return this.patrolTaskStatusMapper.updatePatrolTaskStatusRunning(patrolTaskStatus);
}
public int deletePatrolTaskStatusByLineIds(Long[] lineIds) {
return this.patrolTaskStatusMapper.deletePatrolTaskStatusByLineIds(lineIds);
}
public int deletePatrolTaskStatusByLineId(Long lineId) {
return this.patrolTaskStatusMapper.deletePatrolTaskStatusByLineId(lineId);
}
@Override
public int insertIgnorePatrolTaskStatus(PatrolTaskStatus patrolTaskStatusMain) {
return this.patrolTaskStatusMapper.insertIgnorePatrolTaskStatus(patrolTaskStatusMain);
}
@Override
public List<PatrolTaskStatus> selectPatrolTaskStatusListByMainId(String taskPatrolledId) {
return this.patrolTaskStatusMapper.selectPatrolTaskStatusListByMainId(taskPatrolledId);
}
@Override
public PatrolTaskStatus selectPatrolTaskStatusMain(String taskPatrolledId) {
return patrolTaskStatusMapper.selectPatrolTaskStatusMain(taskPatrolledId);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateTaskProgress(Long lineId, String collectionProgress, String algorithmProgress, String state) {
log.info("==========updateTaskProgress=============== lineId: {}", lineId);
if (lineId == null) {
throw new IllegalArgumentException("lineId 不能为空");
}
// 查找任务
PatrolTaskStatus patrolTaskStatus = selectPatrolTaskStatusByLineId(lineId);
if (patrolTaskStatus == null) {
throw new IllegalArgumentException("执行任务不存在,lineId: " + lineId);
}
// 主任务由子任务更新
if (TaskType.MAIN.getCode().equals(patrolTaskStatus.getTaskType())) {
throw new IllegalArgumentException("主任务进度/状态由子任务自动计算,不能直接修改:" + patrolTaskStatus.getTaskPatrolledId());
}
patrolTaskStatus.setTaskProgress(collectionProgress);
patrolTaskStatus.setTaskEstimatedTime(algorithmProgress);
patrolTaskStatus.setTaskState(state);
setNormalTaskStatus(patrolTaskStatus);
// 更新子任务或普通任务
updatePatrolTaskStatus(patrolTaskStatus);
log.info("updateTaskProgress: {}", patrolTaskStatus);
// 如果是子任务需要同步更新主任务
if (TaskType.SUB.getCode().equals(patrolTaskStatus.getTaskType()) && patrolTaskStatus.getMainId() != null) {
updateMainTask(patrolTaskStatus.getMainId(), patrolTaskStatus.getTaskCode());
}
}
private void updateMainTask(String mainId, String taskCode) {
// 查找子任务
List<PatrolTaskStatus> subTasks = selectPatrolTaskStatusListByMainId(mainId);
if (subTasks.isEmpty()) {
return;
}
PatrolTaskStatus mainTask = selectPatrolTaskStatusByTaskPatrolledId(mainId);
BigDecimal execTotalPoints = BigDecimal.ZERO;
BigDecimal execTotalAlgorithms = BigDecimal.ZERO;
TaskStatus mainTaskState = TaskStatus.DONE;
// 计算平均进度
for (PatrolTaskStatus subTask : subTasks) {
String[] taskNames = subTask.getTaskName().split("@");
log.info("taskNames: {}", subTask.getTaskName());
if (taskNames.length > 1) {
String sendCode = taskNames[0];
// 指定任务算法
List<String> algList = patrolResultService.selectAlgList(taskCode, sendCode, mainTask.getSpecifiedAlg());
int subTotalPoints = algList.size();
int subTotalAlgorithms = algList.stream().mapToInt(s -> s.split(",").length).sum();
BigDecimal subTaskProgress = BigDecimalUtil.toBigDecimal(subTask.getTaskProgress());
BigDecimal subAlgorithmProgress = BigDecimalUtil.toBigDecimal(subTask.getTaskEstimatedTime());
BigDecimal subExecPoints = subTaskProgress.multiply(new BigDecimal(subTotalPoints)).divide(BigDecimal.valueOf(100), 1, RoundingMode.DOWN);
BigDecimal subExecAlgorithms = subAlgorithmProgress.multiply(new BigDecimal(subTotalAlgorithms)).divide(BigDecimal.valueOf(100), 1, RoundingMode.DOWN);
execTotalPoints = execTotalPoints.add(subExecPoints);
execTotalAlgorithms = execTotalAlgorithms.add(subExecAlgorithms);
log.info("subTotalPoints:{},subTotalAlgorithms:{},execTotalPoints:{},execTotalAlgorithms:{}", subTotalPoints, subTotalAlgorithms, execTotalPoints, execTotalAlgorithms);
}
// 按状态优先级设置主任务状态
TaskStatus subTaskState = TaskStatus.fromCode(subTask.getTaskState());
if (subTaskState == null) {
continue;
}
if (mainTaskState.getPriority() > subTaskState.getPriority()) {
mainTaskState = subTaskState;
}
}
List<String> algList = patrolResultService.selectAlgList(taskCode, null, mainTask.getSpecifiedAlg());
int totalPoints = algList.size();
int totalAlgorithms = algList.stream().mapToInt(s -> s.split(",").length).sum();
log.info("totalPoints:{},totalAlgorithms:{}", totalPoints, totalAlgorithms);
BigDecimal mainTaskProgress = execTotalPoints
.multiply(BigDecimal.valueOf(100))
.divide(
BigDecimal.valueOf(totalPoints),
1, RoundingMode.DOWN
);
BigDecimal mainAlgorithmProgress = execTotalAlgorithms
.multiply(BigDecimal.valueOf(100))
.divide(
BigDecimal.valueOf(totalAlgorithms),
1, RoundingMode.DOWN
);
// 如果状态为已完成但采集和分析进度小于100说明还有任务未上报更新为运行中
if (mainTaskState.getCode().equals(TaskStatus.DONE.getCode())
&& (mainTaskProgress.compareTo(new BigDecimal(100)) != 0 || mainAlgorithmProgress.compareTo(new BigDecimal(100)) != 0)) {
mainTaskState = TaskStatus.RUNNING;
}
mainTask.setTaskState(mainTaskState.getCode());
mainTask.setTaskProgress(mainTaskProgress.toString());
mainTask.setTaskEstimatedTime(mainAlgorithmProgress.toString());
setNormalTaskStatus(mainTask);
// 更新主任务
patrolTaskStatusMapper.updatePatrolTaskStatus(mainTask);
}
// 生成巡视归档记录
@Override
public int generateTaskResultMain(PatrolTaskStatus patrolTaskStatus) {
int mainId = -1;
if (patrolTaskStatus != null && !patrolTaskStatus.getTaskType().equals(TaskType.SUB.getCode())) {
PatrolTaskResultMain taskResultMain = new PatrolTaskResultMain();
taskResultMain.setTaskId(patrolTaskStatus.getTaskCode());
taskResultMain.setTaskCode(patrolTaskStatus.getTaskCode());
taskResultMain.setTaskTime(patrolTaskStatus.getStartTime());
taskResultMain.setTaskPatrolledId(patrolTaskStatus.getTaskPatrolledId());
taskResultMain.setTaskName(patrolTaskStatus.getTaskName());
taskResultMain.setCreateBy("sys");
taskResultMain.setCreateTime(new Date());
taskResultMain.setFileStatus("0");
PatrolTask patrolTask = patrolTaskService.selectPatrolTaskByTaskId(Long.valueOf(patrolTaskStatus.getTaskCode()));
taskResultMain.setTaskType(patrolTask.getType());
taskResultMain.setDevType(patrolTask.getDevType());
if (patrolTask != null && StringUtils.isNotEmpty(patrolTask.getAreaName())) {
taskResultMain.setAreaName(patrolTask.getAreaName());
}
taskResultMain.setUnifiedTaskPatrolledId(patrolTaskStatus.getTaskPatrolledId());
mainId = patrolTaskResultMainService.insertPatrolTaskResultMain(taskResultMain);
log.info("生成巡视归档记录: {}", taskResultMain);
} else {
log.info("子任务不生成归档记录!");
}
return mainId;
}
private String getTaskPointsSummary(String taskCode, String taskPatrolledId, String specifiedAlg) {
// 任务总点位和算法
List<Map<String, String>> totalPointList = patrolTaskStatusMapper.selectTotalPointsAndAlgs(taskCode);
// 任务指定算法类型
if (StringUtils.isNotEmpty(specifiedAlg)) {
Map<String, String> algorithmInfo = patrolResultService.selectAlgorithmInfo(specifiedAlg);
totalPointList.stream().forEach(item -> item.put("alg_subtype_ids", algorithmInfo.get("alg_subtype_id")));
}
// 任务已巡检点位和算法
List<Map<String, String>> executedPointList = patrolTaskStatusMapper.selectExecutedPointsAndAlgs(taskPatrolledId);
return countInspectedPoint(totalPointList, executedPointList);
}
/**
* 统计点位巡检情况
*
* @param data1List 总点位和算法
* @param data2List 已执行点位和算法
* @return
*/
private String countInspectedPoint(List<Map<String, String>> data1List, List<Map<String, String>> data2List) {
Map<String, Set<String>> data2Map = new HashMap<>();
for (Map<String, String> row : data2List) {
String pid = String.valueOf(row.get("patrol_point_id"));
String subtype = String.valueOf(row.get("alg_subtype_id"));
data2Map.computeIfAbsent(pid, k -> new HashSet<>()).add(subtype);
}
// 遍历 data1检查每个 patrol_point_id 是否全部子类型都存在
int count = 0;
for (Map<String, String> row : data1List) {
String pid = String.valueOf(row.get("patrol_point_id"));
String idsStr = String.valueOf(row.get("alg_subtype_ids"));
if (idsStr == null || idsStr.trim().isEmpty()) {
continue; // 空则跳过
}
// 解析逗号分隔的 alg_subtype_ids
Set<String> requiredSet = new HashSet<>();
for (String s : idsStr.split(",")) {
String trim = s.trim();
if (!trim.isEmpty()) {
requiredSet.add(trim);
}
}
// 判断是否是 data2 的子集
Set<String> availableSet = data2Map.get(pid);
if (availableSet != null && availableSet.containsAll(requiredSet)) {
count++;
}
}
JSONObject result = new JSONObject();
result.put("totalPoint", data1List.size());
result.put("executedPoint", count);
result.put("unexecutedPoint", (data1List.size() - count));
return result.toJSONString();
}
private void setNormalTaskStatus(PatrolTaskStatus patrolTaskStatus) {
// 任务最终状态已完成已终止
boolean isFinalState = TaskStatus.DONE.getCode().equals(patrolTaskStatus.getTaskState()) || TaskStatus.HALTED.getCode().equals(patrolTaskStatus.getTaskState());
// 常规任务主任务普通任务
boolean isNormalTask = TaskType.ORDINARY.getCode().equals(patrolTaskStatus.getTaskType()) || TaskType.MAIN.getCode().equals(patrolTaskStatus.getTaskType());
// 更新任务结束时间和redis任务执行标识
if (isFinalState) {
String endTime = DateUtils.parseDateToStr(DateUtils.yyyyMMddHHmmss2, new Date());
patrolTaskStatus.setEndTime(endTime);
if (isNormalTask) {
redisService.deleteObjectOfTask(RedisConst.TASK_CURRENT_CODE, patrolTaskStatus.getTaskCode());
}
}
// 更新的点位汇总信息
if (isNormalTask) {
String summary = getTaskPointsSummary(patrolTaskStatus.getTaskCode(), patrolTaskStatus.getTaskPatrolledId(), patrolTaskStatus.getSpecifiedAlg());
patrolTaskStatus.setSummary(summary);
}
}
} }

+ 5
- 3
inspect-main/inspect-main-task/src/main/resources/mapper/task/InspectionReportDataMapper.xml View File

@ -21,6 +21,7 @@
<result property="algName" column="alg_name"/> <result property="algName" column="alg_name"/>
<result property="taskName" column="task_name"/> <result property="taskName" column="task_name"/>
<result property="taskPatrolledId" column="task_patrolled_id"/> <result property="taskPatrolledId" column="task_patrolled_id"/>
<result property="taskResultId" column="task_result_id"/>
</resultMap> </resultMap>
<sql id="selectInspectionReportDataVo"> <sql id="selectInspectionReportDataVo">
@ -39,7 +40,8 @@
inspection_img, inspection_img,
alg_name, alg_name,
task_name, task_name,
task_patrolled_id
task_patrolled_id,
task_result_id
from inspection_report_data from inspection_report_data
</sql> </sql>
@ -162,11 +164,11 @@
</delete> </delete>
<insert id="batchInsertInspectionReportData" parameterType="java.util.List"> <insert id="batchInsertInspectionReportData" parameterType="java.util.List">
insert into inspection_report_data insert into inspection_report_data
(line_id,code,report_id,area,time_interval,eq_name,parts,point_name,data_sources,acquisition_time,inspection_results,point_status,inspection_img,alg_name,task_name,task_patrolled_id)
(line_id,code,report_id,area,time_interval,eq_name,parts,point_name,data_sources,acquisition_time,inspection_results,point_status,inspection_img,alg_name,task_name,task_patrolled_id,task_result_id)
values values
<foreach collection="list" item="t" index="index" separator=","> <foreach collection="list" item="t" index="index" separator=",">
(#{t.lineId}, #{t.code}, #{t.reportId}, #{t.area}, #{t.timeInterval}, #{t.eqName}, #{t.parts}, (#{t.lineId}, #{t.code}, #{t.reportId}, #{t.area}, #{t.timeInterval}, #{t.eqName}, #{t.parts},
#{t.pointName},#{t.dataSources},#{t.acquisitionTime},#{t.inspectionResults},#{t.pointStatus},#{t.inspectionImg},#{t.algName},#{t.taskName},#{t.taskPatrolledId})
#{t.pointName},#{t.dataSources},#{t.acquisitionTime},#{t.inspectionResults},#{t.pointStatus},#{t.inspectionImg},#{t.algName},#{t.taskName},#{t.taskPatrolledId},#{t.taskResultId})
</foreach> </foreach>
</insert> </insert>
</mapper> </mapper>

+ 37
- 4
inspect-main/inspect-main-task/src/main/resources/mapper/task/MaintainRegionMapper.xml View File

@ -14,6 +14,7 @@
<result property="endTime" column="end_time"/> <result property="endTime" column="end_time"/>
<result property="deviceLevel" column="device_level"/> <result property="deviceLevel" column="device_level"/>
<result property="deviceList" column="device_list"/> <result property="deviceList" column="device_list"/>
<result property="deviceNames" column="device_names"/>
<result property="coordinatePixel" column="coordinate_pixel"/> <result property="coordinatePixel" column="coordinate_pixel"/>
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
<result property="pointList" column="point_list"/> <result property="pointList" column="point_list"/>
@ -35,7 +36,7 @@
from maintain_region from maintain_region
</sql> </sql>
<select id="selectMaintainRegionList" parameterType="MaintainRegion" resultMap="MaintainRegionResult">
<select id="selectMaintainRegionList1" parameterType="MaintainRegion" resultMap="MaintainRegionResult">
<include refid="selectMaintainRegionVo"/> <include refid="selectMaintainRegionVo"/>
<where> <where>
<if test="stationName != null and stationName != ''">and station_name like concat('%', #{stationName}, <if test="stationName != null and stationName != ''">and station_name like concat('%', #{stationName},
@ -44,8 +45,35 @@
<if test="stationCode != null and stationCode != ''">and station_code = #{stationCode}</if> <if test="stationCode != null and stationCode != ''">and station_code = #{stationCode}</if>
<if test="configCode != null and configCode != ''">and config_code = #{configCode}</if> <if test="configCode != null and configCode != ''">and config_code = #{configCode}</if>
<if test="enable != null and enable != ''">and enable = #{enable}</if> <if test="enable != null and enable != ''">and enable = #{enable}</if>
<if test="startTime != null ">and start_time = #{startTime}</if>
<if test="endTime != null ">and end_time = #{endTime}</if>
<if test="startTime != null ">and start_time &gt;= #{beginTime, jdbcType=TIMESTAMP}</if>
<if test="endTime != null ">and end_time &lt;= #{endTime, jdbcType=TIMESTAMP}</if>
<if test="deviceLevel != null and deviceLevel != ''">and device_level = #{deviceLevel}</if>
<if test="deviceList != null and deviceList != ''">and device_list like concat('%',#{deviceList},'%')</if>
<if test="pointList != null and pointList != ''">and point_list like concat('%',#{pointList},'%')</if>
<if test="coordinatePixel != null and coordinatePixel != ''">and coordinate_pixel = #{coordinatePixel}</if>
</where>
ORDER BY line_id desc
</select>
<select id="selectMaintainRegionList" parameterType="MaintainRegion" resultMap="MaintainRegionResult">
SELECT
r.*,
(
SELECT GROUP_CONCAT(a.area_name ORDER BY FIND_IN_SET(a.area_id, r.device_list))
FROM basedata_area a
WHERE FIND_IN_SET(a.area_id, r.device_list)
) AS device_names
FROM maintain_region r
<where>
<if test="stationName != null and stationName != ''">and station_name like concat('%', #{stationName},
'%')
</if>
<if test="stationCode != null and stationCode != ''">and station_code = #{stationCode}</if>
<if test="configCode != null and configCode != ''">and config_code = #{configCode}</if>
<if test="enable != null and enable != ''">and enable = #{enable}</if>
<if test="startTime != null ">and start_time &lt;= #{startTime, jdbcType=TIMESTAMP}</if>
<if test="endTime != null ">and end_time &gt;= #{endTime, jdbcType=TIMESTAMP}</if>
<if test="deviceLevel != null and deviceLevel != ''">and device_level = #{deviceLevel}</if> <if test="deviceLevel != null and deviceLevel != ''">and device_level = #{deviceLevel}</if>
<if test="deviceList != null and deviceList != ''">and device_list like concat('%',#{deviceList},'%')</if> <if test="deviceList != null and deviceList != ''">and device_list like concat('%',#{deviceList},'%')</if>
<if test="pointList != null and pointList != ''">and point_list like concat('%',#{pointList},'%')</if> <if test="pointList != null and pointList != ''">and point_list like concat('%',#{pointList},'%')</if>
@ -59,7 +87,12 @@
where line_id = #{lineId} where line_id = #{lineId}
</select> </select>
<insert id="insertMaintainRegion" parameterType="MaintainRegion">
<select id="checkConfigCodeUnique" resultType="com.inspect.base.core.domain.maintain.MaintainRegion">
<include refid="selectMaintainRegionVo"/>
where config_code = #{configCode}
</select>
<insert id="insertMaintainRegion" parameterType="MaintainRegion" useGeneratedKeys="true" keyProperty="lineId">
insert into maintain_region insert into maintain_region
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="lineId != null">line_id,</if> <if test="lineId != null">line_id,</if>


+ 204
- 8
inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolResultMapper.xml View File

@ -174,6 +174,7 @@
<result property="resStatus" column="res_status"/> <result property="resStatus" column="res_status"/>
<result property="deviceName" column="device_name"/> <result property="deviceName" column="device_name"/>
<result property="areaName" column="area_name"/> <result property="areaName" column="area_name"/>
<result property="areaId" column="area_id"/>
<result property="algType" column="alg_type"/> <result property="algType" column="alg_type"/>
<result property="objectId" column="objectId"/> <result property="objectId" column="objectId"/>
<result property="algName" column="alg_name"/> <result property="algName" column="alg_name"/>
@ -214,6 +215,7 @@
ORDER BY line_id desc ORDER BY line_id desc
</select> </select>
<select id="selectPatrolDataResultByTaskCodeV2" parameterType="ResultAnalysis" resultMap="PatrolDataResult"> <select id="selectPatrolDataResultByTaskCodeV2" parameterType="ResultAnalysis" resultMap="PatrolDataResult">
select select
b.line_id , b.line_id ,
@ -274,9 +276,15 @@
left join basedata_eqpbook h on f.eqp_book_id = h.eqp_book_id left join basedata_eqpbook h on f.eqp_book_id = h.eqp_book_id
</if> </if>
<where> <where>
<if test="taskPatrolId != null and taskPatrolId != ''">
and a.task_patrolled_id=#{taskPatrolId}
and b.task_patrol_id=#{taskPatrolId}
<if test="taskPatrolIds != null and !taskPatrolIds.isEmpty()">
and a.task_patrolled_id IN
<foreach collection="taskPatrolIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
and b.task_patrol_id IN
<foreach collection="taskPatrolIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if> </if>
<if test="objectId != null and objectId != ''">and b.objectId=#{objectId}</if> <if test="objectId != null and objectId != ''">and b.objectId=#{objectId}</if>
<if test="result != null and result != ''">and b.result = #{result}</if> <if test="result != null and result != ''">and b.result = #{result}</if>
@ -320,8 +328,6 @@
</where> </where>
<if test="abnormal == 0">ORDER BY d.device_name,a.device_name</if> <if test="abnormal == 0">ORDER BY d.device_name,a.device_name</if>
<if test="abnormal == 1">ORDER BY b.point_status</if> <if test="abnormal == 1">ORDER BY b.point_status</if>
</select> </select>
<select id="selectPatrolDataResultByTaskCodeList" parameterType="PatrolResult" resultMap="PatrolDataResult"> <select id="selectPatrolDataResultByTaskCodeList" parameterType="PatrolResult" resultMap="PatrolDataResult">
@ -424,6 +430,48 @@
<if test="password != null and password != ''">and password = #{password}</if> <if test="password != null and password != ''">and password = #{password}</if>
</where> </where>
</select> </select>
<select id="selectCamera" parameterType="com.inspect.system.base.openDomain.BasedataEqpBookMoMain"
resultMap="BasedataEqpBookResult">
SELECT
a.eqp_book_id,
a.station_name,
a.station_code,
a.area_id,
a.area_name,
b.channel_name AS patrol_device_name,
b.patrol_device_code,
b.up_system_device_code,
a.device_model,
a.manufacturer,
a.use_unit,
b.device_source,
a.production_date,
a.production_code,
a.is_transport,
ifnull(a.use_mode,b.use_mode) as use_mode,
ifnull(a.video_mode,b.video_mode) as video_mode,
a.place,
a.position_x,
a.position_y,
a.position_z,
a.type,
a.patrol_device_info,
a.robots_code,
b.HOST AS ip_addr,
b.PORT as port,
b.username AS user,
b.`password`,
a.main_system_code
from basedata_eqpbook a
left join basedata_eqpbook_channel b on a.eqp_book_id = b.eqp_book_id
where type in
<foreach item="algIda" collection="algId" open="(" separator="," close=")">
#{algIda}
</foreach>
</select>
<select id="selectPatroByAllDev" parameterType="PatrolResult" resultMap="PatrolResultResult"> <select id="selectPatroByAllDev" parameterType="PatrolResult" resultMap="PatrolResultResult">
select a.*,c.area_name from patrol_result a select a.*,c.area_name from patrol_result a
left JOIN basedata_patrolpoint b on a.device_id=b.patrol_point_id left JOIN basedata_patrolpoint b on a.device_id=b.patrol_point_id
@ -609,6 +657,7 @@
</select> </select>
<resultMap type="PatrolResultRef" id="PatrolResultRef"> <resultMap type="PatrolResultRef" id="PatrolResultRef">
<result property="lineId" column="line_id"/> <result property="lineId" column="line_id"/>
<result property="mainId" column="main_id"/>
<result property="deviceId" column="device_id"/> <result property="deviceId" column="device_id"/>
<result property="taskName" column="task_name"/> <result property="taskName" column="task_name"/>
<result property="devType" column="dev_type"/> <result property="devType" column="dev_type"/>
@ -649,6 +698,7 @@
<select id="selectResultRefByLineIds" resultMap="PatrolResultRef"> <select id="selectResultRefByLineIds" resultMap="PatrolResultRef">
select a.line_id, select a.line_id,
a.main_id,
a.device_id, a.device_id,
a.task_name, a.task_name,
c.dev_type, c.dev_type,
@ -663,6 +713,7 @@
b.result_type, b.result_type,
b.task_patrol_id, b.task_patrol_id,
a.value_unit, a.value_unit,
a.unit,
b.result_content, b.result_content,
b.alg_type, b.alg_type,
d.alg_subtype_name as alg_name d.alg_subtype_name as alg_name
@ -1270,8 +1321,153 @@
</select> </select>
<select id="selectAlgList" parameterType="String" resultType="String"> <select id="selectAlgList" parameterType="String" resultType="String">
SELECT alg_subtype_ids FROM basedata_patrolpoint WHERE patrol_point_id IN (
SELECT device_id FROM patrol_task_info WHERE task_major_id = #{taskId}
)
SELECT p.alg_subtype_ids FROM basedata_patrolpoint p
LEFT JOIN patrol_task_info i ON p.patrol_point_id = i.device_id
LEFT JOIN basedata_eqpbook e ON i.ebook_id = e.eqp_book_id
<where>
<if test="taskCode != null and taskCode != ''">and i.task_major_id = #{taskCode}</if>
<if test="sendCode != null and sendCode != ''">and e.main_system_code = #{sendCode}</if>
<if test="devType != null and devType != ''">and i.dev_type = #{devType}</if>
</where>
</select>
<select id="selectPatrolDataResultByTaskCodeV3" parameterType="ResultAnalysis" resultMap="PatrolDataResult">
SELECT
b.line_id,
a.device_name AS point_name,
a.device_id AS point_id,
a.create_time AS patrol_time,
b.point_status,
b.result_type AS warn_status,
b.description AS `desc`,
<if test="filter == 0 ">a.file_path as img,</if>
<if test="filter == 1 ">b.res_img_url as img,</if>
<if test="filter == null or filter ==''">
case when b.filter = 0 then a.file_path else b.res_img_url end as img,
</if>
b.image_normal_url_path,
a.file_path,
a.file_type AS img_type,
a.data_type,
b.filter,
b.request_id,
b.res_img_url AS img_analysis,
b.original_value,
b.res_status,
d.device_name,
e.area_name,
e.area_id,
b.alg_type,
b.objectId,
b.suggestion,
b.res_value,
s.pos_type,
b.task_patrol_id,
CASE
WHEN s.pos_type = '0' THEN g.channel_name
ELSE h.patrol_device_name
END AS channel_name,
CASE
WHEN s.pos_type = '0' THEN g.device_source
ELSE h.device_source
END AS device_source
FROM patrol_result a
INNER JOIN result_analysis b
ON a.line_id = b.business_id
LEFT JOIN basedata_patrolpoint c
ON a.device_id = c.patrol_point_id
LEFT JOIN basedata_device d
ON c.device_id = d.device_id
LEFT JOIN basedata_area e
ON e.area_id = d.area_id
LEFT JOIN patrol_task_status s
ON s.task_patrolled_id = a.task_patrolled_id
LEFT JOIN patrol_preset_pos f1
ON s.pos_type = '0'
AND c.patrol_point_id = f1.patrol_point_id
LEFT JOIN basedata_eqpbook_channel g
ON f1.channel_id = g.channel_id
<if test="channelName != null and channelName != ''">and g.channel_name like concat('%',
#{channelName}, '%')
</if>
<if test="deviceSource != null and deviceSource != ''">and g.device_source like concat('%',
#{deviceSource}, '%')
</if>
LEFT JOIN basedata_patrolpoint_preset f2
ON s.pos_type != '0'
AND c.patrol_point_id = f2.patrol_point_id
LEFT JOIN basedata_eqpbook h
ON f2.eqp_book_id = h.eqp_book_id
<if test="channelName != null and channelName != ''">and h.patrol_device_name like concat('%',
#{channelName}, '%')
</if>
<if test="deviceSource != null and deviceSource != ''">and h.device_source like concat('%',
#{deviceSource}, '%')
</if>
<where>
(g.channel_id IS NOT NULL OR h.eqp_book_id IS NOT NULL)
<if test="taskPatrolIds != null and !taskPatrolIds.isEmpty()">
and a.task_patrolled_id IN
<foreach collection="taskPatrolIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
and b.task_patrol_id IN
<foreach collection="taskPatrolIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="pointStatusList != null and !pointStatusList.isEmpty()">
and b.point_status IN
<foreach collection="pointStatusList" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
<if test="objectId != null and objectId != ''">and b.objectId=#{objectId}</if>
<if test="result != null and result != ''">and b.result = #{result}</if>
<if test="resultType != null and resultType != ''">and b.result_type =
#{resultType}
</if>
<if test="filter != null and filter != ''">
and b.filter = #{filter}
</if>
<if test="resCode != null and resCode!= ''">
and b.res_code=#{resCode}
</if>
<if test="pointStatus != null and pointStatus != ''">
and b.point_status = #{pointStatus}
</if>
<if test="pointName != null and pointName != ''">and a.device_name like concat('%', #{pointName}, '%')</if>
<if test="deviceName != null and deviceName != ''">and d.device_name like concat('%', #{deviceName}, '%')
</if>
</where>
<if test="abnormal == 0">ORDER BY d.device_name,a.device_name</if>
<if test="abnormal == 1">ORDER BY b.point_status</if>
</select>
<select id="selectPointAlgInfo" resultMap="AlgInfoResult">
SELECT a.alg_name, s.alg_subtype_code, s.alg_subtype_name
FROM basedata_patrolpoint p
LEFT JOIN basedata_alg_subtype s ON FIND_IN_SET(s.alg_subtype_id, p.alg_subtype_ids)
LEFT JOIN basedata_alg a ON s.alg_id = a.alg_id
WHERE p.patrol_point_id = #{patrolPointId}
</select>
<select id="selectAlgInfoByCode" resultMap="AlgInfoResult">
SELECT a.alg_name, s.alg_subtype_code, s.alg_subtype_name
FROM basedata_alg_subtype s
LEFT JOIN basedata_alg a ON s.alg_id = a.alg_id
WHERE FIND_IN_SET(s.alg_subtype_code, #{codes})
</select> </select>
</mapper> </mapper>

+ 3
- 2
inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolTaskInfoMapper.xml View File

@ -78,13 +78,14 @@
select a.*,b.device_name as devName, select a.*,b.device_name as devName,
b.device_code as deviceCode, b.device_code as deviceCode,
c.area_name as areName, c.area_name as areName,
c.area_id as areaId,
d.device_type_name as devType, d.device_type_name as devType,
d.phase as phase d.phase as phase
from patrol_task_info a from patrol_task_info a
LEFT JOIN basedata_device b on a.main_device_id=b.device_id LEFT JOIN basedata_device b on a.main_device_id=b.device_id
INNER JOIN basedata_area c on b.area_id =c.area_id
INNER JOIN basedata_devicetype d on b.device_type_id=d.device_type_id
LEFT JOIN basedata_area c on b.area_id =c.area_id
LEFT JOIN basedata_devicetype d on b.device_type_id=d.device_type_id
<where> <where>
<if test="taskMajorId != null and taskMajorId != ''">and task_major_id = #{taskMajorId}</if> <if test="taskMajorId != null and taskMajorId != ''">and task_major_id = #{taskMajorId}</if>
<if test="deviceId != null ">and device_id = #{deviceId}</if> <if test="deviceId != null ">and device_id = #{deviceId}</if>


+ 97
- 3
inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolTaskMapper.xml View File

@ -41,6 +41,9 @@
<result property="linkageState" column="linkage_state"/> <result property="linkageState" column="linkage_state"/>
<result property="isUp" column="is_up"/> <result property="isUp" column="is_up"/>
<result property="areaIdS" column="area_id_s"/> <result property="areaIdS" column="area_id_s"/>
<result property="pointType" column="point_type"/>
<result property="deviceType" column="device_type"/>
<result property="specifiedAlg" column="specified_alg"/>
</resultMap> </resultMap>
<sql id="selectPatrolTaskVo"> <sql id="selectPatrolTaskVo">
@ -80,7 +83,10 @@
is_enable, is_enable,
create_time, create_time,
drafter, drafter,
area_id_s
area_id_s,
point_type,
device_type,
specified_alg
from patrol_task from patrol_task
</sql> </sql>
@ -121,11 +127,9 @@
<if test="executionStatus != null and executionStatus != ''">and execution_status = #{executionStatus}</if> <if test="executionStatus != null and executionStatus != ''">and execution_status = #{executionStatus}</if>
<if test="taskCycle != null and taskCycle != ''">and task_cycle = #{taskCycle}</if> <if test="taskCycle != null and taskCycle != ''">and task_cycle = #{taskCycle}</if>
<if test="devNo != null and devNo != ''">and dev_no = #{devNo}</if> <if test="devNo != null and devNo != ''">and dev_no = #{devNo}</if>
<!-- <if test="devType != null and devType != ''">and dev_type = #{devType}</if>-->
<if test="devType != null and devType != ''">and find_in_set(#{devType}, dev_type)</if> <if test="devType != null and devType != ''">and find_in_set(#{devType}, dev_type)</if>
<if test="storage != null and storage != ''">and storage = #{storage}</if> <if test="storage != null and storage != ''">and storage = #{storage}</if>
<if test="areaId != null and areaId != ''">and area_id = #{areaId}</if> <if test="areaId != null and areaId != ''">and area_id = #{areaId}</if>
<!-- <if test="areaName != null and areaName != ''">and area_name = #{areaName}</if>-->
<if test="executionMode != null and executionMode != ''">and execution_mode = #{executionMode}</if> <if test="executionMode != null and executionMode != ''">and execution_mode = #{executionMode}</if>
<if test="linkageState != null and linkageState != ''">and linkage_state = #{linkageState}</if> <if test="linkageState != null and linkageState != ''">and linkage_state = #{linkageState}</if>
<if test="isUp != null and isUp != ''">and is_up = #{isUp}</if> <if test="isUp != null and isUp != ''">and is_up = #{isUp}</if>
@ -136,6 +140,9 @@
<if test="endTime != null and endTime != ''"> <if test="endTime != null and endTime != ''">
and date_format(create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d') and date_format(create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
</if> </if>
<if test="areaName != null and areaName != ''">
and CONCAT(',', area_name, ',') LIKE CONCAT('%', #{areaName}, '%')
</if>
</where> </where>
order by task_id desc order by task_id desc
</select> </select>
@ -237,6 +244,8 @@
<if test="linkageState != null">linkage_state,</if> <if test="linkageState != null">linkage_state,</if>
<if test="isUp != null">is_up,</if> <if test="isUp != null">is_up,</if>
<if test="areaIdS != null">area_id_s,</if> <if test="areaIdS != null">area_id_s,</if>
<if test="deviceType != null">device_type,</if>
<if test="pointType != null">point_type,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="stationName != null">#{stationName},</if> <if test="stationName != null">#{stationName},</if>
@ -275,6 +284,8 @@
<if test="linkageState != null">#{linkageState},</if> <if test="linkageState != null">#{linkageState},</if>
<if test="isUp != null">#{isUp},</if> <if test="isUp != null">#{isUp},</if>
<if test="areaIdS != null">#{areaIdS},</if> <if test="areaIdS != null">#{areaIdS},</if>
<if test="deviceType != null">#{deviceType},</if>
<if test="pointType != null">#{pointType},</if>
</trim> </trim>
</insert> </insert>
@ -317,6 +328,8 @@
<if test="linkageState != null">linkage_state = #{linkageState},</if> <if test="linkageState != null">linkage_state = #{linkageState},</if>
<if test="isUp != null">is_up = #{isUp},</if> <if test="isUp != null">is_up = #{isUp},</if>
<if test="areaIdS != null">area_id_s = #{areaIdS},</if> <if test="areaIdS != null">area_id_s = #{areaIdS},</if>
<if test="pointType != null">point_type = #{pointType},</if>
<if test="deviceType != null">device_type = #{deviceType},</if>
</trim> </trim>
where task_id = #{taskId} where task_id = #{taskId}
</update> </update>
@ -381,5 +394,86 @@
select station_no from basedata_station limit 1 select station_no from basedata_station limit 1
</select> </select>
<select id="selectBasedataPatrolPointList" resultType="com.alibaba.fastjson.JSONObject">
select patrol_point_id as patrolPointId,
patrol_point_code as patrolPointCode,
patrol_point_name as patrolPointName,
device_type_id as deviceTypeId,
main_device_id as mainDeviceId,
relation_main_device_id as relationMainDeviceId,
device_id as deviceId,
relation_device_id as relationDeviceId,
area_id as areaId,
relation_area_id as relationAreaId,
patrol_content as patrolContent,
purpose as purpose,
create_by as createBy,
create_time as createTime,
update_by as updateBy,
update_time as updateTime,
delete_flag as deleteFlag,
std_parol_point_id as stdPatrolPointId,
point_impt_level as pointImptLevel,
patrol_type_id as patrolTypeId,
lower_value as lowerValue,
upper_value as upperValue,
position_x as positionX,
position_y as positionY,
position_z as positionZ,
alg_subtype_ids as algSubtypeIds,
original_alg_subtype_ids as originalAlgSubtypeIds,
original_device_id as originalDeviceId,
dis_ref_picture_path as disRefPicturePath,
original_main_device_id as originalMainDeviceId,
alarm_threshold as alarmThreshold,
meter_type as meterType
from basedata_patrolpoint where patrol_point_id in
<foreach item="patrolPointId" collection="patrolPointIds" open="(" separator="," close=")">
#{patrolPointId}
</foreach>
</select>
<select id="selectBasedataPatrolPointPresetList" resultType="com.alibaba.fastjson.JSONObject">
select patrol_point_preset_id as patrolPointPresetId,
patrol_point_id as patrolPointId,
eqp_book_id as eqpBookId,
channel_id as channelId,
preset_code as presetCode,
preset_name as presetName,
create_by as createBy,
create_time as createTime,
update_by as updateBy,
update_time as updateTime,
delete_flag as deleteFlag,
patrol_device_code as patrolDeviceCode,
channel_code as channelCode,
video_nvr_code as videoNvrCode
from basedata_patrolpoint_preset where patrol_point_id in
<foreach item="patrolPointId" collection="patrolPointIds" open="(" separator="," close=")">
#{patrolPointId}
</foreach>
</select>
<select id="selectPatrolPresetPosList" resultType="com.alibaba.fastjson.JSONObject">
select preset_pos_id as presetPosId,
preset_pos_code as presetCode,
preset_pos_name as presetPosName,
eqp_book_id as eqpBookId,
patrol_device_code as patrolDeviceCode,
patrol_point_id as patrolPointId,
channel_id as channelId,
channel_code as channelCode,
channel_type as channelType,
coordinate_type as coordinateType,
stop_time as stopTime,
channel_img as channelImg,
description as description,
alg_subtype_code as algSubtypeCode,
is_enable as isEnable,
create_time as createTime,
video_nvr_code as videoNvrCode
from patrol_preset_pos where patrol_point_id in
<foreach item="patrolPointId" collection="patrolPointIds" open="(" separator="," close=")">
#{patrolPointId}
</foreach>
</select>
</mapper> </mapper>

+ 18
- 6
inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolTaskResultMainMapper.xml View File

@ -142,12 +142,12 @@
</select> </select>
<select id="selectLineIds" resultType="java.lang.Long"> <select id="selectLineIds" resultType="java.lang.Long">
select
line_id
from
patrol_task_result_main
where
unified_task_patrolled_id in (select unified_task_patrolled_id from patrol_task_result_main where line_id = #{lineId})
SELECT DISTINCT d.line_id
FROM patrol_task_result_main a
JOIN patrol_task_status b ON a.task_patrolled_id = b.task_patrolled_id
JOIN patrol_task_status c ON c.parent_id = b.line_id
JOIN patrol_task_result_main d ON c.task_patrolled_id = d.task_patrolled_id
WHERE a.line_id = #{lineId};
</select> </select>
<select id="selectLineIdsByList" resultType="java.lang.Long"> <select id="selectLineIdsByList" resultType="java.lang.Long">
@ -176,6 +176,18 @@
</foreach> </foreach>
</select> </select>
<select id="selectPatrolTaskResultMainOne" resultMap="PatrolTaskResultMainResult" parameterType="String">
select c.* from patrol_task_result_main c
where c.task_patrolled_id = (
select
CASE
WHEN a.main_id is null THEN a.task_patrolled_id
ELSE a.main_id
END
FROM patrol_task_status a
where a.task_patrolled_id = #{patrolTaskId}
)
</select>
<insert id="insertPatrolTaskResultMain" parameterType="PatrolTaskResultMain" useGeneratedKeys="true" <insert id="insertPatrolTaskResultMain" parameterType="PatrolTaskResultMain" useGeneratedKeys="true"
keyProperty="lineId"> keyProperty="lineId">


+ 240
- 7
inspect-main/inspect-main-task/src/main/resources/mapper/task/PatrolTaskStatusMapper.xml View File

@ -22,6 +22,42 @@
<result property="endTime" column="end_time"/> <result property="endTime" column="end_time"/>
<result property="execType" column="exec_type"/> <result property="execType" column="exec_type"/>
<result property="beginTime" column="beginTime"/> <result property="beginTime" column="beginTime"/>
<result property="taskType" column="task_type"/>
<result property="mainId" column="main_id"/>
<result property="specifiedAlg" column="specified_alg"/>
<collection property="children"
ofType="PatrolTaskStatus"
select="selectPatrolTaskStatusListByMainId"
column="task_patrolled_id"
/>
</resultMap>
<resultMap type="PatrolTaskStatus" id="PatrolTaskStatusResultV2">
<result property="lineId" column="line_id"/>
<result property="taskPatrolledId" column="task_patrolled_id"/>
<result property="taskName" column="task_name"/>
<result property="taskCode" column="task_code"/>
<result property="taskState" column="task_state"/>
<result property="planStartTime" column="plan_start_time"/>
<result property="startTime" column="start_time"/>
<result property="taskProgress" column="task_progress"/>
<result property="taskEstimatedTime" column="task_estimated_time"/>
<result property="description" column="description"/>
<result property="posType" column="pos_type"/>
<result property="code" column="code"/>
<result property="pos" column="pos"/>
<result property="patrolType" column="patrol_type"/>
<result property="endTime" column="end_time"/>
<result property="execType" column="exec_type"/>
<result property="taskType" column="task_type"/>
<result property="beginTime" column="beginTime"/>
<result property="mainId" column="main_id"/>
<result property="specifiedAlg" column="specified_alg"/>
<collection property="children"
ofType="PatrolTaskStatus"
select="selectPatrolTaskStatusListByMainId"
column="task_patrolled_id"
/>
</resultMap> </resultMap>
<sql id="selectPatrolTaskStatusVo"> <sql id="selectPatrolTaskStatusVo">
@ -40,7 +76,10 @@
pos_type, pos_type,
code, code,
pos, pos,
exec_type
exec_type,
task_type,
main_id,
summary
from patrol_task_status from patrol_task_status
</sql> </sql>
@ -79,9 +118,16 @@
a.pos, a.pos,
a.end_time, a.end_time,
b.type as patrol_type, b.type as patrol_type,
b.execution_status as exec_type from patrol_task_status a
LEFT JOIN patrol_task b on a.task_code=b.task_code
a.task_type,
a.main_id,
a.summary,
b.execution_status as exec_type,
b.specified_alg
from patrol_task_status a
LEFT JOIN patrol_task b on a.task_code=b.task_code
<where> <where>
<if test="filterTaskType != null and filterTaskType != ''">and a.task_type != #{filterTaskType}
</if>
<if test="taskPatrolledId != null and taskPatrolledId != ''">and a.task_patrolled_id = #{taskPatrolledId} <if test="taskPatrolledId != null and taskPatrolledId != ''">and a.task_patrolled_id = #{taskPatrolledId}
</if> </if>
<if test="taskName != null and taskName != ''"> <if test="taskName != null and taskName != ''">
@ -118,6 +164,68 @@
ORDER BY line_id desc ORDER BY line_id desc
</select> </select>
<select id="selectPatrolTaskStatusPage" resultType="com.inspect.taskstatus.domain.PatrolTaskStatus">
a.line_id,
a.task_patrolled_id,
a.task_name,
a.task_code,
a.task_state,
a.plan_start_time,
a.start_time,
a.task_progress,
a.task_estimated_time,
a.description,
a.pos_type,
a.code,
a.pos,
a.end_time,
b.type as patrol_type,
a.task_type,
a.main_id,
b.execution_status as exec_type
from patrol_task_status a
LEFT JOIN patrol_task b on a.task_code=b.task_code
LEFT JOIN
<where>
<if test="taskPatrolledId != null and taskPatrolledId != ''">and a.task_patrolled_id = #{taskPatrolledId}
</if>
<if test="taskName != null and taskName != ''">
and a.task_name like concat('%', #{taskName}, '%')
</if>
<if test="areaTaskName != null and areaTaskName != ''">
and b.area_name like concat('%', #{areaTaskName}, '%')
</if>
<if test="taskCode != null and taskCode != ''">and a.task_code = #{taskCode}</if>
<if test="taskState != null and taskState != ''">and a.task_state = #{taskState}</if>
<if test="planStartTime != null ">and a.plan_start_time = #{planStartTime}</if>
<if test="startTime != null ">
and date_format(a.start_time,'%y%m%d') >= date_format(#{startTime},'%y%m%d')
</if>
<if test="createTime != null ">and date_format(a.create_time,'%y%m%d') =
date_format(#{createTime},'%y%m%d')
</if>
<if test="taskProgress != null and taskProgress != ''">and a.task_progress = #{taskProgress}</if>
<if test="taskEstimatedTime != null and taskEstimatedTime != ''">and a.task_estimated_time =
#{taskEstimatedTime}
</if>
<if test="description != null and description != ''">and a.description = #{description}</if>
<if test="posType != null and posType != ''">and a.pos_type = #{posType}</if>
<if test="code != null and code != ''">and a.code = #{code}</if>
<if test="pos != null and pos != ''">and a.pos = #{pos}</if>
<if test="patrolType != null and patrolType != ''">and b.type = #{patrolType}</if>
<if test="beginTime != null and beginTime != ''">
and date_format(a.start_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
</if>
<if test="endTime != null and endTime != ''">
and date_format(a.start_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
</if>
AND task_type != 2
AND main_id IS NULL
</where>
ORDER BY line_id desc
</select>
<resultMap type="TaskCount" id="TaskCountResult"> <resultMap type="TaskCount" id="TaskCountResult">
<result property="callName" column="callName"/> <result property="callName" column="callName"/>
<result property="descName" column="descName"/> <result property="descName" column="descName"/>
@ -190,13 +298,57 @@
</select> </select>
<select id="selectPatrolTaskStatusByLineId" parameterType="Long" resultMap="PatrolTaskStatusResult"> <select id="selectPatrolTaskStatusByLineId" parameterType="Long" resultMap="PatrolTaskStatusResult">
<include refid="selectPatrolTaskStatusVo"/>
where line_id = #{lineId}
SELECT
pts.line_id,
pts.task_patrolled_id,
pts.end_time,
pts.patrol_type,
pts.task_name,
pts.task_code,
pts.task_state,
pts.plan_start_time,
pts.start_time,
pts.task_progress,
pts.task_estimated_time,
pts.description,
pts.pos_type,
pts.code,
pts.pos,
pts.exec_type,
pts.task_type,
pts.main_id,
pts.summary,
t.specified_alg
FROM patrol_task_status pts
LEFT JOIN patrol_task t ON pts.task_code = t.task_code
where pts.line_id = #{lineId}
</select> </select>
<select id="selectPatrolTaskStatusByTaskPatrolledId" parameterType="String" resultMap="PatrolTaskStatusResult"> <select id="selectPatrolTaskStatusByTaskPatrolledId" parameterType="String" resultMap="PatrolTaskStatusResult">
<include refid="selectPatrolTaskStatusVo"/>
where task_patrolled_id = #{taskPatrolledId}
SELECT
pts.line_id,
pts.task_patrolled_id,
pts.end_time,
pts.patrol_type,
pts.task_name,
pts.task_code,
pts.task_state,
pts.plan_start_time,
pts.start_time,
pts.task_progress,
pts.task_estimated_time,
pts.description,
pts.pos_type,
pts.code,
pts.pos,
pts.exec_type,
pts.task_type,
pts.main_id,
pts.summary,
t.specified_alg
FROM patrol_task_status pts
LEFT JOIN patrol_task t ON pts.task_code = t.task_code
WHERE pts.task_patrolled_id = #{taskPatrolledId}
</select> </select>
<select id="selectPatrolTaskStatusListByTaskPatrolledIds" <select id="selectPatrolTaskStatusListByTaskPatrolledIds"
@ -238,6 +390,39 @@
GROUP BY m.month GROUP BY m.month
ORDER BY m.month ORDER BY m.month
</select> </select>
<select id="selectPatrolTaskStatusListByMainId" resultMap="PatrolTaskStatusResult">
<include refid="selectPatrolTaskStatusVo"/>
where main_id = #{taskPatrolledId}
</select>
<select id="selectPatrolTaskStatusMain" resultMap="PatrolTaskStatusResult" parameterType="String">
select a.* from patrol_task_status a
where a.task_patrolled_id = (
SELECT
CASE
WHEN b.main_id is null THEN b.task_patrolled_id
ELSE b.main_id
END
FROM patrol_task_status b where b.task_patrolled_id = #{taskPatrolledId}
)
</select>
<select id="selectExecutedPointsAndAlgs" resultType="java.util.Map">
SELECT a.objectId AS patrol_point_id, s.alg_subtype_id
FROM result_analysis a
LEFT JOIN basedata_alg_subtype s ON a.alg_type = s.alg_subtype_code
LEFT JOIN patrol_task_status t ON a.task_patrol_id = t.task_patrolled_id
WHERE a.filter = 1
AND (t.task_patrolled_id = #{taskPatrolledId} or t.main_id = #{taskPatrolledId})
</select>
<select id="selectTotalPointsAndAlgs" resultType="java.util.Map">
SELECT p.patrol_point_id, p.alg_subtype_ids
FROM basedata_patrolpoint p
LEFT JOIN patrol_task_info i ON p.patrol_point_id = i.device_id
LEFT JOIN basedata_eqpbook e ON i.ebook_id = e.eqp_book_id
where i.task_major_id = #{taskCode}
</select>
<insert id="insertPatrolTaskStatus" parameterType="PatrolTaskStatus" useGeneratedKeys="true" keyProperty="lineId"> <insert id="insertPatrolTaskStatus" parameterType="PatrolTaskStatus" useGeneratedKeys="true" keyProperty="lineId">
insert into patrol_task_status insert into patrol_task_status
@ -258,6 +443,51 @@
<if test="endTime != null">end_time,</if> <if test="endTime != null">end_time,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="execType != null">exec_type,</if> <if test="execType != null">exec_type,</if>
<if test="taskType != null">task_type,</if>
<if test="mainId != null">main_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="taskPatrolledId != null">#{taskPatrolledId},</if>
<if test="taskName != null">#{taskName},</if>
<if test="taskCode != null">#{taskCode},</if>
<if test="taskState != null">#{taskState},</if>
<if test="planStartTime != null">#{planStartTime},</if>
<if test="startTime != null">#{startTime},</if>
<if test="taskProgress != null">#{taskProgress},</if>
<if test="taskEstimatedTime != null">#{taskEstimatedTime},</if>
<if test="description != null">#{description},</if>
<if test="posType != null">#{posType},</if>
<if test="code != null">#{code},</if>
<if test="pos != null">#{pos},</if>
<if test="patrolType != null">#{patrolType},</if>
<if test="endTime != null">#{endTime},</if>
<if test="createTime != null">#{createTime},</if>
<if test="execType != null">#{execType},</if>
<if test="taskType != null">#{taskType},</if>
<if test="mainId != null">#{mainId},</if>
</trim>
</insert>
<insert id="insertIgnorePatrolTaskStatus" useGeneratedKeys="true" keyProperty="lineId">
insert ignore into patrol_task_status
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="taskPatrolledId != null">task_patrolled_id,</if>
<if test="taskName != null">task_name,</if>
<if test="taskCode != null">task_code,</if>
<if test="taskState != null">task_state,</if>
<if test="planStartTime != null">plan_start_time,</if>
<if test="startTime != null">start_time,</if>
<if test="taskProgress != null">task_progress,</if>
<if test="taskEstimatedTime != null">task_estimated_time,</if>
<if test="description != null">description,</if>
<if test="posType != null">pos_type,</if>
<if test="code != null">code,</if>
<if test="pos != null">pos,</if>
<if test="patrolType != null">patrol_type,</if>
<if test="endTime != null">end_time,</if>
<if test="createTime != null">create_time,</if>
<if test="execType != null">exec_type,</if>
<if test="taskType != null">task_type,</if>
<if test="mainId != null">main_id,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="taskPatrolledId != null">#{taskPatrolledId},</if> <if test="taskPatrolledId != null">#{taskPatrolledId},</if>
@ -276,6 +506,8 @@
<if test="endTime != null">#{endTime},</if> <if test="endTime != null">#{endTime},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="execType != null">#{execType},</if> <if test="execType != null">#{execType},</if>
<if test="taskType != null">#{taskType},</if>
<if test="mainId != null">#{mainId},</if>
</trim> </trim>
</insert> </insert>
@ -295,6 +527,7 @@
<if test="code != null">code = #{code},</if> <if test="code != null">code = #{code},</if>
<if test="pos != null">pos = #{pos},</if> <if test="pos != null">pos = #{pos},</if>
<if test="patrolType != null">patrol_type = #{patrolType},</if> <if test="patrolType != null">patrol_type = #{patrolType},</if>
<if test="summary != null and summary != ''">summary = #{summary},</if>
<if test="endTime != null">end_time = #{endTime},</if> <if test="endTime != null">end_time = #{endTime},</if>
</trim> </trim>
where line_id = #{lineId} where line_id = #{lineId}


+ 22
- 0
inspect-main/inspect-main-task/src/main/resources/mapper/task/ResultAnalysisMapper.xml View File

@ -121,6 +121,12 @@
<if test="lineId != null and lineId != ''"> <if test="lineId != null and lineId != ''">
and line_id = #{lineId} and line_id = #{lineId}
</if> </if>
<if test="taskPatrolIds != null and !taskPatrolIds.isEmpty()">
and task_patrol_id in
<foreach item="item" index="index" collection="taskPatrolIds" separator="," open="(" close=")">
#{item}
</foreach>
</if>
</where> </where>
ORDER BY line_id desc ORDER BY line_id desc
</select> </select>
@ -629,6 +635,22 @@
) aiYcNum ) aiYcNum
</select> </select>
<select id="countResultAnalysisSummary" parameterType="java.util.List" resultType="com.inspect.analysis.domain.ResultAnalysisSummaryDTO">
SELECT
task_patrol_id as taskPatrolledId,
SUM(CASE WHEN result_type = '0' AND filter = '1' THEN 1 ELSE 0 END) as csQxNum,
SUM(CASE WHEN result_type = '0' AND filter = '0' THEN 1 ELSE 0 END) as aiQxNum,
SUM(CASE WHEN result_type = '2' AND filter = '1' THEN 1 ELSE 0 END) as csYcNum,
SUM(CASE WHEN result_type = '2' AND filter = '0' THEN 1 ELSE 0 END) as aiYcNum,
COUNT(DISTINCT CASE WHEN result_type = '0' THEN CONCAT(objectId, '_', alg_type) END) as qxNum
FROM result_analysis
WHERE task_patrol_id IN
<foreach collection="list" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
AND result_type IN ('0', '2')
GROUP BY task_patrol_id
</select>
<select id="selectTaskAbnormalDataBatch" parameterType="java.util.List" resultType="map"> <select id="selectTaskAbnormalDataBatch" parameterType="java.util.List" resultType="map">
SELECT SELECT


+ 49
- 0
inspect-metadata/src/main/java/com/inspect/metadata/area/controller/BaseDataAreaController.java View File

@ -370,6 +370,26 @@ public class BaseDataAreaController extends BaseController {
return AjaxResult.success("成功", nameSBuilder.toString()); return AjaxResult.success("成功", nameSBuilder.toString());
} }
@GetMapping({"/selectAreaNameSForTaskByAreaIdSRelation"})
public AjaxResult selectAreaNameSForTaskByAreaIdSRelation(BaseDataArea area) {
Map<String, BaseDataArea> areaMap = new HashMap<>();
List<String> list = this.paramsGetListByAreaIdS(area);
BaseDataArea areaQuery = new BaseDataArea();
List<BaseDataArea> areas = this.baseDataAreaService.selectAreaRelationList(areaQuery);
for (BaseDataArea baseDataArea : areas) {
areaMap.put(String.valueOf(baseDataArea.getAreaId()), baseDataArea);
}
Map<String, String> retHashMap = new HashMap<>();
StringBuilder nameSBuilder = new StringBuilder();
for (String areaId : list) {
this.getAreaDeviceTreeDeviceCodeRelation(areaId, areaMap, retHashMap, nameSBuilder);
}
return AjaxResult.success("成功", nameSBuilder.toString());
}
private void getAreaDeviceTreeDeviceCode(String areaId, Map<String, BaseDataArea> areaMap, Map<String, String> retHashMap, StringBuilder nameSBuilder) { private void getAreaDeviceTreeDeviceCode(String areaId, Map<String, BaseDataArea> areaMap, Map<String, String> retHashMap, StringBuilder nameSBuilder) {
if (areaMap.containsKey(areaId)) { if (areaMap.containsKey(areaId)) {
BaseDataArea area = areaMap.get(areaId); BaseDataArea area = areaMap.get(areaId);
@ -398,4 +418,33 @@ public class BaseDataAreaController extends BaseController {
} }
} }
private void getAreaDeviceTreeDeviceCodeRelation(String areaId, Map<String, BaseDataArea> areaMap, Map<String, String> retHashMap, StringBuilder nameSBuilder) {
if (areaMap.containsKey(areaId)) {
BaseDataArea area = areaMap.get(areaId);
if (area.getRelationParentId() == 0L) {
return;
}
if (area.getRelationParentId() == 1L) {
if (!retHashMap.containsKey(area.getAreaId().toString())) {
if (!retHashMap.isEmpty()) {
nameSBuilder.append(",");
nameSBuilder.append(area.getAreaName());
} else {
nameSBuilder.append(area.getAreaName());
}
retHashMap.put(area.getAreaId().toString(), area.getAreaName());
return;
}
return;
}
areaId = area.getRelationParentId().toString();
this.getAreaDeviceTreeDeviceCodeRelation(areaId, areaMap, retHashMap, nameSBuilder);
}
}
} }

+ 55
- 0
inspect-metadata/src/main/java/com/inspect/metadata/area/domain/BaseDataArea.java View File

@ -53,6 +53,29 @@ public class BaseDataArea extends BaseEntity {
private List<BaseDataArea> children = new ArrayList<>(); private List<BaseDataArea> children = new ArrayList<>();
private List<String> filterNameList; private List<String> filterNameList;
// 设备类型 编码 10: 摄像头高清视频 13无人机 0机器人
private List<String> devTypeList;
// 设备类型 字典编码
private List<Long> devTypeCodeList;
// 算法类型 编码 1: 表计 2外观 3红外
private List<String> algTypeList;
// 算法类型 字典编码
private List<Long> algTypeCodeList;
// 是否过滤未配置预置位的点位
private Boolean filterByPreset;
public Boolean getFilterByPreset() {
return filterByPreset;
}
public void setFilterByPreset(Boolean filterByPreset) {
this.filterByPreset = filterByPreset;
}
public String getOldAreaId() { public String getOldAreaId() {
return this.oldAreaId; return this.oldAreaId;
} }
@ -156,6 +179,38 @@ public class BaseDataArea extends BaseEntity {
this.filterNameList = filterNameList; this.filterNameList = filterNameList;
} }
public List<String> getDevTypeList() {
return devTypeList;
}
public void setDevTypeList(List<String> devTypeList) {
this.devTypeList = devTypeList;
}
public List<String> getAlgTypeList() {
return algTypeList;
}
public void setAlgTypeList(List<String> algTypeList) {
this.algTypeList = algTypeList;
}
public List<Long> getDevTypeCodeList() {
return devTypeCodeList;
}
public void setDevTypeCodeList(List<Long> devTypeCodeList) {
this.devTypeCodeList = devTypeCodeList;
}
public List<Long> getAlgTypeCodeList() {
return algTypeCodeList;
}
public void setAlgTypeCodeList(List<Long> algTypeCodeList) {
this.algTypeCodeList = algTypeCodeList;
}
@Override @Override
public String toString() { public String toString() {
return "BaseDataArea{" + return "BaseDataArea{" +


+ 97
- 29
inspect-metadata/src/main/java/com/inspect/metadata/eqpbook/controller/BasedataEqpBookController.java View File

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.inspect.base.core.utils.ServletUtils; import com.inspect.base.core.utils.ServletUtils;
import com.inspect.metadata.alg.domain.BasedataAlgSubtype; import com.inspect.metadata.alg.domain.BasedataAlgSubtype;
import com.inspect.metadata.alg.service.IBasedataAlgSubtypeService; 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.area.domain.BaseDataArea;
import com.inspect.metadata.eqpbook.domain.BasedataEqpBook; import com.inspect.metadata.eqpbook.domain.BasedataEqpBook;
import com.inspect.metadata.eqpbook.domain.BasedataEqpBookChannel; 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.montdata.domain.BasedataMontPatDevStaData;
import com.inspect.metadata.mqutil.FeignMsgClient; import com.inspect.metadata.mqutil.FeignMsgClient;
import com.inspect.metadata.patrolpointmnt.domain.BasedataPatrolPoint; 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.patrolpointmnt.service.IBasedataPatrolPointService;
import com.inspect.metadata.station.service.IBasedataStationService; import com.inspect.metadata.station.service.IBasedataStationService;
import com.inspect.metadata.threshold.domain.BasedataThresholdModification; import com.inspect.metadata.threshold.domain.BasedataThresholdModification;
@ -52,11 +54,7 @@ import java.io.BufferedReader;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -93,6 +91,11 @@ public class BasedataEqpBookController extends BaseController {
private IBasedataThresholdModificationService basedataThresholdModificationService; private IBasedataThresholdModificationService basedataThresholdModificationService;
@Autowired @Autowired
private FeignTaskClient feignTaskClient; private FeignTaskClient feignTaskClient;
@Autowired
private BaseDataAreaController baseDataAreaController;
@Resource
private BasedataPatrolPointMapper basedataPatrolpointMapper;
@GetMapping({"/list"}) @GetMapping({"/list"})
public TableDataInfo list(BasedataEqpBook basedataEqpbook) { public TableDataInfo list(BasedataEqpBook basedataEqpbook) {
@ -857,10 +860,44 @@ public class BasedataEqpBookController extends BaseController {
@GetMapping({"/subtypeData"}) @GetMapping({"/subtypeData"})
public TableDataInfo subtypeData(BasedataPatrolPoint basedataPatrolpoint) { 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(); this.startPage();
basedataPatrolpoint.setAlgSubtypeIds(StringUtils.join(allowedSubtypeIds, ","));
List<BasedataPatrolPoint> subtypeList = this.basedataEqpBookService.getSubtypeData(basedataPatrolpoint); List<BasedataPatrolPoint> subtypeList = this.basedataEqpBookService.getSubtypeData(basedataPatrolpoint);
List<BasedataPatrolPoint> stdList = new ArrayList<>();
// 查询区域信息
for (BasedataPatrolPoint bp : subtypeList) { for (BasedataPatrolPoint bp : subtypeList) {
List<BasedataThresholdModification> subTypeDOList = new ArrayList<>(); List<BasedataThresholdModification> subTypeDOList = new ArrayList<>();
List<JSONObject> jsonArray = JSONArray.parseArray(bp.getAlarmThreshold(), JSONObject.class); List<JSONObject> jsonArray = JSONArray.parseArray(bp.getAlarmThreshold(), JSONObject.class);
@ -870,22 +907,35 @@ public class BasedataEqpBookController extends BaseController {
} else { } else {
subs = new String[]{bp.getAlgSubtypeIds()}; 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) { 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()) { if (!subTypeDOList.isEmpty()) {
bp.setSubTypeDOList(subTypeDOList); bp.setSubTypeDOList(subTypeDOList);
stdList.add(bp); stdList.add(bp);
@ -904,23 +954,41 @@ public class BasedataEqpBookController extends BaseController {
return rspData; return rspData;
} }
private List<SysDictData> getSysDictDataList(String dictType) {
return basedataPatrolpointMapper.selectDictDataByType(dictType);
}
@PostMapping({"/subtypeUpdate"}) @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"}) @GetMapping({"/subtypeUpdateRecord"})
public TableDataInfo subtypeUpdateRecord(BasedataThresholdModification btd) { public TableDataInfo subtypeUpdateRecord(BasedataThresholdModification btd) {
this.startPage(); this.startPage();
logger.info("查询巡检点位报警阈值修改记录,{}",btd.getAlgSubtypeId());
if (btd.getAlgSubtypeId() != null) {
String[] subs;
if (btd.getAlgSubtypeId().contains(StringUtils.COMMA)) {
subs = btd.getAlgSubtypeId().split(StringUtils.COMMA);
} else {
subs = new String[]{btd.getAlgSubtypeId()};
}
btd.setAlgSubtypeIds(Arrays.asList(subs));
}
List<BasedataThresholdModification> list = this.basedataThresholdModificationService.selectBasedataThresholdModificationList(btd); List<BasedataThresholdModification> list = this.basedataThresholdModificationService.selectBasedataThresholdModificationList(btd);
return this.getDataTable(list); return this.getDataTable(list);
} }


+ 9
- 1
inspect-metadata/src/main/java/com/inspect/metadata/patrolpointmnt/controller/BasedataPatrolPointController.java View File

@ -1,5 +1,6 @@
package com.inspect.metadata.patrolpointmnt.controller; package com.inspect.metadata.patrolpointmnt.controller;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.inspect.base.core.constant.Color; import com.inspect.base.core.constant.Color;
@ -118,6 +119,7 @@ public class BasedataPatrolPointController extends BaseController {
basedataPatrolPoint2.setPointImptLevel(basedataPatrolPoint.getPointImptLevel()); basedataPatrolPoint2.setPointImptLevel(basedataPatrolPoint.getPointImptLevel());
basedataPatrolPoint2.setAlgSubtypeName(basedataPatrolPoint.getAlgSubtypeName()); basedataPatrolPoint2.setAlgSubtypeName(basedataPatrolPoint.getAlgSubtypeName());
basedataPatrolPoint2.setPurpose(basedataPatrolPoint.getPurpose()); basedataPatrolPoint2.setPurpose(basedataPatrolPoint.getPurpose());
basedataPatrolPoint2.setAlarmThreshold(basedataPatrolPoint.getAlarmThreshold());
listEx.add(basedataPatrolPoint2); listEx.add(basedataPatrolPoint2);
} }
return getDataTable(listEx); return getDataTable(listEx);
@ -162,6 +164,7 @@ public class BasedataPatrolPointController extends BaseController {
basedataPatrolPoint2.setPointImptLevel(basedataPatrolPoint.getPointImptLevel()); basedataPatrolPoint2.setPointImptLevel(basedataPatrolPoint.getPointImptLevel());
basedataPatrolPoint2.setAlgSubtypeName(basedataPatrolPoint.getAlgSubtypeName()); basedataPatrolPoint2.setAlgSubtypeName(basedataPatrolPoint.getAlgSubtypeName());
basedataPatrolPoint2.setPurpose(basedataPatrolPoint.getPurpose()); basedataPatrolPoint2.setPurpose(basedataPatrolPoint.getPurpose());
basedataPatrolPoint2.setAlarmThreshold(basedataPatrolPoint.getAlarmThreshold());
listEx.add(basedataPatrolPoint2); listEx.add(basedataPatrolPoint2);
} }
return getDataTable(listEx); return getDataTable(listEx);
@ -216,7 +219,12 @@ public class BasedataPatrolPointController extends BaseController {
basedataPatrolpoint.setRelationMainDeviceId(basedataPatrolpoint.getMainDeviceId()); basedataPatrolpoint.setRelationMainDeviceId(basedataPatrolpoint.getMainDeviceId());
basedataPatrolPointService.insertBasedataPatrolPoint(basedataPatrolpoint); basedataPatrolPointService.insertBasedataPatrolPoint(basedataPatrolpoint);
return null != basedataPatrolpoint.getPatrolPointId() ? AjaxResult.success(basedataPatrolpoint.getPatrolPointId()) : AjaxResult.error("新增异常");
if (basedataPatrolpoint.getPatrolPointId() == null) {
return AjaxResult.error("新增异常");
}
basedataPatrolpoint.setPatrolPointCode(String.valueOf(basedataPatrolpoint.getPatrolPointId()));
basedataPatrolPointService.updateBasedataPatrolPoint(basedataPatrolpoint);
return AjaxResult.success(basedataPatrolpoint.getPatrolPointId());
} }
private void combinePatrolPointByStd(BasedataPatrolPoint basedataPatrolpoint) { private void combinePatrolPointByStd(BasedataPatrolPoint basedataPatrolpoint) {


+ 7
- 0
inspect-metadata/src/main/java/com/inspect/metadata/patrolpointmnt/domain/BasedataPatrolPoint.java View File

@ -70,6 +70,7 @@ public class BasedataPatrolPoint extends BaseEntity {
@JsonProperty("stdparolPointId") @JsonProperty("stdparolPointId")
private Long stdParolPointId; private Long stdParolPointId;
private Long areaId; private Long areaId;
private String areaName;
private Long relationAreaId; private Long relationAreaId;
private String patrolTypeId; private String patrolTypeId;
private String pointImptLevel; private String pointImptLevel;
@ -120,6 +121,12 @@ public class BasedataPatrolPoint extends BaseEntity {
private String pointTypeName; private String pointTypeName;
private String pointTypeCode; private String pointTypeCode;
private String parentName;
List<Long> algTypeCodeList;
private String allowedSubtypeIds;
public void setPatrolpointName(String patrolpointName) { public void setPatrolpointName(String patrolpointName) {
this.patrolpointName = patrolpointName; this.patrolpointName = patrolpointName;
this.patrolPointName = patrolpointName; this.patrolPointName = patrolpointName;


+ 2
- 0
inspect-metadata/src/main/java/com/inspect/metadata/patrolpointmnt/mapper/BasedataPatrolPointMapper.java View File

@ -45,6 +45,8 @@ public interface BasedataPatrolPointMapper {
List<BasedataPatrolPoint> selectBasedataPatrolPointListByDeviceIds(@Param("deviceIds") List<Long> deviceIds); List<BasedataPatrolPoint> selectBasedataPatrolPointListByDeviceIds(@Param("deviceIds") List<Long> deviceIds);
List<BasedataPatrolPoint> selectBasedataPatrolPointRelationListByDeviceIds(@Param("deviceIds") List<Long> deviceIds); List<BasedataPatrolPoint> selectBasedataPatrolPointRelationListByDeviceIds(@Param("deviceIds") List<Long> deviceIds);
List<BasedataPatrolPoint> selectBasedataPatrolPointWithPresetRelationListByDeviceIds(@Param("deviceIds") List<Long> deviceIds);
void updateBasedataPatrolPointRelation(@Param("toAreaId") Long toAreaId, @Param("deviceId") Long deviceId); void updateBasedataPatrolPointRelation(@Param("toAreaId") Long toAreaId, @Param("deviceId") Long deviceId);


+ 12
- 7
inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/controller/BasedataDeviceController.java View File

@ -46,12 +46,7 @@ import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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 org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@Slf4j @Slf4j
@ -239,7 +234,7 @@ public class BasedataDeviceController extends BaseController {
filterNameList.add("新增相机"); filterNameList.add("新增相机");
} }
return !areaList.isEmpty() return !areaList.isEmpty()
? AjaxResult.success(basedataDeviceService.buildAreaDeviceTreeSelectByAreasFilterByPresetRelationRight(areaList, filterNameList))
? AjaxResult.success(basedataDeviceService.buildAreaDeviceTreeSelectByAreasFilterByPresetRelationRight(areaList, filterNameList, baseDataArea))
: AjaxResult.success(new JSONArray()); : AjaxResult.success(new JSONArray());
} }
@ -719,6 +714,16 @@ public class BasedataDeviceController extends BaseController {
return AjaxResult.success(this.mergeDeptAndEquipment(arel, maindevlist, "1")); return AjaxResult.success(this.mergeDeptAndEquipment(arel, maindevlist, "1"));
} }
@GetMapping("/treeAreaDeviceSelectByLevel")
public AjaxResult treeAreaDeviceSelectByLevel(@RequestParam(defaultValue = "0")int deviceLevel) {
log.info("deviceLevel: {}", deviceLevel);
List<BaseDataArea> areas = this.baseDataAreaService.selectAreaList(new BaseDataArea());
log.info("areas: {}", areas);
List<TreeModule> arel = this.baseDataAreaService.buildAreaTreeAgain(areas);
log.info("arel: {}", arel);
return AjaxResult.success(arel);
}
private List<TreeModule> mergeDeptAndEquipment(List<TreeModule> mainOrgList, List<TreeModule> pointOrgList, String type) { private List<TreeModule> mergeDeptAndEquipment(List<TreeModule> mainOrgList, List<TreeModule> pointOrgList, String type) {
for (TreeModule equipmentOrg : pointOrgList) { for (TreeModule equipmentOrg : pointOrgList) {


+ 10
- 0
inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/domain/vo/AreaDeviceTreeSelect.java View File

@ -46,6 +46,8 @@ public class AreaDeviceTreeSelect implements Serializable {
this.patrolPointNames = patrolPointNames; this.patrolPointNames = patrolPointNames;
} }
@JsonInclude(JsonInclude.Include.NON_NULL)
private String patrolPointCode;
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
private String patrolPointId; private String patrolPointId;
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
@ -253,6 +255,14 @@ public class AreaDeviceTreeSelect implements Serializable {
this.basedataPatrolPoints = basedataPatrolPoints; this.basedataPatrolPoints = basedataPatrolPoints;
} }
public String getPatrolPointCode() {
return patrolPointCode;
}
public void setPatrolPointCode(String patrolPointCode) {
this.patrolPointCode = patrolPointCode;
}
// public List<AreaDeviceTreeSelect> cleanEmptyPatrolPoints() { // public List<AreaDeviceTreeSelect> cleanEmptyPatrolPoints() {
// // 递归清理 // // 递归清理
// if (children != null) { // if (children != null) {


+ 1
- 1
inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/service/IBasedataDeviceService.java View File

@ -51,7 +51,7 @@ public interface IBasedataDeviceService {
List<AreaDeviceTreeSelect> buildAreaDeviceTreeSelectByAreasFilterByPreset(List<BaseDataArea> areas, List<String> filterNameList); List<AreaDeviceTreeSelect> buildAreaDeviceTreeSelectByAreasFilterByPreset(List<BaseDataArea> areas, List<String> filterNameList);
List<AreaDeviceTreeSelect> buildAreaDeviceTreeSelectByAreasFilterByPresetRelationLeft(List<BaseDataArea> areas, List<String> filterNameList); List<AreaDeviceTreeSelect> buildAreaDeviceTreeSelectByAreasFilterByPresetRelationLeft(List<BaseDataArea> areas, List<String> filterNameList);
List<AreaDeviceTreeSelect> buildAreaDeviceTreeSelectByAreasFilterByPresetRelationRight(List<BaseDataArea> areas, List<String> filterNameList);
List<AreaDeviceTreeSelect> buildAreaDeviceTreeSelectByAreasFilterByPresetRelationRight(List<BaseDataArea> areas, List<String> filterNameList, BaseDataArea baseDataArea);
List<AreaDeviceTreeSelect> buildAreaDeviceTreeSelectByAreasFilterByPresetRelation(List<BaseDataArea> areas, List<String> filterNameList); List<AreaDeviceTreeSelect> buildAreaDeviceTreeSelectByAreasFilterByPresetRelation(List<BaseDataArea> areas, List<String> filterNameList);


+ 144
- 6
inspect-metadata/src/main/java/com/inspect/metadata/prodevmnt/service/impl/BasedataDeviceServiceImpl.java View File

@ -1,5 +1,9 @@
package com.inspect.metadata.prodevmnt.service.impl; package com.inspect.metadata.prodevmnt.service.impl;
import com.inspect.base.core.enums.AlgTypeEnum;
import com.inspect.base.core.enums.DevTypeEnum;
import com.inspect.metadata.alg.domain.BasedataAlgSubtype;
import com.inspect.metadata.alg.mapper.BasedataAlgSubtypeMapper;
import com.inspect.metadata.area.domain.BaseDataArea; import com.inspect.metadata.area.domain.BaseDataArea;
import com.inspect.metadata.eqpbook.domain.BasedataEqpBook; import com.inspect.metadata.eqpbook.domain.BasedataEqpBook;
import com.inspect.metadata.eqpbook.mapper.BasedataEqpBookMapper; import com.inspect.metadata.eqpbook.mapper.BasedataEqpBookMapper;
@ -30,10 +34,13 @@ import com.inspect.base.core.utils.bean.BeanUtils;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.inspect.system.base.domain.SysDictData;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service @Service
public class BasedataDeviceServiceImpl implements IBasedataDeviceService { public class BasedataDeviceServiceImpl implements IBasedataDeviceService {
@ -51,6 +58,12 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService {
final final
BasedataDeviceTypeMapper basedataDevicetypeMapper; BasedataDeviceTypeMapper basedataDevicetypeMapper;
@Resource
private BasedataPatrolPointMapper basedataPatrolpointMapper;
@Resource
private BasedataAlgSubtypeMapper basedataAlgSubtypeMapper;
public BasedataDeviceServiceImpl(BasedataDeviceMapper basedataDeviceMapper, BasedataPatrolPointMapper basedataPatrolPointMapper, BasedataPatrolPointPresetMapper basedataPatrolPointPresetMapper, BasedataEqpBookMapper basedataEqpbookMapper, BasedataModelDeviceMapper basedataModelDeviceMapper, BasedataDeviceTypeMapper basedataDevicetypeMapper) { public BasedataDeviceServiceImpl(BasedataDeviceMapper basedataDeviceMapper, BasedataPatrolPointMapper basedataPatrolPointMapper, BasedataPatrolPointPresetMapper basedataPatrolPointPresetMapper, BasedataEqpBookMapper basedataEqpbookMapper, BasedataModelDeviceMapper basedataModelDeviceMapper, BasedataDeviceTypeMapper basedataDevicetypeMapper) {
this.basedataDeviceMapper = basedataDeviceMapper; this.basedataDeviceMapper = basedataDeviceMapper;
this.basedataPatrolPointMapper = basedataPatrolPointMapper; this.basedataPatrolPointMapper = basedataPatrolPointMapper;
@ -373,6 +386,8 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService {
patrolVO.setPatrolPointName(basedataPatrolPoint.getPatrolPointName()); patrolVO.setPatrolPointName(basedataPatrolPoint.getPatrolPointName());
patrolVO.setDeviceName(basedataPatrolPoint.getPatrolPointName()); patrolVO.setDeviceName(basedataPatrolPoint.getPatrolPointName());
patrolVO.setPatrolPointId(String.valueOf(basedataPatrolPoint.getPatrolPointId())); patrolVO.setPatrolPointId(String.valueOf(basedataPatrolPoint.getPatrolPointId()));
patrolVO.setDataId(String.valueOf(basedataPatrolPoint.getPatrolPointId()));
patrolVO.setPatrolPointCode(basedataPatrolPoint.getPatrolPointCode());
patrolPoints.add(patrolVO); patrolPoints.add(patrolVO);
} }
// 设置点位列表到节点上 // 设置点位列表到节点上
@ -498,7 +513,7 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService {
/** /**
* 与fillPointNumAndPatrolPoints区别在于查询的表不一样 此处用的是basedata_patrolpoint_relation表用于迁移数据使用 * 与fillPointNumAndPatrolPoints区别在于查询的表不一样 此处用的是basedata_patrolpoint_relation表用于迁移数据使用
*/ */
private void fillPointNumAndPatrolPointsRelation(List<AreaDeviceTreeSelect> allNodes, List<AreaDeviceTreeSelect> treeList) {
private void fillPointNumAndPatrolPointsRelation(List<AreaDeviceTreeSelect> allNodes, List<AreaDeviceTreeSelect> treeList, BaseDataArea baseDataArea) {
// 收集所有设备ID // 收集所有设备ID
Set<Long> deviceIds = new HashSet<>(); Set<Long> deviceIds = new HashSet<>();
for (AreaDeviceTreeSelect node : allNodes) { for (AreaDeviceTreeSelect node : allNodes) {
@ -509,9 +524,42 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService {
if (deviceIds.isEmpty()) { if (deviceIds.isEmpty()) {
return; return;
} }
List<BasedataPatrolPoint> patrolPoints = null;
// 批量查询点位 // 批量查询点位
List<BasedataPatrolPoint> patrolPoints = basedataPatrolPointMapper.selectBasedataPatrolPointRelationListByDeviceIds(new ArrayList<>(deviceIds));
if (baseDataArea != null && baseDataArea.getFilterByPreset() != null && baseDataArea.getFilterByPreset()) {
// 剔除掉未配置预置位的点位
patrolPoints = basedataPatrolPointMapper.selectBasedataPatrolPointWithPresetRelationListByDeviceIds(new ArrayList<>(deviceIds));
} else {
// 全部点位
patrolPoints = basedataPatrolPointMapper.selectBasedataPatrolPointRelationListByDeviceIds(new ArrayList<>(deviceIds));
}
List<BasedataAlgSubtype> basedataAlgSubtypes = basedataAlgSubtypeMapper.selectBasedataAlgSubtypeList(new BasedataAlgSubtype());
logger.info("[META] basedataAlgSubtypes cnt: {}", basedataAlgSubtypes.size());
Map<String, String> algSubtypeMap = new HashMap<>();
basedataAlgSubtypes.forEach((item) -> {
algSubtypeMap.put(item.getAlgSubtypeId() + "", item.getAlgSubtypeName());
});
List<SysDictData> dictList = getSysDictDataList("point_device_type");
Optional<SysDictData> defaultDictData = dictList.stream()
.filter(SysDictData::getDefault)
.findFirst();
for (BasedataPatrolPoint basedataPatrolPoint : patrolPoints) {
basedataPatrolPoint.loadAlgSubtypeName(algSubtypeMap);
processPointType(basedataPatrolPoint, dictList, defaultDictData);
}
if (baseDataArea != null && baseDataArea.getDevTypeCodeList() != null && baseDataArea.getDevTypeCodeList().size() > 0) {
// 设备
dictList = dictList.stream().filter(item -> baseDataArea.getDevTypeCodeList().contains(item.getDictCode())).collect(Collectors.toList());
patrolPoints = filterByDeviceTypes(patrolPoints, dictList);
}
if (baseDataArea != null && baseDataArea.getAlgTypeCodeList() != null && baseDataArea.getAlgTypeCodeList().size() > 0) {
// 算法类型
patrolPoints = filterByAlgTypes(patrolPoints, baseDataArea.getAlgTypeCodeList());
}
// 按设备ID分组 // 按设备ID分组
Map<Long, List<BasedataPatrolPoint>> devicePatrolMap = patrolPoints.stream() Map<Long, List<BasedataPatrolPoint>> devicePatrolMap = patrolPoints.stream()
.collect(Collectors.groupingBy(BasedataPatrolPoint::getRelationDeviceId)); .collect(Collectors.groupingBy(BasedataPatrolPoint::getRelationDeviceId));
@ -520,6 +568,94 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService {
setPointNumAndPatrolPoints(treeList, devicePatrolMap); setPointNumAndPatrolPoints(treeList, devicePatrolMap);
} }
private List<BasedataPatrolPoint> filterByAlgTypes(List<BasedataPatrolPoint> patrolPoints, List<Long> algTypeCodeList) {
// 获取算法分类字典dictCode=字典编码dictValue=逗号分隔的子类型ID
List<SysDictData> algCategoryDict = getSysDictDataList("point_alg_category");
// 构建字典编码 -> 子类型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);
// 合并所有允许的子类型ID
Set<String> allowedSubtypeIds = algTypeCodeList.stream()
.filter(Objects::nonNull)
.flatMap(dictCode -> labelToSubtypeIds.getOrDefault(dictCode, Collections.emptySet()).stream())
.collect(Collectors.toSet());
if (allowedSubtypeIds.isEmpty()) {
return Collections.emptyList();
}
// 筛选出那些 algSubtypeIds 字段逗号分隔的 ID 字符串中至少有一个 ID 存在于 allowedSubtypeIds 集合中的对象
return patrolPoints.stream()
.filter(point -> {
String subtypeIds = point.getAlgSubtypeIds();
if (StringUtils.isBlank(subtypeIds)) {
return false;
}
return Arrays.stream(subtypeIds.split(","))
.anyMatch(allowedSubtypeIds::contains);
})
.collect(Collectors.toList());
}
private List<BasedataPatrolPoint> filterByDeviceTypes(List<BasedataPatrolPoint> patrolPoints, List<SysDictData> dictList) {
Set<String> allowedPointTypeNames = dictList.stream().map(SysDictData::getDictLabel).collect(Collectors.toSet());
if (allowedPointTypeNames.isEmpty()) {
return Collections.emptyList();
}
return patrolPoints.stream()
.filter(point -> allowedPointTypeNames.contains(point.getPointTypeName()))
.collect(Collectors.toList());
}
private List<SysDictData> getSysDictDataList(String dictType) {
return basedataPatrolpointMapper.selectDictDataByType(dictType);
}
/**
* 处理点位的设备类型
*
* @param dictList
* @param basedataPatrolPoint
*/
private void processPointType(BasedataPatrolPoint basedataPatrolPoint, List<SysDictData> dictList, Optional<SysDictData> defaultDictData) {
String patrolPointCode = basedataPatrolPoint.getPatrolPointCode();
if (StringUtils.isNotEmpty(patrolPointCode)) {
if (patrolPointCode.contains("|")) {
String finalPatrolPointCode = patrolPointCode.substring(0, patrolPointCode.indexOf("|"));
Optional<String> pointTypeName = dictList.stream()
.filter(dict -> {
String valueStr = dict.getDictValue(); // 调用 getter
if (valueStr == null) {
return false;
}
return Arrays.stream(valueStr.split(","))
.map(String::trim)
.anyMatch(code -> code.equals(finalPatrolPointCode));
})
.map(SysDictData::getDictLabel)
.findFirst();
basedataPatrolPoint.setPointTypeName(pointTypeName.orElse("未知设备类型"));
basedataPatrolPoint.setPointTypeCode(finalPatrolPointCode);
} else {
defaultDictData.ifPresent(dict -> {
basedataPatrolPoint.setPointTypeName(dict.getDictLabel());
String[] codes = dict.getDictValue().split(",");
logger.info("[META] pointTypeCode: {}", codes);
if (codes.length > 0) {
basedataPatrolPoint.setPointTypeCode(codes[0]);
}
});
}
}
}
public List<AreaDeviceTreeSelect> buildAreaDeviceTreeSelectByAreasFilterByPresetRelation(List<BaseDataArea> areas, List<String> filterNamelist) { public List<AreaDeviceTreeSelect> buildAreaDeviceTreeSelectByAreasFilterByPresetRelation(List<BaseDataArea> areas, List<String> filterNamelist) {
ArrayList<Long> areaIdList = new ArrayList<>(); ArrayList<Long> areaIdList = new ArrayList<>();
HashMap<Long, BaseDataArea> areaMap = new HashMap<>(); HashMap<Long, BaseDataArea> areaMap = new HashMap<>();
@ -587,7 +723,7 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService {
return treeList; return treeList;
} }
public List<AreaDeviceTreeSelect> buildAreaDeviceTreeSelectByAreasFilterByPresetRelationRight(List<BaseDataArea> areas, List<String> filterNamelist) {
public List<AreaDeviceTreeSelect> buildAreaDeviceTreeSelectByAreasFilterByPresetRelationRight(List<BaseDataArea> areas, List<String> filterNamelist, BaseDataArea baseDataArea) {
ArrayList<Long> areaIdList = new ArrayList<>(); ArrayList<Long> areaIdList = new ArrayList<>();
HashMap<Long, BaseDataArea> areaMap = new HashMap<>(); HashMap<Long, BaseDataArea> areaMap = new HashMap<>();
HashMap<Long, BasedataDevice> deviceHashMap = new HashMap<>(); HashMap<Long, BasedataDevice> deviceHashMap = new HashMap<>();
@ -647,8 +783,10 @@ public class BasedataDeviceServiceImpl implements IBasedataDeviceService {
List<AreaDeviceTreeSelect> treeList = AreaDeviceTreeSelectUtil.buildDeviceTreeFilterByAreaName(areaVOS, filterNamelist); List<AreaDeviceTreeSelect> treeList = AreaDeviceTreeSelectUtil.buildDeviceTreeFilterByAreaName(areaVOS, filterNamelist);
// 新增填充点位统计 // 新增填充点位统计
fillPointNumAndPatrolPointsRelation(areaVOS, treeList);
fillPointNumAndPatrolPointsRelation(areaVOS, treeList, baseDataArea);
for (AreaDeviceTreeSelect area : treeList) {
area.cleanEmptyPatrolPoints();
}
return treeList; return treeList;
} }
public List<AreaDeviceTreeSelect> buildAreaDeviceTreeSelectByAreasFilterByMeter(List<BaseDataArea> areas) { public List<AreaDeviceTreeSelect> buildAreaDeviceTreeSelectByAreasFilterByMeter(List<BaseDataArea> areas) {


+ 4
- 0
inspect-metadata/src/main/java/com/inspect/metadata/threshold/domain/BasedataThresholdModification.java View File

@ -5,6 +5,8 @@ import com.inspect.base.core.web.domain.BaseEntity;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.List;
@Setter @Setter
@Getter @Getter
public class BasedataThresholdModification extends BaseEntity { public class BasedataThresholdModification extends BaseEntity {
@ -26,6 +28,8 @@ public class BasedataThresholdModification extends BaseEntity {
name = "算法子类型id" name = "算法子类型id"
) )
private String algSubtypeId; private String algSubtypeId;
private List<String> algSubtypeIds;
@Excel( @Excel(
name = "算法子类型名称" name = "算法子类型名称"
) )


+ 10
- 4
inspect-metadata/src/main/resources/mapper/eqpbook/BasedataEqpBookMapper.xml View File

@ -731,7 +731,8 @@
</select> </select>
<resultMap type="BasedataPatrolPoint" id="BasedataPatrolPointResult"> <resultMap type="BasedataPatrolPoint" id="BasedataPatrolPointResult">
<result property="patrolPointId" column="patrol_point_id"/> <result property="patrolPointId" column="patrol_point_id"/>
<result property="patrolPointName" column="patrolpoint_name"/>
<result property="relationAreaId" column="relation_area_id"/>
<result property="patrolPointName" column="patrol_point_name"/>
<result property="parentName" column="parent_name"/> <result property="parentName" column="parent_name"/>
<result property="alarmThreshold" column="alarm_threshold"/> <result property="alarmThreshold" column="alarm_threshold"/>
<result property="algSubtypeIds" column="alg_subtype_ids"/> <result property="algSubtypeIds" column="alg_subtype_ids"/>
@ -744,9 +745,10 @@
<select id="getSubtypeData" resultMap="BasedataPatrolPointResult"> <select id="getSubtypeData" resultMap="BasedataPatrolPointResult">
SELECT SELECT
a.patrol_point_id, a.patrol_point_id,
a.relation_area_id,
(SELECT c.device_name FROM basedata_device c WHERE c.device_id = b.parent_id) parent_name, (SELECT c.device_name FROM basedata_device c WHERE c.device_id = b.parent_id) parent_name,
b.device_name, b.device_name,
a.patrolpoint_name,
a.patrol_point_name,
a.alarm_threshold, a.alarm_threshold,
a.alg_subtype_ids, a.alg_subtype_ids,
IFNULL(a.update_time, a.create_time) AS update_time IFNULL(a.update_time, a.create_time) AS update_time
@ -757,10 +759,14 @@
a.device_id = b.device_id a.device_id = b.device_id
AND a.alarm_threshold != '' AND a.alarm_threshold != ''
AND a.alarm_threshold != '[]' AND a.alarm_threshold != '[]'
AND ( a.alarm_threshold LIKE '%52%' OR a.alarm_threshold LIKE '%53%' )
<if test="deviceName != null and deviceName != ''">and b.device_name = #{deviceName}</if> <if test="deviceName != null and deviceName != ''">and b.device_name = #{deviceName}</if>
<if test="patrolPointName != null and patrolPointName != ''">and a.patrolpoint_name = #{patrolPointName}</if>
<if test="patrolPointName != null and patrolPointName != ''">and a.patrol_point_name like concat('%',
#{patrolPointName}, '%')</if>
<if test="algSubtypeIds != null and algSubtypeIds != ''">
AND a.alg_subtype_ids REGEXP CONCAT('(^|,)(', REPLACE(#{algSubtypeIds}, ',', '|'), ')(,|$)')
</if>
ORDER BY ORDER BY
update_time DESC,
a.device_id a.device_id
</select> </select>


+ 45
- 0
inspect-metadata/src/main/resources/mapper/patrolpointmnt/BasedataPatrolPointMapper.xml View File

@ -198,6 +198,51 @@
</foreach> </foreach>
</select> </select>
<select id="selectBasedataPatrolPointWithPresetRelationListByDeviceIds" parameterType="java.util.List"
resultMap="BasedataPatrolPointResult">
select
distinct bp.patrol_point_id,
bp.patrol_point_code,
bp.patrol_point_name,
bp.device_type_id,
bp.main_device_id,
bp.relation_main_device_id,
bp.device_id,
bp.relation_device_id,
bp.area_id,
bp.relation_area_id,
bp.patrol_content,
bp.purpose,
bp.create_by,
bp.create_time,
bp.update_by,
bp.update_time,
bp.delete_flag,
bp.std_parol_point_id,
bp.point_impt_level,
bp.patrol_type_id,
bp.lower_value,
bp.upper_value,
bp.position_x,
bp.position_y,
bp.position_z,
bp.alg_subtype_ids,
bp.original_alg_subtype_ids,
bp.original_device_id,
bp.dis_ref_picture_path,
bp.original_main_device_id,
bp.alarm_threshold,
bp.meter_type
from basedata_patrolpoint bp
left join basedata_patrolpoint_preset bpp on bp.patrol_point_id = bpp.patrol_point_id
left join patrol_preset_pos ppp on bp.patrol_point_id = ppp.patrol_point_id
WHERE relation_device_id IN
<foreach item="item" collection="deviceIds" open="(" separator="," close=")">
#{item}
</foreach>
and (bpp.patrol_point_id is not null or ppp.patrol_point_id is not null)
</select>
<select id="selectBasedataMonitorList" parameterType="BasedataPatrolPoint" resultMap="BasedataPatrolPointResult"> <select id="selectBasedataMonitorList" parameterType="BasedataPatrolPoint" resultMap="BasedataPatrolPointResult">
-- select a.patrol_point_id, a.patrol_point_code,a.area_id, a.patrol_point_name, a.main_device_id, a.device_id, -- select a.patrol_point_id, a.patrol_point_code,a.area_id, a.patrol_point_name, a.main_device_id, a.device_id,
-- left join basedata_stdpatrol_point b on a.std_parol_point_id = b.std_patrol_point_id -- left join basedata_stdpatrol_point b on a.std_parol_point_id = b.std_patrol_point_id


+ 7
- 9
inspect-metadata/src/main/resources/mapper/threshold/BasedataThresholdModificationMapper.xml View File

@ -42,22 +42,20 @@
<if test="patrolPointId != null ">and patrol_point_id = #{patrolPointId}</if> <if test="patrolPointId != null ">and patrol_point_id = #{patrolPointId}</if>
<if test="algId != null ">and alg_id = #{algId}</if> <if test="algId != null ">and alg_id = #{algId}</if>
<if test="algName != null and algName != ''">and alg_name like concat('%', #{algName}, '%')</if> <if test="algName != null and algName != ''">and alg_name like concat('%', #{algName}, '%')</if>
<if test="params != null">
<if test="params.algSubtypeId != null and params.algSubtypeId != ''">
and alg_subtype_id in
<foreach item="item" collection="params.algSubtypeId" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="algSubtypeIds != null and algSubtypeIds != ''">
and alg_subtype_id in
<foreach item="item" collection="algSubtypeIds" open="(" separator="," close=")">
#{item}
</foreach>
</if> </if>
<if test="algSubtypeName != null and algSubtypeName != ''">and alg_subtype_name like concat('%', <if test="algSubtypeName != null and algSubtypeName != ''">and alg_subtype_name like concat('%',
#{algSubtypeName}, '%') #{algSubtypeName}, '%')
</if> </if>
<if test="lowerValue != null and lowerValue != ''">and lower_value = #{lowerValue}</if> <if test="lowerValue != null and lowerValue != ''">and lower_value = #{lowerValue}</if>
<if test="upperValue != null and upperValue != ''">and upper_value = #{upperValue}</if> <if test="upperValue != null and upperValue != ''">and upper_value = #{upperValue}</if>
ORDER BY alg_subtype_name,create_time DESC
</where> </where>
ORDER BY alg_subtype_name,create_time DESC
</select> </select>
<select id="selectBasedataThresholdModificationByLineId" parameterType="Long" <select id="selectBasedataThresholdModificationByLineId" parameterType="Long"


Loading…
Cancel
Save