|
|
@@ -262,6 +262,91 @@ public class CommonUitl {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ /** 冷板校验失败码:国内工件绑了非国内冷板 */
|
|
|
+ public static final String COLD_PLATE_CODE_LN = "LN";
|
|
|
+ /** 冷板校验失败码:国外工件绑了非国外冷板 */
|
|
|
+ public static final String COLD_PLATE_CODE_LW = "LW";
|
|
|
+ /** 冷板校验失败码:冷板码不在配置前缀范围 */
|
|
|
+ public static final String COLD_PLATE_CODE_LP = "LP";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 液冷板国内/国外绑定校验。
|
|
|
+ * 后台参数 mes.bind.coldplate.check=1 时生效(系统管理-参数设置)。
|
|
|
+ * 仅当工件码命中国内/国外前缀时才校验,避免影响其他物料绑定。
|
|
|
+ * @return null 表示通过(或未开启/不在校验范围);非空为失败码 LN/LW/LP
|
|
|
+ */
|
|
|
+ public static String checkColdPlateBind(String sn, String wsn) {
|
|
|
+ String check = Global.getConfig("mes.bind.coldplate.check", "0");
|
|
|
+ if (!"1".equals(check)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(sn) || StringUtils.isEmpty(wsn)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ String snDomestic = Global.getConfig("mes.bind.coldplate.sn.domestic.prefix", "");
|
|
|
+ String snForeign = Global.getConfig("mes.bind.coldplate.sn.foreign.prefix", "");
|
|
|
+ String wsnDomestic = Global.getConfig("mes.bind.coldplate.wsn.domestic.prefix", "");
|
|
|
+ String wsnForeign = Global.getConfig("mes.bind.coldplate.wsn.foreign.prefix", "");
|
|
|
+
|
|
|
+ int snRegion = matchRegion(sn, snDomestic, snForeign);
|
|
|
+ // 工件码未命中配置前缀:不拦截(非本次冷板校验范围)
|
|
|
+ if (snRegion == 0) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ int wsnRegion = matchRegion(wsn, wsnDomestic, wsnForeign);
|
|
|
+ if (wsnRegion == 0) {
|
|
|
+ return COLD_PLATE_CODE_LP;
|
|
|
+ }
|
|
|
+ if (snRegion != wsnRegion) {
|
|
|
+ if (snRegion == 1) {
|
|
|
+ return COLD_PLATE_CODE_LN;
|
|
|
+ }
|
|
|
+ return COLD_PLATE_CODE_LW;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 冷板校验失败码转提示文案(HTTP 接口 / 日志用) */
|
|
|
+ public static String getColdPlateBindMsg(String code) {
|
|
|
+ if (COLD_PLATE_CODE_LN.equals(code)) {
|
|
|
+ return "国内工件只能绑定国内冷板!";
|
|
|
+ }
|
|
|
+ if (COLD_PLATE_CODE_LW.equals(code)) {
|
|
|
+ return "国外工件只能绑定国外冷板!";
|
|
|
+ }
|
|
|
+ if (COLD_PLATE_CODE_LP.equals(code)) {
|
|
|
+ return "冷板码不在配置的国内/国外前缀范围内!";
|
|
|
+ }
|
|
|
+ return "工件与冷板国内/国外版本不匹配!";
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 1=国内 2=国外 0=未匹配 */
|
|
|
+ private static int matchRegion(String code, String domesticPrefix, String foreignPrefix) {
|
|
|
+ boolean domestic = matchAnyPrefix(code, domesticPrefix);
|
|
|
+ boolean foreign = matchAnyPrefix(code, foreignPrefix);
|
|
|
+ if (domestic && !foreign) {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ if (foreign && !domestic) {
|
|
|
+ return 2;
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ private static boolean matchAnyPrefix(String code, String prefixes) {
|
|
|
+ if (StringUtils.isEmpty(code) || StringUtils.isEmpty(prefixes)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ String[] arr = prefixes.split(",");
|
|
|
+ for (String p : arr) {
|
|
|
+ if (StringUtils.isNotEmpty(p) && code.startsWith(p.trim())) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
// 检查底护板批次码是否正确
|
|
|
public static boolean checkBatchSn(String batchSn,String sn) {
|
|
|
if(batchSn.length() < 20 || sn.length() < 20){
|