Commit 0418e899 authored by lisong's avatar lisong

优化物联报表定时任务配置读取

parent 2c62d3f5
package com.yeejoin.equipmanage.service.impl; package com.yeejoin.equipmanage.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yeejoin.equipmanage.common.dto.AnalysisReportLogDto; import com.yeejoin.equipmanage.common.dto.AnalysisReportLogDto;
...@@ -14,16 +16,23 @@ import com.yeejoin.equipmanage.common.utils.DateUtils; ...@@ -14,16 +16,23 @@ import com.yeejoin.equipmanage.common.utils.DateUtils;
import com.yeejoin.equipmanage.mapper.AnalysisReportLogMapper; import com.yeejoin.equipmanage.mapper.AnalysisReportLogMapper;
import com.yeejoin.equipmanage.mapper.AnalysisReportMonthMapper; import com.yeejoin.equipmanage.mapper.AnalysisReportMonthMapper;
import com.yeejoin.equipmanage.mapper.AnalysisReportSummaryMapper; import com.yeejoin.equipmanage.mapper.AnalysisReportSummaryMapper;
import com.yeejoin.equipmanage.mapper.FireFightingSystemMapper;
import com.yeejoin.equipmanage.service.IAnalysisReportLogService; import com.yeejoin.equipmanage.service.IAnalysisReportLogService;
import com.yeejoin.equipmanage.service.IFireFightingSystemService; import com.yeejoin.equipmanage.service.IFireFightingSystemService;
import com.yeejoin.equipmanage.service.IUploadFileService; import com.yeejoin.equipmanage.service.IUploadFileService;
import liquibase.pro.packaged.A; import liquibase.pro.packaged.A;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.text.ParseException; import java.text.ParseException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* 报告流水表 服务实现类 * 报告流水表 服务实现类
...@@ -48,6 +57,12 @@ public class AnalysisReportLogServiceImpl extends ServiceImpl<AnalysisReportLogM ...@@ -48,6 +57,12 @@ public class AnalysisReportLogServiceImpl extends ServiceImpl<AnalysisReportLogM
@Autowired @Autowired
IUploadFileService iUploadFileService; IUploadFileService iUploadFileService;
@Autowired
FireFightingSystemMapper fireFightingSystemMapper;
@Value("classpath:/json/systemIndex.json")
private Resource systemIndex;
@Override @Override
public IPage<AnalysisReportLog> listPage(Page page, AnalysisReportLog analysisReportLog) { public IPage<AnalysisReportLog> listPage(Page page, AnalysisReportLog analysisReportLog) {
...@@ -74,15 +89,27 @@ public class AnalysisReportLogServiceImpl extends ServiceImpl<AnalysisReportLogM ...@@ -74,15 +89,27 @@ public class AnalysisReportLogServiceImpl extends ServiceImpl<AnalysisReportLogM
this.saveAnalysisReportLog(reportEnum, beginDate, endDate); this.saveAnalysisReportLog(reportEnum, beginDate, endDate);
// 创建月分析统计报告数据 // 创建月分析统计报告数据
// 1、 查询消防系统表,捞出所有系统,新增字段,存放自定义用的告警指标模糊查询指标key,逗号分隔 // 1、 查询消防系统表,捞出所有系统,新增字段,存放自定义用的告警指标模糊查询指标key,逗号分隔
List<FireFightingSystemEntity> fightingSystemEntityList = fireFightingSystemService.getBaseMapper().selectList( List<Map<String, Object>> list = fireFightingSystemMapper.selectSystemByBizOrgCode(null);
new LambdaQueryWrapper<FireFightingSystemEntity>()
.isNotNull(FireFightingSystemEntity::getAnalysisIndexKey));
// 2、循环插入 wl_analysis_report_month、wl_analysis_report_summary // 2、循环插入 wl_analysis_report_month、wl_analysis_report_summary
String beginDateStr = DateUtils.dateFormat(beginDate,DateUtils.DATE_PATTERN); String beginDateStr = DateUtils.dateFormat(beginDate,DateUtils.DATE_PATTERN);
String endDateStr = DateUtils.dateFormat(endDate,DateUtils.DATE_PATTERN); String endDateStr = DateUtils.dateFormat(endDate,DateUtils.DATE_PATTERN);
fightingSystemEntityList.forEach(f -> { String json = null;
analysisReportMonthMapper.insertSystemMonthData(new ArrayList<>(Arrays.asList(f.getAnalysisIndexKey().split(","))), beginDateStr, endDateStr, f.getId()); try {
analysisReportSummaryMapper.insertSystemMonthSummaryData(new ArrayList<>(Arrays.asList(f.getAnalysisIndexKey().split(","))), beginDateStr, endDateStr, f.getId()); json = IOUtils.toString(systemIndex.getInputStream(), java.lang.String.valueOf(StandardCharsets.UTF_8));
} catch (IOException e) {
e.printStackTrace();
}
// 获取系统对应指标配置信息
List<Map> indicatorConfiguration = JSONObject.parseArray(json, Map.class);
list.forEach(f -> {
// 具体系统对应指标
List<Map> collect = indicatorConfiguration.stream().
filter(index -> index.get("code").equals(String.valueOf(f.get("typeCode")))).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(collect)) {
String indicator = String.valueOf(collect.get(0).get("index"));
analysisReportMonthMapper.insertSystemMonthData(new ArrayList<>(Arrays.asList(indicator.split(","))), beginDateStr, endDateStr, Long.valueOf(f.get("id").toString()));
analysisReportSummaryMapper.insertSystemMonthSummaryData(new ArrayList<>(Arrays.asList(indicator.split(","))), beginDateStr, endDateStr, Long.valueOf(f.get("id").toString()));
}
}); });
} }
...@@ -93,15 +120,27 @@ public class AnalysisReportLogServiceImpl extends ServiceImpl<AnalysisReportLogM ...@@ -93,15 +120,27 @@ public class AnalysisReportLogServiceImpl extends ServiceImpl<AnalysisReportLogM
this.saveAnalysisReportLog(reportEnum, beginDate, endDate); this.saveAnalysisReportLog(reportEnum, beginDate, endDate);
// 创建月分析统计报告数据 // 创建月分析统计报告数据
// 1、 查询消防系统表,捞出所有系统,新增字段,存放自定义用的告警指标模糊查询指标key,逗号分隔 // 1、 查询消防系统表,捞出所有系统,新增字段,存放自定义用的告警指标模糊查询指标key,逗号分隔
List<FireFightingSystemEntity> fightingSystemEntityList = fireFightingSystemService.getBaseMapper().selectList( List<Map<String, Object>> list = fireFightingSystemMapper.selectSystemByBizOrgCode(null);
new LambdaQueryWrapper<FireFightingSystemEntity>()
.isNotNull(FireFightingSystemEntity::getAnalysisIndexKey));
// 2、循环插入 wl_analysis_report_month、wl_analysis_report_summary // 2、循环插入 wl_analysis_report_month、wl_analysis_report_summary
String beginDateStr = DateUtils.dateFormat(beginDate,DateUtils.DATE_PATTERN); String beginDateStr = DateUtils.dateFormat(beginDate,DateUtils.DATE_PATTERN);
String endDateStr = DateUtils.dateFormat(endDate,DateUtils.DATE_PATTERN); String endDateStr = DateUtils.dateFormat(endDate,DateUtils.DATE_PATTERN);
fightingSystemEntityList.forEach(f -> { String json = null;
analysisReportMonthMapper.insertSystemMonthDataTest(new ArrayList<>(Arrays.asList(f.getAnalysisIndexKey().split(","))), beginDateStr, endDateStr, f.getId(),now,num); try {
analysisReportSummaryMapper.insertSystemMonthSummaryDataTest(new ArrayList<>(Arrays.asList(f.getAnalysisIndexKey().split(","))), beginDateStr, endDateStr, f.getId(),now,num); json = IOUtils.toString(systemIndex.getInputStream(), java.lang.String.valueOf(StandardCharsets.UTF_8));
} catch (IOException e) {
e.printStackTrace();
}
// 获取系统对应指标配置信息
List<Map> indicatorConfiguration = JSONObject.parseArray(json, Map.class);
list.forEach(f -> {
// 具体系统对应指标
List<Map> collect = indicatorConfiguration.stream().
filter(index -> index.get("code").equals(String.valueOf(f.get("typeCode")))).collect(Collectors.toList());
if (!ObjectUtils.isEmpty(collect)) {
String indicator = String.valueOf(collect.get(0).get("index"));
analysisReportMonthMapper.insertSystemMonthData(new ArrayList<>(Arrays.asList(indicator.split(","))), beginDateStr, endDateStr, Long.valueOf(f.get("id").toString()));
analysisReportSummaryMapper.insertSystemMonthSummaryData(new ArrayList<>(Arrays.asList(indicator.split(","))), beginDateStr, endDateStr, Long.valueOf(f.get("id").toString()));
}
}); });
} }
......
...@@ -1513,11 +1513,15 @@ ...@@ -1513,11 +1513,15 @@
select select
count(1) count(1)
from from
wl_equipment_specific_index wl_equipment_specific_index wesi
LEFT JOIN wl_equipment_specific wes on wesi.equipment_specific_id = wes.id
where where
equipment_index_key in ('FHS_PressurePump_Start', 'FHS_PressurePump_Stop') wesi.equipment_index_key in ('FHS_PressurePump_Start', 'FHS_PressurePump_Stop')
and update_date >= and update_date >=
#{startTime} and #{endTime} >= update_date #{startTime} and #{endTime} >= update_date
<if test="orgCode != null and orgCode != ''">
and wes.biz_org_code like concat(#{orgCode}, "%")
</if>
) as allNum, ) as allNum,
( (
select select
...@@ -1526,8 +1530,13 @@ ...@@ -1526,8 +1530,13 @@
count(1) count(1)
from from
wl_equipment_detail wed wl_equipment_detail wed
LEFT JOIN wl_equipment_specific wes on wes.equipment_detail_id = wed.id
where where
wed.code like '92010800%' ) as allEqu) as allEqu, wed.code like '92010800%'
<if test="orgCode != null and orgCode != ''">
and wes.biz_org_code like concat(#{orgCode}, "%")
</if>
) as allEqu) as allEqu,
( (
select select
'稳压泵平均打压频次' as name) as name, '稳压泵平均打压频次' as name) as name,
...@@ -1537,11 +1546,15 @@ ...@@ -1537,11 +1546,15 @@
select select
count(1) count(1)
from from
wl_equipment_specific_index wl_equipment_specific_index wesi
LEFT JOIN wl_equipment_specific wes on wesi.equipment_specific_id = wes.id
where where
equipment_index_key in ('FHS_PressurePump_Start') wesi.equipment_index_key in ('FHS_PressurePump_Start')
and update_date >= and wesi.update_date >=
#{startTime} and #{endTime} >= update_date #{startTime} and #{endTime} >= update_date
<if test="orgCode != null and orgCode != ''">
and wes.biz_org_code like concat(#{orgCode}, "%")
</if>
) as startNum) as startNum ) as startNum) as startNum
</select> </select>
......
...@@ -3890,7 +3890,11 @@ ...@@ -3890,7 +3890,11 @@
FROM `f_fire_fighting_system` ffs FROM `f_fire_fighting_system` ffs
LEFT JOIN wl_equipment_category wec LEFT JOIN wl_equipment_category wec
on ffs.system_type = wec.id on ffs.system_type = wec.id
WHERE biz_org_code like concat(#{bizOrgCode},'%') <where>
<if test="bizOrgCode != null and bizOrgCode != ''">
biz_org_code like concat(#{bizOrgCode},'%')
</if>
</where>
order by ffs.sort order by ffs.sort
</select> </select>
<select id="selectAlarmList" resultType="java.util.Map"> <select id="selectAlarmList" resultType="java.util.Map">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment