061214b5 康伟

kangwei:指挥中心,电耗改为万吨水电耗,CSL改为万吨水

1 个父辈 12d66bdb
...@@ -79,9 +79,13 @@ public class ReportViewUtil { ...@@ -79,9 +79,13 @@ public class ReportViewUtil {
79 if(StringUtils.isNotEmpty(departIds)){ 79 if(StringUtils.isNotEmpty(departIds)){
80 sb.append(" and depart_id in ("+inSqlPart+") "); 80 sb.append(" and depart_id in ("+inSqlPart+") ");
81 } 81 }
82 if(!StringUtils.isEmpty(startTime)) { 82 if(StringUtils.isNotEmpty(startTime)) {
83 sb.append(" and data_time>='"+startTime+"' and data_time<='"+endTime+"' "); 83 sb.append(" and data_time>='"+startTime+"' ");
84 }
85 if(StringUtils.isNotEmpty(endTime)) {
86 sb.append(" and data_time<='"+endTime+"' ");
84 } 87 }
88
85 sb.append(" and reit_id in ("+itemIds+")) `a` left join `f_report_item` `d` on((`a`.`reit_id` = `d`.`id`))) where 1=1 group by `a`.`data_id`,`a`.`depart_id`,`a`.`data_time` order by `a`.`data_time`)"); 89 sb.append(" and reit_id in ("+itemIds+")) `a` left join `f_report_item` `d` on((`a`.`reit_id` = `d`.`id`))) where 1=1 group by `a`.`data_id`,`a`.`depart_id`,`a`.`data_time` order by `a`.`data_time`)");
86 return sb.toString(); 90 return sb.toString();
87 } 91 }
......
1 package com.skua.tool.util; 1 package com.skua.tool.util;
2 2
3 import org.apache.commons.lang3.StringUtils;
4
3 import javax.script.ScriptEngine; 5 import javax.script.ScriptEngine;
4 import javax.script.ScriptEngineManager; 6 import javax.script.ScriptEngineManager;
5 import javax.script.ScriptException; 7 import javax.script.ScriptException;
...@@ -36,8 +38,13 @@ public class JSUtils { ...@@ -36,8 +38,13 @@ public class JSUtils {
36 return executeExpression(expression,"0.00"); 38 return executeExpression(expression,"0.00");
37 } 39 }
38 public static String divide(Object obj1 , Object obj2){ 40 public static String divide(Object obj1 , Object obj2){
39 String expression = obj1+ "/" + obj2; 41 if(StringUtils.isNotEmpty(obj1.toString())){
40 return executeExpression(expression,"0.00"); 42 if(StringUtils.isNotEmpty(obj2.toString()) && Double.parseDouble(obj2.toString())!=0){
43 String expression = obj1+ "/" + obj2;
44 return executeExpression(expression,"0.00");
45 }
46 }
47 return "0";
41 } 48 }
42 49
43 /*** 50 /***
......
...@@ -2,9 +2,11 @@ package com.skua.modules.algorithm.controller; ...@@ -2,9 +2,11 @@ package com.skua.modules.algorithm.controller;
2 2
3 3
4 import com.skua.common.constant.ReportConstant; 4 import com.skua.common.constant.ReportConstant;
5 import com.skua.common.report.ReportViewUtil;
5 import com.skua.core.api.vo.Result; 6 import com.skua.core.api.vo.Result;
6 import com.skua.core.aspect.annotation.AutoLog; 7 import com.skua.core.aspect.annotation.AutoLog;
7 import com.skua.core.context.BaseContextHandler; 8 import com.skua.core.context.BaseContextHandler;
9 import com.skua.core.context.SpringContextUtils;
8 import com.skua.core.util.ConvertUtils; 10 import com.skua.core.util.ConvertUtils;
9 import com.skua.modules.algorithm.service.ICommandCentreService; 11 import com.skua.modules.algorithm.service.ICommandCentreService;
10 import com.skua.modules.algorithm.service.impl.ReportItemvService; 12 import com.skua.modules.algorithm.service.impl.ReportItemvService;
...@@ -22,6 +24,7 @@ import io.swagger.annotations.Api; ...@@ -22,6 +24,7 @@ import io.swagger.annotations.Api;
22 import io.swagger.annotations.ApiOperation; 24 import io.swagger.annotations.ApiOperation;
23 import lombok.extern.slf4j.Slf4j; 25 import lombok.extern.slf4j.Slf4j;
24 import org.springframework.beans.factory.annotation.Autowired; 26 import org.springframework.beans.factory.annotation.Autowired;
27 import org.springframework.jdbc.core.JdbcTemplate;
25 import org.springframework.web.bind.annotation.GetMapping; 28 import org.springframework.web.bind.annotation.GetMapping;
26 import org.springframework.web.bind.annotation.RequestMapping; 29 import org.springframework.web.bind.annotation.RequestMapping;
27 import org.springframework.web.bind.annotation.RequestParam; 30 import org.springframework.web.bind.annotation.RequestParam;
...@@ -44,8 +47,6 @@ public class SysCommandCentreController { ...@@ -44,8 +47,6 @@ public class SysCommandCentreController {
44 @Autowired 47 @Autowired
45 private ICommandCentreService commandCentreService; 48 private ICommandCentreService commandCentreService;
46 @Autowired 49 @Autowired
47 private ISysConfigService sysConfigService;
48 @Autowired
49 private ReportItemvService reportItemvService; 50 private ReportItemvService reportItemvService;
50 51
51 /** 52 /**
...@@ -177,53 +178,47 @@ public class SysCommandCentreController { ...@@ -177,53 +178,47 @@ public class SysCommandCentreController {
177 @ApiOperation(value="指挥中心-水量电耗趋势", notes="指挥中心-水量电耗趋势") 178 @ApiOperation(value="指挥中心-水量电耗趋势", notes="指挥中心-水量电耗趋势")
178 @GetMapping(value = "/statisticsBySewage") 179 @GetMapping(value = "/statisticsBySewage")
179 public Result<StackedAreaChartDataVO> statisticsBySewage(ReportItemvParam reportItemvParam) throws Exception { 180 public Result<StackedAreaChartDataVO> statisticsBySewage(ReportItemvParam reportItemvParam) throws Exception {
180 //报表数据项值
181 String reitId = sysConfigService.queryValueByKey("REIT_ID_DLHJ");
182 //reportItemvParam.setReportId(reportId);
183 reportItemvParam.setReitId( reitId );
184 //电
185 List<ReportDateTrendVO> electricityMapList = commandCentreService.getReportItemvByReitIdAndDate7Day(reportItemvParam );
186 //reportItemCode = "CSL";//查询字段
187 reitId = sysConfigService.queryValueByKey("REIT_ID_CSL");
188 //水集合
189 reportItemvParam.setReitId( reitId );
190 List<ReportDateTrendVO> waterMapList = commandCentreService.getReportItemvByReitIdAndDate7Day(reportItemvParam );
191
192 List<String > dateList = new ArrayList<>();//日期数据 181 List<String > dateList = new ArrayList<>();//日期数据
193 List<String> electricityList = new ArrayList<>();//电能数据数据; 182 List<String> electricityList = new ArrayList<>();//电能数据数据;
194 List<String> waterList = new ArrayList<>();// 水集合 183 List<String> waterList = new ArrayList<>();// 水集合
195 List<String> consumeList = new ArrayList<>();//电小号集合 184 List<String> consumeList = new ArrayList<>();//电集合
196 185
197 List<String > dateTimeList = DateUtil.getInstance().getBetweenDate(reportItemvParam.getStartDate(),reportItemvParam.getEndDate(),null); 186 String departIds = BaseContextHandler.getDeparts();
198 Map<String,String > electricityMap = new HashMap<String,String >();//电能数据数据; 187 List<ReportDateTrendVO> dlhjDateList = reportItemvService.getDayDateFieldList(ReportConstant.view3a24, "DLHJ", departIds, reportItemvParam.getStartDate(), reportItemvParam.getEndDate());
199 Map<String,String > waterMap = new HashMap<String,String >();//水 188 List<ReportDateTrendVO> cslDateList = reportItemvService.getDayDateFieldList(ReportConstant.view2119, "CSL", departIds, reportItemvParam.getStartDate(), reportItemvParam.getEndDate());
200 if(electricityMapList != null){
201 for( ReportDateTrendVO reportDateTrendVO : electricityMapList){
202 electricityMap.put(reportDateTrendVO.getTime(),reportDateTrendVO.getValue() );
203 }
204 }
205 if(waterMapList != null){
206 for( ReportDateTrendVO reportDateTrendVO : waterMapList){
207 waterMap.put(reportDateTrendVO.getTime(),reportDateTrendVO.getValue() );
208 }
209 }
210 189
211 String electricity = null; String water = null; String consume = null; 190 List<String > dateTimeList = DateUtil.getInstance().getBetweenDate(reportItemvParam.getStartDate(),reportItemvParam.getEndDate(),null);
212 for(String dateTime : dateTimeList){ 191 String dlhj = null; String csl = null; String dh = null;
213 electricity = electricityMap.get(dateTime ) ; 192 if(dateTimeList != null){
214 water = waterMap.get(dateTime ) ; 193
215 194 for(String dateTime : dateTimeList){
216 consume = "0"; 195 csl = null;
217 if(electricity == null ) electricity = "0"; 196 dlhj = null;
218 if(water == null ){ 197 dateList.add( DateUtil.getInstance().formatDate(dateTime,"MM-dd") ) ;
219 water = "0"; 198 //水
220 }else{ 199 if( cslDateList != null ){
221 consume = DigitalUtils.division( electricity ,water ); 200 for(ReportDateTrendVO cslVo : cslDateList){
201 if(dateTime.equals(cslVo.getTime())){
202 csl = cslVo.getValue();
203 break;
204 }
205 }
206 }
207 waterList.add(JSUtils.divide(csl,10000));
208 //电
209 if( dlhjDateList != null ){
210 for(ReportDateTrendVO dlhjVo : dlhjDateList){
211 if(dateTime.equals(dlhjVo.getTime())){
212 dlhj = dlhjVo.getValue();
213 break;
214 }
215 }
216 }
217 electricityList.add(ConvertUtils.getString(dlhj,"0"));
218 //电耗
219 consumeList.add(JSUtils.divide(JSUtils.divide(dlhj,csl),10000) );
222 } 220 }
223 electricityList.add( electricity ) ; waterList.add(water) ; consumeList.add( consume);
224 dateList.add( DateUtil.getInstance().formatDate(dateTime,"MM-dd") ) ;
225 } 221 }
226
227 StackedAreaChartDataVO stackedAreaChartDataVO = new StackedAreaChartDataVO(); 222 StackedAreaChartDataVO stackedAreaChartDataVO = new StackedAreaChartDataVO();
228 stackedAreaChartDataVO.setElectricityList(electricityList);//电集合 223 stackedAreaChartDataVO.setElectricityList(electricityList);//电集合
229 stackedAreaChartDataVO.setWaterList(waterList);//水集合 224 stackedAreaChartDataVO.setWaterList(waterList);//水集合
......
...@@ -29,7 +29,7 @@ import java.util.Map; ...@@ -29,7 +29,7 @@ import java.util.Map;
29 * @auther kangwei 29 * @auther kangwei
30 * @create 2024-11-01-10:09 30 * @create 2024-11-01-10:09
31 */ 31 */
32 @Service("reportItemvService") 32 @Service
33 public class ReportItemvService { 33 public class ReportItemvService {
34 34
35 private JdbcTemplate getJdbcTemplate(){ 35 private JdbcTemplate getJdbcTemplate(){
...@@ -262,6 +262,13 @@ public class ReportItemvService { ...@@ -262,6 +262,13 @@ public class ReportItemvService {
262 String sql = "select DATE_FORMAT( aaa.time, '%Y-%m' ) time , ROUND(SUM(IFNULL(aaa."+field+",0)),2) AS 'value' from " + dataViewName2119+ "aaa group by DATE_FORMAT( aaa.time, '%Y-%m' ) "; 262 String sql = "select DATE_FORMAT( aaa.time, '%Y-%m' ) time , ROUND(SUM(IFNULL(aaa."+field+",0)),2) AS 'value' from " + dataViewName2119+ "aaa group by DATE_FORMAT( aaa.time, '%Y-%m' ) ";
263 return getJdbcTemplate().query(sql,new BeanPropertyRowMapper<ReportDateTrendVO>(ReportDateTrendVO.class)); 263 return getJdbcTemplate().query(sql,new BeanPropertyRowMapper<ReportDateTrendVO>(ReportDateTrendVO.class));
264 } 264 }
265
266 public List<ReportDateTrendVO> getDayDateFieldList(String reportId, String field, String departId , String startTime , String endTime){
267 String dataViewName2119 = ReportViewUtil.buildView(reportId,field, departId, startTime,endTime);
268
269 String sql = "select aaa.time , ROUND(SUM(IFNULL(aaa."+field+",0)),2) AS 'value' from " + dataViewName2119+ "aaa group by aaa.time order by aaa.time";
270 return getJdbcTemplate().query(sql,new BeanPropertyRowMapper<ReportDateTrendVO>(ReportDateTrendVO.class));
271 }
265 public String getSumCSL(String departId ,String startTime ,String endTime){ 272 public String getSumCSL(String departId ,String startTime ,String endTime){
266 String dataViewName2119 = ReportViewUtil.buildViewLike(ReportConstant.view2119,"CSL", departId, startTime,endTime); 273 String dataViewName2119 = ReportViewUtil.buildViewLike(ReportConstant.view2119,"CSL", departId, startTime,endTime);
267 String sql = "select ROUND( sum( IFNULL( aaa.CSL,0) ),2) from " + dataViewName2119+ "aaa"; 274 String sql = "select ROUND( sum( IFNULL( aaa.CSL,0) ),2) from " + dataViewName2119+ "aaa";
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!