e062bec7 康伟

kangwei :设备运行时间报表接口

1 个父辈 a0c024ef
...@@ -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 * 分页列表查询
...@@ -336,6 +346,17 @@ public class AjhMeetingSendController { ...@@ -336,6 +346,17 @@ public class AjhMeetingSendController {
336 public Result<AjhMeetingSend> queryById(@RequestParam(name="id",required=true) String id) { 346 public Result<AjhMeetingSend> queryById(@RequestParam(name="id",required=true) String id) {
337 Result<AjhMeetingSend> result = new Result<AjhMeetingSend>(); 347 Result<AjhMeetingSend> result = new Result<AjhMeetingSend>();
338 AjhMeetingSend ajhMeetingSend = ajhMeetingSendService.getById(id); 348 AjhMeetingSend ajhMeetingSend = ajhMeetingSendService.getById(id);
349 if(ajhMeetingSend != null ){
350 if(StringUtils.isNotEmpty(ajhMeetingSend.getMeetCompere())){
351 SysUser sysUser = userService.getById(ajhMeetingSend.getMeetCompere());
352 ajhMeetingSend.setMeetCompereName( sysUser.getRealname());
353 }
354
355 if(StringUtils.isNotEmpty(ajhMeetingSend.getDepartId()) && StringUtils.isEmpty(ajhMeetingSend.getDepartName())){
356 SysDepart depart = departService.getById(ajhMeetingSend.getDepartId());
357 ajhMeetingSend.setDepartName( depart.getDepartName());
358 }
359 }
339 if(ajhMeetingSend==null) { 360 if(ajhMeetingSend==null) {
340 result.error500("未找到对应实体"); 361 result.error500("未找到对应实体");
341 }else { 362 }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 }
......
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 }
...@@ -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;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!