|
|
@@ -1049,74 +1049,130 @@ public class MesProductStorageRecordController extends BaseController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 保存入库数据(安卓端 anon 访问,跟610对齐)
|
|
|
+ * 保存入库数据(安卓端 form 表单方式,跟610对齐)
|
|
|
*/
|
|
|
// @RequiresPermissions("mes:mesProductStorageRecord:edit")
|
|
|
@RequestMapping(value = "saveStorage")
|
|
|
@ResponseBody
|
|
|
- public CommonResp<String> saveStorage(@RequestBody Map<String, Object> requestData) {
|
|
|
+ public CommonResp<String> saveStorage(HttpServletRequest request) {
|
|
|
CommonResp<String> resp = new CommonResp<>();
|
|
|
try {
|
|
|
- String customer = (String) requestData.get("customer");
|
|
|
- String productModel = (String) requestData.get("productModel");
|
|
|
- String orderNo = (String) requestData.get("orderNo");
|
|
|
- String batchSn = (String) requestData.get("batchSn");
|
|
|
- String batchSn2 = (String) requestData.get("batchSn2");
|
|
|
- String relationSn2 = (String) requestData.get("relationSn2");
|
|
|
- List<Map<String, Object>> products = (List<Map<String, Object>>) requestData.get("products");
|
|
|
-
|
|
|
- if (!StringUtils.hasText(customer)) {
|
|
|
+ String productModel = request.getParameter("productModel");
|
|
|
+ String batchSn = request.getParameter("batchSn");
|
|
|
+ String remark = request.getParameter("remark");
|
|
|
+ String productsStr = request.getParameter("products");
|
|
|
+
|
|
|
+ if (!StringUtils.hasText(productModel)) {
|
|
|
resp.setResult(Global.FALSE);
|
|
|
- resp.setMessage("所属客户不能为空");
|
|
|
+ resp.setMessage("产品型号不能为空");
|
|
|
return resp;
|
|
|
}
|
|
|
-
|
|
|
- if (!StringUtils.hasText(productModel)) {
|
|
|
+
|
|
|
+ if (!StringUtils.hasText(batchSn)) {
|
|
|
resp.setResult(Global.FALSE);
|
|
|
- resp.setMessage("产品型号不能为空");
|
|
|
+ resp.setMessage("托盘码不能为空");
|
|
|
return resp;
|
|
|
}
|
|
|
-
|
|
|
- if (ListUtils.isEmpty(products)) {
|
|
|
+
|
|
|
+ if (!StringUtils.hasText(productsStr)) {
|
|
|
resp.setResult(Global.FALSE);
|
|
|
- resp.setMessage("产品信息不能为空");
|
|
|
+ resp.setMessage("工件列表不能为空");
|
|
|
return resp;
|
|
|
}
|
|
|
-
|
|
|
- // 准备批量保存的记录列表
|
|
|
+
|
|
|
+ // 解析工件码列表(逗号分隔)
|
|
|
+ List<String> productQrList = ListUtils.newArrayList();
|
|
|
+ String[] arr = productsStr.split(",");
|
|
|
+ for (String s : arr) {
|
|
|
+ if (StringUtils.hasText(s.trim())) {
|
|
|
+ productQrList.add(s.trim());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (productQrList.isEmpty()) {
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("工件列表不能为空");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验托盘最大包装量
|
|
|
+ MesProductModel queryModel = new MesProductModel();
|
|
|
+ queryModel.setModel(productModel);
|
|
|
+ queryModel.setStatus("0");
|
|
|
+ List<MesProductModel> modelList = mesProductModelService.findList(queryModel);
|
|
|
+ if (!ListUtils.isEmpty(modelList)) {
|
|
|
+ Integer maxNums = modelList.get(0).getNums();
|
|
|
+ if (maxNums != null) {
|
|
|
+ // 查询该托盘已有工件数量
|
|
|
+ MesProductStorageRecord trayQuery = new MesProductStorageRecord();
|
|
|
+ trayQuery.setBatchSn(batchSn);
|
|
|
+ trayQuery.setBind("1");
|
|
|
+ List<MesProductStorageRecord> existInTray = mesProductStorageRecordService.findList(trayQuery);
|
|
|
+ if (existInTray.size() + productQrList.size() > maxNums) {
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("超出托盘最大包装量(最多" + maxNums + "个)");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
List<MesProductStorageRecord> recordsToSave = ListUtils.newArrayList();
|
|
|
-
|
|
|
- for (Map<String, Object> product : products) {
|
|
|
- String productQr = (String) product.get("productQr");
|
|
|
- String waterCool = (String) product.get("waterCool");
|
|
|
- String airTight = (String) product.get("airTight");
|
|
|
- String coldPlateQr = (String) product.get("coldPlateQr");
|
|
|
-
|
|
|
+
|
|
|
+ for (String productQr : productQrList) {
|
|
|
if (!StringUtils.hasText(productQr)) {
|
|
|
- continue; // 跳过空的产品二维码
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验重复入库
|
|
|
+ MesProductStorageRecord checkRecord = new MesProductStorageRecord();
|
|
|
+ checkRecord.setSn(productQr);
|
|
|
+ checkRecord.setBind("1");
|
|
|
+ List<MesProductStorageRecord> existList = mesProductStorageRecordService.findList(checkRecord);
|
|
|
+ if (!ListUtils.isEmpty(existList)) {
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("工件【" + productQr + "】已入库,勿重复操作");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验新版返修记录(mes_product_repair)
|
|
|
+ MesProductRepair mesProductRepair = new MesProductRepair();
|
|
|
+ mesProductRepair.setSn(productQr);
|
|
|
+ mesProductRepair.getSqlMap().getOrder().setOrderBy("a.id DESC");
|
|
|
+ MesProductRepair mesProductRepair2 = mesProductRepairService.findInfo(mesProductRepair);
|
|
|
+ if (!ObjectUtils.isEmpty(mesProductRepair2)) {
|
|
|
+ if ("0".equals(mesProductRepair2.getState()) || "1".equals(mesProductRepair2.getState())) {
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("工件【" + productQr + "】存在未完成的返修记录");
|
|
|
+ return resp;
|
|
|
+ } else if ("2".equals(mesProductRepair2.getState()) && !"1".equals(mesProductRepair2.getResult())) {
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("工件【" + productQr + "】返修结果为NG,不能入库");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- // 创建新的入库记录
|
|
|
+
|
|
|
+ // 创建入库记录
|
|
|
MesProductStorageRecord record = new MesProductStorageRecord();
|
|
|
record.setSn(productQr);
|
|
|
- record.setCustomer(customer);
|
|
|
record.setProductModel(productModel);
|
|
|
- record.setOrderNo(orderNo);
|
|
|
record.setBatchSn(batchSn);
|
|
|
- record.setBatchSn2(batchSn2);
|
|
|
- record.setRelationSn2(relationSn2);
|
|
|
- record.setColdPlateQr(coldPlateQr);
|
|
|
- record.setSlleak(waterCool);
|
|
|
- record.setCpleak(airTight);
|
|
|
+ record.setRemark(remark);
|
|
|
record.setBind("1");
|
|
|
record.setIsNewRecord(true);
|
|
|
-
|
|
|
+
|
|
|
recordsToSave.add(record);
|
|
|
}
|
|
|
-
|
|
|
- // 批量保存(事务性操作)
|
|
|
+
|
|
|
+ // 批量保存
|
|
|
mesProductStorageRecordService.batchSave(recordsToSave);
|
|
|
-
|
|
|
+
|
|
|
+ // 保存图片(如果有)
|
|
|
+ if (StringUtils.hasText(request.getParameter("mesProductPackage_image"))) {
|
|
|
+ if (!recordsToSave.isEmpty()) {
|
|
|
+ FileUploadUtils.saveFileUpload(recordsToSave.get(0), recordsToSave.get(0).getId(), "mesProductPackage_image");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
resp.setResult(Global.TRUE);
|
|
|
resp.setMessage("入库成功");
|
|
|
} catch (Exception e) {
|