Merge remote-tracking branch 'origin/master' into master
正在显示
12 个修改的文件
包含
357 行增加
和
56 行删除
... | @@ -22,9 +22,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage; | ... | @@ -22,9 +22,14 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
22 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 22 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
23 | import com.skua.modules.ajh.service.IAjhMeetingService; | 23 | import com.skua.modules.ajh.service.IAjhMeetingService; |
24 | import com.skua.modules.ajh.vo.AjhMeetingSendVO; | 24 | import com.skua.modules.ajh.vo.AjhMeetingSendVO; |
25 | import com.skua.modules.system.entity.SysDepart; | ||
26 | import com.skua.modules.system.entity.SysUser; | ||
27 | import com.skua.modules.system.service.ISysDepartService; | ||
28 | import com.skua.modules.system.service.ISysUserService; | ||
25 | import com.skua.tool.util.QRCodeUtil; | 29 | import com.skua.tool.util.QRCodeUtil; |
26 | import lombok.extern.slf4j.Slf4j; | 30 | import lombok.extern.slf4j.Slf4j; |
27 | 31 | ||
32 | import org.apache.commons.lang3.StringUtils; | ||
28 | import org.jeecgframework.poi.excel.ExcelImportUtil; | 33 | import org.jeecgframework.poi.excel.ExcelImportUtil; |
29 | import org.jeecgframework.poi.excel.def.NormalExcelConstants; | 34 | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
30 | import org.jeecgframework.poi.excel.entity.ExportParams; | 35 | import org.jeecgframework.poi.excel.entity.ExportParams; |
... | @@ -61,6 +66,11 @@ public class AjhMeetingSendController { | ... | @@ -61,6 +66,11 @@ public class AjhMeetingSendController { |
61 | @Value("${skua.web-url}") | 66 | @Value("${skua.web-url}") |
62 | private String webUrl; | 67 | private String webUrl; |
63 | 68 | ||
69 | @Autowired | ||
70 | private ISysUserService userService; | ||
71 | @Autowired | ||
72 | private ISysDepartService departService; | ||
73 | |||
64 | /** | 74 | /** |
65 | * <pre> | 75 | * <pre> |
66 | * 分页列表查询 | 76 | * 分页列表查询 |
... | @@ -335,6 +345,17 @@ public class AjhMeetingSendController { | ... | @@ -335,6 +345,17 @@ public class AjhMeetingSendController { |
335 | public Result<AjhMeetingSend> queryById(@RequestParam(name="id",required=true) String id) { | 345 | public Result<AjhMeetingSend> queryById(@RequestParam(name="id",required=true) String id) { |
336 | Result<AjhMeetingSend> result = new Result<AjhMeetingSend>(); | 346 | Result<AjhMeetingSend> result = new Result<AjhMeetingSend>(); |
337 | AjhMeetingSend ajhMeetingSend = ajhMeetingSendService.getById(id); | 347 | AjhMeetingSend ajhMeetingSend = ajhMeetingSendService.getById(id); |
348 | if(ajhMeetingSend != null ){ | ||
349 | if(StringUtils.isNotEmpty(ajhMeetingSend.getMeetCompere())){ | ||
350 | SysUser sysUser = userService.getById(ajhMeetingSend.getMeetCompere()); | ||
351 | ajhMeetingSend.setMeetCompereName( sysUser.getRealname()); | ||
352 | } | ||
353 | |||
354 | if(StringUtils.isNotEmpty(ajhMeetingSend.getDepartId()) && StringUtils.isEmpty(ajhMeetingSend.getDepartName())){ | ||
355 | SysDepart depart = departService.getById(ajhMeetingSend.getDepartId()); | ||
356 | ajhMeetingSend.setDepartName( depart.getDepartName()); | ||
357 | } | ||
358 | } | ||
338 | if(ajhMeetingSend==null) { | 359 | if(ajhMeetingSend==null) { |
339 | result.error500("未找到对应实体"); | 360 | result.error500("未找到对应实体"); |
340 | }else { | 361 | }else { | ... | ... |
... | @@ -130,6 +130,11 @@ public class AjhMeetingSend { | ... | @@ -130,6 +130,11 @@ public class AjhMeetingSend { |
130 | @TableField(exist = false) | 130 | @TableField(exist = false) |
131 | @ApiModelProperty(value = "机构名称") | 131 | @ApiModelProperty(value = "机构名称") |
132 | private java.lang.String departName; | 132 | private java.lang.String departName; |
133 | |||
134 | @TableField(exist = false) | ||
135 | @ApiModelProperty(value = "主持人") | ||
136 | private java.lang.String meetCompereName; | ||
137 | |||
133 | /**邀请人数*/ | 138 | /**邀请人数*/ |
134 | @Excel(name = "邀请人数", width = 15,orderNum = "7") | 139 | @Excel(name = "邀请人数", width = 15,orderNum = "7") |
135 | @TableField(exist = false) | 140 | @TableField(exist = false) |
... | @@ -146,8 +151,5 @@ public class AjhMeetingSend { | ... | @@ -146,8 +151,5 @@ public class AjhMeetingSend { |
146 | @ApiModelProperty(value = "会议内容") | 151 | @ApiModelProperty(value = "会议内容") |
147 | private String meetContentHtml; | 152 | private String meetContentHtml; |
148 | 153 | ||
149 | public String getMeetContentHtml() { | 154 | |
150 | meetContentHtml = BaseUtil.delHTMLTag( this.getMeetContent()); | ||
151 | return meetContentHtml; | ||
152 | } | ||
153 | } | 155 | } | ... | ... |
... | @@ -34,15 +34,16 @@ public class CustomConsumeController { | ... | @@ -34,15 +34,16 @@ public class CustomConsumeController { |
34 | * <pre> | 34 | * <pre> |
35 | * 自定义分析获取数据类型 | 35 | * 自定义分析获取数据类型 |
36 | * </pre> | 36 | * </pre> |
37 | * @param granularity 时间粒度 | ||
37 | * @return | 38 | * @return |
38 | * @author Li Yuanyuan, 2021年1月29日 下午3:07:12 | 39 | * @author Li Yuanyuan, 2021年1月29日 下午3:07:12 |
39 | */ | 40 | */ |
40 | @ApiOperation(value="自定义分析获取数据类型", notes="自定义分析获取数据类型") | 41 | @ApiOperation(value="自定义分析获取数据类型", notes="自定义分析获取数据类型") |
41 | @GetMapping(value = "/getDataType") | 42 | @GetMapping(value = "/getDataType") |
42 | public Result<List<TreeData>> getDataType(){ | 43 | public Result<List<TreeData>> getDataType(String granularity){ |
43 | Result<List<TreeData>> result = new Result<List<TreeData>>(); | 44 | Result<List<TreeData>> result = new Result<List<TreeData>>(); |
44 | List<TreeData> dataTypeList = new ArrayList<TreeData>(); | 45 | List<TreeData> dataTypeList = new ArrayList<TreeData>(); |
45 | dataTypeList = customConsumeService.getDataType(); | 46 | dataTypeList = customConsumeService.getDataType(granularity); |
46 | result.setResult(dataTypeList); | 47 | result.setResult(dataTypeList); |
47 | result.setSuccess(true); | 48 | result.setSuccess(true); |
48 | return result; | 49 | return result; |
... | @@ -140,9 +141,9 @@ public class CustomConsumeController { | ... | @@ -140,9 +141,9 @@ public class CustomConsumeController { |
140 | 141 | ||
141 | @ApiOperation(value="填报指标获取", notes="填报指标获取") | 142 | @ApiOperation(value="填报指标获取", notes="填报指标获取") |
142 | @GetMapping(value = "/queryDataFillIndex") | 143 | @GetMapping(value = "/queryDataFillIndex") |
143 | public Result<List<Map<String,Object>>> queryDataFillIndex(String reportId) { | 144 | public Result<List<Map<String,Object>>> queryDataFillIndex(String reportId,String granularity) { |
144 | Result<List<Map<String,Object>>> result = new Result<List<Map<String,Object>>>(); | 145 | Result<List<Map<String,Object>>> result = new Result<List<Map<String,Object>>>(); |
145 | List<Map<String, Object>> list = customConsumeService.queryDataFillIndex(reportId); | 146 | List<Map<String, Object>> list = customConsumeService.queryDataFillIndex(reportId,granularity); |
146 | result.setResult(list); | 147 | result.setResult(list); |
147 | result.setSuccess(true); | 148 | result.setSuccess(true); |
148 | return result; | 149 | return result; | ... | ... |
... | @@ -41,4 +41,9 @@ public class AnalyseCustomConsume { | ... | @@ -41,4 +41,9 @@ public class AnalyseCustomConsume { |
41 | @Excel(name = "历史指标标记名称", width = 15) | 41 | @Excel(name = "历史指标标记名称", width = 15) |
42 | @ApiModelProperty(value = "历史指标标记名称") | 42 | @ApiModelProperty(value = "历史指标标记名称") |
43 | private java.lang.String analyseTitle; | 43 | private java.lang.String analyseTitle; |
44 | |||
45 | @Excel(name = "分析指标时间粒度", width = 15) | ||
46 | @ApiModelProperty(value = "分析指标时间粒度") | ||
47 | private java.lang.String analyseGranularity; | ||
48 | |||
44 | } | 49 | } | ... | ... |
... | @@ -54,7 +54,7 @@ public interface ICustomConsumeService { | ... | @@ -54,7 +54,7 @@ public interface ICustomConsumeService { |
54 | * @return | 54 | * @return |
55 | * @author Li Yuanyuan, 2021年1月29日 下午3:10:42 | 55 | * @author Li Yuanyuan, 2021年1月29日 下午3:10:42 |
56 | */ | 56 | */ |
57 | public List<TreeData> getDataType(); | 57 | public List<TreeData> getDataType(String granularity); |
58 | /** | 58 | /** |
59 | * <pre> | 59 | * <pre> |
60 | * 实时数据/水质水量 | 60 | * 实时数据/水质水量 |
... | @@ -89,10 +89,11 @@ public interface ICustomConsumeService { | ... | @@ -89,10 +89,11 @@ public interface ICustomConsumeService { |
89 | * 报表数据项获取 | 89 | * 报表数据项获取 |
90 | * </pre> | 90 | * </pre> |
91 | * @param reportId | 91 | * @param reportId |
92 | * @param granularity 时间粒度 | ||
92 | * @return | 93 | * @return |
93 | * @author Li Yuanyuan, 2021年2月3日 下午3:39:44 | 94 | * @author Li Yuanyuan, 2021年2月3日 下午3:39:44 |
94 | */ | 95 | */ |
95 | public List<Map<String, Object>> queryDataFillIndex(String reportId); | 96 | public List<Map<String, Object>> queryDataFillIndex(String reportId,String granularity); |
96 | 97 | ||
97 | 98 | ||
98 | } | 99 | } | ... | ... |
sk-module-biz/src/main/java/com/skua/modules/dataAnalysis/service/impl/CustomConsumeServiceImpl.java
... | @@ -274,7 +274,7 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService { | ... | @@ -274,7 +274,7 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService { |
274 | pattern = "yyyy-MM"; | 274 | pattern = "yyyy-MM"; |
275 | type = "year"; | 275 | type = "year"; |
276 | } | 276 | } |
277 | List<Map<String, Object>> list = reportItemService.getReportItemData(departId,reportId, startTime, endTime, indexs); | 277 | List<Map<String, Object>> list = reportItemService.getReportItemData(departId,reportId, startTime, endTime, indexs,granularity); |
278 | //获取部门数据 | 278 | //获取部门数据 |
279 | List<Map<String, Object>> handleList = new ArrayList<Map<String,Object>>();//接收处理结果 | 279 | List<Map<String, Object>> handleList = new ArrayList<Map<String,Object>>();//接收处理结果 |
280 | String[] factoryArray = departId.split(","); | 280 | String[] factoryArray = departId.split(","); |
... | @@ -366,7 +366,7 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService { | ... | @@ -366,7 +366,7 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService { |
366 | if(!StringUtils.isEmpty(contrastType)&&contrastType.contains("tb")) { | 366 | if(!StringUtils.isEmpty(contrastType)&&contrastType.contains("tb")) { |
367 | String tbStartTime = DateUtils.formatAddTime(startTime,pattern,Calendar.YEAR,-1); | 367 | String tbStartTime = DateUtils.formatAddTime(startTime,pattern,Calendar.YEAR,-1); |
368 | String tbEndTime = DateUtils.formatAddTime(endTime,pattern,Calendar.YEAR,-1); | 368 | String tbEndTime = DateUtils.formatAddTime(endTime,pattern,Calendar.YEAR,-1); |
369 | List<Map<String, Object>> tbList =reportItemService.getReportItemData(departId,reportId, tbStartTime, tbEndTime, indexs); | 369 | List<Map<String, Object>> tbList =reportItemService.getReportItemData(departId,reportId, tbStartTime, tbEndTime, indexs,granularity); |
370 | for(Map<String, Object> map : tbList) { | 370 | for(Map<String, Object> map : tbList) { |
371 | tbMap.put(ConvertUtils.getString(map.get("time")+""+map.get("departId")), map); | 371 | tbMap.put(ConvertUtils.getString(map.get("time")+""+map.get("departId")), map); |
372 | } | 372 | } |
... | @@ -374,7 +374,7 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService { | ... | @@ -374,7 +374,7 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService { |
374 | if(!StringUtils.isEmpty(contrastType)&&contrastType.contains("hb")) { | 374 | if(!StringUtils.isEmpty(contrastType)&&contrastType.contains("hb")) { |
375 | String hbStartTime = DateUtils.formatAddTime(startTime,pattern,Calendar.MONTH,-1); | 375 | String hbStartTime = DateUtils.formatAddTime(startTime,pattern,Calendar.MONTH,-1); |
376 | String hbEndTime = DateUtils.formatAddTime(endTime,pattern,Calendar.MONTH,-1); | 376 | String hbEndTime = DateUtils.formatAddTime(endTime,pattern,Calendar.MONTH,-1); |
377 | List<Map<String, Object>> hbList =reportItemService.getReportItemData(departId,reportId, hbStartTime, hbEndTime, indexs); | 377 | List<Map<String, Object>> hbList =reportItemService.getReportItemData(departId,reportId, hbStartTime, hbEndTime, indexs,granularity); |
378 | for(Map<String, Object> map : hbList) { | 378 | for(Map<String, Object> map : hbList) { |
379 | hbMap.put(ConvertUtils.getString(map.get("time")+""+map.get("departId")), map); | 379 | hbMap.put(ConvertUtils.getString(map.get("time")+""+map.get("departId")), map); |
380 | } | 380 | } |
... | @@ -402,26 +402,31 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService { | ... | @@ -402,26 +402,31 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService { |
402 | } | 402 | } |
403 | 403 | ||
404 | @Override | 404 | @Override |
405 | public List<TreeData> getDataType() { | 405 | public List<TreeData> getDataType(String granularity) { |
406 | List<Map<String,Object>> dataTypeList = new ArrayList<Map<String,Object>>(); | 406 | List<Map<String,Object>> dataTypeList = new ArrayList<Map<String,Object>>(); |
407 | Map<String,Object> ssmap = new HashMap<String,Object>(); | 407 | Map<String,Object> ssmap = new HashMap<String,Object>(); |
408 | ssmap.put("id", "ss"); | 408 | ssmap.put("id", "ss"); |
409 | ssmap.put("pid", ""); | 409 | ssmap.put("pid", ""); |
410 | ssmap.put("title", "实时"); | 410 | ssmap.put("title", "实时"); |
411 | dataTypeList.add(ssmap); | ||
412 | Map<String,Object> szmap = new HashMap<String,Object>(); | 411 | Map<String,Object> szmap = new HashMap<String,Object>(); |
413 | szmap.put("id", "sz"); | 412 | szmap.put("id", "sz"); |
414 | szmap.put("pid", "ss"); | 413 | szmap.put("pid", "ss"); |
415 | szmap.put("title", "采集数据"); | 414 | szmap.put("title", "采集数据"); |
415 | if("hour".equals(granularity)||"day".equals(granularity)) { | ||
416 | dataTypeList.add(ssmap); | ||
417 | dataTypeList.add(szmap); | ||
418 | } | ||
416 | Map<String,Object> tbmap = new HashMap<String,Object>(); | 419 | Map<String,Object> tbmap = new HashMap<String,Object>(); |
417 | tbmap.put("id", "tb"); | 420 | tbmap.put("id", "tb"); |
418 | tbmap.put("pid", ""); | 421 | tbmap.put("pid", ""); |
419 | tbmap.put("title", "填报"); | 422 | tbmap.put("title", "填报"); |
420 | dataTypeList.add(szmap); | 423 | if("day".equals(granularity)||"month".equals(granularity)) { |
421 | dataTypeList.add(tbmap); | 424 | dataTypeList.add(tbmap); |
425 | } | ||
422 | QueryWrapper<FReportManage> fReportManageQueryWrapper = new QueryWrapper<>(); | 426 | QueryWrapper<FReportManage> fReportManageQueryWrapper = new QueryWrapper<>(); |
423 | fReportManageQueryWrapper.eq("status","1"); | 427 | fReportManageQueryWrapper.eq("status","1"); |
424 | fReportManageQueryWrapper.eq("pro_status","1"); | 428 | fReportManageQueryWrapper.eq("pro_status","1"); |
429 | fReportManageQueryWrapper.eq("time_type", granularity); | ||
425 | fReportManageQueryWrapper.orderByAsc("sort_num"); | 430 | fReportManageQueryWrapper.orderByAsc("sort_num"); |
426 | List<FReportManage> fReportManages = reportManageService.list(fReportManageQueryWrapper); | 431 | List<FReportManage> fReportManages = reportManageService.list(fReportManageQueryWrapper); |
427 | for (FReportManage fReportManage : fReportManages) { | 432 | for (FReportManage fReportManage : fReportManages) { |
... | @@ -431,6 +436,12 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService { | ... | @@ -431,6 +436,12 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService { |
431 | report.put("title", fReportManage.getReportName()); | 436 | report.put("title", fReportManage.getReportName()); |
432 | dataTypeList.add(report); | 437 | dataTypeList.add(report); |
433 | } | 438 | } |
439 | //填报追加公式计算字段 | ||
440 | Map<String, Object> formulaReport = new HashMap<>(); | ||
441 | formulaReport.put("id", "formula"); | ||
442 | formulaReport.put("pid", "tb"); | ||
443 | formulaReport.put("title", "填报计算"); | ||
444 | dataTypeList.add(formulaReport); | ||
434 | //将业务数据转换为构造树所需的数据结构 | 445 | //将业务数据转换为构造树所需的数据结构 |
435 | List<TransTreeModel> transTreeModels = dataTypeList.stream().map(bo -> convertToTreeModel(bo)).collect(Collectors.toList()); | 446 | List<TransTreeModel> transTreeModels = dataTypeList.stream().map(bo -> convertToTreeModel(bo)).collect(Collectors.toList()); |
436 | List<TreeData> treeList=TreeUtils.buildTreeByRootId(transTreeModels, ""); | 447 | List<TreeData> treeList=TreeUtils.buildTreeByRootId(transTreeModels, ""); |
... | @@ -477,9 +488,14 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService { | ... | @@ -477,9 +488,14 @@ public class CustomConsumeServiceImpl implements ICustomConsumeService { |
477 | } | 488 | } |
478 | 489 | ||
479 | @Override | 490 | @Override |
480 | public List<Map<String, Object>> queryDataFillIndex(String reportId) { | 491 | public List<Map<String, Object>> queryDataFillIndex(String reportId,String granularity) { |
481 | JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master"); | 492 | JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master"); |
482 | List<Map<String, Object>> list = masterDB.queryForList("select item_code as indexCode,item_alias as indexName,unit as indexUnit from f_report_item where report_id='"+reportId+"' and is_use_power_analyse='1' order by sort_num"); | 493 | List<Map<String, Object>> list = null; |
494 | if("formula".equals(reportId)) { | ||
495 | list = masterDB.queryForList("select formula_code as indexCode,formula_name as indexName,formula_unit as indexUnit from f_report_itemv_formula where report_id='"+reportId+"' and formula_granularity='"+granularity+"' order by sort_num"); | ||
496 | }else { | ||
497 | list = masterDB.queryForList("select item_code as indexCode,item_alias as indexName,unit as indexUnit from f_report_item where report_id='"+reportId+"' and is_use_power_analyse='1' order by sort_num"); | ||
498 | } | ||
483 | return list; | 499 | return list; |
484 | } | 500 | } |
485 | } | 501 | } | ... | ... |
sk-module-biz/src/main/java/com/skua/modules/erp/controller/TestMetricInfoController.java
0 → 100644
1 | package com.skua.modules.erp.controller; | ||
2 | |||
3 | import cn.hutool.core.util.RandomUtil; | ||
4 | import com.skua.common.util.ChineseInital; | ||
5 | import com.skua.core.api.vo.Result; | ||
6 | import com.skua.core.aspect.annotation.AutoLog; | ||
7 | import com.skua.core.context.SpringContextUtils; | ||
8 | import com.skua.core.service.IFactoryInfoService; | ||
9 | import com.skua.core.util.ConvertUtils; | ||
10 | import com.skua.core.util.DateUtils; | ||
11 | import com.skua.modules.equipment.vo.EquipmentRealTimeVO; | ||
12 | import com.skua.modules.erp.vo.MetricInfoVO; | ||
13 | import com.skua.modules.erp.vo.RealTimeHistoryDataVO; | ||
14 | import io.swagger.annotations.Api; | ||
15 | import io.swagger.annotations.ApiOperation; | ||
16 | import org.apache.commons.lang.StringUtils; | ||
17 | import org.springframework.beans.factory.annotation.Autowired; | ||
18 | import org.springframework.dao.DataAccessException; | ||
19 | import org.springframework.jdbc.core.BeanPropertyRowMapper; | ||
20 | import org.springframework.jdbc.core.JdbcTemplate; | ||
21 | import org.springframework.web.bind.annotation.GetMapping; | ||
22 | import org.springframework.web.bind.annotation.RequestMapping; | ||
23 | import org.springframework.web.bind.annotation.RequestParam; | ||
24 | import org.springframework.web.bind.annotation.RestController; | ||
25 | import java.util.*; | ||
26 | |||
27 | @Api(tags="设备-设备运行台时报表") | ||
28 | @RestController | ||
29 | @RequestMapping("/test/metricInfo") | ||
30 | public class TestMetricInfoController { | ||
31 | |||
32 | @Autowired | ||
33 | private IFactoryInfoService iFactoryInfoService; | ||
34 | |||
35 | |||
36 | @AutoLog(value = "设备-设备运行台时报表") | ||
37 | @ApiOperation(value = "设备-设备运行台时报表", notes = "设备-设备运行台时报表") | ||
38 | @GetMapping(value = "/realTimeHistoryData") | ||
39 | public Result<RealTimeHistoryDataVO> equipRealTimeHistoryDataCtrl(@RequestParam(value = "departId") String departId, | ||
40 | @RequestParam(value = "startTime") String startTime, | ||
41 | @RequestParam(value = "endTime") String endTime) { | ||
42 | Result<RealTimeHistoryDataVO> result = new Result<>(); | ||
43 | RealTimeHistoryDataVO realTimeHistoryDataVO = new RealTimeHistoryDataVO(); | ||
44 | //String fields = "TCSWSCLC_PLC300_Tag182,TCSWSCLC_PLC300_Tag185"; | ||
45 | JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master"); | ||
46 | String metricInfoSql = "select ei.equipment_name , t.metric_express1 'gzExpress' , t.metric_express2 'yxExpress' ,t.metric_express3 'tzExpress' from sys_monitor_metric_info t "; | ||
47 | metricInfoSql += " left join equipment_info ei on ei.id = t.equipment_code "; | ||
48 | metricInfoSql += " where t.metric_type = 1 and t.depart_id = '"+departId+"' and t.equipment_code > 0 " ; | ||
49 | List<MetricInfoVO> metricInfoVOList = masterDB.query(metricInfoSql,new BeanPropertyRowMapper<MetricInfoVO>(MetricInfoVO.class)); | ||
50 | |||
51 | //StringBuffer fields= new StringBuffer(); | ||
52 | String fields = ""; | ||
53 | if(metricInfoVOList != null ){ | ||
54 | for(MetricInfoVO metricInfoVO : metricInfoVOList){ | ||
55 | String equipmentName = metricInfoVO.getEquipmentName().replaceAll("[^\\u4e00-\\u9fa5]", ""); | ||
56 | String equipmentCode = ChineseInital.getAllFirstLetter(equipmentName)+"_"+ RandomUtil.randomNumbers(2); | ||
57 | metricInfoVO.setEquipmentName(equipmentName ); | ||
58 | metricInfoVO.setEquipmentCode(equipmentCode ); | ||
59 | if(StringUtils.isNotEmpty(metricInfoVO.getGzExpress())){ | ||
60 | fields += metricInfoVO.getGzExpress()+","; | ||
61 | } | ||
62 | if(StringUtils.isNotEmpty(metricInfoVO.getYxExpress())){ | ||
63 | fields += metricInfoVO.getYxExpress()+","; | ||
64 | } | ||
65 | if(StringUtils.isNotEmpty(metricInfoVO.getTzExpress())){ | ||
66 | fields += metricInfoVO.getTzExpress()+","; | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | |||
71 | if (fields.endsWith(",")) { | ||
72 | fields = fields.substring(0, fields.length() - 1); | ||
73 | } | ||
74 | List<Map<String, Object>> pgDataList = iFactoryInfoService.queryFactoryInfos(departId, fields, startTime, endTime, "1"); | ||
75 | |||
76 | List<Map<String, Object>> dataList = null; | ||
77 | if(pgDataList != null ) { | ||
78 | dataList = new ArrayList<>(pgDataList.size()); | ||
79 | Map<String, Object> dataMap = null; | ||
80 | //elect ts as time,nm as monitorId,v as monitorValue | ||
81 | String equipmentCode = null; | ||
82 | for (Map<String, Object> paramMap : pgDataList) { | ||
83 | dataMap = new HashMap<>(); | ||
84 | dataMap.put("time",DateUtils.formatTime(Long.parseLong(paramMap.get("time") + "000")) ); | ||
85 | for(MetricInfoVO metricInfoVO : metricInfoVOList){ | ||
86 | dataMap.put( metricInfoVO.getEquipmentCode()+"_YX" , ConvertUtils.getString(paramMap.get(metricInfoVO.getYxExpress())));//运行 | ||
87 | dataMap.put( metricInfoVO.getEquipmentCode()+"_GZ" , ConvertUtils.getString(paramMap.get(metricInfoVO.getGzExpress())));//故障 | ||
88 | dataMap.put( metricInfoVO.getEquipmentCode()+"_ZT" ,60 - ConvertUtils.getDouble(paramMap.get(metricInfoVO.getYxExpress()),0) - ConvertUtils.getDouble(paramMap.get(metricInfoVO.getGzExpress()) ,0) );//暂停 | ||
89 | } | ||
90 | |||
91 | dataList.add( dataMap ); | ||
92 | } | ||
93 | } | ||
94 | /* //拼装数据 | ||
95 | Map<String, Map<String,String>> linkedHashMap = new LinkedHashMap<String, Map<String,String>>();//返回数据结果 | ||
96 | String timeTemp = null; | ||
97 | Map<String,String> dataMap = null; | ||
98 | if(pgDataList != null ){ | ||
99 | //elect ts as time,nm as monitorId,v as monitorValue | ||
100 | for( Map<String, Object> paramMap : pgDataList){ | ||
101 | timeTemp = DateUtils.formatTime(Long.parseLong(paramMap.get("time") + "000")); | ||
102 | dataMap = linkedHashMap.get(timeTemp); | ||
103 | if(dataMap == null ){ | ||
104 | dataMap = new HashMap<>(); | ||
105 | dataMap.put("time",timeTemp); | ||
106 | for (Map.Entry<String, String> entry : nameMap.entrySet()) { | ||
107 | dataMap.put(entry.getKey(),"0"); | ||
108 | } | ||
109 | } | ||
110 | // 使用For-Each迭代entries,通过Map.entrySet遍历key和value | ||
111 | for (Map.Entry<String, String> entry : nameMap.entrySet()) { | ||
112 | System.out.println("entry.getKey()" +entry.getKey()+ "****"+"paramMap.get() = "+paramMap.get(entry.getKey())); | ||
113 | if(entry.getKey().equals( ConvertUtils.getString(paramMap.get(entry.getKey())) )){ | ||
114 | dataMap.put( entry.getValue() , ConvertUtils.getString(paramMap.get(entry.getKey()))); | ||
115 | } | ||
116 | } | ||
117 | linkedHashMap.put(timeTemp,dataMap); | ||
118 | } | ||
119 | }*/ | ||
120 | |||
121 | realTimeHistoryDataVO.setHeadList( metricInfoVOList); | ||
122 | realTimeHistoryDataVO.setDataList( dataList ); | ||
123 | result.setResult( realTimeHistoryDataVO); | ||
124 | return result; | ||
125 | } | ||
126 | |||
127 | } |
1 | package com.skua.modules.erp.vo; | ||
2 | |||
3 | import cn.hutool.core.util.RandomUtil; | ||
4 | import com.skua.common.util.ChineseInital; | ||
5 | import io.swagger.annotations.ApiModel; | ||
6 | import io.swagger.annotations.ApiModelProperty; | ||
7 | import lombok.Data; | ||
8 | import lombok.EqualsAndHashCode; | ||
9 | import lombok.experimental.Accessors; | ||
10 | |||
11 | @Data | ||
12 | @EqualsAndHashCode(callSuper = false) | ||
13 | @Accessors(chain = true) | ||
14 | @ApiModel(value="sys_monitor_metric_info对象", description="数据项管理") | ||
15 | public class MetricInfoVO { | ||
16 | @ApiModelProperty(value = "名称") | ||
17 | private String equipmentName;// | ||
18 | |||
19 | @ApiModelProperty(value = "设备编码") | ||
20 | private java.lang.String equipmentCode; | ||
21 | @ApiModelProperty(value = "故障表达式") | ||
22 | private String gzExpress; | ||
23 | @ApiModelProperty(value = "运行表达式") | ||
24 | private String yxExpress; | ||
25 | @ApiModelProperty(value = "停止编码") | ||
26 | private String tzExpress; | ||
27 | |||
28 | |||
29 | } |
1 | package com.skua.modules.erp.vo; | ||
2 | |||
3 | import io.swagger.annotations.ApiModel; | ||
4 | import io.swagger.annotations.ApiModelProperty; | ||
5 | import lombok.Data; | ||
6 | import lombok.EqualsAndHashCode; | ||
7 | import lombok.experimental.Accessors; | ||
8 | |||
9 | import java.util.List; | ||
10 | import java.util.Map; | ||
11 | |||
12 | @Data | ||
13 | @EqualsAndHashCode(callSuper = false) | ||
14 | @Accessors(chain = true) | ||
15 | @ApiModel(value="设备运行台时报表对象", description="设备运行台时报表对象") | ||
16 | public class RealTimeHistoryDataVO { | ||
17 | |||
18 | @ApiModelProperty(value = "表头集合") | ||
19 | private List<MetricInfoVO> headList; | ||
20 | |||
21 | |||
22 | @ApiModelProperty(value = "列表集合数据") | ||
23 | private List<Map<String, Object>> dataList; | ||
24 | |||
25 | } |
... | @@ -39,7 +39,7 @@ public interface IFReportItemService extends IService<FReportItem> { | ... | @@ -39,7 +39,7 @@ public interface IFReportItemService extends IService<FReportItem> { |
39 | * @return | 39 | * @return |
40 | * @author Li Yuanyuan, 2021年2月3日 下午5:03:47 | 40 | * @author Li Yuanyuan, 2021年2月3日 下午5:03:47 |
41 | */ | 41 | */ |
42 | List<Map<String,Object>> getReportItemData(String departIds,String reportId,String startTime,String endTime,String index); | 42 | List<Map<String,Object>> getReportItemData(String departIds,String reportId,String startTime,String endTime,String index,String granularity); |
43 | 43 | ||
44 | Map<String, Object> getReportData(String reportId, String dataId); | 44 | Map<String, Object> getReportData(String reportId, String dataId); |
45 | 45 | ... | ... |
1 | package com.skua.modules.report.service.impl; | 1 | package com.skua.modules.report.service.impl; |
2 | 2 | ||
3 | import com.skua.common.report.ReportViewUtil; | 3 | import java.util.ArrayList; |
4 | import com.skua.modules.report.entity.FReportItem; | 4 | import java.util.Arrays; |
5 | import com.skua.modules.report.mapper.FReportItemMapper; | 5 | import java.util.HashMap; |
6 | import com.skua.modules.report.service.IFReportItemService; | 6 | import java.util.LinkedHashSet; |
7 | import java.util.List; | ||
8 | import java.util.Map; | ||
9 | import java.util.Set; | ||
10 | import java.util.stream.Collectors; | ||
11 | |||
12 | import javax.annotation.Resource; | ||
7 | 13 | ||
8 | import org.apache.commons.lang.StringUtils; | 14 | import org.apache.commons.lang.StringUtils; |
15 | import org.springframework.jdbc.core.JdbcTemplate; | ||
9 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
10 | 17 | ||
11 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
12 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 18 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
13 | 19 | import com.skua.common.report.CustomReportUtil; | |
14 | import javax.annotation.Resource; | 20 | import com.skua.common.report.ReportViewUtil; |
15 | 21 | import com.skua.core.context.SpringContextUtils; | |
16 | import java.util.HashMap; | 22 | import com.skua.core.util.ConvertUtils; |
17 | import java.util.List; | 23 | import com.skua.modules.report.entity.FReportItem; |
18 | import java.util.Map; | 24 | import com.skua.modules.report.mapper.FReportItemMapper; |
25 | import com.skua.modules.report.service.IFReportItemService; | ||
19 | 26 | ||
20 | /** | 27 | /** |
21 | * 报表数据项管理 | 28 | * 报表数据项管理 |
... | @@ -96,35 +103,104 @@ public class FReportItemServiceImpl extends ServiceImpl<FReportItemMapper, FRepo | ... | @@ -96,35 +103,104 @@ public class FReportItemServiceImpl extends ServiceImpl<FReportItemMapper, FRepo |
96 | return list; | 103 | return list; |
97 | } | 104 | } |
98 | 105 | ||
106 | //fReportManageQueryWrapper.eq("status","1"); | ||
107 | //fReportManageQueryWrapper.eq("pro_status","1"); | ||
108 | //fReportManageQueryWrapper.eq("time_type", granularity); | ||
99 | @Override | 109 | @Override |
100 | public List<Map<String, Object>> getReportItemData(String departIds,String reportId, String startTime, String endTime,String indexs) { | 110 | public List<Map<String, Object>> getReportItemData(String departIds,String reportId, String startTime, String endTime,String indexs,String granularity) { |
101 | String[] indexArray = indexs.split(","); | 111 | String[] indexArray = indexs.split(","); |
112 | //查询报表计算指标 | ||
113 | JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master"); | ||
114 | String formulaSql = "select formula_code,formula_info from f_report_itemv_formula where formula_granularity='"+granularity+"'"; | ||
115 | List<Map<String, Object>> formulaList = masterDB.queryForList(formulaSql); | ||
116 | Map<String,String> formulaMap = new HashMap<String,String>(); | ||
117 | for(Map<String,Object> map : formulaList) { | ||
118 | formulaMap.put(ConvertUtils.getString(map.get("formula_code")), ConvertUtils.getString(map.get("formula_info"))); | ||
119 | } | ||
120 | //对计算指标进行解析,追加到基础查询指标 | ||
121 | Set<String> indexSet = new LinkedHashSet<String>();//查询指标 | ||
122 | //存在计算指标,重新构造基础指标集合 | ||
102 | String selectPart = ""; | 123 | String selectPart = ""; |
103 | String headSelectPart = ""; | ||
104 | String formulaIds = ""; | ||
105 | for(String index : indexArray) { | 124 | for(String index : indexArray) { |
125 | if(index.contains("formula_")) { | ||
126 | String formula = formulaMap.get(index); | ||
127 | selectPart = selectPart+",round("+formulaMap.get(index).replace("{", "IFNULL(").replace("}", ",0)")+",2) as "+index; | ||
128 | //提取计算指标 | ||
129 | List<String> formulaIndexList = CustomReportUtil.getFormulaElement(formula); | ||
130 | for(String formulaIndex : formulaIndexList) { | ||
131 | indexSet.add(formulaIndex); | ||
132 | } | ||
133 | }else { | ||
106 | selectPart = selectPart+","+index; | 134 | selectPart = selectPart+","+index; |
107 | headSelectPart = headSelectPart+", max(case when item_code = '"+index+"' then CONCAT(item_alias,'(',unit,')') else '' end) as '"+index+"'"; | 135 | indexSet.add(index); |
108 | formulaIds = formulaIds+","+"'"+index+"'"; | 136 | } |
109 | } | 137 | } |
110 | if(!StringUtils.isEmpty(formulaIds)) { | 138 | indexs = String.join(",", indexSet); |
111 | selectPart = selectPart.substring(1); | 139 | //对基础查询指标按照报表进行分组 |
112 | headSelectPart = headSelectPart.substring(1); | 140 | String queryDataFillFieldSql="select item_code,report_id from f_report_item where report_id in(select id from f_report_manage where status='1' and pro_status='1' and time_type='"+granularity+"')"; |
113 | formulaIds = formulaIds.substring(1); | 141 | List<Map<String, Object>> baseDataFillFieldList = masterDB.queryForList(queryDataFillFieldSql); |
114 | } | 142 | Map<String,String> fieldToReportIdMap = new HashMap<String,String>(); |
115 | String headWhereInPart = "item_code IN("+formulaIds+")"; | 143 | for(Map<String,Object> map : baseDataFillFieldList) { |
116 | 144 | fieldToReportIdMap.put(ConvertUtils.getString(map.get("item_code")), ConvertUtils.getString(map.get("report_id"))); | |
117 | Map<String,String> paramMap = new HashMap<String,String>(); | 145 | } |
118 | paramMap.put("viewName", ReportViewUtil.buildView(reportId, indexs, departIds, startTime, endTime)); | 146 | String[] tempIndexArray = indexs.split(","); |
119 | //paramMap.put("viewName", "view_"+reportId.substring(0, 4)); | 147 | Map<String,List<String>> reportIndexGroup = new HashMap<String,List<String>>(); |
120 | paramMap.put("startTime", startTime); | 148 | for(String key : tempIndexArray) { |
121 | paramMap.put("endTime", endTime); | 149 | String tempReportId = fieldToReportIdMap.get(key); |
122 | paramMap.put("dataSelectPart", selectPart); | 150 | List<String> reportIndexList = reportIndexGroup.get(tempReportId); |
123 | paramMap.put("headSelectPart", headSelectPart); | 151 | if(reportIndexList!=null) { |
124 | paramMap.put("headWhereInPart", headWhereInPart); | 152 | reportIndexList.add(key); |
125 | paramMap.put("reportId", reportId); | 153 | }else { |
126 | paramMap.put("departIds", departIds); | 154 | reportIndexList = new ArrayList<String>(); |
127 | return fReportItemMapper.getReportItemData(paramMap); | 155 | reportIndexList.add(key); |
156 | reportIndexGroup.put(tempReportId, reportIndexList); | ||
157 | } | ||
158 | } | ||
159 | //基于报表做基础指标查询 | ||
160 | Set<String> reportIdSet = reportIndexGroup.keySet(); | ||
161 | //构造日期机构主参照表动态视图 | ||
162 | String baseViewPattern = "%Y-%m-%d"; | ||
163 | String baseViewGranularity = "DAY"; | ||
164 | String[] departIdArray = departIds.split(","); | ||
165 | String temp = ""; | ||
166 | for(String tempDepartId : departIdArray) { | ||
167 | temp = temp+",'"+tempDepartId+"'"; | ||
168 | } | ||
169 | if(StringUtils.isNotEmpty(temp)) { | ||
170 | temp = temp.substring(1); | ||
171 | } | ||
172 | String tempStartTime = startTime; | ||
173 | String tempEndTime = endTime; | ||
174 | if("month".equals(granularity)) { | ||
175 | baseViewPattern = "%Y-%m"; | ||
176 | baseViewGranularity = "MONTH"; | ||
177 | tempStartTime = startTime+"-01"; | ||
178 | tempEndTime = endTime+"-01"; | ||
179 | } | ||
180 | String baseViewName= "(SELECT a.time,b.id as depart_id,b.depart_name FROM (\r\n" + | ||
181 | "SELECT \r\n" + | ||
182 | " DATE_FORMAT(DATE_ADD('"+tempStartTime+"', INTERVAL t.help_topic_id "+baseViewGranularity+"), '"+baseViewPattern+"') AS time\r\n" + | ||
183 | "FROM \r\n" + | ||
184 | " mysql.help_topic t \r\n" + | ||
185 | "WHERE \r\n" + | ||
186 | " t.help_topic_id <= TIMESTAMPDIFF("+baseViewGranularity+", '"+tempStartTime+"', '"+tempEndTime+"')\r\n" + | ||
187 | ") a left join (select * from sys_depart where id in("+Arrays.stream(departIds.split(",")).map(id -> "'" + id + "'").collect(Collectors.joining(","))+")) b on 1=1)"; | ||
188 | |||
189 | int tag=1; | ||
190 | String sql = "select aa.time,aa.depart_id as departId,aa.depart_name as departName"+selectPart+" from "+baseViewName+" aa "; | ||
191 | for(String tempReportId : reportIdSet) { | ||
192 | String viewName = "view"+tag; | ||
193 | List<String> indexList = reportIndexGroup.get(tempReportId); | ||
194 | sql = sql +"left join "+ReportViewUtil.buildView(tempReportId, String.join(",", indexList), departIds, startTime, endTime) +viewName+ " on aa.time = "+viewName+".time and aa.depart_id = "+viewName+".depart_id "; | ||
195 | tag++; | ||
196 | } | ||
197 | System.out.println("======>>>>"+sql); | ||
198 | return masterDB.queryForList(sql); | ||
199 | } | ||
200 | public static void main(String[] args) { | ||
201 | String ids = "1,2,3,4"; | ||
202 | String str = Arrays.stream(ids.split(",")).map(id -> "'" + id + "'").collect(Collectors.joining(",")); | ||
203 | System.out.println(str); | ||
128 | } | 204 | } |
129 | 205 | ||
130 | @Override | 206 | @Override | ... | ... |
... | @@ -110,8 +110,6 @@ public class EquipmentController { | ... | @@ -110,8 +110,6 @@ public class EquipmentController { |
110 | @Autowired | 110 | @Autowired |
111 | private ISysStructDictService sysStructDictService; | 111 | private ISysStructDictService sysStructDictService; |
112 | @Autowired | 112 | @Autowired |
113 | private ISysMetricDictService sysMetricDictService; | ||
114 | @Autowired | ||
115 | private IFactoryInfoService iFactoryInfoService; | 113 | private IFactoryInfoService iFactoryInfoService; |
116 | @Autowired | 114 | @Autowired |
117 | private IPgQueryService pgQueryService; | 115 | private IPgQueryService pgQueryService; | ... | ... |
-
请 注册 或 登录 后发表评论