Browse Source

包装入库,过站

wangxichen 4 ngày trước cách đây
mục cha
commit
c527402057

+ 33 - 0
src/main/java/com/jeesite/modules/mes/web/MesProductStorageRecordController.java

@@ -1173,6 +1173,39 @@ public class MesProductStorageRecordController extends BaseController {
 				}
 			}
 
+			// 包装完成后,写OP250过站记录(craft=100000/400001 各1条,content=OK,create_by=system)
+			for (MesProductStorageRecord rec : recordsToSave) {
+				String sn = rec.getSn();
+				// 查该sn当前最大serial
+				Integer maxSerial = jdbcTemplate.queryForObject(
+					"SELECT COALESCE(MAX(serial), 0) FROM mes_product_record WHERE sn = ?",
+					Integer.class, sn);
+				int nextSerial = (maxSerial == null ? 0 : maxSerial) + 1;
+				long cdate = System.currentTimeMillis() / 1000L;
+
+				String[] crafts = {"100000", "400001"};
+				for (int i = 0; i < crafts.length; i++) {
+					MesProductRecord pr = new MesProductRecord();
+					pr.setSn(sn);
+					pr.setOprno("OP250");
+					pr.setCraft(crafts[i]);
+					pr.setSerial(nextSerial + i);
+					pr.setCateSn("ZHXT");
+					pr.setContent("OK");
+					pr.setLineSn("XT");
+					pr.setSource("0");
+					pr.setPid("0");
+					pr.setCdate(cdate);
+					pr.setIsNewRecord(true);
+					mesProductRecordService.save(pr);
+
+					// create_by/update_by 强制固定为 system,与现有过站记录风格一致
+					jdbcTemplate.update(
+						"UPDATE mes_product_record SET create_by='system', update_by='system' WHERE id=?",
+						pr.getId());
+				}
+			}
+
 			resp.setResult(Global.TRUE);
 			resp.setMessage("入库成功");
 		} catch (Exception e) {