Browse Source

Merge remote-tracking branch 'origin/main'

liuwei 2 ngày trước cách đây
mục cha
commit
5f14f7857b

+ 8 - 7
db/mes_param_parse_config.sql

@@ -1,6 +1,6 @@
 -- 上传参数解析配置表(方案二:配置化替代代码硬编码)
 -- 数据库:MySQL(mes_cloud_xz)
-CREATE TABLE mes_param_parse_config (
+CREATE TABLE IF NOT EXISTS mes_param_parse_config (
 	id varchar(64) NOT NULL COMMENT '编码',
 	line_sn varchar(50) NOT NULL COMMENT '产线编号(*表示所有产线)',
 	oprno varchar(50) NOT NULL COMMENT '工位号(如OP035,不含尾缀字母)',
@@ -19,20 +19,20 @@ CREATE TABLE mes_param_parse_config (
 
 -- 种子数据:迁移原XT线硬编码规则
 -- OP010 底板码:ps第1、2段,结果固定OK
-INSERT INTO mes_param_parse_config (id, line_sn, oprno, craft, ps_pos, result_mode, title, status, create_by, create_date, update_by, update_date)
+INSERT IGNORE INTO mes_param_parse_config (id, line_sn, oprno, craft, ps_pos, result_mode, title, status, create_by, create_date, update_by, update_date)
 VALUES ('ppc_xt_op010_1', 'XT', 'OP010', '400005', 1, 1, '底板码1(固定OK)', '0', 'system', NOW(), 'system', NOW());
-INSERT INTO mes_param_parse_config (id, line_sn, oprno, craft, ps_pos, result_mode, title, status, create_by, create_date, update_by, update_date)
+INSERT IGNORE INTO mes_param_parse_config (id, line_sn, oprno, craft, ps_pos, result_mode, title, status, create_by, create_date, update_by, update_date)
 VALUES ('ppc_xt_op010_2', 'XT', 'OP010', '400005', 2, 1, '底板码2(固定OK)', '0', 'system', NOW(), 'system', NOW());
 -- OP060/OP100/OP130 程序名称:ps第1段,结果取报文Y/N
-INSERT INTO mes_param_parse_config (id, line_sn, oprno, craft, ps_pos, result_mode, title, status, create_by, create_date, update_by, update_date)
+INSERT IGNORE INTO mes_param_parse_config (id, line_sn, oprno, craft, ps_pos, result_mode, title, status, create_by, create_date, update_by, update_date)
 VALUES ('ppc_xt_op060_1', 'XT', 'OP060', '300001', 1, 0, '程序名称', '0', 'system', NOW(), 'system', NOW());
-INSERT INTO mes_param_parse_config (id, line_sn, oprno, craft, ps_pos, result_mode, title, status, create_by, create_date, update_by, update_date)
+INSERT IGNORE INTO mes_param_parse_config (id, line_sn, oprno, craft, ps_pos, result_mode, title, status, create_by, create_date, update_by, update_date)
 VALUES ('ppc_xt_op100_1', 'XT', 'OP100', '300001', 1, 0, '程序名称', '0', 'system', NOW(), 'system', NOW());
-INSERT INTO mes_param_parse_config (id, line_sn, oprno, craft, ps_pos, result_mode, title, status, create_by, create_date, update_by, update_date)
+INSERT IGNORE INTO mes_param_parse_config (id, line_sn, oprno, craft, ps_pos, result_mode, title, status, create_by, create_date, update_by, update_date)
 VALUES ('ppc_xt_op130_1', 'XT', 'OP130', '300001', 1, 0, '程序名称', '0', 'system', NOW(), 'system', NOW());
 
 -- 后台菜单:挂在"生产管理"(menu_code=1672118505143263232)下
-INSERT INTO js_sys_menu (menu_code, parent_code, parent_codes, tree_sort, tree_sorts, tree_leaf, tree_level, tree_names,
+INSERT IGNORE INTO js_sys_menu (menu_code, parent_code, parent_codes, tree_sort, tree_sorts, tree_leaf, tree_level, tree_names,
 	menu_name, menu_type, menu_href, menu_target, menu_icon, menu_color, menu_title, permission, weight, is_show,
 	sys_code, module_codes, status, create_by, create_date, update_by, update_date, remarks)
 VALUES ('2043000000000000001', '1672118505143263232', '0,1672118505143263232,', 2060, '0000009290,0000002060,', '1', 1, '生产管理/上传参数解析配置',
@@ -45,3 +45,4 @@ SELECT rm.role_code, '2043000000000000001'
 FROM js_sys_role_menu rm
 WHERE rm.menu_code = '1672118505143263232'
 	AND NOT EXISTS (SELECT 1 FROM js_sys_role_menu x WHERE x.role_code = rm.role_code AND x.menu_code = '2043000000000000001');
+

+ 17 - 14
src/main/java/com/jeesite/modules/mes/service/MesProductPreService.java

@@ -65,29 +65,27 @@ public class MesProductPreService extends CrudService<MesProductPreDao, MesProdu
 		return mesProductPreDao.findInfo(mesProductPre);
 	}
 
-	public String getNewSn(String lineSn,String cate){
-		return getNewSn(lineSn,cate,"");
-	}
-
-	// pn:CZ060 产品PN号(195/196/198),为空或不合法时默认195
+	// pn:CZ060 产品PN号(195/196/198),必填;不合法直接不生成
 	public String getNewSn(String lineSn,String cate,String pn){
 		//500104004355C230001  cate=1
 		//0050010400435E6348245C120001   cate=2
-		String pre = "CZ060195";
-		if("195".equals(pn) || "196".equals(pn) || "198".equals(pn)){
-			pre = "CZ060" + pn;
+		// 产品号必填,不合法直接不生成
+		if(!"195".equals(pn) && !"196".equals(pn) && !"198".equals(pn)){
+			return "";
 		}
-		String pre2 = "F956210325195AI2";
-		if(lineSn.equals("CZ061")){
+		String pre = "CZ060" + pn;
+		// 长码前缀:物料代码最后一位随产品号变化(195->5、196->6、198->8),AI2 为原有固定位
+		String pre2 = "F95621032519" + pn.substring(2) + "AI2";
+		if("CZ061".equals(lineSn)){
 
 		}
 
 		String todayStr = CommonUitl.getYearLastChar()+CommonUitl.getMonthChar()+CommonUitl.getDayChar();
 		String sn = "";
 		String newSn = "";
-		// 检查当前是否配置规则
+		// 检查当前是否配置规则;长码(cate=2)固定按产品拼装,不受规则配置影响
 		MesProductPreConfig mesProductPreConfig = mesProductPreConfigService.checkRuleCate(lineSn,cate);
-		if(!ObjectUtils.isEmpty(mesProductPreConfig)){
+		if(!ObjectUtils.isEmpty(mesProductPreConfig) && !cate.equals("2")){
 			Integer isAuto = 0;
 			List<RuleResp> rules = JSON.parseArray(mesProductPreConfig.getContent(), RuleResp.class);
 			if(!ListUtils.isEmpty(rules)){
@@ -193,6 +191,10 @@ public class MesProductPreService extends CrudService<MesProductPreDao, MesProdu
 				mesProductPre.setCate(cate);
 				mesProductPre.setLineSn(lineSn);
 				mesProductPre.getSqlMap().getWhere().and("a.sn", QueryType.RIGHT_LIKE,sn);
+				if(cate.equals("2")){
+					// 取最大流水,避免重复试探
+					mesProductPre.getSqlMap().getOrder().setOrderBy("a.sn desc");
+				}
 				MesProductPre mesProductPre1 = this.findInfo(mesProductPre);
 				if(!ObjectUtils.isEmpty(mesProductPre1)){
 					if(cate.equals("1")){
@@ -203,9 +205,10 @@ public class MesProductPreService extends CrudService<MesProductPreDao, MesProdu
 							number = no + 1 + i;
 						}
 					}else{
-						String snDate = mesProductPre1.getSn().substring(20,24);
+						// 24位码:前缀(16)+年月日(4)+流水号(4),流水号取第20位之后
+						String snDate = mesProductPre1.getSn().substring(16,20);
 						if(snDate.equals(todayStr)){
-							int no = Integer.valueOf(mesProductPre1.getSn().substring(24,28));
+							int no = Integer.valueOf(mesProductPre1.getSn().substring(20,24));
 							number = no + 1 + i;
 						}
 					}

+ 17 - 1
src/main/java/com/jeesite/modules/mes/web/MesProductHmbController.java

@@ -198,7 +198,22 @@ public class MesProductHmbController extends BaseController {
 			return resp;
 		}
 
-		String sn = mesProductPreService.getNewSn(lineSn,"2");
+		// 产品PN号:195/196/198,必填,决定长码物料段;兼容镭雕机文档里的 type 参数名
+		String pn = request.getParameter("pn");
+		if(StringUtils.isEmpty(pn)){
+			pn = request.getParameter("type");
+		}
+		if(StringUtils.isEmpty(pn)){
+			resp.setResult(Global.FALSE);
+			resp.setMessage("工件类型不能为空");
+			return resp;
+		}
+		if(!"195".equals(pn) && !"196".equals(pn) && !"198".equals(pn)){
+			resp.setResult(Global.FALSE);
+			resp.setMessage("工件类型错误");
+			return resp;
+		}
+		String sn = mesProductPreService.getNewSn(lineSn,"2",pn);
 		if(sn.isEmpty()){
 			resp.setResult(Global.FALSE);
 			resp.setMessage("没有符合要求的镭雕码可生成");
@@ -211,6 +226,7 @@ public class MesProductHmbController extends BaseController {
 		if(check.equals("1")){
 			mesProductHmb3.setState("0");
 		}
+		mesProductHmb3.setLineSn(lineSn);
 		mesProductHmb3.setCreateBy(userCode);
 		mesProductHmb3.setUpdateBy(userCode);
 		this.save(mesProductHmb3);

+ 9 - 0
src/main/java/com/jeesite/modules/mes/web/MesProductRecordController.java

@@ -2892,6 +2892,15 @@ public class MesProductRecordController extends BaseController {
 			resp.setMessage("参数错误");
 			return resp;
 		}
+		// 产品PN号必填:195/196/198
+		if(StringUtils.isEmpty(pn)){
+			resp.setMessage("工件类型不能为空");
+			return resp;
+		}
+		if(!"195".equals(pn) && !"196".equals(pn) && !"198".equals(pn)){
+			resp.setMessage("工件类型错误");
+			return resp;
+		}
 
 		//判断开班点检
 		if(!mesProcessCheckRecordService.checkRecord(oprno,lineSn)){

+ 1 - 1
src/main/resources/views/modules/mes/mesParamParseConfigList.html

@@ -8,7 +8,7 @@
 			<div class="box-tools pull-right">
 				<a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
 				<% if(hasPermi('mes:mesParamParseConfig:edit')){ %>
-					<a href="${ctx}/mes/mesParamParseConfig/form?isNewRecord" class="btn btn-default btnTool" title="${text('新增参数解析配置')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
+					<a href="${ctx}/mes/mesParamParseConfig/form" class="btn btn-default btnTool" title="${text('新增参数解析配置')}"><i class="fa fa-plus"></i> ${text('新增')}</a>
 				<% } %>
 				<a href="#" class="btn btn-default" id="btnSetting" title="${text('设置')}"><i class="fa fa-navicon"></i></a>
 			</div>