代码备份,获取关联关系
parent
33cbd296d6
commit
add5fecbca
@ -0,0 +1,9 @@
|
|||||||
|
package com.glxp.mipsdl.dao.basic;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.glxp.mipsdl.entity.basic.RelCodeDetail;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface RelCodeDetailMapper extends BaseMapper<RelCodeDetail> {
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package com.glxp.mipsdl.entity.basic;
|
||||||
|
|
||||||
|
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 java.io.Serializable;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName(value = "rel_code_detail")
|
||||||
|
public class RelCodeDetail implements Serializable {
|
||||||
|
@TableId(value = "id", type = IdType.INPUT)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前条码
|
||||||
|
*/
|
||||||
|
@TableField(value = "curCode")
|
||||||
|
private String curCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 包装级别
|
||||||
|
*/
|
||||||
|
@TableField(value = "packLayer")
|
||||||
|
private Byte packLayer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父级码
|
||||||
|
*/
|
||||||
|
@TableField(value = "parentCode")
|
||||||
|
private String parentCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
@TableField(value = "flag")
|
||||||
|
private Byte flag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品批次ID外键
|
||||||
|
*/
|
||||||
|
@TableField(value = "batchIdFk")
|
||||||
|
private Integer batchIdFk;
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.glxp.mipsdl.service.basic;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.glxp.mipsdl.entity.basic.RelCodeDetail;
|
||||||
|
import com.glxp.mipsdl.dao.basic.RelCodeDetailMapper;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class RelCodeDetailService extends ServiceImpl<RelCodeDetailMapper, RelCodeDetail> {
|
||||||
|
/**
|
||||||
|
* 获取下级所有码
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<RelCodeDetail> getAllNext(String code) {
|
||||||
|
List<RelCodeDetail> list = new ArrayList<>();
|
||||||
|
fetchAllChildren(code, list);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fetchAllChildren(String code, List<RelCodeDetail> list) {
|
||||||
|
List<RelCodeDetail> relCodeDetails = this.baseMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<RelCodeDetail>().eq(RelCodeDetail::getParentCode, code));
|
||||||
|
|
||||||
|
if (CollUtil.isNotEmpty(relCodeDetails)) {
|
||||||
|
list.addAll(relCodeDetails);
|
||||||
|
for (RelCodeDetail relCodeDetail : relCodeDetails) {
|
||||||
|
fetchAllChildren(relCodeDetail.getCurCode(), list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.glxp.mipsdl.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.sun.tools.javac.Main;
|
||||||
|
|
||||||
|
public class DdlUtils {
|
||||||
|
static {
|
||||||
|
// String path = System.getProperty("user.dir");
|
||||||
|
// path = path + "/dll/hsafsiyhsafe.dll";
|
||||||
|
// System.out.println(path);
|
||||||
|
System.loadLibrary("hsafsiyhsafe"); //
|
||||||
|
}
|
||||||
|
|
||||||
|
public native int gm_ecb_encrypt_key(String pub_key, String plain, int plain_len, String cipher);
|
||||||
|
|
||||||
|
public native int gm_ecb_decrypt_key(String pub_key, String cipher, int cipher_len, String plain);
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
DdlUtils ddlUtils = new DdlUtils();
|
||||||
|
String key = "D7F322E4541DB0C48EB7B0AF2093BEE3F1AC6A3FAB1BDE30E72816571EEC50B7";
|
||||||
|
String code = "H51072700564";
|
||||||
|
String data = "";
|
||||||
|
ddlUtils.gm_ecb_decrypt_key(code, key, key.length(), data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package com.glxp.mipsdl.util;
|
||||||
|
|
||||||
|
import com.sun.jna.Native;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author AnthonyYwj
|
||||||
|
* @date 2024/11/6
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import com.sun.jna.Library;
|
||||||
|
import com.sun.jna.Native;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
public interface GMEncrypt {
|
||||||
|
// 定义接口,映射 DLL 中的函数
|
||||||
|
public interface GMEncryptLibrary extends Library {
|
||||||
|
GMEncryptLibrary INSTANCE = (GMEncryptLibrary) Native.load("hsafsiyhsafe", GMEncryptLibrary.class);
|
||||||
|
|
||||||
|
// 映射 gm_ecb_encrypt_key 函数
|
||||||
|
int gm_ecb_encrypt_key(byte[] pub_key, byte[] plain, int plain_len, byte[] cipher);
|
||||||
|
int gm_ecb_decrypt_key(byte[] pub_key, byte[] plain, int plain_len, byte[] cipher);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// 准备输入数据
|
||||||
|
String pubKeyStr = "D7F322E4541DB0C48EB7B0AF2093BEE3F1AC6A3FAB1BDE30E72816571EEC50B7";
|
||||||
|
byte[] plain = "test plaintext".getBytes();
|
||||||
|
int plainLen = plain.length;
|
||||||
|
byte[] cipher = new byte[1024]; // cipher 大小依据加密算法决定
|
||||||
|
|
||||||
|
// 调用加密方法
|
||||||
|
int result = GMEncryptLibrary.INSTANCE.gm_ecb_encrypt_key(pubKeyStr.getBytes(StandardCharsets.UTF_8), plain, plainLen, cipher);
|
||||||
|
|
||||||
|
// 输出结果
|
||||||
|
if (result == 0) {
|
||||||
|
System.out.println("Encryption successful!");
|
||||||
|
System.out.println("Encrypted data: " + new String(cipher));
|
||||||
|
} else {
|
||||||
|
System.out.println("Encryption failed with error code: " + result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.glxp.mipsdl.dao.basic.RelCodeDetailMapper">
|
||||||
|
<resultMap id="BaseResultMap" type="com.glxp.mipsdl.entity.basic.RelCodeDetail">
|
||||||
|
<!--@mbg.generated-->
|
||||||
|
<!--@Table rel_code_detail-->
|
||||||
|
<id column="id" jdbcType="INTEGER" property="id" />
|
||||||
|
<result column="curCode" jdbcType="VARCHAR" property="curCode" />
|
||||||
|
<result column="packLayer" jdbcType="TINYINT" property="packLayer" />
|
||||||
|
<result column="parentCode" jdbcType="VARCHAR" property="parentCode" />
|
||||||
|
<result column="flag" jdbcType="TINYINT" property="flag" />
|
||||||
|
<result column="batchIdFk" jdbcType="INTEGER" property="batchIdFk" />
|
||||||
|
</resultMap>
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
<!--@mbg.generated-->
|
||||||
|
id, curCode, packLayer, parentCode, flag, batchIdFk
|
||||||
|
</sql>
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue