wangxichen 4 дней назад
Родитель
Сommit
a4f44ea9d6

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

@@ -11,6 +11,7 @@ import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
@@ -82,6 +83,31 @@ public class MesLaserService {
 	}
 
 	/**
+	 * 解绑钢印码和客户码映射。客户码建档数据保留,只删除 mes_product_laser 对应关系。
+	 * @param steelSn 钢印码
+	 * @param oprno 工位号
+	 * @param lineSn 产线编号
+	 * @return 被解绑的客户码
+	 */
+	@Transactional
+	public String unbindSteelSn(String steelSn, String oprno, String lineSn) {
+		List<Map<String, Object>> binds = jdbcTemplate.queryForList(
+				"SELECT customer_sn FROM mes_product_laser WHERE steel_sn = ? ORDER BY update_date DESC LIMIT 1",
+				steelSn);
+		if (binds.isEmpty()) {
+			throw new ServiceException("该钢印码未绑定客户码,无需解绑");
+		}
+
+		String customerSn = String.valueOf(binds.get(0).get("customer_sn"));
+		int rows = jdbcTemplate.update(
+				"DELETE FROM mes_product_laser WHERE steel_sn = ? AND customer_sn = ?",
+				steelSn, customerSn);
+		if (rows < 1) {
+			throw new ServiceException("解绑失败,请刷新后重试");
+		}
+		return customerSn;
+	}
+	/**
 	 * 根据客户码查询已绑定的钢印码。
 	 * @param customerSn 客户码
 	 * @return 已绑定钢印码,未找到返回 null

+ 35 - 0
src/main/java/com/jeesite/modules/mes/web/MesLaserController.java

@@ -66,4 +66,39 @@ public class MesLaserController extends BaseController {
 		return resp;
 	}
 
+	/**
+	 * 解绑钢印码和客户码映射。客户码建档数据保留。
+	 * 请求参数(form):steelSn(钢印码) oprno lineSn
+	 * 返回 data:被解绑的客户码
+	 */
+	@PostMapping(value = "unbindSteelSn")
+	@ResponseBody
+	public CommonResp unbindSteelSn(HttpServletRequest request) {
+		CommonResp<String> resp = new CommonResp<>();
+		String steelSn = request.getParameter("steelSn");
+		String oprno = request.getParameter("oprno");
+		String lineSn = request.getParameter("lineSn");
+
+		if (StringUtils.isEmpty(steelSn)) {
+			resp.setResult(Global.FALSE);
+			resp.setMessage("参数错误:steelSn不能为空");
+			return resp;
+		}
+
+		try {
+			String customerSn = mesLaserService.unbindSteelSn(steelSn, oprno, lineSn);
+			resp.setData(customerSn);
+			resp.setResult(Global.TRUE);
+			resp.setMessage("解绑成功,客户码:" + customerSn);
+		} catch (ServiceException e) {
+			resp.setResult(Global.FALSE);
+			resp.setMessage(e.getMessage());
+		} catch (Exception e) {
+			logger.error("钢印码解绑失败:steelSn=" + steelSn, e);
+			resp.setResult(Global.FALSE);
+			resp.setMessage("解绑失败:" + e.getMessage());
+		}
+
+		return resp;
+	}
 }

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

@@ -640,6 +640,8 @@ shiro:
     ${adminPath}/mes/mesProductBs/batchsave = anon
     ${adminPath}/mes/mesLineProcessMaterial/materials = anon
     ${adminPath}/mes/mesMaterialPrebind/bind = anon
+    ${adminPath}/mes/mesLaser/genCustomerSn = anon
+    ${adminPath}/mes/mesLaser/unbindSteelSn = anon
     ${adminPath}/mes/mesProductPush/test = anon
     ${adminPath}/mes/mesProcessCheckRecord/check = anon
     ${adminPath}/mes/mesProductRecord/work = anon
@@ -887,7 +889,7 @@ file:
   enabled: true
 
 #  # 文件上传根路径,设置路径中不允许包含“userfiles”,在指定目录中系统会自动创建userfiles目录,如果不设置默认为contextPath路径
-  baseDir: E:/mescloud
+  baseDir: D:/mescloud
 #  baseDir: /www/wwwroot/mes_cloud_br4
 #
 #  # 上传文件的相对路径(支持:yyyy, MM, dd, HH, mm, ss, E)