|
|
@@ -7,6 +7,7 @@ import java.text.SimpleDateFormat;
|
|
|
import java.time.*;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
@@ -5010,31 +5011,31 @@ public class MesProductRecordController extends BaseController {
|
|
|
public CommonResp queryProduct(HttpServletRequest request) {
|
|
|
CommonResp<String> resp = new CommonResp<>();
|
|
|
String sn = request.getParameter("sn");
|
|
|
- String lineSn = request.getParameter("lineSn");
|
|
|
- if(StringUtils.isEmpty(lineSn)){
|
|
|
- lineSn = "XT"; // Compatibility with clients that only submit sn.
|
|
|
- }
|
|
|
- if(StringUtils.isEmpty(sn)){
|
|
|
+ if (StringUtils.isBlank(sn)) {
|
|
|
resp.setResult(Global.FALSE);
|
|
|
resp.setMessage("参数错误");
|
|
|
return resp;
|
|
|
}
|
|
|
- String cate = mesLineService.findInfoCate(lineSn);
|
|
|
- if(StringUtils.isEmpty(cate)){
|
|
|
- resp.setResult(Global.FALSE);
|
|
|
- resp.setMessage("产线不存在或未绑定产品");
|
|
|
- return resp;
|
|
|
- }
|
|
|
- if("XT".equals(lineSn) && sn.length() == 28){
|
|
|
- sn = mesProductHmbService.formatHmbSn(sn,"OP115",lineSn);
|
|
|
- }
|
|
|
|
|
|
- MesProductRecord mesProductRecord = mesProductRecordService.findBySnCate(sn,cate);
|
|
|
- if(ObjectUtils.isEmpty(mesProductRecord)){
|
|
|
- resp.setData("0");
|
|
|
- }else{
|
|
|
- resp.setData("1");
|
|
|
+ String lineSn = CommonUitl.resolvePdaQueryLine(request.getParameter("lineSn"));
|
|
|
+ MesProductRecord record;
|
|
|
+ if ("CZ060".equals(lineSn)) {
|
|
|
+ sn = mesProductHmbService.formatHmbSn(sn.trim());
|
|
|
+ MesProductRecord query = new MesProductRecord();
|
|
|
+ query.getSqlMap().getWhere()
|
|
|
+ .and("a.sn", QueryType.EQ, sn)
|
|
|
+ .and("a.line_sn", QueryType.EQ, lineSn);
|
|
|
+ record = mesProductRecordService.findInfo(query);
|
|
|
+ } else {
|
|
|
+ String cate = mesLineService.findInfoCate(lineSn);
|
|
|
+ if (StringUtils.isEmpty(cate)) {
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("产线不存在或未绑定产品");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
+ record = mesProductRecordService.findBySnCate(sn, cate);
|
|
|
}
|
|
|
+ resp.setData(ObjectUtils.isEmpty(record) ? "0" : "1");
|
|
|
resp.setResult(Global.TRUE);
|
|
|
return resp;
|
|
|
}
|
|
|
@@ -5486,27 +5487,30 @@ public class MesProductRecordController extends BaseController {
|
|
|
public CommonResp checkProduct(HttpServletRequest request) {
|
|
|
CommonResp<Map<String, Object>> resp = new CommonResp<>();
|
|
|
String sn = request.getParameter("sn");
|
|
|
- if(StringUtils.isEmpty(sn)){
|
|
|
+ if (StringUtils.isBlank(sn)) {
|
|
|
resp.setResult(Global.FALSE);
|
|
|
resp.setMessage("参数错误");
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
- String cate = "ZHXT";
|
|
|
- if(sn.length() == 28){
|
|
|
- sn = mesProductHmbService.formatHmbSn(sn,"OP130","XT");
|
|
|
+ String lineSn = CommonUitl.resolvePdaQueryLine(request.getParameter("lineSn"));
|
|
|
+ MesProductRecord query = new MesProductRecord();
|
|
|
+ query.getSqlMap().getWhere().and("a.craft", QueryType.EQ, "100000");
|
|
|
+ if ("CZ060".equals(lineSn)) {
|
|
|
+ sn = mesProductHmbService.formatHmbSn(sn.trim());
|
|
|
+ query.getSqlMap().getWhere().and("a.line_sn", QueryType.EQ, lineSn);
|
|
|
+ } else {
|
|
|
+ if (sn.length() == 28) {
|
|
|
+ sn = mesProductHmbService.formatHmbSn(sn, "OP130", "XT");
|
|
|
+ }
|
|
|
+ query.getSqlMap().getWhere().and("a.cate_sn", QueryType.EQ, "ZHXT");
|
|
|
}
|
|
|
+ query.getSqlMap().getWhere().and("a.sn", QueryType.EQ, sn);
|
|
|
|
|
|
- Map<String, Object> map = MapUtils.newHashMap();
|
|
|
- map.put("sn",sn);
|
|
|
- MesProductRecord mesProductRecord = new MesProductRecord();
|
|
|
- mesProductRecord.getSqlMap().getWhere()
|
|
|
- .and("craft", QueryType.EQ,"100000")
|
|
|
- .and("cate_sn", QueryType.EQ,cate)
|
|
|
- .and("sn", QueryType.EQ,sn);
|
|
|
- List<MesProductRecord> lists = mesProductRecordService.findList(mesProductRecord);
|
|
|
- map.put("lists", lists);
|
|
|
- resp.setData(map);
|
|
|
+ Map<String, Object> data = MapUtils.newHashMap();
|
|
|
+ data.put("sn", sn);
|
|
|
+ data.put("lists", mesProductRecordService.findList(query));
|
|
|
+ resp.setData(data);
|
|
|
resp.setResult(Global.TRUE);
|
|
|
return resp;
|
|
|
}
|
|
|
@@ -5514,95 +5518,100 @@ public class MesProductRecordController extends BaseController {
|
|
|
// 修改工位
|
|
|
@PostMapping(value = "editProduct")
|
|
|
@ResponseBody
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public CommonResp editProduct(HttpServletRequest request) {
|
|
|
CommonResp<String> resp = new CommonResp<>();
|
|
|
String sn = request.getParameter("sn");
|
|
|
String oprno = request.getParameter("oprno");
|
|
|
String content = request.getParameter("content");
|
|
|
- if(StringUtils.isEmpty(sn) || StringUtils.isEmpty(oprno) || StringUtils.isEmpty(content)){
|
|
|
+ if (StringUtils.isBlank(sn) || StringUtils.isBlank(oprno) || StringUtils.isBlank(content)) {
|
|
|
resp.setResult(Global.FALSE);
|
|
|
resp.setMessage("参数错误");
|
|
|
return resp;
|
|
|
}
|
|
|
- if(!content.equals("UDF") && !content.equals("OK") && !content.equals("NG")){
|
|
|
+ if (!"UDF".equals(content) && !"OK".equals(content) && !"NG".equals(content)) {
|
|
|
resp.setResult(Global.FALSE);
|
|
|
resp.setMessage("结果值错误");
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
- sn = mesProductHmbService.formatHmbSn(sn,oprno,"XT");
|
|
|
-
|
|
|
- MesProductRecord mesProductRecord2 = mesProductRecordService.findBySn(sn);
|
|
|
- if(ObjectUtils.isEmpty(mesProductRecord2)){
|
|
|
+ String lineSn = CommonUitl.resolvePdaQueryLine(request.getParameter("lineSn"));
|
|
|
+ sn = mesProductHmbService.formatHmbSn(sn.trim());
|
|
|
+ oprno = oprno.trim();
|
|
|
+ String parentOprno = CommonUitl.formatOprno(oprno);
|
|
|
+ MesLineProcess parent = mesLineProcessService.findActiveStation(lineSn, parentOprno);
|
|
|
+ if (parent == null || StringUtils.isNotBlank(parent.getPid())) {
|
|
|
resp.setResult(Global.FALSE);
|
|
|
- resp.setMessage("工件信息不存在");
|
|
|
+ resp.setMessage("当前产线没有可用的主工位");
|
|
|
return resp;
|
|
|
}
|
|
|
-
|
|
|
- MesProductRecord mesProductRecord = new MesProductRecord();
|
|
|
- mesProductRecord.setCraft("100000");
|
|
|
- mesProductRecord.setOprno(CommonUitl.formatOprno(oprno));
|
|
|
- mesProductRecord.setSn(sn);
|
|
|
- MesProductRecord mesProductRecord1 = mesProductRecordService.findInfo(mesProductRecord);
|
|
|
- if(content.equals("UDF")){
|
|
|
- mesProductRecord1.setOprno(CommonUitl.formatOprno(oprno));
|
|
|
- }else{
|
|
|
- mesProductRecord1.setOprno(oprno);
|
|
|
+ if (!parentOprno.equals(oprno)) {
|
|
|
+ MesLineProcess selected = mesLineProcessService.findActiveStation(lineSn, oprno);
|
|
|
+ if (selected == null || !parent.getId().equals(selected.getPid())) {
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage("所选子工位不属于当前产线或主工位");
|
|
|
+ return resp;
|
|
|
+ }
|
|
|
}
|
|
|
- String contentOld = mesProductRecord1.getContent();
|
|
|
- mesProductRecord1.setContent(content);
|
|
|
- mesProductRecord1.setSource("2");
|
|
|
- mesProductRecordService.save(mesProductRecord1);
|
|
|
|
|
|
- //添加到产品修改记录100000
|
|
|
- MesProductModifyRecord mesProductModifyRecord = new MesProductModifyRecord();
|
|
|
- mesProductModifyRecord.setSn(sn);
|
|
|
- if(content.equals("UDF")){
|
|
|
- mesProductModifyRecord.setOprno(CommonUitl.formatOprno(oprno));
|
|
|
- }else{
|
|
|
- mesProductModifyRecord.setOprno(oprno);
|
|
|
+ MesProductRecord query = new MesProductRecord();
|
|
|
+ query.setSn(sn);
|
|
|
+ query.setCraft("100000");
|
|
|
+ query.setOprno(parentOprno);
|
|
|
+ query.getSqlMap().getWhere().and("a.line_sn", QueryType.EQ, lineSn);
|
|
|
+ List<MesProductRecord> stationRecords = mesProductRecordService.findList(query).stream()
|
|
|
+ .filter(record -> parentOprno.equals(CommonUitl.formatOprno(record.getOprno())))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ MesProductRecord record = stationRecords.stream()
|
|
|
+ .filter(item -> parentOprno.equals(item.getOprno()))
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ if (record == null) {
|
|
|
+ record = stationRecords.size() == 1 ? stationRecords.get(0) : null;
|
|
|
+ }
|
|
|
+ if (record == null) {
|
|
|
+ resp.setResult(Global.FALSE);
|
|
|
+ resp.setMessage(stationRecords.isEmpty() ? "当前产线没有该工件的工位结果记录" : "找到多条工位结果记录,无法确定要修改的记录");
|
|
|
+ return resp;
|
|
|
}
|
|
|
- mesProductModifyRecord.setCraft("100000");
|
|
|
- mesProductModifyRecord.setContentOld(contentOld);
|
|
|
- mesProductModifyRecord.setContent(content);
|
|
|
- mesProductModifyRecord.setSource("2");
|
|
|
- mesProductModifyRecordService.save(mesProductModifyRecord);
|
|
|
|
|
|
- String state = "0";
|
|
|
- List<String> ngList = new ArrayList<>();
|
|
|
- if(CommonUitl.isOfflineOprno(oprno, mesProductRecord2.getLineSn())){
|
|
|
- MesProductRecord mesProductRecord3 = new MesProductRecord();
|
|
|
- mesProductRecord3.setSn(sn);
|
|
|
- mesProductRecord3.setCraft("100000");
|
|
|
- List<MesProductRecord> lists = mesProductRecordService.findList(mesProductRecord3);
|
|
|
- for(MesProductRecord mesProductRecord4:lists){
|
|
|
- if(mesProductRecord4.getContent().equals("NG")){
|
|
|
- ngList.add(mesProductRecord4.getOprno());
|
|
|
- }
|
|
|
- }
|
|
|
- if(!ngList.isEmpty()){
|
|
|
- state= "4";
|
|
|
- }else {
|
|
|
- state= "1";
|
|
|
- }
|
|
|
- if(content.equals("UDF")){
|
|
|
- MesProduct mesProduct = new MesProduct();
|
|
|
- mesProduct.setSn(sn);
|
|
|
- MesProduct mp = mesProductService.findInfo(mesProduct);
|
|
|
- if(!ObjectUtils.isEmpty(mp)){
|
|
|
- mp.setState("0");
|
|
|
- mesProductService.update(mp);
|
|
|
- }
|
|
|
+ String savedOprno = "UDF".equals(content) ? parentOprno : oprno;
|
|
|
+ String oldContent = record.getContent();
|
|
|
+ record.setOprno(savedOprno);
|
|
|
+ record.setContent(content);
|
|
|
+ record.setSource("2");
|
|
|
+ mesProductRecordService.save(record);
|
|
|
+
|
|
|
+ MesProductModifyRecord change = new MesProductModifyRecord();
|
|
|
+ change.setSn(sn);
|
|
|
+ change.setLineSn(lineSn);
|
|
|
+ change.setOprno(savedOprno);
|
|
|
+ change.setCraft("100000");
|
|
|
+ change.setContentOld(oldContent);
|
|
|
+ change.setContent(content);
|
|
|
+ change.setSource("2");
|
|
|
+ mesProductModifyRecordService.save(change);
|
|
|
+
|
|
|
+ // 工件主表没有产线字段,同码跨产线时仅保存当前产线的工位结果。
|
|
|
+ MesProductRecord otherLine = new MesProductRecord();
|
|
|
+ otherLine.setSn(sn);
|
|
|
+ otherLine.getSqlMap().getWhere().and("a.line_sn", QueryType.NE, lineSn);
|
|
|
+ if (mesProductRecordService.findCount(otherLine) == 0) {
|
|
|
+ String state = "0";
|
|
|
+ if (CommonUitl.isOfflineOprno(oprno, lineSn)) {
|
|
|
+ MesProductRecord failures = new MesProductRecord();
|
|
|
+ failures.setSn(sn);
|
|
|
+ failures.setCraft("100000");
|
|
|
+ failures.setContent("NG");
|
|
|
+ failures.getSqlMap().getWhere().and("a.line_sn", QueryType.EQ, lineSn);
|
|
|
+ state = mesProductRecordService.findCount(failures) > 0 ? "4" : "1";
|
|
|
+ }
|
|
|
+ MesProduct productQuery = new MesProduct();
|
|
|
+ productQuery.setSn(sn);
|
|
|
+ MesProduct product = mesProductService.findInfo(productQuery);
|
|
|
+ if (product != null) {
|
|
|
+ product.setState(state);
|
|
|
+ mesProductService.save(product);
|
|
|
}
|
|
|
- }else {
|
|
|
- state= "0";
|
|
|
- }
|
|
|
- MesProduct mesProduct = new MesProduct();
|
|
|
- mesProduct.setSn(sn);
|
|
|
- MesProduct mm = mesProductService.findInfo(mesProduct);
|
|
|
- if(!ObjectUtils.isEmpty(mm)){
|
|
|
- mm.setState(state);
|
|
|
- mesProductService.save(mm);
|
|
|
}
|
|
|
resp.setResult(Global.TRUE);
|
|
|
resp.setMessage("操作成功");
|
|
|
@@ -5610,7 +5619,6 @@ public class MesProductRecordController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 查询列表NG预警
|
|
|
*/
|