|
@@ -6,13 +6,12 @@ import cn.hutool.poi.excel.ExcelReader;
|
|
|
import cn.hutool.poi.excel.ExcelUtil;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
+import com.slibra.business.domain.TXinyiCalculate;
|
|
|
+import com.slibra.business.domain.TXinyiNormConfig;
|
|
|
+import com.slibra.business.mapper.*;
|
|
|
import com.slibra.common.core.domain.TXinyiDaily;
|
|
|
import com.slibra.business.domain.TXinyiIndustry;
|
|
|
import com.slibra.business.domain.TXinyiLaboratory;
|
|
|
-import com.slibra.business.mapper.TXinyiDailyMapper;
|
|
|
-import com.slibra.business.mapper.TXinyiIndustryMapper;
|
|
|
-import com.slibra.business.mapper.TXinyiLaboratoryMapper;
|
|
|
-import com.slibra.business.mapper.TXinyiRobotMapper;
|
|
|
import com.slibra.common.core.controller.BaseController;
|
|
|
import com.slibra.common.utils.DateUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -22,10 +21,14 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
|
|
|
+import static com.slibra.common.constant.MyConstants.*;
|
|
|
+import static com.slibra.common.constant.MyConstants.BigDecimal_100;
|
|
|
+
|
|
|
/**
|
|
|
* 参数配置 信息操作处理
|
|
|
*
|
|
@@ -48,6 +51,13 @@ public class HandleDataController extends BaseController
|
|
|
@Autowired
|
|
|
private TXinyiRobotMapper xinyiRobotMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TXinyiNormConfigMapper xinyiNormConfigMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TXinyiCalculateMapper xinyiCalculateMapper;
|
|
|
+
|
|
|
+
|
|
|
public static final String[] queryTags = {"信义污水厂JS_COD_Value","信义污水厂JS_PH_Value","信义污水厂JS_SS_Value","信义污水厂JS_ZL_Value","信义污水厂JS_ZA_Value","信义污水厂JS_AD_Value","信义污水厂JS_T_Value","信义污水厂进水泵房液位","信义污水厂出水瞬时流量","信义污水厂升级出水COD","信义污水厂升级出水PH","信义污水厂升级出水SS","信义污水厂升级出水TN","信义污水厂升级出水TP","信义污水厂升级出水氨氮","信义污水厂AIT202_Value","信义污水厂AIT203_Value","信义污水厂AIT207_Value","信义污水厂AIT206_Value","信义污水厂AIT209_Value","信义污水厂AIT210_Value","信义污水厂进水TDS","信义污水厂FT101_Value","信义污水厂SWCHHYHLB1_R_Value","信义污水厂SWCHHYHLB2_R_Value","信义污水厂SWCHHYHLB3_R_Value","信义污水厂SWCHHYHLB4_R_Value","信义污水厂SWCHHYHLB5_R_Value","信义污水厂SWCHHYHLB6_R_Value","信义污水厂SWCWNHLB1_R_Value","信义污水厂SWCWNHLB2_R_Value","信义污水厂SWCWNHLB3_R_Value","信义污水厂SWCWNHLB4_R_Value","信义污水厂SWCWNHLB5_R_Value","信义污水厂GFJ1_R_Value","信义污水厂GFJ2_R_Value","信义污水厂GFJ3_R_Value","信义污水厂GFJ4_R_Value","信义污水厂GFJ5_R_Value","信义污水厂GFJ6_R_Value","信义污水厂GFJ1_KQLL_Value","信义污水厂GFJ2_KQLL_Value","信义污水厂GFJ3_KQLL_Value","信义污水厂GFJ4_KQLL_Value","信义污水厂GFJ5_KQLL_Value","信义污水厂GFJ6_KQLL_Value"};
|
|
|
|
|
|
@GetMapping("/dateAdd")
|
|
@@ -701,8 +711,141 @@ public class HandleDataController extends BaseController
|
|
|
*/
|
|
|
@GetMapping("/handleCalculateHistoryDates")
|
|
|
public String handleCalculateHistoryDates() {
|
|
|
+ log.info("进入了 手动处理-重置计算表历史数据");
|
|
|
long begin = System.currentTimeMillis();
|
|
|
|
|
|
+ List<TXinyiNormConfig> tXinyiNormConfigs = xinyiNormConfigMapper.selectTXinyiNormConfigList(null);
|
|
|
+ if(CollectionUtils.isEmpty(tXinyiNormConfigs)) {
|
|
|
+ log.error( "未查询到配置信息");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ TXinyiNormConfig normConfig = tXinyiNormConfigs.get(0);
|
|
|
+
|
|
|
+ int size = 500;
|
|
|
+ int count = xinyiIndustryMapper.getCount();
|
|
|
+
|
|
|
+ int num = ( count / size ) + 1;
|
|
|
+
|
|
|
+ for (int i = 0; i < num; i++) {
|
|
|
+ List<TXinyiIndustry> tXinyiIndustries = xinyiIndustryMapper.selectTXinyiIndustryListByPage(i * size, size);
|
|
|
+ List<TXinyiCalculate> tempInsertData = new ArrayList<>();
|
|
|
+ if (!CollectionUtils.isEmpty( tXinyiIndustries )) {
|
|
|
+ for (int j = 0; j < tXinyiIndustries.size(); j++) {
|
|
|
+
|
|
|
+ TXinyiIndustry tXinyiIndustry = tXinyiIndustries.get(j);
|
|
|
+
|
|
|
+ //获取的一些配置信息
|
|
|
+ BigDecimal nhlbqdsl = normConfig.getNHLBQDSL();
|
|
|
+ BigDecimal nhlbdsjll = normConfig.getNHLBDSJLL();
|
|
|
+ BigDecimal nhlbgzxl = normConfig.getNHLBGZXL();
|
|
|
+ BigDecimal whlbqdsl = normConfig.getWHLBQDSL();
|
|
|
+ BigDecimal whlbdsjll = normConfig.getWHLBDSJLL();
|
|
|
+ BigDecimal whlbgzxl = normConfig.getWHLBGZXL();
|
|
|
+ BigDecimal gfjgzts = normConfig.getGFJGZTS();
|
|
|
+ BigDecimal gfjckll = normConfig.getGFJCKLL();
|
|
|
+ BigDecimal fcxbsjll = normConfig.getFCXBSJLL();
|
|
|
+ BigDecimal fclbsl = normConfig.getFCLBSL();
|
|
|
+ BigDecimal fcxbgzxl = normConfig.getFCXBGZXL();
|
|
|
+
|
|
|
+ //结算结果
|
|
|
+ TXinyiCalculate tXinyiCalculate = new TXinyiCalculate();
|
|
|
+ //时间相关
|
|
|
+ tXinyiCalculate.setTestDate(tXinyiIndustry.getTestDate());
|
|
|
+ tXinyiCalculate.setTestHour(tXinyiIndustry.getTestHour());
|
|
|
+ tXinyiCalculate.setTestTime(tXinyiIndustry.getTestTime());
|
|
|
+
|
|
|
+ //获取最新的一条日报信息
|
|
|
+ TXinyiDaily tXinyiDaily = this.xinyiDailyMapper.getDetailByDay(tXinyiIndustry.getTestDate());
|
|
|
+ if(Objects.isNull(tXinyiDaily)){
|
|
|
+ //理论不会出现
|
|
|
+ log.error("没有日报数据,取最新的");
|
|
|
+ tXinyiDaily = this.xinyiDailyMapper.selectNewestData();
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal jsBod5 = tXinyiDaily.getJsBod5();
|
|
|
+ BigDecimal csBod5 = tXinyiDaily.getCsBod5();
|
|
|
+ BigDecimal whlR = tXinyiDaily.getWhlR();
|
|
|
+ BigDecimal oneMlvss = tXinyiDaily.getShcHyOneMlvss();
|
|
|
+ BigDecimal twoMlvss = tXinyiDaily.getShcHyTwoMlvss();
|
|
|
+ BigDecimal avgMlvss = null;
|
|
|
+ if(!Objects.isNull(oneMlvss) && !Objects.isNull(twoMlvss))
|
|
|
+ avgMlvss = ((oneMlvss.add(twoMlvss)).divide(new BigDecimal(2),4, RoundingMode.HALF_UP));
|
|
|
+ BigDecimal oneMlss = tXinyiDaily.getShcHyOneMlss();
|
|
|
+ BigDecimal twoMlss = tXinyiDaily.getShcHyTwoMlss();
|
|
|
+ BigDecimal avgMlss = null;
|
|
|
+ if(!Objects.isNull(oneMlss) && !Objects.isNull(twoMlss))
|
|
|
+ avgMlss = ((oneMlss.add(twoMlss)).divide(new BigDecimal(NUMBER_2),NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+
|
|
|
+ //工业库的指标
|
|
|
+ BigDecimal jsTn = tXinyiIndustry.getJsTn();
|
|
|
+ BigDecimal jsTp = tXinyiIndustry.getJsTp();
|
|
|
+ BigDecimal jsCod = tXinyiIndustry.getJsCod();
|
|
|
+ BigDecimal jsSlq = tXinyiIndustry.getJsSlq();
|
|
|
+ //计算
|
|
|
+ if(!Objects.isNull(jsBod5)){
|
|
|
+ if(!Objects.isNull(jsTn) && jsTn.compareTo(BigDecimal.ZERO) > 0)
|
|
|
+ tXinyiCalculate.setJsTdb(jsBod5.divide(jsTn, NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+ if(!Objects.isNull(jsTp) && jsTp.compareTo(BigDecimal.ZERO) > 0)
|
|
|
+ tXinyiCalculate.setJsTlb(jsBod5.divide(jsTp, NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+ if(!Objects.isNull(jsCod) && jsCod.compareTo(BigDecimal.ZERO) > 0)
|
|
|
+ tXinyiCalculate.setJsBodBCod(jsBod5.divide(jsCod, NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+ if(!Objects.isNull(csBod5) && !Objects.isNull(avgMlss) && avgMlss.compareTo(BigDecimal.ZERO) > 0 && !Objects.isNull(jsSlq) && jsSlq.compareTo(BigDecimal.ZERO) > 0)
|
|
|
+ tXinyiCalculate.setFM(new BigDecimal(ONE_DAY_HOURS).multiply((jsBod5.subtract(csBod5))).multiply(jsSlq).divide(avgMlss, NUMBER_SCALE_4, RoundingMode.HALF_UP).divide(new BigDecimal(F_M_LAST), NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
+ if(!Objects.isNull(avgMlss) && avgMlss.compareTo(BigDecimal.ZERO) > 0 && !Objects.isNull(avgMlvss) && avgMlvss.compareTo(BigDecimal.ZERO) > 0)
|
|
|
+ tXinyiCalculate.setHFXWNNDZB(avgMlvss.divide(avgMlss, NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+ if(!Objects.isNull(jsSlq) && jsSlq.compareTo(BigDecimal.ZERO) > 0){
|
|
|
+ tXinyiCalculate.setYyqHrt(new BigDecimal(YYQ_TLSJ_FIRST).divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+ tXinyiCalculate.setQyqHrt(new BigDecimal(QYQ_TLSJ_FIRST).divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+ tXinyiCalculate.setHyqHrt(new BigDecimal(HYQ_TLSJ_FIRST).divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+// tXinyiCalculate.setGSLS(jsSlq.divide(new BigDecimal(NUMBER_3600), NUMBER_SCALE_4, RoundingMode.HALF_UP).multiply(new BigDecimal(NUMBER_4)).divide((new BigDecimal(Math.PI).multiply(new BigDecimal(NUMBER_0_0_0_3)).multiply(new BigDecimal(NUMBER_0_0_0_3)).multiply(new BigDecimal(NUMBER_4)).multiply(new BigDecimal(NUMBER_4)).multiply(new BigDecimal(NUMBER_97119))) , NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+ tXinyiCalculate.setGSLS(jsSlq.divide(GSLS_LAST, NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+ tXinyiCalculate.setGslsOne(jsSlq.divide(new BigDecimal(NUMBER_3600), NUMBER_SCALE_4, RoundingMode.HALF_UP).multiply(new BigDecimal(Math.sqrt(Math.sin(Math.toRadians(DOUBLE_75))))).divide(GSLSONE_LAST, NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+ tXinyiCalculate.setGslsTwo(jsSlq.divide(new BigDecimal(NUMBER_3600), NUMBER_SCALE_4, RoundingMode.HALF_UP).multiply(new BigDecimal(Math.sqrt(Math.sin(Math.toRadians(DOUBLE_75))))).divide(GSLSTWO_LAST, NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+ tXinyiCalculate.setXgsGsls(jsSlq.divide(new BigDecimal(NUMBER_3600), NUMBER_SCALE_4, RoundingMode.HALF_UP).multiply(new BigDecimal(NUMBER_4)).divide((GSLS_XGS_LAST) , NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+
|
|
|
+ tXinyiCalculate.setXlcscBmfh(jsSlq.divide(XLCSCBMFH_LAST, NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+ tXinyiCalculate.setXlcscHrt(XLCSCHRT_LAST.divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+ tXinyiCalculate.setCccdcBmfh(jsSlq.divide(CCCDCBMFH_LAST, NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+ tXinyiCalculate.setCccdcHrt(CCCDCHRT_LAST.divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+ tXinyiCalculate.setEccBmfh(jsSlq.divide(ECCBMFH_LAST, NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+ tXinyiCalculate.setEccHrt(ECCHRT_LAST.divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+ //2024年7月1日17:16:16 计算逻辑调整
|
|
|
+ if(!Objects.isNull(whlR) && avgMlss != null && jsSlq != null) {
|
|
|
+ tXinyiCalculate.setEccGtfh((new BigDecimal(1).add(whlR.divide(BigDecimal_100, NUMBER_SCALE_4, RoundingMode.HALF_UP))).multiply(jsSlq).multiply(new BigDecimal(NUMBER_24)).multiply(avgMlss).divide(ECCGTFH_LAST, NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+ }
|
|
|
+ tXinyiCalculate.setClsnJcsj(CLSNJCSJ_LAST.divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+ tXinyiCalculate.setXgcdcQsqSsls(jsSlq.multiply(XGCDCQSQSSLS_LAST));
|
|
|
+ //2024年6月29日15:18:01 增加几个新的计算指标
|
|
|
+ if(!Objects.isNull(nhlbqdsl) && !Objects.isNull(nhlbdsjll) && !Objects.isNull(nhlbgzxl))
|
|
|
+ tXinyiCalculate.setNHLB(nhlbqdsl.multiply(nhlbdsjll).multiply(nhlbgzxl).multiply(BigDecimal_100).divide(jsSlq, 4, RoundingMode.HALF_UP));
|
|
|
+ if(!Objects.isNull(whlbqdsl) && !Objects.isNull(whlbdsjll) && !Objects.isNull(whlbgzxl))
|
|
|
+ tXinyiCalculate.setWHLB(whlbqdsl.multiply(whlbdsjll).multiply(whlbgzxl).multiply(BigDecimal_100).divide(jsSlq, 4, RoundingMode.HALF_UP));
|
|
|
+ if(!Objects.isNull(gfjgzts) && !Objects.isNull(gfjckll))
|
|
|
+ tXinyiCalculate.setQSB(gfjgzts.multiply(gfjckll).divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP));
|
|
|
+ if(!Objects.isNull(fcxbsjll) && !Objects.isNull(fclbsl) && !Objects.isNull(fcxbgzxl)){
|
|
|
+ BigDecimal fcxsl = fcxbsjll.multiply(fclbsl).multiply(fcxbgzxl);
|
|
|
+ tXinyiCalculate.setFCXSL(fcxsl);
|
|
|
+ //2024年7月3日10:54:28 额外再增加一个字段
|
|
|
+ tXinyiCalculate.setFCXSLBL(fcxsl.divide(jsSlq, NUMBER_SCALE_4, RoundingMode.HALF_UP).multiply(BigDecimal_100));
|
|
|
+ }
|
|
|
+ //2024年7月11日15:43:47 之前给的外回流比计算不准确,额外一个字段记录新的外回流比
|
|
|
+ BigDecimal divide = jsSlq.divide(DECIMAL_2, NUMBER_SCALE_4, RoundingMode.HALF_UP);
|
|
|
+ if(divide.compareTo(DECIMAL_1500) < 0)
|
|
|
+ tXinyiCalculate.setWhlRN(DECIMAL_1200.divide(divide, NUMBER_SCALE_4, RoundingMode.HALF_UP).multiply(BigDecimal_100));
|
|
|
+ else
|
|
|
+ tXinyiCalculate.setWhlRN(DECIMAL_1620.divide(divide, NUMBER_SCALE_4, RoundingMode.HALF_UP).multiply(BigDecimal_100));
|
|
|
+ }
|
|
|
+
|
|
|
+ tempInsertData.add(tXinyiCalculate);
|
|
|
+ xinyiCalculateMapper.insertTXinyiCalculate(tXinyiCalculate);
|
|
|
+ }
|
|
|
+
|
|
|
+ // xinyiCalculateMapper.insertBatchData(tempInsertData);
|
|
|
+ // return tXinyiCalculate;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
long end = System.currentTimeMillis();
|
|
|
return "ok;耗时:" + (end - begin) /1000 + "秒。";
|