Browse Source

企业备案信息表

heguanxun 9 months ago
parent
commit
efb2fc7b50

+ 2 - 1
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/qyrecardbody/controller/QyRecardBodyController.java

@@ -22,6 +22,8 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
+import vip.xiaonuo.biz.modular.qyrecordinfo.param.QyRecordInfoPageParam;
+import vip.xiaonuo.biz.modular.qyrecordinfo.service.QyRecordInfoService;
 import vip.xiaonuo.common.annotation.CommonLog;
 import vip.xiaonuo.common.pojo.CommonResult;
 import vip.xiaonuo.biz.modular.qyrecardbody.entity.QyRecardBody;
@@ -54,7 +56,6 @@ public class QyRecardBodyController {
 
     @Resource
     private QyRecardBodyService qyRecardBodyService;
-
     /**
      * 获取企业备案信息主体分页
      *

+ 65 - 34
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/qyrecordinfo/controller/QyRecordInfoController.java

@@ -13,7 +13,10 @@
 package vip.xiaonuo.biz.modular.qyrecordinfo.controller;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.URLUtil;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import io.swagger.v3.oas.annotations.Operation;
@@ -22,6 +25,7 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
+import vip.xiaonuo.biz.modular.qyrecordinfo.entity.BusinessIdGenerator;
 import vip.xiaonuo.common.annotation.CommonLog;
 import vip.xiaonuo.common.pojo.CommonResult;
 import vip.xiaonuo.biz.modular.qyrecordinfo.entity.QyRecordInfo;
@@ -34,10 +38,13 @@ import jakarta.servlet.http.HttpServletResponse;
 import jakarta.annotation.Resource;
 import jakarta.validation.Valid;
 import jakarta.validation.constraints.NotEmpty;
+
 import java.util.List;
 import java.io.IOException;
+
 import com.alibaba.excel.EasyExcel;
 import com.alibaba.fastjson.JSON;
+
 import java.net.URLEncoder;
 import java.util.HashMap;
 
@@ -45,7 +52,7 @@ import java.util.HashMap;
  * 企业备案信息控制器
  *
  * @author hgx
- * @date  2024/07/06 11:20
+ * @date 2024/07/06 11:20
  */
 @Tag(name = "企业备案信息控制器")
 @RestController
@@ -59,7 +66,7 @@ public class QyRecordInfoController {
      * 获取企业备案信息分页
      *
      * @author hgx
-     * @date  2024/07/06 11:20
+     * @date 2024/07/06 11:20
      */
     @Operation(summary = "获取企业备案信息分页")
     @SaCheckPermission("/biz/qyrecordinfo/page")
@@ -72,22 +79,45 @@ public class QyRecordInfoController {
      * 添加企业备案信息
      *
      * @author hgx
-     * @date  2024/07/06 11:20
+     * @date 2024/07/06 11:20
      */
     @Operation(summary = "添加企业备案信息")
     @CommonLog("添加企业备案信息")
     @SaCheckPermission("/biz/qyrecordinfo/add")
     @PostMapping("/biz/qyrecordinfo/add")
     public CommonResult<String> add(@RequestBody @Valid QyRecordInfoAddParam qyRecordInfoAddParam) {
+        QyRecordInfoPageParam qyRecordInfoPageParam = BeanUtil.toBean(qyRecordInfoAddParam, QyRecordInfoPageParam.class);
+        IPage<QyRecordInfo> page = qyRecordInfoService.page(qyRecordInfoPageParam);
+        List<QyRecordInfo> records = page.getRecords();
+        String ylTzCode_;
+        String tzCode_;
+        if (CollectionUtil.isNotEmpty(records)) {
+            String ylTzCode = records.get(0).getYlTzCode();
+            String tzCode = records.get(0).getTzCode();
+            String ylCode = ylTzCode.substring(ylTzCode.length() - 5, ylTzCode.length());
+            String code = tzCode.substring(tzCode.length() - 3, tzCode.length());
+            int i = Integer.valueOf(ylCode);
+            i++;
+            ylTzCode_ = BusinessIdGenerator.generateBusinessId(i);
+            int j = Integer.valueOf(code);
+            j++;
+            tzCode_ = BusinessIdGenerator.generateCode(j);
+
+        } else {
+            ylTzCode_ = BusinessIdGenerator.generateBusinessId(0);
+            tzCode_ = BusinessIdGenerator.generateCode(0);
+        }
+        qyRecordInfoAddParam.setYlTzCode(ylTzCode_);
+        qyRecordInfoAddParam.setTzCode(tzCode_);
         qyRecordInfoService.add(qyRecordInfoAddParam);
-        return CommonResult.ok();
+        return CommonResult.ok(ylTzCode_);
     }
 
     /**
      * 编辑企业备案信息
      *
      * @author hgx
-     * @date  2024/07/06 11:20
+     * @date 2024/07/06 11:20
      */
     @Operation(summary = "编辑企业备案信息")
     @CommonLog("编辑企业备案信息")
@@ -102,59 +132,60 @@ public class QyRecordInfoController {
      * 导出企业备案信息
      *
      * @author hgx
-     * @date  2024/07/06 11:20
+     * @date 2024/07/06 11:20
      */
     @Operation(summary = "导出企业备案信息")
     @CommonLog("导出企业备案信息")
     @SaCheckPermission("/biz/qyrecordinfo/export")
     @PostMapping("/biz/qyrecordinfo/export")
     public void export(@RequestBody @Valid QyRecordInfoPageParam qyRecordInfoPageParam, HttpServletResponse response) {
-        Page<QyRecordInfo> page =  qyRecordInfoService.page(qyRecordInfoPageParam);
+        Page<QyRecordInfo> page = qyRecordInfoService.page(qyRecordInfoPageParam);
         List<QyRecordInfo> records = page.getRecords();
-        exportExcel(response,QyRecordInfo.class,records,"企业备案信息");
+        exportExcel(response, QyRecordInfo.class, records, "企业备案信息");
     }
 
 
     /**
      * 导出表格数据
-     * @param cl       表格字段实体类
-     * @param data     查询数据
-     * @param sheetName  表格名称
+     *
+     * @param cl        表格字段实体类
+     * @param data      查询数据
+     * @param sheetName 表格名称
      */
-    public void exportExcel(HttpServletResponse response, Class cl, List data, String sheetName){
-       HashMap<String, String> map = new HashMap<>();
-       try {
-           response.setHeader("Content-disposition", "attachment;filename=" + URLUtil.encode(sheetName) + ".xlsx");
-           response.setHeader("Access-Control-Allow-Origin", "*");
-           response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
-           response.setContentType("application/octet-stream;charset=UTF-8");
-           EasyExcel.write(response.getOutputStream(), cl).autoCloseStream(Boolean.FALSE).sheet(sheetName).doWrite(data);
-       } catch (IOException e) {
-           response.reset();
-           response.setContentType("application/json");
-           response.setCharacterEncoding("utf-8");
-           map.put("status", "failure");
-           map.put("message", "下载文件失败" + e.getMessage());
-           try {
-               response.getWriter().println(JSON.toJSONString(map));
-           } catch (IOException ex) {
-               ex.printStackTrace();
-           }
-       }
+    public void exportExcel(HttpServletResponse response, Class cl, List data, String sheetName) {
+        HashMap<String, String> map = new HashMap<>();
+        try {
+            response.setHeader("Content-disposition", "attachment;filename=" + URLUtil.encode(sheetName) + ".xlsx");
+            response.setHeader("Access-Control-Allow-Origin", "*");
+            response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
+            response.setContentType("application/octet-stream;charset=UTF-8");
+            EasyExcel.write(response.getOutputStream(), cl).autoCloseStream(Boolean.FALSE).sheet(sheetName).doWrite(data);
+        } catch (IOException e) {
+            response.reset();
+            response.setContentType("application/json");
+            response.setCharacterEncoding("utf-8");
+            map.put("status", "failure");
+            map.put("message", "下载文件失败" + e.getMessage());
+            try {
+                response.getWriter().println(JSON.toJSONString(map));
+            } catch (IOException ex) {
+                ex.printStackTrace();
+            }
+        }
     }
 
     /**
      * 删除企业备案信息
      *
      * @author hgx
-     * @date  2024/07/06 11:20
+     * @date 2024/07/06 11:20
      */
     @Operation(summary = "删除企业备案信息")
     @CommonLog("删除企业备案信息")
     @SaCheckPermission("/biz/qyrecordinfo/delete")
     @PostMapping("/biz/qyrecordinfo/delete")
     public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
-                                                   List<QyRecordInfoIdParam> qyRecordInfoIdParamList) {
+                                       List<QyRecordInfoIdParam> qyRecordInfoIdParamList) {
         qyRecordInfoService.delete(qyRecordInfoIdParamList);
         return CommonResult.ok();
     }
@@ -163,7 +194,7 @@ public class QyRecordInfoController {
      * 获取企业备案信息详情
      *
      * @author hgx
-     * @date  2024/07/06 11:20
+     * @date 2024/07/06 11:20
      */
     @Operation(summary = "获取企业备案信息详情")
     @SaCheckPermission("/biz/qyrecordinfo/detail")

+ 46 - 0
snowy-plugin/snowy-plugin-biz/src/main/java/vip/xiaonuo/biz/modular/qyrecordinfo/entity/BusinessIdGenerator.java

@@ -0,0 +1,46 @@
+package vip.xiaonuo.biz.modular.qyrecordinfo.entity;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class BusinessIdGenerator {
+
+    private static final String PREFIX = "EPD";
+    private static final String FIXED_MIDDLE_PART = "000";
+    private static final int SERIAL_NUMBER_LENGTH = 5;
+
+    private static final String PREFIX_ = "LHTWL";
+
+    public static String generateCode(int sequenceNumber) {
+        StringBuilder code = new StringBuilder();
+        code.append(PREFIX_);
+        code.append(String.format("%03d", sequenceNumber++)); // 格式化序列号为3位数字,不足部分补0
+        return code.toString();
+    }
+    public static String generateBusinessId(int currentSerialNumber) {
+        StringBuilder businessId = new StringBuilder();
+        businessId.append(PREFIX);
+        businessId.append(getDatePart());
+        businessId.append(FIXED_MIDDLE_PART);
+        businessId.append(getSerialNumberPart(currentSerialNumber));
+
+        return businessId.toString();
+    }
+
+    private static String getDatePart() {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
+        return sdf.format(new Date());
+    }
+
+    private static String getSerialNumberPart(int currentSerialNumber) {
+        // 如果序列号不足长度,前面补0
+        return String.format("%0" + SERIAL_NUMBER_LENGTH + "d", currentSerialNumber);
+    }
+
+    public static void main(String[] args) {
+        for (int i = 0; i < 10; i++) {
+            String code = generateCode(i);
+            System.out.println("Generated Code: " + code);
+        }
+    }
+}