|
@@ -2,14 +2,13 @@ package com.github.zuihou.business.util;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.github.zuihou.business.DemoLine.DemoCacheKey;
|
|
|
-import com.github.zuihou.business.DemoLine.DemoLineConstant;
|
|
|
import com.github.zuihou.business.DemoLine.YunjianConstant;
|
|
|
import com.github.zuihou.business.edgeLibrary.service.StockInfoService;
|
|
|
import com.github.zuihou.business.edgeLibrary.service.impl.StockInfoServiceImpl;
|
|
|
-import com.github.zuihou.business.operationManagementCenter.entity.TTask;
|
|
|
-import com.github.zuihou.business.operationManagementCenter.entity.TWorkpiece;
|
|
|
-import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.dao.OrderMapper;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.dao.OrderQualityMapper;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.dao.PlanMapper;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.entity.*;
|
|
|
import com.github.zuihou.business.operationManagementCenter.service.TaskNodeService;
|
|
|
import com.github.zuihou.business.operationManagementCenter.service.TaskService;
|
|
|
import com.github.zuihou.business.productionReadyCenter.dao.BBomMapper;
|
|
@@ -23,15 +22,15 @@ import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
|
|
|
import com.github.zuihou.business.productionResourceCenter.service.impl.ZZoneServiceImpl;
|
|
|
import com.github.zuihou.business.websocket.WebSocketServer;
|
|
|
import com.github.zuihou.common.constant.BizConstant;
|
|
|
-import com.github.zuihou.common.constant.CacheKey;
|
|
|
import com.github.zuihou.common.constant.DictionaryKey;
|
|
|
import com.github.zuihou.common.constant.ParameterKey;
|
|
|
+import com.github.zuihou.common.util.SmbShareFileUtil;
|
|
|
import com.github.zuihou.database.mybatis.conditions.Wraps;
|
|
|
-import com.qiniu.common.Zone;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeansException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
import org.springframework.context.ApplicationContextAware;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
@@ -42,10 +41,7 @@ import org.springframework.stereotype.Component;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
@Component
|
|
@@ -55,6 +51,15 @@ public class MsgUtil implements ApplicationContextAware {
|
|
|
|
|
|
private static ApplicationContext applicationContext;
|
|
|
|
|
|
+ @Value("${zuihou.smb.userName}")
|
|
|
+ private String userName;
|
|
|
+ @Value("${zuihou.smb.password}")
|
|
|
+ private String password;
|
|
|
+ @Value("${zuihou.smb.password}")
|
|
|
+ private String fileIp;
|
|
|
+ @Value("${zuihou.smb.filePath}")
|
|
|
+ private String filePath;
|
|
|
+
|
|
|
@Resource
|
|
|
private RedisTemplate<String,Object> redisTemplate;
|
|
|
|
|
@@ -87,6 +92,13 @@ public class MsgUtil implements ApplicationContextAware {
|
|
|
@Autowired
|
|
|
private MsgUtil msgUtil;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private OrderQualityMapper orderQualityMapper;
|
|
|
+ @Autowired
|
|
|
+ private OrderMapper orderMapper;
|
|
|
+ @Autowired
|
|
|
+ private PlanMapper planMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
|
|
MsgUtil.applicationContext = applicationContext;
|
|
@@ -141,19 +153,6 @@ public class MsgUtil implements ApplicationContextAware {
|
|
|
if(n<taskNodeList.size()-1){//尚未执行到最后一个
|
|
|
TaskNode nextTaskNode = taskNodeList.get(n+1);
|
|
|
|
|
|
- //如果切换成了手动档,则只把当前工序走完
|
|
|
-// if(currWorkpiece!=null&&"1".equals(currWorkpiece.getExchangeZoneFlag())){
|
|
|
- BBom bom = bBomMapper.selectById(task.getBomId());
|
|
|
- ZZone bomzZone = zoneService.getById(bom.getZoneId());
|
|
|
- Long exchangeProcedureId = currWorkpiece.getExchangeProcedureId();
|
|
|
-
|
|
|
- System.err.println("***************************");
|
|
|
- //如果是手动模式,执行完当前工序就不往下走了
|
|
|
- if("2".equals(bomzZone.getRunMode()) && taskNode.getProcedureId() != nextTaskNode.getProcedureId().longValue()){
|
|
|
- return;
|
|
|
- }
|
|
|
-// }
|
|
|
-
|
|
|
//如果是三坐标检测
|
|
|
if("3".equals(taskNode.getNodeType())){
|
|
|
// TODO 后续改成动态拼接
|
|
@@ -182,7 +181,36 @@ public class MsgUtil implements ApplicationContextAware {
|
|
|
System.out.println("instructionUrl=" + instructionUrl);
|
|
|
System.out.println("jsonParam=" + jsonParam);
|
|
|
String returnData = restTemplate.postForObject(instructionUrl, formEntity, String.class);
|
|
|
- if("1".equals(returnData)){
|
|
|
+
|
|
|
+ // TODO modify by yejian on 20220525 for 添加三坐标模拟
|
|
|
+ Random random = new Random();
|
|
|
+ Boolean measuringFlag = random.nextBoolean();
|
|
|
+ int measuringResult = measuringFlag ? 0 : 1;
|
|
|
+ String measuringResultFile = filePath + taskNode.getCompleteBatchNo() + "_" + task.getProcedureNo();
|
|
|
+ List<String> fileContents = new ArrayList<>();
|
|
|
+// if(measuringFlag){
|
|
|
+// fileContents.add("NG");
|
|
|
+// }else{
|
|
|
+ fileContents.add("OK");
|
|
|
+// }
|
|
|
+ SmbShareFileUtil.writeShareFileContent(measuringResultFile,fileContents,userName,password,fileIp);
|
|
|
+ Order order = orderMapper.selectById(task.getOrderId());
|
|
|
+ Plan plan = planMapper.selectById(task.getPlanId());
|
|
|
+ BBom bom = bBomMapper.selectById(task.getBomId());
|
|
|
+ OrderQuality orderQuality = new OrderQuality();
|
|
|
+ orderQuality.setOrderNo(order.getOrderNo());
|
|
|
+ orderQuality.setOrderId(order.getId());
|
|
|
+ orderQuality.setTaskId(task.getId());
|
|
|
+ orderQuality.setWorkpieceId(task.getCompleteBatchNo());
|
|
|
+ orderQuality.setWorkpieceName(bom.getName());
|
|
|
+ orderQuality.setProcedureId(task.getProcedureId());
|
|
|
+ orderQuality.setProcedureName(task.getProcedureName());
|
|
|
+ orderQuality.setMeasuringType(1);
|
|
|
+ orderQuality.setOkFlag("OK");
|
|
|
+ orderQuality.setMeasuringReport(measuringResultFile);
|
|
|
+ orderQualityMapper.insert(orderQuality);
|
|
|
+
|
|
|
+ if(1 == measuringResult){
|
|
|
//获取下料工序
|
|
|
List<BomProcedure> bomProcedureList = bomProcedureService.list(Wraps.<BomProcedure>lbQ().eq(BomProcedure::getBomId,task.getBomId()).eq(BomProcedure::getType,"下料").orderByAsc(BomProcedure::getSort));
|
|
|
if(CollectionUtil.isNotEmpty(bomProcedureList)){
|
|
@@ -199,6 +227,15 @@ public class MsgUtil implements ApplicationContextAware {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //如果切换成了手动档,则只把当前工序走完
|
|
|
+ BBom bom = bBomMapper.selectById(task.getBomId());
|
|
|
+ ZZone bomzZone = zoneService.getById(bom.getZoneId());
|
|
|
+
|
|
|
+ //如果是手动模式,执行完当前工序就不往下走了
|
|
|
+ if("2".equals(bomzZone.getRunMode()) && taskNode.getProcedureId() != nextTaskNode.getProcedureId().longValue()){
|
|
|
+ System.err.println("手动模式下工序最后一个工步***************************");
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
if(callBackJson.containsKey(YunjianConstant.YUNJIAN_XBKFLAG)){//临时存放到了线边库,向虚拟线边库发一个MQ。
|
|
|
int count = callBackJson.getString(taskNode.getId().toString()+"count")==null?-1:Integer.parseInt(callBackJson.getString(taskNode.getId().toString()+"count"));
|