Просмотр исходного кода

新增接口"PDA校验客户码钢印码"

17491 6 дней назад
Родитель
Сommit
3846c840b8

+ 16 - 0
src/main/java/com/jeesite/modules/mes/service/MesLaserService.java

@@ -2,6 +2,7 @@ package com.jeesite.modules.mes.service;
 
 
 import com.jeesite.common.service.ServiceException;
 import com.jeesite.common.service.ServiceException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.EmptyResultDataAccessException;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
@@ -81,6 +82,21 @@ public class MesLaserService {
 	}
 	}
 
 
 	/**
 	/**
+	 * 根据客户码查询已绑定的钢印码。
+	 * @param customerSn 客户码
+	 * @return 已绑定钢印码,未找到返回 null
+	 */
+	public String findSteelSnByCustomerSn(String customerSn) {
+		try {
+			return jdbcTemplate.queryForObject(
+					"SELECT steel_sn FROM mes_product_laser WHERE customer_sn = ? ORDER BY update_date DESC LIMIT 1",
+					String.class, customerSn);
+		} catch (EmptyResultDataAccessException e) {
+			return null;
+		}
+	}
+
+	/**
 	 * 只生成客户编码,不做绑定(预留,正常流程走 genAndBindCustomerSn)
 	 * 只生成客户编码,不做绑定(预留,正常流程走 genAndBindCustomerSn)
 	 */
 	 */
 	@Transactional
 	@Transactional

+ 67 - 0
src/main/java/com/jeesite/modules/mes/web/MesPdaProductController.java

@@ -0,0 +1,67 @@
+package com.jeesite.modules.mes.web;
+
+import com.jeesite.common.config.Global;
+import com.jeesite.common.lang.StringUtils;
+import com.jeesite.common.web.BaseController;
+import com.jeesite.modules.mes.resp.CommonResp;
+import com.jeesite.modules.mes.service.MesLaserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * PDA产品接口
+ * @author hzd
+ * @version 2026-07-08
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/mes/pda/product")
+public class MesPdaProductController extends BaseController {
+
+	@Autowired
+	private MesLaserService mesLaserService;
+
+	/**
+	 * 根据客户码查询钢印码,并在提交钢印码时校验是否一致。
+	 * 请求参数:sn=客户码,steelSn=用户提交的钢印码(可选)
+	 */
+	@GetMapping(value = "steelSn")
+	@ResponseBody
+	public CommonResp<Map<String, String>> steelSn(@RequestParam("sn") String sn,
+			@RequestParam(value = "steelSn", required = false) String submitSteelSn) {
+		CommonResp<Map<String, String>> resp = new CommonResp<>();
+		Map<String, String> data = new HashMap<>();
+		data.put("sn", sn);
+		resp.setData(data);
+
+		if (StringUtils.isBlank(sn)) {
+			resp.setResult(Global.FALSE);
+			resp.setMessage("客户码不能为空");
+			return resp;
+		}
+
+		String steelSn = mesLaserService.findSteelSnByCustomerSn(sn);
+		data.put("steelSn", steelSn);
+		if (StringUtils.isBlank(steelSn)) {
+			resp.setResult(Global.FALSE);
+			resp.setMessage("未查询到客户码对应的钢印码");
+			return resp;
+		}
+
+		if (StringUtils.isNotBlank(submitSteelSn) && !steelSn.equals(submitSteelSn)) {
+			resp.setResult(Global.FALSE);
+			resp.setMessage("钢印码不一致");
+			return resp;
+		}
+
+		resp.setResult(Global.TRUE);
+		resp.setMessage("OK");
+		return resp;
+	}
+}

+ 1 - 0
src/main/resources/config/application.yml

@@ -617,6 +617,7 @@ shiro:
   filterChainDefinitions: |
   filterChainDefinitions: |
     ${adminPath}/mes/mesApp/ver = anon
     ${adminPath}/mes/mesApp/ver = anon
     ${adminPath}/mes/mesLogin/login = anon
     ${adminPath}/mes/mesLogin/login = anon
+    ${adminPath}/mes/pda/product/steelSn = anon
     ${adminPath}/mes/mesProductQm/add = anon
     ${adminPath}/mes/mesProductQm/add = anon
     ${adminPath}/mes/mesProductQm/testDate = anon
     ${adminPath}/mes/mesProductQm/testDate = anon
     ${adminPath}/mes/mesProductRecord/ghtime = anon
     ${adminPath}/mes/mesProductRecord/ghtime = anon