소스 검색

模拟组态返回 碳源投加开关控制 碳源相关的2个接口增加自定义日期处理和默认兜底日期处理

王苗苗 6 달 전
부모
커밋
9af61d3dcd

+ 37 - 3
slibra-admin/src/main/java/com/slibra/web/controller/business/FrontController.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson2.JSONWriter;
 import com.github.pagehelper.PageInfo;
 import com.slibra.business.domain.TXinyiCarbonMajor;
 import com.slibra.business.domain.TXinyiChatRecord;
+import com.slibra.business.domain.TXinyiMedicineConf;
 import com.slibra.business.domain.TXinyiWarningRecord;
 import com.slibra.business.mapper.*;
 import com.slibra.business.req.ChatReq;
@@ -75,6 +76,9 @@ public class FrontController extends BaseController {
     @Autowired
     private ITXinyiCarbonMajorService tXinyiCarbonMajorService;
 
+    @Autowired
+    private TXinyiMedicineConfMapper xinyiMedicineConfMapper;
+
 
 
     /**
@@ -463,19 +467,49 @@ public class FrontController extends BaseController {
      * 5:进水COD
      * 6:进水总氮
      * 7:碳源投加量
-     * 入股新增,则类型继续递增 已经优化,放入枚举
+     *
      *
      * @param type
      * @return
      */
     @GetMapping("/bigModel/smartAdd/charList/{type}")
-    public AjaxResult smartAddCharList(@PathVariable int type)
+    public AjaxResult smartAddCharList(@PathVariable int type, @RequestParam(required = false, name = "timeBegin") String timeBegin, @RequestParam(required = false, name = "timeBegin") String timeEnd)
     {
         log.info("进入了 智能投药系统获取对应指标最近3天的数据情况 接口");
-        return AjaxResult.success(frontService.smartAddCharList(type));
+        return AjaxResult.success(frontService.smartAddCharList(type, timeBegin, timeEnd));
+    }
+
+
+    /**
+     *获取碳源投加 是否在本系统中允许投放(用于部分场景:计算异常 或者 想手动中断等)
+     * @return
+     */
+    @GetMapping("/bigModel/smartAdd/getSwitchStatus")
+    public R<Integer> getSwitchStatus()
+    {
+        log.info("进入了 获取碳源投加 是否在本系统中允许投放(用于部分场景:计算异常 或者 想手动中断等) 接口");
+        TXinyiMedicineConf tXinyiMedicineConf = xinyiMedicineConfMapper.selectTXinyiMedicineConfById(LONG_1);
+        if(Objects.isNull(tXinyiMedicineConf))
+            throw new ServiceException("未查询到碳源投放配置开关");
+        return R.ok(tXinyiMedicineConf.getAddStatus());
     }
 
 
+    /**
+     *修改碳源投加 是否在本系统中允许投放(用于部分场景:计算异常 或者 想手动中断等)
+     * @return
+     */
+    @PutMapping("/bigModel/smartAdd/updateSwitchStatus")
+    public R<String> updateSwitchStatus(@RequestBody TXinyiMedicineConf tXinyiMedicineConf)
+    {
+        log.info("进入了 修改碳源投加 是否在本系统中允许投放(用于部分场景:计算异常 或者 想手动中断等) 接口");
+        if(Objects.isNull(tXinyiMedicineConf.getAddStatus()))
+            throw new ServiceException("请输入要更改的状态");
+        tXinyiMedicineConf.setId(LONG_1);
+        this.xinyiMedicineConfMapper.updateTXinyiMedicineConf(tXinyiMedicineConf);
+        return R.ok("修改成功");
+    }
+
 
     //--------------------下面是碳排放智能体相关的方法--------------------begin
 

+ 8 - 0
slibra-common/src/main/java/com/slibra/common/TYAddUtil.java

@@ -0,0 +1,8 @@
+package com.slibra.common;
+
+/**
+ * 碳源投加计算工具类
+ * ToDo 部分数据需要实时获取,而不是依靠传过来的数据
+ */
+public class TYAddUtil {
+}

+ 3 - 0
slibra-common/src/main/java/com/slibra/common/constant/MyConstants.java

@@ -185,6 +185,9 @@ public class MyConstants {
     public static final int INT_10000 = 10000;//10秒钟
     public static final int MAX_QUESTION_LENGTH = 5000;
 
+
+    public static final long LONG_1 = 1L;
+
     public static final int DAILY_RECORDS_TOTAL = 30;
     public static final int DAILY_REPORT_COUNT_RECORD = 7;
     public static final String JIAN_BAO_END = "简报";

+ 40 - 0
slibra-system/src/main/java/com/slibra/business/domain/TXinyiMedicineConf.java

@@ -0,0 +1,40 @@
+package com.slibra.business.domain;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import com.slibra.common.annotation.Excel;
+import com.slibra.common.core.domain.BaseEntity;
+
+/**
+ * 投药控制对象 t_xinyi_medicine_conf
+ * 
+ * @author slibra
+ * @date 2024-09-13
+ */
+
+@Builder
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class TXinyiMedicineConf extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 主键 */
+    private Long id;
+
+    /** 投药状态(0不允许  1允许) */
+    @Excel(name = "投药状态", readConverterExp = "0=不允许,1=允许")
+    private Integer addStatus;
+
+    /** 删除标志(0代表存在 2代表删除) */
+    private Long delFlag;
+
+    /** 乐观锁 */
+    @Excel(name = "乐观锁")
+    private Long revision;
+
+
+}

+ 3 - 0
slibra-system/src/main/java/com/slibra/business/domain/TXinyiMedicineParam.java

@@ -167,6 +167,9 @@ public class TXinyiMedicineParam extends BaseEntity
     //碳源投加瞬时流量
     private BigDecimal tytjTransientLL;
 
+    //投加运行方式(0启用智适应碳源投加  1手动碳源投加)
+    private Integer addType;
+
     //请求参数
 
     /**  开始时间 */

+ 61 - 0
slibra-system/src/main/java/com/slibra/business/mapper/TXinyiMedicineConfMapper.java

@@ -0,0 +1,61 @@
+package com.slibra.business.mapper;
+
+import java.util.List;
+import com.slibra.business.domain.TXinyiMedicineConf;
+
+/**
+ * 投药控制Mapper接口
+ * 
+ * @author slibra
+ * @date 2024-09-13
+ */
+public interface TXinyiMedicineConfMapper 
+{
+    /**
+     * 查询投药控制
+     * 
+     * @param id 投药控制主键
+     * @return 投药控制
+     */
+    public TXinyiMedicineConf selectTXinyiMedicineConfById(Long id);
+
+    /**
+     * 查询投药控制列表
+     * 
+     * @param tXinyiMedicineConf 投药控制
+     * @return 投药控制集合
+     */
+    public List<TXinyiMedicineConf> selectTXinyiMedicineConfList(TXinyiMedicineConf tXinyiMedicineConf);
+
+    /**
+     * 新增投药控制
+     * 
+     * @param tXinyiMedicineConf 投药控制
+     * @return 结果
+     */
+    public int insertTXinyiMedicineConf(TXinyiMedicineConf tXinyiMedicineConf);
+
+    /**
+     * 修改投药控制
+     * 
+     * @param tXinyiMedicineConf 投药控制
+     * @return 结果
+     */
+    public int updateTXinyiMedicineConf(TXinyiMedicineConf tXinyiMedicineConf);
+
+    /**
+     * 删除投药控制
+     * 
+     * @param id 投药控制主键
+     * @return 结果
+     */
+    public int deleteTXinyiMedicineConfById(Long id);
+
+    /**
+     * 批量删除投药控制
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteTXinyiMedicineConfByIds(Long[] ids);
+}

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

@@ -50,5 +50,5 @@ public interface IFrontService
 
     SmartAdd smartAddDataInfo();
 
-    Map<String, List<ChartBasic>> smartAddCharList(int type);
+    Map<String, List<ChartBasic>> smartAddCharList(int type, String timeBegin, String timeEnd);
 }

+ 61 - 0
slibra-system/src/main/java/com/slibra/business/service/ITXinyiMedicineConfService.java

@@ -0,0 +1,61 @@
+package com.slibra.business.service;
+
+import java.util.List;
+import com.slibra.business.domain.TXinyiMedicineConf;
+
+/**
+ * 投药控制Service接口
+ * 
+ * @author slibra
+ * @date 2024-09-13
+ */
+public interface ITXinyiMedicineConfService 
+{
+    /**
+     * 查询投药控制
+     * 
+     * @param id 投药控制主键
+     * @return 投药控制
+     */
+    public TXinyiMedicineConf selectTXinyiMedicineConfById(Long id);
+
+    /**
+     * 查询投药控制列表
+     * 
+     * @param tXinyiMedicineConf 投药控制
+     * @return 投药控制集合
+     */
+    public List<TXinyiMedicineConf> selectTXinyiMedicineConfList(TXinyiMedicineConf tXinyiMedicineConf);
+
+    /**
+     * 新增投药控制
+     * 
+     * @param tXinyiMedicineConf 投药控制
+     * @return 结果
+     */
+    public int insertTXinyiMedicineConf(TXinyiMedicineConf tXinyiMedicineConf);
+
+    /**
+     * 修改投药控制
+     * 
+     * @param tXinyiMedicineConf 投药控制
+     * @return 结果
+     */
+    public int updateTXinyiMedicineConf(TXinyiMedicineConf tXinyiMedicineConf);
+
+    /**
+     * 批量删除投药控制
+     * 
+     * @param ids 需要删除的投药控制主键集合
+     * @return 结果
+     */
+    public int deleteTXinyiMedicineConfByIds(Long[] ids);
+
+    /**
+     * 删除投药控制信息
+     * 
+     * @param id 投药控制主键
+     * @return 结果
+     */
+    public int deleteTXinyiMedicineConfById(Long id);
+}

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

@@ -17,7 +17,6 @@ import com.slibra.common.utils.DateUtils;
 import com.slibra.common.utils.SecurityUtils;
 import com.slibra.common.utils.StringUtils;
 import lombok.extern.slf4j.Slf4j;
-import lombok.val;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.connection.stream.RecordId;
@@ -431,13 +430,14 @@ public class FrontServiceImpl implements IFrontService {
     }
 
     @Override
-    public Map<String, List<ChartBasic>> smartAddCharList(int type) {
+    public Map<String, List<ChartBasic>> smartAddCharList(int type, String timeBegin, String timeEnd) {
         //日期兜底处理
         Date nowDate = DateUtils.getNowDate();
-        Date dayBefore7 = DateUtils.plusDate(-3, nowDate);
+        Date dayBefore7 = DateUtils.plusDate(-7, nowDate);
+        //2024年09月13日17:02:59 支持前段自定义起止时间
         //先用日期获取当天和前一天的数据,如果获取不到,则提示错误信息
-        String nowDateStr = DateUtils.parseDateToStr(DateUtils.YYYYMMDD_TS, nowDate);
-        String dayBefore3Str = DateUtils.parseDateToStr(DateUtils.YYYYMMDD_TS, dayBefore7);
+        String nowDateStr = StringUtils.isBlank(timeEnd) ? DateUtils.parseDateToStr(DateUtils.YYYYMMDD_TS, nowDate) : timeEnd;
+        String dayBefore3Str = StringUtils.isBlank(timeBegin) ? DateUtils.parseDateToStr(DateUtils.YYYYMMDD_TS, dayBefore7) : timeBegin;
         //返回的对象
         Map<String, List<ChartBasic>> result = new HashMap<>();
         List<ChartBasic> list = new ArrayList<>();

+ 96 - 0
slibra-system/src/main/java/com/slibra/business/service/impl/TXinyiMedicineConfServiceImpl.java

@@ -0,0 +1,96 @@
+package com.slibra.business.service.impl;
+
+import java.util.List;
+import com.slibra.common.utils.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.slibra.business.mapper.TXinyiMedicineConfMapper;
+import com.slibra.business.domain.TXinyiMedicineConf;
+import com.slibra.business.service.ITXinyiMedicineConfService;
+
+/**
+ * 投药控制Service业务层处理
+ * 
+ * @author slibra
+ * @date 2024-09-13
+ */
+@Service
+public class TXinyiMedicineConfServiceImpl implements ITXinyiMedicineConfService 
+{
+    @Autowired
+    private TXinyiMedicineConfMapper tXinyiMedicineConfMapper;
+
+    /**
+     * 查询投药控制
+     * 
+     * @param id 投药控制主键
+     * @return 投药控制
+     */
+    @Override
+    public TXinyiMedicineConf selectTXinyiMedicineConfById(Long id)
+    {
+        return tXinyiMedicineConfMapper.selectTXinyiMedicineConfById(id);
+    }
+
+    /**
+     * 查询投药控制列表
+     * 
+     * @param tXinyiMedicineConf 投药控制
+     * @return 投药控制
+     */
+    @Override
+    public List<TXinyiMedicineConf> selectTXinyiMedicineConfList(TXinyiMedicineConf tXinyiMedicineConf)
+    {
+        return tXinyiMedicineConfMapper.selectTXinyiMedicineConfList(tXinyiMedicineConf);
+    }
+
+    /**
+     * 新增投药控制
+     * 
+     * @param tXinyiMedicineConf 投药控制
+     * @return 结果
+     */
+    @Override
+    public int insertTXinyiMedicineConf(TXinyiMedicineConf tXinyiMedicineConf)
+    {
+        tXinyiMedicineConf.setCreateTime(DateUtils.getNowDate());
+        return tXinyiMedicineConfMapper.insertTXinyiMedicineConf(tXinyiMedicineConf);
+    }
+
+    /**
+     * 修改投药控制
+     * 
+     * @param tXinyiMedicineConf 投药控制
+     * @return 结果
+     */
+    @Override
+    public int updateTXinyiMedicineConf(TXinyiMedicineConf tXinyiMedicineConf)
+    {
+        tXinyiMedicineConf.setUpdateTime(DateUtils.getNowDate());
+        return tXinyiMedicineConfMapper.updateTXinyiMedicineConf(tXinyiMedicineConf);
+    }
+
+    /**
+     * 批量删除投药控制
+     * 
+     * @param ids 需要删除的投药控制主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTXinyiMedicineConfByIds(Long[] ids)
+    {
+        return tXinyiMedicineConfMapper.deleteTXinyiMedicineConfByIds(ids);
+    }
+
+    /**
+     * 删除投药控制信息
+     * 
+     * @param id 投药控制主键
+     * @return 结果
+     */
+    @Override
+    public int deleteTXinyiMedicineConfById(Long id)
+    {
+        return tXinyiMedicineConfMapper.deleteTXinyiMedicineConfById(id);
+    }
+}

+ 17 - 0
slibra-system/src/main/java/com/slibra/business/service/impl/TXinyiMedicineParamServiceImpl.java

@@ -1,5 +1,6 @@
 package com.slibra.business.service.impl;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Objects;
 
@@ -7,6 +8,7 @@ import com.slibra.business.domain.TXinyiIndustry;
 import com.slibra.business.mapper.TXinyiIndustryMapper;
 import com.slibra.common.DecimalUtils;
 import com.slibra.common.utils.DateUtils;
+import com.slibra.common.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.slibra.business.mapper.TXinyiMedicineParamMapper;
@@ -52,6 +54,15 @@ public class TXinyiMedicineParamServiceImpl implements ITXinyiMedicineParamServi
     @Override
     public List<TXinyiMedicineParam> selectTXinyiMedicineParamList(TXinyiMedicineParam tXinyiMedicineParam)
     {
+        //日期兜底处理
+        String timeBegin = tXinyiMedicineParam.getTimeBegin();
+        String timeEnd = tXinyiMedicineParam.getTimeEnd();
+        Date nowDate = DateUtils.getNowDate();
+        Date dayBefore7 = DateUtils.plusDate(-7, nowDate);
+        if(StringUtils.isBlank(timeBegin))
+            tXinyiMedicineParam.setTimeBegin(DateUtils.parseDateToStr(DateUtils.YYYYMMDD_TS, dayBefore7));
+        if(StringUtils.isBlank(timeEnd))
+            tXinyiMedicineParam.setTimeEnd(DateUtils.parseDateToStr(DateUtils.YYYYMMDD_TS, nowDate));
         return tXinyiMedicineParamMapper.selectTXinyiMedicineParamList(tXinyiMedicineParam);
     }
 
@@ -114,6 +125,12 @@ public class TXinyiMedicineParamServiceImpl implements ITXinyiMedicineParamServi
                 latestRecord.setTytjTransientLL(DecimalUtils.getAbsAndScale(tXinyiIndustry.getSJTYJLY(), INT_4));
             }
         }
+        //todo 调用组态,获取投加状态
+        latestRecord.setAddType(Math.random() < 0.5 ? 0 : 1);
         return latestRecord;
     }
+
+    public static void main(String[] args) {
+        System.out.println(Math.random() < 0.5 ? 0 : 1);
+    }
 }

+ 90 - 0
slibra-system/src/main/resources/mapper/business/TXinyiMedicineConfMapper.xml

@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.slibra.business.mapper.TXinyiMedicineConfMapper">
+    
+    <resultMap type="TXinyiMedicineConf" id="TXinyiMedicineConfResult">
+        <result property="id"    column="id"    />
+        <result property="addStatus"    column="add_status"    />
+        <result property="delFlag"    column="del_flag"    />
+        <result property="revision"    column="revision"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="remark"    column="remark"    />
+    </resultMap>
+
+    <sql id="selectTXinyiMedicineConfVo">
+        select id, add_status, del_flag, revision, create_by, create_time, update_by, update_time, remark from t_xinyi_medicine_conf
+    </sql>
+
+    <select id="selectTXinyiMedicineConfList" parameterType="TXinyiMedicineConf" resultMap="TXinyiMedicineConfResult">
+        <include refid="selectTXinyiMedicineConfVo"/>
+        <where>
+            1 = 1
+            <if test="addStatus != null "> and add_status = #{addStatus}</if>
+            <if test="revision != null "> and revision = #{revision}</if>
+        </where>
+        and del_flag = 0 order by id desc
+    </select>
+    
+    <select id="selectTXinyiMedicineConfById" parameterType="Long" resultMap="TXinyiMedicineConfResult">
+        <include refid="selectTXinyiMedicineConfVo"/>
+        where id = #{id} and del_flag = 0
+    </select>
+        
+    <insert id="insertTXinyiMedicineConf" parameterType="TXinyiMedicineConf" useGeneratedKeys="true" keyProperty="id">
+        insert into t_xinyi_medicine_conf
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="addStatus != null">add_status,</if>
+            <if test="delFlag != null">del_flag,</if>
+            <if test="revision != null">revision,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="remark != null">remark,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="addStatus != null">#{addStatus},</if>
+            <if test="delFlag != null">#{delFlag},</if>
+            <if test="revision != null">#{revision},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="remark != null">#{remark},</if>
+         </trim>
+    </insert>
+
+    <update id="updateTXinyiMedicineConf" parameterType="TXinyiMedicineConf">
+        update t_xinyi_medicine_conf
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="addStatus != null">add_status = #{addStatus},</if>
+            <if test="delFlag != null">del_flag = #{delFlag},</if>
+            <if test="revision != null">revision = #{revision},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="remark != null">remark = #{remark},</if>
+        </trim>
+        ,revision = revision + 1
+        where id = #{id}
+    </update>
+
+    
+
+    <delete id="deleteTXinyiMedicineConfById" parameterType="Long">
+        update t_xinyi_medicine_conf set del_flag = 2,revision = revision + 1 where del_flag = 0 and id = #{id}
+    </delete>
+
+    <delete id="deleteTXinyiMedicineConfByIds" parameterType="String">
+        update t_xinyi_medicine_conf set del_flag = 2,revision = revision + 1 where del_flag = 0 and id in
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>