|
|
@@ -67,6 +67,9 @@ public class MesProductStorageRecordController extends BaseController {
|
|
|
private MesCustomerService mesCustomerService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private MesRepairService mesRepairService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private org.springframework.jdbc.core.JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
/**
|
|
|
@@ -586,7 +589,7 @@ public class MesProductStorageRecordController extends BaseController {
|
|
|
/**
|
|
|
* 根据托盘码获取已包装的工件列表
|
|
|
*/
|
|
|
- @RequiresPermissions("mes:mesProductStorageRecord:api")
|
|
|
+// @RequiresPermissions("mes:mesProductStorageRecord:api")
|
|
|
@RequestMapping("/getProductListByTrayCode")
|
|
|
@ResponseBody
|
|
|
public CommonResp<List<MesProductStorageRecord>> getProductListByTrayCode(HttpServletRequest request) {
|
|
|
@@ -873,9 +876,9 @@ public class MesProductStorageRecordController extends BaseController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取产品型号列表
|
|
|
+ * 获取产品型号列表(安卓端)
|
|
|
*/
|
|
|
- @RequiresPermissions("mes:mesProductStorageRecord:view")
|
|
|
+// @RequiresPermissions("mes:mesProductStorageRecord:view")
|
|
|
@RequestMapping(value = "getProductModelList")
|
|
|
@ResponseBody
|
|
|
public CommonResp<List<MesProductModel>> getProductModelList() {
|
|
|
@@ -897,9 +900,9 @@ public class MesProductStorageRecordController extends BaseController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 验证产品二维码
|
|
|
+ * 验证产品二维码(安卓端扫码校验)
|
|
|
*/
|
|
|
- @RequiresPermissions("mes:mesProductStorageRecord:edit")
|
|
|
+// @RequiresPermissions("mes:mesProductStorageRecord:edit")
|
|
|
@RequestMapping(value = "validateProductQr")
|
|
|
@ResponseBody
|
|
|
public CommonResp<String> validateProductQr(HttpServletRequest request) {
|
|
|
@@ -963,9 +966,42 @@ public class MesProductStorageRecordController extends BaseController {
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
- logger.info("产品二维码格式验证通过,开始检查维修记录:productQr={}", productQr);
|
|
|
-
|
|
|
- // 校验维修记录状态(如果存在维修记录的话)
|
|
|
+ logger.info("产品二维码格式验证通过,开始检查是否重复入库:productQr={}", productQr);
|
|
|
+
|
|
|
+ // 校验是否重复入库
|
|
|
+ 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("该工件已入库,勿重复操作");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ logger.info("开始检查维修记录:productQr={}", productQr);
|
|
|
+
|
|
|
+ // 校验旧版返修记录(mes_repair表)
|
|
|
+ MesRepair mesRepairQuery = new MesRepair();
|
|
|
+ mesRepairQuery.setSn(productQr);
|
|
|
+ mesRepairQuery.getSqlMap().getOrder().setOrderBy("a.update_date DESC");
|
|
|
+ MesRepair mesRepairInfo = mesRepairService.findInfo(mesRepairQuery);
|
|
|
+ if (!ObjectUtils.isEmpty(mesRepairInfo)) {
|
|
|
+ // state: 1=待返修, 2=待检查, 3=已检查
|
|
|
+ if (!"3".equals(mesRepairInfo.getState())) {
|
|
|
+ String stateDesc = "1".equals(mesRepairInfo.getState()) ? "待返修" : "待检查";
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("工件状态为:" + stateDesc + ",只有已检查的工件才能入库");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+ if (!"1".equals(mesRepairInfo.getResult())) {
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("工件维修结果为NG,只有维修结果为OK的工件才能入库");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 校验新版维修记录状态(mes_product_repair表)
|
|
|
// 使用原生SQL查询避免JOIN问题
|
|
|
List<MesProductRepair> repairList = jdbcTemplate.query(
|
|
|
"SELECT id, sn, product_model_id, reason, state, result, remark, create_by, create_date, update_by, update_date, repair_by, repair_date, repair_remark FROM mes_product_repair WHERE sn = ? ORDER BY update_date DESC LIMIT 1",
|
|
|
@@ -1049,90 +1085,149 @@ public class MesProductStorageRecordController extends BaseController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 保存入库数据
|
|
|
+ * 保存入库数据(安卓端)
|
|
|
*/
|
|
|
- @RequiresPermissions("mes:mesProductStorageRecord:edit")
|
|
|
+// @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_repair表)
|
|
|
+ MesRepair mesRepairQuery = new MesRepair();
|
|
|
+ mesRepairQuery.setSn(productQr);
|
|
|
+ mesRepairQuery.getSqlMap().getOrder().setOrderBy("a.update_date DESC");
|
|
|
+ MesRepair mesRepairInfo = mesRepairService.findInfo(mesRepairQuery);
|
|
|
+ if (!ObjectUtils.isEmpty(mesRepairInfo)) {
|
|
|
+ if (!"3".equals(mesRepairInfo.getState())) {
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("工件【" + productQr + "】存在未完成的返修记录");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+ if (!"1".equals(mesRepairInfo.getResult())) {
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("工件【" + productQr + "】返修结果为NG,不能入库");
|
|
|
+ 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(mesProductRepair2.getState().equals("0") || mesProductRepair2.getState().equals("1")) {
|
|
|
+ if (mesProductRepair2.getState().equals("0") || mesProductRepair2.getState().equals("1")) {
|
|
|
resp.setResult(Global.FALSE);
|
|
|
- resp.setMessage("工件【"+productQr+"】存在未完成的返修记录");
|
|
|
+ resp.setMessage("工件【" + productQr + "】存在未完成的返修记录");
|
|
|
return resp;
|
|
|
- } else if(mesProductRepair2.getState().equals("2") && !mesProductRepair2.getResult().equals("1")) {
|
|
|
+ } else if (mesProductRepair2.getState().equals("2") && !mesProductRepair2.getResult().equals("1")) {
|
|
|
resp.setResult(Global.FALSE);
|
|
|
- resp.setMessage("工件【"+productQr+"】存在返修NG的记录");
|
|
|
+ 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) {
|
|
|
@@ -1143,5 +1238,109 @@ public class MesProductStorageRecordController extends BaseController {
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 包装入库列表(安卓端,按托盘码分组)
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "appList")
|
|
|
+ @ResponseBody
|
|
|
+ public CommonResp<Map<String, Object>> appList(HttpServletRequest request) {
|
|
|
+ CommonResp<Map<String, Object>> resp = new CommonResp<>();
|
|
|
+ try {
|
|
|
+ String pageNo = request.getParameter("pageNo");
|
|
|
+ String pageSize = request.getParameter("pageSize");
|
|
|
+ int pNo = StringUtils.hasText(pageNo) ? Integer.parseInt(pageNo) : 1;
|
|
|
+ int pSize = StringUtils.hasText(pageSize) ? Integer.parseInt(pageSize) : 10;
|
|
|
+ int offset = (pNo - 1) * pSize;
|
|
|
+
|
|
|
+ // 按托盘码分组查询
|
|
|
+ List<Map<String, Object>> list = jdbcTemplate.queryForList(
|
|
|
+ "SELECT batch_sn AS batchSn, product_model AS productModel, COUNT(*) AS count, MAX(create_date) AS createDate " +
|
|
|
+ "FROM mes_product_storage_record WHERE bind = '1' AND batch_sn IS NOT NULL AND batch_sn != '' " +
|
|
|
+ "GROUP BY batch_sn, product_model ORDER BY MAX(create_date) DESC LIMIT ? OFFSET ?",
|
|
|
+ pSize, offset
|
|
|
+ );
|
|
|
+
|
|
|
+ // 查询总数
|
|
|
+ Integer total = jdbcTemplate.queryForObject(
|
|
|
+ "SELECT COUNT(DISTINCT batch_sn) FROM mes_product_storage_record WHERE bind = '1' AND batch_sn IS NOT NULL AND batch_sn != ''",
|
|
|
+ Integer.class
|
|
|
+ );
|
|
|
+
|
|
|
+ Map<String, Object> resultData = MapUtils.newHashMap();
|
|
|
+ resultData.put("list", list);
|
|
|
+ resultData.put("count", total != null ? total : 0);
|
|
|
+
|
|
|
+ resp.setData(resultData);
|
|
|
+ resp.setResult(Global.TRUE);
|
|
|
+ resp.setMessage("操作成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ logger.error("查询包装入库列表失败", e);
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("查询失败");
|
|
|
+ }
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 包装入库详情(安卓端,根据托盘码查看绑定的工件)
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "appDetail")
|
|
|
+ @ResponseBody
|
|
|
+ public CommonResp<Map<String, Object>> appDetail(HttpServletRequest request) {
|
|
|
+ CommonResp<Map<String, Object>> resp = new CommonResp<>();
|
|
|
+ String batchSn = request.getParameter("batchSn");
|
|
|
+ if (!StringUtils.hasText(batchSn)) {
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("托盘码为空");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
+ MesProductStorageRecord query = new MesProductStorageRecord();
|
|
|
+ query.setBatchSn(batchSn);
|
|
|
+ query.setBind("1");
|
|
|
+ query.getSqlMap().getOrder().setOrderBy("a.create_date ASC");
|
|
|
+ List<MesProductStorageRecord> list = mesProductStorageRecordService.findList(query);
|
|
|
+
|
|
|
+ Map<String, Object> data = MapUtils.newHashMap();
|
|
|
+ data.put("batchSn", batchSn);
|
|
|
+ data.put("productModel", ListUtils.isEmpty(list) ? "" : list.get(0).getProductModel());
|
|
|
+ data.put("count", list.size());
|
|
|
+ data.put("createBy", ListUtils.isEmpty(list) ? "" : list.get(0).getCreateBy());
|
|
|
+ data.put("createDate", ListUtils.isEmpty(list) ? "" : list.get(0).getCreateDate());
|
|
|
+ data.put("remark", ListUtils.isEmpty(list) ? "" : (list.get(0).getRemark() != null ? list.get(0).getRemark() : ""));
|
|
|
+
|
|
|
+ // 工件码列表(逗号分隔)
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
+ if (i > 0) sb.append(",");
|
|
|
+ sb.append(list.get(i).getSn());
|
|
|
+ }
|
|
|
+ data.put("products", sb.toString());
|
|
|
+
|
|
|
+ // 图片(取第一条记录关联的图片)
|
|
|
+ List imgList = ListUtils.newArrayList();
|
|
|
+ if (!ListUtils.isEmpty(list)) {
|
|
|
+ String host = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/js";
|
|
|
+ FileUpload fu = new FileUpload();
|
|
|
+ fu.setBizKey(list.get(0).getId());
|
|
|
+ fu.setBizType("mesProductPackage_image");
|
|
|
+ List<FileUpload> finfo = fileUploadService.findList(fu);
|
|
|
+ for (FileUpload fi : finfo) {
|
|
|
+ Map<String, Object> map1 = MapUtils.newHashMap();
|
|
|
+ map1.put("id", fi.getFileEntity().getFileId());
|
|
|
+ map1.put("url", host + fi.getFileUrl());
|
|
|
+ map1.put("name", fi.getFileName());
|
|
|
+ map1.put("size", fi.getFileEntity().getFileSize());
|
|
|
+ imgList.add(map1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ data.put("imgList", imgList);
|
|
|
+
|
|
|
+ resp.setData(data);
|
|
|
+ resp.setResult(Global.TRUE);
|
|
|
+ resp.setMessage("操作成功");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|