|
@@ -16,11 +16,15 @@ import com.github.zuihou.business.productionReadyCenter.dao.BBomMapper;
|
|
|
import com.github.zuihou.business.productionReadyCenter.entity.BBom;
|
|
|
import com.github.zuihou.business.productionReadyCenter.entity.BomProcedure;
|
|
|
import com.github.zuihou.business.productionReadyCenter.service.BomProcedureService;
|
|
|
+import com.github.zuihou.business.productionResourceCenter.dao.ZZoneProductionresourceMapper;
|
|
|
import com.github.zuihou.business.productionResourceCenter.entity.ZZone;
|
|
|
+import com.github.zuihou.business.productionResourceCenter.entity.ZZoneProductionresource;
|
|
|
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.database.mybatis.conditions.Wraps;
|
|
|
import com.qiniu.common.Zone;
|
|
|
import org.slf4j.Logger;
|
|
@@ -30,9 +34,14 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
import org.springframework.context.ApplicationContextAware;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
+import org.springframework.http.HttpEntity;
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
|
+import org.springframework.http.MediaType;
|
|
|
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;
|
|
@@ -68,6 +77,12 @@ public class MsgUtil implements ApplicationContextAware {
|
|
|
@Autowired
|
|
|
private TaskNodeService taskNodeService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RestTemplate restTemplate;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ZZoneProductionresourceMapper zZoneProductionresourceMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
|
|
MsgUtil.applicationContext = applicationContext;
|
|
@@ -135,20 +150,40 @@ public class MsgUtil implements ApplicationContextAware {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
//如果是三坐标检测
|
|
|
- if(callBackJson.containsKey("result")&&"NG".equals(callBackJson.getString("result"))){
|
|
|
- //获取下料工序
|
|
|
- List<BomProcedure> bomProcedureList = bomProcedureService.list(Wraps.<BomProcedure>lbQ().eq(BomProcedure::getBomId,task.getBomId()).eq(BomProcedure::getType,"下料").orderByAsc(BomProcedure::getSort));
|
|
|
- if(CollectionUtil.isNotEmpty(bomProcedureList)){
|
|
|
- //获取下料序的第一个节点
|
|
|
- List<TaskNode> taskNodes = taskNodeService.list(Wraps.<TaskNode>lbQ().eq(TaskNode::getProcedureId,bomProcedureList.get(0).getId()).orderByAsc(TaskNode::getCompleteBatchSort));
|
|
|
- if(CollectionUtil.isNotEmpty(taskNodes)){
|
|
|
- jsonObject.put("taskNodeId",taskNodes.get(0).getId());
|
|
|
- //强制下线
|
|
|
- jsonObject.put("bizType", BizConstant.MQ_TASK_NODE_TYPE_COMMON);
|
|
|
- dynamicRabbitMq.sendMsg(taskNode.getResourceId().toString(),jsonObject.toString());
|
|
|
- return;
|
|
|
+ if("3".equals(taskNode.getNodeType())){
|
|
|
+ // TODO 后续改成动态拼接
|
|
|
+ //组装接口参数
|
|
|
+ ZZoneProductionresource zoneProductionresource = zZoneProductionresourceMapper.selectOne(Wraps.<ZZoneProductionresource>lbQ().eq(ZZoneProductionresource::getResourceId,taskNode.getResourceId()));
|
|
|
+ long zoneId = zoneProductionresource.getZoneId();
|
|
|
+ ZZone zZone = zoneService.getById(zoneId);
|
|
|
+ Map<String, String> plcInfo = DictionaryKey.PLC_CATEGORY.get(zZone.getNo());
|
|
|
+
|
|
|
+ HttpHeaders headers = new HttpHeaders();
|
|
|
+ headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
|
|
|
+ JSONObject jsonParam = new JSONObject();
|
|
|
+ jsonParam.put("tagname","DB200.38");
|
|
|
+ jsonParam.put("ip",plcInfo.get("url"));
|
|
|
+ HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam.toJSONString(), headers);
|
|
|
+
|
|
|
+ //动态调用接口和新增指令执行时间
|
|
|
+ String instructionUrl = DictionaryKey.INSTRUCTION_URL + "/api/GetTagValue";
|
|
|
+ System.out.println("instructionUrl=" + instructionUrl);
|
|
|
+ System.out.println("jsonParam=" + jsonParam);
|
|
|
+ String returnData = restTemplate.postForObject(instructionUrl, formEntity, String.class);
|
|
|
+ if("1".equals(returnData)){
|
|
|
+ //获取下料工序
|
|
|
+ List<BomProcedure> bomProcedureList = bomProcedureService.list(Wraps.<BomProcedure>lbQ().eq(BomProcedure::getBomId,task.getBomId()).eq(BomProcedure::getType,"下料").orderByAsc(BomProcedure::getSort));
|
|
|
+ if(CollectionUtil.isNotEmpty(bomProcedureList)){
|
|
|
+ //获取下料序的第一个节点
|
|
|
+ List<TaskNode> taskNodes = taskNodeService.list(Wraps.<TaskNode>lbQ().eq(TaskNode::getProcedureId,bomProcedureList.get(0).getId()).orderByAsc(TaskNode::getCompleteBatchSort));
|
|
|
+ if(CollectionUtil.isNotEmpty(taskNodes)){
|
|
|
+ jsonObject.put("taskNodeId",taskNodes.get(0).getId());
|
|
|
+ //强制下线
|
|
|
+ jsonObject.put("bizType", BizConstant.MQ_TASK_NODE_TYPE_COMMON);
|
|
|
+ dynamicRabbitMq.sendMsg(taskNode.getResourceId().toString(),jsonObject.toString());
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|