Quellcode durchsuchen

按照新的需求接口调整: 1.配置加字段 2.手动投药也区分上下限 3.增加定时调整系统开关接口 4.其他

王苗苗 vor 5 Monaten
Ursprung
Commit
8a3bb734ed

+ 53 - 5
src/main/java/com/xlht/xlhtproject/controller/ScheduledTasks.java

@@ -1,9 +1,7 @@
 package com.xlht.xlhtproject.controller;
 
-import com.xlht.xlhtproject.domain.TTbDu;
-import com.xlht.xlhtproject.domain.TTbXie;
-import com.xlht.xlhtproject.domain.TXlhtAddRecord;
-import com.xlht.xlhtproject.domain.TXlhtMedicineParam;
+import com.alibaba.fastjson2.JSON;
+import com.xlht.xlhtproject.domain.*;
 import com.xlht.xlhtproject.mapper.*;
 import com.xlht.xlhtproject.utils.CalculateUtils;
 import com.xlht.xlhtproject.utils.DateUtils;
@@ -42,6 +40,9 @@ public class ScheduledTasks {
     @Autowired
     private TXlhtAddRecordMapper xlhtAddRecordMapper;
 
+    @Autowired
+    private TXlhtConfMapper xlhtConfMapper;
+
     /*@Scheduled(fixedRate = 5, timeUnit = TimeUnit.MINUTES) // 五分钟行一次
     public void reportCurrentTime() {
         System.out.println("现在时间: " + System.currentTimeMillis() / 1000);
@@ -87,7 +88,6 @@ public class ScheduledTasks {
         tTbDu.setC1TjLlTime(now);
         tTbDu.setC2TjLl(val2);
         tTbDu.setC2TjLlTime(now);
-        this.tTbDuMapper.updateTTbDu(tTbDu);
         //2024年10月13日17:05:42  除了更新表外,还要记录投药的数据
         TTbXie tTbXie = this.tTbXieMapper.selectTTbXieByID(LONG_1);
         if(!Objects.isNull(tTbXie)){
@@ -122,6 +122,54 @@ public class ScheduledTasks {
             xlhtAddRecord.setRemark(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, nowDate));
             this.xlhtAddRecordMapper.insertTXlhtAddRecord(xlhtAddRecord);
         }
+        //2024年10月25日16:19:59 增加新的逻辑 记录组态返回的状态,然后下次判断
+        TXlhtConf tXlhtConf = this.xlhtConfMapper.selectTXlhtConfById(LONG_1);
+        if(!Objects.isNull(tXlhtConf)){//理论上不会存在空的
+            //获取上次存取的值
+            Integer lastOneStatus = tXlhtConf.getLastOneStatus();
+            Integer lastTwoStatus = tXlhtConf.getLastTwoStatus();
+            Integer addTypeOne = null;
+            Integer addTypeTwo = null;
+            //查询反馈的状态并更新到数据库中
+            if(!Objects.isNull(tTbXie)){
+                latestRecord.setTytjTransientLLOne(tTbXie.getOneJYL());
+                latestRecord.setTytjTransientLLTwo(tTbXie.getTwoJYL());
+
+                Integer oneRemoteStatus = tTbXie.getOneRemoteStatus();
+                Integer oneHLStatus = tTbXie.getOneHLStatus();
+                Integer oneHandleStatus = tTbXie.getOneHandleStatus();
+                if(!Objects.isNull(oneRemoteStatus) && oneRemoteStatus == 1 && !Objects.isNull(oneHLStatus) && oneHLStatus == 1 && !Objects.isNull(oneHandleStatus) && oneHandleStatus == 1){
+                    addTypeOne = 1;
+                }else {
+                    addTypeOne = 0;
+                }
+
+                Integer twoRemoteStatus = tTbXie.getTwoRemoteStatus();
+                Integer twoHLStatus = tTbXie.getTwoHLStatus();
+                Integer twoHandleStatus = tTbXie.getTwoHandleStatus();
+                if(!Objects.isNull(twoRemoteStatus) && twoRemoteStatus == 1 && !Objects.isNull(twoHLStatus) && twoHLStatus == 1 && !Objects.isNull(twoHandleStatus) && twoHandleStatus == 1){
+                    addTypeTwo = 1;
+                }else{
+                    addTypeTwo = 0;
+                }
+            }
+            //如果不一致,则更新开关状态
+            if(!Objects.isNull(addTypeOne) && !addTypeOne.equals(lastOneStatus)){
+                log.info("11定时任务执行的时候,发现一池的组态返回的状态和上次返回的数据不一致,更新为关闭状态,组态返回数据为{}\n上次的一池状态为{}", JSON.toJSONString(tTbXie), lastOneStatus);
+                tTbDu.setActiveOne(0L);
+            }
+            if(!Objects.isNull(addTypeTwo) && !addTypeTwo.equals(lastTwoStatus)){
+                log.info("22定时任务执行的时候,发现二池的组态返回的状态和上次返回的数据不一致,更新为关闭状态,组态返回数据为{}\n上次的一池状态为{}", JSON.toJSONString(tTbXie), lastTwoStatus);
+                tTbDu.setActiveTwo(0L);
+            }
+            //更新投加量、系统开关等
+            this.tTbDuMapper.updateTTbDu(tTbDu);
+            //更新组态返回的状态
+            tXlhtConf.setLastOneStatus(addTypeOne);
+            tXlhtConf.setLastTwoStatus(addTypeTwo);
+            this.xlhtConfMapper.updateTXlhtConf(tXlhtConf);
+        }
+
         log.info("进入了定时投药的逻辑处理--结束");
     }
 

+ 11 - 0
src/main/java/com/xlht/xlhtproject/domain/TXlhtConf.java

@@ -66,4 +66,15 @@ public class TXlhtConf extends BaseEntity
     private Long revision;
 
 
+    //2024年10月25日16:09:09  新增的字段
+    /** 投加取值时间范围配置 */
+    private Long timeVal;
+
+    /** 一池组态反馈情况 */
+    private Integer lastOneStatus;
+
+    /** 二池组态反馈情况 */
+    private Integer lastTwoStatus;
+
+
 }

+ 2 - 0
src/main/java/com/xlht/xlhtproject/mapper/TXlhtAddRecordMapper.java

@@ -61,4 +61,6 @@ public interface TXlhtAddRecordMapper
     public int deleteTXlhtAddRecordByIds(Long[] ids);
 
     TXlhtAddRecord selectLatestTXlhtAddRecord();
+
+    List<TXlhtAddRecord> getNAddRecords(long counts);
 }

+ 26 - 1
src/main/java/com/xlht/xlhtproject/service/impl/TXlhtMedicineParamServiceImpl.java

@@ -14,6 +14,7 @@ import org.springframework.stereotype.Service;
 import java.math.BigDecimal;
 import java.util.List;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 import static com.xlht.xlhtproject.enums.MyConstants.*;
 
@@ -46,6 +47,9 @@ public class TXlhtMedicineParamServiceImpl implements ITXlhtMedicineParamService
     @Autowired
     private TXlhtAddRecordMapper xlhtAddRecordMapper;
 
+    @Autowired
+    private TXlhtConfMapper xlhtConfMapper;
+
 
     /**
      * 查询智能投药参数设置
@@ -318,7 +322,7 @@ public class TXlhtMedicineParamServiceImpl implements ITXlhtMedicineParamService
             }
         }
         //2024年10月23日10:23:08 额外返回[实际投药和反馈的差值]
-        TXlhtAddRecord xlhtAddRecord = this.xlhtAddRecordMapper.selectLatestTXlhtAddRecord();
+        /*TXlhtAddRecord xlhtAddRecord = this.xlhtAddRecordMapper.selectLatestTXlhtAddRecord();
         if(!Objects.isNull(xlhtAddRecord)){
             BigDecimal oneAmount = xlhtAddRecord.getOneAmount();
             BigDecimal realOneAmount = xlhtAddRecord.getRealOneAmount();
@@ -330,7 +334,28 @@ public class TXlhtMedicineParamServiceImpl implements ITXlhtMedicineParamService
             if(!Objects.isNull(twoAmount) && !Objects.isNull(realTwoAmount)){
                 latestRecord.setAddDifferenceTwo(DecimalUtils.getNLengthHalfUp(twoAmount.subtract(realTwoAmount).abs(), INT_2));
             }
+        }*/
+
+        //2024年10月25日17:15:54 逻辑调整:这里根据配置的数据,返回N条数据,取数据的平均值。
+        TXlhtConf tXlhtConf = this.xlhtConfMapper.selectTXlhtConfById(LONG_1);
+        long timeVal = 30;//默认30分钟
+        if(!Objects.isNull(tXlhtConf) && !Objects.isNull(tXlhtConf.getTimeVal())){
+            timeVal = tXlhtConf.getTimeVal();
         }
+        long counts = timeVal/5L;//获取数据的条数
+        List<TXlhtAddRecord> xlhtAddRecords = this.xlhtAddRecordMapper.getNAddRecords(counts);
+        //获取四个值(集合中的平均值):
+        BigDecimal oneAmount = DecimalUtils.calculateAverage(xlhtAddRecords.stream().map(TXlhtAddRecord::getOneAmount).collect(Collectors.toList()), INT_2);
+        BigDecimal realOneAmount = DecimalUtils.calculateAverage(xlhtAddRecords.stream().map(TXlhtAddRecord::getRealOneAmount).collect(Collectors.toList()), INT_2);
+        BigDecimal twoAmount = DecimalUtils.calculateAverage(xlhtAddRecords.stream().map(TXlhtAddRecord::getTwoAmount).collect(Collectors.toList()), INT_2);
+        BigDecimal realTwoAmount = DecimalUtils.calculateAverage(xlhtAddRecords.stream().map(TXlhtAddRecord::getRealTwoAmount).collect(Collectors.toList()), INT_2);
+        if(!Objects.isNull(oneAmount) && !Objects.isNull(realOneAmount)){
+            latestRecord.setAddDifferenceOne(DecimalUtils.getNLengthHalfUp(oneAmount.subtract(realOneAmount).abs(), INT_2));
+        }
+        if(!Objects.isNull(twoAmount) && !Objects.isNull(realTwoAmount)){
+            latestRecord.setAddDifferenceTwo(DecimalUtils.getNLengthHalfUp(twoAmount.subtract(realTwoAmount).abs(), INT_2));
+        }
+
     }
 
     private void parseData(TXlhtMedicineParam latestRecord) {

+ 35 - 11
src/main/java/com/xlht/xlhtproject/utils/CalculateUtils.java

@@ -6,8 +6,6 @@ import com.xlht.xlhtproject.domain.TXlhtMedicineParam;
 import com.xlht.xlhtproject.mapper.TShuju1Mapper;
 import com.xlht.xlhtproject.mapper.TXlhtConfMapper;
 import lombok.extern.slf4j.Slf4j;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -78,8 +76,6 @@ public class CalculateUtils {
         BigDecimal tydlOne = param.getTydlOne();
         BigDecimal tydlTwo = param.getTydlTwo();
 
-        BigDecimal medicineAmountOne = param.getMedicineAmountOne();//手动需要
-
 //        Integer type = param.getType();//0自动 1一号池 2二号池 3人工投放
 
         BigDecimal yymdOne = param.getYymdOne();
@@ -116,17 +112,46 @@ public class CalculateUtils {
         if(Objects.isNull(typeTwo)) {
             typeTwo = 0;
         }
+        //获取配置的信息
+        //2024年10月14日15:09:28 由于几个参数设置了最大值和最小值的范围,这里再额外校验一下
+        TXlhtConf tXlhtConf = this.xxlhtConfMapper.selectTXlhtConfById(LONG_1);
         if(1 == whichCZ) {
             if(typeOne == 1){//人工
-                return param.getMedicineAmountOne();
+                BigDecimal medicineAmountOne = param.getMedicineAmountOne();
+                if(!Objects.isNull(tXlhtConf) && !Objects.isNull(medicineAmountOne)){
+                    BigDecimal minAddAmount = tXlhtConf.getMinAddAmount();
+                    if(!Objects.isNull(minAddAmount) && medicineAmountOne.compareTo(minAddAmount) < 0){
+                        log.info("&&&&&&1池通过手动配置得到的碳源投加量为{},比配置的最小值还低,配置的最小值为{}", medicineAmountOne, minAddAmount);
+                        medicineAmountOne = minAddAmount;
+                    }
+                    BigDecimal maxAddAmount = tXlhtConf.getMaxAddAmount();
+                    if(!Objects.isNull(maxAddAmount) && medicineAmountOne.compareTo(maxAddAmount) > 0){
+                        log.info("&&&&&&1池通过手动配置得到的碳源投加量为{},比配置的最大值还高,配置的最大值为{}", medicineAmountOne, maxAddAmount);
+                        medicineAmountOne = maxAddAmount;
+                    }
+                }
+                return medicineAmountOne;
             }else {//自动
-                return getResultByDiff(hycXsyTypeOne, hycXsyOne, htfksdOne, qycAdTypeOne, qycAdOne, qycYxyTypeOne, qycYxyOne, xzxsOne, jzxsOne, jsLlTypeOne, jsLlOne, slfpxsOne, kzxsOne, jsCodTypeOne, jsCodOne, zhxsOne, tydlOne, "one", yymdOne, sxpsOne);
+                return getResultByDiff(hycXsyTypeOne, hycXsyOne, htfksdOne, qycAdTypeOne, qycAdOne, qycYxyTypeOne, qycYxyOne, xzxsOne, jzxsOne, jsLlTypeOne, jsLlOne, slfpxsOne, kzxsOne, jsCodTypeOne, jsCodOne, zhxsOne, tydlOne, "one", yymdOne, sxpsOne, tXlhtConf);
             }
         }else if(2 == whichCZ) {
             if(typeTwo == 1){//人工
-                return param.getMedicineAmountTwo();
+                BigDecimal medicineAmountTwo = param.getMedicineAmountTwo();
+                if(!Objects.isNull(tXlhtConf) && !Objects.isNull(medicineAmountTwo)){
+                    BigDecimal minAddAmount = tXlhtConf.getMinAddAmount();
+                    if(!Objects.isNull(minAddAmount) && medicineAmountTwo.compareTo(minAddAmount) < 0){
+                        log.info("&&&&&&2池通过手动配置得到的碳源投加量为{},比配置的最小值还低,配置的最小值为{}", medicineAmountTwo, minAddAmount);
+                        medicineAmountTwo = minAddAmount;
+                    }
+                    BigDecimal maxAddAmount = tXlhtConf.getMaxAddAmount();
+                    if(!Objects.isNull(maxAddAmount) && medicineAmountTwo.compareTo(maxAddAmount) > 0){
+                        log.info("&&&&&&2池通过手动配置得到的碳源投加量为{},比配置的最大值还高,配置的最大值为{}", medicineAmountTwo, maxAddAmount);
+                        medicineAmountTwo = maxAddAmount;
+                    }
+                }
+                return medicineAmountTwo;
             }else {//自动
-                return getResultByDiff(hycXsyTypeTwo, hycXsyTwo, htfksdTwo, qycAdTypeTwo, qycAdTwo, qycYxyTypeTwo, qycYxyTwo, xzxsTwo, jzxsTwo, jsLlTypeTwo, jsLlTwo, slfpxsTwo, kzxsTwo, jsCodTypeTwo, jsCodTwo, zhxsTwo, tydlTwo, "two", yymdTwo, sxpsTwo);
+                return getResultByDiff(hycXsyTypeTwo, hycXsyTwo, htfksdTwo, qycAdTypeTwo, qycAdTwo, qycYxyTypeTwo, qycYxyTwo, xzxsTwo, jzxsTwo, jsLlTypeTwo, jsLlTwo, slfpxsTwo, kzxsTwo, jsCodTypeTwo, jsCodTwo, zhxsTwo, tydlTwo, "two", yymdTwo, sxpsTwo, tXlhtConf);
             }
         }else {
             log.error("不支持的类型××××××");
@@ -136,7 +161,7 @@ public class CalculateUtils {
 
     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, BigDecimal yymd, BigDecimal sxps) {
+                                       BigDecimal jsCodVal, BigDecimal zhxs, BigDecimal tydl, String whichCZ, BigDecimal yymd, BigDecimal sxps, TXlhtConf tXlhtConf) {
         //2024年09月14日10:26:11  不同池子,根据不同类型,获取最新的数据,计算碳源投加量
         //获取最新的实时数据
         SmartAdd smartAdd = this.shuju1Mapper.getNewestData();
@@ -224,8 +249,7 @@ public class CalculateUtils {
             sxps = BigDecimal.ZERO;
         }
 
-        //2024年10月14日15:09:28 由于几个参数设置了最大值和最小值的范围,这里再额外校验一下
-        TXlhtConf tXlhtConf = this.xxlhtConfMapper.selectTXlhtConfById(LONG_1);
+
 
         if(!Objects.isNull(tXlhtConf)){
             BigDecimal minJsll = tXlhtConf.getMinJsll();

+ 27 - 4
src/main/java/com/xlht/xlhtproject/utils/DecimalUtils.java

@@ -4,10 +4,7 @@ import com.alibaba.fastjson2.JSONArray;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-import java.util.OptionalDouble;
+import java.util.*;
 import java.util.stream.Collectors;
 
 public class DecimalUtils {
@@ -52,6 +49,22 @@ public class DecimalUtils {
     }
 
 
+    public static BigDecimal calculateAverage(List<BigDecimal> bigDecimals, int scale) {
+        if (bigDecimals == null || bigDecimals.isEmpty()) {
+            return null;
+        }
+
+        // Sum all BigDecimal values
+        BigDecimal sum = bigDecimals.stream()
+                .reduce(BigDecimal.ZERO, BigDecimal::add);
+
+        // Count the number of elements
+        long count = bigDecimals.stream().count();
+
+        // Calculate the average
+        return sum.divide(new BigDecimal(count), scale, RoundingMode.HALF_UP);
+    }
+
     public static void main(String[] args) {
 //         System.out.println(getAbsAndScale(null, 3));
 //         System.out.println(getAbsAndScale(new BigDecimal("33.33333"), 3));
@@ -73,5 +86,15 @@ public class DecimalUtils {
         arr.add(2);
         OptionalDouble average = arr.stream().mapToInt(Integer::intValue).average();
         System.out.println(average.getAsDouble());
+
+
+        List<BigDecimal> bigDecimals = Arrays.asList(
+                new BigDecimal("10.5"),
+                new BigDecimal("20.3"),
+                new BigDecimal("30.1"),
+                new BigDecimal("40.7")
+        );
+
+        System.out.println(calculateAverage(bigDecimals, 2));
     }
 }

+ 4 - 0
src/main/resources/mapper/TXlhtAddRecordMapper.xml

@@ -123,4 +123,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectLatestTXlhtAddRecord" resultMap="TXlhtAddRecordResult">
         select top 1 id, one_system_add, two_system_add, one_amount, two_amount, real_one_amount, real_two_amount, del_flag, revision, create_by, create_time, update_by, update_time, remark from t_xlht_add_record order by id desc
     </select>
+
+    <select id="getNAddRecords" resultMap="TXlhtAddRecordResult">
+        select top ${counts} id, one_system_add, two_system_add, one_amount, two_amount, real_one_amount, real_two_amount, del_flag, revision, create_by, create_time, update_by, update_time, remark from t_xlht_add_record order by id desc
+    </select>
 </mapper>

+ 20 - 3
src/main/resources/mapper/TXlhtConfMapper.xml

@@ -24,10 +24,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="updateBy"    column="update_by"    />
         <result property="updateTime"    column="update_time"    />
         <result property="remark"    column="remark"    />
+        <result property="timeVal"    column="time_val"    />
+        <result property="lastOneStatus"    column="last_one_status"    />
+        <result property="lastTwoStatus"    column="last_two_status"    />
     </resultMap>
 
     <sql id="selectTXlhtConfVo">
-        select id, min_add_amount, max_add_amount, min_jsll, max_jsll, min_js_cod, max_js_cod, stop_add_flag, kzmbplbjz, hycxsygkz, xhycbjz, jylpybjz, del_flag, revision, create_by, create_time, update_by, update_time, remark from t_xlht_conf
+        select id, min_add_amount, max_add_amount, min_jsll, max_jsll, min_js_cod, max_js_cod, stop_add_flag, kzmbplbjz, hycxsygkz, xhycbjz, jylpybjz, del_flag, revision, create_by, create_time, update_by, update_time, remark, time_val, last_one_status, last_two_status from t_xlht_conf
     </sql>
 
     <select id="selectTXlhtConfList" parameterType="TXlhtConf" resultMap="TXlhtConfResult">
@@ -46,6 +49,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="xhycbjz != null "> and xhycbjz = #{xhycbjz}</if>
             <if test="jylpybjz != null "> and jylpybjz = #{jylpybjz}</if>
             <if test="revision != null "> and revision = #{revision}</if>
+            <if test="timeVal != null "> and time_val = #{timeVal}</if>
+            <if test="lastOneStatus != null "> and last_one_status = #{lastOneStatus}</if>
+            <if test="lastTwoStatus != null "> and last_two_status = #{lastTwoStatus}</if>
         </where>
         and del_flag = 0 order by id desc
     </select>
@@ -58,6 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <insert id="insertTXlhtConf" parameterType="TXlhtConf" useGeneratedKeys="true" keyProperty="id">
         insert into t_xlht_conf
         <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">id,</if>
             <if test="minAddAmount != null">min_add_amount,</if>
             <if test="maxAddAmount != null">max_add_amount,</if>
             <if test="minJsll != null">min_jsll,</if>
@@ -76,8 +83,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="remark != null">remark,</if>
-         </trim>
+            <if test="timeVal != null">time_val,</if>
+            <if test="lastOneStatus != null">last_one_status,</if>
+            <if test="lastTwoStatus != null">last_two_status,</if>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">#{id},</if>
             <if test="minAddAmount != null">#{minAddAmount},</if>
             <if test="maxAddAmount != null">#{maxAddAmount},</if>
             <if test="minJsll != null">#{minJsll},</if>
@@ -96,7 +107,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="remark != null">#{remark},</if>
-         </trim>
+            <if test="timeVal != null">#{timeVal},</if>
+            <if test="lastOneStatus != null">#{lastOneStatus},</if>
+            <if test="lastTwoStatus != null">#{lastTwoStatus},</if>
+        </trim>
     </insert>
 
     <update id="updateTXlhtConf" parameterType="TXlhtConf">
@@ -120,6 +134,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="remark != null">remark = #{remark},</if>
+            <if test="timeVal != null">time_val = #{timeVal},</if>
+            <if test="lastOneStatus != null">last_one_status = #{lastOneStatus},</if>
+            <if test="lastTwoStatus != null">last_two_status = #{lastTwoStatus},</if>
         </trim>
         ,revision = revision + 1
         where id = #{id}