9 次代码提交 0e86a4d559 ... 2d7d85d401

作者 SHA1 备注 提交日期
  chubiao 2d7d85d401 Merge remote-tracking branch 'origin/master' 11 月之前
  chubiao 301d32fb63 yl 11 月之前
  sckj a206b74e88 Merge branch '20240322_sun' of sckj/mz-cloud into master 11 月之前
  15143018065 ba351d354b 20240326_sun 11 月之前
  sckj f42aa91273 Merge branch '20240322_sun' of sckj/mz-cloud into master 11 月之前
  15143018065 f2be650949 20240322_sun 11 月之前
  NanMing a5c8a84ed4 Merge branch 'yl-service' of sckj/mz-cloud into master 11 月之前
  sckj c170add48d Merge branch '20240322_sun' of sckj/mz-cloud into master 11 月之前
  15143018065 a5df127e00 20240325_sun 11 月之前

+ 2 - 0
ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/lnst/domain/InLnstLrxx.java

@@ -199,4 +199,6 @@ public class InLnstLrxx extends BaseEntity
     private String lrHtdb;
 
     private String lrHtzp;
+
+    private String ylcard;
 }

+ 1 - 0
ruoyi-api/ruoyi-api-system/src/main/java/com/ruoyi/lnst/domain/InLnstShxx.java

@@ -121,6 +121,7 @@ public class InLnstShxx extends BaseEntity
     private String lrHtdb;
     private String lrHtzp;
     private String state;
+    private String ylcard;
     @TableField(exist = false)
     private InLnstShxx last;
 }

+ 36 - 21
ruoyi-modules/mz-lnst/src/main/java/com/ruoyi/lnst/service/impl/YlServer.java

@@ -30,9 +30,21 @@ import static com.ruoyi.common.core.utils.DateUtils.YYYY_MM_DD_HH_MM_SS;
 @Service
 public class YlServer {
 
+    public static void main(String[] args) {
+        TreeMap<String, Object> lr = new TreeMap<>();
+        try {
+            lr.put("memberUniqueId", RSAUtils.encryptByPublicKey("220283194001163436", ResourceUtil.getConfigByName("yl.enKey")));
+        } catch (Exception e) {
+            System.out.println("加密失败");
+        }
+        TreeMap<String, Object> map = YlServer.publicSupport(ResourceUtil.getConfigByName("yl.hycx"), null,
+                ResourceUtil.getConfigByName("yl.version"), lr);
+        System.out.println(YlServer.httpsRequest(YlServer.Map2JSONStr(map)));
+    }
+
     // 2.1	会员信息新增
-    public String ylRegister(InLnstLrxx lrxx) {
-        String r = "";
+    public JSONObject ylRegister(InLnstLrxx lrxx) {
+        JSONObject r = null;
         TreeMap<String, Object> lr = new TreeMap<>();
         try {
             lr.put("memberName", RSAUtils.encryptByPublicKey(lrxx.getLrXm(), ResourceUtil.getConfigByName("yl.enKey")));
@@ -49,11 +61,12 @@ public class YlServer {
                 ResourceUtil.getConfigByName("yl.version"), lr);
         JSONObject res = YlServer.httpsRequest(YlServer.Map2JSONStr(map));
         if (res.containsKey("respCode") && StringUtils.equals(res.getString("respCode"), "0000")) {
-            r = res.getString("memberCode");
+            r = res;
+            // 先禁用
+            ylDisabled(res.getString("memberCode"));
         } else {
             throw new ServiceException(res.toJSONString());
         }
-//        r = "1100302099";
         return r;
     }
 
@@ -71,7 +84,7 @@ public class YlServer {
             lr.put("communityName", null);
             lr.put("streetName", null);
         } catch (Exception e) {
-            throw new ServiceException(e.getMessage());
+            throw new ServiceException("加密失败 ==> " + e.getMessage());
         }
         TreeMap<String, Object> map = YlServer.publicSupport(ResourceUtil.getConfigByName("yl.hybj"), null,
                 ResourceUtil.getConfigByName("yl.version"), lr);
@@ -87,9 +100,20 @@ public class YlServer {
     // 2.3	会员信息查询
     public JSONObject ylQuery(InLnstLrxx lrxx) {
         TreeMap<String, Object> lr = new TreeMap<>();
-        lr.put("memberCode", lrxx.getYlcode());
-        TreeMap<String, Object> map = YlServer.publicSupport(ResourceUtil.getConfigByName("yl.hycx"), null,
-                null, lr);
+        TreeMap<String, Object> map = new TreeMap<>();
+        if (StringUtils.isNotEmpty(lrxx.getYlcode())) {
+            lr.put("memberCode", lrxx.getYlcode());
+            map = YlServer.publicSupport(ResourceUtil.getConfigByName("yl.hycx"), null,
+                    null, lr);
+        } else {
+            try {
+                lr.put("memberUniqueId", RSAUtils.encryptByPublicKey(lrxx.getLrZjhm(), ResourceUtil.getConfigByName("yl.enKey")));
+                map = YlServer.publicSupport(ResourceUtil.getConfigByName("yl.hycx"), null,
+                        ResourceUtil.getConfigByName("yl.version"), lr);
+            } catch (Exception e) {
+                throw new ServiceException("加密失败 ==> " + e.getMessage());
+            }
+        }
         JSONObject res = YlServer.httpsRequest(YlServer.Map2JSONStr(map));
         if (res.containsKey("respCode") && StringUtils.equals(res.getString("respCode"), "0000")) {
             try {
@@ -112,9 +136,9 @@ public class YlServer {
     }
 
     // 2.4	会员禁用
-    public void ylDisabled(InLnstLrxx lrxx) {
+    public void ylDisabled(String memberCode) {
         TreeMap<String, Object> lr = new TreeMap<>();
-        lr.put("memberCode", lrxx.getYlcode());
+        lr.put("memberCode", memberCode);
         TreeMap<String, Object> map = YlServer.publicSupport(ResourceUtil.getConfigByName("yl.hyjy"), null,
                 null, lr);
         JSONObject res = YlServer.httpsRequest(YlServer.Map2JSONStr(map));
@@ -126,9 +150,9 @@ public class YlServer {
     }
 
     // 2.5	会员启用
-    public void ylEnabled(InLnstLrxx lrxx) {
+    public void ylEnabled(String memberCode) {
         TreeMap<String, Object> lr = new TreeMap<>();
-        lr.put("memberCode", lrxx.getYlcode());
+        lr.put("memberCode", memberCode);
         TreeMap<String, Object> map = YlServer.publicSupport(ResourceUtil.getConfigByName("yl.hyqy"), null,
                 null, lr);
         JSONObject res = YlServer.httpsRequest(YlServer.Map2JSONStr(map));
@@ -168,15 +192,6 @@ public class YlServer {
         }
     }
 
-    public static void main(String[] args) {
-        TreeMap<String, Object> test = new TreeMap<>();
-        test.put("storeCode", "100000444");
-        test.put("state", "1");
-        TreeMap<String, Object> map = publicSupport("plat.mchnt.store.stateswitch", null, null, test);
-        JSONObject res = httpsRequest(Map2JSONStr(map));
-        System.out.println(res);
-    }
-
     public static String Map2JSONStr(TreeMap<String, Object> params) {
         JSONObject jsonParams = new JSONObject();
         for (String key : params.keySet()) {

+ 105 - 70
ruoyi-modules/mz-lnst/src/main/java/com/ruoyi/lnst/service/impl/ZwywLrJbxxServiceImpl.java

@@ -189,14 +189,6 @@ public class ZwywLrJbxxServiceImpl implements IZwywLrJbxxService {
         return res;
     }
 
-    @Override
-    public InLnstLrxx getLrByZjhm(InLnstLrxx zwywLrJbxx) {
-        if (StringUtils.isEmpty(zwywLrJbxx.getLrJmzjhm())) {
-            throw new ServiceException("缺失必要参数");
-        }
-        return zwywLrJbxxMapper.selectOne(new LambdaQueryWrapper<>(zwywLrJbxx));
-    }
-
     /**
      * 新增老人基本信息
      *
@@ -206,35 +198,41 @@ public class ZwywLrJbxxServiceImpl implements IZwywLrJbxxService {
     @Transactional
     @Override
     public int insertZwywLrJbxx(InLnstLrxx zwywLrJbxx) {
-        // 插用户
-        LoginUser loginUser = userService.getUserInfo(zwywLrJbxx.getLrZjhm(), SecurityConstants.INNER).getData();
+        // 微信端专用新增
+        // 重复性检测 老人信息表/本系统老人用户表/银联系统会员表
+        LoginUser loginUser = userService.getLrUserInfo(zwywLrJbxx.getLrZjhm(), SecurityConstants.INNER).getData();
         InLnstLrxx query = new InLnstLrxx();
         query.setLrZjhm(zwywLrJbxx.getLrZjhm());
         InLnstLrxx check = zwywLrJbxxMapper.selectOne(new LambdaQueryWrapper<>(query));
         if (ObjectUtils.isNotEmpty(loginUser) || ObjectUtils.isNotEmpty(check)) {
             throw new ServiceException("该证件号码账号已存在");
         }
+        // 前端未传流转状态
+        // 草稿
         if (StringUtils.isEmpty(zwywLrJbxx.getLzzt())) {
-            if (StringUtils.isNotEmpty(zwywLrJbxx.getLrTx()) && StringUtils.isNotEmpty(zwywLrJbxx.getLrZjz())) {
-                // 通过
-                zwywLrJbxx.setLzzt("3");
-            } else {
-                // 草稿
-                zwywLrJbxx.setLzzt("0");
-            }
+            zwywLrJbxx.setLzzt("0");
         }
+        // 调用银联会员注册接口,将返回值放到 银联code 和 银联会员卡code 中
+        zwywLrJbxx.setYlcode("1100302099");
+        zwywLrJbxx.setYlcard("1100302099");
+        // 老人加密证件号码
+        zwywLrJbxx.setLrJmzjhm(DigestUtils.md5Hex(zwywLrJbxx.getLrZjhm()));
+        // 本系统的老人注册
         String userId = insertUser(zwywLrJbxx);
         if (StringUtils.isEmpty(userId)) {
             throw new ServiceException("用户已经存在");
         }
-        zwywLrJbxx.setYlcode("1100302099");
+        // 主键直接使用该userId
         zwywLrJbxx.setId(userId);
-        zwywLrJbxx.setLrJmzjhm(DigestUtils.md5Hex(zwywLrJbxx.getLrZjhm()));
+        // 生成登记编号
         zwywLrJbxx.setDjbh(String.valueOf(Long.parseLong(zwywLrJbxxMapper.selectMaxBh(zwywLrJbxx.getLrHjdz().substring(0, 6))) + 1));
+        // 审核信息实例化并将当前新增的老人数据复制一份
         InLnstShxx shxx = new InLnstShxx();
         BeanUtil.copyProperties(zwywLrJbxx, shxx, new CopyOptions().ignoreNullValue());
+        // 判断老人注册的户籍地址是否是强制注册的区划
         LnstDeptExamine examine = lnstDeptExamineMapper.selectList(new LambdaQueryWrapper<LnstDeptExamine>()
-                .eq(LnstDeptExamine::getCode, zwywLrJbxx.getLrHjdz())).stream().findFirst().orElse(null);
+                .eq(LnstDeptExamine::getCode, zwywLrJbxx.getLrHjdz().substring(0, 6) + "000000")).stream().findFirst().orElse(null);
+        // 需要审核的情况
         if (StringUtils.equals(zwywLrJbxx.getLzzt(), "1") || StringUtils.equals(zwywLrJbxx.getLzzt(), "2")
                 || ObjectUtils.isNotEmpty(examine) || StringUtils.equals(zwywLrJbxx.getLzzt(), "5")
                 || !StringUtils.isAllEmpty(zwywLrJbxx.getTkzm(), zwywLrJbxx.getDbzm(), zwywLrJbxx.getZczm())) {
@@ -251,6 +249,7 @@ public class ZwywLrJbxxServiceImpl implements IZwywLrJbxxService {
                 shxx.setSqyy("老人待审核");
             }
         }
+        // 插入出生日期和性别
         try {
             if (StringUtils.isEmpty(zwywLrJbxx.getLrCsrq())) {
                 zwywLrJbxx.setLrCsrq(zwywLrJbxx.getLrZjhm().substring(7, 15));
@@ -260,7 +259,9 @@ public class ZwywLrJbxxServiceImpl implements IZwywLrJbxxService {
                 zwywLrJbxx.setLrXb(xb);
             }
         } catch (Exception ignored) {}
+        // 插入该条老人数据
         int res = zwywLrJbxxMapper.insert(zwywLrJbxx);
+        // 当前需要审核的情况插入审核数据
         if (StringUtils.equals(zwywLrJbxx.getLzzt(), "1") || StringUtils.equals(zwywLrJbxx.getLzzt(), "2")
                 || StringUtils.equals(zwywLrJbxx.getLzzt(), "5") || StringUtils.equals(zwywLrJbxx.getLzzt(), "7")) {
             shxx.setId(IdUtils.simpleUUID());
@@ -269,36 +270,60 @@ public class ZwywLrJbxxServiceImpl implements IZwywLrJbxxService {
             shxx.setLzzt(zwywLrJbxx.getLzzt());
             zwywJclrShxxMapper.insert(shxx);
         }
+        // 插入一条空的活体数据
         LnstYlht ht = new LnstYlht();
         ht.setId(IdUtils.simpleUUID());
         ht.setYlcode(zwywLrJbxx.getYlcode());
         ht.setYlid(zwywLrJbxx.getId());
         lnstYlhtMapper.insert(ht);
-//        if (StringUtils.equals(zwywLrJbxx.getLzzt(), "3") && StringUtils.equals(zwywLrJbxx.getSource(), "0")) {
-//            uploadBaidu(zwywLrJbxx);
-//        }
         return res;
     }
 
     @Transactional
     @Override
     public int insertZwywLrJbxxWeb(InLnstLrxx zwywLrJbxx) {
+        // web端专用新增
         int res = 0;
-        LoginUser loginUser = userService.getUserInfo(zwywLrJbxx.getLrZjhm(), SecurityConstants.INNER).getData();
+        // 重复性检测 老人信息表/本系统老人用户表/银联系统会员表
+        LoginUser loginUser = userService.getLrUserInfo(zwywLrJbxx.getLrZjhm(), SecurityConstants.INNER).getData();
         InLnstLrxx query = new InLnstLrxx();
         query.setLrZjhm(zwywLrJbxx.getLrZjhm());
         InLnstLrxx check = zwywLrJbxxMapper.selectOne(new LambdaQueryWrapper<>(query));
+
         if (ObjectUtils.isNotEmpty(loginUser) || ObjectUtils.isNotEmpty(check)) {
             throw new ServiceException("该证件号码账号已存在");
         }
+        // insert默认草稿属性,活体检测后才确定流转状态
         zwywLrJbxx.setLzzt("0");
+        // 调用银联会员注册接口,将返回值放到 银联code 和 银联会员卡code 中
         zwywLrJbxx.setYlcode("1100302099");
+        zwywLrJbxx.setYlcard("1100302099");
+        // 老人加密证件号码
         zwywLrJbxx.setLrJmzjhm(DigestUtils.md5Hex(zwywLrJbxx.getLrZjhm()));
+        // web端户籍地址直接使用当前账号的行政区划
         zwywLrJbxx.setLrHjdz(SecurityUtils.getAreaCode());
+        // 生成登记编号
         zwywLrJbxx.setDjbh(String.valueOf(Long.parseLong(zwywLrJbxxMapper.selectMaxBh(zwywLrJbxx.getLrHjdz().substring(0, 6))) + 1));
+        // 本系统的老人注册
         String userId = insertUser(zwywLrJbxx);
+        if (StringUtils.isEmpty(userId)) {
+            throw new ServiceException("用户已经存在");
+        }
+        // 主键直接使用该userId
         zwywLrJbxx.setId(userId);
+        // 插入出生日期和性别
+        try {
+            if (StringUtils.isEmpty(zwywLrJbxx.getLrCsrq())) {
+                zwywLrJbxx.setLrCsrq(zwywLrJbxx.getLrZjhm().substring(7, 15));
+            }
+            if (StringUtils.isEmpty(zwywLrJbxx.getLrXb())) {
+                String xb = Integer.parseInt(zwywLrJbxx.getLrZjhm().substring(17, 18)) % 2 == 0 ? "2" : "1";
+                zwywLrJbxx.setLrXb(xb);
+            }
+        } catch (Exception ignored) {}
+        // 插入本条老人数据
         res = zwywLrJbxxMapper.insert(zwywLrJbxx);
+        // 直接插入一条空的活体数据
         LnstYlht ht = new LnstYlht();
         ht.setId(IdUtils.simpleUUID());
         ht.setYlcode(zwywLrJbxx.getYlcode());
@@ -307,6 +332,54 @@ public class ZwywLrJbxxServiceImpl implements IZwywLrJbxxService {
         return res;
     }
 
+    /**
+     * 修改老人基本信息
+     *
+     * @param zwywLrJbxx 老人基本信息
+     * @return 结果
+     */
+    @Transactional
+    @Override
+    public int updateZwywLrJbxx(InLnstLrxx zwywLrJbxx) {
+        // 检测是否存在老人户籍地址
+        if (StringUtils.isEmpty(zwywLrJbxx.getLrHjdz())) {
+            InLnstLrxx old = zwywLrJbxxMapper.selectById(zwywLrJbxx.getId());
+            if (ObjectUtils.isNotEmpty(old)) {
+                zwywLrJbxx.setLrHjdz(old.getLrHjdz());
+            } else {
+                throw new ServiceException("该老人已被删除");
+            }
+        }
+        // 判断老人更新的户籍地址是否是强制注册的区划
+        LnstDeptExamine examine = lnstDeptExamineMapper.selectList(new LambdaQueryWrapper<LnstDeptExamine>()
+                .eq(LnstDeptExamine::getCode, zwywLrJbxx.getLrHjdz().substring(0, 6) + "000000")).stream().findFirst().orElse(null);
+        // 当前需要审核的情况
+        if (StringUtils.equals(zwywLrJbxx.getLzzt(), "1") || StringUtils.equals(zwywLrJbxx.getLzzt(), "2")
+                || StringUtils.equals(zwywLrJbxx.getLzzt(), "5") || ObjectUtils.isNotEmpty(examine)
+                || !StringUtils.isAllEmpty(zwywLrJbxx.getTkzm(), zwywLrJbxx.getDbzm(), zwywLrJbxx.getZczm())) {
+            InLnstShxx shxx = new InLnstShxx();
+            BeanUtil.copyProperties(zwywLrJbxx, shxx, new CopyOptions().ignoreNullValue());
+            if (StringUtils.equals(zwywLrJbxx.getLzzt(), "1")) {
+                shxx.setSqyy("老人照片与证件照匹配度过低");
+            } else if (StringUtils.equals(zwywLrJbxx.getLzzt(), "2")) {
+                shxx.setSqyy("存在相似老人照片");
+            } else if (StringUtils.equals(zwywLrJbxx.getLzzt(), "5")
+                    || !StringUtils.isAllEmpty(zwywLrJbxx.getTkzm(), zwywLrJbxx.getDbzm(), zwywLrJbxx.getZczm())) {
+                zwywLrJbxx.setLzzt("5");
+                shxx.setSqyy("特殊材料待审");
+            } else {
+                zwywLrJbxx.setLzzt("7");
+                shxx.setSqyy("老人待审核");
+            }
+            shxx.setId(IdUtils.simpleUUID());
+            shxx.setLrId(zwywLrJbxx.getId());
+            shxx.setSqsj(DateUtils.dateTimeNow());
+            shxx.setLzzt(zwywLrJbxx.getLzzt());
+            zwywJclrShxxMapper.insert(shxx);
+        }
+        return zwywLrJbxxMapper.updateById(zwywLrJbxx);
+    }
+
     @Override
     public int sh(InLnstShxx shxx) {
         int res = 0;
@@ -338,6 +411,14 @@ public class ZwywLrJbxxServiceImpl implements IZwywLrJbxxService {
         return zwywLrJbxxMapper.updateById(lrxx);
     }
 
+    @Override
+    public InLnstLrxx getLrByZjhm(InLnstLrxx zwywLrJbxx) {
+        if (StringUtils.isEmpty(zwywLrJbxx.getLrJmzjhm())) {
+            throw new ServiceException("缺失必要参数");
+        }
+        return zwywLrJbxxMapper.selectOne(new LambdaQueryWrapper<>(zwywLrJbxx));
+    }
+
     @Override
     public Map<String, String> match(InLnstLrxx zwywLrJbxx) {
         Map<String, String> res = new LinkedHashMap<>();
@@ -659,52 +740,6 @@ public class ZwywLrJbxxServiceImpl implements IZwywLrJbxxService {
         return res;
     }
 
-    /**
-     * 修改老人基本信息
-     *
-     * @param zwywLrJbxx 老人基本信息
-     * @return 结果
-     */
-    @Transactional
-    @Override
-    public int updateZwywLrJbxx(InLnstLrxx zwywLrJbxx)
-    {
-        if (StringUtils.isEmpty(zwywLrJbxx.getLrHjdz())) {
-            InLnstLrxx old = zwywLrJbxxMapper.selectById(zwywLrJbxx.getId());
-            if (ObjectUtils.isNotEmpty(old)) {
-                zwywLrJbxx.setLrHjdz(old.getLrHjdz());
-            } else {
-                throw new ServiceException("该老人已被删除");
-            }
-        }
-        LnstDeptExamine examine = lnstDeptExamineMapper.selectList(new LambdaQueryWrapper<LnstDeptExamine>()
-                .eq(LnstDeptExamine::getCode, zwywLrJbxx.getLrHjdz())).stream().findFirst().orElse(null);
-        if (StringUtils.equals(zwywLrJbxx.getLzzt(), "1") || StringUtils.equals(zwywLrJbxx.getLzzt(), "2")
-                || StringUtils.equals(zwywLrJbxx.getLzzt(), "5") || ObjectUtils.isNotEmpty(examine)
-                || !StringUtils.isAllEmpty(zwywLrJbxx.getTkzm(), zwywLrJbxx.getDbzm(), zwywLrJbxx.getZczm())) {
-            InLnstShxx shxx = new InLnstShxx();
-            BeanUtil.copyProperties(zwywLrJbxx, shxx, new CopyOptions().ignoreNullValue());
-            if (StringUtils.equals(zwywLrJbxx.getLzzt(), "1")) {
-                shxx.setSqyy("老人照片与证件照匹配度过低");
-            } else if (StringUtils.equals(zwywLrJbxx.getLzzt(), "2")) {
-                shxx.setSqyy("存在相似老人照片");
-            } else if (StringUtils.equals(zwywLrJbxx.getLzzt(), "5")
-                || !StringUtils.isAllEmpty(zwywLrJbxx.getTkzm(), zwywLrJbxx.getDbzm(), zwywLrJbxx.getZczm())) {
-                zwywLrJbxx.setLzzt("5");
-                shxx.setSqyy("特殊材料待审");
-            } else {
-                zwywLrJbxx.setLzzt("7");
-                shxx.setSqyy("老人待审核");
-            }
-            shxx.setId(IdUtils.simpleUUID());
-            shxx.setLrId(zwywLrJbxx.getId());
-            shxx.setSqsj(DateUtils.dateTimeNow());
-            shxx.setLzzt(zwywLrJbxx.getLzzt());
-            zwywJclrShxxMapper.insert(shxx);
-        }
-        return zwywLrJbxxMapper.updateById(zwywLrJbxx);
-    }
-
     /**
      * 批量删除老人基本信息
      *

+ 157 - 0
ruoyi-modules/mz-lnst/src/main/java/com/ruoyi/lnst/utils/yl/DESedeEncryptAndDecryptDemo.java

@@ -0,0 +1,157 @@
+package com.ruoyi.lnst.utils.yl;
+
+import javax.crypto.Cipher;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
+
+/**
+ * 3DES加解密 demo
+ * 可自取需要的代码部分
+ */
+public class DESedeEncryptAndDecryptDemo {
+
+    /**
+     * 加密算法3DES
+     */
+    private static final String Algorithm = "DESede";
+
+    /**
+     * 十六进制字符
+     */
+    private static final String hexChars = "0123456789ABCDEF";
+
+    /**
+     * 3DES加密
+     *
+     * @param src 待加密数据(二进制格式)
+     * @param key 3DES密钥
+     * @return 密文(二进制格式)
+     * @throws Exception
+     */
+    public static byte[] encryptMode(byte[] src, String key) throws Exception {
+        SecretKey deskey = new SecretKeySpec(build3DesKey(key), Algorithm);    //生成密钥
+        Cipher c1 = Cipher.getInstance(Algorithm);    //实例化负责加密/解密的Cipher工具类
+        c1.init(Cipher.ENCRYPT_MODE, deskey);    //初始化为加密模式
+        return c1.doFinal(src);
+    }
+
+    /**
+     * 3DES解密
+     *
+     * @param src 待解密数据(二进制格式)
+     * @param key 3DES密钥
+     * @return 明文
+     * @throws Exception
+     */
+    public static byte[] decryptMode(byte[] src, String key) throws Exception {
+        SecretKey deskey = new SecretKeySpec(build3DesKey(key), Algorithm);
+        Cipher c1 = Cipher.getInstance(Algorithm);
+        c1.init(Cipher.DECRYPT_MODE, deskey);    //初始化为解密模式
+        return c1.doFinal(src);
+    }
+
+    /**
+     * 构造3DES密钥
+     *
+     * @param keyStr 密钥字符串
+     * @return 24位的3DES密钥
+     * @throws UnsupportedEncodingException
+     */
+    public static byte[] build3DesKey(String keyStr) throws UnsupportedEncodingException {
+        byte[] key = new byte[24];    //声明一个24位的字节数组,默认里面都是0
+        byte[] temp = keyStr.getBytes("UTF-8");    //将字符串转成字节数组
+        //执行数组拷贝
+        if (key.length > temp.length) {
+            //如果temp不够24位,则拷贝temp数组整个长度的内容到key数组中
+            System.arraycopy(temp, 0, key, 0, temp.length);
+        } else {
+            //如果temp大于24位,则拷贝temp数组24个长度的内容到key数组中
+            System.arraycopy(temp, 0, key, 0, key.length);
+        }
+        return key;
+    }
+
+    /**
+     * byte数组转换成Hex字符串
+     *
+     * @param data byte数组
+     * @return Hex字符串
+     */
+    public static String byteArray2HexString(byte[] data) {
+        if (data == null)
+            return null;
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < data.length; i++) {
+            byte lo = (byte) (0x0f & data[i]);
+            byte hi = (byte) ((0xf0 & data[i]) >>> 4);
+            sb.append(hexChars.charAt(hi)).append(hexChars.charAt(lo));
+        }
+        return sb.toString();
+    }
+
+    /**
+     * Hex字符串转换成byte数组
+     *
+     * @param hexStr Hex字符串
+     * @return byte数组
+     */
+    public static byte[] hexString2ByteArray(String hexStr) {
+        if (hexStr == null)
+            return null;
+        if (hexStr.length() % 2 != 0) {
+            return null;
+        }
+        byte[] data = new byte[hexStr.length() / 2];
+        for (int i = 0; i < hexStr.length() / 2; i++) {
+            char hc = hexStr.charAt(2 * i);
+            char lc = hexStr.charAt(2 * i + 1);
+            byte hb = hexChar2Byte(hc);
+            byte lb = hexChar2Byte(lc);
+            if (hb < 0 || lb < 0) {
+                return null;
+            }
+            int n = hb << 4;
+            data[i] = (byte) (n + lb);
+        }
+        return data;
+    }
+
+    /**
+     * Hex字符转换成byte格式
+     *
+     * @param c Hex字符
+     * @return byte格式数据
+     */
+    public static byte hexChar2Byte(char c) {
+        if (c >= '0' && c <= '9')
+            return (byte) (c - '0');
+        if (c >= 'a' && c <= 'f')
+            return (byte) (c - 'a' + 10);
+        if (c >= 'A' && c <= 'F')
+            return (byte) (c - 'A' + 10);
+        return -1;
+    }
+
+    public static void main(String[] args) throws Exception {
+
+        String desKey = "EC8A649490CF2FEC8EC4CB9337ADB305";//desKey,注意替换成自己的
+
+        //加密
+        String name = "张三";
+        String certNo = "123456202210244321";
+        String nameEnc = byteArray2HexString(encryptMode(name.getBytes(), desKey));
+        String certNoEnc = byteArray2HexString(encryptMode(certNo.getBytes(), desKey));
+        System.out.println(nameEnc);
+        System.out.println(certNoEnc);
+
+        //解密
+        String nameEnc2 = "AF7462A08EE5EC2CAAA8D3B2D9FC322CB22A63654A52B035";
+        String certNoEnc2 = "48D8AB97BB28F4AA0257F03D0C6867DF9CACB2C56081DAA1";
+        String name2 = new String(decryptMode(hexString2ByteArray(nameEnc2), desKey), StandardCharsets.UTF_8);
+        String certNo2 = new String(decryptMode(hexString2ByteArray(certNoEnc2), desKey), StandardCharsets.UTF_8);
+        System.out.println(name2);
+        System.out.println(certNo2);
+    }
+}

+ 79 - 0
ruoyi-modules/mz-lnst/src/main/java/com/ruoyi/lnst/utils/yl/FaceMatchIdcardDemo.java

@@ -0,0 +1,79 @@
+package com.ruoyi.lnst.utils.yl;
+
+import cn.hutool.http.HttpRequest;
+import cn.hutool.http.HttpResponse;
+import cn.hutool.http.HttpUtil;
+import cn.hutool.json.JSONObject;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.codec.digest.DigestUtils;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URLEncoder;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.UUID;
+
+/**
+ * H5人证比对 demo
+ */
+public class FaceMatchIdcardDemo {
+
+    static String appId = "10037e6f894883e9018985d7d45900cc"; //appId,注意替换成自己的
+    static String appKey = "6d024f7545ba4ada9db15809ed3d8192"; //appKey,注意替换成自己的
+    static String timestamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
+    static String nonce = UUID.randomUUID().toString().replace("-", "");
+
+    public static void main(String[] args) throws IOException, NoSuchAlgorithmException, InvalidKeyException {
+        getParam();
+    }
+
+    public static void getParam() throws IOException, NoSuchAlgorithmException, InvalidKeyException {
+        JSONObject json = new JSONObject();
+        json.put("bizType", 0);
+        json.put("returnUrl", "https://www.baidu.com");
+
+        System.out.println("请求报文:\n"+json);
+        String param = getOpenBodySig(appId, appKey, timestamp, nonce, json.toString());
+        String url = "https://test-api-open.chinaums.com/v1/visual-ai/face-match-idcard";
+        System.out.println("URL:\n" + url + "?" + param);
+
+
+
+    }
+
+    public static String getOpenBodySig(String appId, String appKey, String timestamp, String nonce, String content) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
+
+        byte[] data = content.getBytes("utf-8");
+        InputStream is = new ByteArrayInputStream(data);
+        String bodyDigest = DigestUtils.sha256Hex(is);
+        System.out.println("bodyDigest:" + bodyDigest);
+        String str1_C = appId + timestamp + nonce + bodyDigest;
+        System.out.println("str1_C:" + str1_C);
+        byte[] localSignature = hmacSHA256(str1_C.getBytes(), appKey.getBytes());
+        System.out.println("localSignature:" + localSignature);
+        String signature = Base64.encodeBase64String(localSignature);
+        System.out.println("signature:" + signature);
+        return ("authorization=OPEN-FORM-PARAM" + "&appId=" + appId + "&timestamp=" + timestamp + "&nonce=" + nonce + "&content=" + URLEncoder.encode(content, "UTF-8") + "&signature=" + URLEncoder.encode(signature, "UTF-8"));
+    }
+
+    /**
+     * @param data
+     * @param key
+     * @return
+     * @throws NoSuchAlgorithmException
+     * @throws InvalidKeyException
+     * @Description
+     */
+    public static byte[] hmacSHA256(byte[] data, byte[] key) throws NoSuchAlgorithmException, InvalidKeyException {
+        String algorithm = "HmacSHA256";
+        Mac mac = Mac.getInstance(algorithm);
+        mac.init(new SecretKeySpec(key, algorithm));
+        return mac.doFinal(data);
+    }
+}

+ 98 - 0
ruoyi-modules/mz-lnst/src/main/java/com/ruoyi/lnst/utils/yl/Test.java

@@ -0,0 +1,98 @@
+package com.ruoyi.lnst.utils.yl;
+
+import com.alibaba.fastjson.JSON;
+import org.apache.commons.codec.digest.DigestUtils;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URLEncoder;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TreeMap;
+import java.util.UUID;
+
+import static com.ruoyi.lnst.utils.yl.DESedeEncryptAndDecryptDemo.byteArray2HexString;
+import static com.ruoyi.lnst.utils.yl.DESedeEncryptAndDecryptDemo.encryptMode;
+
+public class Test {
+
+
+    public static void main(String[] args) throws Exception {
+        String url = "https://test-api-open.chinaums.com/v1/visual-ai/face/garden-collect";
+        String appKey = "5a735c9a42d1401da0e39516f2b3bef7";
+        String desKey = "A5D37C3D8502D503CC7B1EB62CEF4B79";
+        String authorization = "OPEN-FORM-PARAM";
+        String appId = "10037e6f6394f6e70163a6782676007d";
+        String timestamp = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
+        String nonce = UUID.randomUUID().toString().replace("-", "");
+        String content = "";
+        TreeMap<String, Object> contentMap = new TreeMap<>();
+        TreeMap<String, Object> bizDataMap = new TreeMap<String, Object>();
+        String cardNo = "1200317040";
+        String gardenId = "0100000019";
+        bizDataMap.put("gardenId", gardenId);
+        bizDataMap.put("mbrId", "1100302250");
+        bizDataMap.put("cardNo", cardNo);
+        bizDataMap.put("mobile", "15143018065");
+        // 人脸用户号usrId生成规则为: cardCode + mchntCode
+        contentMap.put("usrId", cardNo + gardenId);
+        contentMap.put("notifyUrl", "https://www.ccsckj.com/");
+        contentMap.put("redirectUrl", "https://www.ccsckj.com/");
+        contentMap.put("type", "action");
+        System.out.println(JSON.toJSONString(bizDataMap));
+
+
+        String nameEnc = byteArray2HexString(encryptMode(JSON.toJSONString(bizDataMap).getBytes(), desKey));
+        contentMap.put("bizData", nameEnc);
+
+        content = JSON.toJSONString(contentMap);
+
+        System.out.println("加密前:" + content);
+
+        String signature = getOpenBodySig(appId, appKey, timestamp, nonce, content);
+        String uri = url + "?" + signature;
+        // encodeURIComponent
+        System.out.println("入参:" + uri);
+//        HttpRequest get = HttpUtil.createGet(uri);
+//        HttpResponse response = get.execute();
+//        System.out.println("wwww"+response.body());
+    }
+
+
+    public static String getOpenBodySig(String appId, String appKey, String timestamp, String nonce, String content) throws IOException, InvalidKeyException, NoSuchAlgorithmException {
+
+        byte[] data = content.getBytes("utf-8");
+        InputStream is = new ByteArrayInputStream(data);
+        String bodyDigest = DigestUtils.sha256Hex(is);
+        System.out.println("bodyDigest:" + bodyDigest);
+        String str1_C = appId + timestamp + nonce + bodyDigest;
+        System.out.println("str1_C:" + str1_C);
+        byte[] localSignature = hmacSHA256(str1_C.getBytes(), appKey.getBytes());
+        System.out.println("localSignature:" + localSignature);
+        String signature = org.apache.commons.codec.binary.Base64.encodeBase64String(localSignature);
+        System.out.println("signature:" + signature);
+        return ("authorization=OPEN-FORM-PARAM" + "&appId=" + appId + "&timestamp=" + timestamp + "&nonce=" + nonce + "&content=" + URLEncoder.encode(content, "UTF-8") + "&signature=" + URLEncoder.encode(signature, "UTF-8"));
+    }
+
+    /**
+     * @param data
+     * @param key
+     * @return
+     * @throws NoSuchAlgorithmException
+     * @throws InvalidKeyException
+     * @Description
+     */
+    public static byte[] hmacSHA256(byte[] data, byte[] key) throws NoSuchAlgorithmException, InvalidKeyException {
+        String algorithm = "HmacSHA256";
+        Mac mac = Mac.getInstance(algorithm);
+        mac.init(new SecretKeySpec(key, algorithm));
+        return mac.doFinal(data);
+    }
+
+
+}

+ 1 - 0
ruoyi-modules/mz-lnst/src/main/resources/mapper/lnst/ZwywJclrShxxMapper.xml

@@ -27,6 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="spyj"    column="spyj"    />
         <result property="lzzt"    column="lzzt"    />
         <result property="state"    column="state"    />
+        <result property="ylcard"    column="ylcard"    />
         <result property="createTimeStr"    column="create_time_str"    />
         <result property="createUserId"    column="create_user_id"    />
         <result property="createBy"    column="create_by"    />

+ 1 - 0
ruoyi-modules/mz-lnst/src/main/resources/mapper/lnst/ZwywLrJbxxMapper.xml

@@ -55,6 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="djbh"    column="djbh"    />
         <result property="lrHtdb"    column="lr_htdb"    />
         <result property="lrHtzp"    column="lr_htzp"    />
+        <result property="ylcard"    column="ylcard"    />
     </resultMap>
 
     <select id="selectZwywLrJbxxList" parameterType="InLnstLrxx" resultMap="ZwywLrJbxxResult">