代码备份

panjc_field_management
yewj 8 months ago
parent 93cf1636f3
commit ace1830bbb

@ -404,12 +404,14 @@ public class IoCodeTempController extends BaseController {
codeList = codeList.stream().distinct().collect(Collectors.toList());
List<VailCodeResultResponse> vailCodeResultResponses = new ArrayList<>();
List<String> prefixes = Arrays.asList("01", "11", "17", "10", "21");
//判断是否多段扫码
String mutiCode = filterAndConcatenate(codeList, prefixes);
UdiEntity temp = FilterUdiUtils.getUdi(mutiCode);
if (temp != null) {
codeList.clear();
codeList.add(mutiCode);
if (hasMoreThanTwoPrefixes(codeList, prefixes.toArray(new String[0]))) {
//判断是否多段扫码
String mutiCode = filterAndConcatenate(codeList, prefixes);
UdiEntity temp = FilterUdiUtils.getUdi(mutiCode);
if (temp != null) {
codeList.clear();
codeList.add(mutiCode);
}
}
for (String code : codeList) {
VailCodeResultResponse vailCodeResultResponse = new VailCodeResultResponse();
@ -433,6 +435,20 @@ public class IoCodeTempController extends BaseController {
return ResultVOUtils.success(vailCodeResultResponses);
}
public static boolean hasMoreThanTwoPrefixes(List<String> codes, String[] prefixes) {
int uniquePrefixCount = 0;
boolean[] prefixFound = new boolean[prefixes.length];
for (String code : codes) {
for (int i = 0; i < prefixes.length; i++) {
if (code.startsWith(prefixes[i]) && !prefixFound[i]) {
prefixFound[i] = true;
uniquePrefixCount++;
break;
}
}
}
return uniquePrefixCount > 1;
}
public static String filterAndConcatenate(List<String> codeList, List<String> prefixes) {
Set<String> matchedPrefixes = new HashSet<>();

@ -55,7 +55,7 @@ public class IoSplitFifoInvController extends BaseController {
Long workPlaceCode = ioSplitFifoInvRequest.getWorkPlaceCode();
SysWorkplace workplace = sysWorkplaceService.getWorkplace(workPlaceCode);
Integer workPlaceClass = workplace.getWorkPlaceClass();
if (workPlaceClass == 1){
if (workPlaceClass == 1) {
SysWorkplacePutRel putWorkPlace = sysWorkplacePutRelService.findPutWorkPlace(workPlaceCode, null);
ioSplitFifoInvRequest.setWorkPlaceCode(putWorkPlace.getWorkPlaceCode());
}

@ -0,0 +1,97 @@
package com.glxp.api.util;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.glxp.api.entity.basic.UdiEntity;
import com.glxp.api.res.inout.VailCodeResultResponse;
import com.glxp.api.util.udi.FilterUdiUtils;
import java.util.*;
import java.util.stream.Collectors;
public class VailBatchCodeUtils {
public static List<VailCodeResultResponse> batchVailCode(String codes) {
List<String> codeList = List.of(codes.split(";"));
if (CollUtil.isEmpty(codeList)) return null;
codeList = codeList.stream().distinct().collect(Collectors.toList());
List<VailCodeResultResponse> vailCodeResultResponses = new ArrayList<>();
List<String> prefixes = Arrays.asList("01", "11", "17", "10", "21");
if (hasMoreThanTwoPrefixes(codeList, prefixes.toArray(new String[0]))) {
//判断是否多段扫码
String mutiCode = filterAndConcatenate(codeList, prefixes);
UdiEntity temp = FilterUdiUtils.getUdi(mutiCode);
if (temp != null) {
codeList.clear();
codeList.add(mutiCode);
}
}
for (String code : codeList) {
VailCodeResultResponse vailCodeResultResponse = new VailCodeResultResponse();
UdiEntity udiEntity = FilterUdiUtils.getUdi(code);
vailCodeResultResponse.setCode(code);
if (udiEntity != null) {
vailCodeResultResponse.setStatus(1);
vailCodeResultResponse.setErrMsg("解析正确");
} else {
vailCodeResultResponse.setStatus(2);
vailCodeResultResponse.setErrMsg("追溯码格式错误");
}
vailCodeResultResponses.add(vailCodeResultResponse);
}
return vailCodeResultResponses;
}
public static boolean hasMoreThanTwoPrefixes(List<String> codes, String[] prefixes) {
int uniquePrefixCount = 0;
boolean[] prefixFound = new boolean[prefixes.length];
for (String code : codes) {
for (int i = 0; i < prefixes.length; i++) {
if (code.startsWith(prefixes[i]) && !prefixFound[i]) {
prefixFound[i] = true;
uniquePrefixCount++;
break;
}
}
}
return uniquePrefixCount > 1;
}
public static void main(String[] args) {
String code = "MA.156.M0.100442.0WET6505.S1394.M230624.L230601.DS22306241.E250624.V250623.C5";
// String code = "0116922943800657112406011724063010JY999\u001D210003;0118822943800657112406011724063010JY999\u001D210003";
// String code = "0116922943800657;1124060117240630;10JY999\u001D210003;www.baidu.com;32329382;0118822943800657112406011724063010JY999\u001D210003";
List<VailCodeResultResponse> vailCodeResultResponses = batchVailCode(code);
for (VailCodeResultResponse vailCodeResultResponse : vailCodeResultResponses) {
System.out.println(vailCodeResultResponse.getCode() + ":" + vailCodeResultResponse.getStatus() + ":" + vailCodeResultResponse.getErrMsg());
}
}
public static String filterAndConcatenate(List<String> codeList, List<String> prefixes) {
Set<String> matchedPrefixes = new HashSet<>();
StringBuilder concatenatedResult = new StringBuilder();
for (String prefix : prefixes) {
for (String code : codeList) {
if (code.length() >= 2 && code.startsWith(prefix)) {
if (!matchedPrefixes.contains(prefix)) {
matchedPrefixes.add(prefix);
concatenatedResult.append(code);
break;
}
}
}
UdiEntity udiEntity = FilterUdiUtils.getUdi(concatenatedResult.toString());
if (udiEntity != null && StrUtil.isNotEmpty(udiEntity.getBatchNo())) {
if (concatenatedResult.toString().endsWith("10" + udiEntity.getBatchNo())) {
concatenatedResult.append("\u001D");
}
}
}
return concatenatedResult.toString();
}
}

@ -4,9 +4,9 @@ server:
spring:
datasource:
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
jdbc-url: jdbc:p6spy:mysql://192.168.0.206:3306/udiwms81?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
jdbc-url: jdbc:p6spy:mysql://127.0.0.1:3306/udi_wms?allowMultiQueries=true&serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: Glxp@6066
password: 123456
hikari:
connection-timeout: 60000
maximum-pool-size: 20

Loading…
Cancel
Save