|
|
@@ -1,5 +1,9 @@
|
|
|
package com.jeesite.modules.mes.web;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import com.jeesite.common.lang.StringUtils;
|
|
|
@@ -10,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import com.jeesite.common.config.Global;
|
|
|
@@ -101,4 +106,111 @@ public class MesLaserController extends BaseController {
|
|
|
|
|
|
return resp;
|
|
|
}
|
|
|
+
|
|
|
+ // ==== 新流程:PDA 提交 + OP40 客户端轮询打印 ====
|
|
|
+
|
|
|
+ /**
|
|
|
+ * PDA 端提交钢印码:服务端生成客户码,绑定并入待打印队列。
|
|
|
+ * 请求参数(form):steelSn / prodCode
|
|
|
+ * 返回 data.customerSn(21位客户码)
|
|
|
+ * 说明:lineSn 和 user 由服务端固定填入(lineSn=T9,user=pda),PDA 端不用传。
|
|
|
+ */
|
|
|
+ @PostMapping(value = "submitSteelSn")
|
|
|
+ @ResponseBody
|
|
|
+ public CommonResp<Map<String, String>> submitSteelSn(HttpServletRequest request) {
|
|
|
+ CommonResp<Map<String, String>> resp = new CommonResp<>();
|
|
|
+ String steelSn = request.getParameter("steelSn");
|
|
|
+ String prodCode = request.getParameter("prodCode");
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(steelSn)) {
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("steelSn 不能为空");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(prodCode)) {
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("prodCode 不能为空");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ String customerSn = mesLaserService.submitSteelSn(prodCode, steelSn);
|
|
|
+ Map<String, String> data = new HashMap<>();
|
|
|
+ data.put("customerSn", customerSn);
|
|
|
+ resp.setData(data);
|
|
|
+ resp.setResult(Global.TRUE);
|
|
|
+ resp.setMessage("提交成功");
|
|
|
+ } catch (ServiceException e) {
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage(e.getMessage());
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("PDA 提交钢印码失败:steelSn=" + steelSn, e);
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("提交失败:" + e.getMessage());
|
|
|
+ }
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * OP40 客户端拉取待打印列表(FIFO,按创建时间升序)。
|
|
|
+ * @param lineSn 产线编号,例 T9
|
|
|
+ * @param limit 单次条数上限,默认 10
|
|
|
+ * @return data 列表元素含 customerSn / steelSn / prodCode / oprno / createDate
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "pendingPrint")
|
|
|
+ @ResponseBody
|
|
|
+ public CommonResp<List<Map<String, Object>>> pendingPrint(
|
|
|
+ @RequestParam("lineSn") String lineSn,
|
|
|
+ @RequestParam(value = "limit", required = false, defaultValue = "10") int limit) {
|
|
|
+ CommonResp<List<Map<String, Object>>> resp = new CommonResp<>();
|
|
|
+ if (StringUtils.isEmpty(lineSn)) {
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("lineSn 不能为空");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ List<Map<String, Object>> list = mesLaserService.listPending(lineSn, limit);
|
|
|
+ resp.setData(list);
|
|
|
+ resp.setResult(Global.TRUE);
|
|
|
+ resp.setMessage("OK");
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("拉取待打印列表失败:lineSn=" + lineSn, e);
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("拉取失败:" + e.getMessage());
|
|
|
+ }
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * OP40 客户端上报打印结果。
|
|
|
+ * 请求参数(form):customerSn / result=OK|NG / msg(失败原因,可选)
|
|
|
+ */
|
|
|
+ @PostMapping(value = "printAck")
|
|
|
+ @ResponseBody
|
|
|
+ public CommonResp printAck(HttpServletRequest request) {
|
|
|
+ CommonResp<String> resp = new CommonResp<>();
|
|
|
+ String customerSn = request.getParameter("customerSn");
|
|
|
+ String result = request.getParameter("result");
|
|
|
+ String msg = request.getParameter("msg");
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(customerSn)) {
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("customerSn 不能为空");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+ if (!"OK".equalsIgnoreCase(result) && !"NG".equalsIgnoreCase(result)) {
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("result 只能是 OK/NG");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ int rows = mesLaserService.ackPrint(customerSn, result, msg);
|
|
|
+ resp.setResult(Global.TRUE);
|
|
|
+ resp.setMessage("ack 已接收,影响行数 " + rows);
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("打印结果 ack 失败:customerSn=" + customerSn, e);
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("ack 失败:" + e.getMessage());
|
|
|
+ }
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
}
|