|
|
@@ -55,6 +55,7 @@ import com.jeesite.modules.mes.req.MesProductQmReq;
|
|
|
import com.jeesite.modules.mes.req.MesSearchDateReq;
|
|
|
import com.jeesite.modules.mes.resp.BindMaterialResp;
|
|
|
import com.jeesite.modules.mes.resp.CommonResp;
|
|
|
+import com.jeesite.modules.mes.resp.MesShiftDataResp;
|
|
|
import com.jeesite.modules.mes.resp.ParamsResp;
|
|
|
import com.jeesite.modules.mes.service.*;
|
|
|
import com.jeesite.modules.mes.util.CommonUitl;
|
|
|
@@ -1380,20 +1381,150 @@ public class MesProductRecordController extends BaseController {
|
|
|
if(mesLineProcess1.getRepeat().equals("1") && (ret.equals(bs+"OK") || ret.equals(bs+"NG"))){ // 可重复工作
|
|
|
ret = "RSUD";
|
|
|
}
|
|
|
- //判断是否属于可做三次气密检测的工位 mes_qm_maxNumber次数 mes_qm_oprnos工位
|
|
|
- String qmOprnos = Global.getConfig("mes_qm_oprnos");
|
|
|
- if(!StringUtils.isEmpty(qmOprnos) && qmOprnos.contains(CommonUitl.formatOprno(oldOprno))){
|
|
|
- int qmMaxNumber =new Integer(Global.getConfig("mes_qm_maxNumber")) ;
|
|
|
- if(qmMaxNumber > 0){
|
|
|
- MesProductQm mesProductQm = new MesProductQm();
|
|
|
- mesProductQm.setComponentNum(sn);
|
|
|
- mesProductQm.setOprno(oldOprno);
|
|
|
-
|
|
|
- mesProductQm.setProductCate(lineSn);
|
|
|
- List<MesProductQm> list = mesProductQmService.findList(mesProductQm);//----
|
|
|
-//判断列表长度
|
|
|
- if(list.size() >= qmMaxNumber){
|
|
|
- ret = bs+lxres;
|
|
|
+// //判断是否属于可做三次气密检测的工位 mes_qm_maxNumber次数 mes_qm_oprnos工位
|
|
|
+// String qmOprnos = Global.getConfig("mes_qm_oprnos");
|
|
|
+// if(!StringUtils.isEmpty(qmOprnos) && qmOprnos.contains(CommonUitl.formatOprno(oldOprno))){
|
|
|
+// int qmMaxNumber =new Integer(Global.getConfig("mes_qm_maxNumber")) ;
|
|
|
+// if(qmMaxNumber > 0){
|
|
|
+// MesProductQm mesProductQm = new MesProductQm();
|
|
|
+// mesProductQm.setComponentNum(sn);
|
|
|
+// mesProductQm.setOprno(oldOprno);
|
|
|
+//
|
|
|
+// mesProductQm.setProductCate(lineSn);
|
|
|
+// List<MesProductQm> list = mesProductQmService.findList(mesProductQm);//----
|
|
|
+// //判断列表长度
|
|
|
+// if(list.size() >= qmMaxNumber){
|
|
|
+// ret = bs+lxres;
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
+ String oprno1 = CommonUitl.formatOprno(oprno);
|
|
|
+ MesShiftDataResp mesShiftDataResp = mesShiftService.getCurShift();
|
|
|
+
|
|
|
+ // 气密工位
|
|
|
+ String qmoprnos = Global.getConfig("mes.qm.oprnos");
|
|
|
+ if(!StringUtils.isEmpty(qmoprnos) && qmoprnos.contains(oprno1)){
|
|
|
+ String Fchech = Global.getConfig("mes.qm.check");
|
|
|
+ if (Fchech.equals("1")){
|
|
|
+ // 首件点检
|
|
|
+ String NpqmOprnos = Global.getConfig("mes.qm.nocheck");
|
|
|
+ if(!StringUtils.isEmpty(NpqmOprnos) && NpqmOprnos.contains(oprno)){
|
|
|
+
|
|
|
+ }else{
|
|
|
+
|
|
|
+ String oks = "";
|
|
|
+ String ngs = "";
|
|
|
+ if(oprno1.equals("OP350") && lineSn.equals("XT")){ // 半成品气密
|
|
|
+ oks = Global.getConfig("mes.xt.OP350.ok");
|
|
|
+ ngs = Global.getConfig("mes.xt.OP350.ng");
|
|
|
+ }else if(oprno1.equals("OP450") && lineSn.equals("XT")){ //总成
|
|
|
+ oks = Global.getConfig("mes.xt.OP450.ok");
|
|
|
+ ngs = Global.getConfig("mes.xt.OP450.ng");
|
|
|
+ }
|
|
|
+ logger.info("qmok:"+oks);
|
|
|
+ logger.info("qmng:"+ngs);
|
|
|
+ if(StringUtils.isEmpty(oks) && StringUtils.isEmpty(ngs)){
|
|
|
+
|
|
|
+ }
|
|
|
+ Boolean oksret = true;
|
|
|
+ Boolean ngsret = true;
|
|
|
+
|
|
|
+ DateFormat dateFormat2 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
+ Date stdate =null;
|
|
|
+ Date etdate =null;
|
|
|
+ try {
|
|
|
+ stdate = dateFormat2.parse(mesShiftDataResp.getStart());
|
|
|
+ etdate = dateFormat2.parse(mesShiftDataResp.getEnd());
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(!StringUtils.isEmpty(oks)){
|
|
|
+ String[] oksarr = oks.split(",",-1);
|
|
|
+ for(String ok : oksarr){
|
|
|
+ if(StringUtils.isEmpty(ok)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(sn.equals(ok)){
|
|
|
+ return "RSUD";
|
|
|
+ }
|
|
|
+ MesProductQm mesProductQm = new MesProductQm();
|
|
|
+ mesProductQm.setOprno(oprno);
|
|
|
+ mesProductQm.setComponentNum(ok);
|
|
|
+ mesProductQm.setProductCate(lineSn);
|
|
|
+ mesProductQm.setTestTime_gte(stdate);
|
|
|
+ mesProductQm.setTestTime_lte(etdate);
|
|
|
+ mesProductQm.setTestResult("OK");
|
|
|
+ mesProductQm.getSqlMap().getOrder().setOrderBy("a.test_date desc");
|
|
|
+ MesProductQm mesProductQm1 = mesProductQmService.findInfo(mesProductQm);
|
|
|
+ if(com.jeesite.common.lang.ObjectUtils.isEmpty(mesProductQm1)){
|
|
|
+ oksret = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ logger.info("qmok2:"+oks);
|
|
|
+ if(!StringUtils.isEmpty(ngs)){
|
|
|
+ String[] ngsarr = ngs.split(",",-1);
|
|
|
+ for(String ng : ngsarr){
|
|
|
+ if(StringUtils.isEmpty(ng)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if(sn.equals(ng)){
|
|
|
+ return "RSUD";
|
|
|
+ }
|
|
|
+ MesProductQm mesProductQm = new MesProductQm();
|
|
|
+ mesProductQm.setOprno(oprno);
|
|
|
+ mesProductQm.setComponentNum(ng);
|
|
|
+ mesProductQm.setProductCate(lineSn);
|
|
|
+ mesProductQm.setTestTime_gte(stdate);
|
|
|
+ mesProductQm.setTestTime_lte(etdate);
|
|
|
+ mesProductQm.getSqlMap().getWhere().and("a.oprno",QueryType.NE,"OK");
|
|
|
+ mesProductQm.getSqlMap().getOrder().setOrderBy("a.test_date desc");
|
|
|
+ MesProductQm mesProductQm1 = mesProductQmService.findInfo(mesProductQm);
|
|
|
+ if(com.jeesite.common.lang.ObjectUtils.isEmpty(mesProductQm1)){
|
|
|
+ ngsret = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!oksret || !ngsret){
|
|
|
+ return "RSDJ";
|
|
|
+ }else{
|
|
|
+ ret= "RSUD";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ String check = Global.getConfig("mes.qm.ng.time");
|
|
|
+ if(check.equals("1")){
|
|
|
+ // 检查是否超过15分钟
|
|
|
+ String checkret = Global.getConfig("mes.qm.nong.time");
|
|
|
+ if (!StringUtils.isEmpty(checkret) && qmoprnos.contains(checkret)){
|
|
|
+
|
|
|
+ }else {
|
|
|
+ MesProductQm mpr2 = new MesProductQm();
|
|
|
+ mpr2.setComponentNum(sn);
|
|
|
+ mpr2.getSqlMap().getWhere().and("a.oprno",QueryType.RIGHT_LIKE,oprno);
|
|
|
+ mpr2.getSqlMap().getOrder().setOrderBy("a.test_time desc");
|
|
|
+ MesProductQm mprinfo = mesProductQmService.findInfo(mpr2);
|
|
|
+ if(!ObjectUtils.isEmpty(mprinfo)){
|
|
|
+ // 计算两个日期之间相差的分钟数
|
|
|
+ Date curDate = new Date();
|
|
|
+ Date date2 = mprinfo.getTestTime();
|
|
|
+ long minutesBetween = Math.abs(ChronoUnit.MINUTES.between(curDate.toInstant(), date2.toInstant()));
|
|
|
+ logger.info("minutesBetween:"+ minutesBetween);
|
|
|
+ if(minutesBetween < 15){ // 未超过15分钟
|
|
|
+ return "RSQM";
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -1490,45 +1621,44 @@ public class MesProductRecordController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// MesProductOprno mesProductOprno = new MesProductOprno();
|
|
|
-// mesProductOprno.setSn(sn);
|
|
|
-// mesProductOprno.setOprno(oprnoOld);
|
|
|
-// mesProductOprno.setLineSn(lineSn);
|
|
|
-// MesProductOprno mesProductOprno1 = mesProductOprnoService.findInfo(mesProductOprno);
|
|
|
-// System.out.println(mesProductOprno1);
|
|
|
-// if(ObjectUtils.isEmpty(mesProductOprno1)){
|
|
|
-// //添加子工位表
|
|
|
-// mesProductOprnoService.save(mesProductOprno);
|
|
|
-// mesProductOprno1 = mesProductOprnoService.findInfo(mesProductOprno);
|
|
|
-// }
|
|
|
-// //添加子工位
|
|
|
-// if (!StringUtils.isEmpty(oprno) &&"OP220".equals(oprnoOld)){
|
|
|
-//
|
|
|
-// if("OP220A".equals(oprno) ){
|
|
|
-// mesProductOprno1.setResult1(content);
|
|
|
-// }else if("OP220B".equals(oprno)){
|
|
|
-// mesProductOprno1.setResult2(content);
|
|
|
-// }
|
|
|
-// mesProductOprnoService.save(mesProductOprno1);
|
|
|
-//
|
|
|
-// // 全有结果
|
|
|
-// if(mesProductOprno1.getResult1()!=null && !StringUtils.isEmpty(mesProductOprno1.getResult1()) && mesProductOprno1.getResult2()!=null && !StringUtils.isEmpty(mesProductOprno1.getResult2())){
|
|
|
-// String lastRet = "NG";
|
|
|
-// if(mesProductOprno1.getResult1().equals("OK") && mesProductOprno1.getResult2().equals("OK")){
|
|
|
-// lastRet = "OK";
|
|
|
-// }
|
|
|
-// // 2.判断物料批次是否符合绑定
|
|
|
-// List<BindMaterialResp> bmlists = mesLineProcessMaterialService.getBindMaterial(oprnoOld, lineSn);
|
|
|
-// // 总结果产线要求写死“OK”
|
|
|
-// mesProductRecordService.updateRecordResult(sn,oprnoOld,"100000","",lastRet,userCode,params,lineSn,true,bmlists);
|
|
|
-// }else {
|
|
|
-// ret = "RSOK";
|
|
|
-// return ret;
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
|
|
|
+ //310添加子工位
|
|
|
+ if (!StringUtils.isEmpty(oprno) &&"OP310".equals(oprnoOld)){
|
|
|
+ MesProductOprno mesProductOprno = new MesProductOprno();
|
|
|
+ mesProductOprno.setSn(sn);
|
|
|
+ mesProductOprno.setOprno(oprnoOld);
|
|
|
+ mesProductOprno.setLineSn(lineSn);
|
|
|
+ MesProductOprno mesProductOprno1 = mesProductOprnoService.findInfo(mesProductOprno);
|
|
|
+ System.out.println(mesProductOprno1);
|
|
|
+ if(ObjectUtils.isEmpty(mesProductOprno1)){
|
|
|
+ //添加子工位表
|
|
|
+ mesProductOprnoService.save(mesProductOprno);
|
|
|
+ mesProductOprno1 = mesProductOprnoService.findInfo(mesProductOprno);
|
|
|
+ }
|
|
|
+
|
|
|
+ if("OP310A".equals(oprno) ){
|
|
|
+ mesProductOprno1.setResult1(content);
|
|
|
+ }else if("OP310B".equals(oprno)){
|
|
|
+ mesProductOprno1.setResult2(content);
|
|
|
+ }
|
|
|
+ mesProductOprnoService.save(mesProductOprno1);
|
|
|
|
|
|
+ // 全有结果
|
|
|
+ if(mesProductOprno1.getResult1()!=null && !StringUtils.isEmpty(mesProductOprno1.getResult1()) && mesProductOprno1.getResult2()!=null && !StringUtils.isEmpty(mesProductOprno1.getResult2())){
|
|
|
+ String lastRet = "NG";
|
|
|
+ if(mesProductOprno1.getResult1().equals("OK") && mesProductOprno1.getResult2().equals("OK")){
|
|
|
+ lastRet = "OK";
|
|
|
+ }
|
|
|
+ // 2.判断物料批次是否符合绑定
|
|
|
+ List<BindMaterialResp> bmlists = mesLineProcessMaterialService.getBindMaterial(oprnoOld, lineSn);
|
|
|
+ // 总结果产线要求写死“OK”
|
|
|
+ mesProductRecordService.updateRecordResult(sn,oprnoOld,"100000","",lastRet,userCode,params,lineSn,true,bmlists);
|
|
|
+ }else {
|
|
|
+ ret = "RSOK";
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1642,6 +1772,91 @@ public class MesProductRecordController extends BaseController {
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
+ String fOprno = CommonUitl.formatOprno(oprno);
|
|
|
+ // 判断当前模板是否和当前模板清单一致
|
|
|
+ // 查询当前工位的相关模板
|
|
|
+ List<MesTemplateItems> mesTemplateItemsList = mesTemplateItemsService.findListByOprno(fOprno);
|
|
|
+ // 查询已经有的Record
|
|
|
+ List<MesProductRecord> mesProductRecordList = mesProductRecordService.findBySnAndOprnoLike(sn,fOprno);
|
|
|
+ //根据craft对比,找出没加入的模板项
|
|
|
+ if(!ListUtils.isEmpty(mesTemplateItemsList)){
|
|
|
+ // 提取已存在的工艺号集合
|
|
|
+ Set<String> existCrafts = new HashSet<>();
|
|
|
+ if(!ListUtils.isEmpty(mesProductRecordList)){
|
|
|
+ for(MesProductRecord record : mesProductRecordList){
|
|
|
+ existCrafts.add(record.getCraft());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 找出模板中存在但记录中不存在的工艺项
|
|
|
+ List<MesTemplateItems> missingItems = new ArrayList<>();
|
|
|
+ for(MesTemplateItems templateItem : mesTemplateItemsList){
|
|
|
+ if(!existCrafts.contains(templateItem.getCraft())){
|
|
|
+ missingItems.add(templateItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果有缺失的模板项,需要补充创建
|
|
|
+ if(!ListUtils.isEmpty(missingItems)){
|
|
|
+ logger.warn("产品SN:{}, 工位:{}, 缺失模板项数量:{}", sn, fOprno, missingItems.size());
|
|
|
+
|
|
|
+ // 获取产品信息
|
|
|
+// MesProduct mesProduct1 = new MesProduct();
|
|
|
+// mesProduct1.setSn(sn);
|
|
|
+ MesProduct mesProduct = mesProductService.findBySn(sn);
|
|
|
+ if(ObjectUtils.isEmpty(mesProduct)){
|
|
|
+ throw new ServiceException(text("产品不存在!"));
|
|
|
+ }
|
|
|
+
|
|
|
+// // 获取模板信息
|
|
|
+// MesProductCate mesProductCate = mesProductCateService.findBySn(mesProduct.getCate());
|
|
|
+// if(ObjectUtils.isEmpty(mesProductCate)){
|
|
|
+// throw new ServiceException(text("产品类型不正确!"));
|
|
|
+// }
|
|
|
+
|
|
|
+ Long cdate = Long.valueOf(CommonUitl.Date2TimeStamp(new Date()));
|
|
|
+ List<MesProductRecord> recordsToAdd = new ArrayList<>();
|
|
|
+
|
|
|
+ // 获取当前最大序号
|
|
|
+ int maxSerial = 0;
|
|
|
+ if(!ListUtils.isEmpty(mesProductRecordList)){
|
|
|
+ for(MesProductRecord record : mesProductRecordList){
|
|
|
+ if(record.getSerial() != null && record.getSerial() > maxSerial){
|
|
|
+ maxSerial = record.getSerial();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 创建缺失的记录
|
|
|
+ for(MesTemplateItems missingItem : missingItems){
|
|
|
+ MesProductRecord newRecord = new MesProductRecord();
|
|
|
+ newRecord.setSn(sn);
|
|
|
+ newRecord.setPid("0");
|
|
|
+ newRecord.setCateSn(mesProduct.getCate());
|
|
|
+ newRecord.setLineSn(lineSn);
|
|
|
+ newRecord.setCraft(missingItem.getCraft());
|
|
|
+ newRecord.setOprno(missingItem.getOprno());
|
|
|
+ newRecord.setSerial(maxSerial);
|
|
|
+ newRecord.setTid(missingItem.getId());
|
|
|
+ newRecord.setTreeLevel(0);
|
|
|
+ newRecord.setCdate(cdate);
|
|
|
+ newRecord.setContent("UDF"); // 默认未定义状态
|
|
|
+ newRecord.setSource("0");
|
|
|
+ newRecord.setCreateDate(new Date());
|
|
|
+ newRecord.setUpdateDate(new Date());
|
|
|
+
|
|
|
+ recordsToAdd.add(newRecord);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 批量插入缺失的记录
|
|
|
+ if(!ListUtils.isEmpty(recordsToAdd)){
|
|
|
+ mesProductRecordService.insertBatch(recordsToAdd, recordsToAdd.size());
|
|
|
+ logger.info("产品SN:{}, 补充创建记录数量:{}", sn, recordsToAdd.size());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
try{
|
|
|
mesProductRecordService.updateRecord(sn,oprno,craft,materielSn,"OK",userCode,lineSn);
|
|
|
}catch (Exception e){
|
|
|
@@ -3042,7 +3257,7 @@ public class MesProductRecordController extends BaseController {
|
|
|
mesProductRecord.setOprno(oprno);
|
|
|
mesProductRecord.setSn(sn);
|
|
|
mesProductRecord.setLineSn(lineSn);
|
|
|
- mesProductRecord.setCraft("400004");
|
|
|
+ mesProductRecord.setCraft("400002");
|
|
|
mesProductRecord.setContent("OK");
|
|
|
MesProductRecord mesProductRecord1 = mesProductRecordService.findInfo(mesProductRecord);
|
|
|
if(ObjectUtils.isEmpty(mesProductRecord1)||StringUtils.isEmpty(mesProductRecord1.getMaterielSn())){
|
|
|
@@ -3865,6 +4080,45 @@ public class MesProductRecordController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ //310添加子工位
|
|
|
+ if (!StringUtils.isEmpty(oprno) &&"OP310".equals(oprnoOld)){
|
|
|
+ MesProductOprno mesProductOprno = new MesProductOprno();
|
|
|
+ mesProductOprno.setSn(sn);
|
|
|
+ mesProductOprno.setOprno(oprnoOld);
|
|
|
+ mesProductOprno.setLineSn(lineSn);
|
|
|
+ MesProductOprno mesProductOprno1 = mesProductOprnoService.findInfo(mesProductOprno);
|
|
|
+ System.out.println(mesProductOprno1);
|
|
|
+ if(ObjectUtils.isEmpty(mesProductOprno1)){
|
|
|
+ //添加子工位表
|
|
|
+ mesProductOprnoService.save(mesProductOprno);
|
|
|
+ mesProductOprno1 = mesProductOprnoService.findInfo(mesProductOprno);
|
|
|
+ }
|
|
|
+
|
|
|
+ if("OP310A".equals(oprno) ){
|
|
|
+ mesProductOprno1.setResult1(result);
|
|
|
+ }else if("OP310B".equals(oprno)){
|
|
|
+ mesProductOprno1.setResult2(result);
|
|
|
+ }
|
|
|
+ mesProductOprnoService.save(mesProductOprno1);
|
|
|
+
|
|
|
+ // 全有结果
|
|
|
+ if(mesProductOprno1.getResult1()!=null && !StringUtils.isEmpty(mesProductOprno1.getResult1()) && mesProductOprno1.getResult2()!=null && !StringUtils.isEmpty(mesProductOprno1.getResult2())){
|
|
|
+ String lastRet = "NG";
|
|
|
+ if(mesProductOprno1.getResult1().equals("OK") && mesProductOprno1.getResult2().equals("OK")){
|
|
|
+ lastRet = "OK";
|
|
|
+ }
|
|
|
+ // 2.判断物料批次是否符合绑定
|
|
|
+ List<BindMaterialResp> bmlists = mesLineProcessMaterialService.getBindMaterial(oprnoOld, lineSn);
|
|
|
+ // 总结果产线要求写死“OK”
|
|
|
+ mesProductRecordService.updateRecordResult(sn,oprnoOld,"100000","",lastRet,userCode,params,lineSn,true,bmlists);
|
|
|
+ }else {
|
|
|
+ ret = "RSOK";
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
if (oprnoOld.equals("OP380")){
|
|
|
// 查询开始时间
|
|
|
MesDeviceTime mesDeviceTime = mesDeviceTimeService.getInfoByOprnoAndSnAndCate(oprno,sn,lineSn);
|