79358c7d 康伟

kangwei :重写:运营季报接口

1 个父辈 4ea7e99a
...@@ -86,7 +86,7 @@ public final class ChineseInital { ...@@ -86,7 +86,7 @@ public final class ChineseInital {
86 } 86 }
87 87
88 public static void main(String[] args) { 88 public static void main(String[] args) {
89 System.out.println("获取拼音首字母:"+getAllFirstLetter("1大中国南昌中大china")); 89 System.out.println("获取拼音首字母:"+getAllFirstLetter("1-1#进水提升泵"));
90 } 90 }
91 91
92 } 92 }
......
...@@ -28,6 +28,8 @@ public class JTDisplayScreenController { ...@@ -28,6 +28,8 @@ public class JTDisplayScreenController {
28 public Result<List<SysFactoryInfoVO>> factoryList() { 28 public Result<List<SysFactoryInfoVO>> factoryList() {
29 Result<List<SysFactoryInfoVO>> result = new Result<>(); 29 Result<List<SysFactoryInfoVO>> result = new Result<>();
30 List<SysFactoryInfoVO> list = displayScreenService.getFactoryList(); 30 List<SysFactoryInfoVO> list = displayScreenService.getFactoryList();
31
32
31 result.setResult(list); 33 result.setResult(list);
32 return result; 34 return result;
33 } 35 }
......
...@@ -55,7 +55,7 @@ public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService { ...@@ -55,7 +55,7 @@ public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService {
55 List<Map<String, Object>> dataList = masterDB.queryForList(factorySql); 55 List<Map<String, Object>> dataList = masterDB.queryForList(factorySql);
56 for(Map<String, Object> dataMap : dataList) { 56 for(Map<String, Object> dataMap : dataList) {
57 // resultMap.put(ConvertUtils.getString(dataMap.get("id")), ConvertUtils.getString(dataMap.get("create_by"))+""+ConvertUtils.getString(dataMap.get("title"))); 57 // resultMap.put(ConvertUtils.getString(dataMap.get("id")), ConvertUtils.getString(dataMap.get("create_by"))+""+ConvertUtils.getString(dataMap.get("title")));
58 factoryInfoVO = new SysFactoryInfoVO(dataMap.get("id")+"",dataMap.get("depart_id").toString(),dataMap.get("depart_name").toString(),dataMap.get("pro_longitude").toString(),dataMap.get("pro_latitude").toString()); 58 factoryInfoVO = new SysFactoryInfoVO(dataMap.get("id")+"",dataMap.get("depart_id").toString(),dataMap.get("depart_name").toString(),dataMap.get("pro_longitude").toString(),dataMap.get("pro_latitude").toString(),1);
59 factoryInfoMap.put(factoryInfoVO.getDepartId(),factoryInfoVO); 59 factoryInfoMap.put(factoryInfoVO.getDepartId(),factoryInfoVO);
60 } 60 }
61 //查询部门集合 61 //查询部门集合
...@@ -89,9 +89,19 @@ public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService { ...@@ -89,9 +89,19 @@ public class JTDisplayScreenServiceImpl implements IJTDisplayScreenService {
89 } 89 }
90 // resultMap.put(ConvertUtils.getString(dataMap.get("id")), ConvertUtils.getString(dataMap.get("create_by"))+""+ConvertUtils.getString(dataMap.get("title"))); 90 // resultMap.put(ConvertUtils.getString(dataMap.get("id")), ConvertUtils.getString(dataMap.get("create_by"))+""+ConvertUtils.getString(dataMap.get("title")));
91 } 91 }
92
93
92 factoryInfoVOList = new ArrayList(factoryInfoMap.values()); 94 factoryInfoVOList = new ArrayList(factoryInfoMap.values());
95
96 // 添加:中冶数据
97 factorySql = "select fi.id,fi.depart_id,d.depart_name, fi.pro_longitude,fi.pro_latitude ,d.depart_type from sys_factory_info fi ,sys_depart d where fi.depart_id = d.id and d.depart_type =-1";
98 List<SysFactoryInfoVO> factroyList = masterDB.query(factorySql, new BeanPropertyRowMapper<SysFactoryInfoVO>(SysFactoryInfoVO.class));
99 if(factroyList != null ){
100 factoryInfoVOList.addAll(factroyList);
101 }
93 return factoryInfoVOList; 102 return factoryInfoVOList;
94 } 103 }
104
95 /** 105 /**
96 * 项目运营情况 106 * 项目运营情况
97 * @param departId 107 * @param departId
......
...@@ -17,6 +17,9 @@ public class SysFactoryInfoVO { ...@@ -17,6 +17,9 @@ public class SysFactoryInfoVO {
17 @ApiModelProperty(value = "水厂名称") 17 @ApiModelProperty(value = "水厂名称")
18 private String departId; 18 private String departId;
19 19
20 @ApiModelProperty(value = "厂站类型")
21 private Integer departType = 1;
22
20 @ApiModelProperty(value = "水厂名称") 23 @ApiModelProperty(value = "水厂名称")
21 private String departName; 24 private String departName;
22 25
...@@ -42,11 +45,12 @@ public class SysFactoryInfoVO { ...@@ -42,11 +45,12 @@ public class SysFactoryInfoVO {
42 public SysFactoryInfoVO() { 45 public SysFactoryInfoVO() {
43 } 46 }
44 47
45 public SysFactoryInfoVO(String id, String departId, String departName, String proLongitude, String proLatitude) { 48 public SysFactoryInfoVO(String id, String departId, String departName, String proLongitude, String proLatitude,Integer departType) {
46 this.id = id; 49 this.id = id;
47 this.departId = departId; 50 this.departId = departId;
48 this.departName = departName; 51 this.departName = departName;
49 this.proLongitude = proLongitude; 52 this.proLongitude = proLongitude;
50 this.proLatitude = proLatitude; 53 this.proLatitude = proLatitude;
54 this.departType = departType;
51 } 55 }
52 } 56 }
......
...@@ -11,16 +11,6 @@ import java.util.List; ...@@ -11,16 +11,6 @@ import java.util.List;
11 */ 11 */
12 public interface OperationReportMapper { 12 public interface OperationReportMapper {
13 /*** 13 /***
14 * 查询月度生产数据报表
15 * @param startTime
16 * @param endTime
17 * @param lastStartTime
18 * @param lastEndTime
19 * @return
20 */
21 List<FReportMonthDataVO> queryReportMonthData(@Param("startTime") String startTime,@Param("endTime") String endTime, @Param("lastStartTime")String lastStartTime,@Param("lastEndTime") String lastEndTime) ;
22
23 /***
24 * 查询隐含排查部门名称 14 * 查询隐含排查部门名称
25 * @return 15 * @return
26 */ 16 */
......
...@@ -2,60 +2,6 @@ ...@@ -2,60 +2,6 @@
2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 <mapper namespace="com.skua.modules.report.mapper.OperationReportMapper"> 3 <mapper namespace="com.skua.modules.report.mapper.OperationReportMapper">
4 4
5 <!-- -->
6 <select id="queryReportMonthData" resultType="com.skua.modules.report.vo.FReportMonthDataVO">
7 SELECT
8 a.depart_id,tc.target_water,tc. target_power,tc.target_drug,
9 (select t.depart_name from sys_depart t where t.id = a.depart_id ) 'depart_name',
10 (
11 select sum(fiv.item_value)/10000 from f_report_itemv fiv ,f_report_item fi
12 where fi.report_id = '2119ecbf53a1d2d0708258ff67cfd9e1' and item_code= 'CSL' and fiv.reit_id =fi.id and a.depart_id = fiv.depart_id and fiv.data_time like '2024%'
13 ) 'ysjsl',
14 (
15 select sum(fiv.item_value)/10000 from f_report_itemv fiv ,f_report_item fi
16 where fi.report_id = '2119ecbf53a1d2d0708258ff67cfd9e1' and item_code= 'CSL' and fiv.reit_id =fi.id and a.depart_id = fiv.depart_id and fiv.data_time like '2023%'
17 ) 'tqysjsl',
18 (select sum(fiv.item_value)/10000 from f_report_itemv fiv ,f_report_item fi
19 where fi.report_id = '3a243d5715b9e1a3753c180872ca0df9' and item_code= 'DLHJ' and fiv.reit_id =fi.id and a.depart_id = fiv.depart_id and fiv.data_time like '2024%' ) 'ydh',
20 sum( IF ( ( `d`.`item_code` = 'yslwcbl' ), `a`.`item_value`, NULL ) ) AS `yslwcbl`, -- 月水量完成比例
21 sum( IF ( ( `d`.`item_code` = 'ysjsldyqntqyy' ), `a`.`item_value`, NULL ) ) AS `ysjsldyqntqyy`, -- 月实际水量低于去年同期原因
22 sum( IF ( ( `d`.`item_code` = 'qntqsfsl' ), `a`.`item_value`, NULL ) ) AS `qntqsfsl`, -- 去年同期收费水量
23 sum( IF ( ( `d`.`item_code` = 'ysfsl' ), `a`.`item_value`, NULL ) ) AS `ysfsl`, -- 月收费水量
24 sum( IF ( ( `d`.`item_code` = 'bnsjdh' ), `a`.`item_value`, NULL ) ) AS `bnsjdh`,-- 本年实际电耗
25 sum( IF ( ( `d`.`item_code` = 'sldyyqyy' ), `a`.`item_value`, NULL ) ) AS `sldyyqyy`,-- 收费水量对比变化率
26 sum( IF ( ( `d`.`item_code` = 'dhgyqntqyy' ), `a`.`item_value`, NULL ) ) AS `dhgyqntqyy`, -- 电耗高于去年同期原因
27 sum( IF ( ( `d`.`item_code` = 'yyf' ), `a`.`item_value`, NULL ) ) AS `yyf`, -- 月药费
28 sum( IF ( ( `d`.`item_code` = 'yhgyqntqyy' ), `a`.`item_value`, NULL ) ) AS `yhgyqntqyy`, -- 药耗高于去年同期原因
29 sum( IF ( ( `d`.`item_code` = 'dhcmbzyy' ), `a`.`item_value`, NULL ) ) AS `dhcmbzyy`, -- 电耗超目标值原因
30 sum( IF ( ( `d`.`item_code` = 'yhcyqyy' ), `a`.`item_value`, NULL ) ) AS `yhcyqyy` -- 药耗超预期原因
31 FROM
32 ( (SELECT reit_id,item_value,depart_id
33 FROM f_report_itemv
34 WHERE
35 data_time LIKE '2024%'
36 AND reit_id IN (
37 '1818936216687595521',
38 '1818936217375461377',
39 '1818936218109464577',
40 '1818936218910576642',
41 '1818936219120291842',
42 '1818936219854295042',
43 '1818936220017872897',
44 '1818936220353417218',
45 '1818936220571521025',
46 '1818936220739293185',
47 '1818936220890288130' )
48 ) `a`
49 LEFT JOIN `f_report_item` `d` ON ( ( `a`.`reit_id` = `d`.`id` ) )
50 LEFT JOIN `report_target_config` tc ON ( ( `tc`.`depart_id` = `a`.`depart_id` ) )
51 )
52 WHERE
53 1 = 1
54 GROUP BY
55 `a`.`depart_id`
56 </select>
57
58
59 <select id="queryDepatNameList" resultType="java.lang.String"> 5 <select id="queryDepatNameList" resultType="java.lang.String">
60 select d.depart_name from ajh_rectification_info t 6 select d.depart_name from ajh_rectification_info t
61 left join sys_depart d on t.depart_id = d.id 7 left join sys_depart d on t.depart_id = d.id
......
...@@ -8,12 +8,6 @@ import com.skua.modules.report.vo.ProductDataVO; ...@@ -8,12 +8,6 @@ import com.skua.modules.report.vo.ProductDataVO;
8 */ 8 */
9 public interface IOperationReportService { 9 public interface IOperationReportService {
10 10
11 /***
12 * 执行查询sql语句返回一个结果
13 * @param sql
14 * @return
15 */
16 String queryForString(String sql );
17 11
18 /*** 12 /***
19 * 处理月季度数据 13 * 处理月季度数据
......
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 com.skua.core.context.SpringContextUtils; 4 import com.skua.core.context.SpringContextUtils;
5 import com.skua.core.util.ConvertUtils;
4 import com.skua.modules.report.mapper.OperationReportMapper; 6 import com.skua.modules.report.mapper.OperationReportMapper;
5 import com.skua.modules.report.service.IOperationReportService; 7 import com.skua.modules.report.service.IOperationReportService;
6 import com.skua.modules.report.vo.*; 8 import com.skua.modules.report.vo.*;
9 import com.skua.tool.util.DateUtils;
7 import com.skua.tool.util.DigitalUtils; 10 import com.skua.tool.util.DigitalUtils;
8 import org.apache.commons.lang3.StringUtils; 11 import org.apache.commons.lang3.StringUtils;
9 import org.springframework.beans.factory.annotation.Autowired; 12 import org.springframework.beans.factory.annotation.Autowired;
13 import org.springframework.jdbc.core.BeanPropertyRowMapper;
10 import org.springframework.jdbc.core.JdbcTemplate; 14 import org.springframework.jdbc.core.JdbcTemplate;
11 import org.springframework.stereotype.Service; 15 import org.springframework.stereotype.Service;
12 16
...@@ -16,6 +20,7 @@ import java.math.RoundingMode; ...@@ -16,6 +20,7 @@ import java.math.RoundingMode;
16 import java.time.LocalDate; 20 import java.time.LocalDate;
17 import java.time.format.DateTimeFormatter; 21 import java.time.format.DateTimeFormatter;
18 import java.util.List; 22 import java.util.List;
23 import java.util.Map;
19 24
20 /*** 25 /***
21 * 运营周报 26 * 运营周报
...@@ -25,6 +30,15 @@ public class OperationReportServiceImpl implements IOperationReportService { ...@@ -25,6 +30,15 @@ public class OperationReportServiceImpl implements IOperationReportService {
25 30
26 @Resource 31 @Resource
27 private OperationReportMapper operationReportMapper; 32 private OperationReportMapper operationReportMapper;
33
34 String view2119 = "2119ecbf53a1d2d0708258ff67cfd9e1";// 水 COD TP TN NH3H
35 String view3a24 = "3a243d5715b9e1a3753c180872ca0df9";//能耗报表
36 String view4411 = "4411ed3d78634bcdcd700f6e33724025";
37
38 private JdbcTemplate getJdbcTemplate(){
39 JdbcTemplate masterDB = (JdbcTemplate) SpringContextUtils.getBean("master");
40 return masterDB;
41 }
28 /*** 42 /***
29 * 处理月季度数据 43 * 处理月季度数据
30 * @param year 44 * @param year
...@@ -37,23 +51,106 @@ public class OperationReportServiceImpl implements IOperationReportService { ...@@ -37,23 +51,106 @@ public class OperationReportServiceImpl implements IOperationReportService {
37 productDataVO.setLastYear(lastYear); 51 productDataVO.setLastYear(lastYear);
38 SeasonTimeVO seasonTimeVO = new SeasonTimeVO(year ,season ); 52 SeasonTimeVO seasonTimeVO = new SeasonTimeVO(year ,season );
39 SeasonTimeVO lastSeasonTimeVO = new SeasonTimeVO(lastYear ,season ); 53 SeasonTimeVO lastSeasonTimeVO = new SeasonTimeVO(lastYear ,season );
40 54 productDataVO.setSeansonEndDay(seasonTimeVO.getEndTime());//季度最后一天
41 productDataVO.setStartTime(seasonTimeVO.getStartTime()); 55 productDataVO.setStartTime(seasonTimeVO.getStartTime());//季度开始时间
42 productDataVO.setEndTime( seasonTimeVO.getEndTime()); 56 productDataVO.setEndTime( seasonTimeVO.getEndTime());//季度结束时间
43 //水务公司总数 57 //水务公司总数
44 String sql = "select count(1) from sys_depart where depart_type = 1"; 58 String sql = "select count(1) from sys_depart where depart_type = 1";
45 String deptartCount = queryForString(sql); 59 String deptartCount = getJdbcTemplate().queryForObject(sql,String.class);
46 productDataVO.setDeptartCount( deptartCount ); 60 productDataVO.setDeptartCount( deptartCount );
47 61
48 List<FReportMonthDataVO> reportMonthDataVOList = operationReportMapper.queryReportMonthData(seasonTimeVO.getStartTime() ,seasonTimeVO.getEndTime() , lastSeasonTimeVO.getStartTime(),lastSeasonTimeVO.getEndTime()); 62 //生产指标完成情况--收费水量
49 //处理月报生成数据 63 //DLHJ 电量合计 ,ydh 用电量 ,yslwcbl 月水量完成比例,ysjsldyqntqyy 月实际水量低于去年同期原因,qntqsfsl 去年同期收费水量, ysfsl`,月收费水量 `bnsjdh`, 本年实际电耗 sldyyqyy`, 收费水量对比变化率 ,`dhgyqntqyy`, 电耗高于去年同期原因;`yyf`, 月药费 `yhgyqntqyy`, 药耗高于去年同期原因 `dhcmbzyy`, 电耗超目标值原因 `yhcyqyy` 药耗超预期原因
50 handeReportMonthData(productDataVO,reportMonthDataVOList,seasonTimeVO.getDisparityDay()); 64 // 电量合计 , 用电量 , 月水量完成比例, 月实际水量低于去年同期原因, 去年同期收费水量, `,月收费水量 ``, 本年实际电耗 `, 收费水量对比变化率 ,``, 电耗高于去年同期原因;``, 月药费 ``, 药耗高于去年同期原因 ``, 电耗超目标值原因 `` 药耗超预期原因
51 productDataVO.setSeansonEndDay(seasonTimeVO.getEndTime());//季度最后一天 65 //String fields = "DLHJ,ydh,yslwcbl,ysjsldyqntqyy,qntqsfsl,ysfsl,bnsjdh,sldyyqyy,dhgyqntqyy,yyf,yhgyqntqyy,dhcmbzyy,yhcyqyy";
66 // fields = "DLHJ,YDH,YSLWCBL,YSJSLDYQNTQYY,QNTQSFSL,YSFSL,BNSJDH,SLDYYQYY,DHGYQNTQYY,YYF,YHGYQNTQYY,DHCMBZYY,YHCYQYY";
67 // fields = fields.toUpperCase();
68 String departId = null;
69
70
71 // ysfsl:月收费水量 ; yyf:月药费 ; ysjsl:月实际水量
72 String dataViewName4411 = ReportViewUtil.buildViewLike(view4411,"ysfsl,ysjsl,yyf", departId, seasonTimeVO.getStartTime(),seasonTimeVO.getEndTime());
73 sql = "select sum( aaa.ysfsl ) 'ysfsl' , sum( aaa.ysjsl ) 'ysjsl' , sum(tc.target_water ) 'target_water', sum(tc.target_drug ) 'target_drug' ,round((sum( aaa.ysfsl ) *100 / sum(tc.target_water )),2) as 'completeRatio' from "+dataViewName4411+" aaa";
74 sql += " left join report_target_config tc on (tc.depart_id = aaa.depart_id and tc.target_year = '"+year+"')";
75 List<Map<String, Object>> mapList = getJdbcTemplate().queryForList(sql);
76 productDataVO.setDayNum( DateUtils.differenceDay(seasonTimeVO.getStartTime(),seasonTimeVO.getEndTime()) );//相差天数
77 Double target_drug = null;//药吨水药耗
78 Double drugCost = 0d;//药剂实际费用
79 Double ysjsl = null;//实际处理水量
80 if(mapList != null ){
81 for(Map<String,Object> map : mapList){
82 productDataVO.setChargeWaterVolume( ConvertUtils.getString( map.get("ysfsl")) ); //收费水量
83 productDataVO.setYsjslWaterVolume(ConvertUtils.getString( map.get("ysjsl")) );//实际处理水量
84 productDataVO.setCompleteRatio( ConvertUtils.getDouble( map.get("completeRatio"),0d) );//收费水量-完成率
85
86 target_drug = ConvertUtils.getDouble( map.get("target_drug"),0d);
87 ysjsl = ConvertUtils.getDouble( map.get("ysjsl"),0d);
88 if(ysjsl.doubleValue() != 0 ){
89 drugCost = ConvertUtils.getDouble( map.get("yyf"),0d) / ysjsl;
90 }
91 }
92 }
93 productDataVO.setDrugCost( drugCost );
94 productDataVO.setTargetDrug( target_drug );
95 productDataVO.setSequentialProgress("基本满足时序进度");
96 if(productDataVO.getCompleteRatio().doubleValue() > 25){
97 productDataVO.setSequentialProgress("超额完成时序进度");
98 }
99 // 去年水数据:月收费水量、月实际水量
100 // ysfsl:月收费水量 ; yyf:月药费 ; ysjsl:月实际水量
101 dataViewName4411 = ReportViewUtil.buildViewLike(view4411,"ysfsl,ysjsl", departId, lastSeasonTimeVO.getStartTime(),lastSeasonTimeVO.getEndTime());
102 sql = "select sum( aaa.ysfsl ) 'ysfsl' , sum( aaa.ysjsl ) 'ysjsl' from "+dataViewName4411+" aaa";
103 if(mapList != null ){
104 for(Map<String,Object> map : mapList){
105 Double qn_ysfsl = ConvertUtils.getDouble( map.get("ysfsl"),0d);// 去年:收费水量
106 Double qn_ysjsl = ConvertUtils.getDouble( map.get("ysjsl"),0d);// 去年:月实际水量
107 if(qn_ysfsl.doubleValue() != 0){//去年:收费水量
108 productDataVO.setChargeWaterRatio( (ConvertUtils.getDouble( productDataVO.getChargeWaterVolume() ,0d) - qn_ysfsl) / qn_ysfsl );
109 }
110 if(qn_ysjsl.doubleValue() != 0){//去年:月实际水量
111 productDataVO.setYsjslWaterRatio( ( ConvertUtils.getDouble( productDataVO.getYsjslWaterVolume() ,0d) - qn_ysjsl ) / qn_ysjsl );
112 }
113 }
114 }
115 //实际水量同比下降水务公司原因分析一览表
116 //ysjsldyqntqyy 月实际水量低于去年同期原因
117 //tqysjsl 同期月实际水量
118 //ysjsl 月实际水量
119 // fields = "ysjsl,tqysjsl,ysjsldyqntqyy";
120 dataViewName4411 = ReportViewUtil.buildView(view4411,"ysjsl,tqysjsl,ysjsldyqntqyy", departId, seasonTimeVO.getStartTime(),seasonTimeVO.getEndTime());
121 // sql = "select sum( aaa.ysfsl ) 'ysfsl' , sum( aaa.ysjsl ) 'ysjsl' , sum(tc.target_water ) 'target_water' , sum(tc.target_power) 'target_power' ,round((sum( aaa.ysfsl ) *100 / sum(tc.target_water )),2) as 'completeRatio' from "+dataViewName4411+" aaa";
122 sql = "select round( (aaa.tqysjsl - aaa.ysjsl ) / aaa.tqysjsl ,2 ) 'ratio' , aaa.tqysjsl , aaa.ysjsl , aaa.ysjsldyqntqyy 'causeAnalysis' , d.depart_name from "+dataViewName4411 +" aaa";
123 sql += " left join sys_depart d on d.id = aaa.depart_id where aaa.tqysjsl > aaa.ysjsl";
124 List<FReportWaterMonthDataVO> waterMonthDataList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<FReportWaterMonthDataVO>(FReportWaterMonthDataVO.class));
125 productDataVO.setWaterDeptartList(waterMonthDataList);
126
127 //水电耗高于控制目标--水务公司列表
128 dataViewName4411 = ReportViewUtil.buildViewLike(view4411,"ydh,qntqdh,dhgyqntqyy", departId, seasonTimeVO.getStartTime(),seasonTimeVO.getEndTime(),"max");
129 sql = "select aaa.dhgyqntqyy 'causeAnalysis' , aaa.qntqdh ,aaa.ydh 'realConsume' ,d.depart_name 'deptartName' , tc.target_power 'targetConsume' from " + dataViewName4411 + " aaa ";
130 sql += " left join report_target_config tc on (tc.depart_id = aaa.depart_id and tc.target_year ="+year+")";
131 sql += " left join sys_depart d on d.id = aaa.depart_id ";
132 sql += " where aaa.ydh > IFNULL(tc.target_power,0)";
133 List<FReportPowerMonthDataVO> powerMonthDataVOList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<FReportPowerMonthDataVO>(FReportPowerMonthDataVO.class));
134 productDataVO.setPowerDeptartList(powerMonthDataVOList);
135
136 /**
137 * ysjsl:月实际水量 ; 月药耗 yyh; 去年同期药耗 qntqyh; 月药费 yyf;药耗高于去年同期原因 yhgyqntqyy;药耗超预期原因 yhcyqyy; 本年实际药耗 bnsjyh; 本年药耗目标 bnyhmb*/
138 //药剂成本高于控制目标--水务公司列表
139 dataViewName4411 = ReportViewUtil.buildViewLike(view4411,"ysjsl,yyh,qntqyh,qntqyh,yhgyqntqyy,bnsjyh,bnyhmb", departId, seasonTimeVO.getStartTime(),seasonTimeVO.getEndTime(),"max");
140 // sql = "select (aaa.yyh/aaa.ysjsl) 'realConsume',aaa.ysjsl,aaa.qntqyh,aaa.qntqyh,aaa.yhgyqntqyy '',aaa.bnsjyh,aaa.bnyhmb,aaa.depart_id ,d.depart_name ,tc.target_drug 'targetConsume' from " + dataViewName4411 + " aaa ";
141 sql = "select (aaa.yyh/aaa.ysjsl) 'realConsume',aaa.yhgyqntqyy 'causeAnalysis',d.depart_name 'deptartName' ,tc.target_drug 'targetConsume' from " + dataViewName4411 + " aaa ";
142 sql += " left join report_target_config tc on (tc.depart_id = aaa.depart_id and tc.target_year ="+year+")";
143 sql+= " left join sys_depart d on d.id = aaa.depart_id ";
144 sql += " where (aaa.ysjsl/aaa.ysjsl) > IFNULL(tc.target_drug,0)";
145 List<FReportPowerMonthDataVO> drugDataList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<FReportPowerMonthDataVO>(FReportPowerMonthDataVO.class));
146 productDataVO.setDrugDeptartList(drugDataList);
52 147
53 //隐患排查完成情况 148 //隐患排查完成情况
54 List<String> deptNameList = operationReportMapper.queryDepatNameList(); 149 sql = "select d.depart_name from ajh_rectification_info t ";
55 150 sql+=" left join sys_depart d on t.depart_id = d.id ";
151 sql += " group by t.depart_id ";
56 152
153 List<String> deptNameList = operationReportMapper.queryDepatNameList();
57 productDataVO.setDangerDeptCount( 0 ); 154 productDataVO.setDangerDeptCount( 0 );
58 if(deptNameList != null && !deptNameList.isEmpty()){ 155 if(deptNameList != null && !deptNameList.isEmpty()){
59 productDataVO.setDangerDeptCount( deptNameList.size()); 156 productDataVO.setDangerDeptCount( deptNameList.size());
...@@ -62,219 +159,4 @@ public class OperationReportServiceImpl implements IOperationReportService { ...@@ -62,219 +159,4 @@ public class OperationReportServiceImpl implements IOperationReportService {
62 159
63 return productDataVO; 160 return productDataVO;
64 } 161 }
65
66 private void handeReportMonthData(ProductDataVO productDataVO,List<FReportMonthDataVO> reportMonthDataVOList,String disparityDay){
67 // 遍历月数据报表获取
68 String chargeWaterVolume = "0";//收费水量 总量
69 String lastYearChargeWaterVolume = "0";//去年收费水量 总量
70 String ysjslWaterVolume = "0";//月实际水量 总量
71 String tqysjslWaterVolume = "0";//同期月实际水量 总量
72 String targetWater = "0";//水目标
73
74 FReportWaterMonthDataVO reportMonthItemDataVO = null;
75 //同期月实际水量
76 if(reportMonthDataVOList != null && !reportMonthDataVOList.isEmpty()){
77 for(FReportMonthDataVO monthDataVO : reportMonthDataVOList){
78 /**********************收费水量********************************/
79 if(StringUtils.isNotEmpty(monthDataVO.getYsfsl())){//ysfsl 月收费水量
80 chargeWaterVolume = DigitalUtils.add( chargeWaterVolume , monthDataVO.getYsfsl());
81 }
82 if(StringUtils.isNotEmpty(monthDataVO.getQntqsfsl())){//qntqsfsl 去年同期收费水量
83 lastYearChargeWaterVolume = DigitalUtils.add( lastYearChargeWaterVolume , monthDataVO.getQntqsfsl());
84 }
85 if(StringUtils.isNotEmpty(monthDataVO.getTargetWater())){//ysfsl 收费水量目标
86 targetWater = DigitalUtils.add( targetWater , monthDataVO.getTargetWater());
87 }
88 /********************实际水量**********************************/
89 if(StringUtils.isNotEmpty(monthDataVO.getYsjsl())){//ysjsl 月实际水量
90 ysjslWaterVolume = DigitalUtils.add( ysjslWaterVolume , monthDataVO.getYsjsl());
91 }
92 if(StringUtils.isNotEmpty(monthDataVO.getQntqsfsl())){//qntqsfsl 去年同期收费水量
93 tqysjslWaterVolume = DigitalUtils.add( tqysjslWaterVolume , monthDataVO.getQntqsfsl());
94 }
95 //同比下降的部门
96 Integer comparisonResult_water = DigitalUtils.compareTo(ysjslWaterVolume , tqysjslWaterVolume) ;
97 if(comparisonResult_water != null && comparisonResult_water < 0 ){//同比下降
98 // 部门名称,下降比例,下降原因
99 String ratio = DigitalUtils.division( ysjslWaterVolume ,tqysjslWaterVolume ) ;
100 ratio = DigitalUtils.multiply( ratio , "100");
101 reportMonthItemDataVO = new FReportWaterMonthDataVO(monthDataVO.getDeptartName(),ratio,monthDataVO.getYsjsldyqntqyy()) ;
102 productDataVO.getWaterDeptartList().add( reportMonthItemDataVO );
103 }
104
105
106 /********************电**********************************/
107 String consume = checkPowerConsume(monthDataVO.getYdh(),monthDataVO.getYsjsl() ,monthDataVO.getTargetPower());//部门电耗
108 if(consume != null){
109 productDataVO.getPowerDeptartList().add( new FReportPowerMonthDataVO( monthDataVO.getDeptartName(), monthDataVO.getTargetDrug(),consume,monthDataVO.getDhcmbzyy() ) );
110 }
111
112 /********************药剂**********************************/
113 productDataVO.setTargetDrug(monthDataVO.getTargetDrug() );//目标药剂
114 if(StringUtils.isNotEmpty(monthDataVO.getYyf()) && StringUtils.isNotEmpty(monthDataVO.getYsjsl()) ){
115 String drugCost = DigitalUtils.division( monthDataVO.getYyf() , monthDataVO.getYsjsl() );
116 Integer comparison_drug = DigitalUtils.compareTo( drugCost , monthDataVO.getTargetDrug() ) ;
117 if(comparison_drug != null && comparison_drug > 0){
118 productDataVO.getDrugDeptartList().add( new FReportPowerMonthDataVO( monthDataVO.getDeptartName(), monthDataVO.getTargetDrug(),drugCost.toString(),monthDataVO.getYhcyqyy() ) );
119 }
120 }
121 }
122 }
123 /****************实际水量、统计数量、百分比、平均值***********/
124 setChargeWater(productDataVO, chargeWaterVolume , lastYearChargeWaterVolume ,targetWater,disparityDay);
125 /****************实际水量、统计数量、百分比、平均值***********/
126 setYsjslWater(productDataVO, ysjslWaterVolume , tqysjslWaterVolume ,disparityDay);
127 }
128
129 /***
130 * 比较两个数字
131 * @param ydl 用电量
132 * @param ysjsl 用水量
133 * @param targetPower 目标电耗
134 * @return
135 */
136 public String checkPowerConsume(String ydl ,String ysjsl, String targetPower){
137 Double consume = null;
138 if(StringUtils.isNotEmpty(ydl) && StringUtils.isNotEmpty(ysjsl) && StringUtils.isNotEmpty(targetPower)){
139 Double ysjslD = Double.parseDouble(ysjsl);
140 //公式 = 用电量/用水量 - 目标电耗 = 用电量 - 用水量 * 目标电耗
141 if( ysjslD.doubleValue() > 0 && ( Double.parseDouble(ydl) - Double.parseDouble(ysjsl) * Double.parseDouble(targetPower) ) > 0){
142 consume = Double.parseDouble(ydl)/Double.parseDouble(ysjsl) - Double.parseDouble(targetPower);
143 return consume.toString();
144 }
145 }
146 return null;
147 }
148
149 /***
150 * ***************设置实际收费水量***************
151 * @param targetChargeWater
152 * @param tqysjslWaterVolume
153 * @param disparityDay
154 */
155 public void setChargeWater(ProductDataVO productDataVO,String chargeWaterVolume, String tqysjslWaterVolume,String targetChargeWater, String disparityDay) {
156 productDataVO.setChargeWaterVolume(chargeWaterVolume);//收费水量 总量
157 // 除法运算,保留两位小数
158 String avgDayWaterVolume = DigitalUtils.division(chargeWaterVolume ,disparityDay );
159 productDataVO.setAvgDayWaterVolume( avgDayWaterVolume );//收费水量 日均值
160 //完成年度目标
161 if(targetChargeWater != null ){
162 String completeRatio = DigitalUtils.division(chargeWaterVolume ,targetChargeWater );
163 productDataVO.setCompleteRatio( completeRatio );//完成年度目标
164
165 int comparisonResult = DigitalUtils.compareTo(completeRatio ,"25" );
166 if(comparisonResult > 0 ){
167 productDataVO.setSequentialProgress("超额完成时序进度");
168 } else {
169 productDataVO.setSequentialProgress("基本满足时序进度");
170 }
171 }
172 String chargeWaterRatio = DigitalUtils.division(chargeWaterVolume , tqysjslWaterVolume ) ; //增长率
173 productDataVO.setChargeWaterRatio( chargeWaterRatio );
174 }
175
176 /***
177 * ***************实际水量、统计数量、百分比、平均值**********
178 * @param ysjslWaterVolume
179 * @param tqysjslWaterVolume
180 * @param disparityDay
181 */
182 public void setYsjslWater(ProductDataVO productDataVO,String ysjslWaterVolume, String tqysjslWaterVolume, String disparityDay) {
183 productDataVO.setYsjslWaterVolume( ysjslWaterVolume );//实际水量
184
185 // 除法运算,保留两位小数
186 String avgDayWaterVolume = DigitalUtils.division(ysjslWaterVolume ,disparityDay );
187 productDataVO.setAvgDayWaterVolume( avgDayWaterVolume );//实际水量 日均值
188
189 //增长率
190 if(tqysjslWaterVolume != null ){
191 String chargeWaterRatio = DigitalUtils.division(ysjslWaterVolume ,tqysjslWaterVolume );
192 productDataVO.setYsjslWaterRatio( chargeWaterRatio );//完成年度目标
193 }
194
195 }
196 /***
197 * 执行查询sql语句返回一个结果
198 * @param sql
199 * @return
200 */
201 public String queryForString(String sql ){
202 //主库数据源
203 JdbcTemplate masterDB = (JdbcTemplate) SpringContextUtils.getBean("master");
204 String result = masterDB.queryForObject(sql, String.class);
205 return result;
206 }
207 /***
208 * 根据记录获取:季度开始时间
209 * @param year
210 * @param season
211 * @return
212 */
213 public String getStartTimeBySeason(int year,int season){
214 int startMonth = 0;
215 int endMonth = 0;
216 switch (season) {
217 case 1:
218 startMonth = 1;
219 endMonth = 3;
220 break;
221 case 2:
222 startMonth = 4;
223 endMonth = 6;
224 break;
225 case 3:
226 startMonth = 7;
227 endMonth = 9;
228 break;
229 case 4:
230 startMonth = 10;
231 endMonth = 12;
232 break;
233 default:
234 System.out.println("季度输入无效,请输入1-4之间的数字。");
235 return "";
236 }
237 LocalDate startDate = LocalDate.of(year, startMonth, 1);
238 LocalDate endDate = LocalDate.of(year, endMonth, startDate.lengthOfMonth());
239
240 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
241 return startDate.format(formatter);
242 }
243
244 /***
245 * 根据记录获取:季度结束时间
246 * @param year
247 * @param season
248 * @return
249 */
250 public String getEndTimeBySeason(int year,int season){
251 int startMonth = 0;
252 int endMonth = 0;
253 switch (season) {
254 case 1:
255 startMonth = 1;
256 endMonth = 3;
257 break;
258 case 2:
259 startMonth = 4;
260 endMonth = 6;
261 break;
262 case 3:
263 startMonth = 7;
264 endMonth = 9;
265 break;
266 case 4:
267 startMonth = 10;
268 endMonth = 12;
269 break;
270 default:
271 System.out.println("季度输入无效,请输入1-4之间的数字。");
272 return "";
273 }
274
275 LocalDate startDate = LocalDate.of(year, startMonth, 1);
276 LocalDate endDate = LocalDate.of(year, endMonth, startDate.lengthOfMonth());
277 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
278 return endDate.format(formatter);
279 }
280 } 162 }
......
...@@ -22,6 +22,10 @@ public class FReportPowerMonthDataVO { ...@@ -22,6 +22,10 @@ public class FReportPowerMonthDataVO {
22 @ApiModelProperty(value = "原因分析") 22 @ApiModelProperty(value = "原因分析")
23 private String causeAnalysis; 23 private String causeAnalysis;
24 24
25 public FReportPowerMonthDataVO(){
26
27 }
28
25 public FReportPowerMonthDataVO(String deptartName, String targetConsume, String realConsume , String causeAnalysis) { 29 public FReportPowerMonthDataVO(String deptartName, String targetConsume, String realConsume , String causeAnalysis) {
26 this.deptartName = deptartName; 30 this.deptartName = deptartName;
27 this.targetConsume = targetConsume; 31 this.targetConsume = targetConsume;
......
...@@ -19,6 +19,10 @@ public class FReportWaterMonthDataVO { ...@@ -19,6 +19,10 @@ public class FReportWaterMonthDataVO {
19 @ApiModelProperty(value = "原因分析") 19 @ApiModelProperty(value = "原因分析")
20 private String causeAnalysis; 20 private String causeAnalysis;
21 21
22 public FReportWaterMonthDataVO(){
23
24 }
25
22 public FReportWaterMonthDataVO(String deptartName, String ratio, String causeAnalysis) { 26 public FReportWaterMonthDataVO(String deptartName, String ratio, String causeAnalysis) {
23 this.deptartName = deptartName; 27 this.deptartName = deptartName;
24 this.ratio = ratio; 28 this.ratio = ratio;
......
1 package com.skua.modules.report.vo; 1 package com.skua.modules.report.vo;
2 2
3 import com.skua.core.util.ConvertUtils;
3 import io.swagger.annotations.ApiModel; 4 import io.swagger.annotations.ApiModel;
4 import io.swagger.annotations.ApiModelProperty; 5 import io.swagger.annotations.ApiModelProperty;
5 import lombok.Data; 6 import lombok.Data;
...@@ -18,19 +19,22 @@ public class ProductDataVO { ...@@ -18,19 +19,22 @@ public class ProductDataVO {
18 19
19 @ApiModelProperty(value = "季度开始时间") 20 @ApiModelProperty(value = "季度开始时间")
20 private String startTime; 21 private String startTime;
21
22 @ApiModelProperty(value = "季度结束时间") 22 @ApiModelProperty(value = "季度结束时间")
23 private String endTime; 23 private String endTime;
24 @ApiModelProperty(value = "水务厂站数量") 24 @ApiModelProperty(value = "水务厂站数量")
25 private String deptartCount; 25 private String deptartCount;
26
27 @ApiModelProperty(value = "相差天数")
28 private Long dayNum;
29
26 @ApiModelProperty(value = "收费水量") 30 @ApiModelProperty(value = "收费水量")
27 private String chargeWaterVolume;//收费水量9854.012552万吨 31 private String chargeWaterVolume;//收费水量9854.012552万吨
28 @ApiModelProperty(value = "收费水量-日均值") 32 @ApiModelProperty(value = "收费水量-日均值")
29 private String avgDayWaterVolume;//平均108.29万吨/天 33 private Double avgDayWaterVolume;//平均108.29万吨/天
30 @ApiModelProperty(value = "收费水量-同比增长") 34 @ApiModelProperty(value = "收费水量-同比增长")
31 private String chargeWaterRatio; 35 private Double chargeWaterRatio;
32 @ApiModelProperty(value = "收费水量-完成率") 36 @ApiModelProperty(value = "收费水量-完成率")
33 private String completeRatio; 37 private Double completeRatio;
34 @ApiModelProperty(value = "序时进度") 38 @ApiModelProperty(value = "序时进度")
35 private String sequentialProgress; 39 private String sequentialProgress;
36 40
...@@ -39,17 +43,17 @@ public class ProductDataVO { ...@@ -39,17 +43,17 @@ public class ProductDataVO {
39 @ApiModelProperty(value = "实际处理水量") 43 @ApiModelProperty(value = "实际处理水量")
40 private String ysjslWaterVolume; 44 private String ysjslWaterVolume;
41 @ApiModelProperty(value = "实际处理水量-日均值") 45 @ApiModelProperty(value = "实际处理水量-日均值")
42 private String avgYsjslWaterVolume;//平均99.76万吨/天 46 private Double avgYsjslWaterVolume;//平均99.76万吨/天
43 @ApiModelProperty(value = "实际处理水量--同比增长") 47 @ApiModelProperty(value = "实际处理水量--同比增长")
44 private String ysjslWaterRatio; 48 private Double ysjslWaterRatio;
45 49
46 50
47 @ApiModelProperty(value = "药量目标") 51 @ApiModelProperty(value = "药量目标")
48 private String targetDrug; 52 private Double targetDrug;
49 53
50 54
51 @ApiModelProperty(value = "药剂实际费用") 55 @ApiModelProperty(value = "药剂实际费用")
52 private String drugCost;//实际发生为0.219元/吨水 56 private Double drugCost;//实际发生为0.219元/吨水
53 57
54 58
55 @ApiModelProperty(value = "实际水量同比下降--水务公司列表") 59 @ApiModelProperty(value = "实际水量同比下降--水务公司列表")
...@@ -76,6 +80,16 @@ public class ProductDataVO { ...@@ -76,6 +80,16 @@ public class ProductDataVO {
76 @ApiModelProperty(value = "隐患部门名称") 80 @ApiModelProperty(value = "隐患部门名称")
77 private String dangerDeptNames; 81 private String dangerDeptNames;
78 82
83 //收费水量-日均值
84 public Double getAvgDayWaterVolume() {
85 avgDayWaterVolume = ConvertUtils.getDouble(chargeWaterVolume,0) / dayNum ;
86 return avgDayWaterVolume;
87 }
88 //实际处理水量-日均值
89 public Double getAvgYsjslWaterVolume() {
90 avgYsjslWaterVolume = ConvertUtils.getDouble(ysjslWaterVolume,0) / dayNum;
91 return avgYsjslWaterVolume;
92 }
79 93
80 public String getWaterDeptartName() { 94 public String getWaterDeptartName() {
81 return getDeptName(waterDeptartList); 95 return getDeptName(waterDeptartList);
...@@ -110,3 +124,4 @@ public class ProductDataVO { ...@@ -110,3 +124,4 @@ public class ProductDataVO {
110 return deptName; 124 return deptName;
111 } 125 }
112 } 126 }
127
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!