Browse Source

总分表新增与删除增加日志

lihaoli 1 week ago
parent
commit
f6cf2ff5c4

+ 50 - 0
collect_fees_hdx_api/fees-hdx-api/src/main/java/com/tofly/feesapi/bjgl/controller/YhBjflFbController.java

@@ -11,6 +11,9 @@ import com.tofly.feesapi.common.core.dto.PageDto;
 import com.tofly.feesapi.common.core.vo.PageResult;
 import com.tofly.feesapi.common.exception.FeesErrorCode;
 import com.tofly.feesapi.common.exception.FeesException;
+import com.tofly.feesapi.security.util.SecurityUtils;
+import com.tofly.feesapi.xtgl.service.ISyscommlogService;
+import com.tofly.feesapi.yhgl.entity.YhGroupAccounts;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -20,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
@@ -32,6 +36,9 @@ public class YhBjflFbController {
     @Autowired
     private YhBjflFbService yhBjflFbService;
 
+    @Autowired
+    private ISyscommlogService syscommlogService;
+
     @GetMapping("/page")
     @ApiOperation(value = "分页查询",tags = "档案管理")
     public ResultRespone<PageResult<YhBjflFbSelect>> getPage(@ModelAttribute PageDto pageDto, @ModelAttribute YhBjflFbFilter filter) {
@@ -45,6 +52,10 @@ public class YhBjflFbController {
         if (yhBjflFbList.isEmpty()) {
             throw new FeesException("用户表具分类(总分表、子母表)分表不能为空", FeesErrorCode.BUSINESS_ERROR);
         }
+        //分表
+        List<String> fblist = new ArrayList<>();
+        //子表
+        List<String> zblist = new ArrayList<>();
         for (YhBjflFb yhBjflFb : yhBjflFbList) {
             if (StringUtil.isEmpty(yhBjflFb.getZbId())) {
                 throw new FeesException("主表ID不能为空!", FeesErrorCode.BUSINESS_ERROR);
@@ -80,6 +91,25 @@ public class YhBjflFbController {
             }
             yhBjflFb.setId(yhBjflFbService.getMaxid());
             yhBjflFbService.save(yhBjflFb);
+            if (yhBjflFb.getTypeId().equals("1")) {
+                fblist.add(yhBjflFb.getYhbh());
+            } else {
+                zblist.add(yhBjflFb.getYhbh());
+            }
+        }
+        String tablename = "yh_bjfl_fb";
+        if (fblist.size() > 0) {
+            String remark = String.format("%s-添加分表户号:%s",
+                    SecurityUtils.getUser().getRealName(),
+                    Arrays.toString(fblist.toArray())
+            );
+            syscommlogService.LogSave(tablename, "添加分表户号", "ADD", remark, "");
+        }
+        if (zblist.size() > 0) {
+            String remark = String.format("%s-添加分表户号:%s",
+                    SecurityUtils.getUser().getRealName(),
+                    Arrays.toString(zblist.toArray()));
+            syscommlogService.LogSave(tablename, "添加子表户号", "ADD", remark, "");
         }
         return ResultRespone.success(true);
     }
@@ -99,6 +129,26 @@ public class YhBjflFbController {
     })
     @DeleteMapping("/deleteByIds")
     public ResultRespone<Boolean> removeByIds(String ids) {
+        List<YhBjflFb> yhBjflFbs = yhBjflFbService.lambdaQuery()
+                .in(YhBjflFb::getId, Arrays.asList(ids.split(",")))
+                .list();
+        if (yhBjflFbs.size() > 0) {
+            String tablename = "yh_bjfl_fb";
+            long count = yhBjflFbs.stream().filter(e -> e.getTypeId().equals("1")).count();
+            if (count > 0) {
+                String remark = String.format("%s-删除分表户号:%s",
+                        SecurityUtils.getUser().getRealName(),
+                        Arrays.toString(yhBjflFbs.stream().filter(e -> e.getTypeId().equals("1")).map(YhBjflFb::getYhbh).toArray()));
+                syscommlogService.LogSave(tablename, "删除分表户号", "DELETE", remark, "");
+            }
+            count = yhBjflFbs.stream().filter(e -> e.getTypeId().equals("2")).count();
+            if (count > 0) {
+                String remark = String.format("%s-删除子表户号:%s",
+                        SecurityUtils.getUser().getRealName(),
+                        Arrays.toString(yhBjflFbs.stream().filter(e -> e.getTypeId().equals("2")).map(YhBjflFb::getYhbh).toArray()));
+                syscommlogService.LogSave(tablename, "删除子表户号", "DELETE", remark, "");
+            }
+        }
         return ResultRespone.success(yhBjflFbService.removeByIds(Arrays.asList(ids.split(","))));
     }
 }

+ 52 - 0
collect_fees_hdx_api/fees-hdx-api/src/main/java/com/tofly/feesapi/bjgl/controller/YhBjflZbController.java

@@ -15,6 +15,7 @@ import com.tofly.feesapi.common.core.vo.PageResult;
 import com.tofly.feesapi.common.exception.FeesErrorCode;
 import com.tofly.feesapi.common.exception.FeesException;
 import com.tofly.feesapi.security.util.SecurityUtils;
+import com.tofly.feesapi.xtgl.service.ISyscommlogService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -25,6 +26,7 @@ import org.springframework.web.bind.annotation.*;
 
 import java.util.Arrays;
 import java.util.Date;
+import java.util.List;
 
 @RestController
 @AllArgsConstructor
@@ -37,6 +39,9 @@ public class YhBjflZbController {
     @Autowired
     private YhBjflFbService yhBjflFbService;
 
+    @Autowired
+    private ISyscommlogService syscommlogService;
+
     @GetMapping("/page")
     @ApiOperation(value = "分页查询", tags = "档案管理")
     public ResultRespone<PageResult<YhBjflZbSelect>> getPage(@ModelAttribute PageDto pageDto,
@@ -73,6 +78,19 @@ public class YhBjflZbController {
         yhBjflZb.setCzryxm(SecurityUtils.getUser().getRealName());
         yhBjflZb.setCzsj(new Date());
         yhBjflZb.setId(yhBjflZbService.getMaxid());
+        String tablename = "yh_bjfl_zb";
+        if (yhBjflZb.getTypeId().equals("1")) {
+            String remark = String.format("%s-添加总表户号:%s",
+                    SecurityUtils.getUser().getRealName(),
+                    yhBjflZb.getYhbh()
+            );
+            syscommlogService.LogSave(tablename, "添加总表户号", "ADD", remark, "");
+        } else {
+            String remark = String.format("%s-添加母表户号:%s",
+                    SecurityUtils.getUser().getRealName(),
+                    yhBjflZb.getYhbh());
+            syscommlogService.LogSave(tablename, "添加母表户号", "ADD", remark, "");
+        }
         return ResultRespone.success(yhBjflZbService.save(yhBjflZb));
     }
 
@@ -89,6 +107,19 @@ public class YhBjflZbController {
         if (count > 0) {
             throw new FeesException("该用户表分类(总分类表、子母表)主表下有子表,不能删除", FeesErrorCode.BUSINESS_ERROR);
         }
+        YhBjflZb yhBjflzb = yhBjflZbService.getById(id);
+        String tablename = "yh_bjfl_zb";
+        if (yhBjflzb.getTypeId().equals("1")) {
+            String remark = String.format("%s-删除总表户号:%s",
+                    SecurityUtils.getUser().getRealName(),
+                    yhBjflzb.getYhbh());
+            syscommlogService.LogSave(tablename, "删除总表户号", "DELETE", remark, "");
+        } else {
+            String remark = String.format("%s-删除母表户号:%s",
+                    SecurityUtils.getUser().getRealName(),
+                    yhBjflzb.getYhbh());
+            syscommlogService.LogSave(tablename, "删除母表户号", "DELETE", remark, "");
+        }
         return ResultRespone.success(yhBjflZbService.removeById(id));
     }
 
@@ -106,6 +137,27 @@ public class YhBjflZbController {
         if (count > 0) {
             throw new FeesException("存在用户表分类(总分类表、子母表)主表下有子表,不能删除", FeesErrorCode.BUSINESS_ERROR);
         }
+        List<YhBjflZb> yhBjflzbs = yhBjflZbService.lambdaQuery()
+                .in(YhBjflZb::getId, Arrays.asList(ids.split(",")))
+                .list();
+        if (yhBjflzbs.size() > 0) {
+            String tablename = "yh_bjfl_fb";
+            count = yhBjflzbs.stream().filter(e -> e.getTypeId().equals("1")).count();
+            if (count > 0) {
+                String remark = String.format("%s-删除总表户号:%s",
+                        SecurityUtils.getUser().getRealName(),
+                        Arrays.toString(yhBjflzbs.stream().filter(e -> e.getTypeId().equals("1")).map(YhBjflZb::getYhbh).toArray()));
+                syscommlogService.LogSave(tablename, "删除总表户号", "DELETE", remark, "");
+            }
+            count = yhBjflzbs.stream().filter(e -> e.getTypeId().equals("2")).count();
+            if (count > 0) {
+                String remark = String.format("%s-删除母表户号:%s",
+                        SecurityUtils.getUser().getRealName(),
+                        Arrays.toString(yhBjflzbs.stream().filter(e -> e.getTypeId().equals("2")).map(YhBjflZb::getYhbh).toArray()));
+                syscommlogService.LogSave(tablename, "删除母表户号", "DELETE", remark, "");
+            }
+        }
+
         return ResultRespone.success(yhBjflZbService.removeByIds(Arrays.asList(ids.split(","))));
     }
 }

+ 3 - 0
collect_fees_hdx_api/fees-hdx-api/src/main/java/com/tofly/feesapi/xtgl/service/ISyscommlogService.java

@@ -14,4 +14,7 @@ public interface ISyscommlogService extends IService<Syscommlog> {
      *  新增日志
      */
     void xz(String tablename, String mstext, String remark, String userid);
+
+
+    void LogSave(String Tablename, String Context, String optype, String remark, String userid);
 }

+ 18 - 1
collect_fees_hdx_api/fees-hdx-api/src/main/java/com/tofly/feesapi/xtgl/service/impl/SyscommlogServiceImpl.java

@@ -1,5 +1,7 @@
 package com.tofly.feesapi.xtgl.service.impl;
 
+import com.tofly.common.core.util.StringUtil;
+import com.tofly.feesapi.security.util.SecurityUtils;
 import com.tofly.feesapi.xtgl.entity.Syscommlog;
 import com.tofly.feesapi.xtgl.mapper.SyscommlogMapper;
 import com.tofly.feesapi.xtgl.service.ISyscommlogService;
@@ -38,5 +40,20 @@ public class SyscommlogServiceImpl extends ServiceImpl<SyscommlogMapper, Syscomm
         syscommlog.setUserid(userid);
         this.save(syscommlog);
     }
-
+    @Override
+    public void LogSave(String Tablename, String Context, String optype, String remark, String userid) {
+        Syscommlog syscommlog = new Syscommlog();
+        if (StringUtil.isEmpty(userid)) {
+            syscommlog.setUserid(SecurityUtils.getUserId().toString());
+        } else {
+            syscommlog.setUserid(userid);
+        }
+        String addate = LocalDateTime.now().format(formatter);
+        syscommlog.setAddate(addate);
+        syscommlog.setTablename(Tablename);
+        syscommlog.setMstext(Context);
+        syscommlog.setOptype(optype);
+        syscommlog.setRemark(remark);
+        this.save(syscommlog);
+    }
 }