a0c024ef 康伟

kangwei :指挥中心-运行负荷率分析-处理水量详情

1 个父辈 d8f9987d
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.core.context.BaseContextHandler;
import com.skua.modules.algorithm.service.ICommandCentreService;
import com.skua.modules.algorithm.vo.*;
import com.skua.modules.guest.util.DateUtil;
......@@ -14,14 +14,10 @@ import com.skua.tool.util.DigitalUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
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.time.LocalDate;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
......@@ -561,4 +557,16 @@ public class SysCommandCentreController {
return result;
}
//指挥中心----运行负荷率分析----处理水量详情
@AutoLog(value = "指挥中心-药剂趋势")
@ApiOperation(value="指挥中心-运行负荷率分析-处理水量详情", notes="指挥中心-运行负荷率分析-处理水量详情")
@GetMapping("/getCLSLXQ")
public Result<List<WaterTreatmentVO>> getCLSLXQ(String time){
Result<List<WaterTreatmentVO>> result = new Result<>();
//String departIds = "1818215093192753152,1818214519948836864,1818214145808531456";
List<WaterTreatmentVO> waterTrendVOList = commandCentreService.statisticsCLSLXQ(time, BaseContextHandler.getDeparts());
result.setResult(waterTrendVOList );
return result;
}
}
......
package com.skua.modules.algorithm.service;
import com.skua.modules.algorithm.vo.WaterTreatmentVO;
import com.skua.modules.report.entity.FReportItemv;
import com.skua.modules.report.vo.*;
......@@ -82,4 +83,11 @@ public interface ICommandCentreService {
* @return
*/
DepartDrugResult getYhTotal(String month);
/***
* 指挥中心----运行负荷率分析----处理水量详情
* @param time
* @return
*/
List<WaterTreatmentVO> statisticsCLSLXQ(String time ,String departIds);
}
......
package com.skua.modules.algorithm.service.impl;
import com.skua.common.report.ReportViewUtil;
import com.skua.core.context.SpringContextUtils;
import com.skua.core.util.ConvertUtils;
import com.skua.modules.algorithm.service.ICommandCentreService;
import com.skua.modules.algorithm.vo.WaterTreatmentVO;
import com.skua.modules.common.vo.DateVO;
import com.skua.modules.quartz.util.BaseUtil;
import com.skua.modules.report.entity.FReportItem;
import com.skua.modules.report.entity.FReportItemv;
import com.skua.modules.report.mapper.FReportItemMapper;
import com.skua.modules.report.vo.*;
import com.skua.modules.report.mapper.FReportItemvMapper;
import com.skua.tool.util.DateUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <pre>
......@@ -31,6 +40,9 @@ public class CommandCentreServiceImpl implements ICommandCentreService {
@Resource
private FReportItemMapper reportItemMapper;
String view2119 = "2119ecbf53a1d2d0708258ff67cfd9e1";// 水 COD TP TN NH3H
String view3a24 = "3a243d5715b9e1a3753c180872ca0df9";//能耗报表
/**
* 指挥中心---运行负荷率分析
* @param reportItemvParam
......@@ -146,6 +158,86 @@ public class CommandCentreServiceImpl implements ICommandCentreService {
return departDrugResult;
}
private JdbcTemplate getJdbcTemplate(){
JdbcTemplate masterDB = (JdbcTemplate) SpringContextUtils.getBean("master");
return masterDB;
}
/***
* 指挥中心----运行负荷率分析----处理水量详情
* @param time
* @return
*/
public List<WaterTreatmentVO> statisticsCLSLXQ(String time, String departIds){
List<WaterTreatmentVO> dateList = null;
DateVO dateVO = new DateVO(time);//转换后的时间参数
long differenceDay = DateUtils.differenceDay(dateVO.getNowMonthStartDate(), dateVO.getNowMonthEndDate());
String departIdssss = BaseUtil.quoteEach(departIds , ",");
System.out.println("departIds = "+departIds);
//String factorySql = "select fi.depart_id ,d.depart_name, fi.pro_scale*10000 'pro_scale' from sys_factory_info fi , sys_depart d where fi.depart_id = d.id and d.depart_type =1 and d.id in("+departIdssss+")";
String factorySql = "select group_concat(fi.depart_id) from sys_factory_info fi , sys_depart d where fi.depart_id = d.id and d.depart_type =1 and d.id in("+departIdssss+")";
//水厂部门编号集合
departIds =getJdbcTemplate().queryForObject(factorySql,String.class);
//月产水量
Map<String,String> cslMap = commonQueryCsl(departIds, dateVO.getNowMonthStartDate(),dateVO.getNowMonthEndDate());
String dataViewName2119 = ReportViewUtil.buildViewLike(view2119,"CSL", departIds, dateVO.getNowMonthStartDate(),dateVO.getNowMonthEndDate());
String sql = "select aaa.CSL 'csl' ,aaa.depart_id , d.depart_name, fi.pro_scale*10000 'pro_scale' from "+ dataViewName2119 +" aaa";
sql += " left join sys_factory_info fi on fi.depart_id = aaa.depart_id";
sql += " left join sys_depart d on d.id = aaa.depart_id";
sql += " order by aaa.CSL desc ";
dateList = getJdbcTemplate().query(sql,new BeanPropertyRowMapper<WaterTreatmentVO>(WaterTreatmentVO.class));
//环比:月产水量
Map<String,String> hbCslMap = commonQueryCsl(departIds, dateVO.getLastMonthStartTime(),dateVO.getLastMonthEndTime());
//同比:月产水量
Map<String,String> tbCslMap = commonQueryCsl(departIds, dateVO.getLastYearMonthStartTime(),dateVO.getLastYearMonthEndTime());
int index =1;
if(dateList != null ){
for(WaterTreatmentVO waterTreatmentVO : dateList){
waterTreatmentVO.setRank(index++);//设置排名
if(waterTreatmentVO.getCSL() != null ){
waterTreatmentVO.setDayCsl( waterTreatmentVO.getCSL() / differenceDay );
}
/* waterTreatmentVO.setRank( index++);//设置排名
if(cslMap.get(waterTreatmentVO.getDepartId()) != null ){
waterTreatmentVO.setCsl(Double.parseDouble(cslMap.get(waterTreatmentVO.getDepartId())) );
waterTreatmentVO.setDayCsl( waterTreatmentVO.getCsl() / differenceDay );
}*/
if(hbCslMap.get(waterTreatmentVO.getDepartId()) != null ){
waterTreatmentVO.setHbcsl(Double.parseDouble(hbCslMap.get(waterTreatmentVO.getDepartId())) );
}
if(tbCslMap.get(waterTreatmentVO.getDepartId()) != null ){
waterTreatmentVO.setTbcsl(Double.parseDouble(tbCslMap.get(waterTreatmentVO.getDepartId())) );
}
}
}
return dateList;
}
//通用csl查询,返回Map<部门编号,CSL出水量>
public Map<String,String> commonQueryCsl(String departIds ,String startTime ,String endTime){
Map<String,String> cslMap = new HashMap<>();
String dataViewName2119 = ReportViewUtil.buildViewLike(view2119,"CSL", departIds, startTime,endTime);
// System.out.println("dataViewName2119 ="+dataViewName2119 );
List<Map<String, Object>> dataMapList = getJdbcTemplate().queryForList(dataViewName2119);
if(dataMapList != null){
for(Map<String, Object> dataMap : dataMapList){
cslMap.put(ConvertUtils.getString(dataMap.get("depart_id")) ,ConvertUtils.getString(dataMap.get("CSL")));
}
}
return cslMap;
}
/**
* 同比
* @param month
......
package com.skua.modules.algorithm.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value="指挥中心:运行负荷率分析:处理水量详情", description="指挥中心:运行负荷率分析:处理水量详情)")
public class WaterTreatmentVO {
@ApiModelProperty(value = "厂站编号")
private String departId;
@ApiModelProperty(value = "厂站名称")
private String departName;
@ApiModelProperty(value = "设计规模")
private Double proScale;
@ApiModelProperty(value = "处理水量")
private Double CSL;
@ApiModelProperty(value = "环比:处理水量")
private Double hbcsl;
@ApiModelProperty(value = "同比:处理水量")
private Double tbcsl;
@ApiModelProperty(value = "日均处理水量")
private Double dayCsl;
@ApiModelProperty(value = "环比:处理水量比例")
private Double hbcslbl;
@ApiModelProperty(value = "同比:处理水量比例")
private Double tbcslbl;
@ApiModelProperty(value = "负荷率")
private Double fhl;
@ApiModelProperty(value = "排名")
private Integer rank;
public Double getFhl() {
if(this.getCSL() != null && this.getProScale() != null && this.getProScale().doubleValue() > 0 ){
fhl = this.getCSL() / this.getProScale();
}
return fhl;
}
public Double getHbcslbl() {
if(this.getCSL() != null && this.getHbcsl() != null && this.getHbcsl().doubleValue() > 0){
hbcslbl = (this.getCSL() - this.getHbcsl()) * 100 / this.getHbcsl() ;
}
return hbcslbl;
}
public Double getTbcslbl() {
if(this.getCSL() != null && this.getTbcsl() != null && this.getTbcsl().doubleValue() > 0){
tbcslbl = (this.getCSL() - this.getTbcsl())*100 / this.getTbcsl() ;
}
return tbcslbl;
}
}
......@@ -3,6 +3,7 @@ package com.skua.modules.equipment.service.impl;
import com.google.common.collect.Maps;
import com.skua.common.report.ReportViewUtil;
import com.skua.core.context.SpringContextUtils;
import com.skua.core.util.ConvertUtils;
import com.skua.modules.common.vo.DateVO;
import com.skua.modules.equipment.dto.*;
import com.skua.modules.equipment.mapper.ComprehensiveSupervisionMapper;
......@@ -36,6 +37,14 @@ public class DrugConsumptionAnalusisServiceImpl implements IDrugConsumptionAnaly
JdbcTemplate masterDB = (JdbcTemplate)SpringContextUtils.getBean("master");
return masterDB;
}
private Map<String,Object> queryForMap(String sql){
List<Map<String, Object>> mapList = getJdbcTemplate().queryForList(sql);
if(mapList != null && !mapList.isEmpty()){
return mapList.get(0);
}else{
return new HashMap<>();
}
}
//数据展示
public DrugConsumptionDisplayVO dataDisplay(String time, String departId){
DrugConsumptionDisplayVO displayVO = null;
......@@ -66,7 +75,7 @@ public class DrugConsumptionAnalusisServiceImpl implements IDrugConsumptionAnaly
sql.append(" from "+dataViewName3a24+" aaa group by DATE_FORMAT(aaa.time,'%Y-%m') ) ddd ") ;
sql.append(" where ccc.time = ddd.time order by ( ddd.YH /ccc.CSL ) asc limit 1 ") ;
Map<String, Object> dsyhMap = getJdbcTemplate().queryForMap(sql.toString());
Map<String, Object> dsyhMap = queryForMap(sql.toString());// getJdbcTemplate().queryForMap(sql.toString());
if(dsyhMap != null ){
displayVO.setLszddsyh( dsyhMap.get("dsyh")+"" );
displayVO.setLszddsyhyf( dsyhMap.get("time")+"" );
......@@ -141,9 +150,10 @@ public class DrugConsumptionAnalusisServiceImpl implements IDrugConsumptionAnaly
if(dataList != null ){
for (Map<String,Object> map : dataList){
chartVO = new DrugConsumptionTrendChartVO();
chartVO.setTime( map.get("time")+"");
if(map.get("dsyh") != null )chartVO.setDsyh( map.get("dsyh")+"");
if(map.get("YH") != null ) chartVO.setZyh( Double.parseDouble(map.get("YH")+"") );
chartVO.setTime( ConvertUtils.getString( map.get("time")) );
chartVO.setDsyh( ConvertUtils.getString(map.get("dsyh") ));
chartVO.setZyh( ConvertUtils.getDouble(map.get("YH"),0d) );
chartVOMap.put( chartVO.getTime(),chartVO );
}
}
......@@ -171,7 +181,7 @@ public class DrugConsumptionAnalusisServiceImpl implements IDrugConsumptionAnaly
List<Map<String, Object>> dataMapList = getJdbcTemplate().queryForList(dataViewName2119);
if(dataMapList != null ){
for(Map<String, Object> dataMap : dataMapList){
if( dataMap.get("CSL") != null) nowMonthCSL = Double.parseDouble(dataMap.get("CSL") +"");
nowMonthCSL = ConvertUtils.getDouble(dataMap.get("CSL") ,0,2);
}
}
......@@ -181,7 +191,7 @@ public class DrugConsumptionAnalusisServiceImpl implements IDrugConsumptionAnaly
dataMapList = getJdbcTemplate().queryForList(dataViewName2119);
if(dataMapList != null ){
for(Map<String, Object> dataMap : dataMapList){
if( dataMap.get("CSL") != null) hbsyCsl = Double.parseDouble(dataMap.get("CSL") +"");
hbsyCsl = ConvertUtils.getDouble(dataMap.get("CSL") ,0,2);
}
}
//同比处理水量
......@@ -190,7 +200,7 @@ public class DrugConsumptionAnalusisServiceImpl implements IDrugConsumptionAnaly
dataMapList = getJdbcTemplate().queryForList(dataViewName2119);
if(dataMapList != null ){
for(Map<String, Object> dataMap : dataMapList){
if( dataMap.get("CSL") != null) tbqnCsl = Double.parseDouble(dataMap.get("CSL") +"");
tbqnCsl = ConvertUtils.getDouble(dataMap.get("CSL") ,0,2);
}
}
......@@ -199,13 +209,13 @@ public class DrugConsumptionAnalusisServiceImpl implements IDrugConsumptionAnaly
//本月药剂 总药耗
String dataViewName3a24 = ReportViewUtil.buildViewLike(view3a24,fileds, departId, dateVO.getNowMonthStartDate(),dateVO.getNowMonthEndDate());
Map<String, Object> nowMonthDataMap = getJdbcTemplate().queryForMap(dataViewName3a24);
Map<String, Object> nowMonthDataMap =queryForMap(dataViewName3a24);// getJdbcTemplate().queryForMap(dataViewName3a24);
//环比:上月药剂 总药耗
dataViewName3a24 = ReportViewUtil.buildViewLike(view3a24,fileds, departId, dateVO.getLastMonthStartTime(),dateVO.getLastMonthEndTime());
Map<String, Object> lastMonthDataMap = getJdbcTemplate().queryForMap(dataViewName3a24);
Map<String, Object> lastMonthDataMap = queryForMap(dataViewName3a24);//getJdbcTemplate().queryForMap(dataViewName3a24);
//同比:去年本月药剂: 总药耗
dataViewName3a24 = ReportViewUtil.buildViewLike(view3a24,fileds, departId, dateVO.getLastYearMonthStartTime(),dateVO.getLastYearMonthEndTime());
Map<String, Object> lastYearMonthDataMap = getJdbcTemplate().queryForMap(dataViewName3a24);
Map<String, Object> lastYearMonthDataMap = queryForMap(dataViewName3a24);//getJdbcTemplate().queryForMap(dataViewName3a24);
String filedsSql = "select item_code ,item_alias from f_report_item where item_code in ('PAMZ','PAMF','PAMRJ','SCLPAMZ','SCLPAMF','NACLO','PACGT','PACYT','FESO4G','FESO4Y','H2O2','CH3COOH','SH','FECL3','HXT','PFS','CH3COONA','GXCLJ','YWL','RYXNJ','FHTY') ";
List<Map<String, Object>> filedsDataList = getJdbcTemplate().queryForList(filedsSql);
......@@ -220,13 +230,14 @@ public class DrugConsumptionAnalusisServiceImpl implements IDrugConsumptionAnaly
//整理数据
if(filedsDataList != null ){
for( Map<String,Object> filedsMap : filedsDataList){
drugCode = filedsMap.get("item_code")+"";
drugCode = ConvertUtils.getString(filedsMap.get("item_code") );
//Double CSL, Double tbqnCsl, Double hbsyCsl, Double zyh, Double hbsyzyh, Double tbqnzyh
zyh = nowMonthDataMap.get(drugCode) != null ? Double.parseDouble(nowMonthDataMap.get(drugCode) +""):null;
hbsyzyh = lastMonthDataMap.get(drugCode) != null ? Double.parseDouble(lastMonthDataMap.get(drugCode) +""):null;
tbqnzyh = lastYearMonthDataMap.get(drugCode) != null ? Double.parseDouble(lastYearMonthDataMap.get(drugCode) +""):null;
zyh = ConvertUtils.getDouble(nowMonthDataMap.get(drugCode),0,2);
hbsyzyh = ConvertUtils.getDouble(lastMonthDataMap.get(drugCode),0,2);
tbqnzyh = ConvertUtils.getDouble(lastYearMonthDataMap.get(drugCode),0,2);
displayVO = new DrugConsumptionDisplayVO(nowMonthCSL,tbqnCsl,hbsyCsl,zyh ,hbsyzyh ,tbqnzyh );
displayVO.setDrugCode(drugCode);displayVO.setDrugName(filedsMap.get("item_alias")+"");
displayVO.setDrugCode(drugCode);displayVO.setDrugName(ConvertUtils.getString(filedsMap.get("item_alias")));
drugConsumptionDisplayList.add( displayVO );
}
}
......@@ -241,9 +252,7 @@ public class DrugConsumptionAnalusisServiceImpl implements IDrugConsumptionAnaly
DrugConsumptionDisplayVO displayVO = null;
if(filedsDataList != null ){
for( Map<String,Object> filedsMap : filedsDataList){
displayVO = new DrugConsumptionDisplayVO();
if(filedsMap.get("item_code") != null ) displayVO.setDrugCode(filedsMap.get("item_code")+"");
if(filedsMap.get("item_alias") != null ) displayVO.setDrugName(filedsMap.get("item_alias")+"");
displayVO = new DrugConsumptionDisplayVO(ConvertUtils.getString(filedsMap.get("item_code")) ,ConvertUtils.getString( filedsMap.get("item_alias") ));
drugConsumptionDisplayList.add( displayVO );
}
}
......@@ -265,7 +274,7 @@ public class DrugConsumptionAnalusisServiceImpl implements IDrugConsumptionAnaly
List<Map<String, Object>> dataList = getJdbcTemplate().queryForList(sql);
if(dataList != null){
for(Map<String,Object> map : dataList){
jsssDataMap.put(map.get("time")+"",map.get("JSSS")+"");
jsssDataMap.put(ConvertUtils.getString(map.get("time")),ConvertUtils.getString(map.get("JSSS")));
}
}
......@@ -275,11 +284,12 @@ public class DrugConsumptionAnalusisServiceImpl implements IDrugConsumptionAnaly
CorrelationAnalysisVO correlationAnalysisVO = null;
if(dataList != null){
for(Map<String,Object> map : dataList){
correlationAnalysisVO = new CorrelationAnalysisVO();
if(map.get("time") != null ) correlationAnalysisVO.setTime(map.get("time") +"");
//String time, String zyh, String dnhl, String wnl, String wnhsl
correlationAnalysisVO = new CorrelationAnalysisVO(ConvertUtils.getString(map.get("time")),ConvertUtils.getString(map.get("zyh")),ConvertUtils.getString(map.get("wnl")),ConvertUtils.getString(map.get("wnhsl")));
/* if(map.get("time") != null ) correlationAnalysisVO.setTime(map.get("time") +"");
if(map.get("zyh") != null ) correlationAnalysisVO.setZyh(map.get("zyh") +"");
if(map.get("wnl") != null ) correlationAnalysisVO.setWnl(map.get("wnl") +"");
if(map.get("wnhsl") != null ) correlationAnalysisVO.setWnhsl(map.get("wnhsl") +"");
if(map.get("wnhsl") != null ) correlationAnalysisVO.setWnhsl(map.get("wnhsl") +"");*/
zyhMap.put(map.get("time").toString(),correlationAnalysisVO);
}
}
......@@ -314,10 +324,7 @@ public class DrugConsumptionAnalusisServiceImpl implements IDrugConsumptionAnaly
List<Map<String, Object>> mapList = getJdbcTemplate().queryForList(sql2.toString());
String YH = null;
for(Map<String,Object> map : mapList ){
if(map.get("YH") != null ){
YH = map.get("YH").toString();
}
YH = ConvertUtils.getString(map.get("YH"));
}
return YH!=null ? Double.parseDouble(YH) : null;
}
......@@ -327,9 +334,7 @@ public class DrugConsumptionAnalusisServiceImpl implements IDrugConsumptionAnaly
List<Map<String, Object>> mapList = getJdbcTemplate().queryForList(dataViewName2119);
String csl = null;
for(Map<String,Object> map : mapList ){
if(map.get("CSL") != null ){
csl = map.get("CSL").toString();
}
csl = ConvertUtils.getString(map.get("CSL"));
}
return csl!=null ? Double.parseDouble(csl) : null;
}
......@@ -346,7 +351,7 @@ public class DrugConsumptionAnalusisServiceImpl implements IDrugConsumptionAnaly
* @return
*/
private String getMonthBytime(int month,String time) {
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM");
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
Calendar calendar = Calendar.getInstance();
try {
calendar.setTime(format.parse(time));
......
......@@ -33,6 +33,16 @@ public class CorrelationAnalysisVO {
@ApiModelProperty(value = "污泥含水量")
private String wnhsl;
public CorrelationAnalysisVO() {
}
public CorrelationAnalysisVO(String time, String zyh, String wnl, String wnhsl) {
this.time = time;
this.zyh = zyh;
this.wnl = wnl;
this.wnhsl = wnhsl;
}
////吨泥耗量=絮凝剂总量/干污泥总量
//干污泥量=产泥量*(1-污泥含水率)
public String getDnhl() {
......
......@@ -74,6 +74,11 @@ public class DrugConsumptionDisplayVO {
public DrugConsumptionDisplayVO() {
}
public DrugConsumptionDisplayVO(String drugCode, String drugName) {
this.drugCode = drugCode;
this.drugName = drugName;
}
public DrugConsumptionDisplayVO(Double CSL, Double tbqnCsl, Double hbsyCsl, Double zyh, Double hbsyzyh, Double tbqnzyh) {
this.CSL = CSL;
this.tbqnCsl = tbqnCsl;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!