|
@@ -16,6 +16,8 @@ import com.slibra.business.req.GenerateArgs;
|
|
|
import com.slibra.business.req.PredictorRequest;
|
|
|
import com.slibra.business.res.ChartBasic;
|
|
|
import com.slibra.business.res.ShowValueChartBasic;
|
|
|
+import com.slibra.business.res.SmartAdd;
|
|
|
+import com.slibra.business.service.IFrontService;
|
|
|
import com.slibra.business.service.ITXinyiForecastComparisonService;
|
|
|
import com.slibra.common.DecimalUtils;
|
|
|
import com.slibra.common.config.BigModelConfig;
|
|
@@ -42,6 +44,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.text.ParseException;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
@@ -118,6 +121,15 @@ public class RyTask
|
|
|
@Autowired
|
|
|
private JsCsFormatData jsCsFormatData;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TXinyiMedicineParamMapper xinyiMedicineParamMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TXinyiMedicineConfMapper xinyiMedicineConfMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFrontService frontService;
|
|
|
+
|
|
|
/** 使用的是哪个环境 */
|
|
|
@Value("${spring.profiles.active}")
|
|
|
private String environment;
|
|
@@ -833,6 +845,189 @@ public class RyTask
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public void calculateAndAddMedicine(){
|
|
|
+ log.info("进入了 定时计算投药 定时任务处理++++++");
|
|
|
+ BigDecimal val = this.calculateMedicine();
|
|
|
+ log.info("计算的结果是{}", val);
|
|
|
+ boolean canAdd = false;
|
|
|
+ TXinyiMedicineConf tXinyiMedicineConf = xinyiMedicineConfMapper.selectTXinyiMedicineConfById(LONG_1);
|
|
|
+ if(!Objects.isNull(tXinyiMedicineConf) && !Objects.isNull(tXinyiMedicineConf.getAddStatus()) && 1 == tXinyiMedicineConf.getAddStatus()){
|
|
|
+ canAdd = true;
|
|
|
+ }
|
|
|
+ if(!Objects.isNull(val) && canAdd){
|
|
|
+ //todo 调用组态接口,实施碳源投加
|
|
|
+ log.info("开始调用组态接口,实施碳源投加^^^^^^");
|
|
|
+
|
|
|
+ log.info("调用组态接口,实施碳源投加结束******");
|
|
|
+ }
|
|
|
+ log.info(" 定时计算投药 定时任务处理 结束------");
|
|
|
+ }
|
|
|
+
|
|
|
+ private BigDecimal calculateMedicine() {
|
|
|
+ //获取最新的配置信息
|
|
|
+ TXinyiMedicineParam latestRecord = this.xinyiMedicineParamMapper.getLatestRecord();
|
|
|
+ if(!Objects.isNull(latestRecord)){
|
|
|
+ return this.calculateMedicineByLastRecord(latestRecord);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private BigDecimal calculateMedicineByLastRecord(TXinyiMedicineParam param) {
|
|
|
+ if (Objects.isNull(param)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ //计算用到的值
|
|
|
+ Integer hycXsyType = param.getHycXsyType();
|
|
|
+ BigDecimal hycXsyOne = param.getHycXsyOne();
|
|
|
+ BigDecimal hycXsyTwo = param.getHycXsyTwo();
|
|
|
+
|
|
|
+ BigDecimal htfksd = param.getHtfksd();
|
|
|
+
|
|
|
+ Integer qycAdType = param.getQycAdType();
|
|
|
+ BigDecimal qycAdOne = param.getQycAdOne();
|
|
|
+ BigDecimal qycAdTwo = param.getQycAdTwo();
|
|
|
+
|
|
|
+ Integer qycYxyType = param.getQycYxyType();
|
|
|
+ BigDecimal qycYxyOne = param.getQycYxyOne();
|
|
|
+ BigDecimal qycYxyTwo = param.getQycYxyTwo();
|
|
|
+
|
|
|
+ BigDecimal xzxs = param.getXzxs();
|
|
|
+
|
|
|
+ BigDecimal jzxs = param.getJzxs();
|
|
|
+
|
|
|
+ Integer jsLlType = param.getJsLlType();
|
|
|
+ BigDecimal jsLlOne = param.getJsLlOne();//两个池子的值是一样的
|
|
|
+
|
|
|
+ BigDecimal slfpxs = param.getSlfpxs();
|
|
|
+
|
|
|
+ BigDecimal kzxs = param.getKzxs();
|
|
|
+
|
|
|
+ Integer jsCodType = param.getJsCodType();
|
|
|
+ BigDecimal jsCodOne = param.getJsCodOne();
|
|
|
+ BigDecimal jsCodTwo = param.getJsCodTwo();
|
|
|
+
|
|
|
+ BigDecimal zhxs = param.getZhxs();
|
|
|
+
|
|
|
+ BigDecimal tydl = param.getTydl();
|
|
|
+
|
|
|
+ BigDecimal medicineAmount = param.getMedicineAmount();//手动需要
|
|
|
+
|
|
|
+ Integer type = param.getType();//0自动 1一号池 2二号池 3人工投放
|
|
|
+
|
|
|
+ //计算
|
|
|
+ if(!Objects.isNull(type)) {
|
|
|
+ if(3 == type){
|
|
|
+ return medicineAmount;
|
|
|
+ }
|
|
|
+ //计算1号池的值
|
|
|
+ BigDecimal oneResult = this.getResultByDiff(hycXsyType, hycXsyOne, htfksd, qycAdType, qycAdOne, qycYxyType, qycYxyOne, xzxs, jzxs, jsLlType, jsLlOne, slfpxs, kzxs, jsCodType, jsCodOne, zhxs, tydl, "one");
|
|
|
+ //计算二号池的值
|
|
|
+ BigDecimal twoResult = this.getResultByDiff(hycXsyType, hycXsyTwo, htfksd, qycAdType, qycAdTwo, qycYxyType, qycYxyTwo, xzxs, jzxs, jsLlType, jsLlOne, slfpxs, kzxs, jsCodType, jsCodTwo, zhxs, tydl, "two");
|
|
|
+ //判断,返回值
|
|
|
+ if(0 == type)
|
|
|
+ return oneResult.compareTo(twoResult) > 0 ? oneResult : twoResult;
|
|
|
+ else if(1 == type) {
|
|
|
+ return oneResult;
|
|
|
+ }else if(2 == type)
|
|
|
+ return twoResult;
|
|
|
+ else {
|
|
|
+ return null;//错误的配置
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private BigDecimal getResultByDiff(Integer hycXsyType, BigDecimal hycXsyVal, BigDecimal htfksd, Integer qycAdType, BigDecimal qycAdVal, Integer qycYxyType,
|
|
|
+ BigDecimal qycYxyVal, BigDecimal xzxs, BigDecimal jzxs, Integer jsLlType, BigDecimal jsLlVal, BigDecimal slfpxs, BigDecimal kzxs, Integer jsCodType,
|
|
|
+ BigDecimal jsCodVal, BigDecimal zhxs, BigDecimal tydl, String whichCZ) {
|
|
|
+ //2024年09月14日10:26:11 不同池子,根据不同类型,获取最新的数据,计算碳源投加量
|
|
|
+ //获取最新的实时数据
|
|
|
+ SmartAdd smartAdd = this.frontService.smartAddDataInfo();
|
|
|
+ if(!Objects.isNull(smartAdd)){
|
|
|
+ if("one".equals(whichCZ)){//一池
|
|
|
+ if(!Objects.isNull(hycXsyType)){
|
|
|
+ if(1 == hycXsyType){//化验
|
|
|
+ hycXsyVal = smartAdd.getHyXsyHYOne();
|
|
|
+ }else if(2 == hycXsyType){//预测
|
|
|
+ hycXsyVal = smartAdd.getHyXsyYCOne();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Objects.isNull(qycAdType) && 1 == qycAdType){//化验
|
|
|
+ qycAdVal = smartAdd.getQyAdHYOne();
|
|
|
+ }
|
|
|
+ if(!Objects.isNull(qycYxyType) && 1 == qycYxyType){//化验
|
|
|
+ qycYxyVal = smartAdd.getQyXsyHYOne();
|
|
|
+ }
|
|
|
+ if(!Objects.isNull(jsCodType)){
|
|
|
+ if(1 == jsCodType){//仪表
|
|
|
+ jsCodVal = smartAdd.getJsCodYB();
|
|
|
+ }else if(2 == jsCodType){//化验
|
|
|
+ jsCodVal = smartAdd.getJsCodHY();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Objects.isNull(jsLlType) && 1 == jsLlType){//仪表
|
|
|
+ jsLlVal = smartAdd.getJslYB();
|
|
|
+ }
|
|
|
+ }else {//二池
|
|
|
+ if(!Objects.isNull(hycXsyType)){
|
|
|
+ if(1 == hycXsyType){//化验
|
|
|
+ hycXsyVal = smartAdd.getHyXsyHYTwo();
|
|
|
+ }else if(2 == hycXsyType){//预测
|
|
|
+ hycXsyVal = smartAdd.getHyXsyYCTwo();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Objects.isNull(qycAdType) && 1 == qycAdType){//化验
|
|
|
+ qycAdVal = smartAdd.getQyAdHYTwo();
|
|
|
+ }
|
|
|
+ if(!Objects.isNull(qycYxyType) && 1 == qycYxyType){//化验
|
|
|
+ qycYxyVal = smartAdd.getQyXsyHYTwo();
|
|
|
+ }
|
|
|
+ if(!Objects.isNull(jsCodType)){
|
|
|
+ if(1 == jsCodType){//仪表
|
|
|
+ jsCodVal = smartAdd.getJsCodYB();
|
|
|
+ }else if(2 == jsCodType){//化验
|
|
|
+ jsCodVal = smartAdd.getJsCodHY();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Objects.isNull(jsLlType) && 1 == jsLlType){//仪表
|
|
|
+ jsLlVal = smartAdd.getJslYB();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //兜底处理
|
|
|
+ if(Objects.isNull(hycXsyVal))
|
|
|
+ hycXsyVal = BigDecimal.ZERO;
|
|
|
+ if(Objects.isNull(htfksd))
|
|
|
+ htfksd = BigDecimal.ZERO;
|
|
|
+ if(Objects.isNull(qycAdVal))
|
|
|
+ qycAdVal = BigDecimal.ZERO;
|
|
|
+ if(Objects.isNull(qycYxyVal))
|
|
|
+ qycYxyVal = BigDecimal.ZERO;
|
|
|
+ if(Objects.isNull(xzxs))
|
|
|
+ xzxs = BigDecimal.ZERO;
|
|
|
+ if(Objects.isNull(jzxs))
|
|
|
+ jzxs = BigDecimal.ZERO;
|
|
|
+ if(Objects.isNull(jsLlVal))
|
|
|
+ jsLlVal = BigDecimal.ZERO;
|
|
|
+ if(Objects.isNull(slfpxs))
|
|
|
+ slfpxs = BigDecimal.ZERO;
|
|
|
+ if(Objects.isNull(kzxs))
|
|
|
+ kzxs = BigDecimal.ZERO;
|
|
|
+ if(Objects.isNull(jsCodVal))
|
|
|
+ jsCodVal = BigDecimal.ZERO;
|
|
|
+ if(Objects.isNull(zhxs))
|
|
|
+ zhxs = BigDecimal.ZERO;
|
|
|
+ if(Objects.isNull(tydl))
|
|
|
+ tydl = BigDecimal.ZERO;
|
|
|
+ //1)计算挟走量
|
|
|
+ BigDecimal xzl = (((BigDecimal_2.multiply(hycXsyVal).subtract(htfksd)).add(((qycAdVal.add(qycYxyVal)).multiply(xzxs).subtract(htfksd)))).multiply((jzxs.subtract(BigDecimal_1)))).multiply((jsLlVal.multiply(slfpxs))).divide(BigDecimal_1000, NUMBER_SCALE_4, RoundingMode.HALF_UP);
|
|
|
+ //2)计算碳源投加总量
|
|
|
+ return (xzl.multiply(kzxs).subtract((jsLlVal.multiply(slfpxs).multiply(jsCodVal).multiply(zhxs).divide(BigDecimal_1000, NUMBER_SCALE_4, RoundingMode.HALF_UP)))).divide(tydl, NUMBER_SCALE_4, RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public String formatList(List<BigDecimal> list) {
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
return null;
|
|
@@ -2026,12 +2221,12 @@ public class RyTask
|
|
|
|
|
|
// System.out.println(new BigDecimal("1").compareTo(null));//空指针 要判断
|
|
|
|
|
|
- System.out.println("2022/01/01 10".substring(11));*/
|
|
|
+ System.out.println("2022/01/01 10".substring(11));
|
|
|
|
|
|
String date = DateUtil.format(DateUtils.getNowDate(), DateUtils.YYYY_MM_DD_HH);
|
|
|
System.out.println("date = " + date);
|
|
|
|
|
|
- System.out.println(HttpUtil.get("http://10.0.3.52:10003/system/forecast?type=2&time=" + date, 10));
|
|
|
+ System.out.println(HttpUtil.get("http://10.0.3.52:10003/system/forecast?type=2&time=" + date, 10));*/
|
|
|
|
|
|
System.out.println("2024-06-18 14".replaceAll("-", "/"));
|
|
|
|
|
@@ -2049,6 +2244,8 @@ public class RyTask
|
|
|
|
|
|
System.out.println("2024/07/07 12".substring(0, 7));
|
|
|
|
|
|
+ System.out.println(BigDecimal_0_1.multiply(null));
|
|
|
+
|
|
|
|
|
|
}
|
|
|
|