|
@@ -42,10 +42,7 @@ import org.apache.commons.compress.utils.Lists;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -150,7 +147,8 @@ public class MachineNodeServiceImpl implements NodeOperationService {
|
|
|
//生产设备操作不关联接驳位,资源占用只暂存在线边库
|
|
|
|
|
|
ResourceAutoCode resourceAutoCode = taskNode.getAutoNode();
|
|
|
- String functionName = resourceAutoCode.getCommand();
|
|
|
+ //加工设备默认指令类型(1-上传程序 2-执行程序 3-坐标系校验) 1只应用于机床设备 3已经弃用
|
|
|
+ String functionType = resourceAutoCode.getCommand();
|
|
|
String moduleName = dataMap.get("moduleName") == null ? "" : dataMap.get("moduleName").toString();
|
|
|
|
|
|
//采集接口判断当前设备是否在线
|
|
@@ -171,86 +169,79 @@ public class MachineNodeServiceImpl implements NodeOperationService {
|
|
|
if(isXbk){
|
|
|
//获取锁定线边库的库位信息
|
|
|
Storge storge = storgeService.getById(productionresourcePosition.getStorgeId());
|
|
|
- //设定线边库目标ID
|
|
|
- //storge.setTargetId(task.getResourceId());
|
|
|
//锁定当前节点与线边库库位
|
|
|
storgeService.lockStorge(storge, taskNode.getId());
|
|
|
//更新零件节点的库位信息————workpiece
|
|
|
-
|
|
|
map.put("result", false);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- switch (moduleName) {
|
|
|
+ //获取设备指令集合
|
|
|
+ List<ModuleInstruction> moduleInstructions = (List<ModuleInstruction>)dataMap.get("instructions");
|
|
|
|
|
|
+ switch (moduleName.toLowerCase()) {
|
|
|
case "打标机":
|
|
|
- if("print".equals(functionName)){
|
|
|
+ //执行打标程序
|
|
|
+ if("2".equals(functionType) && moduleInstructions.size() == 1){
|
|
|
//打标
|
|
|
- map.put("zkIp", ZK_ip_rxx);
|
|
|
- map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "print");
|
|
|
+// map.put("zkIp", ZK_ip_rxx);
|
|
|
+// map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "print");
|
|
|
+ //获取打标指令编码
|
|
|
+ map.put("method", moduleInstructions.get(0).getCode());
|
|
|
//获取打标唯一码
|
|
|
String unionCode = workpieceService.getUnionCode(task.getCompleteBatchNo());
|
|
|
JSONObject data = new JSONObject();
|
|
|
+ //默认配置 后期可改可去
|
|
|
+ data.put("workId", "1");
|
|
|
data.put("labelContent", unionCode);
|
|
|
map.put("data", data);//打标内容
|
|
|
map.put("result", true);
|
|
|
}
|
|
|
-
|
|
|
break;
|
|
|
case "smu50":
|
|
|
- if ("SMU50_FILE".equals(functionName)) {
|
|
|
+ if ("1".equals(functionType)) {
|
|
|
+ //程序文件上传
|
|
|
List<BomProcedureProgram>procedureProgramList = bomProcedureProgramMapper.selectList(Wraps.<BomProcedureProgram>lbQ().eq(BomProcedureProgram::getProcedureId,task.getProcedureId()));
|
|
|
|
|
|
List<Map<String, String>> fileList = new ArrayList<Map<String, String>>();
|
|
|
- if (procedureProgramList != null && procedureProgramList.size() > 0) {//先按一个处理
|
|
|
+ if (procedureProgramList != null && procedureProgramList.size() > 0) {
|
|
|
+ //文件上传只允许单个文件
|
|
|
procedureProgramList.forEach(i -> {
|
|
|
Map<String, String> m = new HashMap<>();
|
|
|
m.put("fileName", i.getSubmittedFileName());
|
|
|
fileList.add(m);
|
|
|
});
|
|
|
- String fileName = procedureProgramList.get(0).getSubmittedFileName();
|
|
|
- map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "uploadProgram");
|
|
|
- map.put("Data", JSONArray.parseArray(JSONObject.toJSONString(fileList)));
|
|
|
- msgUtil.redis_set(DemoCacheKey.DEMOLINE_PROGRAME_NAMES + task.getCompleteBatchNo(), fileName, 1, TimeUnit.DAYS);
|
|
|
-
|
|
|
+ //map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "uploadProgram");
|
|
|
+ map.put("method", "UploadFile");
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
+ data.put("fileName", fileList.get(0).get("fileName"));
|
|
|
+ map.put("data", data);
|
|
|
+ //msgUtil.redis_set(DemoCacheKey.DEMOLINE_PROGRAME_NAMES + task.getCompleteBatchNo(), fileName, 1, TimeUnit.DAYS);
|
|
|
+ map.put("result", true);
|
|
|
}
|
|
|
- map.put("result", true);
|
|
|
- } else if ("execProgram".equals(functionName)) {
|
|
|
- //执行程序,分多次执行
|
|
|
- String zoneNo = msgUtil.redis_get(DemoCacheKey.DEMOLINE_WORKOP_ZONE + task.getCompleteBatchNo()) == null ? ""
|
|
|
- : msgUtil.redis_get(DemoCacheKey.DEMOLINE_WORKOP_ZONE + task.getCompleteBatchNo()).toString();
|
|
|
-
|
|
|
-// if (DemoLineConstant.DEMOLINE_WORK_SPACE1.equals(zoneNo)) {
|
|
|
-// map.put("zkIp",ZK_ip_zndy);
|
|
|
-// }else{
|
|
|
-// map.put("zkIp",ZK_ip_rxx);
|
|
|
-// }
|
|
|
- map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "execProgram");
|
|
|
+ }
|
|
|
+ else if ("2".equals(functionType)) {
|
|
|
+ //执行加工程序,分多次执行
|
|
|
+ //String zoneNo = msgUtil.redis_get(DemoCacheKey.DEMOLINE_WORKOP_ZONE + task.getCompleteBatchNo()) == null ? ""
|
|
|
+ // : msgUtil.redis_get(DemoCacheKey.DEMOLINE_WORKOP_ZONE + task.getCompleteBatchNo()).toString();
|
|
|
+ //map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "execProgram");
|
|
|
//当前执行数量
|
|
|
-// int currCount = msgUtil.redis_get(DemoCacheKey.DEMOLINE_PROGRAME_CURRCOUNT + task.getCompleteBatchNo()) == null ? 0 : Integer.parseInt(msgUtil.redis_get(DemoCacheKey.DEMOLINE_PROGRAME_CURRCOUNT + task.getCompleteBatchNo()).toString());
|
|
|
- String fileName = msgUtil.redis_get(DemoCacheKey.DEMOLINE_PROGRAME_NAMES + task.getCompleteBatchNo()) == null ? "" : msgUtil.redis_get(DemoCacheKey.DEMOLINE_PROGRAME_NAMES + task.getCompleteBatchNo()).toString();
|
|
|
- String fileNames[] = fileName.split(",");
|
|
|
-// if (currCount < fileNames.length) {
|
|
|
-// String uploadFileName = fileNames[currCount];
|
|
|
-// Map<String, String> m = new HashMap<>();
|
|
|
-// m.put("fileName", uploadFileName);
|
|
|
-// map.put("data", JSONArray.parseArray(JSONObject.toJSONString(m)));
|
|
|
-// map.put(DemoLineConstant.DEMOLINE_EXEPRO_FLAG, "1");
|
|
|
-// //当前执行数量
|
|
|
-// msgUtil.redis_set(DemoCacheKey.DEMOLINE_PROGRAME_CURRCOUNT + task.getCompleteBatchNo(), ++currCount, 1, TimeUnit.DAYS);
|
|
|
-// }
|
|
|
-// Map fileMap = new HashMap();
|
|
|
-// fileMap.put("fileName", fileName);
|
|
|
- map.put("Data", fileName);
|
|
|
+ //String fileName = msgUtil.redis_get(DemoCacheKey.DEMOLINE_PROGRAME_NAMES + task.getCompleteBatchNo()) == null ? "" : msgUtil.redis_get(DemoCacheKey.DEMOLINE_PROGRAME_NAMES + task.getCompleteBatchNo()).toString();
|
|
|
+ List<BomProcedureProgram> procedureProgramList = bomProcedureProgramMapper.selectList(Wraps.<BomProcedureProgram>lbQ().eq(BomProcedureProgram::getProcedureId,task.getProcedureId()));
|
|
|
+ //执行程序默认按单文件处理
|
|
|
+ //String fileName = "";
|
|
|
+ //String fileNames[] = fileName.split(",");
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
+ data.put("remotePath", procedureProgramList.get(0).getSubmittedFileName());
|
|
|
+ map.put("data", data);
|
|
|
+ map.put("method", "StartNCProgram");
|
|
|
map.put("result", true);
|
|
|
- } else if ("writeOffset".equals(functionName)){
|
|
|
+ }
|
|
|
+ else if ("3".equals(functionType)){
|
|
|
// 加工前写入工件坐标系 根据taskid查找工件三坐标测量的工件坐标系,可能存在装夹一次未果的情况,所以取最后一条数据
|
|
|
// TODO 工件坐标系根据机场不同系统,不同通讯协议调用不同的接口
|
|
|
QueryWrapper<OrderQuality> orderQualityWrapper = new QueryWrapper<OrderQuality>();
|
|
|
- orderQualityWrapper.in("taskId", task.getId());
|
|
|
- orderQualityWrapper.in("measuringType", "2");
|
|
|
- orderQualityWrapper.orderByDesc("updateTime");
|
|
|
- orderQualityWrapper.last("limit 1");
|
|
|
+ orderQualityWrapper.in("taskId", task.getId()).in("measuringType", "2").orderByDesc("updateTime").last("limit 1");
|
|
|
OrderQuality orderQuality = orderQualityMapper.selectOne(orderQualityWrapper);
|
|
|
if(null == orderQuality){
|
|
|
// 简单处理的方式,直接将坐标偏移全部设置成0
|
|
@@ -280,29 +271,37 @@ public class MachineNodeServiceImpl implements NodeOperationService {
|
|
|
queryMap.put("exactXaxisOffset", orderQuality.getExactBaxisOffset());
|
|
|
queryMap.put("exactXaxisOffset", orderQuality.getExactCaxisOffset());
|
|
|
}
|
|
|
- map.put("Data", JSONObject.toJSONString(queryMap));
|
|
|
+ map.put("method", "SendLinShift");
|
|
|
+ map.put("data", JSONObject.toJSONString(queryMap));
|
|
|
map.put("result", true);
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
case "清洗烘干机":
|
|
|
- if ("clean".equals(functionName)) {
|
|
|
+ if ("2".equals(functionType) && moduleInstructions.size() == 1) {
|
|
|
//清洗,PLC接口
|
|
|
- map.put("zkIp", ZK_ip_rxx);
|
|
|
- map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "Clean");
|
|
|
+ //map.put("zkIp", ZK_ip_rxx);
|
|
|
+ //map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "Clean");
|
|
|
+ //获取打标指令编码
|
|
|
+ map.put("method", moduleInstructions.get(0).getCode());
|
|
|
map.put("result", true);
|
|
|
}
|
|
|
break;
|
|
|
case "三坐标检测仪":
|
|
|
- if ("measuring".equals(functionName)) {
|
|
|
- map.put("zkIp", ZK_ip_zlzx);
|
|
|
- map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "testwork");
|
|
|
+ //坐标检测类型判断
|
|
|
+ if ("2".equals(functionType) && moduleInstructions.size()==1) {
|
|
|
+ //map.put("zkIp", ZK_ip_zlzx);
|
|
|
+ //map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "testwork");
|
|
|
//查出工序三坐标相关
|
|
|
- BomProcedure procedure = bomProcedureService.getById(task.getProcedureId());
|
|
|
-
|
|
|
- String unionCode = workpieceService.getUnionCode(task.getCompleteBatchNo());
|
|
|
-
|
|
|
- map.put("Data", JSONObject.toJSONString(queryMap));
|
|
|
+ //BomProcedure procedure = bomProcedureService.getById(task.getProcedureId());
|
|
|
+ //String unionCode = workpieceService.getUnionCode(task.getCompleteBatchNo());
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
+ //三坐标生成编号 动态可变
|
|
|
+ data.put("workId", "measuring_123");
|
|
|
+ data.put("workType", "1111");
|
|
|
+ //map.put("data", JSONObject.toJSONString(queryMap));
|
|
|
+ map.put("method", moduleInstructions.get(0).getCode());
|
|
|
+ map.put("data", data);
|
|
|
map.put("result", true);
|
|
|
}
|
|
|
|
|
@@ -314,59 +313,18 @@ public class MachineNodeServiceImpl implements NodeOperationService {
|
|
|
|
|
|
@Override
|
|
|
public Map operation(JSONObject jsonObject, JSONObject bizJsonObject, Map<String, Object> conMap) {
|
|
|
- boolean bool = (Boolean) conMap.get("NO_WMS");
|
|
|
- TTask task = (TTask) conMap.get("task");
|
|
|
- if(bool) {
|
|
|
- // 生产加工
|
|
|
- jsonObject.put("url", task.getIp());
|
|
|
- jsonObject.put("port", task.getPort());
|
|
|
- jsonObject.put("IsCallBackFlag", "1");
|
|
|
- //搬运类型,拿-放
|
|
|
- String carryRequest = conMap.get(DemoLineConstant.DEMOLINE_BIZ_TYPE) == null ? "" : conMap.get(DemoLineConstant.DEMOLINE_BIZ_TYPE).toString();
|
|
|
- jsonObject.put("BusinessType", carryRequest);
|
|
|
-
|
|
|
- //执行程序标志
|
|
|
- String exePrograme = conMap.get(DemoLineConstant.DEMOLINE_EXEPRO_FLAG) == null ? "" : conMap.get(DemoLineConstant.DEMOLINE_EXEPRO_FLAG).toString();
|
|
|
- bizJsonObject.put(DemoLineConstant.DEMOLINE_EXEPRO_FLAG, exePrograme);
|
|
|
-
|
|
|
- String data = conMap.get("Data") == null ? "" : conMap.get("Data").toString();
|
|
|
- if (StringUtil.isNotEmpty(data)) {
|
|
|
- jsonObject.put("Data", data);
|
|
|
- }
|
|
|
- }else{
|
|
|
- // WMS处理
|
|
|
- String wmsType = conMap.get(DemoLineConstant.DEMOLINE_WMS_TYPE) == null ? "" : conMap.get(DemoLineConstant.DEMOLINE_WMS_TYPE).toString();
|
|
|
- //物料类型0-毛坯1-成品
|
|
|
- String goodsType = conMap.get(DemoLineConstant.DEMOLINE_GOODS_TYPE) == null ? "" : conMap.get(DemoLineConstant.DEMOLINE_GOODS_TYPE).toString();
|
|
|
- String locationName = conMap.get("locationName") == null ? "" : conMap.get("locationName").toString();
|
|
|
- String boxes = conMap.get("boxes") == null ? "" : conMap.get("boxes").toString();
|
|
|
-
|
|
|
- if (DemoLineConstant.DEMOLINE_WMS_CHUKU.equals(wmsType)) {
|
|
|
- jsonObject.put("jobType", "wmsDown");
|
|
|
- } else {
|
|
|
- jsonObject.put("jobType", "wmsUp");
|
|
|
- //3-货物入库1-无物入库
|
|
|
- jsonObject.put("type", "3");
|
|
|
- }
|
|
|
- jsonObject.put("transferType", "wms");
|
|
|
- jsonObject.put("locationName", locationName);
|
|
|
- jsonObject.put("boxes", boxes);
|
|
|
-
|
|
|
- //WMS只能出一个
|
|
|
- if (DemoLineConstant.DEMOLINE_GOODS_TYPE_MAOPI.equals(goodsType)) {//毛坯
|
|
|
- jsonObject.put("goodsId", task.getMeterialId());
|
|
|
- } else {
|
|
|
- jsonObject.put("goodsId", task.getBomId());
|
|
|
+ //获取节点指令操作名称
|
|
|
+ String method = conMap.get("method").toString();
|
|
|
+ String hostSyetemUrl = "http://192.168.170.240:8090/";
|
|
|
+ switch(method){
|
|
|
+ case "execProgram": hostSyetemUrl = hostSyetemUrl + "/api/StartNCProgram"; break;
|
|
|
+ case "clean": hostSyetemUrl = hostSyetemUrl + "/api/StartCleanMachine"; break;
|
|
|
+ case "print": hostSyetemUrl = hostSyetemUrl + "/api/StartLabelMachine"; break;
|
|
|
+ case "measuring": hostSyetemUrl = hostSyetemUrl + "/api/StartCoordinateMeasuringMachine";break;
|
|
|
+
|
|
|
}
|
|
|
- Storge fstorge = (Storge) conMap.get("fromStorge");
|
|
|
- Storge tstorge = (Storge) conMap.get("toStorge");
|
|
|
- //此数据用来业务回传
|
|
|
- bizJsonObject.put("srcPosition", fstorge == null ? "" : fstorge.getId().toString());
|
|
|
- bizJsonObject.put("targetPostion", tstorge == null ? "" : tstorge.getId().toString());
|
|
|
- }
|
|
|
- map.put("jsonObject", jsonObject);
|
|
|
- map.put("bizJsonObject", bizJsonObject);
|
|
|
- return map;
|
|
|
+ conMap.put("instructionUrl", hostSyetemUrl);
|
|
|
+ return conMap;
|
|
|
}
|
|
|
|
|
|
@Override
|