Browse Source

智能投药图表接口

王苗苗 7 months ago
parent
commit
a6cb73c0e4

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

@@ -433,6 +433,29 @@ public class FrontController extends BaseController {
     }
 
 
+    /**
+     * type说明:
+     * 0:进水流量
+     * 1:#1好氧池硝酸盐
+     * 2:#2好氧池硝酸盐
+     * 3:#1缺氧池氨氮
+     * 4:#2缺氧池氨氮
+     * 5:进水COD
+     * 6:进水总氮
+     * 7:碳源投加量
+     * 入股新增,则类型继续递增 已经优化,放入枚举
+     *
+     * @param type
+     * @return
+     */
+    @GetMapping("/bigModel/smartAdd/charList/{type}")
+    public AjaxResult smartAddCharList(@PathVariable int type)
+    {
+        log.info("进入了 智能投药系统获取对应指标最近3天的数据情况 接口");
+        return AjaxResult.success(frontService.smartAddCharList(type));
+    }
+
+
     //--------------------下面是测试的方法--------------------
     /*@GetMapping("/test/data")
     public void testData(){

+ 84 - 0
slibra-common/src/main/java/com/slibra/common/enums/BusinessEnum.java

@@ -253,4 +253,88 @@ public class BusinessEnum {
             return msg;
         }
     }
+
+
+
+    /**
+     *
+     * 智能投药请求参数枚举
+     *      * 0:进水流量
+     *      * 1:#1好氧池硝酸盐
+     *      * 2:#2好氧池硝酸盐
+     *      * 3:#1缺氧池氨氮
+     *      * 4:#2缺氧池氨氮
+     *      * 5:进水COD
+     *      * 6:进水总氮
+     *      * 7:碳源投加量
+     *
+     */
+    public enum SmartAddMedicineReqEnum
+    {
+        JSLL(0, "进水流量"),
+        HY_1_XSY(1, "#1好氧池硝酸盐"),
+        HY_2_XSY(2, "#2好氧池硝酸盐"),
+        QY_1_AD(3, "#1缺氧池氨氮"),
+        QY_2_AD(4, "#2缺氧池氨氮"),
+        JSCOD(5, "进水COD"),
+        JSTN(6, "进水总氮"),
+        TYTJL(7, "碳源投加量"),
+
+
+        ;
+
+        private final int code;
+        private final String msg;
+
+        SmartAddMedicineReqEnum(int code, String msg)
+        {
+            this.code = code;
+            this.msg = msg;
+        }
+
+        public int getCode()
+        {
+            return code;
+        }
+
+        public String getMsg()
+        {
+            return msg;
+        }
+    }
+
+
+    /**
+     *
+     * 数据来源枚举
+     *
+     */
+    public enum DataSourceEnum
+    {
+        YB("YB", "仪表"),
+        HY("HY", "化验"),
+        YC("YC", "预测"),
+
+
+        ;
+
+        private final String code;
+        private final String msg;
+
+        DataSourceEnum(String code, String msg)
+        {
+            this.code = code;
+            this.msg = msg;
+        }
+
+        public String getCode()
+        {
+            return code;
+        }
+
+        public String getMsg()
+        {
+            return msg;
+        }
+    }
 }

+ 4 - 0
slibra-system/src/main/java/com/slibra/business/mapper/TXinyiForecastComparisonMapper.java

@@ -1,7 +1,9 @@
 package com.slibra.business.mapper;
 
+import java.util.Date;
 import java.util.List;
 import com.slibra.business.domain.TXinyiForecastComparison;
+import com.slibra.business.res.ChartBasic;
 
 /**
  * 信义预测对比Mapper接口
@@ -60,4 +62,6 @@ public interface TXinyiForecastComparisonMapper
     public int deleteTXinyiForecastComparisonByIds(Long[] ids);
 
     TXinyiForecastComparison selectNewestForecastComparison(String category);
+
+    List<ChartBasic> selectOneValAndTimeByDate(String category);
 }

+ 9 - 1
slibra-system/src/main/java/com/slibra/business/mapper/TXinyiIndustryMapper.java

@@ -5,6 +5,7 @@ import java.util.HashMap;
 import java.util.List;
 
 import com.slibra.business.domain.TXinyiIndustry;
+import com.slibra.business.res.ChartBasic;
 import com.slibra.common.core.domain.DecisionReq;
 import org.apache.ibatis.annotations.Param;
 
@@ -88,10 +89,17 @@ public interface TXinyiIndustryMapper
     /**
      * 查询信义工业数据
      *
-     * @param null
      * @return 总条数
      */
     int getCount();
 
     List<TXinyiIndustry> selectTXinyiIndustryListByPage(@Param("start")  int i, @Param("end")  int size);
+
+    List<ChartBasic> selectJSLByDate(@Param("start") String dayBefore3Str, @Param("end") String nowDateStr);
+
+    List<ChartBasic> selectJsCodByDate(@Param("start") String dayBefore3Str, @Param("end") String nowDateStr);
+
+    List<ChartBasic> selectJsTnByDate(@Param("start") String dayBefore3Str, @Param("end") String nowDateStr);
+
+    List<ChartBasic> selectTytzjlByDate(@Param("start") String dayBefore3Str, @Param("end") String nowDateStr);
 }

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

@@ -5,6 +5,8 @@ import java.util.List;
 
 import com.slibra.business.domain.TXinyiLaboratory;
 import com.slibra.business.domain.TXinyiRobot;
+import com.slibra.business.res.ChartBasic;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 信义化验数据Mapper接口
@@ -75,4 +77,14 @@ public interface TXinyiRobotMapper
     TXinyiRobot selectTXinyiRobotByAvg(TXinyiRobot tXinyiRobot);
 
     List<HashMap<String, Object>> selectAvg7Datas();
+
+    List<ChartBasic> selectXSY1ByDate(@Param("start") String dayBefore3Str, @Param("end") String nowDateStr);
+
+    List<ChartBasic> selectXSY2ByDate(@Param("start") String dayBefore3Str, @Param("end") String nowDateStr);
+
+    List<ChartBasic> selectAD1ByDate(@Param("start") String dayBefore3Str, @Param("end") String nowDateStr);
+
+    List<ChartBasic> selectAD2ByDate(@Param("start") String dayBefore3Str, @Param("end") String nowDateStr);
+
+    List<ChartBasic> selectCodByDate(@Param("start") String dayBefore3Str, @Param("end") String nowDateStr);
 }

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

@@ -6,12 +6,10 @@ 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.SmartAdd;
-import com.slibra.business.res.WorkOrderRes;
-import com.slibra.business.res.XinyiDailyFeeSimple;
-import com.slibra.business.res.XinyiIndustrySimple;
+import com.slibra.business.res.*;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * 信义日报数据Service接口
@@ -51,4 +49,6 @@ public interface IFrontService
     String stopChat(String sessionId);
 
     SmartAdd smartAddDataInfo();
+
+    Map<String, List<ChartBasic>> smartAddCharList(int type);
 }

+ 60 - 4
slibra-system/src/main/java/com/slibra/business/service/impl/FrontServiceImpl.java

@@ -6,10 +6,7 @@ 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.SmartAdd;
-import com.slibra.business.res.WorkOrderRes;
-import com.slibra.business.res.XinyiDailyFeeSimple;
-import com.slibra.business.res.XinyiIndustrySimple;
+import com.slibra.business.res.*;
 import com.slibra.business.service.IFrontService;
 import com.slibra.common.DecimalUtils;
 import com.slibra.common.core.domain.TXinyiDaily;
@@ -432,6 +429,65 @@ public class FrontServiceImpl implements IFrontService {
         return build;
     }
 
+    @Override
+    public Map<String, List<ChartBasic>> smartAddCharList(int type) {
+        //日期兜底处理
+        Date nowDate = DateUtils.getNowDate();
+        Date dayBefore7 = DateUtils.plusDate(-3, nowDate);
+        //先用日期获取当天和前一天的数据,如果获取不到,则提示错误信息
+        String nowDateStr = DateUtils.parseDateToStr(DateUtils.YYYYMMDD_TS, nowDate);
+        String dayBefore3Str = DateUtils.parseDateToStr(DateUtils.YYYYMMDD_TS, dayBefore7);
+        //返回的对象
+        Map<String, List<ChartBasic>> result = new HashMap<>();
+        List<ChartBasic> list = new ArrayList<>();
+        //先判断类型,然后根据不同类型,查询不同的数据
+        if(BusinessEnum.SmartAddMedicineReqEnum.JSLL.getCode() == type){
+            //查询仪表即可
+            list = this.xinyiIndustryMapper.selectJSLByDate(dayBefore3Str, nowDateStr);
+            result.put(BusinessEnum.DataSourceEnum.YB.getCode(), list);
+        }else if(BusinessEnum.SmartAddMedicineReqEnum.HY_1_XSY.getCode() == type){
+            //查询化验室
+            list = this.xinyiRobotMapper.selectXSY1ByDate(dayBefore3Str, nowDateStr);
+            result.put(BusinessEnum.DataSourceEnum.HY.getCode(), list);
+            //查询预测
+            list = this.xinyiForecastComparisonMapper.selectOneValAndTimeByDate(BusinessEnum.BigModelForecastEnum.XSY1.getCode());//SQL中处理日期 否则索引失效
+            result.put(BusinessEnum.DataSourceEnum.YC.getCode(), list);
+        }else if(BusinessEnum.SmartAddMedicineReqEnum.HY_2_XSY.getCode() == type){
+            //查询化验室
+            list = this.xinyiRobotMapper.selectXSY2ByDate(dayBefore3Str, nowDateStr);
+            result.put(BusinessEnum.DataSourceEnum.HY.getCode(), list);
+            //查询预测
+            list = this.xinyiForecastComparisonMapper.selectOneValAndTimeByDate(BusinessEnum.BigModelForecastEnum.XSY2.getCode());//SQL中处理日期 否则索引失效
+            result.put(BusinessEnum.DataSourceEnum.YC.getCode(), list);
+        }else if(BusinessEnum.SmartAddMedicineReqEnum.QY_1_AD.getCode() == type){
+            //查询化验室
+            list = this.xinyiRobotMapper.selectAD1ByDate(dayBefore3Str, nowDateStr);
+            result.put(BusinessEnum.DataSourceEnum.HY.getCode(), list);
+        }else if(BusinessEnum.SmartAddMedicineReqEnum.QY_2_AD.getCode() == type){
+            //查询化验室
+            list = this.xinyiRobotMapper.selectAD2ByDate(dayBefore3Str, nowDateStr);
+            result.put(BusinessEnum.DataSourceEnum.HY.getCode(), list);
+        }else if(BusinessEnum.SmartAddMedicineReqEnum.JSCOD.getCode() == type){
+            //查询仪表即可
+            list = this.xinyiIndustryMapper.selectJsCodByDate(dayBefore3Str, nowDateStr);
+            result.put(BusinessEnum.DataSourceEnum.YB.getCode(), list);
+            //查询化验室
+            list = this.xinyiRobotMapper.selectCodByDate(dayBefore3Str, nowDateStr);
+            result.put(BusinessEnum.DataSourceEnum.HY.getCode(), list);
+        }else if(BusinessEnum.SmartAddMedicineReqEnum.JSTN.getCode() == type){
+            //查询仪表即可
+            list = this.xinyiIndustryMapper.selectJsTnByDate(dayBefore3Str, nowDateStr);
+            result.put(BusinessEnum.DataSourceEnum.YB.getCode(), list);
+        }else if(BusinessEnum.SmartAddMedicineReqEnum.TYTJL.getCode() == type){
+            //查询仪表即可
+            list = this.xinyiIndustryMapper.selectTytzjlByDate(dayBefore3Str, nowDateStr);
+            result.put(BusinessEnum.DataSourceEnum.YB.getCode(), list);
+        }else{
+            log.info("暂不支持的类型~~~");
+        }
+        return result;
+    }
+
     private void buildIndustryData(TXinyiIndustry industry, WorkOrderRes workOrderRes, WorkOrderReq workOrderReq) {
         if(workOrderReq.getJsSlq())
             workOrderRes.setJsSlq(DecimalUtils.getAbsAndScale(industry.getJsSlq(), 2));

+ 11 - 0
slibra-system/src/main/resources/mapper/business/TXinyiForecastComparisonMapper.xml

@@ -218,4 +218,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectTXinyiForecastComparisonVo"/>
         where category = #{category} and del_flag = 0 order by id desc limit 1,1
     </select>
+
+    <select id="selectOneValAndTimeByDate" resultType="com.slibra.business.res.ChartBasic">
+        SELECT
+            remark time,
+	        hs_forecast_one val
+        FROM
+            t_xinyi_forecast_comparison
+        WHERE category = #{category} and
+            create_time >= CURDATE() - INTERVAL 3 DAY
+        ORDER BY ID ASC
+    </select>
 </mapper>

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

@@ -541,4 +541,53 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         ORDER BY id LIMIT #{start}, #{end}
     </select>
 
+    <select id="selectJSLByDate" resultType="com.slibra.business.res.ChartBasic">
+        SELECT
+            TEST_HOUR time,
+	        JS_SLQ val
+        FROM
+            t_xinyi_industry
+        WHERE
+            TEST_DATE BETWEEN #{start} AND #{end}
+        ORDER BY
+            ID ASC
+    </select>
+
+
+    <select id="selectJsCodByDate" resultType="com.slibra.business.res.ChartBasic">
+        SELECT
+            TEST_HOUR time,
+	        JS_COD val
+        FROM
+            t_xinyi_industry
+        WHERE
+            TEST_DATE BETWEEN #{start} AND #{end}
+        ORDER BY
+            ID ASC
+    </select>
+
+    <select id="selectJsTnByDate" resultType="com.slibra.business.res.ChartBasic">
+        SELECT
+            TEST_HOUR time,
+	        JS_TN val
+        FROM
+            t_xinyi_industry
+        WHERE
+            TEST_DATE BETWEEN #{start} AND #{end}
+        ORDER BY
+            ID ASC
+    </select>
+
+
+    <select id="selectTytzjlByDate" resultType="com.slibra.business.res.ChartBasic">
+        SELECT
+            TEST_HOUR time,
+	        SJTYJLY val
+        FROM
+            t_xinyi_industry
+        WHERE
+            TEST_DATE BETWEEN #{start} AND #{end}
+        ORDER BY
+            ID ASC
+    </select>
 </mapper>

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

@@ -305,4 +305,65 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             TEST_DATE LIMIT 1,7
     </select>
 
+    <select id="selectXSY1ByDate" resultType="com.slibra.business.res.ChartBasic">
+        SELECT
+            TEST_HOUR time,
+	        NO3_HLJ1_JQR val
+        FROM
+            t_xinyi_robot
+        WHERE
+            TEST_DATE BETWEEN #{start} AND #{end}
+        ORDER BY
+            ID ASC
+    </select>
+
+
+    <select id="selectXSY2ByDate" resultType="com.slibra.business.res.ChartBasic">
+        SELECT
+            TEST_HOUR time,
+	        NO3_HLJ2_JQR val
+        FROM
+            t_xinyi_robot
+        WHERE
+            TEST_DATE BETWEEN #{start} AND #{end}
+        ORDER BY
+            ID ASC
+    </select>
+
+    <select id="selectAD1ByDate" resultType="com.slibra.business.res.ChartBasic">
+        SELECT
+            TEST_HOUR time,
+	        NH3_1_JQR val
+        FROM
+            t_xinyi_robot
+        WHERE
+            TEST_DATE BETWEEN #{start} AND #{end}
+        ORDER BY
+            ID ASC
+    </select>
+
+    <select id="selectAD2ByDate" resultType="com.slibra.business.res.ChartBasic">
+        SELECT
+            TEST_HOUR time,
+	        NH3_2_JQR val
+        FROM
+            t_xinyi_robot
+        WHERE
+            TEST_DATE BETWEEN #{start} AND #{end}
+        ORDER BY
+            ID ASC
+    </select>
+
+
+    <select id="selectCodByDate" resultType="com.slibra.business.res.ChartBasic">
+        SELECT
+            TEST_HOUR time,
+	         COD_JQR val
+        FROM
+            t_xinyi_robot
+        WHERE
+            TEST_DATE BETWEEN #{start} AND #{end}
+        ORDER BY
+            ID ASC
+    </select>
 </mapper>