浏览代码

开关阀指令保存

lihaoli 11 月之前
父节点
当前提交
f2278bcb78

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

@@ -26,6 +26,8 @@ import com.tofly.feesapi.security.model.CzyUserDetails;
 import com.tofly.feesapi.yhgl.entity.YhKhjbxx;
 import com.tofly.feesapi.yhgl.mapper.YhKhjbxxMapper;
 import com.tofly.feesapi.yhgl.service.YhKhjbxxService;
+import com.tofly.feesapi.znbgl.entity.ZnbYhda;
+import com.tofly.feesapi.znbgl.service.ZnbYhdaService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -33,6 +35,7 @@ import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.security.core.annotation.AuthenticationPrincipal;
+import org.springframework.security.task.DelegatingSecurityContextAsyncTaskExecutor;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 import springfox.documentation.annotations.ApiIgnore;
@@ -56,6 +59,8 @@ public class YhCbkxxController {
 
     private final YyCblrService yyCblrService;
 
+    private final ZnbYhdaService znbYhdaService;
+
     @ApiOperationSupport(order = 5)
     @GetMapping("/page")
     @ApiOperation(value = "查询普表水表档案(分页)", tags = {"抄表序号调整", "批量设置水价", "用户换表"})
@@ -168,9 +173,16 @@ public class YhCbkxxController {
             yyCblr.setSscbb(yhKhjbxx.getSscbb());
             //endregion
 
-            if (yyCblrService.save(yyCblr)
-                    && yhCbkxxService.save(yhCbkxx)) {
-                return ResultRespone.success(true);
+            if (yyCblrService.save(yyCblr) && yhCbkxxService.save(yhCbkxx)) {
+                if (yhCbkxx.getSblb().equals("2") || yhCbkxx.getSblb().equals("3")) {
+                    if (znbYhdaService.savaZnbYhda(yhKhjbxx, yhCbkxx)) {
+                        return ResultRespone.success(true);
+                    } else {
+                        return ResultRespone.failed("智能表档案添加失败!");
+                    }
+                } else {
+                    return ResultRespone.success(true);
+                }
             } else {
                 return ResultRespone.failed("添加失败!");
             }
@@ -190,9 +202,23 @@ public class YhCbkxxController {
         } else {
             queryWrapper.eq("yhbh", yhCbkxx.getYhbh()).and(i -> i.eq("cbkh", yhCbkxx.getCbkh()));
         }
-
-
-        return ResultRespone.success(yhCbkxxService.update(yhCbkxx, queryWrapper));
+        YhCbkxx oldyhCbkxx = yhCbkxxService.getOne(queryWrapper);
+        if (!oldyhCbkxx.getSblb().equals(yhCbkxx.getSblb())) {
+            return ResultRespone.failed("修改失败,不能修改水表类型!");
+        }
+        if (yhCbkxxService.update(yhCbkxx, queryWrapper)) {
+            if (yhCbkxx.getSblb().equals("2") || yhCbkxx.getSblb().equals("3")) {
+                YhKhjbxx yhKhjbxx = yhKhjbxxService.getById(yhCbkxx.getYhbh());
+                if (znbYhdaService.updateZnbYhda(yhKhjbxx, yhCbkxx, "1")) {
+                    return ResultRespone.success(true);
+                } else {
+                    return ResultRespone.failed("智能表档案修改失败!");
+                }
+            } else {
+                return ResultRespone.success(true);
+            }
+        }
+        return ResultRespone.failed("修改水表档案失败!");
     }
 
     @ApiOperationSupport(order = 8)

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

@@ -1,5 +1,6 @@
 package com.tofly.feesapi.bjgl.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.tofly.feesapi.bjgl.entity.YhCbkxx;
@@ -25,6 +26,8 @@ import com.tofly.feesapi.security.model.CzyUserDetails;
 import com.tofly.feesapi.yhgl.entity.YhKhjbxx;
 import com.tofly.feesapi.yhgl.entity.dto.YhKhjbxxInsert;
 import com.tofly.feesapi.yhgl.service.YhKhjbxxService;
+import com.tofly.feesapi.znbgl.entity.ZnbYhda;
+import com.tofly.feesapi.znbgl.service.ZnbYhdaService;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -53,6 +56,8 @@ public class YhCbkxxServiceImpl extends ServiceImpl<YhCbkxxMapper, YhCbkxx> impl
 
     @Autowired
     private BmSjService sjService;
+    @Autowired
+    private ZnbYhdaService znbYhdaService;
 
     @Autowired(required = false)
     private Map<String, CjService> cjServices;
@@ -280,9 +285,11 @@ public class YhCbkxxServiceImpl extends ServiceImpl<YhCbkxxMapper, YhCbkxx> impl
     @Override
     public boolean hb(YhHbUpdate update, CzyUserDetails czyUserDetails) {
         String yhbh = update.getYhbh();
-        if (StringUtils.isBlank(yhbh)) throw new FeesException("用户编号不能为空", FeesErrorCode.BUSINESS_ERROR);
+        if (StringUtils.isBlank(yhbh))
+            throw new FeesException("用户编号不能为空", FeesErrorCode.BUSINESS_ERROR);
         YhCbkxx oldYhCbkxx = this.getById(yhbh);
-        if (oldYhCbkxx == null) throw new FeesException("水表档案不存在", FeesErrorCode.BUSINESS_ERROR);
+        if (oldYhCbkxx == null)
+            throw new FeesException("水表档案不存在", FeesErrorCode.BUSINESS_ERROR);
         YhCbkxx yhCbkxx = new YhCbkxx();
         BeanUtils.copyProperties(oldYhCbkxx, yhCbkxx);
         BeanUtils.copyProperties(update, yhCbkxx);
@@ -292,6 +299,14 @@ public class YhCbkxxServiceImpl extends ServiceImpl<YhCbkxxMapper, YhCbkxx> impl
         }
         yhCbkxx.setCzsj(LocalDateTime.now());
         this.updateById(yhCbkxx);
+        if (yhCbkxx.getSblb().equals("2") || yhCbkxx.getSblb().equals("3")) {
+            YhKhjbxx yhKhjbxx = yhKhjbxxService.getById(yhbh);
+            if (znbYhdaService.count(new QueryWrapper<ZnbYhda>().lambda().eq(ZnbYhda::getYhbh, yhbh)) > 0) {
+                znbYhdaService.updateZnbYhda(yhKhjbxx,yhCbkxx,"2");
+            } else {
+                znbYhdaService.savaZnbYhda(yhKhjbxx,yhCbkxx,"2");
+            }
+        }
         saveLog(yhCbkxx, oldYhCbkxx, czyUserDetails, "换表");
         return true;
     }

+ 6 - 6
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/cbgl/controller/ZnbZlLogController.java

@@ -2,7 +2,6 @@ package com.tofly.feesapi.cbgl.controller;
 
 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.cbgl.entity.ZnbZlLog;
 import com.tofly.feesapi.cbgl.entity.dto.ZnbFkFilter;
 import com.tofly.feesapi.cbgl.entity.dto.ZnbZlLogFilter;
@@ -44,21 +43,22 @@ public class ZnbZlLogController {
 
     /**
      * 新增智能表指令明细
+     *
      * @param znbZlLog 智能表指令明细
      * @return ResultRespone
      */
-    @ToFlyAppLog(title="新增智能表指令明细" )
+    @ApiOperationSupport(order = 2)
     @ApiOperation(value = "新增智能表指令明细")
-    @PostMapping
+    @PostMapping("/save")
     public ResultRespone save(@RequestBody ZnbZlLog znbZlLog) {
         return ResultRespone.success(znbZlLogService.save(znbZlLog));
     }
 
-    @ApiOperationSupport(order=2)
+    @ApiOperationSupport(order = 3)
     @ApiOperation(value = "智能表阀控")
     @PostMapping
-    public  ResultRespone<Boolean> ZnbFk(@ModelAttribute ZnbFkFilter filter, @ApiIgnore @AuthenticationPrincipal CzyUserDetails czyUserDetails){
-        boolean result = znbZlLogService.ZnbFk(filter,czyUserDetails);
+    public ResultRespone<Boolean> ZnbFk(@ModelAttribute ZnbFkFilter filter, @ApiIgnore @AuthenticationPrincipal CzyUserDetails czyUserDetails) {
+        boolean result = znbZlLogService.ZnbFk(filter, czyUserDetails);
         return result ? ResultRespone.success(true, "指令下发成功") : ResultRespone.failed(false, "指令下发失败");
     }
 //    @ApiOperationSupport(order = 2)

+ 11 - 8
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/cbgl/service/impl/ZnbZlLogServiceImpl.java

@@ -17,6 +17,7 @@ import com.tofly.feesapi.common.exception.FeesException;
 import com.tofly.feesapi.security.model.CzyUserDetails;
 import com.tofly.feesapi.yhgl.entity.YhKhjbxx;
 import com.tofly.feesapi.yhgl.service.YhKhjbxxService;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.support.TransactionTemplate;
@@ -48,14 +49,16 @@ public class ZnbZlLogServiceImpl extends ServiceImpl<ZnbZlLogMapper, ZnbZlLog> i
 
     @Override
     public PageResult<ZnbZlLogSelect> getPage(PageDto pageDto, ZnbZlLogFilter filter) {
-        if (filter.getZltype().equals("znb_da_log")) {
-            filter.setZltype("0");
-        }
-        if (filter.getZltype().equals("znb_zl_log")) {
-            filter.setZltype("1");
-        }
-        if (filter.getZltype().equals("znb_cz_log")) {
-            filter.setZltype("2");
+        if (StringUtils.isNotEmpty(filter.getZltype())) {
+            if (filter.getZltype().equals("znb_da_log")) {
+                filter.setZltype("0");
+            }
+            if (filter.getZltype().equals("znb_zl_log")) {
+                filter.setZltype("1");
+            }
+            if (filter.getZltype().equals("znb_cz_log")) {
+                filter.setZltype("2");
+            }
         }
         PageDto<ZnbZlLogSelect> page = this.baseMapper.getPage(pageDto, filter);
         return page.toVo();

+ 25 - 0
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/common/constant/TbbzEnum.java

@@ -0,0 +1,25 @@
+package com.tofly.feesapi.common.constant;
+
+import com.baomidou.mybatisplus.annotation.IEnum;
+
+/**
+ * @author lihaoli
+ * @date 2024/4/25
+ */
+public enum TbbzEnum implements IEnum<Integer> {
+    未同步(0, "未同步"),
+    同步(1, "同步");
+
+    TbbzEnum(Integer value, String desc) {
+        this.value = value;
+        this.desc = desc;
+    }
+
+    private Integer value;
+    private String desc;
+
+    @Override
+    public Integer getValue() {
+        return this.value;
+    }
+}

+ 71 - 50
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/yhgl/controller/YhKhjbxxController.java

@@ -356,52 +356,53 @@ public class YhKhjbxxController {
                                     yyCblrService.save(bwMeterReadPlan);
                                     //同步智能表档案
                                     if (sblb.equals("2") || sblb.equals("3")) {
-                                        ZnbYhda znbYhda = new ZnbYhda();
-
-                                        znbYhda.setYhbh(user.getYhbh());//用户编号
-                                        znbYhda.setYhxm(user.getYhxm());//用户姓名
-                                        znbYhda.setYhdz(user.getYhdz());//用户地址
-                                        znbYhda.setLxdh(user.getLxdh());//联系电话
-                                        znbYhda.setSsgs(ssgs);//所属公司
-                                        znbYhda.setSspq(sscbpq);//片区
-                                        znbYhda.setSscbb(sscbb);//抄表本
-
-                                        znbYhda.setJgbm(sjbm);//价格编码
-                                        znbYhda.setBjcj(sbsccj);//厂家
-                                        znbYhda.setBjbh(user.getSbbh());//表具编号
-                                        znbYhda.setBjxh(sbxh);//表具型号
-                                        znbYhda.setBjlb(sblb);//水表类型
-                                        znbYhda.setBjwz(bjwz);//位置
-                                        znbYhda.setBjkj(user.getSbkj());//口径
-                                        znbYhda.setBjlc(sblc);//表具量程
-                                        znbYhda.setCbpl(cbpl);//抄表频率
-                                        znbYhda.setBjqd(BigDecimal.valueOf(Long.valueOf(user.getSbqs())));//表具起度
-                                        znbYhda.setBjzd(BigDecimal.valueOf(Long.valueOf(user.getSbqs())));//表具止度
-                                        znbYhda.setBjbh(user.getSbbh());//水表编号
-                                        znbYhda.setJdrq(new Date());//建档日期
-                                        znbYhda.setJdpch(strplbh);//建档批次号
-                                        znbYhda.setCzry(czrybm);//操作人员编码
-                                        znbYhda.setCzrq(new Date());//操作日期
-                                        znbYhda.setYhzt(daCustomer.getYhzt().getValue().toString());//用户状态
-                                        znbYhda.setFmzt("1");//阀门状态0关阀1开阀
-                                        znbYhda.setBjzt("1");//表具状态0异常1正常
-                                        znbYhda.setJdlx("0");//建档类型(0:建档;1:变更;2:换表)
-                                        znbYhdaService.save(znbYhda);
-                                        //添加智能表档案日志
-                                        ZnbZlLog znbZlLog = new ZnbZlLog();
-                                        znbZlLog.setYhbh(user.getYhbh());
-                                        znbZlLog.setCbkh(bwMeterReadPlan.getCbkh());
-                                        znbZlLog.setCbkid(bwMeterReadPlan.getCbkid());
-                                        znbZlLog.setPch(strplbh);
-                                        znbZlLog.setSccj(sbsccj);
-                                        znbZlLog.setSsgs(ssgs);
-                                        znbZlLog.setCzry(czrybm);
-                                        znbZlLog.setCzsj(LocalDateTime.now());
-                                        znbZlLog.setClLock("0");
-                                        znbZlLog.setClCljg("0");
-                                        znbZlLog.setZltype("1");
-                                        iZnbZlLogService.save(znbZlLog);
-                                        //znbDaLogService.addznbDaLog(znbYhda);
+                                        znbYhdaService.savaZnbYhda(daCustomer, daMeter);
+//                                        ZnbYhda znbYhda = new ZnbYhda();
+//
+//                                        znbYhda.setYhbh(user.getYhbh());//用户编号
+//                                        znbYhda.setYhxm(user.getYhxm());//用户姓名
+//                                        znbYhda.setYhdz(user.getYhdz());//用户地址
+//                                        znbYhda.setLxdh(user.getLxdh());//联系电话
+//                                        znbYhda.setSsgs(ssgs);//所属公司
+//                                        znbYhda.setSspq(sscbpq);//片区
+//                                        znbYhda.setSscbb(sscbb);//抄表本
+//
+//                                        znbYhda.setJgbm(sjbm);//价格编码
+//                                        znbYhda.setBjcj(sbsccj);//厂家
+//                                        znbYhda.setBjbh(user.getSbbh());//表具编号
+//                                        znbYhda.setBjxh(sbxh);//表具型号
+//                                        znbYhda.setBjlb(sblb);//水表类型
+//                                        znbYhda.setBjwz(bjwz);//位置
+//                                        znbYhda.setBjkj(user.getSbkj());//口径
+//                                        znbYhda.setBjlc(sblc);//表具量程
+//                                        znbYhda.setCbpl(cbpl);//抄表频率
+//                                        znbYhda.setBjqd(BigDecimal.valueOf(Long.valueOf(user.getSbqs())));//表具起度
+//                                        znbYhda.setBjzd(BigDecimal.valueOf(Long.valueOf(user.getSbqs())));//表具止度
+//                                        znbYhda.setBjbh(user.getSbbh());//水表编号
+//                                        znbYhda.setJdrq(new Date());//建档日期
+//                                        znbYhda.setJdpch(strplbh);//建档批次号
+//                                        znbYhda.setCzry(czrybm);//操作人员编码
+//                                        znbYhda.setCzrq(new Date());//操作日期
+//                                        znbYhda.setYhzt(daCustomer.getYhzt().getValue().toString());//用户状态
+//                                        znbYhda.setFmzt("1");//阀门状态0关阀1开阀
+//                                        znbYhda.setBjzt("1");//表具状态0异常1正常
+//                                        znbYhda.setJdlx("0");//建档类型(0:建档;1:变更;2:换表)
+//                                        znbYhdaService.save(znbYhda);
+//                                        //添加智能表档案日志
+//                                        ZnbZlLog znbZlLog = new ZnbZlLog();
+//                                        znbZlLog.setYhbh(user.getYhbh());
+//                                        znbZlLog.setCbkh(bwMeterReadPlan.getCbkh());
+//                                        znbZlLog.setCbkid(bwMeterReadPlan.getCbkid());
+//                                        znbZlLog.setPch(strplbh);
+//                                        znbZlLog.setSccj(sbsccj);
+//                                        znbZlLog.setSsgs(ssgs);
+//                                        znbZlLog.setCzry(czrybm);
+//                                        znbZlLog.setCzsj(LocalDateTime.now());
+//                                        znbZlLog.setClLock("0");
+//                                        znbZlLog.setClCljg("0");
+//                                        znbZlLog.setZltype("1");
+//                                        iZnbZlLogService.save(znbZlLog);
+//                                        //znbDaLogService.addznbDaLog(znbYhda);
                                     }
                                 }
                             }
@@ -769,8 +770,19 @@ public class YhKhjbxxController {
                         //执行抄表计划(0普表、1IC卡表、2远传表、3NB表、4流量计)
                         if (daCustomerAndMeter.getYhCbkxx().getSblb().equals("0") || daCustomerAndMeter.getYhCbkxx().getSblb().equals("2") || daCustomerAndMeter.getYhCbkxx().getSblb().equals("3") || daCustomerAndMeter.getYhCbkxx().getSblb().equals("4")) {
                             if (yyCblrService.save(yyCblr)) {
-                                rest.setCode(1);
-                                rest.setMessage("新增用户档案成功");
+                                if (daCustomerAndMeter.getYhCbkxx().getSblb().equals("2") || daCustomerAndMeter.getYhCbkxx().getSblb().equals("3")) {
+                                    //执行智能表档案添加
+                                    if (znbYhdaService.savaZnbYhda(yhKhjbxx, yhCbkxx)) {
+                                        rest.setCode(1);
+                                        rest.setMessage("新增用户档案成功");
+                                    } else {
+                                        rest.setCode(-1);
+                                        rest.setMessage("新增智能表档案信息失败");
+                                    }
+                                } else {
+                                    rest.setCode(1);
+                                    rest.setMessage("新增用户档案成功");
+                                }
                             } else {
                                 rest.setCode(-1);
                                 rest.setMessage("新增用户抄表计划失败");
@@ -801,10 +813,19 @@ public class YhKhjbxxController {
                     //用户水表档案执行功
                     QueryWrapper<YhCbkxx> queryWrapper = new QueryWrapper<>();
                     queryWrapper.eq("cbkid", daCustomerAndMeter.getYhCbkxx().getCbkid());
+                    YhCbkxx oldyhCbkxx = yhCbkxxService.getOne(queryWrapper);
+                    if (!oldyhCbkxx.getSblb().equals(yhCbkxx.getSblb())) {
+                        return ResultRespone.failed("修改水表档案失败,不能修改水表类型!");
+                    }
                     if (yhCbkxxService.update(yhCbkxx, queryWrapper)) {
                         if (yyCblrService.updateById(yyCblr)) {
-                            rest.setCode(1);
-                            rest.setMessage("操作成功");
+                            //用户水表档案执行功
+                            if (daCustomerAndMeter.getYhCbkxx().getSblb().equals("2") || daCustomerAndMeter.getYhCbkxx().getSblb().equals("3")) {
+                                if (znbYhdaService.updateZnbYhda(yhKhjbxx, yhCbkxx, "1")) {
+                                    rest.setCode(1);
+                                    rest.setMessage("操作成功");
+                                }
+                            }
                         }
                     }
                 }

+ 9 - 2
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/znbgl/entity/vo/ZnbYhdaSelect.java

@@ -2,6 +2,7 @@ package com.tofly.feesapi.znbgl.entity.vo;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.tofly.feesapi.common.constant.FmztEnum;
+import com.tofly.feesapi.common.constant.TbbzEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
@@ -78,10 +79,10 @@ public class ZnbYhdaSelect implements Serializable {
     @ApiModelProperty(value = "水量比例3", position = 13, example = "0.5")
     private BigDecimal slbl3;
 
-    @ApiModelProperty(value = "所属抄表册名称",position = 14)
+    @ApiModelProperty(value = "所属抄表册名称", position = 14)
     private String sscbbmc;
 
-    @ApiModelProperty(value = "所属抄表片区名称",position = 15)
+    @ApiModelProperty(value = "所属抄表片区名称", position = 15)
     private String sscbpqmc;
 
     @ApiModelProperty(value = "联系电话", position = 16)
@@ -95,4 +96,10 @@ public class ZnbYhdaSelect implements Serializable {
 
     @ApiModelProperty(value = "阀门状态(0关阀 1处理中 2开阀)", position = 19)
     private FmztEnum fmzt;
+    @ApiModelProperty(value = "表具厂家", position = 20)
+    private String bjcjmc;
+    @ApiModelProperty(value = "表具余额", position = 21)
+    private BigDecimal bjye;
+    @ApiModelProperty(value = "档案同步标志0未同步,1同步", position = 22)
+    private TbbzEnum tbbz;
 }

+ 11 - 0
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/znbgl/service/ZnbYhdaService.java

@@ -5,11 +5,14 @@
 package com.tofly.feesapi.znbgl.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.tofly.feesapi.bjgl.entity.YhCbkxx;
 import com.tofly.feesapi.common.entity.dto.PageDto;
 import com.tofly.feesapi.common.entity.vo.PageResult;
+import com.tofly.feesapi.yhgl.entity.YhKhjbxx;
 import com.tofly.feesapi.znbgl.entity.ZnbYhda;
 import com.tofly.feesapi.znbgl.entity.dto.ZnbYhdaFilter;
 import com.tofly.feesapi.znbgl.entity.vo.ZnbYhdaSelect;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 智能表用户档案
@@ -20,4 +23,12 @@ import com.tofly.feesapi.znbgl.entity.vo.ZnbYhdaSelect;
 public interface ZnbYhdaService extends IService<ZnbYhda> {
 
     PageResult<ZnbYhdaSelect> getPage(PageDto pageDto, ZnbYhdaFilter filter);
+
+    boolean savaZnbYhda(YhKhjbxx yhKhjbxx, YhCbkxx yhCbkxx);
+
+    @Transactional(rollbackFor = Exception.class) //声明式事务管理
+    boolean savaZnbYhda(YhKhjbxx yhKhjbxx, YhCbkxx yhCbkxx, String jdlx);
+
+    @Transactional(rollbackFor = Exception.class) //声明式事务管理
+    boolean updateZnbYhda(YhKhjbxx yhKhjbxx, YhCbkxx yhCbkxx, String jdlx);
 }

+ 133 - 1
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/znbgl/service/impl/ZnbYhdaServiceImpl.java

@@ -4,15 +4,27 @@
  */
 package com.tofly.feesapi.znbgl.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.tofly.feesapi.bjgl.entity.YhCbkxx;
+import com.tofly.feesapi.cbgl.entity.ZnbZlLog;
+import com.tofly.feesapi.cbgl.service.IZnbZlLogService;
 import com.tofly.feesapi.common.entity.dto.PageDto;
 import com.tofly.feesapi.common.entity.vo.PageResult;
+import com.tofly.feesapi.yhgl.entity.YhKhjbxx;
 import com.tofly.feesapi.znbgl.entity.ZnbYhda;
 import com.tofly.feesapi.znbgl.entity.dto.ZnbYhdaFilter;
 import com.tofly.feesapi.znbgl.entity.vo.ZnbYhdaSelect;
+import com.tofly.feesapi.znbgl.mapper.ZnbYhdaMapper;
 import com.tofly.feesapi.znbgl.service.ZnbYhdaService;
+import io.micrometer.core.instrument.util.StringUtils;
+import org.apache.poi.util.StringUtil;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-import com.tofly.feesapi.znbgl.mapper.ZnbYhdaMapper;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
 
 /**
  * 智能表用户档案
@@ -20,12 +32,132 @@ import com.tofly.feesapi.znbgl.mapper.ZnbYhdaMapper;
  * @author sxb
  * @date Tue Apr 23 00:00:00 CST 2024
  */
+
 @Service("znbYhdaService")
 public class ZnbYhdaServiceImpl extends ServiceImpl<ZnbYhdaMapper, ZnbYhda> implements ZnbYhdaService {
+    @Autowired
+    private IZnbZlLogService iZnbZlLogService;
+
     @Override
     public PageResult<ZnbYhdaSelect> getPage(PageDto pageDto, ZnbYhdaFilter filter) {
         PageDto<ZnbYhdaSelect> page = this.baseMapper.getPage(pageDto, filter);
         PageResult<ZnbYhdaSelect> pageResult = page.toVo();
         return pageResult;
     }
+
+    public boolean savaZnbYhda(YhKhjbxx yhKhjbxx, YhCbkxx yhCbkx) {
+        return savaZnbYhda(yhKhjbxx, yhCbkx, "0");
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class) //声明式事务管理
+    public boolean savaZnbYhda(YhKhjbxx yhKhjbxx, YhCbkxx yhCbkxx, String jdlx) {
+        ZnbYhda znbYhda = new ZnbYhda();
+
+        znbYhda.setYhbh(yhKhjbxx.getYhbh());//用户编号
+        znbYhda.setYhxm(yhKhjbxx.getYhxm());//用户姓名
+        znbYhda.setYhdz(yhKhjbxx.getYhdz());//用户地址
+        znbYhda.setLxdh(yhKhjbxx.getLxdh());//联系电话
+        znbYhda.setSsgs(yhKhjbxx.getSsgs());//所属公司
+        znbYhda.setSspq(yhKhjbxx.getSscbpq());//片区
+        znbYhda.setSscbb(yhKhjbxx.getSscbb());//抄表本
+        znbYhda.setJdrq(yhKhjbxx.getJdrq());//建档日期
+        znbYhda.setJdpch(yhKhjbxx.getJdpcxlh());//建档批次号
+        znbYhda.setCzry(yhKhjbxx.getCzrybm());//操作人员编码
+        znbYhda.setCzrq(yhKhjbxx.getCzsj());//操作日期
+        znbYhda.setYhzt(yhKhjbxx.getYhzt().getValue().toString());//用户状态
+
+        znbYhda.setJgbm(yhCbkxx.getSjbm());//价格编码
+        znbYhda.setBjcj(yhCbkxx.getSbsccj());//厂家
+        znbYhda.setBjbh(yhCbkxx.getSbbh());//表具编号
+        znbYhda.setBjxh(yhCbkxx.getSbxh());//表具型号
+        znbYhda.setBjlb(yhCbkxx.getSblb());//水表类型
+        znbYhda.setBjwz(yhCbkxx.getBjwz());//位置
+        znbYhda.setBjkj(yhCbkxx.getSbkj());//口径
+        znbYhda.setBjlc(yhCbkxx.getSblc());//表具量程
+        znbYhda.setCbpl(yhCbkxx.getCbpl());//抄表频率
+        znbYhda.setBjqd(BigDecimal.valueOf(Long.valueOf(yhCbkxx.getSbqs())));//表具起度
+        znbYhda.setBjzd(BigDecimal.valueOf(Long.valueOf(yhCbkxx.getSbqs())));//表具止度
+        znbYhda.setBjbh(yhCbkxx.getSbbh());//水表编号
+
+        znbYhda.setFmzt("1");//阀门状态0关阀1开阀
+        znbYhda.setBjzt("1");//表具状态0异常1正常
+        znbYhda.setJdlx(jdlx);//建档类型(0:建档;1:变更;2:换表)
+        if (this.save(znbYhda)) {
+            //添加智能表指令日志
+            ZnbZlLog znbZlLog = new ZnbZlLog();
+            znbZlLog.setYhbh(znbYhda.getYhbh());
+            znbZlLog.setPch(yhKhjbxx.getJdpcxlh());
+            znbZlLog.setSsgs(yhKhjbxx.getSsgs());
+            znbZlLog.setCzry(yhKhjbxx.getCzrybm());
+            znbZlLog.setCbkh(yhCbkxx.getCbkh());
+            znbZlLog.setCbkid(yhCbkxx.getCbkid());
+            znbZlLog.setSccj(yhCbkxx.getSbsccj());
+
+            znbZlLog.setCzsj(LocalDateTime.now());
+            znbZlLog.setClLock("0");
+            znbZlLog.setClCljg("0");
+            znbZlLog.setZltype("0");
+            return iZnbZlLogService.save(znbZlLog);
+        }
+        return false;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class) //声明式事务管理
+    public boolean updateZnbYhda(YhKhjbxx yhKhjbxx, YhCbkxx yhCbkxx, String jdlx) {
+        ZnbYhda znbYhda = this.getOne(new QueryWrapper<ZnbYhda>().lambda()
+                .eq(ZnbYhda::getYhbh, yhKhjbxx.getYhbh())
+        );
+        if (znbYhda == null) {
+            return false;
+        }
+        znbYhda.setYhbh(yhKhjbxx.getYhbh());//用户编号
+        znbYhda.setYhxm(yhKhjbxx.getYhxm());//用户姓名
+        znbYhda.setYhdz(yhKhjbxx.getYhdz());//用户地址
+        znbYhda.setLxdh(yhKhjbxx.getLxdh());//联系电话
+        znbYhda.setSsgs(yhKhjbxx.getSsgs());//所属公司
+        znbYhda.setSspq(yhKhjbxx.getSscbpq());//片区
+        znbYhda.setSscbb(yhKhjbxx.getSscbb());//抄表本
+        znbYhda.setJdrq(yhKhjbxx.getJdrq());//建档日期
+        znbYhda.setJdpch(yhKhjbxx.getJdpcxlh());//建档批次号
+        znbYhda.setCzry(yhKhjbxx.getCzrybm());//操作人员编码
+        znbYhda.setCzrq(yhKhjbxx.getCzsj());//操作日期
+        znbYhda.setYhzt(yhKhjbxx.getYhzt().getValue().toString());//用户状态
+
+        znbYhda.setJgbm(yhCbkxx.getSjbm());//价格编码
+        znbYhda.setBjcj(yhCbkxx.getSbsccj());//厂家
+        znbYhda.setBjbh(yhCbkxx.getSbbh());//表具编号
+        znbYhda.setBjxh(yhCbkxx.getSbxh());//表具型号
+        znbYhda.setBjlb(yhCbkxx.getSblb());//水表类型
+        znbYhda.setBjwz(yhCbkxx.getBjwz());//位置
+        znbYhda.setBjkj(yhCbkxx.getSbkj());//口径
+        znbYhda.setBjlc(yhCbkxx.getSblc());//表具量程
+        znbYhda.setCbpl(yhCbkxx.getCbpl());//抄表频率
+        znbYhda.setBjqd(BigDecimal.valueOf(Long.valueOf(yhCbkxx.getSbqs())));//表具起度
+        znbYhda.setBjzd(BigDecimal.valueOf(Long.valueOf(yhCbkxx.getSbqs())));//表具止度
+        znbYhda.setBjbh(yhCbkxx.getSbbh());//水表编号
+
+//        znbYhda.setFmzt("1");//阀门状态0关阀1开阀
+//        znbYhda.setBjzt("1");//表具状态0异常1正常
+        znbYhda.setJdlx(jdlx);//建档类型(0:建档;1:变更;2:换表)
+        if (this.updateById(znbYhda)) {
+            //添加智能表指令日志
+            ZnbZlLog znbZlLog = new ZnbZlLog();
+            znbZlLog.setYhbh(znbYhda.getYhbh());
+            znbZlLog.setPch(yhKhjbxx.getJdpcxlh());
+            znbZlLog.setSsgs(yhKhjbxx.getSsgs());
+            znbZlLog.setCzry(yhKhjbxx.getCzrybm());
+            znbZlLog.setCbkh(yhCbkxx.getCbkh());
+            znbZlLog.setCbkid(yhCbkxx.getCbkid());
+            znbZlLog.setSccj(yhCbkxx.getSbsccj());
+
+            znbZlLog.setCzsj(LocalDateTime.now());
+            znbZlLog.setClLock("0");
+            znbZlLog.setClCljg("0");
+            znbZlLog.setZltype("0");
+            return iZnbZlLogService.save(znbZlLog);
+        }
+        return false;
+    }
 }

+ 6 - 2
collect-fees/collect-fees-api/src/main/resources/mapper/znbgl/ZnbYhdaMapper.xml

@@ -38,12 +38,16 @@
 
     <!--自定义智能表档案分页查询 -->
     <select id="getPage" resultType="com.tofly.feesapi.znbgl.entity.vo.ZnbYhdaSelect">
-        SELECT a.yhbh, a.yhxm, a.yhdz, a.jgbm,
-        a.bjbh, a.fmzt, f.cbbmc AS sscbbmc, g.cbpqmc AS sscbpqmc, a.lxdh, d.name AS sblbmc
+        SELECT a.yhbh, a.yhxm, a.yhdz, a.jgbm,a.bjye,a.tbbz,a.bjbh, a.fmzt, a.lxdh,
+               f.cbbmc AS sscbbmc,
+               g.cbpqmc AS sscbpqmc,
+               d.name AS sblbmc,
+               h.name AS bjcjmc
         FROM znb_yhda a
         LEFT JOIN bm_sblb d ON a.bjlb = d.code
         LEFT JOIN bm_cbb f ON a.sscbb = f.cbbbm
         LEFT JOIN bm_cbpq g ON a.sspq = g.cbpqbm
+        LEFT JOIN bm_sbsccj h on a.bjcj=h.code
         WHERE 1=1
         <!--模糊查询 -->
         <if test="filter.searchText!=null">