Commit 70b9db5f authored by lisong's avatar lisong

添加物联报表-周分析报表接口

parent 8d224df6
......@@ -14,7 +14,10 @@ public enum WordTemplateTypeEum {
firePatrolReport("消防巡查报表","FirePatrolReport.ftl"),
fireAutoSysManageReport("消防自动化综合管理报表","fireAutoSysManageReport.ftl"),
iotMonthReport("物联报表-月分析报表","iotMonthReport.ftl");
iotMonthReport("物联报表-月分析报表","iotMonthReport.ftl"),
iotWeekReport("物联报表-周分析报表","iotWeekReport.ftl");
......
......@@ -133,7 +133,7 @@ public class ChartsUtils {
}
}
public static String manyLineChart(List<Map<String, Object>> value) {
public static String manyLineChart(List<Map<String, Object>> value, String title, String xtitle, String ytitle) {
// 绘图数据集
DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
......@@ -142,7 +142,7 @@ public class ChartsUtils {
}
JFreeChart chart = createManyLineChart(dataSet);
JFreeChart chart = createManyLineChart(dataSet, title, xtitle, ytitle);
BufferedImage image = chart.createBufferedImage(1000, 800);
byte[] bytes = null;
......@@ -161,16 +161,16 @@ public class ChartsUtils {
*
* @return
*/
public static JFreeChart createManyLineChart(DefaultCategoryDataset dataSet) {
public static JFreeChart createManyLineChart(DefaultCategoryDataset dataSet, String title, String xtitle, String ytitle) {
//如果把createLineChart改为createLineChart3D就变为了3D效果的折线图
JFreeChart chart = ChartFactory.createLineChart("月报警信息", "日期", "告警数量", dataSet,
JFreeChart chart = ChartFactory.createLineChart(title, xtitle, ytitle, dataSet,
PlotOrientation.VERTICAL, // 绘制方向
true, // 显示图例
true, // 采用标准生成器
false // 是否生成超链接
);
//如 果不使用Font,中文将显示不出来
Font font = new Font("新宋体", Font.BOLD, 10);
Font font = new Font("新宋体", Font.BOLD, 18);
chart.getTitle().setFont(font); // 设置标题字体
chart.getLegend().setItemFont(font);// 设置图例类别字体
......
......@@ -480,5 +480,28 @@ public interface FireFightingSystemMapper extends BaseMapper<FireFightingSystemE
List<Map<String, Object>> selectMonthPolyline(@Param("systemCode") String sysCode, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("indicator") List<String> indicator);
List<Map<String, Object>> selectWeekReportList(@Param("systemId") String systemId,@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("indicator") List<String> indicator);
Integer selectAlarms(@Param("systemId") String systemId,
@Param("indexType") String indexType,
@Param("equipmentCode") String equipmentCode,
@Param("startDate") String startDate,
@Param("endDate") String endDate,
@Param("indicator") List<String> indicator);
Map<String, Object> selectWeekSummarize(@Param("systemId") String systemId,
@Param("startDate") String startDate,
@Param("endDate") String endDate);
List<Map<String, Object>> selectWeekEquipEchart(@Param("systemCode") String systemCode,
@Param("startDate") String startDate,
@Param("endDate") String endDate);
List<Map<String, Object>> selectWeekEchart(@Param("systemCode") String systemCode,
@Param("startDate") String startDate,
@Param("endDate") String endDate);
List<Map<String, Object>> selectWeekLinesEchart(@Param("systemCode") String systemCode,
@Param("startDate") String startDate,
@Param("endDate") String endDate);
}
......@@ -276,4 +276,7 @@ public interface IFireFightingSystemService extends IService<FireFightingSystemE
String iotMonthReport(String bizOrgCode, String startDate, String endDate);
String iotWeekReport(String bizOrgCode, String startDate, String endDate);
}
......@@ -1469,8 +1469,14 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
// 系统循环数据填充
ArrayList<Map<String, Object>> systemList = new ArrayList<>();
if (!CollectionUtils.isEmpty(system)) {
map.put("station", "锦屏");
map.put("time", "2022-07");
// 换流站信息
if (!ObjectUtils.isEmpty(system.get(0).get("stationName"))){
map.put("station", system.get(0).get("stationName"));
}else {
map.put("station", "");
}
map.put("time", startDate+"-"+endDate);
// 单个系统数据
for (Map<String, Object> sys : system) {
HashMap<String, Object> systemData = new HashMap<>();
......@@ -1563,7 +1569,7 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
if (!CollectionUtils.isEmpty(selectMonthPolyline)) {
String pieChart2 = ChartsUtils.manyLineChart(selectMonthPolyline);
String pieChart2 = ChartsUtils.manyLineChart(selectMonthPolyline, "月告警信息", "日期", "告警数量");
systemData.put("bing3", pieChart2);
} else {
systemData.put("bing3", "");
......@@ -1622,4 +1628,148 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
return pdfUrlString;
}
private Map<String, Object> getWeekData(String bizOrgCode, String startDate, String endDate) {
Map<String, Object> map = new HashMap<>();
// 查询该站信息以及所有系统
List<Map<String, Object>> systemList = fireFightingSystemMapper.selectSystemByBizOrgCode(bizOrgCode);
String json = null;
try {
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);
// 一周内所有系统情况
if (!CollectionUtils.isEmpty(systemList)) {
// 换流站信息
if (!ObjectUtils.isEmpty(systemList.get(0).get("stationName"))) {
map.put("station", systemList.get(0).get("stationName"));
} else {
map.put("station", "");
}
map.put("time", startDate + "-" + endDate);
// 系统循环数据填充
ArrayList<Map<String, Object>> dataList = new ArrayList<>();
for (Map<String, Object> system : systemList) {
HashMap<String, Object> systemData = new HashMap<>();
List<Map> collect = indicatorConfiguration.stream().
filter(item -> item.get("code").equals(String.valueOf(system.get("typeCode")))).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(collect)) {
// 系统名称
systemData.put("systemName", ObjectUtils.isEmpty(system.get("name")) ? "" : String.valueOf(system.get("name")));
// 系统对应指标
String indicator = String.valueOf(collect.get(0).get("index"));
String[] split = indicator.split(",");
List<String> indicatorList = Arrays.asList(split);
List<Map<String, Object>> weekReportList = fireFightingSystemMapper.selectWeekReportList(String.valueOf(system.get("id")), startDate, endDate, indicatorList);
ArrayList<Map<String, Object>> list = new ArrayList<>();
if (!CollectionUtils.isEmpty(weekReportList)) {
for (Map<String, Object> weekItem : weekReportList) {
HashMap<String, Object> listItem = new HashMap<>();
// 设备类型
listItem.put("name", ObjectUtils.isEmpty(weekItem.get("name")) ? "" : String.valueOf(weekItem.get("name")));
// 设备总数
listItem.put("num", ObjectUtils.isEmpty(weekItem.get("num")) ? "" : String.valueOf(weekItem.get("num")));
// 无异常设备总数
listItem.put("normalNum", ObjectUtils.isEmpty(weekItem.get("normalNum")) ? "" : String.valueOf(weekItem.get("normalNum")));
// 物联指标
listItem.put("type_name", ObjectUtils.isEmpty(weekItem.get("type_name")) ? "" : String.valueOf(weekItem.get("type_name")));
// 监测数据
listItem.put("monitoringData", ObjectUtils.isEmpty(weekItem.get("monitoringData")) ? "" : String.valueOf(weekItem.get("monitoringData")));
// 获取方式
listItem.put("acquisition", ObjectUtils.isEmpty(weekItem.get("acquisition")) ? "" : String.valueOf(weekItem.get("acquisition")));
// 正常标准
listItem.put("normal", ObjectUtils.isEmpty(weekItem.get("normal")) ? "" : String.valueOf(weekItem.get("normal")));
// 7日告警设备数
listItem.put("alarmEquipNum", ObjectUtils.isEmpty(weekItem.get("alarmEquipNum")) ? "" : String.valueOf(weekItem.get("alarmEquipNum")));
// 7日告警条数
if (!ObjectUtils.isEmpty(weekItem.get("type_code")) && !ObjectUtils.isEmpty(weekItem.get("code"))) {
Integer integer = fireFightingSystemMapper.selectAlarms(valueOf(system.get("id")), valueOf(weekItem.get("type_code")), valueOf(weekItem.get("code")), startDate, endDate, indicatorList);
listItem.put("trueNum", String.valueOf(integer));
} else {
listItem.put("trueNum", String.valueOf(0));
}
list.add(listItem);
}
} else {
HashMap<String, Object> listItem = new HashMap<>();
listItem.put("name", "");
listItem.put("num", "");
listItem.put("normalNum", "");
listItem.put("type_name", "");
listItem.put("monitoringData", "");
listItem.put("acquisition", "");
listItem.put("normal", "");
listItem.put("alarmEquipNum", "");
listItem.put("trueNum", "");
list.add(listItem);
}
// 总结
Map<String, Object> summarize = fireFightingSystemMapper.selectWeekSummarize(valueOf(system.get("id")), startDate, endDate);
if (!ObjectUtils.isEmpty(summarize.get("contant"))) {
systemData.put("summarize", String.valueOf(summarize.get("contant")));
} else {
systemData.put("summarize", "");
}
// echarts 图表
List<Map<String, Object>> mapList = fireFightingSystemMapper.selectWeekEquipEchart(valueOf(system.get("code")), startDate, endDate);
String pieChart1 = ChartsUtils.pieChart(mapList, "告警类别统计");
systemData.put("pictureLeft", pieChart1);
List<Map<String, Object>> weekEchart = fireFightingSystemMapper.selectWeekEchart(valueOf(system.get("code")), startDate, endDate);
String pieChart2 = ChartsUtils.pieChart(weekEchart, "设备告警统计");
systemData.put("pictureCenter", pieChart2);
List<Map<String, Object>> linesEchart = fireFightingSystemMapper.selectWeekLinesEchart(valueOf(system.get("code")), startDate, endDate);
String lines = ChartsUtils.manyLineChart(linesEchart, "周告警信息", "日期", "告警数量");
systemData.put("lines", lines);
systemData.put("sysData", list);
dataList.add(systemData);
map.put("data", dataList);
}
}
}
return map;
}
@Override
public String iotWeekReport(String bizOrgCode, String startDate, String endDate) {
Map<String, Object> dataMap = getWeekData(bizOrgCode, startDate, endDate);
WordTemplateUtils instance = WordTemplateUtils.getInstance();
String pdfUrlString = "";
File filepdf = null;
try {
filepdf = instance.getWordFileItem(dataMap, null, WordTemplateTypeEum.iotWeekReport.getTemplateFile());
filepdf.getAbsolutePath();
MultipartFile multipartFile = new MyByteArrayMultipartFile("file", "file.pdf", "application/pdf", file2byte(filepdf));
FeignClientResult<Map<String, String>> result = Systemctl.fileStorageClient.updateCommonFile(multipartFile);
if (result != null) {
Iterator<String> it = result.getResult().keySet().iterator();
while (it.hasNext()) {
pdfUrlString = it.next();
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (filepdf != null) {
filepdf.delete();
}
}
return pdfUrlString;
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
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