wangmiaomiao hai 9 meses
pai
achega
85fd6ce2ab

+ 16 - 0
slibra-admin/src/main/java/com/slibra/web/controller/business/FrontController.java

@@ -6,6 +6,7 @@ import com.slibra.business.domain.TXinyiChatRecord;
 import com.slibra.business.domain.TXinyiWarningRecord;
 import com.slibra.business.mapper.*;
 import com.slibra.business.req.ChatReq;
+import com.slibra.business.req.WorkOrderReq;
 import com.slibra.business.service.IFrontService;
 import com.slibra.common.core.controller.BaseController;
 import com.slibra.common.core.domain.AjaxResult;
@@ -329,6 +330,21 @@ public class FrontController extends BaseController {
     }
 
 
+
+
+
+    /**
+     * 自定义工单接口 获取数据接口
+     * @return
+     */
+    @GetMapping("/bigModel/custom/workOrder")
+    public AjaxResult customWorkOrder(@RequestBody WorkOrderReq workOrderReq)
+    {
+        log.info("进入了 自定义工单接口 获取数据接口 接口");
+        return AjaxResult.success(frontService.customWorkOrder(workOrderReq));
+    }
+
+
     //--------------------下面是测试的方法--------------------
     /*@GetMapping("/test/data")
     public void testData(){

+ 17 - 0
slibra-common/src/main/java/com/slibra/common/utils/DateUtils.java

@@ -8,8 +8,12 @@ import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.List;
+
 import org.apache.commons.lang3.time.DateFormatUtils;
 
 /**
@@ -223,6 +227,19 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     }
 
 
+    public static List<String> getAllDatesBetween(LocalDate startDate, LocalDate endDate) {
+        List<String> dates = new ArrayList<>();
+        LocalDate currentDate = startDate;
+
+        while (!currentDate.isAfter(endDate)) {
+            dates.add(currentDate.format(DateTimeFormatter.ofPattern(DateUtils.YYYYMMDD_TS)));
+            currentDate = currentDate.plusDays(1);
+        }
+
+        return dates;
+    }
+
+
     public static void main(String[] args) {
         Date nowDate = DateUtils.getNowDate();
         Date date = plusDate(1, nowDate);

+ 2 - 0
slibra-system/src/main/java/com/slibra/business/mapper/TXinyiIndustryMapper.java

@@ -82,4 +82,6 @@ public interface TXinyiIndustryMapper
     TXinyiIndustry selectTXinyiIndustryNewest();
 
     List<TXinyiIndustry> selectNIndustry(int size);
+
+    TXinyiIndustry selectIndustryAvgByDate(String date);
 }

+ 2 - 0
slibra-system/src/main/java/com/slibra/business/mapper/TXinyiRobotMapper.java

@@ -66,4 +66,6 @@ public interface TXinyiRobotMapper
     TXinyiRobot selectNewest();
 
     List<TXinyiRobot> selectNRobot(int size);
+
+    TXinyiRobot selectRebotAvgByDate(String date);
 }

+ 93 - 0
slibra-system/src/main/java/com/slibra/business/req/WorkOrderReq.java

@@ -0,0 +1,93 @@
+package com.slibra.business.req;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.slibra.business.domain.TXinyiChatRecord;
+import com.slibra.common.annotation.Excel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.time.LocalDate;
+import java.util.Date;
+
+
+@Builder
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class WorkOrderReq {
+
+
+    /**  开始时间 */
+//    @JsonFormat(pattern = "yyyy-MM-dd")
+    private String timeBegin;
+
+    /** 截止时间 */
+//    @JsonFormat(pattern = "yyyy-MM-dd")
+    private String timeEnd;
+
+    private int type;//统计方式  0:日报  1:工业库(在线仪表)
+
+    /** 进水水量Q进 */
+    private Boolean jsSlq;
+
+    /** 进水化学需氧量COD */
+    private Boolean jsCod;
+
+    /** 进水总氮TN */
+    private Boolean jsTn;
+
+    /** 进水总磷TP */
+    private Boolean jsTp;
+
+    /** 进水氨氮NH₃-N */
+    private Boolean jsNh3;
+
+    /** 进水悬浮物SS */
+    private Boolean jsSs;
+
+
+    /** 出水水量Q出 */
+    private Boolean csSlqc;
+
+    /** 出水化学需氧量COD */
+    private Boolean csCod;
+
+    /** 出水总氮TN */
+    private Boolean csTn;
+
+    /** 出水总磷TP */
+    private Boolean csTp;
+
+    /** 出水氨氮NH₃-N */
+    private Boolean csNh3;
+
+    /** 出水悬浮物SS */
+    private Boolean csSs;
+
+    /** 1#好氧池硝酸盐(内回流)+ 回流进水化验机器人有效值1(硝氮1池回流机器人) */
+    private Boolean no3Hlj1Jqr;
+
+    /** 2#好氧池硝酸盐(内回流) + 回流进水化验机器人有效值2(硝氮2池回流机器人) */
+    private Boolean no3Hlj2Jqr;
+
+    /** 1#缺氧氨氮 + 化验机器人氨氮化验有效值1(氨氮1池缺氧机器人) */
+    private Boolean nh31Jqr;
+
+    /** 2#缺氧氨氮 + 化验机器人氨氮化验有效值2(氨氮2池缺氧机器人) */
+    private Boolean nh32Jqr;
+
+    /** 1#缺氧出口硝酸盐 + 缺氧出水化验机器人有效值1(硝氮1池缺氧机器人) */
+    private Boolean no3Qyc1Jqr;
+
+    /** 2#缺氧出-硝酸盐 + 缺氧出水化验机器人有效值2(硝氮2池缺氧机器人) */
+    private Boolean no3Qyc2Jqr;
+
+    /** 二沉池-正磷酸盐 + 化验机器人正磷化验有效值二沉池(正磷二沉池机器人) */
+    private Boolean tpRccJqr;
+
+
+
+
+}

+ 83 - 0
slibra-system/src/main/java/com/slibra/business/res/WorkOrderRes.java

@@ -0,0 +1,83 @@
+package com.slibra.business.res;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.math.BigDecimal;
+
+@Builder
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class WorkOrderRes {
+
+
+    //日期
+    private String time;
+
+    /** 进水水量Q进 */
+    private BigDecimal jsSlq;
+
+    /** 进水化学需氧量COD */
+    private BigDecimal jsCod;
+
+    /** 进水总氮TN */
+    private BigDecimal jsTn;
+
+    /** 进水总磷TP */
+    private BigDecimal jsTp;
+
+    /** 进水氨氮NH₃-N */
+    private BigDecimal jsNh3;
+
+    /** 进水悬浮物SS */
+    private BigDecimal jsSs;
+
+
+    /** 出水水量Q出 */
+    private BigDecimal csSlqc;
+
+    /** 出水化学需氧量COD */
+    private BigDecimal csCod;
+
+    /** 出水总氮TN */
+    private BigDecimal csTn;
+
+    /** 出水总磷TP */
+    private BigDecimal csTp;
+
+    /** 出水氨氮NH₃-N */
+    private BigDecimal csNh3;
+
+    /** 出水悬浮物SS */
+    private BigDecimal csSs;
+
+    /** 1#好氧池硝酸盐(内回流)+ 回流进水化验机器人有效值1(硝氮1池回流机器人) */
+    private BigDecimal no3Hlj1Jqr;
+
+    /** 2#好氧池硝酸盐(内回流) + 回流进水化验机器人有效值2(硝氮2池回流机器人) */
+    private BigDecimal no3Hlj2Jqr;
+
+    /** 1#缺氧氨氮 + 化验机器人氨氮化验有效值1(氨氮1池缺氧机器人) */
+    private BigDecimal nh31Jqr;
+
+    /** 2#缺氧氨氮 + 化验机器人氨氮化验有效值2(氨氮2池缺氧机器人) */
+    private BigDecimal nh32Jqr;
+
+    /** 1#缺氧出口硝酸盐 + 缺氧出水化验机器人有效值1(硝氮1池缺氧机器人) */
+    private BigDecimal no3Qyc1Jqr;
+
+    /** 2#缺氧出-硝酸盐 + 缺氧出水化验机器人有效值2(硝氮2池缺氧机器人) */
+    private BigDecimal no3Qyc2Jqr;
+
+    /** 二沉池-正磷酸盐 + 化验机器人正磷化验有效值二沉池(正磷二沉池机器人) */
+    private BigDecimal tpRccJqr;
+
+
+
+
+
+}

+ 4 - 0
slibra-system/src/main/java/com/slibra/business/service/IFrontService.java

@@ -4,6 +4,8 @@ import com.slibra.business.domain.TXinyiChatRecord;
 import com.slibra.business.domain.TXinyiRecommendQa;
 import com.slibra.business.domain.TXinyiWarningRecord;
 import com.slibra.business.req.ChatReq;
+import com.slibra.business.req.WorkOrderReq;
+import com.slibra.business.res.WorkOrderRes;
 import com.slibra.business.res.XinyiDailyFeeSimple;
 import com.slibra.business.res.XinyiIndustrySimple;
 
@@ -37,4 +39,6 @@ public interface IFrontService
     List<TXinyiChatRecord> forecastList(String warningId);
 
     XinyiDailyFeeSimple recentlyOneFeeInfo();
+
+    List<WorkOrderRes> customWorkOrder(WorkOrderReq workOrderReq);
 }

+ 130 - 1
slibra-system/src/main/java/com/slibra/business/service/impl/FrontServiceImpl.java

@@ -7,12 +7,15 @@ import com.alibaba.fastjson2.JSONArray;
 import com.slibra.business.domain.*;
 import com.slibra.business.mapper.*;
 import com.slibra.business.req.ChatReq;
+import com.slibra.business.req.WorkOrderReq;
+import com.slibra.business.res.WorkOrderRes;
 import com.slibra.business.res.XinyiDailyFeeSimple;
 import com.slibra.business.res.XinyiIndustrySimple;
 import com.slibra.business.service.IFrontService;
 import com.slibra.common.exception.ServiceException;
 import com.slibra.common.utils.DateUtils;
 import com.slibra.common.utils.SecurityUtils;
+import com.slibra.common.utils.StringUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,6 +24,7 @@ import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
@@ -28,6 +32,7 @@ import java.util.concurrent.atomic.AtomicReference;
 
 import static com.slibra.common.constant.MyConstants.FORECAST_WARNING_TEMPLATE;
 import static com.slibra.common.constant.MyConstants.WARNING_TEMPLATE;
+import static com.slibra.common.utils.DateUtils.getAllDatesBetween;
 
 
 @Service
@@ -102,7 +107,7 @@ public class FrontServiceImpl implements IFrontService {
     @Override
     public TXinyiChatRecord qaDetailByWarningId(String warningId) {
         //2024年5月28日19:10:21 只获取决策的 因为决策和仿真预测是一个接口,所以通过类型区分
-        List<TXinyiChatRecord> tXinyiChatRecords = this.xinyiChatRecordMapper.selectTXinyiChatRecordList(TXinyiChatRecord.builder().warningId(warningId).type(1).build());
+        List<TXinyiChatRecord> tXinyiChatRecords = this.xinyiChatRecordMapper.selectTXinyiChatRecordList(TXinyiChatRecord.builder().warningId(warningId).build());
         return CollectionUtils.isEmpty(tXinyiChatRecords) ? null : tXinyiChatRecords.get(0);
     }
 
@@ -157,6 +162,126 @@ public class FrontServiceImpl implements IFrontService {
         return xinyiDailyFeeSimple;
     }
 
+
+    /**
+     * 自定义工单接口 获取数据接口
+     * @param workOrderReq
+     * @return
+     */
+    @Override
+    public List<WorkOrderRes> customWorkOrder(WorkOrderReq workOrderReq) {
+        checkCustomWorkOrder(workOrderReq);
+        //两个日期之间所有的时间-天
+        List<String> allDatesBetween = getAllDatesBetween(LocalDate.parse(workOrderReq.getTimeBegin()), LocalDate.parse(workOrderReq.getTimeEnd()));
+        //返回结果
+        List<WorkOrderRes> result = new ArrayList<>(allDatesBetween.size());
+        for (String date : allDatesBetween) {
+            //查询机器人数据
+            WorkOrderRes workOrderRes = new WorkOrderRes();
+            workOrderRes.setTime(date);
+            TXinyiRobot xinyiRobot = this.xinyiRobotMapper.selectRebotAvgByDate(date);
+            if(!Objects.isNull(xinyiRobot))
+                this.buildRobotData(xinyiRobot, workOrderRes, workOrderReq);
+            //判断数据来源(进出水情况)
+            if(workOrderReq.getType() == 0){// 0:日报  1:工业库(在线仪表)
+                List<TXinyiDaily> tXinyiDailies = this.xinyiDailyMapper.selectTXinyiDailyList(TXinyiDaily.builder().testDate(date).build());
+                if(!CollectionUtils.isEmpty(tXinyiDailies)){
+                    TXinyiDaily tXinyiDaily = tXinyiDailies.get(0);
+                    this.buildDailyData(tXinyiDaily, workOrderRes, workOrderReq);
+                }
+            }else {
+                TXinyiIndustry industry = this.xinyiIndustryMapper.selectIndustryAvgByDate(date);
+                if(!Objects.isNull(industry))
+                    this.buildIndustryData(industry, workOrderRes, workOrderReq);
+            }
+            result.add(workOrderRes);
+        }
+        return result;
+    }
+
+    private void buildIndustryData(TXinyiIndustry industry, WorkOrderRes workOrderRes, WorkOrderReq workOrderReq) {
+        if(workOrderReq.getJsSlq())
+            workOrderRes.setJsSlq(industry.getJsSlq());
+        if(workOrderReq.getJsCod())
+            workOrderRes.setJsCod(industry.getJsCod());
+        if(workOrderReq.getJsTn())
+            workOrderRes.setJsTn(industry.getJsTn());
+        if(workOrderReq.getJsTp())
+            workOrderRes.setJsTp(industry.getJsTp());
+        if(workOrderReq.getJsNh3())
+            workOrderRes.setJsNh3(industry.getJsNh3());
+        if(workOrderReq.getJsSs())
+            workOrderRes.setJsSs(industry.getJsSs());
+        if(workOrderReq.getCsSlqc())
+            workOrderRes.setCsSlqc(industry.getCsSlqc());
+        if(workOrderReq.getCsCod())
+            workOrderRes.setCsCod(industry.getCsCod());
+        if(workOrderReq.getCsTn())
+            workOrderRes.setCsTn(industry.getCsTn());
+        if(workOrderReq.getCsTp())
+            workOrderRes.setCsTp(industry.getCsTp());
+        if(workOrderReq.getCsNh3())
+            workOrderRes.setCsNh3(industry.getCsNh3());
+        if(workOrderReq.getCsSs())
+            workOrderRes.setCsSs(industry.getCsSs());
+    }
+
+    private void buildDailyData(TXinyiDaily tXinyiDaily, WorkOrderRes workOrderRes, WorkOrderReq workOrderReq) {
+        if(workOrderReq.getJsSlq())
+            workOrderRes.setJsSlq(tXinyiDaily.getJSL());
+        if(workOrderReq.getJsCod())
+            workOrderRes.setJsCod(tXinyiDaily.getJsCod());
+        if(workOrderReq.getJsTn())
+            workOrderRes.setJsTn(tXinyiDaily.getJsTn());
+        if(workOrderReq.getJsTp())
+            workOrderRes.setJsTp(tXinyiDaily.getJsTp());
+        if(workOrderReq.getJsNh3())
+            workOrderRes.setJsNh3(tXinyiDaily.getJsNh3());
+        if(workOrderReq.getJsSs())
+            workOrderRes.setJsSs(tXinyiDaily.getJsSs());
+        if(workOrderReq.getCsSlqc())
+            workOrderRes.setCsSlqc(tXinyiDaily.getCSL());
+        if(workOrderReq.getCsCod())
+            workOrderRes.setCsCod(tXinyiDaily.getCsCod());
+        if(workOrderReq.getCsTn())
+            workOrderRes.setCsTn(tXinyiDaily.getCsTn());
+        if(workOrderReq.getCsTp())
+            workOrderRes.setCsTp(tXinyiDaily.getCsTp());
+        if(workOrderReq.getCsNh3())
+            workOrderRes.setCsNh3(tXinyiDaily.getCsNh3());
+        if(workOrderReq.getCsSs())
+            workOrderRes.setCsSs(tXinyiDaily.getCsSs());
+    }
+
+    private void buildRobotData(TXinyiRobot xinyiRobot, WorkOrderRes workOrderRes, WorkOrderReq workOrderReq) {
+        if(workOrderReq.getNo3Hlj1Jqr())
+            workOrderRes.setNo3Hlj1Jqr(xinyiRobot.getNo3Hlj1Jqr());
+        if(workOrderReq.getNo3Hlj2Jqr())
+            workOrderRes.setNo3Hlj2Jqr(xinyiRobot.getNo3Hlj2Jqr());
+        if(workOrderReq.getNh31Jqr())
+            workOrderRes.setNh31Jqr(xinyiRobot.getNh31Jqr());
+        if(workOrderReq.getNh32Jqr())
+            workOrderRes.setNh32Jqr(xinyiRobot.getNh32Jqr());
+        if(workOrderReq.getNo3Qyc1Jqr())
+            workOrderRes.setNo3Qyc1Jqr(xinyiRobot.getNo3Qyc1Jqr());
+        if(workOrderReq.getNo3Qyc2Jqr())
+            workOrderRes.setNo3Qyc2Jqr(xinyiRobot.getNo3Qyc2Jqr());
+        if(workOrderReq.getTpRccJqr())
+            workOrderRes.setTpRccJqr(xinyiRobot.getTpRccJqr());
+    }
+
+    private void checkCustomWorkOrder(WorkOrderReq workOrderReq) {
+        if(StringUtils.isBlank(workOrderReq.getTimeBegin()) || StringUtils.isBlank(workOrderReq.getTimeEnd()))
+            throw new ServiceException("输入的参数不合法");
+    }
+
+
+    /***
+     * 将工业库数据计算出结果
+     * @param xinyiIndustrySimple
+     * @param nowTime
+     * @return
+     */
     private XinyiIndustrySimple calculateData(XinyiIndustrySimple xinyiIndustrySimple, LocalDateTime nowTime) {
         LocalDateTime yesterdaySameTime = nowTime.plusDays(-1);
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DateUtils.YYYYMMDDHH_TS);
@@ -397,5 +522,9 @@ public class FrontServiceImpl implements IFrontService {
         LocalDateTime begin = endTime.plusMinutes(-1);
         System.out.println(formatter.format(endTime));
         System.out.println(formatter.format(begin));
+
+        LocalDate parse = LocalDate.parse("2024-02-26");
+        System.out.println("parse = " + parse);
+
     }
 }

+ 1 - 10
slibra-system/src/main/java/com/slibra/business/service/impl/TXinyiDailyServiceImpl.java

@@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import static com.slibra.common.constant.MyConstants.DAILY_RECORDS_TOTAL;
+import static com.slibra.common.utils.DateUtils.getAllDatesBetween;
 
 /**
  * 信义日报数据Service业务层处理
@@ -187,15 +188,5 @@ public class TXinyiDailyServiceImpl implements ITXinyiDailyService
     }
 
 
-    private static List<String> getAllDatesBetween(LocalDate startDate, LocalDate endDate) {
-        List<String> dates = new ArrayList<>();
-        LocalDate currentDate = startDate;
 
-        while (!currentDate.isAfter(endDate)) {
-            dates.add(currentDate.format(DateTimeFormatter.ofPattern(DateUtils.YYYYMMDD_TS)));
-            currentDate = currentDate.plusDays(1);
-        }
-
-        return dates;
-    }
 }

+ 20 - 0
slibra-system/src/main/resources/mapper/business/TXinyiIndustryMapper.xml

@@ -524,4 +524,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectTXinyiIndustryVo"/>
         order by id desc limit #{size}
     </select>
+
+    <select id="selectIndustryAvgByDate" resultMap="TXinyiIndustryResult">
+        SELECT
+            AVG(JS_SLQ) jsSlq,
+            AVG(JS_COD) jsCod,
+            AVG(JS_TN) jsTn,
+            AVG(JS_TP) jsTp,
+            AVG(JS_NH3) jsNh3,
+            AVG(JS_SS) jsSs,
+            AVG(CS_SLQC) csSlqc,
+            AVG(CS_COD) csCod,
+            AVG(CS_TN) csTn,
+            AVG(CS_TP) csTp,
+            AVG(CS_NH3) csNh3,
+            AVG(CS_SS) csSs
+        FROM
+            t_xinyi_industry
+        WHERE
+            TEST_DATE = #{date}
+    </select>
 </mapper>

+ 15 - 0
slibra-system/src/main/resources/mapper/business/TXinyiRobotMapper.xml

@@ -244,4 +244,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectNRobot" resultMap="TXinyiRobotResult">
         <include refid="selectTXinyiRobotVo"/> order by id desc limit #{size}
     </select>
+
+    <select id="selectRebotAvgByDate" resultMap="TXinyiRobotResult">
+        SELECT
+            AVG(NO3_HLJ1_JQR) no3Hlj1Jqr,
+            AVG(NO3_HLJ2_JQR) no3Hlj2Jqr,
+            AVG(NH3_1_JQR) nh31Jqr,
+            AVG(NH3_2_JQR) nh32Jqr,
+            AVG(NO3_QYC_1_JQR) no3Qyc1Jqr,
+            AVG(NO3_QYC_2_JQR) no3Qyc2Jqr,
+            AVG(TP_RCC_JQR) tpRccJqr
+        FROM
+            t_xinyi_robot
+        WHERE
+            TEST_DATE = #{date}
+    </select>
 </mapper>