|
|
@@ -2,16 +2,9 @@ package com.github.zuihou.business.productionResourceCenter.service.impl;
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
-import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
-import com.github.zuihou.authority.entity.auth.RoleOrg;
|
|
|
-import com.github.zuihou.authority.entity.common.DictionaryItem;
|
|
|
-import com.github.zuihou.authority.entity.core.Org;
|
|
|
import com.github.zuihou.authority.service.common.ParameterService;
|
|
|
-import com.github.zuihou.base.R;
|
|
|
import com.github.zuihou.business.DemoLine.DemoCacheKey;
|
|
|
import com.github.zuihou.business.DemoLine.DemoLineConstant;
|
|
|
import com.github.zuihou.business.DemoLine.YunjianConstant;
|
|
|
@@ -22,11 +15,12 @@ import com.github.zuihou.business.edgeLibrary.entity.Storge;
|
|
|
import com.github.zuihou.business.edgeLibrary.service.StorgeService;
|
|
|
import com.github.zuihou.business.externalApi.service.AgvHikOrderInfoService;
|
|
|
import com.github.zuihou.business.externalApi.service.ExternalApiService;
|
|
|
-import com.github.zuihou.business.mq.TaskWorkNode;
|
|
|
import com.github.zuihou.business.operationManagementCenter.dao.PlanMapper;
|
|
|
-import com.github.zuihou.business.operationManagementCenter.dao.PlanProductMapper;
|
|
|
import com.github.zuihou.business.operationManagementCenter.dao.TTaskMapper;
|
|
|
-import com.github.zuihou.business.operationManagementCenter.entity.*;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.entity.Plan;
|
|
|
+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.service.TaskNodeService;
|
|
|
import com.github.zuihou.business.operationManagementCenter.service.WorkpieceService;
|
|
|
import com.github.zuihou.business.productionReadyCenter.dao.*;
|
|
|
@@ -48,29 +42,20 @@ import com.github.zuihou.common.constant.DictionaryKey;
|
|
|
import com.github.zuihou.common.constant.ParameterKey;
|
|
|
import com.github.zuihou.common.util.DateUtil;
|
|
|
import com.github.zuihou.common.util.StringUtil;
|
|
|
-import com.github.zuihou.common.util.UniqueKeyGenerator;
|
|
|
import com.github.zuihou.database.mybatis.conditions.Wraps;
|
|
|
import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
|
|
|
import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
|
|
|
-import com.github.zuihou.tenant.entity.Module;
|
|
|
import com.github.zuihou.tenant.service.ModuleService;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.compress.utils.Lists;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.http.HttpEntity;
|
|
|
-import org.springframework.http.HttpHeaders;
|
|
|
-import org.springframework.http.HttpMethod;
|
|
|
import org.springframework.http.MediaType;
|
|
|
-import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
-import org.springframework.web.reactive.function.BodyInserters;
|
|
|
import org.springframework.web.reactive.function.client.WebClient;
|
|
|
import reactor.core.publisher.Mono;
|
|
|
|
|
|
@@ -991,9 +976,23 @@ public class RobotNodeServiceImpl implements NodeOperationService {
|
|
|
if(null != targetStorge){
|
|
|
|
|
|
log.info("节点{}检查目标库位是否满足返回{}",taskNode.getId(),targetStorge.getPointId());
|
|
|
-
|
|
|
//锁定机械手
|
|
|
String targetxbk = returnMap.get("targetxbk")==null?null:(String)returnMap.get("targetxbk");
|
|
|
+ Object applyFeeding = msgUtil.redis_get("ApplyFeeding_"+ taskNode.getId());
|
|
|
+ //判断是否为机床上料
|
|
|
+ if(returnMap.containsKey("preUpLoadFlag") && targetxbk.equals("0") && ObjectUtil.isEmpty(applyFeeding)){
|
|
|
+ // 发送请求上料cnc程序。并启动
|
|
|
+ boolean bool = this.asyncPredictUploadFile(task, taskNode);
|
|
|
+ if(!bool){
|
|
|
+ dataMap.put("resultmsg","申请上料条件不满足");
|
|
|
+ msgUtil.redis_del("ApplyFeeding_"+ taskNode.getId());
|
|
|
+ }else{
|
|
|
+ dataMap.put("resultmsg","申请上料程序等待");
|
|
|
+ }
|
|
|
+ dataMap.put("result", false);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
jqrStorge = storgeService.getById(jqrMap.get(DemoLineConstant.DEMOLINE_RJQR_ZS).get(0).getStorgeId());
|
|
|
jqrStorge.setCompleteBatchNo(task.getCompleteBatchNo());
|
|
|
storgeService.lockStorge(jqrStorge, taskNode.getId());
|
|
|
@@ -1036,13 +1035,6 @@ public class RobotNodeServiceImpl implements NodeOperationService {
|
|
|
//出入库类型
|
|
|
dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
|
|
|
|
|
|
- //判断是否为机床上料
|
|
|
- if(returnMap.containsKey("preUpLoadFlag")){
|
|
|
- // 发送请求上料cnc程序。并启动
|
|
|
- this.asyncPredictUploadFile(task, taskNode);
|
|
|
- //程序异步文件上传,因为异步问题,会导致上面程序还没执行,就会给覆盖,不进行程序的上传
|
|
|
-// this.asyncUploadFile(task, taskNode);
|
|
|
- }
|
|
|
}else{
|
|
|
dataMap.put("result", false);
|
|
|
dataMap.put("resultmsg", "目标库位为空,任务id:" + taskNode.getId());
|
|
|
@@ -1095,19 +1087,39 @@ public class RobotNodeServiceImpl implements NodeOperationService {
|
|
|
}
|
|
|
|
|
|
// 预上传,发送上料请求
|
|
|
- public void asyncPredictUploadFile(TTask task,TaskNode taskNode){
|
|
|
+ public boolean asyncPredictUploadFile(TTask task,TaskNode taskNode){
|
|
|
// 根据设备节点需求的设备id获取资源设备信息
|
|
|
Productionresource productionresource = productionresourceBizMapper.selectOne(Wraps.<Productionresource>lbQ().eq(Productionresource::getId,taskNode.getTargetResourceId()));
|
|
|
+ TWorkpiece workpiece = workpieceService.getOne(new LbqWrapper<TWorkpiece>().eq(TWorkpiece::getCompleteBatchNo, task.getCompleteBatchNo()).last("limit 1"));
|
|
|
+ BBom bom = bBomMapper.selectById(workpiece.getBomId());
|
|
|
+
|
|
|
+ if(workpiece.getStorgeId()==null) {
|
|
|
+ msgUtil.createWarnLog("上料申请节点库位地址为空", "DataException");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ StockInfo stockInfo = stockInfoMapper.selectOne(new LbqWrapper<StockInfo>().eq(StockInfo::getStorgeId, workpiece.getStorgeId()).eq(StockInfo::getGoodsType, "1").last("limit 1"));
|
|
|
+ Tray tray = trayService.getById(stockInfo.getGoodsId());
|
|
|
+ StringBuilder sbuilder = new StringBuilder();
|
|
|
+ if(tray.getProductionType().getKey().equals("JXT")){
|
|
|
+ String suffix = tray.getNo().replace("JXT_A", "");
|
|
|
+ sbuilder.append("01" + bom.getProcedureType().trim()).append(suffix.trim()+".H");
|
|
|
+ }else{
|
|
|
+ sbuilder.append("01" + bom.getProcedureType().trim() + ".H");
|
|
|
+ }
|
|
|
|
|
|
List<BomProcedureProgram>procedureProgramList = bomProcedureProgramMapper.selectList(Wraps.<BomProcedureProgram>lbQ().eq(BomProcedureProgram::getProcedureId,task.getProcedureId()));
|
|
|
+ if(procedureProgramList==null || procedureProgramList.size() == 0){
|
|
|
+ msgUtil.createWarnLog("上料申请配置上传文件为空", "DataException");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
List<Map<String, String>> fileList = new ArrayList<Map<String, String>>();
|
|
|
- if (procedureProgramList != null && procedureProgramList.size() > 0) {
|
|
|
//文件上传只允许单个文件
|
|
|
procedureProgramList.forEach(i -> {
|
|
|
Map<String, String> m = new HashMap<>();
|
|
|
String filePath = i.getFilePath().replace(uriPath, storagePath);
|
|
|
//替换默认执行申请上料文件
|
|
|
- filePath = filePath.replace("00.H", "O1.H");
|
|
|
+ filePath = filePath.replace("00.H", sbuilder.toString());
|
|
|
m.put("fileName", filePath);
|
|
|
fileList.add(m);
|
|
|
});
|
|
|
@@ -1115,8 +1127,6 @@ public class RobotNodeServiceImpl implements NodeOperationService {
|
|
|
JSONObject data = new JSONObject();
|
|
|
data.put("fileName", fileList.get(0).get("fileName"));
|
|
|
//Module module = moduleService.getOne(new LbqWrapper<Module>().eq(Module::getId, productionresource.getModuleId()));
|
|
|
- TWorkpiece workpiece = workpieceService.getOne(new LbqWrapper<TWorkpiece>().eq(TWorkpiece::getCompleteBatchNo, task.getCompleteBatchNo()).last("limit 1"));
|
|
|
- BBom bom = bBomMapper.selectById(workpiece.getBomId());
|
|
|
data.put("remotePath", bom.getDrawingNo());
|
|
|
|
|
|
JSONObject uploadInfo = new JSONObject();
|
|
|
@@ -1124,15 +1134,7 @@ public class RobotNodeServiceImpl implements NodeOperationService {
|
|
|
uploadInfo.put("port", productionresource.getPort());
|
|
|
uploadInfo.put("data", data);
|
|
|
|
|
|
- Object runStatus = msgUtil.redis_get("ApplyFeeding_"+ taskNode.getId());
|
|
|
- if(ObjectUtil.isEmpty(runStatus)) {
|
|
|
- boolean bool = this.asyncPredictUploadFilePost(uploadInfo, taskNode.getId());
|
|
|
- if(bool){
|
|
|
- //msgUtil.redis_del("ApplyFeeding_"+ taskNode.getId());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+ return this.asyncPredictUploadFilePost(uploadInfo, taskNode.getId());
|
|
|
}
|
|
|
/**
|
|
|
*
|
|
|
@@ -1141,23 +1143,21 @@ public class RobotNodeServiceImpl implements NodeOperationService {
|
|
|
* @return
|
|
|
*/
|
|
|
public boolean asyncPredictUploadFilePost(JSONObject jsonObject, long taskNodeId){
|
|
|
- logger.warn("====发送异步请求,允许上料请求====》"+ jsonObject);
|
|
|
- System.out.println("====发送异步请求,允许上料请求====》"+jsonObject);
|
|
|
+ logger.warn("====发送异步请求,允许上料请求====》"+ jsonObject +"==="+ DateUtil.formatTime(new Date()));
|
|
|
|
|
|
+ msgUtil.redis_set("ApplyFeeding_"+ taskNodeId, DateUtil.formatTime(new Date()), 1, TimeUnit.HOURS);
|
|
|
String hostSystemUrl = parameterService.getValue(ParameterKey.HOSTSYSTEMURL, null);
|
|
|
WebClient webClient = WebClient.create(hostSystemUrl);
|
|
|
jsonObject.put("taskId", "1");
|
|
|
jsonObject.put("taskNodeId", "1");
|
|
|
Mono mono = webClient.post().uri("/api/PredictUploadFile").contentType(MediaType.APPLICATION_JSON)
|
|
|
.syncBody(jsonObject).retrieve().bodyToMono(String.class);
|
|
|
- msgUtil.redis_set("ApplyFeeding_"+ taskNodeId, "1", 1, TimeUnit.HOURS);
|
|
|
// 当上传不成功进行抛错处理
|
|
|
if(!JSONObject.parseObject(mono.block().toString()).getBoolean("result")){
|
|
|
-// throw new RuntimeException("上传nc,接受异步请求结果,上传失败:" + mono.block());
|
|
|
+ logger.warn("======发送异步请求,请求失败======:"+mono.block() + "===" + DateUtil.formatTime(new Date()));
|
|
|
return false;
|
|
|
}
|
|
|
- logger.info("======发送异步请求,允许上料请求返回结果======:"+mono.block());
|
|
|
- System.out.println("======发送异步请求,允许上料请求返回结果======:"+mono.block());
|
|
|
+ logger.warn("======发送异步请求,允许上料请求返回结果======:"+mono.block() + "===" + DateUtil.formatTime(new Date()));
|
|
|
return true;
|
|
|
}
|
|
|
/**
|