|
@@ -5,6 +5,7 @@ import cn.hutool.http.HttpRequest;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.slibra.business.domain.TXinyiDaily;
|
|
|
+import com.slibra.business.domain.TXinyiIndustry;
|
|
|
import com.slibra.business.domain.TXinyiNormConfig;
|
|
|
import com.slibra.business.mapper.TXinyiDailyMapper;
|
|
|
import com.slibra.business.mapper.TXinyiIndustryMapper;
|
|
@@ -48,18 +49,57 @@ public class FrontServiceImpl implements IFrontService {
|
|
|
String[] queryTags = {"信义污水厂JS_COD_Value", "信义污水厂升级出水COD", "信义污水厂JS_AD_Value", "信义污水厂升级出水氨氮", "信义污水厂JS_ZA_Value", "信义污水厂升级出水TN", "信义污水厂JS_ZL_Value", "信义污水厂升级出水TP", "信义污水厂JS_SS_Value", "信义污水厂升级出水SS", "信义污水厂JS_PH_Value", "信义污水厂升级出水PH", "信义污水厂FT101_Value", "信义污水厂出水瞬时流量"};
|
|
|
xinyiIndustrySimple = this.getRealTimeData(queryTags, nowTime);
|
|
|
//处理日报数据
|
|
|
- xinyiIndustrySimple = this.addDailyData(xinyiIndustrySimple, nowTime);
|
|
|
+ this.addDailyData(xinyiIndustrySimple, nowTime);
|
|
|
//处理配置信息
|
|
|
- xinyiIndustrySimple = this.addConfigData(xinyiIndustrySimple);
|
|
|
+ this.addConfigData(xinyiIndustrySimple);
|
|
|
//计算
|
|
|
- xinyiIndustrySimple = this.calculateData(xinyiIndustrySimple);
|
|
|
+ this.calculateData(xinyiIndustrySimple, nowTime);
|
|
|
return xinyiIndustrySimple;
|
|
|
}
|
|
|
|
|
|
- private XinyiIndustrySimple calculateData(XinyiIndustrySimple xinyiIndustrySimple) {
|
|
|
+ private XinyiIndustrySimple calculateData(XinyiIndustrySimple xinyiIndustrySimple, LocalDateTime nowTime) {
|
|
|
+ LocalDateTime yesterdaySameTime = nowTime.plusDays(-1);
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DateUtils.YYYYMMDDHHMM_TS);
|
|
|
+ String testTime = formatter.format(yesterdaySameTime);
|
|
|
//处理昨日同时期的进水 获取环比
|
|
|
-
|
|
|
+ List<TXinyiIndustry> tXinyiIndustries = this.xinyiIndustryMapper.selectTXinyiIndustryList(TXinyiIndustry.builder().testTime(testTime).build());
|
|
|
+ if(!CollectionUtils.isEmpty(tXinyiIndustries)){
|
|
|
+ TXinyiIndustry industry = tXinyiIndustries.get(0);
|
|
|
+ BigDecimal jsSlqYesterday = industry.getJsSlq();
|
|
|
+ BigDecimal csSlqcYesterday = industry.getCsSlqc();
|
|
|
+ BigDecimal jsSlqToday = xinyiIndustrySimple.getJsSlq();
|
|
|
+ BigDecimal csSlqcToday = xinyiIndustrySimple.getCsSlqc();
|
|
|
+ if(!Objects.isNull(jsSlqYesterday) && !Objects.isNull(jsSlqToday))
|
|
|
+ xinyiIndustrySimple.setSsJsHb((jsSlqToday.subtract(jsSlqYesterday)).divide(jsSlqYesterday, 4, RoundingMode.HALF_UP));
|
|
|
+ if(!Objects.isNull(csSlqcYesterday) && !Objects.isNull(csSlqcToday))
|
|
|
+ xinyiIndustrySimple.setSsJsHb((csSlqcToday.subtract(csSlqcYesterday)).divide(csSlqcYesterday, 4, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
//通过sql查询上周的平均值和环比情况
|
|
|
+ DateTimeFormatter formatterDate = DateTimeFormatter.ofPattern(DateUtils.YYYYMMDD_TS);
|
|
|
+ //获取上周的统计进出水品均值
|
|
|
+ String begin = formatterDate.format(nowTime.plusDays(-7));
|
|
|
+ String end = formatterDate.format(nowTime.plusDays(-1));
|
|
|
+ HashMap<String, BigDecimal> lastWeek = this.xinyiDailyMapper.selectAvgWater(begin, end);
|
|
|
+ BigDecimal lastJSL = lastWeek.get("JSL");
|
|
|
+ BigDecimal lastCSL = lastWeek.get("CSL");
|
|
|
+ //获取上上周的统计进出水品均值
|
|
|
+ begin = formatterDate.format(nowTime.plusDays(-14));
|
|
|
+ end = formatterDate.format(nowTime.plusDays(-8));
|
|
|
+ HashMap<String, BigDecimal> beforeLastWeek = this.xinyiDailyMapper.selectAvgWater(begin, end);
|
|
|
+ BigDecimal beforeLastJSL = beforeLastWeek.get("JSL");
|
|
|
+ BigDecimal beforeLastCSL = beforeLastWeek.get("CSL");
|
|
|
+ if(!Objects.isNull(lastJSL)){
|
|
|
+ xinyiIndustrySimple.setSzZJSAvg(lastJSL);
|
|
|
+ if(!Objects.isNull(beforeLastJSL))
|
|
|
+ xinyiIndustrySimple.setSzZJSHb((lastJSL.subtract(beforeLastJSL)).divide(beforeLastJSL, 4, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
+ if(!Objects.isNull(lastCSL)){
|
|
|
+ xinyiIndustrySimple.setSzZCSAvg(lastCSL);
|
|
|
+ if(!Objects.isNull(beforeLastCSL))
|
|
|
+ xinyiIndustrySimple.setSzZCSHb((lastCSL.subtract(beforeLastCSL)).divide(beforeLastCSL, 4, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
return xinyiIndustrySimple;
|
|
|
}
|
|
|
|