86b6e998 康伟

kangwei: 提交“指标中心”后端接口

1 个父辈 beb320ec
正在显示 27 个修改的文件 包含 930 行增加3 行删除
......@@ -86,8 +86,8 @@ public class ReportViewUtil {
* @param reportId 报表id
* @param fields 查询字段
* @param departIds 厂站集合
* @param startTime 开始时间
* @param endTime 结束时间
* @param dataTime 开始时间
* @param dataTime 结束时间
* @return
* @author Li Yuanyuan, 2021年2月26日 上午10:23:06
*/
......
......@@ -2,6 +2,7 @@ package com.skua.tool.util;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
......@@ -36,6 +37,28 @@ public class DigitalUtils {
}
/**
* 除法 保留两位小数
* @param dividend 请输入被除数
* @param divisor 请输入除数
* @return
*/
public static String division(String dividend , String divisor ){
String resultStr = "0";
if( dividend != null && dividend.length()>0 && divisor != null && divisor.length()>0){
double dividendD = Double.parseDouble(dividend);
double divisorD = Double.parseDouble(divisor);
double result = dividendD /divisorD;
BigDecimal bd = new BigDecimal(result);
BigDecimal roundedResult = bd.setScale(2, BigDecimal.ROUND_HALF_UP);System.out.println(roundedResult);
resultStr = roundedResult.toString();
}
//System.out.print("请输入被除数:");double dividend =scanner.nextDouble();
// System.out.print("请输入除数:");double divisor =scanner.nextDouble();
return resultStr;
}
/**
* 判断字符串是否是数字类型
*
* @param str
......
......@@ -99,6 +99,30 @@ public class SysAlgorithmStatisticsLibraryController {
return result;
}
@AutoLog(value = "统计功能配置表-统计计算")
@ApiOperation(value="统计功能配置表-统计计算", notes="统计功能配置表-统计计算")
@PostMapping(value = "/statistics/waterData")
public Result<SysAlgorithmStatisticsResultVO> statisticsByWaterData(@RequestBody JSONObject jsonObject,
HttpServletRequest req) throws Exception {
Result<SysAlgorithmStatisticsResultVO> result = new Result<>();
//将jsonObject转sysAlgorithmStatisticsLibraryVO对象
SysAlgorithmStatisticsLibraryVO sysAlgorithmStatisticsLibraryVO = JSONObject.toJavaObject(jsonObject, SysAlgorithmStatisticsLibraryVO.class);
//将jsonObject转Map对象
Map<String,Object> paramMap = JSONObject.toJavaObject(jsonObject,Map.class);
//将paramMap集合去掉SysAlgorithmStatisticsLibraryVO对象内容
Map<String,Object> sysAlgorithmStatisticsLibraryVOMap = JSON.parseObject(JSON.toJSONString(sysAlgorithmStatisticsLibraryVO), new TypeReference<Map<String, Object>>() {});
//Maps.difference(Map, Map)用来比较两个Map以获取所有不同点
MapDifference<String, Object> difference = Maps.difference(paramMap, sysAlgorithmStatisticsLibraryVOMap);
// 键只存在于左边Map的映射项
paramMap = difference.entriesOnlyOnLeft();
SysAlgorithmStatisticsResultVO vo = sysAlgorithmStatisticsLibraryService.statistics(sysAlgorithmStatisticsLibraryVO,paramMap);
//todo 演示暂时注释
result.setSuccess(true);
result.setResult(vo);
return result;
}
/**
* 添加
* @param sysAlgorithmStatisticsLibrary
......
package com.skua.modules.algorithm.controller;
import com.alibaba.fastjson.JSONObject;
import com.skua.core.api.vo.Result;
import com.skua.core.aspect.annotation.AutoLog;
import com.skua.modules.algorithm.service.ICommandCentreService;
import com.skua.modules.algorithm.vo.*;
import com.skua.modules.guest.util.DateUtil;
import com.skua.modules.report.entity.FReportItemv;
import com.skua.modules.report.vo.DepartLoadRateVO;
import com.skua.modules.report.vo.FRportlCommandCenterVO;
import com.skua.modules.report.vo.ReportItemvParam;
import com.skua.modules.system.service.ISysFactoryInfoService;
import com.skua.tool.util.DigitalUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
* 统计功能配置表
*/
@Slf4j
@Api(tags="指挥中心")
@RestController
@RequestMapping("/v1/algorithm/commandCentre")
public class SysCommandCentreController {
@Autowired
private ISysFactoryInfoService factoryInfoService;
@Autowired
private ICommandCentreService commandCentreService;
/**
* 分页列表查询
* @return
*/
@AutoLog(value = "指挥中心-水量查询")
@ApiOperation(value="指挥中心-水量查询", notes="指挥中心-水量查询")
@GetMapping(value = "/statisticsByWaterData")
public Result<SysCommandCentreResultVO> statisticsByWaterData(@RequestBody JSONObject jsonObject,
HttpServletRequest req) throws Exception{
Result<SysCommandCentreResultVO> result = new Result<>();
//将jsonObject转sysAlgorithmStatisticsLibraryVO对象
SysAlgorithmStatisticsLibraryVO sysAlgorithmLibraryVO = JSONObject.toJavaObject(jsonObject, SysAlgorithmStatisticsLibraryVO.class);
String reportId = " 2119ecbf53a1d2d0708258ff67cfd9e1";//报表编号
String reportItemCode = "CSL";//查询字段
//将jsonObject转Map对象
//Map<String,Object> paramMap = JSONObject.toJavaObject(jsonObject,Map.class);
//将paramMap集合去掉SysAlgorithmStatisticsLibraryVO对象内容
//Map<String,Object> sysAlgorithmStatisticsLibraryVOMap = JSON.parseObject(JSON.toJSONString(sysAlgorithmLibraryVO), new TypeReference<Map<String, Object>>() {});
//Maps.difference(Map, Map)用来比较两个Map以获取所有不同点
//MapDifference<String, Object> difference = Maps.difference(paramMap, sysAlgorithmStatisticsLibraryVOMap);
// 键只存在于左边Map的映射项
//paramMap = difference.entriesOnlyOnLeft();
// SysAlgorithmStatisticsResultVO vo = sysAlgorithmStatisticsLibraryService.statistics(sysAlgorithmStatisticsLibraryVO,paramMap);
ReportItemvParam reportItemvParam = new ReportItemvParam(reportId,reportItemCode ,sysAlgorithmLibraryVO.getStartDate() ,sysAlgorithmLibraryVO.getEndDate());
//List<FReportItemv> reportItemvList = ifReportItemvService.getReportItemvByReitId(reportItemvParam);
String startDate = sysAlgorithmLibraryVO.getStartDate();
String endDate = sysAlgorithmLibraryVO.getEndDate();
FReportItemv currenteportItemv = commandCentreService.getReportItemvByReitIdAndDate(reportId, reportItemCode,startDate , endDate );
//上月数据
FReportItemv lastMonthReportItemv = commandCentreService.getReportItemvByReitIdAndDate(reportId, reportItemCode,reportItemvParam.getLastMonthStartDate() , reportItemvParam.getLastMonthEndDate() );
//去年数据
FReportItemv lastYearReportItemv = commandCentreService.getReportItemvByReitIdAndDate(reportId, reportItemCode, reportItemvParam.getLastYearStartDate() , reportItemvParam.getLastYearEndDate() );
//整理数据
SysCommandCentreResultVO commandCentreResultVO = convertSysAlgorithmStatisticsResultNumberVO(currenteportItemv , lastMonthReportItemv,lastYearReportItemv);
commandCentreResultVO.setTotalData( factoryInfoService.querySumProScale() );
//todo 演示暂时注释
result.setSuccess(true);
result.setResult(commandCentreResultVO);
return result;
}
@AutoLog(value = "指挥中心-运行负荷率分析")
@ApiOperation(value="指挥中心-运行负荷率分析", notes="指挥中心-运行负荷率分析")
@GetMapping(value = "/statisticsByLoadRate")
public Result<DepartLoadRateResultVO> statisticsByLoadRate(@RequestBody JSONObject jsonObject,
HttpServletRequest req) throws Exception {
DepartLoadRateResultVO loadRateResultVO = new DepartLoadRateResultVO();
SysAlgorithmStatisticsLibraryVO sysAlgorithmLibraryVO = JSONObject.toJavaObject(jsonObject, SysAlgorithmStatisticsLibraryVO.class);
Integer loadRateType = 1;//默认查询
if(sysAlgorithmLibraryVO.getLoadRateType() != null){
loadRateType = sysAlgorithmLibraryVO.getLoadRateType();
}
List<DepartLoadRateVO> departLoadRateVOList = commandCentreService.statisticsByLoadRate(loadRateType);
loadRateResultVO.setDepartLoadRateVOList(departLoadRateVOList );
//统计总数
int normalNum = commandCentreService.statisticsByLoadRateNum(1);//正常
int lowLoadNum = commandCentreService.statisticsByLoadRateNum(2);//低负荷
int overloadNum = commandCentreService.statisticsByLoadRateNum(3);//超负荷
loadRateResultVO.setNormalNum( normalNum );
loadRateResultVO.setLowLoadNum( lowLoadNum );
loadRateResultVO.setOverloadNum( overloadNum );
Result<DepartLoadRateResultVO> result = new Result<>();
result.setSuccess(true);
result.setResult(loadRateResultVO);
return result;
}
//cement水泥 electricity
@AutoLog(value = "指挥中心-泥量统计")
@ApiOperation(value="指挥中心-泥量统计", notes="指挥中心-泥量统计")
@GetMapping(value = "/statisticsByCement")
public Result<SysCommandCentreResultVO> statisticsByCement(@RequestBody JSONObject jsonObject,
HttpServletRequest req) throws Exception {
Result<SysCommandCentreResultVO> result = new Result<>();
//将jsonObject转sysAlgorithmStatisticsLibraryVO对象
SysAlgorithmStatisticsLibraryVO sysAlgorithmLibraryVO = JSONObject.toJavaObject(jsonObject, SysAlgorithmStatisticsLibraryVO.class);
String reportId = " 3a243d5715b9e1a3753c180872ca0df9";//报表编号
String reportItemCode = "WNL";//查询字段
ReportItemvParam reportItemvParam = new ReportItemvParam(reportId,reportItemCode ,sysAlgorithmLibraryVO.getStartDate() ,sysAlgorithmLibraryVO.getEndDate());
String startDate = sysAlgorithmLibraryVO.getStartDate();
String endDate = sysAlgorithmLibraryVO.getEndDate();
FReportItemv currenteportItemv = commandCentreService.getReportItemvByReitIdAndDate(reportId, reportItemCode,startDate , endDate );
//上月数据
FReportItemv lastMonthReportItemv = commandCentreService.getReportItemvByReitIdAndDate(reportId, reportItemCode,reportItemvParam.getLastMonthStartDate() , reportItemvParam.getLastMonthEndDate() );
//去年数据
FReportItemv lastYearReportItemv = commandCentreService.getReportItemvByReitIdAndDate(reportId, reportItemCode, reportItemvParam.getLastYearStartDate() , reportItemvParam.getLastYearEndDate() );
//整理数据
SysCommandCentreResultVO commandCentreResultVO = convertSysAlgorithmStatisticsResultNumberVO(currenteportItemv , lastMonthReportItemv,lastYearReportItemv);
//
// FReportItemv waterCurrenteportItemv = ifReportItemvService.getReportItemvByReitIdAndDate(reportId, reportItemCode,startDate , endDate );
//commandCentreResultVO.setTotalData( factoryInfoService.querySumProScale() );
FRportlCommandCenterVO statisticsData = new FRportlCommandCenterVO();
//需要查询统计数据
commandCentreResultVO.setStatisticsData(statisticsData);
//todo 演示暂时注释
result.setSuccess(true);
result.setResult(commandCentreResultVO);
return result;
}
//cement水泥 electricity
@AutoLog(value = "指挥中心-能耗分析")
@ApiOperation(value="指挥中心-能耗分析", notes="指挥中心-能耗分析")
@GetMapping(value = "/statisticsByElectricity")
public Result<SysCommandCentreResultVO> statisticsByElectricity(@RequestBody JSONObject jsonObject,
HttpServletRequest req) throws Exception {
Result<SysCommandCentreResultVO> result = new Result<>();
//将jsonObject转sysAlgorithmStatisticsLibraryVO对象
SysAlgorithmStatisticsLibraryVO sysAlgorithmLibraryVO = JSONObject.toJavaObject(jsonObject, SysAlgorithmStatisticsLibraryVO.class);
String reportId = " 3a243d5715b9e1a3753c180872ca0df9";//报表编号
String reportItemCode = "DLHJ";//查询字段
ReportItemvParam reportItemvParam = new ReportItemvParam(reportId,reportItemCode ,sysAlgorithmLibraryVO.getStartDate() ,sysAlgorithmLibraryVO.getEndDate());
String startDate = sysAlgorithmLibraryVO.getStartDate();
String endDate = sysAlgorithmLibraryVO.getEndDate();
FReportItemv currenteportItemv = commandCentreService.getReportItemvByReitIdAndDate(reportId, reportItemCode,startDate , endDate );
//上月数据
FReportItemv lastMonthReportItemv = commandCentreService.getReportItemvByReitIdAndDate(reportId, reportItemCode,reportItemvParam.getLastMonthStartDate() , reportItemvParam.getLastMonthEndDate() );
//去年数据
FReportItemv lastYearReportItemv = commandCentreService.getReportItemvByReitIdAndDate(reportId, reportItemCode, reportItemvParam.getLastYearStartDate() , reportItemvParam.getLastYearEndDate() );
//整理数据
SysCommandCentreResultVO commandCentreResultVO = convertSysAlgorithmStatisticsResultNumberVO(currenteportItemv , lastMonthReportItemv,lastYearReportItemv);
//
// FReportItemv waterCurrenteportItemv = ifReportItemvService.getReportItemvByReitIdAndDate(reportId, reportItemCode,startDate , endDate );
//commandCentreResultVO.setTotalData( factoryInfoService.querySumProScale() );
FRportlCommandCenterVO statisticsData = new FRportlCommandCenterVO();
//需要查询统计数据
commandCentreResultVO.setStatisticsData(statisticsData);
//todo 演示暂时注释
result.setSuccess(true);
result.setResult(commandCentreResultVO);
return result;
}
//cement水泥 electricity
@AutoLog(value = "指挥中心-污水处理趋势")
@ApiOperation(value="指挥中心-污水处理趋势", notes="指挥中心-污水处理趋势")
@GetMapping(value = "/statisticsBySewage")
public Result<StackedAreaChartDataVO> statisticsBySewage(@RequestBody JSONObject jsonObject,
HttpServletRequest req) throws Exception {
SysAlgorithmStatisticsLibraryVO sysAlgorithmLibraryVO = JSONObject.toJavaObject(jsonObject, SysAlgorithmStatisticsLibraryVO.class);
String reportId = " 3a243d5715b9e1a3753c180872ca0df9";//报表编号
String reportItemCode = "DLHJ";//查询字段
String dateTime = null;//默认今天
//电
List<String> electricityList = commandCentreService.getReportItemvByReitIdAndDate7Day(reportId, reportItemCode,dateTime );
reportId = " 2119ecbf53a1d2d0708258ff67cfd9e1";//报表编号
reportItemCode = "CSL";//查询字段
//水集合
List<String> waterList = commandCentreService.getReportItemvByReitIdAndDate7Day(reportId, reportItemCode,dateTime );
//电耗集合
List<String> consumeList = new ArrayList<>();
String dividend =null; //被除数
String divisor = null;//除数
String division = null;//除法结果
if(electricityList != null && waterList != null && electricityList.size() == waterList.size()){
for(int i =0 ;i<electricityList.size() ; i++){
division = "0";
dividend = electricityList.get(i);
divisor = waterList.get(i);
if(dividend != null && divisor!= null && divisor.equals("0")){
DigitalUtils.division( dividend ,divisor );
}
consumeList.add( division );
}
}
List<String > dateList = DateUtil.getInstance().get7Day("MM-dd");
StackedAreaChartDataVO stackedAreaChartDataVO = new StackedAreaChartDataVO();
stackedAreaChartDataVO.setElectricityList(electricityList);
stackedAreaChartDataVO.setWaterList(waterList);
stackedAreaChartDataVO.setConsumeList( consumeList);
stackedAreaChartDataVO.setDateList(dateList );
Result<StackedAreaChartDataVO> result = new Result<>();
result.setSuccess(true);
result.setResult(stackedAreaChartDataVO);
return result;
}
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;
}
}
package com.skua.modules.algorithm.service;
import com.skua.modules.report.entity.FReportItemv;
import com.skua.modules.report.vo.DepartLoadRateVO;
import java.util.List;
/**
* <pre>
* 指挥中心实现逻辑
* </pre>
* @author 康伟
* @version V0.1, 2024年9月3日
*/
public interface ICommandCentreService {
/**
* 指挥中心---运行负荷率分析
* @param loadRateType
* @return
*/
public List<DepartLoadRateVO> statisticsByLoadRate(Integer loadRateType);
/**
* 指挥中心---运行负荷率分析 总数查询
* @param loadRateType
* @return
*/
public int statisticsByLoadRateNum(int loadRateType);
/**
* 根据reitId与时间查询
* @param reportId
* @param startDate
* @param endDate
* @return
*/
public FReportItemv getReportItemvByReitIdAndDate(String reportId, String reportItemCode, String startDate, String endDate);
/**
* 根据reitId查询近7天数据
* @param reportId
* @param reportItemCode
* @param dateTime
* @return
*/
public List<String> getReportItemvByReitIdAndDate7Day(String reportId, String reportItemCode, String dateTime);
}
......@@ -23,6 +23,8 @@ public interface ISysAlgorithmStatisticsLibraryService extends IService<SysAlgor
*/
SysAlgorithmStatisticsResultVO statistics(SysAlgorithmStatisticsLibraryVO sysAlgorithmStatisticsLibraryVO, Map<String,Object> paramMap) throws Exception;
SysAlgorithmStatisticsResultVO statisticsDayAndFill(SysAlgorithmStatisticsLibraryVO sysAlgorithmStatisticsLibraryVO, Map<String,Object> paramMap, SysAlgorithmStatisticsLibrary sysAlgorithmStatisticsLibrary) throws Exception;
SysAlgorithmStatisticsResultVO statisticsHour(SysAlgorithmStatisticsLibraryVO sysAlgorithmStatisticsLibraryVO, Map<String,Object> paramMap,SysAlgorithmStatisticsLibrary sysAlgorithmStatisticsLibrary) throws Exception;
......
package com.skua.modules.algorithm.service.impl;
import com.skua.modules.algorithm.service.ICommandCentreService;
import com.skua.modules.report.entity.FReportItemv;
import com.skua.modules.report.mapper.FReportItemMapper;
import com.skua.modules.report.vo.DepartLoadRateVO;
import com.skua.modules.report.mapper.FReportItemvMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* <pre>
* 指挥中心实现逻辑
* </pre>
* @author 康伟
* @version V0.1, 2024年9月3日
*/
@Service
public class CommandCentreServiceImpl implements ICommandCentreService {
@Resource
private FReportItemvMapper fReportItemvMapper;
@Resource
private FReportItemMapper reportItemMapper;
/**
* 指挥中心---运行负荷率分析
* @param loadRateType
* @return
*/
public List<DepartLoadRateVO> statisticsByLoadRate(Integer loadRateType){
return fReportItemvMapper.statisticsByLoadRate(loadRateType);
}
/**
* 指挥中心---运行负荷率分析 总数查询
* @param loadRateType
* @return
*/
public int statisticsByLoadRateNum(int loadRateType){
return fReportItemvMapper.statisticsByLoadRateNum(loadRateType);
}
/**
* 根据reitId与时间查询
* @param reportId
* @param startDate
* @param endDate
* @return
*/
public FReportItemv getReportItemvByReitIdAndDate(String reportId, String reportItemCode, String startDate, String endDate){
//根据reportId 与reportItemCode 查询reitId;
List<String> reitIdList = reportItemMapper.getReportItemId(reportId,reportItemCode);
FReportItemv reportItemv = null;
if(reitIdList != null ){
reportItemv = fReportItemvMapper.getReportItemvByReitIdAndDate(reitIdList.get(0) , startDate , endDate);
}
return reportItemv;
}
/**
* 根据reitId查询近7天数据
* @param reportId
* @param reportItemCode
* @param dateTime
* @return
*/
public List<String> getReportItemvByReitIdAndDate7Day(String reportId, String reportItemCode, String dateTime){
//根据reportId 与reportItemCode 查询reitId;
List<String> reitIdList = reportItemMapper.getReportItemId(reportId,reportItemCode);
List<String> dataList = null;
if(reitIdList != null ){
dataList = fReportItemvMapper.getReportItemvByReitIdAndDate7Day(reitIdList.get(0) , dateTime);
}
return dataList;
}
}
......@@ -16,6 +16,8 @@ import com.skua.modules.algorithm.service.ISysAlgorithmLibraryService;
import com.skua.modules.algorithm.service.ISysAlgorithmStatisticsLibraryService;
import com.skua.modules.algorithm.vo.*;
import com.skua.modules.flow.utils.StringUtil;
import com.skua.modules.report.mapper.FReportItemMapper;
import com.skua.modules.report.mapper.FReportItemvMapper;
import com.skua.modules.system.entity.SysDepart;
import com.skua.modules.system.service.ISysDepartService;
import org.apache.commons.lang3.StringUtils;
......@@ -24,6 +26,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.NumberFormat;
import java.util.*;
import java.util.concurrent.Callable;
......@@ -45,6 +48,7 @@ public class SysAlgorithmStatisticsLibraryServiceImpl extends ServiceImpl<SysAlg
private ThreadPoolTaskExecutor taskExecutor;
private static NumberFormat numberFormat;
static {
numberFormat = NumberFormat.getInstance();
numberFormat.setGroupingUsed(false);
......
package com.skua.modules.algorithm.vo;
import com.skua.modules.report.vo.DepartLoadRateVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 指挥中心--部门运行负荷率接受对象
*/
@Data
@ApiModel(value="指挥中心--部门运行负荷率接受对象", description="指挥中心--部门运行负荷率接受对象")
public class DepartLoadRateResultVO implements Serializable{
@ApiModelProperty(value = "正常负荷数")
private Integer normalNum;
@ApiModelProperty(value = "低负荷数")
private Integer lowLoadNum;
@ApiModelProperty(value = "超负荷数")
private Integer overloadNum;
@ApiModelProperty(value = "部门运行负荷率列表")
private List<DepartLoadRateVO> departLoadRateVOList;
}
package com.skua.modules.algorithm.vo;
import com.skua.modules.report.vo.DepartLoadRateVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 指挥中心--部门运行负荷率接受对象
*/
@Data
@ApiModel(value="指挥中心--污水处理趋势", description="指挥中心--污水处理趋势")
public class StackedAreaChartDataVO implements Serializable {
//电集合
@ApiModelProperty(value = "电集合")
List<String> electricityList;
//水集合
@ApiModelProperty(value = "水集合")
List<String> waterList ;
//电耗集合
@ApiModelProperty(value = "电耗集合")
List<String> consumeList = null;
@ApiModelProperty(value = "日历集合")
List<String> dateList;
}
......@@ -65,4 +65,15 @@ public class SysAlgorithmStatisticsLibraryVO {
@Excel(name = "是否查询子机构(0:不是,1:是)", width = 15)
@ApiModelProperty(value = "是否查询子机构(0:不是,1:是)")
private java.lang.String isChildDepart;
/**报表选项code*/
@ApiModelProperty(value = "报表Itme选项code")
private java.lang.String reportItemCode;
@ApiModelProperty(value = "报表编号")
private java.lang.String reportId;
@ApiModelProperty(value = "负载率类型")
private Integer loadRateType;
}
......
package com.skua.modules.algorithm.vo;
import com.skua.modules.report.vo.FRportlCommandCenterVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 统计功能配置表
*/
@Data
@ApiModel(value="控制中心报表结果接收对象", description="控制中心报表结果接收对象")
public class SysCommandCentreResultVO implements Serializable {
@ApiModelProperty(value = "当前月数据")
private FRportlCommandCenterVO monthData;
@ApiModelProperty(value = "上月数据")
private FRportlCommandCenterVO dayData;
@ApiModelProperty(value = "去年数据")
private FRportlCommandCenterVO yearData;
@ApiModelProperty(value = "统计数据")
private FRportlCommandCenterVO statisticsData;
@ApiModelProperty(value = "总设计规模")
private String totalData;
}
package com.skua.modules.guest.util;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.*;
/**
......@@ -25,6 +27,28 @@ public class DateUtil {
}
/**
* 获取7天日期数据,并指定显示格式
* @param dateFormat
* @return
*/
public List<String> get7Day(String dateFormat) {
if(dateFormat == null ){
dateFormat = "yyyy-MM-dd";
}
LocalDate today = LocalDate.now();
List<String> dates = new ArrayList<>();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateFormat);
for (int i = 0; i < 7; i++) {
LocalDate date = today.minusDays(i);
dates.add(date.format(formatter));
}
//dates.forEach(System.out::println);
return dates;
}
/**
* 获取今天日期
*
* @return
......@@ -125,5 +149,4 @@ public class DateUtil {
public static LocalDateTime dateToLocalDateTime(Date date){
return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
}
}
......
package com.skua.modules.report.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.skua.core.aspect.annotation.Dict;
......@@ -85,4 +86,15 @@ public class FReportItemv {
@ApiModelProperty(value = "标识")
private java.lang.Integer delFlag;
@ApiModelProperty(value = "统计总数")
@TableField(exist = false)
private String sumValue;
@ApiModelProperty(value = "平均总数")
@TableField(exist = false)
private String avgValue;
}
......
......@@ -18,6 +18,14 @@ public interface FReportItemMapper extends BaseMapper<FReportItem> {
List<FReportItem> getListByReportId(@Param("reportId") String reportId);
/**
* 根据 itemCode 与reportId 查询id
* @param reportId
* @param reportItemCode
* @return
*/
public List<String> getReportItemId(@Param("reportId") String reportId,@Param("itemCode") String reportItemCode);
void changeStatus(@Param("id") String id, @Param("required") String required);
List<FReportItem> getItemInfo(@Param("itemAlias") String itemAlias, @Param("reportId") String reportId);
......
package com.skua.modules.report.mapper;
import com.skua.modules.report.vo.DepartLoadRateVO;
import com.skua.modules.report.vo.ReportItemvParam;
import org.apache.ibatis.annotations.Param;
import com.skua.modules.report.entity.FReportItemv;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
......@@ -32,4 +34,44 @@ public interface FReportItemvMapper extends BaseMapper<FReportItemv> {
* @author Li Yuanyuan, 2021年5月25日 上午10:34:37
*/
List<FReportItemv> getReportItemvByDataId(String dataId);
/**
* 据reit_id 查询视图表数据 返回总数,平均数
* @param reportItemvParam
* @return
*/
List<FReportItemv> getReportItemvByReitId(ReportItemvParam reportItemvParam);
/**
* 根据reitId与时间查询
* @param reitId
* @param startDate
* @param endDate
* @return
*/
public FReportItemv getReportItemvByReitIdAndDate(@Param("reitId") String reitId, @Param("startDate") String startDate,@Param("endDate") String endDate);
/**
* 根据类型查询:指挥中心---运行负荷率分析
* @param loadRateType
* @return
*/
public List<DepartLoadRateVO> statisticsByLoadRate(@Param("loadRateType") Integer loadRateType);
/**
* 指挥中心---运行负荷率分析 总数查询
* @param loadRateType
* @return
*/
public int statisticsByLoadRateNum(@Param("loadRateType") Integer loadRateType);
/**
* 根据reitId查询近7天数据
* @param reitId
* @param dateTime
* @return
*/
public List<String> getReportItemvByReitIdAndDate7Day(@Param("reitId") String reitId, @Param("dateTime") String dateTime);
}
......
......@@ -18,6 +18,14 @@
order by sort_num
</select>
<!-- 根据 itemCode 与reportId 查询id -->
<select id="getReportItemId" resultType="java.lang.String">
select id from f_report_item
where report_id = #{reportId} and required='1' and item_code = #{itemCode}
</select>
<update id="changeStatus">
update f_report_item set required = #{required} where id = #{id}
</update>
......
......@@ -38,6 +38,73 @@
<select id="getReportItemvByDataId" resultType="com.skua.modules.report.entity.FReportItemv">
select * from f_report_itemv where data_id=#{dataId}
</select>
<!-- 根据reit_id 查询视图表数据 返回总数,平均数 -->
<select id="getReportItemvByReitId" resultType="com.skua.modules.report.entity.FReportItemv">
SELECT sum(item_value) 'sum_value' , avg(item_value) 'avg_value', 'DD' as 'itemValue' FROM f_report_itemv where reit_id=#{reitId} and data_time &gt;= #{startDate} and data_time &lt;= #{endDate}
union all
SELECT sum(item_value),avg(item_value) ,'HB' FROM f_report_itemv where reit_id=#{reitId} and data_time &gt;= #{lastMonthStartDate} and data_time &lt;= #{lastMonthEndDate}
union all
SELECT sum(item_value) ,avg(item_value),'TB' FROM f_report_itemv where reit_id=#{reitId} and data_time &gt;= #{lastYearStartDate} and data_time &lt;= #{lastYearEndDate}
</select>
<!-- 根据reit_id 查询视图表数据 返回总数,平均数 -->
<select id="getReportItemvByReitIdAndDate" resultType="com.skua.modules.report.entity.FReportItemv">
SELECT sum(item_value) 'sum_value' , avg(item_value) 'avg_value' FROM f_report_itemv where reit_id=#{reitId} and data_time &gt;= #{startDate} and data_time &lt;= #{endDate}
</select>
<!-- 根据类型查询:指挥中心-运行负荷率分析 -->
<select id="statisticsByLoadRate" resultType="com.skua.modules.report.vo.DepartLoadRateVO">
select aaa.avg_data ,aaa.sum_data 'waterYieldMonth', fi.pro_scale , d.depart_name 'departName' , ROUND(aaa.avg_data / (fi.pro_scale * 100000) , 2) 'loadRate'
from (
select avg(ri.item_value) 'avg_data' ,sum(ri.item_value) 'sum_data' ,ri.depart_id from f_report_itemv ri where ri.data_time &gt;= #{startDate} and ri.data_time &lt;= #{endDate} group by ri.depart_id
) aaa
left join sys_factory_info fi on aaa.depart_id = fi.depart_id
left join sys_depart d on d.id = aaa.depart_id
where 1=1
<if test="loadRateType != null and loadRateType == '1'">
and aaa.avg_data / (fi.pro_scale * 100000) &gt;= 60 and aaa.avg_data / (fi.pro_scale * 100000) &lt;= 120
</if>
<if test="loadRateType != null and loadRateType == '2'">
aaa.avg_data / (fi.pro_scale * 100000) &lt; 60
</if>
<if test="loadRateType != null and loadRateType == '3'">
and aaa.avg_data / (fi.pro_scale * 100000) &gt; 120
</if>
order by aaa.avg_data / fi.pro_scale desc limit 10
</select>
<!-- 根据类型查询:指挥中心-运行负荷率分析 -->
<select id="statisticsByLoadRateNum" resultType="java.lang.Integer">
select count(1)
from (
select avg(ri.item_value) 'avg_data' ,sum(ri.item_value) 'sum_data' ,ri.depart_id from f_report_itemv ri where ri.data_time &gt;= #{startDate} and ri.data_time &lt;= #{endDate} group by ri.depart_id
) aaa
left join sys_factory_info fi on aaa.depart_id = fi.depart_id
left join sys_depart d on d.id = aaa.depart_id
where 1=1
<if test="loadRateType != null and loadRateType == '1'">
and aaa.avg_data / (fi.pro_scale * 100000) &gt;= 60 and aaa.avg_data / (fi.pro_scale * 100000) &lt;= 120
</if>
<if test="loadRateType != null and loadRateType == '2'">
aaa.avg_data / (fi.pro_scale * 100000) &lt; 60
</if>
<if test="loadRateType != null and loadRateType == '3'">
and aaa.avg_data / (fi.pro_scale * 100000) &gt; 120
</if>
</select>
<!-- 根据reitId查询近7天数据-->
<select id="statisticsByLoadRateNum" resultType="java.lang.Integer">
SELECT sum(item_value) FROM f_report_itemv where reit_id=#{reitId} and DATE_SUB( CURDATE(), INTERVAL 7 DAY ) &lt;= date(data_time)
group by data_time
</select>
</mapper>
......
......@@ -2,6 +2,7 @@ package com.skua.modules.report.service;
import com.skua.modules.report.entity.FReportItemv;
import com.baomidou.mybatisplus.extension.service.IService;
import com.skua.modules.report.vo.ReportItemvParam;
import java.util.Date;
import java.util.List;
......@@ -23,4 +24,13 @@ public interface IFReportItemvService extends IService<FReportItemv> {
boolean isExitDataByTime(String reitId, String dataTime, String departId);
//通过dataId获取填报数据
List<FReportItemv> getReportItemvByDataId(String dataId);
/**
* 据reit_id 查询视图表数据 返回总数,平均数
* @param reportItemvParam
* @return
*/
List<FReportItemv> getReportItemvByReitId(ReportItemvParam reportItemvParam);
}
......
......@@ -2,8 +2,11 @@ package com.skua.modules.report.service.impl;
import com.skua.common.report.ReportViewUtil;
import com.skua.modules.report.entity.FReportItemv;
import com.skua.modules.report.mapper.FReportItemMapper;
import com.skua.modules.report.mapper.FReportItemvMapper;
import com.skua.modules.report.service.IFReportItemvService;
import com.skua.modules.report.vo.FRportlCommandCenterVO;
import com.skua.modules.report.vo.ReportItemvParam;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
......@@ -24,6 +27,9 @@ public class FReportItemvServiceImpl extends ServiceImpl<FReportItemvMapper, FRe
@Resource
private FReportItemvMapper fReportItemvMapper;
@Override
public void deleteByDataId(String dataId) {
fReportItemvMapper.deleteByDataId(dataId);
......@@ -71,4 +77,17 @@ public class FReportItemvServiceImpl extends ServiceImpl<FReportItemvMapper, FRe
return fReportItemvMapper.getReportItemvByDataId(dataId);
}
/**
* 据reit_id 查询视图表数据 返回总数,平均数
* @param reportItemvParam
* @return
*/
public List<FReportItemv> getReportItemvByReitId(ReportItemvParam reportItemvParam){
return fReportItemvMapper.getReportItemvByReitId(reportItemvParam);
}
}
......
package com.skua.modules.report.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 统计功能配置表
*/
@Data
@ApiModel(value="指挥中心--部门运行负荷率接受对象", description="指挥中心--部门运行负荷率接受对象")
public class DepartLoadRateVO implements Serializable{
@ApiModelProperty(value = "项目公司")
private String departName;
@ApiModelProperty(value = "运行负荷率")
private String loadRate;
@ApiModelProperty(value = "达标率")
private String qualifyRate;
@ApiModelProperty(value = "处理水量(吨/月)")
private String waterYieldMonth;
}
package com.skua.modules.report.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 统计功能配置表
*/
@Data
@ApiModel(value="控制中心报表结果接收对象", description="控制中心报表结果接收对象")
public class FRportlCommandCenterVO implements Serializable {
@ApiModelProperty(value = "标题")
private String title;
@ApiModelProperty(value = "结果")
private String value;
/* @ApiModelProperty(value = "最大值")
private Object maxValue;
@ApiModelProperty(value = "最小值")
private Object minValue;*/
@ApiModelProperty(value = "上月同期")
private String valueTb;
@ApiModelProperty(value = "去年同期")
private String valueHb;
/* @ApiModelProperty(value = "同比比例")
private Object valueTbProportion;
@ApiModelProperty(value = "同比差值")
private Object valueTbDifference;
@ApiModelProperty(value = "环比比例")
private Object valueHbProportion;
@ApiModelProperty(value = "环比差值")
private Object valueHbDifference;
@ApiModelProperty(value = "上期")
private Object valuePre;
@ApiModelProperty(value = "上期比例")
private Object valuePreProportion;
@ApiModelProperty(value = "上期差值")
private Object valuePreDifference;
@ApiModelProperty(value = "单位")
private String unit;*/
}
package com.skua.modules.report.vo;
import com.skua.core.util.DateUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.text.ParseException;
import java.util.Calendar;
/**
* ReportItemvParam 查询参数
*/
@Data
@ApiModel(value="统计结果查询对象", description="统计结果查询对象")
public class ReportItemvParam implements Serializable{
@ApiModelProperty(value = "报表数据项id")
public String reitId;
@ApiModelProperty(value = "报表编号")
private java.lang.String reportId;
@ApiModelProperty(value = "报表Itme选项code")
private java.lang.String reportItemCode;
/**开始时间*/
@ApiModelProperty(value = "开始时间")
private java.lang.String startDate;
@ApiModelProperty(value = "结束时间")
private java.lang.String endDate;
@ApiModelProperty(value = "上月开始时间")
private java.lang.String lastMonthStartDate;
@ApiModelProperty(value = "上月结束时间")
private java.lang.String lastMonthEndDate;
@ApiModelProperty(value = "去年开始时间")
private java.lang.String lastYearStartDate;
@ApiModelProperty(value = "去年结束时间")
private java.lang.String lastYearEndDate;
/**
* 初始化数据
* @param startTime
* @param endTime
*/
public ReportItemvParam(String reportId ,String reportItemCode ,String startTime , String endTime){
try {
this.reitId = reportId;
this.reportItemCode = reportItemCode;
if(startTime != null && startTime.length() > 0 ){
this.startDate = startTime;
this.lastMonthStartDate = DateUtils.formatAddTime(startTime, "yyyy-MM-dd", Calendar.MONTH, -1);
this.lastYearStartDate = DateUtils.formatAddTime(startTime, "yyyy-MM-dd", Calendar.YEAR, -1);
}
if(endTime != null && endTime.length() > 0 ){
this.endDate = endTime;
this.lastMonthEndDate = DateUtils.formatAddTime(endTime, "yyyy-MM-dd", Calendar.MONTH, -1);
this. lastYearEndDate = DateUtils.formatAddTime(endTime, "yyyy-MM-dd", Calendar.YEAR, -1);
}
} catch (ParseException e) {
e.printStackTrace();
}
}
}
......@@ -90,4 +90,10 @@ public interface SysFactoryInfoMapper extends BaseMapper<SysFactoryInfo> {
@Select("SELECT d.id as depart_id, d.depart_name AS NAME,d.depart_name AS depart_name,d.depart_type,(select depart_name from sys_depart sd where d.parent_id = sd.id )areaName,f.* FROM sys_depart d LEFT JOIN sys_factory_info f ON f.depart_id = d.id ${customSqlSegment}")
List<SysFactoryInfoVO> getFactoryListByWrapper(QueryWrapper queryWrapper);
/**
* 获取总的设计规模
* @return
*/
public String querySumProScale();
}
......
......@@ -489,4 +489,9 @@
WHERE
alarm_program_code = #{id}
</select>
<!-- 获取总的设计规模-->
<select id="" resultType="java.lang.String">
select sum(pro_scale) from sys_factory_info
</select>
</mapper>
......
......@@ -101,4 +101,12 @@ public interface ISysFactoryInfoService extends IService<SysFactoryInfo> {
void exitNew(SysFactoryInfoNewVO sysFactoryInfoNewVO);
List<SysFactoryInfoVO> getFactoryListByWrapper(QueryWrapper<SysFactoryInfoVO> queryWrapper);
/**
* 获取总的设计规模
* @return
*/
public String querySumProScale();
}
......
......@@ -665,4 +665,12 @@ public class SysFactoryInfoServiceImpl extends ServiceImpl<SysFactoryInfoMapper,
return sysFactoryInfo;
}
/**
* 获取总的设计规模
* @return
*/
public String querySumProScale(){
return sysFactoryInfoMapper.querySumProScale();
}
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!