Browse Source

开关阀指令保存

lihaoli 11 months ago
parent
commit
015bcf4013

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

@@ -2,18 +2,21 @@ 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;
 import com.tofly.feesapi.cbgl.entity.vo.ZnbZlLogSelect;
 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.security.model.CzyUserDetails;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.ModelAttribute;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.security.core.annotation.AuthenticationPrincipal;
+import org.springframework.web.bind.annotation.*;
+import springfox.documentation.annotations.ApiIgnore;
 
 /**
  * <p>
@@ -39,6 +42,25 @@ public class ZnbZlLogController {
         return ResultRespone.success(znbZlLogService.getPage(pageDto, filter));
     }
 
+    /**
+     * 新增智能表指令明细
+     * @param znbZlLog 智能表指令明细
+     * @return ResultRespone
+     */
+    @ToFlyAppLog(title="新增智能表指令明细" )
+    @ApiOperation(value = "新增智能表指令明细")
+    @PostMapping
+    public ResultRespone save(@RequestBody ZnbZlLog znbZlLog) {
+        return ResultRespone.success(znbZlLogService.save(znbZlLog));
+    }
+
+    @ApiOperationSupport(order=2)
+    @ApiOperation(value = "智能表阀控")
+    @PostMapping
+    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)
 //    @GetMapping("/export")
 //    @ApiOperation(value = "导出智能表指令明细")

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

@@ -0,0 +1,17 @@
+package com.tofly.feesapi.cbgl.entity.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+@ApiModel("用户阀控指令dto")
+public class ZnbFkFilter {
+
+    @ApiModelProperty(value = "指令(操作)类型编码 0-关阀 1-开阀",required = true)
+    private String zltype;
+    @ApiModelProperty(value = "操作用户编号",  required = true)
+    private List<String> yhbhs;
+}

+ 4 - 0
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/cbgl/service/IZnbZlLogService.java

@@ -3,10 +3,12 @@ package com.tofly.feesapi.cbgl.service;
 import com.tofly.feesapi.cbgl.entity.ZnbZlLog;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.tofly.feesapi.cbgl.entity.dto.ZnbCbLogFilter;
+import com.tofly.feesapi.cbgl.entity.dto.ZnbFkFilter;
 import com.tofly.feesapi.cbgl.entity.dto.ZnbZlLogFilter;
 import com.tofly.feesapi.cbgl.entity.vo.ZnbZlLogSelect;
 import com.tofly.feesapi.common.entity.dto.PageDto;
 import com.tofly.feesapi.common.entity.vo.PageResult;
+import com.tofly.feesapi.security.model.CzyUserDetails;
 
 import java.util.List;
 
@@ -23,4 +25,6 @@ public interface IZnbZlLogService extends IService<ZnbZlLog> {
     PageResult<ZnbZlLogSelect> getPage(PageDto pageDto, ZnbZlLogFilter filter);
 
     List<ZnbZlLogSelect> getList(ZnbCbLogFilter filter);
+
+    boolean ZnbFk(ZnbFkFilter filter, CzyUserDetails czyUserDetails);
 }

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

@@ -1,7 +1,10 @@
 package com.tofly.feesapi.cbgl.service.impl;
 
+import com.tofly.feesapi.bjgl.entity.YhCbkxx;
+import com.tofly.feesapi.bjgl.service.YhCbkxxService;
 import com.tofly.feesapi.cbgl.entity.ZnbZlLog;
 import com.tofly.feesapi.cbgl.entity.dto.ZnbCbLogFilter;
+import com.tofly.feesapi.cbgl.entity.dto.ZnbFkFilter;
 import com.tofly.feesapi.cbgl.entity.dto.ZnbZlLogFilter;
 import com.tofly.feesapi.cbgl.entity.vo.ZnbZlLogSelect;
 import com.tofly.feesapi.cbgl.mapper.ZnbZlLogMapper;
@@ -9,9 +12,18 @@ import com.tofly.feesapi.cbgl.service.IZnbZlLogService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.tofly.feesapi.common.entity.dto.PageDto;
 import com.tofly.feesapi.common.entity.vo.PageResult;
+import com.tofly.feesapi.common.exception.FeesErrorCode;
+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.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.support.TransactionTemplate;
 
+import java.time.LocalDateTime;
 import java.util.List;
+import java.util.UUID;
 
 /**
  * <p>
@@ -24,8 +36,27 @@ import java.util.List;
 @Service
 public class ZnbZlLogServiceImpl extends ServiceImpl<ZnbZlLogMapper, ZnbZlLog> implements IZnbZlLogService {
 
+
+    @Autowired
+    private YhKhjbxxService khjbxxService;
+
+    @Autowired
+    private YhCbkxxService cbkxxService;
+
+    @Autowired
+    private TransactionTemplate transactionTemplate;
+
     @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");
+        }
         PageDto<ZnbZlLogSelect> page = this.baseMapper.getPage(pageDto, filter);
         return page.toVo();
     }
@@ -34,4 +65,51 @@ public class ZnbZlLogServiceImpl extends ServiceImpl<ZnbZlLogMapper, ZnbZlLog> i
     public List<ZnbZlLogSelect> getList(ZnbCbLogFilter filter) {
         return this.baseMapper.getList(filter);
     }
+
+    @Override
+    public boolean ZnbFk(ZnbFkFilter filter, CzyUserDetails czyUserDetails) {
+        List<String> yhbhs = filter.getYhbhs();
+
+        if (yhbhs.size() == 0) {
+            throw new FeesException("未查询到相关操作用户", FeesErrorCode.BUSINESS_ERROR);
+        }
+        List<YhKhjbxx> yhList = khjbxxService.lambdaQuery().in(YhKhjbxx::getYhbh, yhbhs).list();
+        if (yhList.isEmpty()) {
+            throw new FeesException("未查询到可操作的用户", FeesErrorCode.BUSINESS_ERROR);
+        }
+
+        return fk(yhList, filter.getZltype(), czyUserDetails.getId()) == 1;
+    }
+
+    private int fk(List<YhKhjbxx> yhList, String zltype, Long czry) {
+        int rlt = transactionTemplate.execute(status -> {
+            try {
+                String pch = UUID.randomUUID().toString();
+                for (YhKhjbxx khjbxx : yhList) {
+                    List<YhCbkxx> cbkList = cbkxxService.lambdaQuery().in(YhCbkxx::getYhbh, khjbxx.getYhbh()).list();
+                    for (YhCbkxx cbk : cbkList) {
+                        ZnbZlLog log = new ZnbZlLog();
+                        log.setYhbh(cbk.getYhbh());
+                        log.setCbkh(cbk.getCbkh());
+                        log.setCbkid(cbk.getCbkid());
+                        log.setPch(pch);
+                        log.setSccj(cbk.getSbsccj());
+                        log.setSsgs(khjbxx.getSsgs());
+                        log.setCzry(czry.toString());
+                        log.setCzsj(LocalDateTime.now());
+                        log.setClLock("0");
+                        log.setClCljg("0");
+                        log.setZltype("1");
+                        log.setZlvalue(zltype);
+                        this.save(log);
+                    }
+                }
+                return 1;
+            } catch (Exception e) {
+                status.setRollbackOnly();
+                throw e;
+            }
+        });
+        return rlt;
+    }
 }

+ 3 - 3
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/common/constant/FmztEnum.java

@@ -8,9 +8,9 @@ import lombok.Getter;
  */
 @Getter
 public enum FmztEnum implements IEnum<String> {
-    关阀("0", ""),
-    处理中("1", ""),
-    开阀("2", "");
+    关阀("0", "关阀"),
+    处理中("1", "处理中"),
+    开阀("2", "开阀");
 
     FmztEnum(String value, String desc) {
         this.value = value;

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

@@ -16,6 +16,8 @@ import com.tofly.feesapi.bjgl.entity.vo.YhCbkxxSelect;
 import com.tofly.feesapi.bjgl.service.YhCbkxxLogService;
 import com.tofly.feesapi.bjgl.service.YhCbkxxService;
 import com.tofly.feesapi.cbgl.entity.YyCblr;
+import com.tofly.feesapi.cbgl.entity.ZnbZlLog;
+import com.tofly.feesapi.cbgl.service.IZnbZlLogService;
 import com.tofly.feesapi.cbgl.service.YyCblrService;
 import com.tofly.feesapi.common.Excel.ExcleFileUtil;
 import com.tofly.feesapi.common.constant.*;
@@ -85,6 +87,8 @@ public class YhKhjbxxController {
 
     private final ZnbDaLogService znbDaLogService;
 
+    private final IZnbZlLogService iZnbZlLogService;
+
     @ApiOperationSupport(order = 1)
     @GetMapping("/yhbh")
     @ApiOperation(value = "获取用户编号")
@@ -384,7 +388,20 @@ public class YhKhjbxxController {
                                         znbYhda.setJdlx("0");//建档类型(0:建档;1:变更;2:换表)
                                         znbYhdaService.save(znbYhda);
                                         //添加智能表档案日志
-                                        znbDaLogService.addznbDaLog(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);
                                     }
                                 }
                             }

+ 8 - 6
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/znbgl/controller/ZnbYhdaController.java

@@ -1,10 +1,12 @@
 package com.tofly.feesapi.znbgl.controller;
 
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.tofly.common.core.entity.ResultRespone;
 import com.tofly.common.log.annotation.ToFlyAppLog;
+import com.tofly.feesapi.common.entity.dto.PageDto;
+import com.tofly.feesapi.common.entity.vo.PageResult;
 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.service.ZnbYhdaService;
 import lombok.AllArgsConstructor;
 import org.springframework.web.bind.annotation.*;
@@ -31,14 +33,14 @@ public class ZnbYhdaController {
 
     /**
     * 分页查询
-    * @param page 分页对象
-    * @param znbYhda 智能表用户档案
+    * @param pageDto 分页对象
+    * @param filter 智能表用户档案
     * @return
     */
     @GetMapping("/page" )
     @ApiOperation(value = "分页查询")
-    public ResultRespone getZnbYhdaPage(Page page, @ModelAttribute ZnbYhda znbYhda) {
-      return ResultRespone.success(znbYhdaService.page(page, Wrappers.query(znbYhda)));
+    public ResultRespone<PageResult<ZnbYhdaSelect>> getPage(@ModelAttribute PageDto pageDto, @ModelAttribute ZnbYhdaFilter filter) {
+      return ResultRespone.success(znbYhdaService.getPage(pageDto, filter));
     }
 
 

+ 25 - 0
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/znbgl/entity/dto/ZnbYhdaFilter.java

@@ -0,0 +1,25 @@
+package com.tofly.feesapi.znbgl.entity.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @author lihaoli
+ * @date 2024/4/24
+ */
+@Data
+@ApiModel("智能表档案查询参数DTO")
+public class ZnbYhdaFilter {
+    @ApiModelProperty(value = "关键字(用户编号、用户姓名、用户地址、联系电话)")
+    private String searchText;
+
+    @ApiModelProperty(value = "所属公司编码")
+    private String ssgs;
+
+    @ApiModelProperty(value = "所属抄表片区编码")
+    private String sscbpq;
+
+    @ApiModelProperty("所属抄表本(册)编码")
+    private String sscbb;
+}

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

@@ -0,0 +1,98 @@
+package com.tofly.feesapi.znbgl.entity.vo;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.tofly.feesapi.common.constant.FmztEnum;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @author lihaoli
+ * @date 2024/4/24
+ */
+@Getter
+@Setter
+@ApiModel(value = "智能表档案列表", description = "用户表计信息")
+public class ZnbYhdaSelect implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "用户编号", position = 1)
+    private String yhbh;
+
+    @ApiModelProperty(value = "用户姓名", position = 2)
+    private String yhxm;
+
+    @ApiModelProperty(value = "用户地址", position = 2, example = "13-1-8(29号)")
+    private String yhdz;
+
+    @ApiModelProperty(value = "水价编码", hidden = true)
+    @JsonIgnore
+    private String sjbm;
+
+    @ApiModelProperty(value = "水价名称", position = 3, example = "居民用水")
+    private String sjmc;
+
+    @ApiModelProperty(value = "水价", position = 4, example = "2.6")
+    private String sj;
+
+    @ApiModelProperty(value = "水价编码1", hidden = true)
+    @JsonIgnore
+    private String sjbm1;
+
+    @ApiModelProperty(value = "水价名称1", position = 5, example = "居民用水")
+    private String sjmc1;
+
+    @ApiModelProperty(value = "水价1", position = 6, example = "2.6")
+    private String sj1;
+
+    @ApiModelProperty(value = "水量比例1", position = 7, example = "0.5")
+    private BigDecimal slbl1;
+
+    @ApiModelProperty(value = "水价编码2", hidden = true)
+    @JsonIgnore
+    private String sjbm2;
+
+    @ApiModelProperty(value = "水价名称2", position = 8, example = "居民用水")
+    private String sjmc2;
+
+    @ApiModelProperty(value = "水价2", position = 9, example = "2.6")
+    private String sj2;
+
+    @ApiModelProperty(value = "水量比例2", position = 10, example = "0.5")
+    private BigDecimal slbl2;
+
+    @ApiModelProperty(value = "水价编码3", hidden = true)
+    @JsonIgnore
+    private String sjbm3;
+
+    @ApiModelProperty(value = "水价名称3", position = 11, example = "居民用水")
+    private String sjmc3;
+
+    @ApiModelProperty(value = "水价3", position = 12, example = "2.6")
+    private String sj3;
+
+    @ApiModelProperty(value = "水量比例3", position = 13, example = "0.5")
+    private BigDecimal slbl3;
+
+    @ApiModelProperty(value = "所属抄表册名称",position = 14)
+    private String sscbbmc;
+
+    @ApiModelProperty(value = "所属抄表片区名称",position = 15)
+    private String sscbpqmc;
+
+    @ApiModelProperty(value = "联系电话", position = 16)
+    private String lxdh;
+
+    @ApiModelProperty(value = "水表编号", position = 17)
+    private String sbbh;
+
+    @ApiModelProperty(value = "水表类别", position = 18)
+    private String sblbmc;
+
+    @ApiModelProperty(value = "阀门状态(0关阀 1处理中 2开阀)", position = 19)
+    private FmztEnum fmzt;
+}

+ 7 - 1
collect-fees/collect-fees-api/src/main/java/com/tofly/feesapi/znbgl/mapper/ZnbYhdaMapper.java

@@ -5,12 +5,17 @@
 package com.tofly.feesapi.znbgl.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+import com.tofly.feesapi.common.entity.dto.PageDto;
 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.apache.ibatis.annotations.Param;
 
 import java.math.BigDecimal;
 
 import java.util.List;
+
 /**
  * 智能表用户档案
  *
@@ -18,4 +23,5 @@ import java.util.List;
  * @date Tue Apr 23 00:00:00 CST 2024
  */
 public interface ZnbYhdaMapper extends BaseMapper<ZnbYhda> {
-                                                                                                                        }
+    PageDto<ZnbYhdaSelect> getPage(PageDto pageDto, @Param("filter") ZnbYhdaFilter filter);
+}

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

@@ -5,7 +5,11 @@
 package com.tofly.feesapi.znbgl.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.tofly.feesapi.common.entity.dto.PageDto;
+import com.tofly.feesapi.common.entity.vo.PageResult;
 import com.tofly.feesapi.znbgl.entity.ZnbYhda;
+import com.tofly.feesapi.znbgl.entity.dto.ZnbYhdaFilter;
+import com.tofly.feesapi.znbgl.entity.vo.ZnbYhdaSelect;
 
 /**
  * 智能表用户档案
@@ -15,4 +19,5 @@ import com.tofly.feesapi.znbgl.entity.ZnbYhda;
  */
 public interface ZnbYhdaService extends IService<ZnbYhda> {
 
+    PageResult<ZnbYhdaSelect> getPage(PageDto pageDto, ZnbYhdaFilter filter);
 }

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

@@ -5,7 +5,11 @@
 package com.tofly.feesapi.znbgl.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.tofly.feesapi.common.entity.dto.PageDto;
+import com.tofly.feesapi.common.entity.vo.PageResult;
 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.service.ZnbYhdaService;
 import org.springframework.stereotype.Service;
 import com.tofly.feesapi.znbgl.mapper.ZnbYhdaMapper;
@@ -18,5 +22,10 @@ import com.tofly.feesapi.znbgl.mapper.ZnbYhdaMapper;
  */
 @Service("znbYhdaService")
 public class ZnbYhdaServiceImpl extends ServiceImpl<ZnbYhdaMapper, ZnbYhda> implements ZnbYhdaService {
-
+    @Override
+    public PageResult<ZnbYhdaSelect> getPage(PageDto pageDto, ZnbYhdaFilter filter) {
+        PageDto<ZnbYhdaSelect> page = this.baseMapper.getPage(pageDto, filter);
+        PageResult<ZnbYhdaSelect> pageResult = page.toVo();
+        return pageResult;
+    }
 }

File diff suppressed because it is too large
+ 61 - 33
collect-fees/collect-fees-api/src/main/resources/mapper/znbgl/ZnbYhdaMapper.xml