ソースを参照

Merge remote-tracking branch 'origin/master'

shudong 1 年間 前
コミット
2e8349d1cc

+ 90 - 76
collect-fees/collect-fees-service/src/main/java/com/tofly/fees/userprofilemgt/controller/DaHfysLogController.java

@@ -11,7 +11,9 @@ 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.fees.common.Excel.ExcleFileUtil;
+import com.tofly.fees.common.enums.UserStatusEnum;
 import com.tofly.fees.common.util.GuidGenerator;
+import com.tofly.fees.financialmgt.mapper.SfRecMapper;
 import com.tofly.fees.userprofilemgt.entity.DaCustomer;
 import com.tofly.fees.userprofilemgt.entity.DaHfysLog;
 import com.tofly.fees.userprofilemgt.service.DaCustomerService;
@@ -29,6 +31,7 @@ import java.io.IOException;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 用户恢复用水日志
@@ -39,64 +42,65 @@ import java.util.List;
 @RestController
 @AllArgsConstructor
 @RequestMapping("/api/userprofilemgt/dahfyslog")
-@Api(tags="客户档案-用户恢复用水日志接口")
+@Api(tags = "客户档案-用户恢复用水日志接口")
 public class DaHfysLogController {
 
-    private final  DaHfysLogService daHfysLogService;
+    private final DaHfysLogService daHfysLogService;
     private final DaCustomerService daCustomerService;
 
+    private final SfRecMapper sfRecMapper;
+
     /**
      * page分页查询
      */
-    @GetMapping("/page" )
+    @GetMapping("/page")
     @ApiOperation(value = "page分页查询")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "current", value = "当前页码", required = true, dataType = "int"),
             @ApiImplicitParam(name = "size", value = "每页显示数据条数", required = true, dataType = "int"),
-            @ApiImplicitParam(name = "pages", value = "共几页,输出参数",  dataType = "int"),
-            @ApiImplicitParam(name = "maxLimit", value = "每页最大显示数据",  dataType = "int"),
+            @ApiImplicitParam(name = "pages", value = "共几页,输出参数", dataType = "int"),
+            @ApiImplicitParam(name = "maxLimit", value = "每页最大显示数据", dataType = "int"),
             @ApiImplicitParam(name = "orders[0].asc", value = "排序,bool类型", dataType = "String"),
-            @ApiImplicitParam(name = "orders[0].column", value = "排序,字段名",  dataType = "String"),
+            @ApiImplicitParam(name = "orders[0].column", value = "排序,字段名", dataType = "String"),
             @ApiImplicitParam(name = "companyBranch", value = "公司", dataType = "String"),
-            @ApiImplicitParam(name = "mrArea", value = "片区",  dataType = "String"),
-            @ApiImplicitParam(name = "mrBook", value = "抄表本",  dataType = "String"),
-            @ApiImplicitParam(name = "operatorDate_Start", value = "开始时间",  dataType = "String"),
-            @ApiImplicitParam(name = "operatorDate_Eed", value = "结束时间",  dataType = "String"),
+            @ApiImplicitParam(name = "mrArea", value = "片区", dataType = "String"),
+            @ApiImplicitParam(name = "mrBook", value = "抄表本", dataType = "String"),
+            @ApiImplicitParam(name = "operatorDate_Start", value = "开始时间", dataType = "String"),
+            @ApiImplicitParam(name = "operatorDate_Eed", value = "结束时间", dataType = "String"),
             @ApiImplicitParam(name = "searchText", value = "模糊查询(编号、姓名、电话、地址)", dataType = "String")
     })
     public ResultRespone getDaHfysLogPage(Page page, String companyBranch, String area, String book, String operatorDate_Start, String operatorDate_End, String searchText) {
         QueryWrapper<DaHfysLog> queryWrapper = SelectBtFHLog(companyBranch, area, book, operatorDate_Start, operatorDate_End, searchText);
         // 执行分页查询
-        IPage<DaHfysLog> btfhPage = daHfysLogService.page(page,queryWrapper);
+        IPage<DaHfysLog> btfhPage = daHfysLogService.page(page, queryWrapper);
         // 遍历查询结果进行赋值
         return ResultRespone.success(btfhPage);
     }
 
     private QueryWrapper<DaHfysLog> SelectBtFHLog(String companyBranch, String mrArea, String mrBook, String operatorDate_Start, String operatorDate_End, String searchText) {
         QueryWrapper<DaHfysLog> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq("1",1);
-        if(StringUtils.isNotBlank(companyBranch)) {
-            queryWrapper.and(i->i.eq("COMPANY_BRANCH",companyBranch));
+        queryWrapper.eq("1", 1);
+        if (StringUtils.isNotBlank(companyBranch)) {
+            queryWrapper.and(i -> i.eq("COMPANY_BRANCH", companyBranch));
         }
-        if(StringUtils.isNotBlank(mrArea)) {
-            queryWrapper.and(i->i.eq("MR_AREA",mrArea));
+        if (StringUtils.isNotBlank(mrArea)) {
+            queryWrapper.and(i -> i.eq("MR_AREA", mrArea));
         }
-        if(StringUtils.isNotBlank(mrBook)) {
-            queryWrapper.and(i->i.eq("MR_BOOK",mrBook));
+        if (StringUtils.isNotBlank(mrBook)) {
+            queryWrapper.and(i -> i.eq("MR_BOOK", mrBook));
         }
 
-        if(StringUtils.isNotBlank(operatorDate_Start) && StringUtils.isNotBlank(operatorDate_End)) {
-            queryWrapper.and(i->i.apply("APPLY_DATE BETWEEN to_date({0},'yyyy-mm-dd hh24:mi:ss') AND to_date({1},'yyyy-mm-dd hh24:mi:ss')", operatorDate_Start, operatorDate_End));
+        if (StringUtils.isNotBlank(operatorDate_Start) && StringUtils.isNotBlank(operatorDate_End)) {
+            queryWrapper.and(i -> i.apply("APPLY_DATE BETWEEN to_date({0},'yyyy-mm-dd hh24:mi:ss') AND to_date({1},'yyyy-mm-dd hh24:mi:ss')", operatorDate_Start, operatorDate_End));
         }
-        if(StringUtils.isNotBlank(searchText))
-        {
-            queryWrapper.like("CUSTOMER_NO",searchText)
+        if (StringUtils.isNotBlank(searchText)) {
+            queryWrapper.like("CUSTOMER_NO", searchText)
                     .or()
-                    .like("CUSTOMER_ADDR",searchText)
+                    .like("CUSTOMER_ADDR", searchText)
                     .or()
-                    .like("PHONE",searchText)
+                    .like("PHONE", searchText)
                     .or()
-                    .like("CUSTOMER_NAME",searchText);
+                    .like("CUSTOMER_NAME", searchText);
         }
         return queryWrapper;
     }
@@ -104,17 +108,17 @@ public class DaHfysLogController {
     @GetMapping("/export")
     @ApiOperation(value = "export导出")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "companyBranch", value = "公司",  dataType = "String"),
+            @ApiImplicitParam(name = "companyBranch", value = "公司", dataType = "String"),
             @ApiImplicitParam(name = "mrArea", value = "片区", dataType = "String"),
-            @ApiImplicitParam(name = "mrBook", value = "抄表本",  dataType = "String"),
+            @ApiImplicitParam(name = "mrBook", value = "抄表本", dataType = "String"),
             @ApiImplicitParam(name = "operatorDate_Start", value = "开始时间", dataType = "String"),
-            @ApiImplicitParam(name = "operatorDate_Eed", value = "结束时间",  dataType = "String"),
+            @ApiImplicitParam(name = "operatorDate_Eed", value = "结束时间", dataType = "String"),
             @ApiImplicitParam(name = "searchText", value = "模糊查询(编号、姓名、电话、地址)", dataType = "String")
     })
     public void export(HttpServletResponse response, String companyBranch, String mrArea, String mrBook, String operatorDate_Start, String operatorDate_Eed, String searchText) throws IOException {
         QueryWrapper<DaHfysLog> queryWrapper = SelectBtFHLog(companyBranch, mrArea, mrBook, operatorDate_Start, operatorDate_Eed, searchText);
         // 遍历查询结果进行赋值
-        List<DaHfysLog> list =  daHfysLogService.list(queryWrapper);
+        List<DaHfysLog> list = daHfysLogService.list(queryWrapper);
         //导出Excel
         ExcleFileUtil.exportExcel(response, list, DaHfysLog.class, "恢复用户列表.xlsx");
     }
@@ -122,102 +126,112 @@ public class DaHfysLogController {
 
     /**
      * 通过id查询用户恢复用水日志
+     *
      * @param id id
      * @return ResultRespone
      */
-    @GetMapping("/{id}" )
+    @GetMapping("/{id}")
     @ApiOperation(value = "通过ID查询")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String")
     })
-    public ResultRespone<DaHfysLog> getById(@PathVariable("id" ) String id) {
-      return ResultRespone.success(daHfysLogService.getById(id));
+    public ResultRespone<DaHfysLog> getById(@PathVariable("id") String id) {
+        return ResultRespone.success(daHfysLogService.getById(id));
     }
 
     /**
      * 新增用户恢复用水日志
+     *
      * @param daHfysLog 用户恢复用水日志
      * @return ResultRespone
      */
-    @ToFlyAppLog(title="新增用户恢复用水日志" )
+    @ToFlyAppLog(title = "新增用户恢复用水日志")
     @ApiOperation(value = "新增用户恢复用水日志")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "yzqf", value = "是否验证欠费(1:需验证;0:不验证)", required = false, dataType = "String")
+    })
     @PostMapping
     @Transactional(rollbackFor = Exception.class) //声明式事务管理
-    public ResultRespone save(@RequestBody DaHfysLog daHfysLog) {
-
-        ResultRespone<Object> rest=new  ResultRespone<>();
-         if(StringUtils.isNotBlank(daHfysLog.getCustomerNo()))
-         {
-             daHfysLog.setId(GuidGenerator.getGuid());//id
-             daHfysLog.setOperatorDate(new Date()); //操作时间
-             if(daHfysLogService.save(daHfysLog))
-             {
-                 DaCustomer daCustomer=new DaCustomer();
-                 daCustomer.setCustomerNo(daHfysLog.getCustomerNo());//用户编号
-                 daCustomer.setCustomerState("1");//用户状态
-                 if(daCustomerService.updateById(daCustomer))
-                 {
-                     rest.setCode(1);
-                     rest.setMessage("操作成功");
-                 }
-                 else
-                 {
-                     rest.setCode(-1);
-                     rest.setMessage("操作失败");
-                 }
-             }
-             else
-             {
-                 rest.setCode(-1);
-                 rest.setMessage("操作失败");
-             }
-         }
-         else
-         {
-             rest.setCode(-1);
-             rest.setMessage("操作失败,用户编号不存在");
-         }
-      return rest;
+    public ResultRespone save(@RequestBody DaHfysLog daHfysLog, @RequestParam(required = false) String yzqf) {
+
+        ResultRespone<Object> rest = new ResultRespone<>();
+        if (StringUtils.isNotBlank(daHfysLog.getCustomerNo())) {
+            if (yzqf.equals("1")) {
+                //判断用户是否存在欠费
+                Map<String, Object> map = sfRecMapper.SelectricCount(daHfysLog.getCustomerNo());
+                int count = Integer.parseInt(map.get("COUNT").toString());
+                if (count > 0) {
+                    rest.setCode(-1);
+                    rest.setMessage("操作失败,用户存在欠费:" + count + "笔");
+                    return rest;
+                }
+            }
+
+            daHfysLog.setId(GuidGenerator.getGuid());//id
+            daHfysLog.setOperatorDate(new Date()); //操作时间
+            if (daHfysLogService.save(daHfysLog)) {
+                DaCustomer daCustomer = new DaCustomer();
+                daCustomer.setCustomerNo(daHfysLog.getCustomerNo());//用户编号
+                daCustomer.setCustomerState(UserStatusEnum.OfficialUser.getStatusUser().toString());//用户状态
+                if (daCustomerService.updateById(daCustomer)) {
+                    rest.setCode(1);
+                    rest.setMessage("操作成功");
+                } else {
+                    rest.setCode(-1);
+                    rest.setMessage("操作失败");
+                }
+            } else {
+                rest.setCode(-1);
+                rest.setMessage("操作失败");
+            }
+        } else {
+            rest.setCode(-1);
+            rest.setMessage("操作失败,用户编号不存在");
+        }
+        return rest;
     }
 
     /**
      * 修改用户恢复用水日志
+     *
      * @param daHfysLog 用户恢复用水日志
      * @return ResultRespone
      */
-    @ToFlyAppLog(title="修改用户恢复用水日志" )
+    @ToFlyAppLog(title = "修改用户恢复用水日志")
     @ApiOperation(value = "修改用户恢复用水日志")
     @PutMapping
     public ResultRespone<Boolean> updateById(@RequestBody DaHfysLog daHfysLog) {
-      return ResultRespone.success(daHfysLogService.updateById(daHfysLog));
+        return ResultRespone.success(daHfysLogService.updateById(daHfysLog));
     }
 
     /**
      * 通过id删除用户恢复用水日志
+     *
      * @param id id
      * @return ResultRespone
      */
-    @ToFlyAppLog(title="通过id删除用户恢复用水日志" )
+    @ToFlyAppLog(title = "通过id删除用户恢复用水日志")
     @ApiOperation(value = "通过ID删除用户恢复用水日志")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String")
     })
-    @DeleteMapping("/{id}" )
+    @DeleteMapping("/{id}")
     public ResultRespone<Boolean> removeById(@PathVariable String id) {
-      return ResultRespone.success(daHfysLogService.removeById(id));
+        return ResultRespone.success(daHfysLogService.removeById(id));
     }
 
     /**
      * 通过id批量删除用户恢复用水日志
+     *
      * @param ids id
      * @return ResultRespone
      */
-    @ToFlyAppLog(title="通过id批量删除用户恢复用水日志" )
+    @ToFlyAppLog(title = "通过id批量删除用户恢复用水日志")
     @ApiOperation(value = "通过ID批量删除用户恢复用水日志")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "ids", value = "批量删除,多个id以逗号隔开", required = true, dataType = "String")
     })
-    @DeleteMapping("/deleteByIds" )
+    @DeleteMapping("/deleteByIds")
     public ResultRespone<Boolean> removeByIds(String ids) {
         return ResultRespone.success(daHfysLogService.removeByIds(Arrays.asList(ids.split(","))));
     }