Browse Source

20250305_sun

15143018065 1 month ago
parent
commit
f21ba28ff5

+ 5 - 0
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java

@@ -510,6 +510,11 @@ public class ExcelUtil<T>
         exportExcel(response, list, sheetName, StringUtils.EMPTY);
     }
 
+    public void exportExcelCommon(HttpServletResponse response, List<T> list, String sheetName)
+    {
+        exportExcel(response, list, sheetName, StringUtils.EMPTY);
+    }
+
     /**
      * 对list数据源将其里面的数据导入到excel表单
      *

+ 9 - 14
ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/utils/EncryptionUtils.java

@@ -132,7 +132,9 @@ public class EncryptionUtils {
                         try {
                             String en = SecurityUtils.sm4decrypt_ECB(key, beforeSet);
                             if (StringUtils.isNotEmpty(en)) {
-                                field.set(t, SecurityUtils.sm4encrypt_ECB(SecurityUtils.getEncryptKey(), en));
+                                String key = SecurityUtils.getEncryptKey();
+                                String in = SecurityUtils.sm4encrypt_ECB(key, en);
+                                field.set(t, in);
                             }
                         } catch (Exception e) {
                             //
@@ -167,11 +169,10 @@ public class EncryptionUtils {
                         throw new ServiceException("s✱"+field.getAnnotation(ApiModelProperty.class).value() + "属性包含非法字符,请修改后提交"+"e✱");
                     } else {
                         try {
-                            String en = SecurityUtils.sm4decrypt_ECB(SecurityUtils.getEncryptKey(), beforeSet);
+                            String key = SecurityUtils.getEncryptKey();
+                            String en = SecurityUtils.sm4decrypt_ECB(key, beforeSet);
                             if (StringUtils.isNotEmpty(en)) {
-                                if (java.nio.charset.Charset.forName("GBK").newEncoder().canEncode(en)) {
-                                    field.set(t, en);
-                                }
+                                field.set(t, en);
                             }
                         } catch (Exception e) {
                             //
@@ -208,9 +209,7 @@ public class EncryptionUtils {
                         try {
                             String en = SecurityUtils.sm4encrypt_ECB(key, beforeSet);
                             if (StringUtils.isNotEmpty(en)) {
-                                if (java.nio.charset.Charset.forName("GBK").newEncoder().canEncode(en)) {
-                                    field.set(t, en);
-                                }
+                                field.set(t, en);
                             }
                         } catch (Exception e) {
                             //
@@ -290,9 +289,7 @@ public class EncryptionUtils {
 //                                }
 //                            }
                             if (StringUtils.isNotEmpty(en)) {
-                                if (java.nio.charset.Charset.forName("GBK").newEncoder().canEncode(en)) {
-                                    field.set(t, en);
-                                }
+                                field.set(t, en);
                             }
                         } catch (Exception e) {
                             //
@@ -329,9 +326,7 @@ public class EncryptionUtils {
                         try {
                             String en = SecurityUtils.sm4decrypt_ECB(key, beforeSet);
                             if (StringUtils.isNotEmpty(en)) {
-                                if (java.nio.charset.Charset.forName("GBK").newEncoder().canEncode(en)) {
-                                    field.set(t, en);
-                                }
+                                field.set(t, en);
                             }
                         } catch (Exception e) {
                             //

+ 15 - 1
ruoyi-modules/mz-gljt/src/main/java/com/ruoyi/gljt/controller/GljtSqLrController.java

@@ -12,11 +12,11 @@ import com.ruoyi.common.log.enums.BusinessType;
 import com.ruoyi.common.security.annotation.RequiresPermissions;
 import com.ruoyi.gljt.domain.GljtLscx;
 import com.ruoyi.gljt.domain.GljtSqLr;
+import com.ruoyi.gljt.domain.GljtSqLrExport;
 import com.ruoyi.gljt.mapper.GljtLscxMapper;
 import com.ruoyi.gljt.service.IGljtSqLrService;
 import com.ruoyi.system.validate.group.AddGroup;
 import io.seata.common.util.StringUtils;
-import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -82,6 +82,20 @@ public class GljtSqLrController extends BaseController
         util.exportExcel(response, list, "高龄津贴申请老人信息数据");
     }
 
+    @RequiresPermissions("gljt:gljtLr:export")
+    @Log(title = "高龄津贴申请老人信息", businessType = BusinessType.EXPORT)
+    @PostMapping("/exportGljtLr")
+    public void exportGljtLr(HttpServletResponse response, GljtSqLr gljtSqLr) {
+        List<GljtSqLrExport> list = gljtSqLrService.exportGljtLr(gljtSqLr);
+        ExcelUtil<GljtSqLrExport> util = new ExcelUtil<GljtSqLrExport>(GljtSqLrExport.class);
+        util.exportExcelCommon(response, list, "高龄津贴申请老人信息数据");
+    }
+
+    @GetMapping("/exportGljtLr")
+    public AjaxResult exportGljtLr(GljtSqLr gljtSqLr) {
+        return AjaxResult.success(gljtSqLrService.exportGljtLr(gljtSqLr));
+    }
+
     /**
      * 获取高龄津贴申请老人信息详细信息
      */

+ 123 - 0
ruoyi-modules/mz-gljt/src/main/java/com/ruoyi/gljt/domain/GljtSqLrExport.java

@@ -0,0 +1,123 @@
+package com.ruoyi.gljt.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.ruoyi.common.core.annotation.Excel;
+import com.ruoyi.common.core.web.domain.BaseEntity;
+import com.ruoyi.system.validate.EncryptionV;
+import com.ruoyi.system.validate.group.AddGroup;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Size;
+
+/**
+ * 高龄津贴申请老人信息对象 gljt_sq_lr
+ *
+ * @author sun
+ * @date 2024-12-27
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@TableName("gljt_sq_lr")
+@ApiModel("高龄津贴申请老人信息")
+public class GljtSqLrExport extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 主键标识 */
+//    @Excel(name = "主键标识")
+    @TableId(value = "id",type = IdType.ASSIGN_UUID)
+    @ApiModelProperty(value = "主键标识")
+    private String id;
+
+    /** 行政区划 */
+//    @Excel(name = "行政区划")
+    @ApiModelProperty(value = "行政区划", required = true)
+    @NotBlank(message = "{行政区划}",groups = AddGroup.class)
+    @Size(min = 1, max = 12, message = "{行政区划}")
+    private String xzqh;
+
+    @Excel(name = "登记时间")
+    @TableField(exist = false)
+    private String djsj;
+
+    /** 申请人身份证号 */
+    @Excel(name = "身份证号码")
+    @ApiModelProperty(value = "申请人身份证号", required = true)
+    @NotBlank(message = "{申请人身份证号}",groups = AddGroup.class)
+    @Size(min = 1, max = 72, message = "{申请人身份证号}")
+    @EncryptionV
+    private String sqrZjhm;
+
+    /** 申请人姓名 */
+    @Excel(name = "姓名")
+    @ApiModelProperty(value = "申请人姓名", required = true)
+    @NotBlank(message = "{申请人姓名}",groups = AddGroup.class)
+    @Size(min = 1, max = 72, message = "{申请人姓名}")
+    @EncryptionV
+//    @ChineseV(message = "{申请人姓名}")
+    private String sqrXm;
+
+    /** 申请人性别(C0007) */
+    @Excel(name = "性别")
+    @ApiModelProperty(value = "申请人性别(C0007)", required = true)
+    @NotBlank(message = "{申请人性别}",groups = AddGroup.class)
+//    @DictV(type = "C0007",message = "{申请人性别}")
+    private String xb;
+
+    @Excel(name = "年龄")
+    @TableField(exist = false)
+    private String age;
+
+    @Excel(name = "民族")
+    private String mz;
+
+    /** 申请人居住地址 */
+    @Excel(name = "地址")
+    @ApiModelProperty(value = "申请人户籍地址", required = true)
+    //@NotBlank(message = "{申请人居住地址}",groups = AddGroup.class)
+    //@Size(min = 1, max = 200, message = "{申请人居住地址}")
+    private String hjdz;
+
+    @Excel(name = "邮编")
+    private String yb;
+
+    /** 申请人联系电话 */
+    @Excel(name = "电话")
+    @ApiModelProperty(value = "申请人联系电话", required = true)
+    @NotBlank(message = "{申请人联系电话}",groups = AddGroup.class)
+    @Size(min = 1, max = 64, message = "{申请人联系电话}")
+    @EncryptionV
+    private String sqrLxdh;
+
+    @Excel(name = "享受补贴类别")
+    @TableField(exist = false)
+    private String xsbtlb;
+
+    @Excel(name = "健康状况")
+    private String sndj;
+
+    @Excel(name = "月补助金额")
+    @TableField(exist = false)
+    private String ybzje;
+
+    @Excel(name = "变动种类")
+    @TableField(exist = false)
+    private String bdzl;
+
+    @Excel(name = "变动时间")
+    @TableField(exist = false)
+    private String bdsj;
+
+    private String pc;
+
+    private String status;
+}

+ 14 - 0
ruoyi-modules/mz-gljt/src/main/java/com/ruoyi/gljt/mapper/GljtSqLrExportMapper.java

@@ -0,0 +1,14 @@
+package com.ruoyi.gljt.mapper;
+
+import com.ruoyi.common.datascope.utils.BaseMapperPlus;
+import com.ruoyi.gljt.domain.GljtSqLrExport;
+
+/**
+ * 高龄津贴申请老人信息Mapper接口
+ *
+ * @author sun
+ * @date 2024-12-27
+ */
+public interface GljtSqLrExportMapper extends BaseMapperPlus<GljtSqLrExport> {
+
+}

+ 3 - 0
ruoyi-modules/mz-gljt/src/main/java/com/ruoyi/gljt/service/IGljtSqLrService.java

@@ -1,6 +1,7 @@
 package com.ruoyi.gljt.service;
 
 import com.ruoyi.gljt.domain.GljtSqLr;
+import com.ruoyi.gljt.domain.GljtSqLrExport;
 
 import java.util.List;
 
@@ -28,6 +29,8 @@ public interface IGljtSqLrService
      */
     public List<GljtSqLr> selectGljtSqLrList(GljtSqLr gljtSqLr);
 
+    public List<GljtSqLrExport> exportGljtLr(GljtSqLr gljtSqLr);
+
     public GljtSqLr getLrByZjhm(GljtSqLr gljtSqLr);
 
     /**

+ 94 - 0
ruoyi-modules/mz-gljt/src/main/java/com/ruoyi/gljt/service/impl/GljtSqLrServiceImpl.java

@@ -1,18 +1,25 @@
 package com.ruoyi.gljt.service.impl;
 
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.bean.copier.CopyOptions;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.ruoyi.common.core.exception.ServiceException;
 import com.ruoyi.common.core.utils.DateUtils;
 import com.ruoyi.common.core.utils.StringUtils;
+import com.ruoyi.common.security.utils.DictUtils;
 import com.ruoyi.common.security.utils.EncryptionUtils;
 import com.ruoyi.common.security.utils.SecurityUtils;
 import com.ruoyi.common.security.utils.SysDeptJlUtils;
 import com.ruoyi.gljt.domain.GljtJkzk;
 import com.ruoyi.gljt.domain.GljtSqLr;
+import com.ruoyi.gljt.domain.GljtSqLrExport;
+import com.ruoyi.gljt.domain.GljtXmpz;
 import com.ruoyi.gljt.mapper.GljtJkzkMapper;
+import com.ruoyi.gljt.mapper.GljtSqLrExportMapper;
 import com.ruoyi.gljt.mapper.GljtSqLrMapper;
 import com.ruoyi.gljt.service.IGljtSqLrService;
 import com.ruoyi.gljt.utils.GljtSqUtils;
+import com.ruoyi.system.api.domain.SysDictData;
 import com.ruoyi.system.api.enums.GljtLrStatus;
 import com.ruoyi.system.mapper.SysDeptJlMapper;
 import com.ruoyi.system.utils.SubCodeUtil;
@@ -21,8 +28,12 @@ import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -39,6 +50,9 @@ public class GljtSqLrServiceImpl implements IGljtSqLrService
     @Autowired
     private GljtSqLrMapper gljtSqLrMapper;
 
+    @Autowired
+    private GljtSqLrExportMapper gljtSqLrExportMapper;
+
     @Autowired
     private GljtJkzkMapper gljtJkzkMapper;
 
@@ -133,6 +147,86 @@ public class GljtSqLrServiceImpl implements IGljtSqLrService
         return res;
     }
 
+    @Override
+    public List<GljtSqLrExport> exportGljtLr(GljtSqLr gljtSqLr) {
+        EncryptionUtils.encryptionForPlaintext(gljtSqLr);
+        String filter = StringUtils.isEmpty(gljtSqLr.getXzqh()) ? SecurityUtils.getAreaCode() : gljtSqLr.getXzqh();
+        gljtSqLr.setXzqh(null);
+        List<String> lrStatus = Arrays.asList("0", "1");
+        GljtSqLrExport query = new GljtSqLrExport();
+        BeanUtil.copyProperties(gljtSqLr, query, new CopyOptions().ignoreNullValue());
+        LambdaQueryWrapper<GljtSqLrExport> lqw = new LambdaQueryWrapper<>(query)
+                .likeRight(GljtSqLrExport::getXzqh, SubCodeUtil.code2Short(filter)).in(GljtSqLrExport::getStatus, lrStatus)
+                .orderByDesc(GljtSqLrExport::getCreateTimeStr);
+        List<GljtSqLrExport> res = gljtSqLrExportMapper.selectList(lqw);
+        String en = SecurityUtils.sm4encrypt_ECB("33555573BDFADC45", "张福䘵");
+        System.out.println("33555573BDFADC45");
+        System.out.println(en);
+        System.out.println(SecurityUtils.sm4decrypt_ECB("33555573BDFADC45", en));
+        List<SysDictData> mzList = DictUtils.getDictCache("C0009");
+        List<SysDictData> jkzkList = DictUtils.getDictCache("GL021");
+        if (CollectionUtils.isEmpty(mzList) || CollectionUtils.isEmpty(jkzkList)) {
+            throw new ServiceException("请尝试刷新缓存,当前缓存内未取到相应字典");
+        }
+        GljtXmpz xmpz = gljtSqUtils.getXmpz();
+        for (GljtSqLrExport r: res) {
+            EncryptionUtils.decryptForPlaintext(r);
+            try {
+                r.setDjsj(parseStr2Str(DateUtils.YYYY_MM_DD, StringUtils.isNotEmpty(r.getCreateTimeStr()) ? r.getCreateTimeStr().substring(0, 8) : "20200101"));
+                if (StringUtils.equals(r.getXb(), "1")) {
+                    r.setXb("1|男");
+                } else {
+                    r.setXb("2|女");
+                }
+                r.setAge(String.valueOf(DateUtils.getCurrentAgeByMonth(r.getSqrZjhm().substring(6, 14))));
+                if (StringUtils.isEmpty(r.getMz())) r.setMz("01");
+                if (StringUtils.isEmpty(r.getSndj())) r.setSndj("1");
+                r.setMz(r.getMz() + "|" + mzList.stream().filter(m -> StringUtils.equals(m.getDictValue(), r.getMz())).findFirst().orElse(new SysDictData()).getDictLabel());
+                r.setXsbtlb("1|高龄津贴");
+                r.setSndj(r.getSndj() + "|" + jkzkList.stream().filter(j -> StringUtils.equals(j.getDictValue(), r.getSndj())).findFirst().orElse(new SysDictData()).getDictLabel());
+                r.setYbzje(setYbzje(xmpz, r.getPc()));
+            } catch (Exception ignored) {}
+        }
+        return res;
+    }
+
+    private String setYbzje(GljtXmpz pz, String pc) {
+        String res = "";
+        if (StringUtils.equals(pc, "0")) res = pz.getBtzjE();
+        if (StringUtils.equals(pc, "1")) res = pz.getBtzjN();
+        if (StringUtils.equals(pc, "2")) res = pz.getBtzjH();
+        if (StringUtils.equals(pc, "3")) res = pz.getBtzjEd();
+        if (StringUtils.equals(pc, "4")) res = pz.getBtzjNd();
+        if (StringUtils.equals(pc, "5")) res = pz.getBtzjHd();
+        return formatAmount(res);
+    }
+
+    private String formatAmount(String amount) {
+        if (StringUtils.isEmpty(amount)) {
+            return "0.0";
+        }
+        try {
+            // 转换为 BigDecimal 处理
+            BigDecimal decimal = new BigDecimal(amount);
+            // 设置保留一位小数
+            decimal = decimal.setScale(1, RoundingMode.HALF_UP);
+            return decimal.toString();
+        } catch (Exception e) {
+            return "0.0";
+        }
+    }
+
+    private String parseStr2Str(String format, String dateStr) {
+        String res = "";
+        try {
+            SimpleDateFormat sdf = new SimpleDateFormat(DateUtils.YYYYMMDD);
+            Date date = sdf.parse(dateStr);
+            SimpleDateFormat sdf2 = new SimpleDateFormat(format);
+            res = sdf2.format(date);
+        } catch (Exception ignored) {}
+        return res;
+    }
+
     @Override
     public GljtSqLr getLrByZjhm(GljtSqLr gljtSqLr) {
         if (StringUtils.isEmpty(gljtSqLr.getSqrZjhm())) {