bbf071e3 sonin

巡检分析 巡检设备概况 详情

1 个父辈 1c419398
......@@ -251,7 +251,7 @@ public class InspectionAnalysisController {
@GetMapping("/getInspectionEquipOverview")
public Result<InspectionEquipOverviewVO> getInspectionEquipOverview(String startDate, String endDate){
Result<InspectionEquipOverviewVO> result = new Result<>();
InspectionEquipOverviewVO inspectionEquipOverviewVO = inspectionAnalysisService.getInspectionEquipOverviewNew(startDate,endDate);
InspectionEquipOverviewVO inspectionEquipOverviewVO = inspectionAnalysisService.getInspectionEquipOverview(startDate,endDate);
result.setSuccess(true);
result.setResult(inspectionEquipOverviewVO);
return result;
......@@ -259,15 +259,15 @@ public class InspectionAnalysisController {
@ApiOperation(value = "巡检分析-巡检设备概况-详情", notes = "巡检分析-巡检设备概况-详情")
@GetMapping("/getInspectionEquipOverviewDetail")
public Result<List<InspectionEquipIndicatorsDetailVO>> getInspectionEquipOverviewDetail(String departId,String startDate, String endDate){
Result<List<InspectionEquipIndicatorsDetailVO>> result = new Result<>();
public Result<List<InspectionEquipOverviewVO>> getInspectionEquipOverviewDetail(String departId,String startDate, String endDate){
Result<List<InspectionEquipOverviewVO>> result = new Result<>();
String departIds = departId;
if(StringUtils.isEmpty(departId)){
departIds = BaseContextHandler.getDeparts();
}else{
departIds = sysDepartService.getChildDepartId(departId);
}
List<InspectionEquipIndicatorsDetailVO> dataList = inspectionAnalysisService.getInspectionEquipOverviewDetail(departIds,startDate,endDate);
List<InspectionEquipOverviewVO> dataList = inspectionAnalysisService.getInspectionEquipOverviewDetail(departIds,startDate,endDate);
result.setSuccess(true);
result.setResult(dataList);
return result;
......
......@@ -79,7 +79,7 @@ public interface IInspectionAnalysisService {
* @param endDate
* @return
*/
List<InspectionEquipIndicatorsDetailVO> getInspectionEquipOverviewDetail(String departIds, String startDate, String endDate);
List<InspectionEquipOverviewVO> getInspectionEquipOverviewDetail(String departIds, String startDate, String endDate);
/***
* 巡检分析-巡检任务异常项趋势
......
......@@ -548,8 +548,8 @@ public class InspectionAnalysisServiceImpl implements IInspectionAnalysisService
List<String> tempInspectionTaskIdList = entry0.getValue();
completableFutureList.add(CompletableFuture.supplyAsync(() -> {
InspectionTaskIndicatorsVO vo = new InspectionTaskIndicatorsVO();
vo.setDepartName(StringUtils.isEmpty(departId) ? departId : sysDepartDictMap.get(departId));
//初始化数据
vo.setDepartName(StringUtils.isEmpty(departId) ? departId : sysDepartDictMap.get(departId));
vo.setCompletionRate("0");
vo.setUnCompletionRate("0");
vo.setAbnormalRate("0");
......@@ -1268,31 +1268,139 @@ public class InspectionAnalysisServiceImpl implements IInspectionAnalysisService
* @param endDate
* @return
*/
public List<InspectionEquipIndicatorsDetailVO> getInspectionEquipOverviewDetail(String departIds, String startDate, String endDate){
// return inspectionAnalysisMapper.getInspectionEquipIndicatorsDetail( departIds, startDate, endDate);
//return null;
String sql = "select d.depart_name, d.id 'departId' , ifnull(kkk.total_count,0) 'totalInspectionEquipCount' , ifnull(kkk.yj_count,0) 'checkedInspectionEquipCount' ,ifnull(kkk.yc_count,0) 'abnormalInspectionEquipCount' ,(ifnull(kkk.yj_count,0) - ifnull(kkk.yc_count,0) ) 'normalInspectionEquipCount' , " +
" (ifnull(kkk.total_count,0) - ifnull(kkk.yj_count,0) ) 'notCheckedInspectionEquipCount' " +
" from sys_depart d ";
sql +=" left join ( select ei.depart_id ,count( eee.equip_info_id) 'total_count' ,ifnull( SUM( CASE WHEN fff.equip_info_id > '0' THEN 1 ELSE 0 END ),0) as 'yj_count',ifnull( SUM( CASE WHEN ggg.equip_info_id > '0' THEN 1 ELSE 0 END ),0) as 'yc_count'";
sql +=" from ( " + getInspectionEquipIdsSql(departIds, startDate, endDate) +") eee ";
sql += " left join ( "+ getCheckedInspectionEquipIds(departIds ,startDate, endDate,null)+" ) fff on fff.equip_info_id = eee.equip_info_id";
sql += " left join ( "+ getCheckedInspectionEquipIds(departIds ,startDate, endDate,"0")+" ) ggg on ggg.equip_info_id = eee.equip_info_id ";
sql += " left join equipment_info ei on eee.equip_info_id = ei.id ";
sql +=" group by ei.depart_id ";
sql +=" ) kkk on d.id = kkk.depart_id ";
sql +=" where d.depart_type = 1 ";
if(StringUtils.isNotEmpty(departIds)){
sql +=" and d.id in ("+JSUtils.quoteEach(departIds,",")+") ";
public List<InspectionEquipOverviewVO> getInspectionEquipOverviewDetail(String departIds, String startDate, String endDate){
List<InspectionEquipOverviewVO> voList = new ArrayList<>();
//查询时间内已巡检任务信息
QueryWrapper<InspectionTask> inspectionTaskQueryWrapper = new QueryWrapper();
if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)) {
inspectionTaskQueryWrapper.ge("inspection_cycle_start_date", startDate + " 00:00:00");
inspectionTaskQueryWrapper.le("inspection_cycle_start_date", endDate + " 23:59:59");
}
sql += " order by kkk.total_count desc ";
List<InspectionEquipIndicatorsDetailVO> dataList =getJdbcTemplate().query(sql,new BeanPropertyRowMapper<InspectionEquipIndicatorsDetailVO>(InspectionEquipIndicatorsDetailVO.class));
return dataList;
inspectionTaskQueryWrapper.in("task_state", "2","3");
List<InspectionTask> inspectionTaskList = inspectionTaskService.list(inspectionTaskQueryWrapper);
// 巡检任务按照departId分组
Map<String, List<String>> departId2inspectionTaskIdMap = new LinkedHashMap<>();
for (InspectionTask inspectionTask : inspectionTaskList) {
String departId = inspectionTask.getDepartId();
List<String> inspectionTaskIdList = departId2inspectionTaskIdMap.computeIfAbsent(departId, k -> new ArrayList<>());
inspectionTaskIdList.add(inspectionTask.getId());
}
List<CompletableFuture> completableFutureList = new ArrayList<>();
// 翻译
Map<String, String> sysDepartDictMap = businessService.dictMap("sys_depart", null);
for (Map.Entry<String, List<String>> entry0: departId2inspectionTaskIdMap.entrySet()) {
String departId = entry0.getKey();
List<String> tempInspectionTaskIdList = entry0.getValue();
completableFutureList.add(CompletableFuture.supplyAsync(() -> {
InspectionEquipOverviewVO inspectionEquipOverviewVO = new InspectionEquipOverviewVO();
//设置初始化数据
inspectionEquipOverviewVO.setDepartName(StringUtils.isEmpty(departId) ? departId : sysDepartDictMap.get(departId));
inspectionEquipOverviewVO.setTotalInspectionEquipCount(0);
inspectionEquipOverviewVO.setCheckedInspectionEquipCount(0);
inspectionEquipOverviewVO.setNotCheckedInspectionEquipCount(0);
inspectionEquipOverviewVO.setNormalInspectionEquipCount(0);
inspectionEquipOverviewVO.setAbnormalInspectionEquipCount(0);
inspectionEquipOverviewVO.setProcessedAbnormalRate("0");
if (tempInspectionTaskIdList.size() > 0) {
//查询应检设备数量
QueryWrapper<InspectionTaskPointFillGroup> inspectionTaskPointFillGroupQueryWrapper = new QueryWrapper<>();
inspectionTaskPointFillGroupQueryWrapper.in("inspection_task_id", tempInspectionTaskIdList);
inspectionTaskPointFillGroupQueryWrapper.select("equip_info_id equipInfoId,inspection_point_fill_group_id inspectionPointFillGroupId,inspection_fill_group_id inspectionFillGroupId,inspection_task_id inspectionTaskId");
inspectionTaskPointFillGroupQueryWrapper.groupBy("equip_info_id,inspection_point_fill_group_id,inspection_fill_group_id,inspection_task_id");
inspectionTaskPointFillGroupQueryWrapper.isNotNull("equip_info_id");
inspectionTaskPointFillGroupQueryWrapper.ne("equip_info_id", "");
List<Map<String, Object>> equipInfoIdList = inspectionTaskPointFillGroupService.listMaps(inspectionTaskPointFillGroupQueryWrapper);
//应检设备数量
Integer totalInspectionEquipCount = equipInfoIdList.stream().map(m -> ConvertUtils.getString(m.get("equipInfoId"))).collect(Collectors.toSet()).size();
//查询已巡检设备数量
List<String> inspectionPointFillGroupIdList = equipInfoIdList.stream().map(m -> ConvertUtils.getString(m.get("inspectionPointFillGroupId"))).collect(Collectors.toList());
List<String> inspectionFillGroupIdList = equipInfoIdList.stream().map(m -> ConvertUtils.getString(m.get("inspectionFillGroupId"))).collect(Collectors.toList());
int checkedInspectionEquipCount = 0;
int notCheckedInspectionEquipCount = 0;
int abnormalInspectionEquipCount = 0;
if (inspectionPointFillGroupIdList.size() > 0) {
QueryWrapper<InspectionTaskFillContent> inspectionTaskFillContentQueryWrapper = new QueryWrapper<>();
inspectionTaskFillContentQueryWrapper.in("isfc.inspection_task_id", tempInspectionTaskIdList);
inspectionTaskFillContentQueryWrapper.in("isfc.inspection_point_fill_group_id", inspectionPointFillGroupIdList);
inspectionTaskFillContentQueryWrapper.in("isfc.inspection_fill_group_id",inspectionFillGroupIdList);
inspectionTaskFillContentQueryWrapper.isNotNull("itpfg.equip_info_id");
inspectionTaskFillContentQueryWrapper.ne("itpfg.equip_info_id", "");
inspectionTaskFillContentQueryWrapper.groupBy("itpfg.equip_info_id");
inspectionTaskFillContentQueryWrapper.isNotNull("isfc.fill_content");
inspectionTaskFillContentQueryWrapper.ne("isfc.fill_content", "");
List<Map<String, Object>> inspectionTaskFillContentList = inspectionTaskFillContentService.getList(inspectionTaskFillContentQueryWrapper);
//已检设备数量
checkedInspectionEquipCount = inspectionTaskFillContentList.size();
//未检设备数量
notCheckedInspectionEquipCount = totalInspectionEquipCount - checkedInspectionEquipCount;
//查询异常填报设备数量
inspectionTaskFillContentQueryWrapper.eq("choice_state", "0");
abnormalInspectionEquipCount = inspectionTaskFillContentService.getList(inspectionTaskFillContentQueryWrapper).size();
}
//查询问题上报id集合
QueryWrapper<InspectionTaskProblemReport> inspectionTaskProblemReportQueryWrapper = new QueryWrapper<>();
inspectionTaskProblemReportQueryWrapper.in("inspection_task_id", tempInspectionTaskIdList);
List<InspectionTaskProblemReport> inspectionTaskProblemReportList = inspectionTaskProblemReportService.list(inspectionTaskProblemReportQueryWrapper);
List<String> problemReportIdList = inspectionTaskProblemReportList.stream().map(InspectionTaskProblemReport::getProblemReportPlanId).collect(Collectors.toList());
List<ProblemReportPlan> problemReportPlanList = new ArrayList<>();
if (problemReportIdList.size() > 0) {
QueryWrapper<ProblemReportPlan> problemReportPlanQueryWrapper = new QueryWrapper<>();
problemReportPlanQueryWrapper.in("id", problemReportIdList);
problemReportPlanList = problemReportPlanService.list(problemReportPlanQueryWrapper);
}
//存放问题上报的实例ID
Set<String> processInstanceIdList = problemReportPlanList.stream().map(ProblemReportPlan::getProcessInstanceId).collect(Collectors.toSet());
Map<String, Map<String, String>> processStateMap = new HashMap<>();
if (processInstanceIdList.size() > 0) {
processStateMap = flowBusinessService.getProcessState(processInstanceIdList);
}
Map<String, List<String>> processInstanceStateMap = new HashMap<>();
List<String> tempProcessInstanceIdList;
for (Map.Entry<String, Map<String, String>> entry : processStateMap.entrySet()) {
tempProcessInstanceIdList = new ArrayList<>();
String processInstanceId = entry.getKey();
String state = entry.getValue().get("state");
if (processInstanceStateMap.get(state) != null) {
tempProcessInstanceIdList = processInstanceStateMap.get(state);
}
tempProcessInstanceIdList.add(processInstanceId);
processInstanceStateMap.put(state, tempProcessInstanceIdList);
}
//异常项数量(问题上报)
Integer abnormalItemsCount = problemReportPlanList.size();
//已处理异常项数量(问题上报)
Integer processedAbnormalItemsCount = 0;
if (processInstanceStateMap != null && processInstanceStateMap.get(FlowEngineConstant.STATUS_FINISHED) != null) {
processedAbnormalItemsCount = processInstanceStateMap.get(FlowEngineConstant.STATUS_FINISHED).size();
}
//异常项处理率
String processedAbnormalRate = "0";
if (abnormalItemsCount != 0) {
processedAbnormalRate = numberFormat.format(processedAbnormalItemsCount / (double) abnormalItemsCount * 100);
}
inspectionEquipOverviewVO.setTotalInspectionEquipCount(totalInspectionEquipCount);
inspectionEquipOverviewVO.setCheckedInspectionEquipCount(checkedInspectionEquipCount);
inspectionEquipOverviewVO.setNotCheckedInspectionEquipCount(notCheckedInspectionEquipCount);
inspectionEquipOverviewVO.setNormalInspectionEquipCount(checkedInspectionEquipCount - abnormalInspectionEquipCount);
inspectionEquipOverviewVO.setAbnormalInspectionEquipCount(abnormalInspectionEquipCount);
inspectionEquipOverviewVO.setProcessedAbnormalRate(processedAbnormalRate);
}
return inspectionEquipOverviewVO;
}, (Executor) SpringContextUtils.getBean("taskExecutor2")));
}
// 等待所有子线程处理完毕
CompletableFuture.allOf(completableFutureList.toArray(new CompletableFuture[0])).join();
for (CompletableFuture completableFuture : completableFutureList) {
try {
InspectionEquipOverviewVO vo = (InspectionEquipOverviewVO) completableFuture.get();
voList.add(vo);
} catch (Exception e) {
e.printStackTrace();
}
}
return voList;
}
@Override
public List<InspectionAbnormalItemsTrendVO> getInspectionAbnormalItemsTrend(String startDate, String endDate) {
List<InspectionAbnormalItemsTrendVO> inspectionAbnormalItemsTrendVOList = new ArrayList<>();
......
......@@ -29,4 +29,6 @@ public class InspectionEquipOverviewVO {
private Integer abnormalInspectionEquipCount;
@ApiModelProperty(value = "异常项处理率")
private String processedAbnormalRate;
private String departName;
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!