Browse Source

Merge remote-tracking branch 'origin/master'

sxb 1 year ago
parent
commit
23a6c92f4f

+ 17 - 3
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/bjgl/controller/YhCbkxxController.java

@@ -6,9 +6,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import com.tofly.common.core.entity.ResultRespone;
 import com.tofly.common.log.annotation.ToFlyAppLog;
 import com.tofly.feesapi.bjgl.entity.*;
-import com.tofly.feesapi.bjgl.entity.dto.YhCbkxxCbxhUpdate;
-import com.tofly.feesapi.bjgl.entity.dto.YhCbkxxFilter;
-import com.tofly.feesapi.bjgl.entity.dto.YhCbkxxSjUpdate;
+import com.tofly.feesapi.bjgl.entity.dto.*;
 import com.tofly.feesapi.bjgl.entity.vo.YhCbkxxSelect2;
 import com.tofly.feesapi.bjgl.entity.vo.YhCbkxxUpdate;
 import com.tofly.feesapi.bjgl.entity.vo.YhCbkxxView;
@@ -235,6 +233,22 @@ public class YhCbkxxController {
         return ResultRespone.success(yhCbkxxService.updateCbxh(update, czyUserDetails));
     }
 
+    @ApiOperationSupport(order = 27)
+    @ApiOperation(value = "批量撤销抄表序号", tags = "抄表序号调整")
+    @PutMapping("/cxcbxh")
+    public ResultRespone<Boolean> cancelCbxh(@RequestBody YhCbkxxCbxhCancel cancel,
+                                             @ApiIgnore @AuthenticationPrincipal CzyUserDetails czyUserDetails) {
+        return ResultRespone.success(yhCbkxxService.cancelCbxh(cancel, czyUserDetails));
+    }
+
+    @ApiOperationSupport(order = 27)
+    @ApiOperation(value = "上下移动抄表序号", tags = "抄表序号调整")
+    @PutMapping("/sxydcbxh")
+    public ResultRespone<Boolean> sxydCbxh(@RequestBody YhCbkxxCbxhSxyd sxyd,
+                                             @ApiIgnore @AuthenticationPrincipal CzyUserDetails czyUserDetails) {
+        return ResultRespone.success(yhCbkxxService.sxydCbxh(sxyd, czyUserDetails));
+    }
+
     @ApiOperationSupport(order = 28)
     @ApiOperation(value = "批量设置水价", tags = "批量设置水价")
     @PutMapping("/sj")

+ 17 - 0
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/bjgl/entity/dto/YhCbkxxCbxhCancel.java

@@ -0,0 +1,17 @@
+package com.tofly.feesapi.bjgl.entity.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+
+@Data
+@ApiModel("水表档案抄表序号撤销DTO")
+public class YhCbkxxCbxhCancel {
+
+    @ApiModelProperty(value = "用户编号", position = 3, required = true)
+    private List<String> yhbhs;
+
+}

+ 20 - 0
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/bjgl/entity/dto/YhCbkxxCbxhSxyd.java

@@ -0,0 +1,20 @@
+package com.tofly.feesapi.bjgl.entity.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+
+@Data
+@ApiModel("水表档案抄表序号上下移动DTO")
+public class YhCbkxxCbxhSxyd {
+
+    @ApiModelProperty(value = "用户编号", position = 3, required = true)
+    private String yhbh;
+
+    @ApiModelProperty(value = "移动方向, true:上移, false:下移", position = 4)
+    private Boolean ydfx = true;
+
+}

+ 3 - 0
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/bjgl/entity/vo/YhCbkxxSelect2.java

@@ -89,4 +89,7 @@ public class YhCbkxxSelect2 implements Serializable {
     @ApiModelProperty(value = "抄表序号", position = 19, example = "0")
     private Integer cbxh;
 
+    @ApiModelProperty(value = "所属抄表册",position = 21)
+    private String sscbbmc;
+
 }

+ 9 - 4
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/bjgl/mapper/YhCbkxxMapper.java

@@ -8,11 +8,11 @@ import com.tofly.feesapi.bjgl.entity.YhDaCbkxxSelect;
 import com.tofly.feesapi.bjgl.entity.dto.YhCbkxxFilter;
 import com.tofly.feesapi.bjgl.entity.vo.YhCbkxxSelect;
 import com.tofly.feesapi.bjgl.entity.vo.YhCbkxxSelect2;
-import com.tofly.feesapi.bjgl.entity.vo.YhCbkxxView;
 import com.tofly.feesapi.common.entity.dto.PageDto;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+
 public interface YhCbkxxMapper extends BaseMapper<YhCbkxx> {
     List<YhCbkxxSelect> getList(@Param("yhbh") String yhbh);
 
@@ -24,9 +24,14 @@ public interface YhCbkxxMapper extends BaseMapper<YhCbkxx> {
     YhCbkxx2 SelectYhcbkxx(String yhbh, String cbkh);
 
     //换表查看-根据用户编号,表卡号,查询水表档案信息
-    YhDaCbkxxSelect SelectYhdaSbda(String yhbh,String cbkh);
+    YhDaCbkxxSelect SelectYhdaSbda(String yhbh, String cbkh);
+
+    int selectExistYhbh(String yhbh, String cbkh);
+
+    Page<YhDaCbkxxSelect> getYhdaSbdaPage(@Param("page") Page<YhDaCbkxxSelect> page, String sscbpq, String sscbb, String searchText);
 
-    int selectExistYhbh(String yhbh,String cbkh);
+    int getMaxCbxh(List<String> yhbhs);
 
-    Page<YhDaCbkxxSelect> getYhdaSbdaPage(@Param("page") Page<YhDaCbkxxSelect> page,String sscbpq,String sscbb, String searchText);
+    YhCbkxx getUp(@Param("sscbb") String sscbb, @Param("cbxh") int cbxh);
+    YhCbkxx getDown(@Param("sscbb") String sscbb, @Param("cbxh") int cbxh);
 }

+ 5 - 3
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/bjgl/service/YhCbkxxService.java

@@ -3,9 +3,7 @@ package com.tofly.feesapi.bjgl.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.tofly.feesapi.bjgl.entity.YhCbkxx;
 import com.tofly.feesapi.bjgl.entity.YhDaCbkxxSelect;
-import com.tofly.feesapi.bjgl.entity.dto.YhCbkxxCbxhUpdate;
-import com.tofly.feesapi.bjgl.entity.dto.YhCbkxxFilter;
-import com.tofly.feesapi.bjgl.entity.dto.YhCbkxxSjUpdate;
+import com.tofly.feesapi.bjgl.entity.dto.*;
 import com.tofly.feesapi.bjgl.entity.vo.*;
 import com.tofly.feesapi.common.entity.dto.PageDto;
 import com.tofly.feesapi.common.entity.vo.PageResult;
@@ -45,4 +43,8 @@ public interface YhCbkxxService extends IService<YhCbkxx> {
     boolean updateSj(YhCbkxxSjUpdate update, CzyUserDetails czyUserDetails);
 
     boolean hb(YhHbUpdate update, CzyUserDetails czyUserDetails);
+
+    boolean cancelCbxh(YhCbkxxCbxhCancel cancel, CzyUserDetails czyUserDetails);
+
+    boolean sxydCbxh(YhCbkxxCbxhSxyd sxyd, CzyUserDetails czyUserDetails);
 }

+ 131 - 35
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/bjgl/service/impl/YhCbkxxServiceImpl.java

@@ -1,13 +1,11 @@
 package com.tofly.feesapi.bjgl.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.tofly.feesapi.bjgl.entity.dto.*;
 import com.tofly.feesapi.common.constant.JfztEnum;
 import com.tofly.feesapi.common.constant.JtjslxEnum;
 import com.tofly.feesapi.bjgl.entity.YhCbkxx;
 import com.tofly.feesapi.bjgl.entity.YhCbkxxLog;
-import com.tofly.feesapi.bjgl.entity.dto.YhCbkxxCbxhUpdate;
-import com.tofly.feesapi.bjgl.entity.dto.YhCbkxxFilter;
-import com.tofly.feesapi.bjgl.entity.dto.YhCbkxxSjUpdate;
 import com.tofly.feesapi.bjgl.entity.vo.*;
 import com.tofly.feesapi.bjgl.mapper.YhCbkxxMapper;
 import com.tofly.feesapi.bjgl.service.YhCbkxxLogService;
@@ -34,10 +32,7 @@ import java.math.BigDecimal;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -153,35 +148,69 @@ public class YhCbkxxServiceImpl extends ServiceImpl<YhCbkxxMapper, YhCbkxx> impl
     public boolean updateCbxh(YhCbkxxCbxhUpdate update, CzyUserDetails czyUserDetails) {
         List<String> yhbhs = update.getYhbhs();
         if (yhbhs == null || yhbhs.size() == 0) return false;
-        for (String yhbh : yhbhs) {
-            YhCbkxx yhCbkxx = this.getById(yhbh);
-            if (yhCbkxx == null) throw new FeesException("水表档案不存在", FeesErrorCode.BUSINESS_ERROR);
-        }
+        Set<String> cbbs = new HashSet<>();
+        Set<String> qbyhbhs = new HashSet<>();
+        qbyhbhs.addAll(yhbhs);
         String crdzhYhbh = update.getCrdzhYhbh();
-        YhCbkxx insertAfter = this.getById(crdzhYhbh);
-        if (insertAfter == null) throw new FeesException("水表档案不存在", FeesErrorCode.BUSINESS_ERROR);
-        int cbxh = insertAfter.getCbxh();
-        if (cbxh == 0) throw new FeesException("水表档案未分配序号", FeesErrorCode.BUSINESS_ERROR);
-        List<String> cbbYhbhs = getCbbYhbhs(crdzhYhbh);
-        boolean b = cbbYhbhs.containsAll(yhbhs);
-        if (!b) throw new FeesException("不在同一个抄表本(册)", FeesErrorCode.BUSINESS_ERROR);
-        YhCbkxx next = getNext(cbbYhbhs, cbxh);
-        if (next != null) {
-            this.lambdaUpdate()
-                    .ge(YhCbkxx::getCbxh, next.getCbxh())
-                    .in(YhCbkxx::getYhbh, cbbYhbhs)
-                    .setSql("cbxh = cbxh + " + yhbhs.size())
-                    .update();
-        }
-        int cbxhStart = cbxh;
-        for (String yhbh : yhbhs) {
-            this.lambdaUpdate()
-                    .eq(YhCbkxx::getYhbh, yhbh)
-                    .set(YhCbkxx::getCbxh, ++cbxhStart).update();
+        if (crdzhYhbh != null) qbyhbhs.add(crdzhYhbh);
+        //Map<String, YhKhjbxx> yhxxMap = new HashMap<>();
+        qbyhbhs.forEach(yhbh -> {
+            YhKhjbxx yhKhjbxx = yhKhjbxxService.getById(yhbh);
+            if (yhKhjbxx == null)
+                throw new FeesException(String.format("用户档案不存在:%s", yhbh), FeesErrorCode.BUSINESS_ERROR);
+            String sscbb = yhKhjbxx.getSscbb();
+            if (sscbb == null)
+                throw new FeesException(String.format("用户档案未分配抄表册:%s", yhbh), FeesErrorCode.BUSINESS_ERROR);
+            cbbs.add(sscbb);
+            //yhxxMap.put(yhKhjbxx.getYhbh(), yhKhjbxx);
+        });
+        if (cbbs.size() > 1) throw new FeesException("用户档案不在同一个抄表本(册)", FeesErrorCode.BUSINESS_ERROR);
+        String sscbb = cbbs.stream().findFirst().get();
+
+        if (crdzhYhbh == null) {//未提供插入位置
+            List<String> cbbYhbhs = getCbbYhbhs(sscbb);
+            int cbxhStart = getMaxCbxh(cbbYhbhs);
+            for (String yhbh : yhbhs) {
+                this.lambdaUpdate()
+                        .eq(YhCbkxx::getYhbh, yhbh)
+                        .set(YhCbkxx::getCbxh, ++cbxhStart).update();
+            }
+        } else {
+            YhCbkxx insertAfter = this.getById(crdzhYhbh);
+            if (insertAfter == null)
+                throw new FeesException(String.format("水表档案不存在:%s", crdzhYhbh), FeesErrorCode.BUSINESS_ERROR);
+            int cbxh = insertAfter.getCbxh();
+            if (cbxh == 0) throw new FeesException("水表档案未分配序号", FeesErrorCode.BUSINESS_ERROR);
+            List<String> cbbYhbhs = getCbbYhbhs(sscbb);
+            YhCbkxx next = getNext(cbbYhbhs, cbxh);
+            if (next != null) {
+                this.lambdaUpdate()
+                        .ge(YhCbkxx::getCbxh, next.getCbxh())
+                        .in(YhCbkxx::getYhbh, cbbYhbhs)
+                        .setSql("cbxh = cbxh + " + yhbhs.size())
+                        .update();
+            }
+            int cbxhStart = cbxh;
+            for (String yhbh : yhbhs) {
+                this.lambdaUpdate()
+                        .eq(YhCbkxx::getYhbh, yhbh)
+                        .set(YhCbkxx::getCbxh, ++cbxhStart).update();
+            }
         }
         return true;
     }
 
+    /**
+     * 获取抄表本最大抄表序号
+     *
+     * @param cbbYhbhs 抄表本用户编号
+     * @return
+     */
+    private int getMaxCbxh(List<String> cbbYhbhs) {
+        if (cbbYhbhs == null || cbbYhbhs.isEmpty()) return 0;
+        return this.baseMapper.getMaxCbxh(cbbYhbhs);
+    }
+
     @Override
     public PageResult<YhCbkxxSelect2> getPage(PageDto pageDto, YhCbkxxFilter filter) {
         PageDto<YhCbkxxSelect2> page = this.baseMapper.getPage(pageDto, filter);
@@ -262,15 +291,81 @@ public class YhCbkxxServiceImpl extends ServiceImpl<YhCbkxxMapper, YhCbkxx> impl
         return true;
     }
 
+    @Override
+    public boolean cancelCbxh(YhCbkxxCbxhCancel cancel, CzyUserDetails czyUserDetails) {
+        List<String> yhbhs = cancel.getYhbhs();
+        yhbhs.forEach(yhbh -> {
+            YhKhjbxx yhKhjbxx = yhKhjbxxService.getById(yhbh);
+            if (yhKhjbxx == null)
+                throw new FeesException(String.format("用户档案不存在:%s", yhbh), FeesErrorCode.BUSINESS_ERROR);
+            YhCbkxx yhCbkxx = this.getById(yhbh);
+            if (yhCbkxx == null)
+                throw new FeesException(String.format("水表档案不存在:%s", yhbh), FeesErrorCode.BUSINESS_ERROR);
+        });
+        for (String yhbh : yhbhs) {
+            this.lambdaUpdate()
+                    .eq(YhCbkxx::getYhbh, yhbh)
+                    .set(YhCbkxx::getCbxh, 0).update();
+        }
+        return true;
+    }
+
+    @Override
+    public boolean sxydCbxh(YhCbkxxCbxhSxyd sxyd, CzyUserDetails czyUserDetails) {
+        String yhbh = sxyd.getYhbh();
+        if (yhbh == null) return false;
+        YhKhjbxx yhKhjbxx = yhKhjbxxService.getById(yhbh);
+        if (yhKhjbxx == null)
+            throw new FeesException(String.format("用户档案不存在:%s", yhbh), FeesErrorCode.BUSINESS_ERROR);
+        Boolean ydfx = sxyd.getYdfx();
+        String sscbb = yhKhjbxx.getSscbb();
+        if (sscbb == null)
+            throw new FeesException(String.format("用户档案未分配抄表册:%s", yhbh), FeesErrorCode.BUSINESS_ERROR);
+        YhCbkxx yhCbkxx = this.getById(yhbh);
+        if (yhCbkxx == null)
+            throw new FeesException(String.format("水表档案不存在:%s", yhbh), FeesErrorCode.BUSINESS_ERROR);
+        if (ydfx) {//上移
+            int cbxh = yhCbkxx.getCbxh();
+            YhCbkxx up = this.baseMapper.getUp(sscbb, cbxh);
+            if (up != null) {
+                this.lambdaUpdate()
+                        .eq(YhCbkxx::getYhbh, yhCbkxx.getYhbh())
+                        .set(YhCbkxx::getCbxh, up.getCbxh()).update();
+                this.lambdaUpdate()
+                        .eq(YhCbkxx::getYhbh, up.getYhbh())
+                        .set(YhCbkxx::getCbxh, cbxh).update();
+            } else {
+                this.lambdaUpdate()
+                        .eq(YhCbkxx::getYhbh, yhCbkxx.getYhbh())
+                        .set(YhCbkxx::getCbxh, cbxh - 1).update();
+            }
+        } else {
+            int cbxh = yhCbkxx.getCbxh();
+            YhCbkxx down = this.baseMapper.getDown(sscbb, cbxh);
+            if (down != null) {
+                this.lambdaUpdate()
+                        .eq(YhCbkxx::getYhbh, yhCbkxx.getYhbh())
+                        .set(YhCbkxx::getCbxh, down.getCbxh()).update();
+                this.lambdaUpdate()
+                        .eq(YhCbkxx::getYhbh, down.getYhbh())
+                        .set(YhCbkxx::getCbxh, cbxh).update();
+            } else {
+                this.lambdaUpdate()
+                        .eq(YhCbkxx::getYhbh, yhCbkxx.getYhbh())
+                        .set(YhCbkxx::getCbxh, cbxh + 1).update();
+            }
+        }
+        return true;
+    }
+
     /**
      * 获取用户编号所在抄表本(册)的所有用户编号
      *
-     * @param yhbh 用户编号
+     * @param sscbb 用户编号
      * @return
      */
-    private List<String> getCbbYhbhs(String yhbh) {
-        YhKhjbxx yhKhjbxx = yhKhjbxxService.getById(yhbh);
-        String sscbb = yhKhjbxx.getSscbb();
+    private List<String> getCbbYhbhs(String sscbb) {
+
         if (sscbb == null) return new ArrayList<>();
         List<YhKhjbxx> list = yhKhjbxxService.lambdaQuery()
                 .eq(YhKhjbxx::getSscbb, sscbb)
@@ -301,6 +396,7 @@ public class YhCbkxxServiceImpl extends ServiceImpl<YhCbkxxMapper, YhCbkxx> impl
 
     /**
      * 检查基本参数
+     *
      * @param cbkxx
      */
     private void checkJbcs(YhCbkxx cbkxx) {

+ 40 - 1
collect-fees/collect-fees-api/src/main/resources/mapper/bjgl/YhCbkxxMapper.xml

@@ -63,9 +63,10 @@
         <include refid="sql2"></include>
     </select>
     <sql id="sql2">
-        SELECT a.yhbh, a.cbkh, c.yhxm, c.yhdz, a.ybdjbz, a.wsfbz, a.sjbm, a.sjbm1, a.slbl1, a.sjbm2, a.slbl2, a.sjbm3, a.slbl3, a.cbxh
+        SELECT a.yhbh, a.cbkh, c.yhxm, c.yhdz, a.ybdjbz, a.wsfbz, a.sjbm, a.sjbm1, a.slbl1, a.sjbm2, a.slbl2, a.sjbm3, a.slbl3, a.cbxh, f.cbbmc AS sscbbmc
         FROM yh_cbkxx a
         LEFT JOIN yh_khjbxx c ON a.yhbh = c.yhbh
+        LEFT JOIN bm_cbb f ON c.sscbb = f.cbbbm
         WHERE 1=1
         <!--模糊查询 -->
         <if test="filter.searchText!=null">
@@ -138,4 +139,42 @@
             </if>
         </if>
     </sql>
+    <select id="getMaxCbxh" resultType="Integer">
+        SELECT NVL(MAX(cbxh),0) AS cbxh FROM yh_cbkxx WHERE yhbh IN
+        <foreach collection="yhbhs" item="yhbh" index="index" open="(" close=")" separator=",">
+            #{yhbh}
+        </foreach>
+    </select>
+    <select id="getUp" resultType="com.tofly.feesapi.bjgl.entity.YhCbkxx">
+        SELECT
+        c.sscbb,
+        a.*
+        FROM
+        yh_cbkxx a
+        LEFT JOIN yh_khjbxx c ON
+        a.yhbh = c.yhbh
+        WHERE
+        c.sscbb = #{sscbb}
+        AND ${cbxh} > a.cbxh
+        AND a.cbxh > 0
+        AND ROWNUM = 1
+        ORDER BY
+        a.cbxh
+    </select>
+    <select id="getDown" resultType="com.tofly.feesapi.bjgl.entity.YhCbkxx">
+        SELECT
+        c.sscbb,
+        a.*
+        FROM
+        yh_cbkxx a
+        LEFT JOIN yh_khjbxx c ON
+        a.yhbh = c.yhbh
+        WHERE
+        c.sscbb = #{sscbb}
+        AND a.cbxh > ${cbxh}
+        AND a.cbxh > 0
+        AND ROWNUM = 1
+        ORDER BY
+        a.cbxh
+    </select>
 </mapper>