|
|
@@ -180,6 +180,9 @@ public class MesProductRecordController extends BaseController {
|
|
|
@Autowired
|
|
|
private MesProductProgressService mesProductProgressService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private MesProcessConsumeStockService mesProcessConsumeStockService;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 获取数据
|
|
|
@@ -299,29 +302,113 @@ public class MesProductRecordController extends BaseController {
|
|
|
return renderResult(Global.TRUE, text("操作成功!"));
|
|
|
}
|
|
|
/**
|
|
|
- * 查询列表数据
|
|
|
+ * 查询列表数据(按工件码聚合分页)
|
|
|
*/
|
|
|
@RequiresPermissions("mes:mesProductRecord:view")
|
|
|
@RequestMapping(value = "listData")
|
|
|
@ResponseBody
|
|
|
- public Page<MesProductRecord> listData(MesProductRecord mesProductRecord, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ public Page<MesProductRecord> listData(MesProductRecord mesProductRecord,
|
|
|
+ HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ applyProcessStateFilter(mesProductRecord);
|
|
|
+ Page<MesProductRecord> page = new Page<>(request, response);
|
|
|
+ mesProductRecord.setPage(page);
|
|
|
+ // 按 sn 聚合,不按明细主键排序
|
|
|
+ mesProductRecord.getSqlMap().getOrder().setOrderBy("");
|
|
|
+ page = mesProductRecordService.findSnGroupPage(mesProductRecord);
|
|
|
+ if (!ListUtils.isEmpty(page.getList())) {
|
|
|
+ for (MesProductRecord row : page.getList()) {
|
|
|
+ if (row.getSerial() != null) {
|
|
|
+ row.setRemark("明细 " + row.getSerial() + " 条");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return page;
|
|
|
+ }
|
|
|
|
|
|
- String sn = mesProductRecord.getSn();
|
|
|
+ /**
|
|
|
+ * 工件明细弹层页面(工位 → 工艺)
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductRecord:view")
|
|
|
+ @RequestMapping(value = "detailList")
|
|
|
+ public String detailList(String sn, Model model) {
|
|
|
+ if (StringUtils.isBlank(sn)) {
|
|
|
+ sn = "";
|
|
|
+ }
|
|
|
+ model.addAttribute("sn", sn);
|
|
|
+ return "modules/mes/mesProductRecordDetailList";
|
|
|
+ }
|
|
|
|
|
|
- Page page1 = new Page<>(request, response);
|
|
|
- mesProductRecord.setPage(page1);
|
|
|
- mesProductRecord.getSqlMap().getOrder().setOrderBy("a.id DESC");
|
|
|
- // 如果查询状态的值为 1, 表示用户选择查询 已加工
|
|
|
- if("1".equals(mesProductRecord.getProcessState()) && "".equals(mesProductRecord.getContent()))
|
|
|
- mesProductRecord.getSqlMap().getWhere().and("content",QueryType.NE, "UDF");
|
|
|
- // 如果查询状态的值为 0, 表示用户选择查询 未加工
|
|
|
- else if ("0".equals(mesProductRecord.getProcessState()) && "".equals(mesProductRecord.getContent()))
|
|
|
- mesProductRecord.getSqlMap().getWhere().and("content",QueryType.EQ, "UDF");
|
|
|
- Page<MesProductRecord> page = mesProductRecordService.findPage(mesProductRecord);
|
|
|
- fillProductRecordListFields(page.getList());
|
|
|
+ /**
|
|
|
+ * 明细弹层:指定工件下的工位列表
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductRecord:view")
|
|
|
+ @RequestMapping(value = "listOprnoData")
|
|
|
+ @ResponseBody
|
|
|
+ public Page<MesProductRecord> listOprnoData(String sn, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ Page<MesProductRecord> page = new Page<>(request, response);
|
|
|
+ List<MesProductRecord> list = mesProductRecordService.findOprnoGroupList(sn);
|
|
|
+ if (!ListUtils.isEmpty(list)) {
|
|
|
+ // 生产明细不展示 OP050 工位
|
|
|
+ list.removeIf(row -> "OP050".equals(CommonUitl.formatOprno(row.getOprno())));
|
|
|
+ Map<String, String> oprnoTitleMap = new HashMap<>();
|
|
|
+ for (MesProductRecord row : list) {
|
|
|
+ if (StringUtils.isBlank(row.getLineSn()) || StringUtils.isBlank(row.getOprno())) {
|
|
|
+ row.setOprnoTitle("");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String oprno = CommonUitl.formatOprno(row.getOprno());
|
|
|
+ String key = row.getLineSn() + "|" + oprno;
|
|
|
+ if (!oprnoTitleMap.containsKey(key)) {
|
|
|
+ MesLineProcess mesLineProcess = new MesLineProcess();
|
|
|
+ mesLineProcess.setLineSn(row.getLineSn());
|
|
|
+ mesLineProcess.setOprno(oprno);
|
|
|
+ MesLineProcess info = mesLineProcessService.findInfo(mesLineProcess);
|
|
|
+ oprnoTitleMap.put(key, ObjectUtils.isEmpty(info) ? "" : info.getTitle());
|
|
|
+ }
|
|
|
+ row.setOprnoTitle(oprnoTitleMap.get(key));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ page.setList(list);
|
|
|
+ page.setCount(list == null ? 0 : list.size());
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 明细弹层:指定工件+工位的工艺明细
|
|
|
+ */
|
|
|
+ @RequiresPermissions("mes:mesProductRecord:view")
|
|
|
+ @RequestMapping(value = "listDetailData")
|
|
|
+ @ResponseBody
|
|
|
+ public Page<MesProductRecord> listDetailData(String sn, String oprno,
|
|
|
+ HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ Page<MesProductRecord> page = new Page<>(request, response);
|
|
|
+ if (StringUtils.isBlank(sn)) {
|
|
|
+ page.setList(ListUtils.newArrayList());
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+ MesProductRecord query = new MesProductRecord();
|
|
|
+ query.setSn(sn);
|
|
|
+ if (StringUtils.isNotBlank(oprno)) {
|
|
|
+ query.getSqlMap().getWhere().and("oprno", QueryType.EQ, oprno);
|
|
|
+ }
|
|
|
+ query.getSqlMap().getOrder().setOrderBy("a.oprno ASC, a.serial ASC, a.id ASC");
|
|
|
+ List<MesProductRecord> list = mesProductRecordService.findList(query);
|
|
|
+ fillProductRecordListFields(list);
|
|
|
+ page.setList(list);
|
|
|
+ page.setCount(list == null ? 0 : list.size());
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
+ private void applyProcessStateFilter(MesProductRecord mesProductRecord) {
|
|
|
+ if ("1".equals(mesProductRecord.getProcessState())
|
|
|
+ && (mesProductRecord.getContent() == null || "".equals(mesProductRecord.getContent()))) {
|
|
|
+ mesProductRecord.getSqlMap().getWhere().and("content", QueryType.NE, "UDF");
|
|
|
+ } else if ("0".equals(mesProductRecord.getProcessState())
|
|
|
+ && (mesProductRecord.getContent() == null || "".equals(mesProductRecord.getContent()))) {
|
|
|
+ mesProductRecord.getSqlMap().getWhere().and("content", QueryType.EQ, "UDF");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void fillProductRecordListFields(List<MesProductRecord> list) {
|
|
|
if (ListUtils.isEmpty(list)) {
|
|
|
return;
|
|
|
@@ -1408,6 +1495,7 @@ public class MesProductRecordController extends BaseController {
|
|
|
mesProductRecord.setContent(retokng);
|
|
|
mesProductRecord.setCreateBy(user);
|
|
|
mesProductRecord.setCateSn(cateSn);
|
|
|
+ mesProductRecord.setUpdateBy(user);
|
|
|
|
|
|
// 质量上传,解析参数
|
|
|
List<ParamsResp> params = new ArrayList<ParamsResp>();
|
|
|
@@ -1417,6 +1505,13 @@ public class MesProductRecordController extends BaseController {
|
|
|
paramsResp2.setResult("OK");
|
|
|
params.add(paramsResp2);
|
|
|
|
|
|
+ // 400001 绑定人员:结果为 OK,人员信息写入绑定内容(materiel_sn)
|
|
|
+ ParamsResp paramsResp3 = new ParamsResp();
|
|
|
+ paramsResp3.setCraft("400001");
|
|
|
+ paramsResp3.setResult("OK");
|
|
|
+ paramsResp3.setVal(user);
|
|
|
+ params.add(paramsResp3);
|
|
|
+
|
|
|
try{
|
|
|
|
|
|
// 2.判断物料批次是否符合绑定
|
|
|
@@ -1747,9 +1842,9 @@ public class MesProductRecordController extends BaseController {
|
|
|
}
|
|
|
|
|
|
String passoprnos = "";
|
|
|
- if(lineSn.equals("XT")){
|
|
|
- passoprnos = Global.getConfig("mes.pass.oprno.xt");
|
|
|
- }
|
|
|
+
|
|
|
+ passoprnos = Global.getConfig("mes.pass.oprno.xt");
|
|
|
+
|
|
|
|
|
|
// 万能码逻辑
|
|
|
String universalSn = Global.getConfig("mes.universal.sn");
|
|
|
@@ -3733,6 +3828,8 @@ public class MesProductRecordController extends BaseController {
|
|
|
.and("craft", QueryType.EQ,"100000")
|
|
|
.and("sn", QueryType.EQ,sn);
|
|
|
List<MesProductRecord> lists = mesProductRecordService.findList(mesProductRecord);
|
|
|
+ // 填充工位名称(oprnoTitle)
|
|
|
+ fillProductRecordListFields(lists);
|
|
|
map.put("lists", lists);
|
|
|
resp.setData(map);
|
|
|
resp.setResult(Global.TRUE);
|
|
|
@@ -4217,6 +4314,15 @@ public class MesProductRecordController extends BaseController {
|
|
|
String ret = checkQualityCommon(oldOprno,sn,lineSn,userCode);
|
|
|
String checkret = ret.substring(3,5);
|
|
|
if(checkret.equals("UD")){
|
|
|
+ // 质量通过后:按父工位加工消耗绑定校验库存
|
|
|
+ MesProcessConsumeStockService.StockCheckResult stockCheck =
|
|
|
+ mesProcessConsumeStockService.checkStockEnough(oldOprno, lineSn);
|
|
|
+ if (!stockCheck.isOk()) {
|
|
|
+ resp.setMessage(StringUtils.defaultIfBlank(stockCheck.getMessage(), ErrorMsg.getErrorMsg("KC", "")));
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setData("KC");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
resp.setMessage("工件可以加工");
|
|
|
resp.setResult(Global.TRUE);
|
|
|
}else{
|
|
|
@@ -4288,12 +4394,20 @@ public class MesProductRecordController extends BaseController {
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
return renderResult(Global.FALSE, text("操作失败!"));
|
|
|
}else{
|
|
|
+ // craft=100000 且质量 OK 成功后,按父工位绑定 FIFO 扣库存
|
|
|
+ if ("OK".equals(result)) {
|
|
|
+ mesProcessConsumeStockService.consumeOnOk(sn, oprno, lineSn, userCode);
|
|
|
+ }
|
|
|
return renderResult(Global.TRUE, text("操作成功!"));
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
logger.info(e.getMessage());
|
|
|
+ String msg = e.getMessage();
|
|
|
+ if (StringUtils.isNotBlank(msg) && msg.contains("库存不足")) {
|
|
|
+ return renderResult(Global.FALSE, text(msg));
|
|
|
+ }
|
|
|
return renderResult(Global.FALSE, text("操作失败!"));
|
|
|
}
|
|
|
}
|
|
|
@@ -4307,8 +4421,13 @@ public class MesProductRecordController extends BaseController {
|
|
|
String sn = request.getParameter("sn");
|
|
|
String oprno = request.getParameter("oprno");
|
|
|
String lineSn = request.getParameter("lineSn");
|
|
|
- String userCode = request.getParameter("ucode");
|
|
|
+ // 兼容 ucode / userCode / user,避免客户端参数名不一致导致写成 system
|
|
|
+ String userCode = firstNotBlank(
|
|
|
+ request.getParameter("ucode"),
|
|
|
+ request.getParameter("userCode"),
|
|
|
+ request.getParameter("user"));
|
|
|
String result = request.getParameter("result");
|
|
|
+ logger.info("pccreate sn={}, oprno={}, lineSn={}, ucode={}, result={}", sn, oprno, lineSn, userCode, result);
|
|
|
String oldOprno = oprno;
|
|
|
if(oldOprno.length()==5){
|
|
|
oldOprno += "A";
|
|
|
@@ -4611,5 +4730,17 @@ public class MesProductRecordController extends BaseController {
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
+ /** 取第一个非空字符串(去首尾空格) */
|
|
|
+ private String firstNotBlank(String... values) {
|
|
|
+ if (values == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ for (String value : values) {
|
|
|
+ if (StringUtils.isNotBlank(value)) {
|
|
|
+ return value.trim();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
}
|