Jelajahi Sumber

首件检查

hfy 1 bulan lalu
induk
melakukan
0e0047d229

+ 50 - 0
src/main/java/com/jeesite/modules/mes/service/MesProductRecordService.java

@@ -27,6 +27,9 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.ObjectUtils;
 
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
@@ -42,6 +45,8 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 
 	@Autowired
 	private MesProductRecordDao mesProductRecordDao;
+	@Autowired
+	private MesProductCheckOneService mesProductCheckOneService;
 
 	/**
 	 * 列表聚合:按工件码分组分页
@@ -412,6 +417,7 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 
 			mesProductRecord.setContent("OK");
 
+
 			Integer i = 1;
 			Long cdate = Long.valueOf(CommonUitl.Date2TimeStamp(new Date()));
 			List<MesProductRecord> records = new ArrayList<>();
@@ -800,6 +806,50 @@ public class MesProductRecordService extends CrudService<MesProductRecordDao, Me
 					mesProductModifyRecordService.save(mesProductModifyRecord1);
 				}
 
+				//查询首件检记录是否为OK或是确认状态
+				if ("1".equals(Global.getConfig("mes.check.one"))) {
+					MesShiftDataResp mesShiftDataResp = mesShiftService.getCurShift();
+					try {
+						DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+						Date stdate = null;
+						stdate = dateFormat.parse(mesShiftDataResp.getStart());
+						Date etdate = dateFormat.parse(mesShiftDataResp.getEnd());
+						String checkOprno = oprno;
+						if (checkOprno.length() == 5) {
+							checkOprno += "A";
+						}
+						String formattedOprno = CommonUitl.formatOprno(checkOprno);
+						List<String> oprnos = new ArrayList<>();
+						oprnos.add(checkOprno);
+						if (!StringUtils.equals(checkOprno, formattedOprno)) {
+							oprnos.add(formattedOprno);
+						}
+						//查询当前班次的是否有加工记录
+						MesProductRecord mesProductRecord5 = new MesProductRecord();
+						mesProductRecord5.setLineSn(lineSn);
+						mesProductRecord5.setCraft("100000");
+						mesProductRecord5.setUpdateDate_gte(stdate);
+						mesProductRecord5.setUpdateDate_lte(etdate);
+						mesProductRecord5.getSqlMap().getWhere().and("a.content", QueryType.NE,"UDF");
+						mesProductRecord5.getSqlMap().getWhere().and("a.oprno", QueryType.IN, oprnos);
+						mesProductRecord5.getSqlMap().getOrder().setOrderBy("a.update_date DESC, a.id DESC");
+						List<MesProductRecord> productRecords = this.findList(mesProductRecord);
+						if (ListUtils.isEmpty(productRecords)) {
+							//生成首件检记录
+							MesProductCheckOne mesProductCheckOne1 = new MesProductCheckOne();
+							mesProductCheckOne1.setSn(sn);
+							mesProductCheckOne1.setOprno(checkOprno);
+							mesProductCheckOne1.setLineSn(lineSn);
+							mesProductCheckOne1.setResult("NG");
+							mesProductCheckOne1.setConfirmCheck("0");
+							mesProductCheckOne1.setCreateBy(userCode);
+							mesProductCheckOne1.setUpdateBy(userCode);
+							mesProductCheckOneService.save(mesProductCheckOne1);
+						}
+					} catch (ParseException e) {
+						throw new RuntimeException(e);
+					}
+				}
 				// 更新主结果
 				if(mesProductRecord.getCraft().equals(craft)){
 					if(oldOprno.length() == 6){

+ 53 - 7
src/main/java/com/jeesite/modules/mes/web/MesProductRecordController.java

@@ -1568,7 +1568,50 @@ public class MesProductRecordController extends BaseController {
 					}
 				}
 			}
-
+			//查询首件检记录是否为OK或是确认状态
+			if ("1".equals(Global.getConfig("mes.check.one"))) {
+				MesShiftDataResp mesShiftDataResp = mesShiftService.getCurShift();
+				try {
+					DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+					Date stdate = null;
+					stdate = dateFormat.parse(mesShiftDataResp.getStart());
+					Date etdate = dateFormat.parse(mesShiftDataResp.getEnd());
+					String checkOprno = oprno;
+					if (checkOprno.length() == 5) {
+						checkOprno += "A";
+					}
+					String formattedOprno = CommonUitl.formatOprno(checkOprno);
+					List<String> oprnos = new ArrayList<>();
+					oprnos.add(checkOprno);
+					if (!StringUtils.equals(checkOprno, formattedOprno)) {
+						oprnos.add(formattedOprno);
+					}
+					//查询当前班次的是否有加工记录
+					MesProductRecord mesProductRecord5 = new MesProductRecord();
+					mesProductRecord5.setLineSn(lineSn);
+					mesProductRecord5.setCraft("100000");
+					mesProductRecord5.setUpdateDate_gte(stdate);
+					mesProductRecord5.setUpdateDate_lte(etdate);
+					mesProductRecord5.getSqlMap().getWhere().and("a.content", QueryType.NE,"UDF");
+					mesProductRecord5.getSqlMap().getWhere().and("a.oprno", QueryType.IN, oprnos);
+					mesProductRecord5.getSqlMap().getOrder().setOrderBy("a.update_date DESC, a.id DESC");
+					List<MesProductRecord> productRecords = mesProductRecordService.findList(mesProductRecord);
+					if (ListUtils.isEmpty(productRecords)) {
+						//生成首件检记录
+						MesProductCheckOne mesProductCheckOne1 = new MesProductCheckOne();
+						mesProductCheckOne1.setSn(sn);
+						mesProductCheckOne1.setOprno(checkOprno);
+						mesProductCheckOne1.setLineSn(lineSn);
+						mesProductCheckOne1.setResult("NG");
+						mesProductCheckOne1.setConfirmCheck("0");
+						mesProductCheckOne1.setCreateBy("system");
+						mesProductCheckOne1.setUpdateBy("system");
+						mesProductCheckOneService.save(mesProductCheckOne1);
+					}
+				} catch (ParseException e) {
+					throw new RuntimeException(e);
+				}
+			}
 			ret = mesProductRecordService.add(mesProductRecord,params,bmlists);
 		}catch (Exception e){
 			e.printStackTrace();
@@ -4599,13 +4642,14 @@ public class MesProductRecordController extends BaseController {
 			MesProductRecord mesProductRecord = new MesProductRecord();
 			mesProductRecord.setLineSn(lineSn);
 			mesProductRecord.setCraft("100000");
-			mesProductRecord.setCreateDate_gte(stdate);
-			mesProductRecord.setCreateDate_lte(etdate);
+			mesProductRecord.setUpdateDate_gte(stdate);
+			mesProductRecord.setUpdateDate_lte(etdate);
+			mesProductRecord.getSqlMap().getWhere().and("a.content", QueryType.NE,"UDF");
 			mesProductRecord.getSqlMap().getWhere().and("a.oprno", QueryType.IN, oprnos);
 			mesProductRecord.getSqlMap().getOrder().setOrderBy("a.update_date DESC, a.id DESC");
 			List<MesProductRecord> productRecords = mesProductRecordService.findList(mesProductRecord);
-			if(ListUtils.isEmpty(productRecords)){
-				//生成首件检记录
+		/*	if(ListUtils.isEmpty(productRecords)){
+			*//*	//生成首件检记录
 				MesProductCheckOne mesProductCheckOne1 = new MesProductCheckOne();
 				mesProductCheckOne1.setSn(sn);
 				mesProductCheckOne1.setOprno(checkOprno);
@@ -4614,11 +4658,13 @@ public class MesProductRecordController extends BaseController {
 				mesProductCheckOne1.setConfirmCheck("0");
 				mesProductCheckOne1.setCreateBy(userCode);
 				mesProductCheckOne1.setUpdateBy(userCode);
-				mesProductCheckOneService.save(mesProductCheckOne1);
+				mesProductCheckOneService.save(mesProductCheckOne1);*//*
+				return true;
+			}*/
+			if(ListUtils.isEmpty(productRecords)){
 				return true;
 			}
 
-
 			//有,判断首件检记录
 			MesProductCheckOne mesProductCheckOne = new MesProductCheckOne();
 			mesProductCheckOne.setLineSn(lineSn);

+ 6 - 0
src/main/resources/config/application.yml

@@ -18,6 +18,12 @@ apiMode: false
 
 tess4j:
   datapath: D:/tessdata
+sms:
+  qiyeweixin:
+    corpid: ww3dda2ee8d438f19a
+    corpSecret: thKZV1BSMruwKtqVeTPFsSCe82z75OqKdd8xLkm1dOY
+    agentid: 1000002
+
 #钉钉消息推送
 ding:
   secret: SECb120c104d1b5fdfac620e4242e6c92ea235b5bca60f80fb80b5551675586bd8c