47f70105 康伟

kangwei:指挥中心,修改公式

1 个父辈 36b09673
......@@ -2,6 +2,7 @@ package com.skua.tool.util;
import com.skua.constant.BaseConstant;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
......@@ -25,6 +26,32 @@ public class DateUtils {
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(str2Date(date,format));
}
public static void main(String[] args) {
System.out.println( formatDate("2024-01-01","yyyy-MM"));
}
/***
* 字符串日期格式化
* @param date
* @param format
* @return
*/
public static String formatDate(String date , String format){
if(format == null ){
format = "yyyy-MM-dd";
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat formatSDF = new SimpleDateFormat(format);
// 转化成日期类型
try {
Date startDate = sdf.parse(date);
date = formatSDF.format(startDate);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
public static Date str2Date(String str, String pattern) {
Date d = null;
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
......
......@@ -39,10 +39,10 @@ public class AjhWasteSolidContract {
@ApiModelProperty(value = "水厂名称")
private String departName;
@Excel(name = "处理单位", width = 15)
@ApiModelProperty(value = "处理单位")
@Excel(name = "关联处置点", width = 15)
@ApiModelProperty(value = "关联处置点")
@Dict(dictTable = "ajh_safe_handle_point", dicCode="id", dicText = "company_name")
private String handleDepartName;
private String handlePointId;
/**合同签订时间*/
@Excel(name = "合同签订时间", width = 15)
@ApiModelProperty(value = "合同签订时间")
......
......@@ -40,10 +40,10 @@ public class AjhWasteSolidTransport {
@ApiModelProperty(value = "水厂名称")
private String departName;
@Excel(name = "处理单位", width = 15)
@ApiModelProperty(value = "处理单位")
@Excel(name = "关联处置点", width = 15)
@ApiModelProperty(value = "关联处置点")
@Dict(dictTable = "ajh_safe_handle_point", dicCode="id", dicText = "company_name")
private String handleDepartName;
private String handlePointId;
/**车牌号*/
@Excel(name = "车牌号", width = 15)
@ApiModelProperty(value = "车牌号")
......
package com.skua.modules.algorithm.controller;
import com.skua.common.constant.ReportConstant;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.core.context.BaseContextHandler;
import com.skua.core.util.ConvertUtils;
import com.skua.modules.algorithm.service.ICommandCentreService;
import com.skua.modules.algorithm.service.impl.ReportItemvService;
import com.skua.modules.algorithm.vo.*;
......@@ -155,7 +157,7 @@ public class SysCommandCentreController {
@GetMapping(value = "/statisticsByElectricity")
public Result<List<FRportlCommandCenterVO>> statisticsByElectricity(ReportItemvParam reportItemvParam) throws Exception {
Result<List<FRportlCommandCenterVO>> result = new Result();
String departId = "1818214519948836864,1711662624459804674";
String departId = BaseContextHandler.getDeparts();
List<FRportlCommandCenterVO> dataList = reportItemvService.statisticsByElectricity(departId,reportItemvParam.getStartDate(),reportItemvParam.getEndDate());
result.setResult(dataList );
return result;
......@@ -186,6 +188,7 @@ public class SysCommandCentreController {
//水集合
reportItemvParam.setReitId( reitId );
List<ReportDateTrendVO> waterMapList = commandCentreService.getReportItemvByReitIdAndDate7Day(reportItemvParam );
List<String > dateList = new ArrayList<>();//日期数据
List<String> electricityList = new ArrayList<>();//电能数据数据;
List<String> waterList = new ArrayList<>();// 水集合
......@@ -196,12 +199,12 @@ public class SysCommandCentreController {
Map<String,String > waterMap = new HashMap<String,String >();//水
if(electricityMapList != null){
for( ReportDateTrendVO reportDateTrendVO : electricityMapList){
electricityMap.put(reportDateTrendVO.getDate(),reportDateTrendVO.getValue() );
electricityMap.put(reportDateTrendVO.getTime(),reportDateTrendVO.getValue() );
}
}
if(waterMapList != null){
for( ReportDateTrendVO reportDateTrendVO : waterMapList){
waterMap.put(reportDateTrendVO.getDate(),reportDateTrendVO.getValue() );
waterMap.put(reportDateTrendVO.getTime(),reportDateTrendVO.getValue() );
}
}
......@@ -268,72 +271,50 @@ public class SysCommandCentreController {
return commandCenterVOList;
}
/* private SysCommandCentreResultVO convertSysAlgorithmStatisticsResultNumberVO(FReportItemv currenteportItemv, FReportItemv lastMonthReportItemv ,FReportItemv lastYearReportItemv ){
SysCommandCentreResultVO commandCentreResultVO = new SysCommandCentreResultVO();
FRportlCommandCenterVO monthData = new FRportlCommandCenterVO();//当月数据
FRportlCommandCenterVO dayData = new FRportlCommandCenterVO();//日数据
//FRportlCommandCenterVO yearData = new FRportlCommandCenterVO();//年数据
monthData.setValue( DigitalUtils.division(currenteportItemv.getSumValue() ,"10000") );
monthData.setValueHb( DigitalUtils.division( lastMonthReportItemv.getSumValue(),"10000"));//上月同期;
monthData.setValueTb( DigitalUtils.division( lastYearReportItemv.getSumValue(),"10000") );//去年同期
dayData.setValue( DigitalUtils.division( currenteportItemv.getAvgValue(),"10000"));
dayData.setValueHb( DigitalUtils.division( lastMonthReportItemv.getAvgValue(),"10000"));//上月同期;
dayData.setValueTb( DigitalUtils.division( lastYearReportItemv.getAvgValue(),"10000") );//去年同期
//dayData.setValue(currenteportItemv.getAvgValue());lastMonthReportItemv.getAvgValue(); lastYearReportItemv.getAvgValue();
// yearData.setValue();yearData.setValueHb(); yearData.setValueTb();
commandCentreResultVO.setMonthData( monthData ) ;
commandCentreResultVO.setDayData( dayData );
return commandCentreResultVO;
}*/
@AutoLog(value = "指挥中心-费用趋势")
@ApiOperation(value="指挥中心-费用趋势", notes="指挥中心-费用趋势")
@GetMapping(value = "/statisticsByFy")
public Result<StackedAreaChartDataVO> statisticsByFy(ReportItemvParam reportItemvParam) {
//费用
List<ReportDateTrendVO> fyMapList = commandCentreService.getFyData(reportItemvParam);
String reitId = sysConfigService.queryValueByKey("REIT_ID_CSL");
String startDate = reportItemvParam.getStartDate();
String endDate = reportItemvParam.getEndDate();
reportItemvParam.setStartDate( DateUtils.formatDate(startDate ,"YYYY-MM"));
reportItemvParam.setEndDate( DateUtils.formatDate(endDate ,"YYYY-MM"));
String departIds = BaseContextHandler.getDeparts();
reportItemvParam.setDepartIds( JSUtils.quoteEach(departIds,","));
List<ReportDateTrendVO> fyDataList = commandCentreService.getFyData(reportItemvParam);
List<ReportDateTrendVO> waterDataList = reportItemvService.getDateFieldList(ReportConstant.view2119,"CSL", departIds, startDate,endDate);
//水集合
reportItemvParam.setReitId( reitId );
List<ReportDateTrendVO> waterMapList = commandCentreService.getClslData(reportItemvParam);
List<String > dateList = new ArrayList<>();//日期数据
List<String> fyList = new ArrayList<>();//电能数据数据;
List<String> waterList = new ArrayList<>();// 水集合
List<String> dateTimeList = getMonthsBetween(reportItemvParam.getStartDate(),reportItemvParam.getEndDate());
Map<String,String > electricityMap = new HashMap<String,String >();//电能数据数据;
Map<String,String > waterMap = new HashMap<String,String >();//水
if(fyMapList != null){
for( ReportDateTrendVO reportDateTrendVO : fyMapList){
electricityMap.put(reportDateTrendVO.getDate(),reportDateTrendVO.getValue() );
String electricity = null; String water = null;
List<String> dateTimeList = getMonthsBetween(startDate,endDate);
for(String dateTime : dateTimeList){
if(fyDataList != null ){
for( ReportDateTrendVO dateTrendVO : fyDataList){
if( dateTime.equals( dateTrendVO.getTime() )){
fyList.add(ConvertUtils.getString( dateTrendVO.getValue() ,"0")) ;
break;
}
}
if(waterMapList != null){
for( ReportDateTrendVO reportDateTrendVO : waterMapList){
waterMap.put(reportDateTrendVO.getDate(),reportDateTrendVO.getValue() );
}
if(waterDataList != null ){
for( ReportDateTrendVO dateTrendVO : waterDataList){
if( dateTime.equals( dateTrendVO.getTime() )){
waterList.add(ConvertUtils.getString( dateTrendVO.getValue() ,"0")) ;
break;
}
}
String electricity = null; String water = null;
for(String dateTime : dateTimeList){
electricity = electricityMap.get(dateTime ) ;
water = waterMap.get(dateTime ) ;
if(electricity == null) electricity = "0";
if(water == null ){
water = "0";
}
fyList.add( electricity ) ; waterList.add(water) ;
dateList.add(dateTime) ;
}
StackedAreaChartDataVO stackedAreaChartDataVO = new StackedAreaChartDataVO();
stackedAreaChartDataVO.setElectricityList(fyList);//费用集合
stackedAreaChartDataVO.setWaterList(waterList);//水集合
stackedAreaChartDataVO.setDateList(dateList);//日期集合
stackedAreaChartDataVO.setXAxis(dateList);
stackedAreaChartDataVO.setDateList(dateTimeList);//日期集合
stackedAreaChartDataVO.setXAxis(dateTimeList);
List<String> yaXisList = new ArrayList<String>();
yaXisList.addAll(fyList) ;//费用
......
......@@ -11,6 +11,7 @@ import com.skua.modules.common.vo.DateVO;
import com.skua.modules.quartz.util.BaseUtil;
import com.skua.modules.report.vo.DepartLoadRateVO;
import com.skua.modules.report.vo.FRportlCommandCenterVO;
import com.skua.modules.report.vo.ReportDateTrendVO;
import com.skua.tool.util.DateUtils;
import com.skua.tool.util.JSUtils;
import org.apache.commons.lang.StringUtils;
......@@ -60,8 +61,8 @@ public class ReportItemvService {
FRportlCommandCenterVO nowMonthVO = new FRportlCommandCenterVO("月总数据(", JSUtils.format(nowMonthValue), JSUtils.format(lastMonthValue), JSUtils.format(lastYearValue));
//日均数据:/环比/同比
FRportlCommandCenterVO lastMonthVO = new FRportlCommandCenterVO("日均数据",JSUtils.divide( nowMonthValue ,nowDifferDay ) ,JSUtils.divide( lastMonthValue ,lastMonthDifferDay ),JSUtils.divide( lastYearValue ,lastYearDifferDay ) );
//吨水消耗
FRportlCommandCenterVO lastYearVo = new FRportlCommandCenterVO("吨水数据",JSUtils.divide( nowMonthValue ,nowMonthCSL ) ,JSUtils.divide( lastMonthValue ,lastMonthCSL ),JSUtils.divide( lastYearValue ,lastYearCSL ));
//吨水消耗=万吨水产泥量
FRportlCommandCenterVO lastYearVo = new FRportlCommandCenterVO("万吨水产泥量",JSUtils.divide( nowMonthValue ,JSUtils.divide(nowMonthCSL,10000) ) ,JSUtils.divide( lastMonthValue , JSUtils.divide(lastMonthCSL,10000)),JSUtils.divide( lastYearValue , JSUtils.divide(lastYearCSL,10000) ));
fRportlCommandCenterVOList.add( nowMonthVO) ;
fRportlCommandCenterVOList.add( lastMonthVO) ;
fRportlCommandCenterVOList.add( lastYearVo) ;
......@@ -83,7 +84,7 @@ public class ReportItemvService {
List<FRportlCommandCenterVO> fRportlCommandCenterVOList = new ArrayList<>();
DateVO dateVO = new DateVO(startTime);
String dataViewName3a24 = ReportViewUtil.buildViewLike(ReportConstant.view3a24,"DLHJ", departId, startTime,endTime);
String sql = "select sum(aaa.DLHJ) from " + dataViewName3a24+ "aaa";
String sql = "select ROUND( SUM( IFNULL(aaa.DLHJ,0) ), 2 ) AS DLHJ from " + dataViewName3a24+ "aaa";
String nowMonthValue = getSumDLHJ(departId,dateVO.getNowMonthStartDate(),dateVO.getNowMonthEndDate());
String lastMonthValue = getSumDLHJ(departId, dateVO.getLastMonthStartTime(),dateVO.getLastMonthEndTime());
......@@ -98,9 +99,9 @@ public class ReportItemvService {
long lastYearDifferDay = DateUtils.differenceDay(dateVO.getLastYearMonthStartTime(),dateVO.getLastYearMonthEndTime());
//当月数据/环比、同比
FRportlCommandCenterVO nowMonthVO = new FRportlCommandCenterVO("月总电耗(", JSUtils.format(nowMonthValue), JSUtils.format(lastMonthValue), JSUtils.format(lastYearValue));
FRportlCommandCenterVO nowMonthVO = new FRportlCommandCenterVO("月总电耗(", JSUtils.divide(nowMonthValue,10000), JSUtils.divide(lastMonthValue,10000), JSUtils.divide(lastYearValue,10000));
//日均数据:/环比/同比
FRportlCommandCenterVO lastMonthVO = new FRportlCommandCenterVO("日均电耗",JSUtils.divide( nowMonthValue ,nowDifferDay ) ,JSUtils.divide( lastMonthValue ,lastMonthDifferDay ),JSUtils.divide( lastYearValue ,lastYearDifferDay ) );
FRportlCommandCenterVO lastMonthVO = new FRportlCommandCenterVO("日均电耗",JSUtils.divide( nowMonthValue ,nowDifferDay*10000 ) ,JSUtils.divide( lastMonthValue ,lastMonthDifferDay*10000 ),JSUtils.divide( lastYearValue ,lastYearDifferDay*10000 ) );
//吨水消耗
FRportlCommandCenterVO lastYearVo = new FRportlCommandCenterVO("吨水电耗",JSUtils.divide( nowMonthValue ,nowMonthCSL ) ,JSUtils.divide( lastMonthValue ,lastMonthCSL ),JSUtils.divide( lastYearValue ,lastYearCSL ));
fRportlCommandCenterVOList.add( nowMonthVO) ;
......@@ -238,7 +239,7 @@ public class ReportItemvService {
private Map<String,String> commonQueryByField(String departIds ,String startTime ,String endTime,String dataViewName,String field){
Map<String,String> cslMap = new HashMap<>();
String dataViewNameSql = ReportViewUtil.buildViewLike(dataViewName,field, departIds, startTime,endTime);
System.out.println("dataViewNameSql ="+dataViewNameSql );
//System.out.println("dataViewNameSql ="+dataViewNameSql );
List<Map<String, Object>> dataMapList = getJdbcTemplate().queryForList(dataViewNameSql);
if(dataMapList != null){
for(Map<String, Object> dataMap : dataMapList){
......@@ -254,6 +255,12 @@ public class ReportItemvService {
* @param endTime
* @return
*/
public List<ReportDateTrendVO> getDateFieldList(String reportId, String field, String departId , String startTime , String endTime){
String dataViewName2119 = ReportViewUtil.buildView(reportId,field, departId, startTime,endTime);
String sql = "select aaa.time, sum(aaa."+field+") 'value' from " + dataViewName2119+ "aaa group by aaa.time";
return getJdbcTemplate().query(sql,new BeanPropertyRowMapper<ReportDateTrendVO>(ReportDateTrendVO.class));
}
public String getSumCSL(String departId ,String startTime ,String endTime){
String dataViewName2119 = ReportViewUtil.buildViewLike(ReportConstant.view2119,"CSL", departId, startTime,endTime);
String sql = "select sum(aaa.CSL) from " + dataViewName2119+ "aaa";
......
......@@ -137,13 +137,14 @@
<select id="getFyData" resultType="com.skua.modules.report.vo.ReportDateTrendVO">
SELECT
month AS date,
SUM( cost ) AS value
t.month AS time,
ROUND( SUM( IFNULL(t.cost,0) ), 2 ) AS value
FROM
report_electric_cost
report_electric_cost t
WHERE
month BETWEEN #{startDate} AND ${endDate}
GROUP BY month
t.depart_id in(${departIds})
and t.month BETWEEN #{startDate} AND ${endDate}
GROUP BY t.month
</select>
<select id="getClslData" resultType="com.skua.modules.report.vo.ReportDateTrendVO">
......
......@@ -14,7 +14,7 @@ import java.io.Serializable;
public class ReportDateTrendVO implements Serializable{
@ApiModelProperty(value = "当前月数据")
private String date;
private String time;
@ApiModelProperty(value = "当前月数据")
private String value;
}
......
......@@ -19,6 +19,9 @@ public class ReportItemvParam implements Serializable{
@ApiModelProperty(value = "报表数据项id")
public String reitId;
@ApiModelProperty(value = "部门集合")
public String departIds ;
@ApiModelProperty(value = "报表编号")
private java.lang.String reportId;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!