Merge remote-tracking branch 'lis8.0/master'

This commit is contained in:
jiangs 2025-09-18 17:58:07 +08:00
commit b3171392c6
5 changed files with 218 additions and 15 deletions

View File

@ -0,0 +1,124 @@
package com.czlis.interfaceCommon.utils;
import com.czlis.common.utils.DateUtils;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
public class HaveRegUtils {
/**
* 许可码有效性校验
* @param company 注册单位
* @param regkey 许可码
* @return 有效返回有效期,无效返回空
*/
public static String haveReg(String company, String regkey){
String newkey = regkey.replace("-", "");
String instrsl = RightA(newkey,5);
newkey = LeftA(newkey,10);
int year = 1990 + Integer.parseInt(RightA(instrsl,2));
int day = Integer.parseInt(LeftA(instrsl,3));
Date expiredate=LisUtil.relativeDateTime(DateUtils.parseDate(year + "/01/01"),day);
instrsl =DateUtils.parseDateToStr("yyyyMMdd",expiredate);
if(newkey.equals(haveregister(company,instrsl))){
return DateUtils.parseDateToStr("yyyy-MM-dd",expiredate);
}
return "";
}
/**
* 根据单位名称+有效期生成许可码
* @param company
* @param instrsl
* @return
*/
private static String haveregister(String company,String instrsl){
int ll_len= LisUtil.getGbkByteLength(company);
if(ll_len < 8) return "";
String newcompany = company + instrsl;
int il_len= LisUtil.getGbkByteLength(newcompany);
newcompany = newcompany.toUpperCase();
int[] il_char = LisUtil.getStringAscii(newcompany);
long[] il_parm= {0,0,0,0,0,0,0,0};
for (int i = 0; i < il_char.length; i++) {
il_parm[1] += il_char[i];
}
il_parm[2] = il_parm[1] / il_len;
il_parm[7] = il_parm[2];
il_parm[2] = il_parm[1];
il_parm[1] = il_parm[7];
int il_i=3;
for (int i = 0; i < il_char.length; i++) {
il_parm[il_i] = (int) (il_parm[il_i] + (il_char[i] * il_parm[il_i - 2]) / Math.sqrt(Math.abs(il_parm[il_i - 1])));
}
long[] serialnum={0,0,0,0,0};
serialnum[1]=Math.abs(il_parm[il_i]);
il_i=4;
for (int i = 0; i < il_char.length; i++) {
il_parm[il_i] = (int) (il_parm[il_i] + (il_char[i] * il_parm[il_i - 1]) / Math.sqrt(Math.abs(il_parm[il_i - 2])));
}
serialnum[2]=Math.abs(il_parm[il_i]);
il_i=5;
for (int i = 0; i < il_char.length; i++) {
il_parm[il_i] = (int) (il_parm[il_i] + il_char[i] * Math.sqrt(Math.abs(il_parm[il_i - 1] * il_parm[il_i - 2])));
}
serialnum[3]=Math.abs(il_parm[il_i]);
il_i=6;
for (int i = 0; i < il_char.length; i++) {
il_parm[il_i] = (int) (il_parm[il_i] + Math.log(Math.abs(il_char[i])) * Math.sqrt(Math.abs(il_parm[il_i - 1]) * LisUtil.logten(Math.abs(il_parm[il_i - 2]))));
}
serialnum[4]=Math.abs(il_parm[il_i]);
double com_sum=serialnum[1]+serialnum[2]+serialnum[3]+serialnum[4];
double com_sub=Math.abs(serialnum[2] * serialnum[3] - serialnum[1] * serialnum[4] );
double num1=Math.sqrt(Math.abs( serialnum[1] - serialnum[4] ) * Math.abs( serialnum[2] + serialnum[3] )) * 3412.971;
double num2=Math.log( com_sum * com_sub ) * 9134.176;
String sn1=RightA(String.format("%05d",(num1+ num2) * 2 - Math.sqrt(Math.abs(num1* num2)) ),5);
String sn2=RightA(String.format("%05d", num2 + num1 ),5);
String sn=Mid(sn2,2,1) + Mid(sn1,1,1) + Mid(sn1,5,1) + Mid(sn1,4,1) + Mid(sn2,3,1) + Mid(sn1,2,1) + Mid(sn2,1,1) + Mid(sn2,5,1) + Mid(sn2,4,1) + Mid(sn1,3,1);
return sn;
}
/**
* 从字符串第Index位开始截取指定长度的字符
* @param str 原始字符串
* @param length 要截取的长度
* @return 截取后的字符串
*/
private static String Mid(String str,int Index, int length) {
// 处理null和空字符串
if (str == null || str.isEmpty()) {
return "";
}
// 计算起始索引(第2位对应索引1)
int startIndex = Index - 1;
// 计算结束索引,确保不超出字符串长度
int endIndex = Math.min(startIndex + length, str.length());
// 如果起始索引已经超出字符串长度,返回空
if (startIndex >= str.length()) {
return "";
}
return str.substring(startIndex, endIndex);
}
private static String LeftA(String str,int n) {
if (str == null || str.isEmpty()) {
return str;
}
int length = Math.min(str.length(), n);
return str.substring(0, length);
}
private static String RightA(String str, int n) {
if (str == null) {
return null;
}
int startIndex = Math.max(0, str.length() - n);
return str.substring(startIndex);
}
// 测试
public static void main(String[] args) {
System.out.println(haveReg("石首市人民医院","63325-15429-00060"));
}
}

View File

@ -10,9 +10,8 @@ import java.text.SimpleDateFormat;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.Calendar; import java.util.*;
import java.util.Date;
import java.util.Map;
public class LisUtil { public class LisUtil {
// 换行符常量(跨平台) // 换行符常量(跨平台)
public static final String LINE_SEPARATOR = System.lineSeparator(); public static final String LINE_SEPARATOR = System.lineSeparator();
@ -79,6 +78,86 @@ public class LisUtil {
return result.toString(); return result.toString();
} }
/**
* 查询字符串GBK编码的长度
* @param str
* @return
*/
public static int getGbkByteLength(String str){
if (str == null) {
return 0;
}
// 将字符串按GBK编码转换为字节数组,数组长度即为GBK编码下的宽度
try {
return str.getBytes("GBK").length;
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
/**
* 字符串转ASCII值
* 中文:返回GBK编码第一个字节的ASCII值(无符号)
* 英文及其他单字节字符:直接返回其ASCII值
* @param strdata 要处理的字符串
* @return 对应的ASCII值
*/
public static int[] getStringAscii(String strdata) {
if (strdata == null || strdata.isEmpty()) {
return new int[0]; // 处理空字符串
}
// 用List暂存结果,避免提前计算数组长度
List<Integer> asciiList = new ArrayList<>();
for (int i = 0; i < strdata.length(); i++) {
char c = strdata.charAt(i);
try {
if (isChinese(c)) {
// 中文字符:添加GBK编码的所有字节(通常是2个)
byte[] gbkBytes = String.valueOf(c).getBytes("GBK");
for (byte b : gbkBytes) {
asciiList.add(b & 0xFF); // 转换为无符号值
}
} else {
// 非中文字符:直接添加ASCII值
asciiList.add((int) c);
}
} catch (UnsupportedEncodingException e) {
System.out.println("处理字符 '" + c + "' 时发生编码错误: " + e.getMessage());
}
}
// 转换List为int数组并返回
int[] ascValue = new int[asciiList.size()];
for (int i = 0; i < asciiList.size(); i++) {
ascValue[i] = asciiList.get(i);
}
return ascValue;
}
/**
* 计算以10为底的对数
* @param x 输入值(必须大于0)
* @return 以10为底的对数值
*/
public static double logten(double x) {
if (x <= 0) {
throw new IllegalArgumentException("输入值必须大于0");
}
// 利用换底公式:log10(x) = ln(x) / ln(10)
return Math.log(x) / Math.log(10);
}
/**
* 判断字符是否为中文字符
* @param c 要判断的字符
* @return 是中文字符返回true,否则返回false
*/
private static boolean isChinese(char c) {
// 中文字符的Unicode范围
return (c >= 0x4E00 && c <= 0x9FA5)
|| (c >= 0x3400 && c <= 0x4DBF) // 扩展A
|| (c >= 0x20000 && c <= 0x2A6DF); // 扩展B
}
/** /**
* 使用正则表达式判断字符串是否为数字 * 使用正则表达式判断字符串是否为数字
* 支持:整数(123)、小数(123.45)、正负号(-123、+45.6) * 支持:整数(123)、小数(123.45)、正负号(-123、+45.6)

View File

@ -67,14 +67,14 @@ public class LisWorkController extends BaseController {
*/ */
@ApiOperation("获取样本列表") @ApiOperation("获取样本列表")
@GetMapping("/samplelist") @GetMapping("/samplelist")
// public Result getSampleList(Date jyrq,String yq,Long days){ public Result getSampleList(Date jyrq,String yq,Long days){
// return lisWorkService.getSampleList(jyrq,yq,days); return lisWorkService.getSampleList(jyrq,yq,days);
// }
public TableDataInfo getsamplelist(Date jyrq, String yq, Long days) {
startPage();
List<LabPat> labPatList = lisWorkService.getSampleList(jyrq, yq, days);
return getDataTable(labPatList);
} }
// public TableDataInfo getsamplelist(Date jyrq, String yq, Long days) {
// startPage();
// List<LabPat> labPatList = lisWorkService.getSampleList(jyrq, yq, days);
// return getDataTable(labPatList);
// }
/** /**
* 获取普通样本信息 * 获取普通样本信息

View File

@ -13,7 +13,7 @@ public interface LisWorkService {
Result getInstrdList(Long userId); Result getInstrdList(Long userId);
Result getGroupInstrdList(Long userId,String groupId); Result getGroupInstrdList(Long userId,String groupId);
Result getInstrdConfig(String yq); Result getInstrdConfig(String yq);
List<LabPat> getSampleList(Date jyrq, String yq, Long days); Result getSampleList(Date jyrq, String yq, Long days);
Result getLabPat(Date jyrq, String yq, String ybh); Result getLabPat(Date jyrq, String yq, String ybh);
Result sampleMedInfo(Date jyrq, String yq, String ybh); Result sampleMedInfo(Date jyrq, String yq, String ybh);
Result checkUser(String yhdh, String mm); Result checkUser(String yhdh, String mm);

View File

@ -64,13 +64,13 @@ public class LisWorkServiceImpl implements LisWorkService {
} }
@Override @Override
public List<LabPat> getSampleList(Date jyrq, String yq, Long days) { public Result getSampleList(Date jyrq, String yq, Long days) {
if(days>1) { if(days>1) {
List<LabPat> labPatListday = commonUtil.getSampleListday(yq, days); List<LabPat> labPatListday = commonUtil.getSampleListday(yq, days);
return labPatListday; return new Result("0", "获取样本数据成功!", labPatListday);
}else { }else {
List<LabPat> labPatListday = commonUtil.getsamplelist(jyrq, yq); List<LabPat> labPatListday = commonUtil.getsamplelist(jyrq, yq);
return labPatListday; return new Result("0", "获取样本数据成功!", labPatListday);
} }
} }
@Override @Override