|
@@ -4,22 +4,24 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.gyee.common.model.StringUtils;
|
|
|
import com.gyee.common.util.DateUtils;
|
|
|
import com.gyee.common.util.DoubleUtils;
|
|
|
+import com.gyee.common.vo.specific.SpecificCenterVo;
|
|
|
import com.gyee.common.vo.specific.SpecificTargetVo;
|
|
|
+import com.gyee.common.vo.specific.SpecificTopVo;
|
|
|
import com.gyee.runeconomy.init.CacheContext;
|
|
|
+import com.gyee.runeconomy.model.auto.ProBasicPowerstation;
|
|
|
import com.gyee.runeconomy.model.auto.ProEconPowerstationInfoDay1;
|
|
|
import com.gyee.runeconomy.model.auto.ProEconPowerstationInfoDay4;
|
|
|
import com.gyee.runeconomy.model.auto.ProEconPowerstationInfoDay5;
|
|
|
import com.gyee.runeconomy.service.auto.IProEconPowerstationInfoDay1Service;
|
|
|
import com.gyee.runeconomy.service.auto.IProEconPowerstationInfoDay4Service;
|
|
|
import com.gyee.runeconomy.service.auto.IProEconPowerstationInfoDay5Service;
|
|
|
+import com.gyee.runeconomy.service.bmk.BenchmarkingService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.text.ParseException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/*
|
|
|
@author 谢生杰
|
|
@@ -35,6 +37,566 @@ public class SpecificService {
|
|
|
private IProEconPowerstationInfoDay4Service proEconPowerstationInfoDay4Service;
|
|
|
@Resource
|
|
|
private IProEconPowerstationInfoDay5Service proEconPowerstationInfoDay5Service;
|
|
|
+ @Resource
|
|
|
+ private BenchmarkingService benchmarkingService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取专题分析上面部分
|
|
|
+ * @param yearmonth
|
|
|
+ * @return
|
|
|
+ * @throws ParseException
|
|
|
+ */
|
|
|
+ public List<SpecificTopVo> maintoplist(String companys,String type,String yearmonth) throws ParseException {
|
|
|
+ List<SpecificTopVo> resultList = new ArrayList<>();
|
|
|
+ Date date = DateUtils.parseDate(yearmonth+"-01");
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
+ c.setTime(date);
|
|
|
+ Integer year = c.get(Calendar.YEAR);
|
|
|
+ Integer month = c.get(Calendar.MONTH)+1;
|
|
|
+ SpecificTopVo dqvo = new SpecificTopVo();
|
|
|
+ dqvo.setType("本期");
|
|
|
+ setDySpecificinfodays(companys,type,yearmonth,dqvo);
|
|
|
+ setDnSpecificinfodays(companys,type,yearmonth,dqvo);
|
|
|
+ resultList.add(dqvo);
|
|
|
+ SpecificTopVo tqvo = new SpecificTopVo();
|
|
|
+ tqvo.setType("同期");
|
|
|
+ setTySpecificinfodays(companys,type,yearmonth,tqvo);
|
|
|
+ setTnSpecificinfodays(companys,type,yearmonth,tqvo);
|
|
|
+ resultList.add(tqvo);
|
|
|
+ SpecificTopVo bjvo = new SpecificTopVo();
|
|
|
+ bjvo.setType("比较");
|
|
|
+ setBjVo(dqvo,tqvo,bjvo);
|
|
|
+ resultList.add(bjvo);
|
|
|
+ return resultList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 比较当前,同期值,给比较值赋值
|
|
|
+ * @param dqvo
|
|
|
+ * @param tqvo
|
|
|
+ * @param bjvo
|
|
|
+ */
|
|
|
+ private void setBjVo(SpecificTopVo dqvo, SpecificTopVo tqvo, SpecificTopVo bjvo) {
|
|
|
+ bjvo.setYfnlyl(dqvo.getYfnlyl()>=tqvo.getYfnlyl() ? 1.0 : 2.0);
|
|
|
+ bjvo.setYwhssl(dqvo.getYwhssl()>=tqvo.getYwhssl()?1.0:2.0);
|
|
|
+ bjvo.setYgzssl(dqvo.getYgzssl()>=tqvo.getYgzssl()?1.0:2.0);
|
|
|
+ bjvo.setYxdssl(dqvo.getYxdssl()>=tqvo.getYxdssl()?1.0:2.0);
|
|
|
+ bjvo.setYxnssl(dqvo.getYxnssl()>=tqvo.getYxnssl()?1.0:2.0);
|
|
|
+ bjvo.setYslssl(dqvo.getYslssl()>=tqvo.getYslssl()?1.0:2.0);
|
|
|
+ bjvo.setNfnlyl(dqvo.getNfnlyl()>=tqvo.getNfnlyl() ? 1.0 : 2.0);
|
|
|
+ bjvo.setNwhssl(dqvo.getNwhssl()>=tqvo.getNwhssl()?1.0:2.0);
|
|
|
+ bjvo.setNgzssl(dqvo.getNgzssl()>=tqvo.getNgzssl()?1.0:2.0);
|
|
|
+ bjvo.setNxdssl(dqvo.getNxdssl()>=tqvo.getNxdssl()?1.0:2.0);
|
|
|
+ bjvo.setNxnssl(dqvo.getNxnssl()>=tqvo.getNxnssl()?1.0:2.0);
|
|
|
+ bjvo.setNslssl(dqvo.getNslssl()>=tqvo.getNslssl()?1.0:2.0);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取当月专题分析上面数据
|
|
|
+ * @param companys
|
|
|
+ * @param type
|
|
|
+ * @param yearmonth
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private void setDySpecificinfodays(String companys,String type,String yearmonth,SpecificTopVo dqvo) {
|
|
|
+ QueryWrapper<ProEconPowerstationInfoDay1> qw = new QueryWrapper<>();
|
|
|
+ qw.select("max(yllfdl) as yllfdl,max(yfdl) as yfdl,max(ygzssdl) as ygzssdl,max(ycnslgzssdl) as ycnslgzssdl,max(yjxssdl) as yjxssdl,max(ycnsljxssdl) ycnsljxssdl,max(ydjssdl) ydjssdl,max(yqxjclssdl) as yqxjclssdl,max(ysdtjssdl) as ysdtjssdl,max(yxnssdl) as yxnssdl,max(yxdtjssdl) as yxdtjssdl,max(yxdjclssdl) as yxdjclssdl,max(ycwsldwssdl) ycwsldwssdl,max(ycwsltqssdl) ycwsltqssdl");
|
|
|
+ qw.eq("foreign_key_id",companys+type);
|
|
|
+ qw.eq("to_char(record_date,'yyyy-MM')",yearmonth);
|
|
|
+ qw.groupBy("to_char(record_date,'yyyy-MM')");
|
|
|
+ List<ProEconPowerstationInfoDay1> monthList = proEconPowerstationInfoDay1Service.list(qw);
|
|
|
+ if (StringUtils.isNotEmpty(monthList)){
|
|
|
+ Optional<ProEconPowerstationInfoDay1> monthFirst = monthList.stream().findFirst();
|
|
|
+ if (monthFirst.isPresent()){
|
|
|
+ ProEconPowerstationInfoDay1 monthSpecific = monthFirst.get();
|
|
|
+ dqvo.setYllfdl(DoubleUtils.getRoundingNum(monthSpecific.getYllfdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setYsjfdl(DoubleUtils.getRoundingNum(monthSpecific.getYfdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setYwhssdl(DoubleUtils.getRoundingNum(monthSpecific.getYjxssdl().doubleValue()/10000+monthSpecific.getYcnsljxssdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setYgzssdl(DoubleUtils.getRoundingNum(monthSpecific.getYgzssdl().doubleValue()/10000+monthSpecific.getYcnslgzssdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setYxdssdl(DoubleUtils.getRoundingNum(monthSpecific.getYxnssdl().doubleValue()/10000+monthSpecific.getYxdjclssdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setYxnssdl(DoubleUtils.getRoundingNum(monthSpecific.getYdjssdl().doubleValue()/10000+monthSpecific.getYqxjclssdl().doubleValue()/10000+monthSpecific.getYxnssdl().doubleValue()/10000+monthSpecific.getYsdtjssdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setYslssdl(DoubleUtils.getRoundingNum(monthSpecific.getYcwsldwssdl().doubleValue()/10000+monthSpecific.getYcwsltqssdl().doubleValue()/10000,2));
|
|
|
+ if (dqvo.getYllfdl()!=0){
|
|
|
+ dqvo.setYfnlyl(DoubleUtils.getRoundingNum(dqvo.getYsjfdl()/dqvo.getYllfdl()*100,2));
|
|
|
+ dqvo.setYwhssl(DoubleUtils.getRoundingNum(dqvo.getYwhssdl()/dqvo.getYllfdl()*100,2));
|
|
|
+ dqvo.setYgzssl(DoubleUtils.getRoundingNum(dqvo.getYgzssdl()/dqvo.getYllfdl()*100,2));
|
|
|
+ dqvo.setYxdssl(DoubleUtils.getRoundingNum(dqvo.getYxdssdl()/dqvo.getYllfdl()*100,2));
|
|
|
+ dqvo.setYxnssl(DoubleUtils.getRoundingNum(dqvo.getYxnssdl()/dqvo.getYllfdl()*100,2));
|
|
|
+ dqvo.setYslssl(DoubleUtils.getRoundingNum(dqvo.getYslssdl()/dqvo.getYllfdl()*100,2));
|
|
|
+ }else{
|
|
|
+ dqvo.setYfnlyl(0.0);
|
|
|
+ dqvo.setYwhssl(0.0);
|
|
|
+ dqvo.setYgzssl(0.0);
|
|
|
+ dqvo.setYxdssl(0.0);
|
|
|
+ dqvo.setYxnssl(0.0);
|
|
|
+ dqvo.setYslssl(0.0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ dqvo.setYllfdl(0.0);
|
|
|
+ dqvo.setYsjfdl(0.0);
|
|
|
+ dqvo.setYwhssdl(0.0);
|
|
|
+ dqvo.setYgzssdl(0.0);
|
|
|
+ dqvo.setYxdssdl(0.0);
|
|
|
+ dqvo.setYxnssdl(0.0);
|
|
|
+ dqvo.setYslssdl(0.0);
|
|
|
+ dqvo.setYfnlyl(0.0);
|
|
|
+ dqvo.setYwhssl(0.0);
|
|
|
+ dqvo.setYgzssl(0.0);
|
|
|
+ dqvo.setYxdssl(0.0);
|
|
|
+ dqvo.setYxnssl(0.0);
|
|
|
+ dqvo.setYslssl(0.0);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取月同期专题分析上面数据
|
|
|
+ * @param companys
|
|
|
+ * @param type
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private void setTySpecificinfodays(String companys,String type,String yearmonth,SpecificTopVo dqvo) {
|
|
|
+ String yearString = yearmonth.split("-")[0];
|
|
|
+ String year = String.valueOf(Integer.parseInt(yearString) - 1);
|
|
|
+ String yearMonth = year+"-"+yearmonth.split("-")[1];
|
|
|
+ QueryWrapper<ProEconPowerstationInfoDay1> qw = new QueryWrapper<>();
|
|
|
+ qw.select("max(yllfdl) as yllfdl,max(yfdl) as yfdl,max(ygzssdl) as ygzssdl,max(ycnslgzssdl) as ycnslgzssdl,max(yjxssdl) as yjxssdl,max(ycnsljxssdl) ycnsljxssdl,max(ydjssdl) ydjssdl,max(yqxjclssdl) as yqxjclssdl,max(ysdtjssdl) as ysdtjssdl,max(yxnssdl) as yxnssdl,max(yxdtjssdl) as yxdtjssdl,max(yxdjclssdl) as yxdjclssdl,max(ycwsldwssdl) ycwsldwssdl,max(ycwsltqssdl) ycwsltqssdl");
|
|
|
+ qw.eq("foreign_key_id",companys+type);
|
|
|
+ qw.eq("to_char(record_date,'yyyy-MM')",yearMonth);
|
|
|
+ qw.groupBy("to_char(record_date,'yyyy-MM')");
|
|
|
+ List<ProEconPowerstationInfoDay1> monthList = proEconPowerstationInfoDay1Service.list(qw);
|
|
|
+ Optional<ProEconPowerstationInfoDay1> monthFirst = monthList.stream().findFirst();
|
|
|
+ if (monthFirst.isPresent()){
|
|
|
+ ProEconPowerstationInfoDay1 monthSpecific = monthFirst.get();
|
|
|
+ dqvo.setYllfdl(DoubleUtils.getRoundingNum(monthSpecific.getYllfdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setYsjfdl(DoubleUtils.getRoundingNum(monthSpecific.getYfdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setYwhssdl(DoubleUtils.getRoundingNum(monthSpecific.getYjxssdl().doubleValue()/10000+monthSpecific.getYcnsljxssdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setYgzssdl(DoubleUtils.getRoundingNum(monthSpecific.getYgzssdl().doubleValue()/10000+monthSpecific.getYcnslgzssdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setYxdssdl(DoubleUtils.getRoundingNum(monthSpecific.getYxnssdl().doubleValue()/10000+monthSpecific.getYxdjclssdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setYxnssdl(DoubleUtils.getRoundingNum(monthSpecific.getYdjssdl().doubleValue()/10000+monthSpecific.getYqxjclssdl().doubleValue()/10000+monthSpecific.getYxnssdl().doubleValue()/10000+monthSpecific.getYsdtjssdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setYslssdl(DoubleUtils.getRoundingNum(monthSpecific.getYcwsldwssdl().doubleValue()/10000+monthSpecific.getYcwsltqssdl().doubleValue()/10000,2));
|
|
|
+ if (dqvo.getYllfdl()!=0){
|
|
|
+ dqvo.setYfnlyl(DoubleUtils.getRoundingNum(dqvo.getYsjfdl()/dqvo.getYllfdl()*100,2));
|
|
|
+ dqvo.setYwhssl(DoubleUtils.getRoundingNum(dqvo.getYwhssdl()/dqvo.getYllfdl()*100,2));
|
|
|
+ dqvo.setYgzssl(DoubleUtils.getRoundingNum(dqvo.getYgzssdl()/dqvo.getYllfdl()*100,2));
|
|
|
+ dqvo.setYxdssl(DoubleUtils.getRoundingNum(dqvo.getYxdssdl()/dqvo.getYllfdl()*100,2));
|
|
|
+ dqvo.setYxnssl(DoubleUtils.getRoundingNum(dqvo.getYxnssdl()/dqvo.getYllfdl()*100,2));
|
|
|
+ dqvo.setYslssl(DoubleUtils.getRoundingNum(dqvo.getYslssdl()/dqvo.getYllfdl()*100,2));
|
|
|
+ }else {
|
|
|
+ dqvo.setYfnlyl(0.0);
|
|
|
+ dqvo.setYwhssl(0.0);
|
|
|
+ dqvo.setYgzssl(0.0);
|
|
|
+ dqvo.setYxdssl(0.0);
|
|
|
+ dqvo.setYxnssl(0.0);
|
|
|
+ dqvo.setYslssl(0.0);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ dqvo.setYllfdl(0.0);
|
|
|
+ dqvo.setYsjfdl(0.0);
|
|
|
+ dqvo.setYwhssdl(0.0);
|
|
|
+ dqvo.setYgzssdl(0.0);
|
|
|
+ dqvo.setYxdssdl(0.0);
|
|
|
+ dqvo.setYxnssdl(0.0);
|
|
|
+ dqvo.setYslssdl(0.0);
|
|
|
+ dqvo.setYfnlyl(0.0);
|
|
|
+ dqvo.setYwhssl(0.0);
|
|
|
+ dqvo.setYgzssl(0.0);
|
|
|
+ dqvo.setYxdssl(0.0);
|
|
|
+ dqvo.setYxnssl(0.0);
|
|
|
+ dqvo.setYslssl(0.0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取当年专题分析上面数据
|
|
|
+ * @param companys
|
|
|
+ * @param type
|
|
|
+ * @param yearmonth
|
|
|
+ * @param dqvo
|
|
|
+ */
|
|
|
+ private void setDnSpecificinfodays(String companys,String type,String yearmonth,SpecificTopVo dqvo) {
|
|
|
+ QueryWrapper<ProEconPowerstationInfoDay1> qw = new QueryWrapper<>();
|
|
|
+ qw.select("max(nllfdl) as nllfdl,max(nfdl) as nfdl,max(ngzssdl) as ngzssdl,max(ncnslgzssdl) as ncnslgzssdl,max(njxssdl) as njxssdl,max(ncnsljxssdl) ncnsljxssdl,max(ndjssdl) ndjssdl,max(nqxjclssdl) as nqxjclssdl,max(nsdtjssdl) as nsdtjssdl,max(nxnssdl) as nxnssdl,max(nxdtjssdl) as nxdtjssdl,max(nxdjclssdl) as nxdjclssdl,max(ncwsldwssdl) ncwsldwssdl,max(ncwsltqssdl) ncwsltqssdl");
|
|
|
+ qw.eq("foreign_key_id",companys+type);
|
|
|
+ qw.eq("to_char(record_date,'yyyy')",yearmonth.split("-")[0]);
|
|
|
+ qw.groupBy("to_char(record_date,'yyyy')");
|
|
|
+ List<ProEconPowerstationInfoDay1> yearList = proEconPowerstationInfoDay1Service.list(qw);
|
|
|
+ if (StringUtils.isNotEmpty(yearList)){
|
|
|
+ Optional<ProEconPowerstationInfoDay1> yearFirsts = yearList.stream().findFirst();
|
|
|
+ if (yearFirsts.isPresent()){
|
|
|
+ ProEconPowerstationInfoDay1 yearSpecific = yearFirsts.get();
|
|
|
+ dqvo.setNllfdl(DoubleUtils.getRoundingNum(yearSpecific.getNllfdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setNsjfdl(DoubleUtils.getRoundingNum(yearSpecific.getNfdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setNwhssdl(DoubleUtils.getRoundingNum(yearSpecific.getNjxssdl().doubleValue()/10000+yearSpecific.getNcnsljxssdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setNgzssdl(DoubleUtils.getRoundingNum(yearSpecific.getNgzssdl().doubleValue()/10000+yearSpecific.getNcnslgzssdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setNxdssdl(DoubleUtils.getRoundingNum(yearSpecific.getNxnssdl().doubleValue()/10000+yearSpecific.getNxdjclssdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setNxnssdl(DoubleUtils.getRoundingNum(yearSpecific.getNdjssdl().doubleValue()/10000+yearSpecific.getNqxjclssdl().doubleValue()/10000+yearSpecific.getNxnssdl().doubleValue()/10000+yearSpecific.getNsdtjssdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setNslssdl(DoubleUtils.getRoundingNum(yearSpecific.getNcwsldwssdl().doubleValue()/10000+yearSpecific.getNcwsltqssdl().doubleValue()/10000,2));
|
|
|
+ if (dqvo.getYllfdl()!=0){
|
|
|
+ dqvo.setNfnlyl(DoubleUtils.getRoundingNum(dqvo.getNsjfdl()/dqvo.getNllfdl()*100,2));
|
|
|
+ dqvo.setNwhssl(DoubleUtils.getRoundingNum(dqvo.getNwhssdl()/dqvo.getNllfdl()*100,2));
|
|
|
+ dqvo.setNgzssl(DoubleUtils.getRoundingNum(dqvo.getNgzssdl()/dqvo.getNllfdl()*100,2));
|
|
|
+ dqvo.setNxdssl(DoubleUtils.getRoundingNum(dqvo.getNxdssdl()/dqvo.getNllfdl()*100,2));
|
|
|
+ dqvo.setNxnssl(DoubleUtils.getRoundingNum(dqvo.getNxnssdl()/dqvo.getNllfdl()*100,2));
|
|
|
+ dqvo.setNslssl(DoubleUtils.getRoundingNum(dqvo.getNslssdl()/dqvo.getNllfdl()*100,2));
|
|
|
+ }else {
|
|
|
+ dqvo.setNfnlyl(0.0);
|
|
|
+ dqvo.setNwhssl(0.0);
|
|
|
+ dqvo.setNgzssl(0.0);
|
|
|
+ dqvo.setNxdssl(0.0);
|
|
|
+ dqvo.setNxnssl(0.0);
|
|
|
+ dqvo.setNslssl(0.0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ dqvo.setNllfdl(0.0);
|
|
|
+ dqvo.setNsjfdl(0.0);
|
|
|
+ dqvo.setNwhssdl(0.0);
|
|
|
+ dqvo.setNgzssdl(0.0);
|
|
|
+ dqvo.setNxdssdl(0.0);
|
|
|
+ dqvo.setNxnssdl(0.0);
|
|
|
+ dqvo.setNslssdl(0.0);
|
|
|
+ dqvo.setNfnlyl(0.0);
|
|
|
+ dqvo.setNwhssl(0.0);
|
|
|
+ dqvo.setNgzssl(0.0);
|
|
|
+ dqvo.setNxdssl(0.0);
|
|
|
+ dqvo.setNxnssl(0.0);
|
|
|
+ dqvo.setNslssl(0.0);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取年同期专题分析上面数据
|
|
|
+ * @param companys
|
|
|
+ * @param dqvo
|
|
|
+ */
|
|
|
+ private void setTnSpecificinfodays(String companys,String type,String yearmonth,SpecificTopVo dqvo) throws ParseException {
|
|
|
+ String yearString = yearmonth.split("-")[0];
|
|
|
+ String year = String.valueOf(Integer.parseInt(yearString) - 1);
|
|
|
+ QueryWrapper<ProEconPowerstationInfoDay1> qw = new QueryWrapper<>();
|
|
|
+ qw.select("max(nllfdl) as nllfdl,max(nfdl) as nfdl,max(ngzssdl) as ngzssdl,max(ncnslgzssdl) as ncnslgzssdl,max(njxssdl) as njxssdl,max(ncnsljxssdl) ncnsljxssdl,max(ndjssdl) ndjssdl,max(nqxjclssdl) as nqxjclssdl,max(nsdtjssdl) as nsdtjssdl,max(nxnssdl) as nxnssdl,max(nxdtjssdl) as nxdtjssdl,max(nxdjclssdl) as nxdjclssdl,max(ncwsldwssdl) ncwsldwssdl,max(ncwsltqssdl) ncwsltqssdl");
|
|
|
+ qw.eq("foreign_key_id",companys+type);
|
|
|
+ qw.eq("to_char(record_date,'yyyy')",year);
|
|
|
+ qw.groupBy("to_char(record_date,'yyyy')");
|
|
|
+ List<ProEconPowerstationInfoDay1> yearList = proEconPowerstationInfoDay1Service.list(qw);
|
|
|
+
|
|
|
+ Optional<ProEconPowerstationInfoDay1> yearFirsts = yearList.stream().findFirst();
|
|
|
+ if (yearFirsts.isPresent()){
|
|
|
+ ProEconPowerstationInfoDay1 yearSpecific = yearFirsts.get();
|
|
|
+ dqvo.setNllfdl(DoubleUtils.getRoundingNum(yearSpecific.getNllfdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setNsjfdl(DoubleUtils.getRoundingNum(yearSpecific.getNfdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setNwhssdl(DoubleUtils.getRoundingNum(yearSpecific.getNjxssdl().doubleValue()/10000+yearSpecific.getNcnsljxssdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setNgzssdl(DoubleUtils.getRoundingNum(yearSpecific.getNgzssdl().doubleValue()/10000+yearSpecific.getNcnslgzssdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setNxdssdl(DoubleUtils.getRoundingNum(yearSpecific.getNxnssdl().doubleValue()/10000+yearSpecific.getNxdjclssdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setNxnssdl(DoubleUtils.getRoundingNum(yearSpecific.getNdjssdl().doubleValue()/10000+yearSpecific.getNqxjclssdl().doubleValue()/10000+yearSpecific.getNxnssdl().doubleValue()/10000+yearSpecific.getNsdtjssdl().doubleValue()/10000,2));
|
|
|
+ dqvo.setNslssdl(DoubleUtils.getRoundingNum(yearSpecific.getNcwsldwssdl().doubleValue()/10000+yearSpecific.getNcwsltqssdl().doubleValue()/10000,2));
|
|
|
+ if (dqvo.getYllfdl()!=0){
|
|
|
+ dqvo.setNfnlyl(DoubleUtils.getRoundingNum(dqvo.getNsjfdl()/dqvo.getNllfdl()*100,2));
|
|
|
+ dqvo.setNwhssl(DoubleUtils.getRoundingNum(dqvo.getNwhssdl()/dqvo.getNllfdl()*100,2));
|
|
|
+ dqvo.setNgzssl(DoubleUtils.getRoundingNum(dqvo.getNgzssdl()/dqvo.getNllfdl()*100,2));
|
|
|
+ dqvo.setNxdssl(DoubleUtils.getRoundingNum(dqvo.getNxdssdl()/dqvo.getNllfdl()*100,2));
|
|
|
+ dqvo.setNxnssl(DoubleUtils.getRoundingNum(dqvo.getNxnssdl()/dqvo.getNllfdl()*100,2));
|
|
|
+ dqvo.setNslssl(DoubleUtils.getRoundingNum(dqvo.getNslssdl()/dqvo.getNllfdl()*100,2));
|
|
|
+ }else {
|
|
|
+ dqvo.setNfnlyl(0.0);
|
|
|
+ dqvo.setNwhssl(0.0);
|
|
|
+ dqvo.setNgzssl(0.0);
|
|
|
+ dqvo.setNxdssl(0.0);
|
|
|
+ dqvo.setNxnssl(0.0);
|
|
|
+ dqvo.setNslssl(0.0);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ dqvo.setNllfdl(0.0);
|
|
|
+ dqvo.setNsjfdl(0.0);
|
|
|
+ dqvo.setNwhssdl(0.0);
|
|
|
+ dqvo.setNgzssdl(0.0);
|
|
|
+ dqvo.setNxdssdl(0.0);
|
|
|
+ dqvo.setNxnssdl(0.0);
|
|
|
+ dqvo.setNslssdl(0.0);
|
|
|
+ dqvo.setNfnlyl(0.0);
|
|
|
+ dqvo.setNwhssl(0.0);
|
|
|
+ dqvo.setNgzssl(0.0);
|
|
|
+ dqvo.setNxdssl(0.0);
|
|
|
+ dqvo.setNxnssl(0.0);
|
|
|
+ dqvo.setNslssl(0.0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取专题分析中间部分
|
|
|
+ * @param yearmonth
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String,List<SpecificCenterVo>> maincenterlist(String companys,String type,String yearmonth) throws ParseException {
|
|
|
+ Map<String, ProBasicPowerstation> wpmap = CacheContext.wpmap;
|
|
|
+ Date date = DateUtils.parseDate(yearmonth+"-01");
|
|
|
+ Calendar c= Calendar.getInstance();
|
|
|
+ c.setTime(date);
|
|
|
+ int year = c.get(Calendar.YEAR);
|
|
|
+ int month = c.get(Calendar.MONTH)+1;
|
|
|
+ //定义左边部分的结果list
|
|
|
+ List<SpecificCenterVo> monthresultList = new ArrayList<>();
|
|
|
+ //设置当月数据
|
|
|
+ setCenterDyInfo(companys,type,yearmonth,monthresultList);
|
|
|
+ //设置同期数据
|
|
|
+ setCenterYtqInfo(companys,type,yearmonth,monthresultList);
|
|
|
+ //设置比较数据
|
|
|
+ monthresultList.stream().forEach(i->{
|
|
|
+ i.setMtbfCompare(i.getMtbf()>i.getTqmtbf()?1:2);
|
|
|
+ i.setMttrCompare(i.getMttr()>i.getTqmttr()?1:2);
|
|
|
+ i.setFwjslCompare(i.getFwjsl()>i.getTqfwjsl()?1:2);
|
|
|
+ i.setZtzhlCompare(i.getZtzhl()>i.getTqztzhl()?1:2);
|
|
|
+ i.setXqjslCompare(i.getXqjsl()>i.getTqxqjsl()?1:2);
|
|
|
+ });
|
|
|
+
|
|
|
+ //定义右边部分的结果list
|
|
|
+ List<SpecificCenterVo> yearresultList = new ArrayList<>();
|
|
|
+ //设置当年数据
|
|
|
+ setCenterDnInfo(companys,type,yearmonth, yearresultList);
|
|
|
+ //设置同期数据
|
|
|
+ setCenterNtqInfo(companys,type,yearmonth,yearresultList);
|
|
|
+ //设置比较数据
|
|
|
+ yearresultList.stream().forEach(i->{
|
|
|
+ i.setMtbfCompare(i.getMtbf()>i.getTqmtbf()?1:2);
|
|
|
+ i.setMttrCompare(i.getMttr()>i.getTqmttr()?1:2);
|
|
|
+ i.setFwjslCompare(i.getFwjsl()>i.getTqfwjsl()?1:2);
|
|
|
+ i.setZtzhlCompare(i.getZtzhl()>i.getTqztzhl()?1:2);
|
|
|
+ i.setXqjslCompare(i.getXqjsl()>i.getTqxqjsl()?1:2);
|
|
|
+ });
|
|
|
+
|
|
|
+ //封装最终返回结果
|
|
|
+ monthresultList.stream().forEach(i->{
|
|
|
+ i.setWpid(wpmap.get(i.getWpid()).getAname());
|
|
|
+ });
|
|
|
+ yearresultList.stream().forEach(i->{
|
|
|
+ i.setWpid(wpmap.get(i.getWpid()).getAname());
|
|
|
+ });
|
|
|
+ Map<String,List<SpecificCenterVo>> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("当月",monthresultList);
|
|
|
+ resultMap.put("当年",yearresultList);
|
|
|
+ return resultMap;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置月同期mtbf,mttr,复位及时率,状态转换率,消缺及时率
|
|
|
+ * @param companys
|
|
|
+ * @param type
|
|
|
+ * @param yearmonth
|
|
|
+ * @param monthresultList
|
|
|
+ */
|
|
|
+ private void setCenterYtqInfo(String companys,String type,String yearmonth, List<SpecificCenterVo> monthresultList) {
|
|
|
+ String yearString = yearmonth.split("-")[0];
|
|
|
+ String year = String.valueOf(Integer.parseInt(yearString) - 1);
|
|
|
+ String yearMonth = year+"-"+yearmonth.split("-")[1];
|
|
|
+ QueryWrapper<ProEconPowerstationInfoDay4> qw = new QueryWrapper<>();
|
|
|
+
|
|
|
+ qw.select("foreign_key_id,max(ymtbf) ymtbf,max(ymttr) ymttr,max(yfwjsl) yfwjsl,max(yztzhjsl) yztzhjsl,max(ygzxqjsl) ygzxqjsl");
|
|
|
+ qw.eq("location","wp");
|
|
|
+ if (type.endsWith("-1")){
|
|
|
+ qw.like("foreign_key_id","_FDC_");
|
|
|
+ }else if (type.endsWith("-2")){
|
|
|
+ qw.like("foreign_key_id","_GDC_");
|
|
|
+ }
|
|
|
+ if (companys.endsWith("ZGS")){
|
|
|
+ qw.in("foreign_key_id",CacheContext.wpls.stream().filter(wp->wp.getCompanyId().equals(companys)).map(wp->wp.getId()).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ qw.eq("to_char(record_date,'yyyy-MM')",yearMonth);
|
|
|
+ qw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
|
|
|
+ List<ProEconPowerstationInfoDay4> tqList = proEconPowerstationInfoDay4Service.list(qw);
|
|
|
+ if (StringUtils.isNotEmpty(tqList)){
|
|
|
+ tqList.stream().forEach(i->{
|
|
|
+ Optional<SpecificCenterVo> optionMonth = monthresultList.stream().filter(j -> j.getWpid().equals(i.getWindpowerstationId())).findFirst();
|
|
|
+ SpecificCenterVo leftVo = optionMonth.get();
|
|
|
+ if (optionMonth.isPresent()){
|
|
|
+ leftVo.setTqmtbf(DoubleUtils.keepPrecision(i.getYmtbf().doubleValue(),2));
|
|
|
+ leftVo.setTqmttr(DoubleUtils.keepPrecision(i.getYmttr().doubleValue(),2));
|
|
|
+ leftVo.setTqfwjsl(DoubleUtils.keepPrecision(i.getYfwjsl().doubleValue(),2));
|
|
|
+ leftVo.setTqztzhl(DoubleUtils.keepPrecision(i.getYztzhjsl().doubleValue(),2));
|
|
|
+ leftVo.setTqxqjsl(DoubleUtils.keepPrecision(i.getYgzxqjsl().doubleValue(),2));
|
|
|
+ }else{
|
|
|
+ leftVo.setTqmtbf(0.0);
|
|
|
+ leftVo.setTqmttr(0.0);
|
|
|
+ leftVo.setTqfwjsl(0.0);
|
|
|
+ leftVo.setTqztzhl(0.0);
|
|
|
+ leftVo.setTqxqjsl(0.0);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ List<ProBasicPowerstation> wpls = benchmarkingService.wpByCplist(companys, type);
|
|
|
+ wpls.stream().forEach(wp->{
|
|
|
+ Optional<SpecificCenterVo> optionMonth = monthresultList.stream().filter(j -> j.getWpid().equals(wp.getId())).findFirst();
|
|
|
+ if (optionMonth.isPresent()){
|
|
|
+ SpecificCenterVo leftVo = optionMonth.get();
|
|
|
+ leftVo.setTqmtbf(0.0);
|
|
|
+ leftVo.setTqmttr(0.0);
|
|
|
+ leftVo.setTqfwjsl(0.0);
|
|
|
+ leftVo.setTqztzhl(0.0);
|
|
|
+ leftVo.setTqxqjsl(0.0);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置年同期mtbf,mttr,复位及时率,状态转换率,消缺及时率
|
|
|
+ * @param companys
|
|
|
+ * @param yearresultList
|
|
|
+ */
|
|
|
+ private void setCenterNtqInfo(String companys,String type,String yearmonth, List<SpecificCenterVo> yearresultList) throws ParseException {
|
|
|
+ String yearString = yearmonth.split("-")[0];
|
|
|
+ String year = String.valueOf(Integer.parseInt(yearString) - 1);
|
|
|
+ QueryWrapper<ProEconPowerstationInfoDay4> qw = new QueryWrapper<>();
|
|
|
+ qw.select("foreign_key_id,max(nmtbf) nmtbf,max(nmttr) nmttr,max(nfwjsl) nfwjsl,max(nztzhjsl) nztzhjsl,max(ngzxqjsl) ngzxqjsl");
|
|
|
+ qw.eq("location","wp");
|
|
|
+ if (type.endsWith("-1")){
|
|
|
+ qw.like("foreign_key_id","_FDC_");
|
|
|
+ }else if (type.endsWith("-2")){
|
|
|
+ qw.like("foreign_key_id","_GDC_");
|
|
|
+ }
|
|
|
+ if (companys.endsWith("ZGS")){
|
|
|
+ qw.in("foreign_key_id",CacheContext.wpls.stream().filter(wp->wp.getCompanyId().equals(companys)).map(wp->wp.getId()).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ qw.eq("to_char(record_date,'yyyy')",year);
|
|
|
+ qw.groupBy("to_char(record_date,'yyyy'),foreign_key_id");
|
|
|
+ List<ProEconPowerstationInfoDay4> tqList = proEconPowerstationInfoDay4Service.list(qw);
|
|
|
+ if (StringUtils.isNotEmpty(tqList)){
|
|
|
+ tqList.stream().forEach(i->{
|
|
|
+ Optional<SpecificCenterVo> optionYear = yearresultList.stream().filter(j -> j.getWpid().equals(i.getWindpowerstationId())).findFirst();
|
|
|
+ if (optionYear.isPresent()){
|
|
|
+ SpecificCenterVo rightVo = optionYear.get();
|
|
|
+ rightVo.setTqmtbf(DoubleUtils.keepPrecision(i.getNmtbf().doubleValue(),2));
|
|
|
+ rightVo.setTqmttr(DoubleUtils.keepPrecision(i.getNmttr().doubleValue(),2));
|
|
|
+ rightVo.setTqfwjsl(DoubleUtils.keepPrecision(i.getNfwjsl().doubleValue(),2));
|
|
|
+ rightVo.setTqztzhl(DoubleUtils.keepPrecision(i.getNztzhjsl().doubleValue(),2));
|
|
|
+ rightVo.setTqxqjsl(DoubleUtils.keepPrecision(i.getNgzxqjsl().doubleValue(),2));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ List<ProBasicPowerstation> wpls = benchmarkingService.wpByCplist(companys, type);
|
|
|
+ wpls.stream().forEach(wp->{
|
|
|
+ Optional<SpecificCenterVo> optionMonth = yearresultList.stream().filter(j -> j.getWpid().equals(wp.getId())).findFirst();
|
|
|
+ if (optionMonth.isPresent()){
|
|
|
+ SpecificCenterVo leftVo = optionMonth.get();
|
|
|
+ leftVo.setTqmtbf(0.0);
|
|
|
+ leftVo.setTqmttr(0.0);
|
|
|
+ leftVo.setTqfwjsl(0.0);
|
|
|
+ leftVo.setTqztzhl(0.0);
|
|
|
+ leftVo.setTqxqjsl(0.0);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置当月mtbf,mttr,复位及时率,状态转换率,消缺及时率
|
|
|
+ * @param companys
|
|
|
+ * @param type
|
|
|
+ * @param monthresultList
|
|
|
+ */
|
|
|
+ private void setCenterDyInfo(String companys,String type,String yearmonth, List<SpecificCenterVo> monthresultList) {
|
|
|
+ QueryWrapper<ProEconPowerstationInfoDay4> qw = new QueryWrapper<>();
|
|
|
+
|
|
|
+ qw.select("foreign_key_id,max(ymtbf) ymtbf,max(ymttr) ymttr,max(yfwjsl) yfwjsl,max(yztzhjsl) yztzhjsl,max(ygzxqjsl) ygzxqjsl");
|
|
|
+ qw.eq("location","wp");
|
|
|
+ if (type.endsWith("-1")){
|
|
|
+ qw.like("foreign_key_id","_FDC_");
|
|
|
+ }else if (type.endsWith("-2")){
|
|
|
+ qw.like("foreign_key_id","_GDC_");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (companys.endsWith("ZGS")){
|
|
|
+ List<String> collect = CacheContext.wpls.stream().filter(wp -> wp.getCompanyId().equals(companys)).map(wp -> wp.getId()).collect(Collectors.toList());
|
|
|
+ qw.in("foreign_key_id",CacheContext.wpls.stream().filter(wp -> wp.getCompanyId().equals(companys)).map(wp -> wp.getId()).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ qw.eq("to_char(record_date,'yyyy-MM')",yearmonth);
|
|
|
+ qw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
|
|
|
+ List<ProEconPowerstationInfoDay4> dyList = proEconPowerstationInfoDay4Service.list(qw);
|
|
|
+ if (StringUtils.isNotEmpty(dyList)){
|
|
|
+ dyList.stream().forEach(i->{
|
|
|
+ SpecificCenterVo leftVo = new SpecificCenterVo();
|
|
|
+ leftVo.setWpid(i.getForeignKeyId());
|
|
|
+ leftVo.setMtbf(DoubleUtils.keepPrecision(i.getYmtbf().doubleValue(),2));
|
|
|
+ leftVo.setMttr(DoubleUtils.keepPrecision(i.getYmttr().doubleValue(),2));
|
|
|
+ leftVo.setFwjsl(DoubleUtils.keepPrecision(i.getYfwjsl().doubleValue(),2));
|
|
|
+ leftVo.setZtzhl(DoubleUtils.keepPrecision(i.getYztzhjsl().doubleValue(),2));
|
|
|
+ leftVo.setXqjsl(DoubleUtils.keepPrecision(i.getYgzxqjsl().doubleValue(),2));
|
|
|
+ monthresultList.add(leftVo);
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ List<ProBasicPowerstation> wpls = benchmarkingService.wpByCplist(companys, type);
|
|
|
+ wpls.stream().forEach(i->{
|
|
|
+ SpecificCenterVo leftVo = new SpecificCenterVo();
|
|
|
+ leftVo.setWpid(i.getId());
|
|
|
+ leftVo.setMtbf(0.0);
|
|
|
+ leftVo.setMttr(0.0);
|
|
|
+ leftVo.setFwjsl(0.0);
|
|
|
+ leftVo.setZtzhl(0.0);
|
|
|
+ leftVo.setXqjsl(0.0);
|
|
|
+ monthresultList.add(leftVo);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置当年mtbf,mttr,复位及时率,状态转换率,消缺及时率
|
|
|
+ * @param companys
|
|
|
+ * @param yearresultList
|
|
|
+ */
|
|
|
+ private void setCenterDnInfo(String companys,String type,String yearmonth, List<SpecificCenterVo> yearresultList) {
|
|
|
+
|
|
|
+
|
|
|
+ QueryWrapper<ProEconPowerstationInfoDay4> qw = new QueryWrapper<>();
|
|
|
+
|
|
|
+ qw.select("foreign_key_id,max(nmtbf) nmtbf,max(nmttr) nmttr,max(nfwjsl) nfwjsl,max(nztzhjsl) nztzhjsl,max(ngzxqjsl) ngzxqjsl");
|
|
|
+ qw.eq("location","wp");
|
|
|
+ if (type.endsWith("-1")){
|
|
|
+ qw.like("foreign_key_id","_FDC_");
|
|
|
+ }else if (type.endsWith("-2")){
|
|
|
+ qw.like("foreign_key_id","_GDC_");
|
|
|
+ }
|
|
|
+ if (companys.endsWith("ZGS")){
|
|
|
+ qw.in("foreign_key_id",CacheContext.wpls.stream().filter(wp->wp.getCompanyId().equals(companys)).map(wp->wp.getId()).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ qw.eq("to_char(record_date,'yyyy')",yearmonth.split("-")[0]);
|
|
|
+ qw.groupBy("to_char(record_date,'yyyy'),foreign_key_id");
|
|
|
+ List<ProEconPowerstationInfoDay4> dyList = proEconPowerstationInfoDay4Service.list(qw);
|
|
|
+ if (StringUtils.isNotEmpty(dyList)){
|
|
|
+ dyList.stream().forEach(i->{
|
|
|
+ SpecificCenterVo rightVo = new SpecificCenterVo();
|
|
|
+ rightVo.setWpid(i.getForeignKeyId());
|
|
|
+ rightVo.setMtbf(DoubleUtils.keepPrecision(i.getNmtbf().doubleValue(),2));
|
|
|
+ rightVo.setMttr(DoubleUtils.keepPrecision(i.getNmttr().doubleValue(),2));
|
|
|
+ rightVo.setFwjsl(DoubleUtils.keepPrecision(i.getNfwjsl().doubleValue(),2));
|
|
|
+ rightVo.setZtzhl(DoubleUtils.keepPrecision(i.getNztzhjsl().doubleValue(),2));
|
|
|
+ rightVo.setXqjsl(DoubleUtils.keepPrecision(i.getNgzxqjsl().doubleValue(),2));
|
|
|
+ yearresultList.add(rightVo);
|
|
|
+ });
|
|
|
+ }else {
|
|
|
+ List<ProBasicPowerstation> wpls = benchmarkingService.wpByCplist(companys, type);
|
|
|
+ wpls.stream().forEach(i->{
|
|
|
+ SpecificCenterVo rightVo = new SpecificCenterVo();
|
|
|
+ rightVo.setWpid(i.getId());
|
|
|
+ rightVo.setMtbf(0.0);
|
|
|
+ rightVo.setMttr(0.0);
|
|
|
+ rightVo.setFwjsl(0.0);
|
|
|
+ rightVo.setZtzhl(0.0);
|
|
|
+ rightVo.setXqjsl(0.0);
|
|
|
+ yearresultList.add(rightVo);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 获取风能利用率
|