|
@@ -29,10 +29,12 @@ import com.github.zuihou.business.util.MsgUtil;
|
|
|
import com.github.zuihou.common.constant.DictionaryKey;
|
|
|
import com.github.zuihou.common.util.StringUtil;
|
|
|
import com.github.zuihou.database.mybatis.conditions.Wraps;
|
|
|
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
|
|
|
import com.github.zuihou.tenant.entity.Module;
|
|
|
import com.github.zuihou.tenant.entity.ModuleInstruction;
|
|
|
import com.github.zuihou.tenant.service.ModuleService;
|
|
|
import com.google.common.collect.Maps;
|
|
|
+import io.swagger.models.auth.In;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.compress.utils.Lists;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -43,6 +45,7 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static java.util.stream.Collectors.groupingBy;
|
|
@@ -104,16 +107,17 @@ public class MachineNodeServiceImpl implements NodeOperationService {
|
|
|
|
|
|
@Override
|
|
|
public void initResource(TaskNode taskNode, TTask task, Map dataMap) {
|
|
|
+ //获取当前设备模型
|
|
|
String moduleName = dataMap.get("moduleName") == null ? "" : dataMap.get("moduleName").toString();
|
|
|
if(StringUtil.isNotEmpty(moduleName)) {
|
|
|
- List<Module> modules = moduleService.list(new QueryWrapper<Module>().like("name", moduleName));
|
|
|
- if(modules.size()>0){
|
|
|
- deviceArr = modules.stream().map(Module::getNo).toArray(String[]::new);
|
|
|
+ Module module = moduleService.getOne(new LbqWrapper<Module>().eq(Module::getName, moduleName).eq(Module::getStatus, 1));
|
|
|
+ if(null != module){
|
|
|
+ deviceArr = new String[]{module.getNo()};
|
|
|
deviceList = productionresourcePositionService.getFreeProductionresourcePositionByNos(deviceArr);
|
|
|
}
|
|
|
}
|
|
|
- //初始化默认设定(后期动态获取)
|
|
|
- xbkArr = dataMap.get("bizType")!=null? new String[]{dataMap.get("bizType").toString()}: new String[]{DemoLineConstant.NODE_RESOURCE_ZLZX_XBK};
|
|
|
+ //初始化关联线边库(依据产线ID获取)
|
|
|
+ xbkArr = new String[]{DemoLineConstant.NODE_RESOURCE_ZLZX_XBK};
|
|
|
xbkList = productionresourcePositionService.getFreeProductionresourcePositionByNos(xbkArr);
|
|
|
}
|
|
|
|
|
@@ -133,6 +137,8 @@ public class MachineNodeServiceImpl implements NodeOperationService {
|
|
|
// ResourceAutoCode resourceAutoCode = taskNode.getAutoNode();
|
|
|
// String functionName = resourceAutoCode.getCommand();
|
|
|
|
|
|
+ //生产设备操作不关联接驳位,资源占用只暂存在线边库
|
|
|
+
|
|
|
ResourceAutoCode resourceAutoCode = taskNode.getAutoNode();
|
|
|
String functionName = resourceAutoCode.getCommand();
|
|
|
String moduleName = dataMap.get("moduleName") == null ? "" : dataMap.get("moduleName").toString();
|
|
@@ -153,104 +159,19 @@ public class MachineNodeServiceImpl implements NodeOperationService {
|
|
|
// 设备占用 当前节点锁定线边库
|
|
|
boolean isXbk = map.get("useXbk") == null ? false : true;
|
|
|
if(isXbk){
|
|
|
+ //获取锁定线边库的库位信息
|
|
|
Storge storge = storgeService.getById(productionresourcePosition.getStorgeId());
|
|
|
//设定线边库目标ID
|
|
|
- storge.setTargetId(task.getResourceId());
|
|
|
- //TaskNode nextCode = taskNodeService.getNextNTaskNode(taskNode, 1);
|
|
|
- //锁定当前节点与线边库
|
|
|
+ //storge.setTargetId(task.getResourceId());
|
|
|
+ //锁定当前节点与线边库库位
|
|
|
storgeService.lockStorge(storge, taskNode.getId());
|
|
|
+ //更新零件节点的库位信息————workpiece
|
|
|
+
|
|
|
map.put("result", false);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
switch (moduleName) {
|
|
|
- // case "WMS":
|
|
|
- //WMS出库
|
|
|
-// if ("WMS_OUT".equals(functionName)) {
|
|
|
-// jbwArr = new String[]{DemoLineConstant.JBW_A, DemoLineConstant.JBW_B};
|
|
|
-// String[] zxzxXBKarr = new String[]{DemoLineConstant.NODE_RESOURCE_ZLZX_XBK};
|
|
|
-// List<ProductionresourcePosition> xbkList = productionresourcePositionService.getFreeProductionresourcePositionByNos(zxzxXBKarr);
|
|
|
-// List<ProductionresourcePosition> jbwList = productionresourcePositionService.getFreeProductionresourcePositionByNos(jbwArr);
|
|
|
-// Map<String, List<ProductionresourcePosition>> jbwMap = jbwList.stream().collect(groupingBy(ProductionresourcePosition::getCode));
|
|
|
-// if (CollectionUtil.isNotEmpty(xbkList) && jbwMap.containsKey(DemoLineConstant.JBW_B) && jbwMap.containsKey(DemoLineConstant.JBW_A)) {
|
|
|
-// //获取下一个节点,用于锁定
|
|
|
-// TaskNode nextTaskNode = taskNodeService.getNextNTaskNode(taskNode, 1);
|
|
|
-// //预占A接驳位
|
|
|
-// List<ProductionresourcePosition> jbwAList = jbwMap.get(DemoLineConstant.JBW_A);
|
|
|
-// Storge storgeA = storgeService.getById(jbwAList.get(0).getStorgeId());
|
|
|
-// storgeA.setCompleteBatchNo(task.getCompleteBatchNo());
|
|
|
-// storgeService.lockStorge(storgeA, nextTaskNode.getId());
|
|
|
-// //获取接驳位A位置
|
|
|
-// map.put("toStorge", storgeA);
|
|
|
-// map.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_METERIAL_RK);
|
|
|
-// map.put("locationName", "Location-8002");
|
|
|
-// map.put(DemoLineConstant.DEMOLINE_WMS_TYPE, DemoLineConstant.DEMOLINE_WMS_CHUKU);//出库
|
|
|
-//
|
|
|
-// Map jsonMap = new HashMap();
|
|
|
-// jsonMap.put("productNo", task.getMeterialId());
|
|
|
-// jsonMap.put("productCount", "1");
|
|
|
-// List<Map> list = new ArrayList<>();
|
|
|
-// list.add(jsonMap);
|
|
|
-// map.put("boxes", JSONArray.parseArray(JSONObject.toJSONString(list)));
|
|
|
-//
|
|
|
-// //除去接驳位之后,B、C随机一个
|
|
|
-// List<ProductionresourcePosition> jbwBCList = jbwMap.get(DemoLineConstant.JBW_B);
|
|
|
-// //随机选第一个接驳位
|
|
|
-// ProductionresourcePosition p = jbwBCList.get(0);
|
|
|
-// //预占库位为下个节点准备
|
|
|
-// Storge jbwstorge = storgeService.getById(p.getStorgeId());
|
|
|
-//
|
|
|
-// //锁定接驳位库位,锁定的业务ID是下一个节点的ID
|
|
|
-// jbwstorge.setCompleteBatchNo(task.getCompleteBatchNo());
|
|
|
-// storgeService.lockStorge(jbwstorge, nextTaskNode.getId());
|
|
|
-// msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.JBW + "" + nextTaskNode.getId().toString(), jbwstorge, 1, TimeUnit.DAYS);
|
|
|
-//
|
|
|
-// //锁定线边库
|
|
|
-// ProductionresourcePosition xbkP = xbkList.get(0);
|
|
|
-// Storge storgeXbk = storgeService.getById(xbkP.getStorgeId());
|
|
|
-// //获取到运料的节点。
|
|
|
-// TaskNode next6TaskNode = taskNodeService.getNextNTaskNode(taskNode, 6);
|
|
|
-// storgeXbk.setCompleteBatchNo(task.getCompleteBatchNo());
|
|
|
-// storgeService.lockStorge(storgeXbk, next6TaskNode.getId());
|
|
|
-// msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.NODE_RESOURCE_ZLZX_XBK + next6TaskNode.getId(), storgeXbk, 1, TimeUnit.DAYS);
|
|
|
-// //记录产品流转到的库位
|
|
|
-// msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo(), storgeA, 1, TimeUnit.DAYS);
|
|
|
-// }
|
|
|
-// //条件
|
|
|
-// map.put("result", (CollectionUtil.isNotEmpty(xbkList) && jbwMap.containsKey(DemoLineConstant.JBW_B) && jbwMap.containsKey(DemoLineConstant.JBW_A)));
|
|
|
-// }
|
|
|
-// //WMS入库
|
|
|
-// else if ("WMS_IN".equals(functionName)) {
|
|
|
-// //WMS入库
|
|
|
-// map.put(DemoLineConstant.DEMOLINE_GOODS_TYPE, DemoLineConstant.DEMOLINE_GOODS_TYPE_CHENGPIN);//成品
|
|
|
-// map.put(DemoLineConstant.DEMOLINE_WMS_TYPE, DemoLineConstant.DEMOLINE_WMS_RUKU);//入库
|
|
|
-// //TODO临时这样写
|
|
|
-// Map queryMap = new HashMap();
|
|
|
-// jbwArr = new String[]{DemoLineConstant.JBW_A};
|
|
|
-// queryMap.put("codes", StringUtil.changeIdsArrToSubQueryStr(jbwArr));
|
|
|
-// List<ProductionresourcePosition> jbwAList = productionresourcePositionMapper.getPPList(queryMap);
|
|
|
-// if (CollectionUtil.isNotEmpty(jbwAList)) {
|
|
|
-// Storge jbwAstorge = storgeService.getById(jbwAList.get(0).getStorgeId());
|
|
|
-// map.put("fromStorge", jbwAstorge);
|
|
|
-// }
|
|
|
-// map.put("locationName", "Location-8002");
|
|
|
-// Map jsonMap = new HashMap();
|
|
|
-// jsonMap.put("productNo", task.getBomId());
|
|
|
-// jsonMap.put("productCount", "1");
|
|
|
-// List<Map> list = new ArrayList<>();
|
|
|
-// list.add(jsonMap);
|
|
|
-// map.put("boxes", JSONArray.parseArray(JSONObject.toJSONString(list)));
|
|
|
-// map.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_METERIAL_CK);
|
|
|
-// map.put("result", true);
|
|
|
-// }
|
|
|
-// break;
|
|
|
- case "上下料站":
|
|
|
- //同步等待上下料手动操作是否完成
|
|
|
- //boolean isCompleted = false;
|
|
|
- //Storge startStore = workpieceService.getWorkPieceStock(taskNode.getId(),false);
|
|
|
- //实现页面操作,取消轮询等待
|
|
|
- map.put("result", true);
|
|
|
- break;
|
|
|
|
|
|
case "打标机":
|
|
|
if("print".equals(functionName)){
|
|
@@ -259,7 +180,9 @@ public class MachineNodeServiceImpl implements NodeOperationService {
|
|
|
map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "print");
|
|
|
//获取打标唯一码
|
|
|
String unionCode = workpieceService.getUnionCode(task.getCompleteBatchNo());
|
|
|
- map.put("Data", unionCode);//打标内容
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
+ data.put("labelContent", unionCode);
|
|
|
+ map.put("data", data);//打标内容
|
|
|
map.put("result", true);
|
|
|
}
|
|
|
|
|
@@ -282,7 +205,7 @@ public class MachineNodeServiceImpl implements NodeOperationService {
|
|
|
|
|
|
}
|
|
|
map.put("result", true);
|
|
|
- } else if ("SMU50_EXEC".equals(functionName)) {
|
|
|
+ } 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();
|
|
@@ -368,8 +291,6 @@ public class MachineNodeServiceImpl implements NodeOperationService {
|
|
|
BomProcedure procedure = bomProcedureService.getById(task.getProcedureId());
|
|
|
|
|
|
String unionCode = workpieceService.getUnionCode(task.getCompleteBatchNo());
|
|
|
- queryMap.put("WorkId", unionCode);
|
|
|
- queryMap.put("WorkType", StringUtil.isNotEmpty(procedure.getProgramTestPrograme()) ? procedure.getProgramTestPrograme() : "1111");
|
|
|
|
|
|
map.put("Data", JSONObject.toJSONString(queryMap));
|
|
|
map.put("result", true);
|