actorref(模块名): 优化数据查询和统计功能
-优化了多个模块的数据查询和统计方法,提高了数据处理效率 - 重构了部分代码结构,增强了系统的可维护性 - 优化了数据库查询SQL,提高了查询性能 - 修复了一些潜在的逻辑错误,提升了数据准确性
正在显示
14 个修改的文件
包含
116 行增加
和
246 行删除
... | @@ -350,8 +350,10 @@ public class AjhRectificationInfoController { | ... | @@ -350,8 +350,10 @@ public class AjhRectificationInfoController { |
350 | 350 | ||
351 | @ApiOperation(value="安全态势总览数据统计:统计教育+题库", notes="安全态势总览数据统计:统计教育+题库") | 351 | @ApiOperation(value="安全态势总览数据统计:统计教育+题库", notes="安全态势总览数据统计:统计教育+题库") |
352 | @RequestMapping(value = "/jyCensus", method = RequestMethod.GET) | 352 | @RequestMapping(value = "/jyCensus", method = RequestMethod.GET) |
353 | public Map<String,Object> jyCensus(@RequestParam(name="now",required=true) String now) { | 353 | public Result<Map<String,Object>> jyCensus(@RequestParam(name="now",required=true) String now) { |
354 | Map<String, Object> result = ajhRectificationInfoService.jyCensus(now); | 354 | Result<Map<String,Object>> result = new Result<Map<String,Object>>(); |
355 | Map<String, Object> map = ajhRectificationInfoService.jyCensus(now); | ||
356 | result.setResult(map); | ||
355 | return result; | 357 | return result; |
356 | } | 358 | } |
357 | } | 359 | } | ... | ... |
... | @@ -93,7 +93,7 @@ public class AjhWasteReportController { | ... | @@ -93,7 +93,7 @@ public class AjhWasteReportController { |
93 | if(reportYear==null){ | 93 | if(reportYear==null){ |
94 | reportYear = String.valueOf(Year.now().getValue()); | 94 | reportYear = String.valueOf(Year.now().getValue()); |
95 | } | 95 | } |
96 | IPage<AjhWasteYearReport> pageList = wasteReportService.queryPageListByYear(page, departId,reportYear); | 96 | IPage<AjhWasteYearReport> pageList = wasteReportService.queryPageListByYear(page, departId, reportYear); |
97 | result.setSuccess(true); | 97 | result.setSuccess(true); |
98 | result.setResult(pageList); | 98 | result.setResult(pageList); |
99 | return result; | 99 | return result; | ... | ... |
... | @@ -9,6 +9,8 @@ import lombok.Data; | ... | @@ -9,6 +9,8 @@ import lombok.Data; |
9 | import org.apache.commons.lang3.StringUtils; | 9 | import org.apache.commons.lang3.StringUtils; |
10 | import org.jeecgframework.poi.excel.annotation.Excel; | 10 | import org.jeecgframework.poi.excel.annotation.Excel; |
11 | 11 | ||
12 | import java.text.DecimalFormat; | ||
13 | |||
12 | /** | 14 | /** |
13 | * 危险废物台账月报报表 | 15 | * 危险废物台账月报报表 |
14 | */ | 16 | */ |
... | @@ -57,11 +59,11 @@ public class AjhWasteMonthReport { | ... | @@ -57,11 +59,11 @@ public class AjhWasteMonthReport { |
57 | @ApiModelProperty(value = "贮存量") | 59 | @ApiModelProperty(value = "贮存量") |
58 | private String monthKeep; | 60 | private String monthKeep; |
59 | 61 | ||
60 | |||
61 | public String getStockOnHand() { | 62 | public String getStockOnHand() { |
62 | //数据之间应进行逻辑验算:期初量+入库量-出库量=在存量。 | 63 | //数据之间应进行逻辑验算:期初量+入库量-出库量=在存量。 |
63 | if(StringUtils.isEmpty(stockOnHand)){ | 64 | if(StringUtils.isEmpty(stockOnHand)){ |
64 | stockOnHand = ConvertUtils.getDouble(monthProduce,0d) + ConvertUtils.getDouble(monthKeep,0d) - ConvertUtils.getDouble(monthOut,0d)+"" ; | 65 | DecimalFormat df = new DecimalFormat("#.##"); |
66 | stockOnHand = df.format(ConvertUtils.getDouble(monthKeep,0d) - ConvertUtils.getDouble(monthOut,0d)) ; | ||
65 | } | 67 | } |
66 | return stockOnHand; | 68 | return stockOnHand; |
67 | } | 69 | } | ... | ... |
1 | package com.skua.modules.ajh.entity; | 1 | package com.skua.modules.ajh.entity; |
2 | 2 | ||
3 | import java.text.DecimalFormat; | ||
3 | import java.util.Date; | 4 | import java.util.Date; |
4 | import com.baomidou.mybatisplus.annotation.IdType; | 5 | import com.baomidou.mybatisplus.annotation.IdType; |
5 | import com.baomidou.mybatisplus.annotation.TableField; | 6 | import com.baomidou.mybatisplus.annotation.TableField; |
6 | import com.baomidou.mybatisplus.annotation.TableId; | 7 | import com.baomidou.mybatisplus.annotation.TableId; |
7 | import com.baomidou.mybatisplus.annotation.TableName; | 8 | import com.baomidou.mybatisplus.annotation.TableName; |
8 | import com.skua.core.aspect.annotation.Dict; | 9 | import com.skua.core.aspect.annotation.Dict; |
10 | import com.skua.core.util.ConvertUtils; | ||
9 | import io.swagger.annotations.ApiModel; | 11 | import io.swagger.annotations.ApiModel; |
10 | import io.swagger.annotations.ApiModelProperty; | 12 | import io.swagger.annotations.ApiModelProperty; |
11 | import lombok.Data; | 13 | import lombok.Data; |
12 | import lombok.EqualsAndHashCode; | 14 | import lombok.EqualsAndHashCode; |
13 | import lombok.experimental.Accessors; | 15 | import lombok.experimental.Accessors; |
14 | import com.fasterxml.jackson.annotation.JsonFormat; | 16 | import com.fasterxml.jackson.annotation.JsonFormat; |
17 | import org.apache.commons.lang3.StringUtils; | ||
15 | import org.springframework.format.annotation.DateTimeFormat; | 18 | import org.springframework.format.annotation.DateTimeFormat; |
16 | import org.jeecgframework.poi.excel.annotation.Excel; | 19 | import org.jeecgframework.poi.excel.annotation.Excel; |
17 | 20 | ||
... | @@ -56,11 +59,23 @@ public class AjhWasteYearReport { | ... | @@ -56,11 +59,23 @@ public class AjhWasteYearReport { |
56 | @ApiModelProperty(value = "年度贮存量") | 59 | @ApiModelProperty(value = "年度贮存量") |
57 | private String yearKeep; | 60 | private String yearKeep; |
58 | 61 | ||
62 | @TableField(exist=false) | ||
63 | @Excel(name = "在存量", width = 15) | ||
64 | @ApiModelProperty(value = "在存量") | ||
65 | private String stockOnHand; | ||
66 | |||
59 | /**出库量*/ | 67 | /**出库量*/ |
60 | @TableField(exist=false) | 68 | @TableField(exist=false) |
61 | @Excel(name = "出库量", width = 15) | 69 | @Excel(name = "出库量", width = 15) |
62 | @ApiModelProperty(value = "出库量") | 70 | @ApiModelProperty(value = "出库量") |
63 | private String yearOut; | 71 | private String yearOut; |
64 | 72 | ||
65 | 73 | public String getStockOnHand() { | |
74 | //数据之间应进行逻辑验算:期初量+入库量-出库量=在存量。 | ||
75 | if(StringUtils.isEmpty(stockOnHand)){ | ||
76 | DecimalFormat df = new DecimalFormat("#.##"); | ||
77 | stockOnHand = df.format(ConvertUtils.getDouble(yearKeep,0d) - ConvertUtils.getDouble(yearOut,0d)) ; | ||
78 | } | ||
79 | return stockOnHand; | ||
80 | } | ||
66 | } | 81 | } | ... | ... |
... | @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; | ... | @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
6 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 6 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
7 | import com.skua.modules.ajh.entity.AjhWasteMonthReport; | 7 | import com.skua.modules.ajh.entity.AjhWasteMonthReport; |
8 | import com.skua.modules.ajh.entity.AjhWasteYearReport; | 8 | import com.skua.modules.ajh.entity.AjhWasteYearReport; |
9 | import com.skua.tool.annotation.Anonymous; | ||
9 | import org.apache.ibatis.annotations.Param; | 10 | import org.apache.ibatis.annotations.Param; |
10 | import com.skua.modules.ajh.entity.AjhWasteProduce; | 11 | import com.skua.modules.ajh.entity.AjhWasteProduce; |
11 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; | 12 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
... | @@ -14,6 +15,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ... | @@ -14,6 +15,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
14 | * 危废产生记录表 | 15 | * 危废产生记录表 |
15 | */ | 16 | */ |
16 | public interface AjhWasteProduceMapper extends BaseMapper<AjhWasteProduce> { | 17 | public interface AjhWasteProduceMapper extends BaseMapper<AjhWasteProduce> { |
18 | |||
17 | /*** | 19 | /*** |
18 | * 月报 | 20 | * 月报 |
19 | * @param page | 21 | * @param page | ... | ... |
... | @@ -46,20 +46,19 @@ | ... | @@ -46,20 +46,19 @@ |
46 | 46 | ||
47 | <select id="queryPageListByYear" resultType="com.skua.modules.ajh.entity.AjhWasteYearReport"> | 47 | <select id="queryPageListByYear" resultType="com.skua.modules.ajh.entity.AjhWasteYearReport"> |
48 | SELECT | 48 | SELECT |
49 | p.id, | 49 | p.id, |
50 | p.waste_code, | 50 | p.waste_code, |
51 | p.waste_name, | 51 | p.waste_name, |
52 | LEFT ( p.pro_out_date, 4 ) AS report_year, | 52 | LEFT ( p.pro_out_date, 4 ) AS report_year, |
53 | ROUND(ifnull(SUM( p.pro_come_count ),0) , 2) AS year_produce, | 53 | ROUND(ifnull(SUM( p.pro_come_count ),0) , 2) AS year_produce, |
54 | ROUND(ifnull(SUM( k.keep_out_count ),0) , 2) AS year_out, | 54 | ROUND(ifnull(SUM( k.keep_out_count ),0) , 2) AS year_out, |
55 | ROUND(ifnull(SUM( k.keep_in_count ),0) , 2) AS year_keep, | 55 | ROUND(ifnull(SUM( k.keep_in_count ),0) , 2) AS year_keep, |
56 | d.depart_name AS depart_name, | 56 | d.depart_name AS depart_name, |
57 | d.id as depart_id | 57 | d.id as depart_id |
58 | FROM | 58 | FROM |
59 | ajh_waste_produce p | 59 | ajh_waste_produce p |
60 | LEFT JOIN ( SELECT * FROM ajh_waste_keep WHERE LEFT ( keep_in_date, 4 ) = #{reportYear} ) k ON p.depart_id = k.depart_id | 60 | LEFT JOIN ( SELECT * FROM ajh_waste_keep WHERE LEFT ( keep_in_date, 4 ) = #{reportYear} ) k ON p.depart_id = k.depart_id |
61 | AND p.waste_code = k.waste_code | 61 | AND p.waste_code = k.waste_code AND p.waste_name = k.waste_name |
62 | AND p.waste_name = k.waste_name | ||
63 | LEFT JOIN sys_depart d ON p.depart_id = d.id | 62 | LEFT JOIN sys_depart d ON p.depart_id = d.id |
64 | WHERE | 63 | WHERE |
65 | LEFT ( p.pro_out_date, 4 ) = #{reportYear} | 64 | LEFT ( p.pro_out_date, 4 ) = #{reportYear} |
... | @@ -70,8 +69,8 @@ | ... | @@ -70,8 +69,8 @@ |
70 | </foreach> | 69 | </foreach> |
71 | </if> | 70 | </if> |
72 | GROUP BY | 71 | GROUP BY |
73 | p.depart_id, | 72 | p.depart_id, |
74 | p.waste_code, | 73 | p.waste_code, |
75 | p.waste_name | 74 | p.waste_name |
76 | </select> | 75 | </select> |
77 | </mapper> | 76 | </mapper> | ... | ... |
... | @@ -5,9 +5,9 @@ import java.util.Map; | ... | @@ -5,9 +5,9 @@ import java.util.Map; |
5 | 5 | ||
6 | public interface IRealTimeDataService { | 6 | public interface IRealTimeDataService { |
7 | 7 | ||
8 | List<Map<String, Object>> queryRealTimeData(String factoryId, String type, String structId,String nmName); | 8 | List<Map<String, Object>> queryRealTimeData(String departId, String type, String structId,String nmName); |
9 | 9 | ||
10 | List<Map<String, Object>> queryStructData(String factoryId); | 10 | List<Map<String, Object>> queryStructData(String departId); |
11 | 11 | ||
12 | 12 | ||
13 | /** | 13 | /** |
... | @@ -17,7 +17,7 @@ public interface IRealTimeDataService { | ... | @@ -17,7 +17,7 @@ public interface IRealTimeDataService { |
17 | * @Param [factoryId] | 17 | * @Param [factoryId] |
18 | * @return java.util.Map<java.lang.String, java.lang.Object> | 18 | * @return java.util.Map<java.lang.String, java.lang.Object> |
19 | **/ | 19 | **/ |
20 | Map<String, Object> getFacInfoByFactoryId(String factoryId); | 20 | Map<String, Object> getFacInfoByFactoryId(String departId); |
21 | 21 | ||
22 | 22 | ||
23 | 23 | ||
... | @@ -34,10 +34,10 @@ public interface IRealTimeDataService { | ... | @@ -34,10 +34,10 @@ public interface IRealTimeDataService { |
34 | * | 34 | * |
35 | * @Description web趋势 | 35 | * @Description web趋势 |
36 | * @Date 2022-03-24 10:12 | 36 | * @Date 2022-03-24 10:12 |
37 | * @Param [factoryId, timeType, startTime, endTime, id] | 37 | * @Param [departId, timeType, startTime, endTime, id] |
38 | * @return java.util.Map<java.lang.String, java.lang.Object> | 38 | * @return java.util.Map<java.lang.String, java.lang.Object> |
39 | **/ | 39 | **/ |
40 | Map<String, Object> getSZTreadWeb(String factoryId, String timeType, String startTime, String endTime, String id); | 40 | Map<String, Object> getSZTreadWeb(String departId, String timeType, String startTime, String endTime, String id); |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * <pre> | 43 | * <pre> |
... | @@ -71,7 +71,7 @@ public interface IRealTimeDataService { | ... | @@ -71,7 +71,7 @@ public interface IRealTimeDataService { |
71 | */ | 71 | */ |
72 | Map<String, Object> getProjectInfo(); | 72 | Map<String, Object> getProjectInfo(); |
73 | 73 | ||
74 | List<Map<String, Object>> queryStructDataApp(String factoryId); | 74 | List<Map<String, Object>> queryStructDataApp(String departId); |
75 | 75 | ||
76 | List<Map<String, Object>> queryRealTimeDataApp(String factoryId, String type, String structId, String sortType,String nmName); | 76 | List<Map<String, Object>> queryRealTimeDataApp(String departId, String type, String structId, String sortType,String nmName); |
77 | } | 77 | } | ... | ... |
... | @@ -118,24 +118,33 @@ public class RealTimeDataServiceImpl implements IRealTimeDataService { | ... | @@ -118,24 +118,33 @@ public class RealTimeDataServiceImpl implements IRealTimeDataService { |
118 | return result; | 118 | return result; |
119 | } | 119 | } |
120 | 120 | ||
121 | /** | ||
122 | * 获取SZT趋势数据 | ||
123 | * @param departId 工厂ID | ||
124 | * @param timeType 时间类型,支持"real"(实时),"hour"(小时),"day"(天) | ||
125 | * @param startTime 开始时间 | ||
126 | * @param endTime 结束时间 | ||
127 | * @param id 数据ID,多个ID用逗号分隔 | ||
128 | * @return 包含趋势数据和相关信息的Map对象 | ||
129 | */ | ||
121 | @Override | 130 | @Override |
122 | public Map<String, Object> getSZTreadWeb(String factoryId, String timeType, String startTime, String endTime, String id) { | 131 | public Map<String, Object> getSZTreadWeb(String departId, String timeType, String startTime, String endTime, String id) { |
123 | Map<String, Object> result = Maps.newHashMap(); | 132 | Map<String, Object> result = Maps.newHashMap(); |
124 | //查询指标信息 | 133 | //查询指标信息 |
125 | List<Map<String, Object>> tmp = realTimeDataMapper.queryMetric(factoryId, id); | 134 | List<Map<String, Object>> tmp = realTimeDataMapper.queryMetric(departId, id); |
126 | if (tmp != null && tmp.size() > 0) { | 135 | if (tmp != null && tmp.size() > 0) { |
127 | Map<String, Object> data = Maps.newHashMap(); | 136 | Map<String, Object> data = Maps.newHashMap(); |
128 | switch (timeType) { | 137 | switch (timeType) { |
129 | case "real": | 138 | case "real": |
130 | //查询pg小时表数据 小时 | 139 | //查询pg小时表数据 小时 |
131 | data = pgService.queryTrendDataNew(id, factoryId, startTime, endTime); | 140 | data = pgService.queryTrendDataNew(id, departId, startTime, endTime); |
132 | //data = (List<Map<String, Object>>) map.get("data"); | 141 | //data = (List<Map<String, Object>>) map.get("data"); |
133 | //data = pgService.queryTrendDataNew(tmp, factoryId, startTime, endTime); | 142 | //data = pgService.queryTrendDataNew(tmp, factoryId, startTime, endTime); |
134 | break; | 143 | break; |
135 | case "hour": | 144 | case "hour": |
136 | //查询小时表 | 145 | //查询小时表 |
137 | //data = realTimeDataMapper.queryHourDataByTime(id, factoryId, startTime, endTime); | 146 | //data = realTimeDataMapper.queryHourDataByTime(id, factoryId, startTime, endTime); |
138 | List<Map<String, Object>> maps = factoryInfoService.queryFactoryInfos(factoryId, id, startTime+" 00:00:00", endTime+" 23:59:59", "1"); | 147 | List<Map<String, Object>> maps = factoryInfoService.queryFactoryInfos(departId, id, startTime+" 00:00:00", endTime+" 23:59:59", "1"); |
139 | if (!CollectionUtil.isEmpty(maps)) { | 148 | if (!CollectionUtil.isEmpty(maps)) { |
140 | for (Map<String, Object> map : maps) { | 149 | for (Map<String, Object> map : maps) { |
141 | map.put("time", DateUtils.formatTime(Long.parseLong(map.get("time") + "000"))); | 150 | map.put("time", DateUtils.formatTime(Long.parseLong(map.get("time") + "000"))); |
... | @@ -233,18 +242,18 @@ public class RealTimeDataServiceImpl implements IRealTimeDataService { | ... | @@ -233,18 +242,18 @@ public class RealTimeDataServiceImpl implements IRealTimeDataService { |
233 | 242 | ||
234 | 243 | ||
235 | @Override | 244 | @Override |
236 | public Map<String, Object> getFacInfoByFactoryId(String factoryId) { | 245 | public Map<String, Object> getFacInfoByFactoryId(String departId) { |
237 | DecimalFormat df = new DecimalFormat("#.##"); | 246 | DecimalFormat df = new DecimalFormat("#.##"); |
238 | Map<String, Object> result = Maps.newHashMap(); | 247 | Map<String, Object> result = Maps.newHashMap(); |
239 | result.put("info", realTimeDataMapper.queryFacInfo(factoryId)); | 248 | result.put("info", realTimeDataMapper.queryFacInfo(departId)); |
240 | List<Map<String, Object>> points = realTimeDataMapper.queryPoint(factoryId); | 249 | List<Map<String, Object>> points = realTimeDataMapper.queryPoint(departId); |
241 | StringBuilder feilds = new StringBuilder(); | 250 | StringBuilder feilds = new StringBuilder(); |
242 | if (points != null && points.size() > 0) { | 251 | if (points != null && points.size() > 0) { |
243 | points.forEach(v -> { | 252 | points.forEach(v -> { |
244 | feilds.append(v.get("mid")); | 253 | feilds.append(v.get("mid")); |
245 | feilds.append(","); | 254 | feilds.append(","); |
246 | }); | 255 | }); |
247 | Map<String, Object> map = pgService.queryFactoryInfosForMonitorByXT(factoryId, feilds.substring(0, feilds.length() - 1)); | 256 | Map<String, Object> map = pgService.queryFactoryInfosForMonitorByXT(departId, feilds.substring(0, feilds.length() - 1)); |
248 | if (map != null && map.size() > 0) { | 257 | if (map != null && map.size() > 0) { |
249 | Map<String, Object> real = Maps.newHashMap(); | 258 | Map<String, Object> real = Maps.newHashMap(); |
250 | points.forEach(v -> { | 259 | points.forEach(v -> { |
... | @@ -262,16 +271,16 @@ public class RealTimeDataServiceImpl implements IRealTimeDataService { | ... | @@ -262,16 +271,16 @@ public class RealTimeDataServiceImpl implements IRealTimeDataService { |
262 | } | 271 | } |
263 | 272 | ||
264 | @Override | 273 | @Override |
265 | public List<Map<String, Object>> queryStructData(String factoryId) { | 274 | public List<Map<String, Object>> queryStructData(String departId) { |
266 | return realTimeDataMapper.queryStructData(factoryId); | 275 | return realTimeDataMapper.queryStructData(departId); |
267 | } | 276 | } |
268 | 277 | ||
269 | 278 | ||
270 | @Override | 279 | @Override |
271 | public List<Map<String, Object>> queryRealTimeData(String factoryId, String type, String structId,String nmName) { | 280 | public List<Map<String, Object>> queryRealTimeData(String departId, String type, String structId,String nmName) { |
272 | DecimalFormat df = new DecimalFormat("#.##"); | 281 | DecimalFormat df = new DecimalFormat("#.##"); |
273 | //查询厂站下所有的指标代码 | 282 | //查询厂站下所有的指标代码 |
274 | List<Map<String, Object>> list = realTimeDataMapper.queryMetricListByType(factoryId, type, structId,nmName); | 283 | List<Map<String, Object>> list = realTimeDataMapper.queryMetricListByType(departId, type, structId,nmName); |
275 | StringBuilder feilds = new StringBuilder(); | 284 | StringBuilder feilds = new StringBuilder(); |
276 | if ("0".equals(type)) { | 285 | if ("0".equals(type)) { |
277 | list.forEach(v -> { | 286 | list.forEach(v -> { |
... | @@ -380,186 +389,18 @@ public class RealTimeDataServiceImpl implements IRealTimeDataService { | ... | @@ -380,186 +389,18 @@ public class RealTimeDataServiceImpl implements IRealTimeDataService { |
380 | 389 | ||
381 | 390 | ||
382 | @Override | 391 | @Override |
383 | public List<Map<String, Object>> queryStructDataApp(String factoryId) { | 392 | public List<Map<String, Object>> queryStructDataApp(String departId) { |
384 | return realTimeDataMapper.queryStructDataApp(factoryId); | 393 | return realTimeDataMapper.queryStructDataApp(departId); |
385 | } | 394 | } |
386 | 395 | ||
387 | 396 | ||
388 | @Override | 397 | @Override |
389 | public List<Map<String, Object>> queryRealTimeDataApp(String factoryId, String type, String structId, String sortType,String nmName) { | 398 | public List<Map<String, Object>> queryRealTimeDataApp(String departId, String type, String structId, String sortType,String nmName) { |
390 | DecimalFormat df = new DecimalFormat("#.##"); | 399 | List<Map<String, Object>> list = queryRealTimeData(departId, type, structId, nmName); |
391 | //查询厂站下所有的指标代码 | 400 | if ("name".equals(sortType)) { |
392 | List<Map<String, Object>> list = realTimeDataMapper.queryMetricListByType(factoryId, type, structId, nmName); | 401 | Collections.sort(list, new realTimeNameComparator()); |
393 | |||
394 | StringBuilder feilds = new StringBuilder(); | ||
395 | if ("0".equals(type)) { | ||
396 | list.forEach(v -> { | ||
397 | feilds.append(v.get("id")); | ||
398 | feilds.append(","); | ||
399 | }); | ||
400 | } else { | 402 | } else { |
401 | list.forEach(v -> { | 403 | Collections.sort(list, new realTimeStatusComparator()); |
402 | feilds.append(v.get("id")); | ||
403 | feilds.append(","); | ||
404 | |||
405 | if (v.get("faultExpress") != null) { | ||
406 | //去除表达式的||、&&、=及数字 aksdfjk23=20||asdf88ffaf=30 | ||
407 | String fExpress = (String) v.get("faultExpress"); | ||
408 | feilds.append(getFields(fExpress)).append(","); | ||
409 | } | ||
410 | if (v.get("runExpress") != null) { | ||
411 | String rExpress = (String) v.get("runExpress"); | ||
412 | feilds.append(getFields(rExpress)).append(","); | ||
413 | } | ||
414 | if (v.get("stopExpress") != null) { | ||
415 | String sExpress = (String) v.get("stopExpress"); | ||
416 | feilds.append(getFields(sExpress)).append(","); | ||
417 | } | ||
418 | }); | ||
419 | } | ||
420 | if (feilds != null && feilds.length() > 0) { | ||
421 | Map<String, Object> data = pgService.queryTrendDataTestApp(factoryId, list, type); | ||
422 | if (data != null && data.size() > 0) { | ||
423 | if ("all".equals(structId)) { | ||
424 | //异常 | ||
425 | List<Map<String, Object>> res = Lists.newArrayList(); | ||
426 | list.forEach(v -> { | ||
427 | String id = ConvertUtils.getString(v.get("id")); | ||
428 | String metricUp; | ||
429 | Double value = Double.parseDouble((String) data.getOrDefault(id, "0.0")); | ||
430 | v.put("realTime", data.get("time")); | ||
431 | if ("0".equals(type)) { | ||
432 | metricUp = ConvertUtils.getString(v.get("metricUp")); | ||
433 | String metricLow = ConvertUtils.getString(v.get("metricLow")); | ||
434 | if (ConvertUtils.isNotEmpty(metricUp) && ConvertUtils.isNotEmpty(value)) { | ||
435 | if (value > Double.parseDouble(metricUp) || value < Double.parseDouble(metricLow)) { | ||
436 | String csType = ConvertUtils.getString(v.get("csType")); | ||
437 | if ("1".equals(csType)) { | ||
438 | v.put("metricValue", Double.parseDouble(df.format(value))); | ||
439 | } else { | ||
440 | v.put("metricValue", value); | ||
441 | } | ||
442 | v.put("status", 1); | ||
443 | res.add(v); | ||
444 | } | ||
445 | } | ||
446 | } else { | ||
447 | //设备 | ||
448 | String express = (String) v.get("faultExpress");//表达式 | ||
449 | String express1 = (String) v.get("runExpress");//表达式1 | ||
450 | String express2 = (String) v.get("stopExpress");//表达式2 | ||
451 | String val = ""; | ||
452 | try { | ||
453 | //满足复杂表达式 | ||
454 | //因需要判断是否含有"#"且可能为null,所以暂时初始化 | ||
455 | if (StringUtil.isNullOrEmpty(express)) { | ||
456 | express = ""; | ||
457 | } | ||
458 | if (StringUtil.isNullOrEmpty(express1)) { | ||
459 | express1 = ""; | ||
460 | } | ||
461 | //开关量 | ||
462 | //通过第一个表达式计算结果值,如果为空或者为0 持续向下校验 | ||
463 | val = ExpressUtil.getValueByExpress(express, getExpressMapByExpressStr(data, express, null)); | ||
464 | |||
465 | //先判断故障 | ||
466 | if (StringUtil.isNullOrEmpty(val) || val.equals("0")) { | ||
467 | val = ExpressUtil.getValueByExpress(express1, getExpressMapByExpressStr(data, express1, null)); | ||
468 | if (StringUtil.isNullOrEmpty(val) || val.equals("0")) { | ||
469 | val = "0"; | ||
470 | } else { | ||
471 | val = "2"; | ||
472 | } | ||
473 | |||
474 | } | ||
475 | v.put("metricValue", val); | ||
476 | String metricName = (String) v.get("metricName"); | ||
477 | if (StringUtils.isNotBlank(metricName)) { | ||
478 | if (metricName.contains("运行")) { | ||
479 | v.put("metricName", metricName.replace("运行", "")); | ||
480 | } | ||
481 | } | ||
482 | v.put("status", Integer.parseInt(val)); | ||
483 | if (val.equals("1")) { | ||
484 | res.add(v); | ||
485 | } | ||
486 | } catch (ScriptException e) { | ||
487 | e.printStackTrace(); | ||
488 | } | ||
489 | } | ||
490 | }); | ||
491 | list = res; | ||
492 | } else { | ||
493 | list.forEach(v -> { | ||
494 | String id = ConvertUtils.getString(v.get("id")); | ||
495 | String metricUp; | ||
496 | Double value = ConvertUtils.getDouble( data.get(id),0,2); | ||
497 | if ("0".equals(type)) { | ||
498 | metricUp = ConvertUtils.getString(v.get("metricUp")); | ||
499 | String metricLow = ConvertUtils.getString(v.get("metricLow")); | ||
500 | if (ConvertUtils.isNotEmpty(metricUp) && ConvertUtils.isNotEmpty(value)) { | ||
501 | if (value > Double.parseDouble(metricUp) || value < Double.parseDouble(metricLow)) { | ||
502 | v.put("status", 1); | ||
503 | } else { | ||
504 | v.put("status", 2); | ||
505 | } | ||
506 | } else { | ||
507 | v.put("status", 2); | ||
508 | } | ||
509 | String csType = ConvertUtils.getString(v.get("csType")); | ||
510 | if ("1".equals(csType)) { | ||
511 | v.put("metricValue", Double.parseDouble(df.format(value))); | ||
512 | } else { | ||
513 | v.put("metricValue", value); | ||
514 | } | ||
515 | } else { | ||
516 | //设备 | ||
517 | String express = (String) v.get("faultExpress");//表达式 | ||
518 | String express1 = (String) v.get("runExpress");//表达式1 | ||
519 | String val = ""; | ||
520 | try { | ||
521 | //满足复杂表达式 | ||
522 | //因需要判断是否含有"#"且可能为null,所以暂时初始化 | ||
523 | if (StringUtil.isNullOrEmpty(express)) { | ||
524 | express = ""; | ||
525 | } | ||
526 | if (StringUtil.isNullOrEmpty(express1)) { | ||
527 | express1 = ""; | ||
528 | } | ||
529 | //开关量 | ||
530 | //通过第一个表达式计算结果值,如果为空或者为0 持续向下校验 | ||
531 | //0 停止 1故障 2运行 | ||
532 | val = ExpressUtil.getValueByExpress(express, getExpressMapByExpressStr(data, express, null)); | ||
533 | //先判断故障 | ||
534 | if (StringUtil.isNullOrEmpty(val) || val.equals("0")) { | ||
535 | val = ExpressUtil.getValueByExpress(express1, getExpressMapByExpressStr(data, express1, null)); | ||
536 | if (StringUtil.isNullOrEmpty(val) || val.equals("0")) { | ||
537 | val = "0"; | ||
538 | } else { | ||
539 | val = "2"; | ||
540 | } | ||
541 | } | ||
542 | v.put("metricValue", val); | ||
543 | String metricName = (String) v.get("metricName"); | ||
544 | if (StringUtils.isNotBlank(metricName)) { | ||
545 | if (metricName.contains("运行")) { | ||
546 | v.put("metricName", metricName.replace("运行", "")); | ||
547 | } | ||
548 | } | ||
549 | v.put("status", Integer.parseInt(val)); | ||
550 | } catch (ScriptException e) { | ||
551 | e.printStackTrace(); | ||
552 | } | ||
553 | } | ||
554 | v.put("realTime", data.get("time")); | ||
555 | }); | ||
556 | } | ||
557 | if ("name".equals(sortType)) { | ||
558 | Collections.sort(list, new realTimeNameComparator()); | ||
559 | } else { | ||
560 | Collections.sort(list, new realTimeStatusComparator()); | ||
561 | } | ||
562 | } | ||
563 | } | 404 | } |
564 | return list; | 405 | return list; |
565 | } | 406 | } | ... | ... |
... | @@ -196,20 +196,19 @@ public class ScreenDataServiceImpl implements IScreenDataService { | ... | @@ -196,20 +196,19 @@ public class ScreenDataServiceImpl implements IScreenDataService { |
196 | if (StringUtil.isNotBlank(sb.toString())) { | 196 | if (StringUtil.isNotBlank(sb.toString())) { |
197 | appendSql = "and a.id in (" + sb.substring(1) + ")"; | 197 | appendSql = "and a.id in (" + sb.substring(1) + ")"; |
198 | } | 198 | } |
199 | |||
200 | } | 199 | } |
201 | return masterDB.queryForList("select t.*,\n" + | 200 | String dataViewName2119 = ReportViewUtil.buildViewLike(ReportConstant.view2119,"CSL", departId, month); |
202 | "round(avg(t.indexValue/t.proScale),2) as fhl\n" + | 201 | String sql = "select t.*," + |
203 | ", round(sum(t.indexValue),2) totalCLSL\n" + | 202 | " round(avg(t.indexValue/t.proScale),2) as fhl," + |
204 | "from(\n" + | 203 | " round(sum(t.indexValue),2) totalCLSL " + |
205 | "SELECT a.id as departId,a.depart_name as departName,b.index_tag as indexTag,b.index_value as indexValue," + | 204 | " from( " + |
206 | "(select c.pro_scale*10000 from sys_factory_info c where a.id = c.depart_id) as proScale\n" + | 205 | " SELECT a.id as departId,a.depart_name as departName,'JSLJLL' as indexTag,b.CSL as indexValue," + |
207 | "FROM sys_depart a LEFT JOIN sys_data_calculation b ON a.id = b.depart_id \n" + | 206 | " (select c.pro_scale*10000 from sys_factory_info c where a.id = c.depart_id) as proScale " + |
208 | "where a.del_flag= 1 and a.depart_type = 1 and b.index_tag = 'JSLJLL'\n" + | 207 | " FROM sys_depart a " + |
209 | "\tand ts LIKE '" + month + "%' \n" + appendSql+ | 208 | " LEFT JOIN (select v2.time,v2.CSL,v2.depart_id from "+dataViewName2119+" v2 where v2.time like '"+month+"%') b ON a.id = b.depart_id" + |
210 | "\tGROUP BY a.id, b.ts)t GROUP BY t.departId"); | 209 | " where a.del_flag= 1 and a.depart_type = 1 " + appendSql + |
211 | 210 | " GROUP BY a.id, b.time)t GROUP BY t.departId"; | |
212 | 211 | return masterDB.queryForList(sql); | |
213 | } | 212 | } |
214 | 213 | ||
215 | @Override | 214 | @Override | ... | ... |
... | @@ -162,11 +162,11 @@ skua: | ... | @@ -162,11 +162,11 @@ skua: |
162 | isRunTimeInterval: 3600 | 162 | isRunTimeInterval: 3600 |
163 | #视频对接相关配置,未使用,待完善 | 163 | #视频对接相关配置,未使用,待完善 |
164 | video: | 164 | video: |
165 | lan: 20.0.99.6 | 165 | lan: 112.123.135.139 |
166 | ip: 113.249.91.27 | 166 | ip: 112.123.135.139 |
167 | port: 8667 | 167 | port: 8667 |
168 | appkey: 21656155 | 168 | appkey: 29461614 |
169 | secretkey: llQvkzDIzmYnNiXNYxDN | 169 | secretkey: RkJhpwVKJyf0FbDwQpbP |
170 | #消息推送 | 170 | #消息推送 |
171 | push: | 171 | push: |
172 | #是否开启流程消息推送 | 172 | #是否开启流程消息推送 | ... | ... |
... | @@ -103,4 +103,7 @@ public class EquipmentMaintainTask { | ... | @@ -103,4 +103,7 @@ public class EquipmentMaintainTask { |
103 | @ApiModelProperty(value = "维保类型") | 103 | @ApiModelProperty(value = "维保类型") |
104 | @Dict(dicCode = "maintenance_type") | 104 | @Dict(dicCode = "maintenance_type") |
105 | private String maintenanceType; | 105 | private String maintenanceType; |
106 | @TableField(exist = false) | ||
107 | @ApiModelProperty(value = "预估费用") | ||
108 | private String planCost; | ||
106 | } | 109 | } | ... | ... |
... | @@ -26,6 +26,7 @@ | ... | @@ -26,6 +26,7 @@ |
26 | emt.picture_url AS pictureUrl, | 26 | emt.picture_url AS pictureUrl, |
27 | emt.equipment_id AS equipmentId, | 27 | emt.equipment_id AS equipmentId, |
28 | emt.results_enforcement AS resultsEnforcement, | 28 | emt.results_enforcement AS resultsEnforcement, |
29 | emp.plan_cost AS planCost, | ||
29 | emp.plan_accepter_id AS planAccepterId, | 30 | emp.plan_accepter_id AS planAccepterId, |
30 | emp.plan_arranger_id, | 31 | emp.plan_arranger_id, |
31 | emt.device_administrator_id AS deviceAdministratorId, | 32 | emt.device_administrator_id AS deviceAdministratorId, | ... | ... |
... | @@ -1121,20 +1121,21 @@ public class SysUserController { | ... | @@ -1121,20 +1121,21 @@ public class SysUserController { |
1121 | String newCid = loginUser.getCid(); | 1121 | String newCid = loginUser.getCid(); |
1122 | if (StrUtil.isNotBlank(newCid)) { | 1122 | if (StrUtil.isNotBlank(newCid)) { |
1123 | //修改手机cid | 1123 | //修改手机cid |
1124 | String oldCid = oldUser.getCid(); | 1124 | oldUser.setCid(loginUser.getCid()); |
1125 | if (StringUtils.isBlank(oldCid)) { | 1125 | // String oldCid = oldUser.getCid(); |
1126 | oldUser.setCid(loginUser.getCid()); | 1126 | // if (StringUtils.isBlank(oldCid)) { |
1127 | } else { | 1127 | // oldUser.setCid(loginUser.getCid()); |
1128 | String[] split = oldCid.split(","); | 1128 | // } else { |
1129 | Set<String> sets = new HashSet<>(Arrays.asList(split)); | 1129 | // String[] split = oldCid.split(","); |
1130 | sets.add(loginUser.getCid()); | 1130 | // Set<String> sets = new HashSet<>(Arrays.asList(split)); |
1131 | StringBuilder stringBuilder = new StringBuilder(); | 1131 | // sets.add(loginUser.getCid()); |
1132 | for (String set : sets) { | 1132 | // StringBuilder stringBuilder = new StringBuilder(); |
1133 | stringBuilder.append(set + ","); | 1133 | // for (String set : sets) { |
1134 | } | 1134 | // stringBuilder.append(set + ","); |
1135 | stringBuilder.deleteCharAt(stringBuilder.length() - 1); | 1135 | // } |
1136 | oldUser.setCid(stringBuilder.toString()); | 1136 | // stringBuilder.deleteCharAt(stringBuilder.length() - 1); |
1137 | } | 1137 | // oldUser.setCid(stringBuilder.toString()); |
1138 | // } | ||
1138 | sysBaseAPI.updateUser(oldUser); | 1139 | sysBaseAPI.updateUser(oldUser); |
1139 | result.success("cid修改成功"); | 1140 | result.success("cid修改成功"); |
1140 | } | 1141 | } | ... | ... |
... | @@ -255,6 +255,11 @@ | ... | @@ -255,6 +255,11 @@ |
255 | '${item}' | 255 | '${item}' |
256 | </foreach> | 256 | </foreach> |
257 | ) | 257 | ) |
258 | OR parent_id IN ( SELECT id from sys_depart WHERE parent_id IN(SELECT id FROM sys_depart WHERE parent_id IN | ||
259 | <foreach item="item" index="index" collection="departIds.split(',')" open="(" separator="," close=")"> | ||
260 | '${item}' | ||
261 | </foreach> | ||
262 | )) | ||
258 | ORDER BY | 263 | ORDER BY |
259 | depart_type, | 264 | depart_type, |
260 | depart_order | 265 | depart_order | ... | ... |
-
请 注册 或 登录 后发表评论