diff --git a/acs/nladmin-system/src/main/resources/log/AcsToLk.xml b/acs/nladmin-system/src/main/resources/log/AcsToLk.xml index 986b7f28c..086f3330d 100644 --- a/acs/nladmin-system/src/main/resources/log/AcsToLk.xml +++ b/acs/nladmin-system/src/main/resources/log/AcsToLk.xml @@ -19,7 +19,12 @@ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n ${log.charset} + + + 0 + 500 + - + diff --git a/acs/nladmin-system/src/main/resources/log/AcsToWms.xml b/acs/nladmin-system/src/main/resources/log/AcsToWms.xml index 6388f813e..6404a9f21 100644 --- a/acs/nladmin-system/src/main/resources/log/AcsToWms.xml +++ b/acs/nladmin-system/src/main/resources/log/AcsToWms.xml @@ -19,15 +19,19 @@ %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n ${log.charset} - - + + 0 + 500 + + - + + + + diff --git a/acs/nladmin-system/src/main/resources/log/AgvNdcOneDeviceDriver.xml b/acs/nladmin-system/src/main/resources/log/AgvNdcOneDeviceDriver.xml index ab61b9b7f..dc45113cb 100644 --- a/acs/nladmin-system/src/main/resources/log/AgvNdcOneDeviceDriver.xml +++ b/acs/nladmin-system/src/main/resources/log/AgvNdcOneDeviceDriver.xml @@ -22,12 +22,18 @@ + + 0 + 500 + + + - + diff --git a/acs/nladmin-system/src/main/resources/log/AgvNdcTwoDeviceDriver.xml b/acs/nladmin-system/src/main/resources/log/AgvNdcTwoDeviceDriver.xml index bc8b49dde..7b1200674 100644 --- a/acs/nladmin-system/src/main/resources/log/AgvNdcTwoDeviceDriver.xml +++ b/acs/nladmin-system/src/main/resources/log/AgvNdcTwoDeviceDriver.xml @@ -22,12 +22,15 @@ - + + 0 + 500 + + + - + diff --git a/acs/nladmin-system/src/main/resources/log/AutoCreateInst.xml b/acs/nladmin-system/src/main/resources/log/AutoCreateInst.xml index 449ee9eb9..d40cfa097 100644 --- a/acs/nladmin-system/src/main/resources/log/AutoCreateInst.xml +++ b/acs/nladmin-system/src/main/resources/log/AutoCreateInst.xml @@ -21,12 +21,15 @@ - + + 0 + 500 + + + - + diff --git a/acs/nladmin-system/src/main/resources/log/LkToAcs.xml b/acs/nladmin-system/src/main/resources/log/LkToAcs.xml index d06be707c..e313aa9db 100644 --- a/acs/nladmin-system/src/main/resources/log/LkToAcs.xml +++ b/acs/nladmin-system/src/main/resources/log/LkToAcs.xml @@ -22,12 +22,15 @@ - + + 0 + 500 + + + - + diff --git a/acs/nladmin-system/src/main/resources/log/NDCAgvServiceImpl.xml b/acs/nladmin-system/src/main/resources/log/NDCAgvServiceImpl.xml index ede1c7a66..a37901d62 100644 --- a/acs/nladmin-system/src/main/resources/log/NDCAgvServiceImpl.xml +++ b/acs/nladmin-system/src/main/resources/log/NDCAgvServiceImpl.xml @@ -22,12 +22,15 @@ - + + 0 + 500 + + + - + diff --git a/acs/nladmin-system/src/main/resources/log/OneNDCSocketConnectionAutoRun.xml b/acs/nladmin-system/src/main/resources/log/OneNDCSocketConnectionAutoRun.xml index f80c20f81..e04531a50 100644 --- a/acs/nladmin-system/src/main/resources/log/OneNDCSocketConnectionAutoRun.xml +++ b/acs/nladmin-system/src/main/resources/log/OneNDCSocketConnectionAutoRun.xml @@ -22,12 +22,15 @@ - + + 0 + 500 + + + - + diff --git a/acs/nladmin-system/src/main/resources/log/OpcUtil.xml b/acs/nladmin-system/src/main/resources/log/OpcUtil.xml index b7234fa2f..a3f0ccef4 100644 --- a/acs/nladmin-system/src/main/resources/log/OpcUtil.xml +++ b/acs/nladmin-system/src/main/resources/log/OpcUtil.xml @@ -22,12 +22,15 @@ - + + 0 + 500 + + + - + diff --git a/acs/nladmin-system/src/main/resources/log/TwoNDC2SocketConnectionAutoRun.xml b/acs/nladmin-system/src/main/resources/log/TwoNDC2SocketConnectionAutoRun.xml index 461ac1ac4..8e22834af 100644 --- a/acs/nladmin-system/src/main/resources/log/TwoNDC2SocketConnectionAutoRun.xml +++ b/acs/nladmin-system/src/main/resources/log/TwoNDC2SocketConnectionAutoRun.xml @@ -22,12 +22,15 @@ - + + 0 + 500 + + + - + diff --git a/acs/nladmin-system/src/main/resources/log/TwoNDCSocketConnectionAutoRun.xml b/acs/nladmin-system/src/main/resources/log/TwoNDCSocketConnectionAutoRun.xml index 650f7cc3b..c92e5014d 100644 --- a/acs/nladmin-system/src/main/resources/log/TwoNDCSocketConnectionAutoRun.xml +++ b/acs/nladmin-system/src/main/resources/log/TwoNDCSocketConnectionAutoRun.xml @@ -22,12 +22,14 @@ - + + 0 + 500 + + - + diff --git a/acs/nladmin-system/src/main/resources/log/WmsToAcs.xml b/acs/nladmin-system/src/main/resources/log/WmsToAcs.xml index 46aade8b0..c2773986a 100644 --- a/acs/nladmin-system/src/main/resources/log/WmsToAcs.xml +++ b/acs/nladmin-system/src/main/resources/log/WmsToAcs.xml @@ -22,12 +22,14 @@ - + + 0 + 500 + + - + diff --git a/acs/nladmin-system/src/main/resources/logback-spring.xml b/acs/nladmin-system/src/main/resources/logback-spring.xml index 347dcd797..1c6138993 100644 --- a/acs/nladmin-system/src/main/resources/logback-spring.xml +++ b/acs/nladmin-system/src/main/resources/logback-spring.xml @@ -76,7 +76,7 @@ https://juejin.cn/post/6844903775631572999 - + 0 500 diff --git a/acs2/nladmin-system/nlsso-server/pom.xml b/acs2/nladmin-system/nlsso-server/pom.xml index 210d346cb..d351f489a 100644 --- a/acs2/nladmin-system/nlsso-server/pom.xml +++ b/acs2/nladmin-system/nlsso-server/pom.xml @@ -47,7 +47,7 @@ org.dromara.dynamictp dynamic-tp-spring-boot-starter-adapter-webserver - 1.1.6.1 + 1.1.7 diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/QueryAGVStatus.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/QueryAGVStatus.java index 4ee62576e..269e7a94b 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/QueryAGVStatus.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/QueryAGVStatus.java @@ -75,36 +75,42 @@ public class QueryAGVStatus { String carNo = json.getString("vehicle"); String instructionCode = json.getString("id"); if ("RUNNING".equals(state) || "CREATED".equals(state) || "TOBEDISPATCHED".equals(state) || "WAITING".equals(state)) { - instruction.setInstruction_status("1"); - instruction.setCarno(carNo); - TaskDto task = new TaskDto(); - instructionService.update(instruction); - task.setCarno(carNo); - task.setTask_id(instruction.getTask_id()); - instructionService.update(instruction); - taskService.update(task); - if (StrUtil.isNotEmpty(instructionCode)){ - Device carCode = deviceAppService.findDeviceByCode(instructionCode); - XgAgvCarDeviceDriver xgAgvCarDeviceDriver; - if (null != carCode) { - if (carCode.getDeviceDriver() instanceof XgAgvCarDeviceDriver) { - xgAgvCarDeviceDriver = (XgAgvCarDeviceDriver) carCode.getDeviceDriver(); - xgAgvCarDeviceDriver.setTaskType(AgvActionTypeEnum.getStatus(instruction.getAgv_action_type())); + if (!"1".equals(instruction.getInstruction_status())) { + instruction.setInstruction_status("1"); + instruction.setCarno(carNo); + TaskDto task = new TaskDto(); + instructionService.update(instruction); + task.setCarno(carNo); + task.setTask_id(instruction.getTask_id()); + instructionService.update(instruction); + taskService.update(task); + if (StrUtil.isNotEmpty(instructionCode)) { + Device carCode = deviceAppService.findDeviceByCode(instructionCode); + XgAgvCarDeviceDriver xgAgvCarDeviceDriver; + if (null != carCode) { + if (carCode.getDeviceDriver() instanceof XgAgvCarDeviceDriver) { + xgAgvCarDeviceDriver = (XgAgvCarDeviceDriver) carCode.getDeviceDriver(); + xgAgvCarDeviceDriver.setTaskType(AgvActionTypeEnum.getStatus(instruction.getAgv_action_type())); + } } } - } + } } else if ("FINISHED".equals(state)) { - instruction.setInstruction_status("2"); - try { - instructionService.finish(instruction); - } catch (Exception e) { - log.error("执行完成,但无法更新状态,可能由于参数错误导致的异常"); - e.printStackTrace(); + if (!"2".equals(instruction.getInstruction_status())) { + instruction.setInstruction_status("2"); + try { + instructionService.finish(instruction); + } catch (Exception e) { + log.error("执行完成,但无法更新状态,可能由于参数错误导致的异常"); + e.printStackTrace(); + } } } else if ("STOPPED".equals(state) || "FAILED".equals(state) || "Error".equals(state)) { - instruction.setInstruction_status("1"); - instructionService.update(instruction); + if (!"1".equals(instruction.getInstruction_status())) { + instruction.setInstruction_status("1"); + instructionService.update(instruction); + } } } } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java index 2651804b9..a1d6165b4 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java @@ -38,6 +38,7 @@ import org.nl.config.lucene.service.dto.LuceneLogDto; import org.nl.system.service.param.ISysParamService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import java.util.*; @@ -52,7 +53,8 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { private final DeviceAppService deviceAppService; private final ISysParamService paramService; @Autowired - private final AcsToWmsService acsToWmsService; + @Lazy + private AcsToWmsService acsToWmsService; @Autowired private IAcsPointAngleService acsPointAngleService; @@ -740,10 +742,21 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { String inst_code = requestParam.getString("task_code"); Instruction instructionDto = instructionService.findByCodeFromCache(inst_code); if (ObjectUtil.isEmpty(instructionDto)) { + LuceneLogDto logDto = LuceneLogDto.builder() + .content("请求失败,未找到指令!" + inst_code) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); throw new BadRequestException("请求失败,未找到指令!"); } String address = requestParam.getString("address"); if (StrUtil.isBlank(address)) { + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(instructionDto.getCarno()) + .content("请求失败,地址为空!" ) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); throw new BadRequestException("请求失败,地址为空!"); } if (address.contains("IN") || address.contains("WAIT")) { @@ -755,6 +768,12 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { deviceCodeNow = address.substring(0, address.length() - 5); } if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) { + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(instructionDto.getCarno()) + .content("设备号 " + deviceCodeNow + " 不存在!") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!"); } //一楼诺宝agv @@ -802,6 +821,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { map.put("message", "允许叉车放货!" + "点位" + newPointCode); log.info("允许仙工AGV放货,设备号 - {}", newPointCode); LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(instructionDto.getCarno()) .content("叉车允许放货" + "新点位:" + newPointCode + map ) .build(); logDto.setLog_level(4); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/CustomerStragetyCacheService.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/CustomerStragetyCacheService.java index 7ae5ad02e..192617a18 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/CustomerStragetyCacheService.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/CustomerStragetyCacheService.java @@ -1,13 +1,32 @@ package org.nl.acs.custompolicy; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import org.nl.acs.auto.initial.ApplicationAutoInitial; -import java.util.HashMap; -import java.util.Map; +import org.nl.acs.custompolicy.domain.CustomPolicy; +import org.nl.acs.custompolicy.server.mapper.CustomPolicyMapper; +import org.nl.acs.task.domain.Task; +import org.nl.acs.task.enums.TaskStatusEnum; +import org.nl.acs.task.service.mapper.TaskMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +@Service public class CustomerStragetyCacheService implements ApplicationAutoInitial { private Map strategyCache = new HashMap(); + @Autowired + private CustomPolicyMapper customPolicyMapper; + public CustomerStragetyCacheService() { } @@ -27,5 +46,23 @@ public class CustomerStragetyCacheService implements ApplicationAutoInitial { @Override public void autoInitial() throws Exception { // 策略缓存 + List customPolicyList = new LambdaQueryChainWrapper<>(customPolicyMapper) + .eq(CustomPolicy::getIs_on, "1") + .orderByDesc(CustomPolicy::getCreate_time) + .list(); + for (CustomPolicy customPolicy : customPolicyList) { + if (StrUtil.isEmpty(customPolicy.getKey_value())){ + continue; + } + JSONObject jsonObject = JSONObject.parseObject(customPolicy.getKey_value()); + JSONArray plans = jsonObject.getJSONArray("plans"); + if (ObjectUtil.isNotEmpty(plans)) { + List plansList = plans.toJavaList(StackerInstruction.class); + StackerStrategyDto stackerStrategyDto = new StackerStrategyDto(); + stackerStrategyDto.setPlan(plansList); + stackerStrategyDto.setDeviceCode(customPolicy.getKey_code()); + strategyCache.put(customPolicy.getKey_code(), stackerStrategyDto); + } + } } } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/StackerInstruction.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/StackerInstruction.java index dbbf4ab3a..a4df7c43e 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/StackerInstruction.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/StackerInstruction.java @@ -1,61 +1,16 @@ package org.nl.acs.custompolicy; + +import lombok.Data; + +@Data public class StackerInstruction { - private String procedure; - private String type; private String from; - private String to; - private int quantity = 1; + private int quantity; private int sort; + private String to; + private int type; - public StackerInstruction() { - } - public String getProcedure() { - return this.procedure; - } - public void setProcedure(String procedure) { - this.procedure = procedure; - } - - public String getType() { - return this.type; - } - - public void setType(String type) { - this.type = type; - } - - public String getFrom() { - return this.from; - } - - public void setFrom(String from) { - this.from = from; - } - - public String getTo() { - return this.to; - } - - public void setTo(String to) { - this.to = to; - } - - public int getQuantity() { - return this.quantity; - } - - public void setQuantity(int quantity) { - this.quantity = quantity; - } - - public int getSort() { - return this.sort; - } - - public void setSort(int sort) { - this.sort = sort; - } } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/StackerStrategyDto.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/StackerStrategyDto.java index 26124e0ec..273ff4e12 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/StackerStrategyDto.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/StackerStrategyDto.java @@ -8,7 +8,7 @@ public class StackerStrategyDto { /** * 策略 */ - private List plan = new ArrayList(); + private List plans = new ArrayList(); /** * 禁止策略 暂时未开发 */ @@ -26,11 +26,11 @@ public class StackerStrategyDto { } public List getPlan() { - return this.plan; + return this.plans; } public void setPlan(List plan) { - this.plan = plan; + this.plans = plan; } public List getForbid() { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/server/dto/CustomPolicyPlantDTO.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/server/dto/CustomPolicyPlantDTO.java index 3612046a7..3b7573a14 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/server/dto/CustomPolicyPlantDTO.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/server/dto/CustomPolicyPlantDTO.java @@ -19,15 +19,15 @@ import java.io.Serializable; public class CustomPolicyPlantDTO implements Serializable { private static final long serialVersionUID = 1L; - + private Integer type; - - private Integer from; - - private Integer to; - + + private String from; + + private String to; + private Integer quantity; - + private Integer sort; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/server/impl/CustomPolicyServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/server/impl/CustomPolicyServiceImpl.java index db1245f40..77dc09b8e 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/server/impl/CustomPolicyServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/custompolicy/server/impl/CustomPolicyServiceImpl.java @@ -18,9 +18,15 @@ import org.nl.acs.custompolicy.server.dto.CustomPolicyDTO; import org.nl.acs.custompolicy.server.dto.CustomPolicyPlantDTO; import org.nl.acs.custompolicy.server.mapper.CustomPolicyMapper; import org.nl.acs.custompolicy.server.vo.CustomPolicyPlantVO; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device_driver.stacker.standard_stacker.StandardStackerDeviceDriver; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.opc.DeviceAppServiceImpl; import org.nl.acs.utils.ConvertUtil; import org.nl.acs.utils.PageUtil; import org.nl.common.utils.SecurityUtils; +import org.nl.config.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; @@ -44,6 +50,8 @@ public class CustomPolicyServiceImpl extends CommonServiceImpl> customPolicyPlantDTOMap; + @Autowired + DeviceAppService deviceAppService; /** * 初始化策略 @@ -122,6 +130,14 @@ public class CustomPolicyServiceImpl extends CommonServiceImpl shortPathsList = routeLineService.getShortPathLines(start_device_code, taskdto.getNext_device_code(), route_plan_code); RouteLineDto routeLineDto = shortPathsList.get(0); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/ItemProtocol.java index df2e60715..26622022e 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/belt_conveyor/ItemProtocol.java @@ -152,7 +152,7 @@ public class ItemProtocol { } else { return value; } - return "0"; + return ""; } public int[] getOpcArrayValue(String protocol) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java index 225534d39..f0ef25b2e 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/driver/AbstractOpcDeviceDriver.java @@ -11,10 +11,6 @@ import org.openscada.opc.lib.da.ItemState; import org.springframework.beans.factory.annotation.Autowired; import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements OpcDeviceDriver { UnifiedDataAccessor opcUdw; @@ -39,223 +35,202 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc public void checkcontrol(Map itemValues) throws Exception { + Group group = opcServerService.getServer(this.getOpcServer()); + Map write = new HashMap(); + Map readitems = new LinkedHashMap(); + List itemsString = new ArrayList(); + itemsString = new ArrayList<>(itemValues.keySet()); + Iterator is = itemsString.iterator(); - CompletableFuture future = CompletableFuture.supplyAsync(() -> { + while (is.hasNext()) { + String string = (String) is.next(); try { - Group group = opcServerService.getServer(this.getOpcServer()); - Map write = new HashMap(); - Map readitems = new LinkedHashMap(); - List itemsString = new ArrayList(); - itemsString = new ArrayList<>(itemValues.keySet()); - Iterator is = itemsString.iterator(); - - while (is.hasNext()) { - String string = (String) is.next(); - try { - readitems.put(string, group.addItem(string)); - } catch (Exception e) { - e.printStackTrace(); - } + readitems.put(string, group.addItem(string)); + } catch (Exception e) { + e.printStackTrace(); + } + } + int i = 0; + while (true) { + //下发信号 + try { + if (i == 0) { + control(itemValues); + } else { + controlByNewConn(itemValues); } - int i = 0; - while (true) { - //下发信号 - try { - if (i == 0) { - control(itemValues); - } else { - controlByNewConn(itemValues); + } catch (Exception e) { + e.printStackTrace(); + } +// ThreadUtl.sleep(1000L); + Map read = new HashMap(); + Map itemStatus = null; + boolean check = true; + try { + if (i > 0) { + group = opcServerService.getServer(this.getOpcServer()); + itemsString = new ArrayList<>(itemValues.keySet()); + Iterator nis = itemsString.iterator(); + + while (nis.hasNext()) { + String string = (String) nis.next(); + try { + readitems.put(string, group.addItem(string)); + } catch (Exception e) { + e.printStackTrace(); } - - } catch (Exception e) { - e.printStackTrace(); } - Map read = new HashMap(); - Map itemStatus = null; - boolean check = true; - try { - if (i > 0) { - group = opcServerService.getServer(this.getOpcServer()); - itemsString = new ArrayList<>(itemValues.keySet()); - Iterator nis = itemsString.iterator(); + itemStatus = group.read(true, (Item[]) readitems.values().toArray(new Item[0])); - while (nis.hasNext()) { - String string = (String) nis.next(); - try { - readitems.put(string, group.addItem(string)); - } catch (Exception e) { - e.printStackTrace(); - } - } - itemStatus = group.read(true, (Item[]) readitems.values().toArray(new Item[0])); + } else { + itemStatus = group.read(true, (Item[]) readitems.values().toArray(new Item[0])); + } + Set items = itemStatus.keySet(); + Iterator var15 = items.iterator(); + while (var15.hasNext()) { + Item item = (Item) var15.next(); + ItemState itemState = (ItemState) itemStatus.get(item); + Object value = OpcUtl.getValue(item, itemState); + read.put(item.getId(), value); + } - } else { - itemStatus = group.read(true, (Item[]) readitems.values().toArray(new Item[0])); - } - Set items = itemStatus.keySet(); - Iterator var15 = items.iterator(); - while (var15.hasNext()) { - Item item = (Item) var15.next(); - ItemState itemState = (ItemState) itemStatus.get(item); - Object value = OpcUtl.getValue(item, itemState); - read.put(item.getId(), value); - } + Iterator var24 = itemsString.iterator(); - Iterator var24 = itemsString.iterator(); - - while (var24.hasNext()) { - String itemString = (String) var24.next(); - if (!ObjectUtl.isEquals(String.valueOf(itemValues.get(itemString)), String.valueOf(read.get(itemString)))) { - check = false; - } - } - } catch (Exception e) { - e.printStackTrace(); + while (var24.hasNext()) { + String itemString = (String) var24.next(); + if (!ObjectUtl.isEquals(String.valueOf(itemValues.get(itemString)), String.valueOf(read.get(itemString)))) { check = false; } - - if (check) { - return ""; - } - - if (i > 0) { - ThreadUtl.sleep(100L); - } - - if (i >= 3) { -// log.info("写入次数超过3次而失败"); - throw new RuntimeException("写入次数超过3次而失败"); - } - ++i; } } catch (Exception e) { - Thread.currentThread().interrupt(); - throw new IllegalStateException("Interrupted", e); + e.printStackTrace(); + check = false; } - }); - try { - String result = future.get(2, TimeUnit.SECONDS); // 设置超时时间为2秒 - System.out.println(result); - } catch (CompletionException e) { - Throwable cause = e.getCause(); - if (cause instanceof TimeoutException) { - System.out.println("Operation timed out"); - } else { - throw e; // rethrow other exceptions + + if (check) { + return; } - } catch (Exception e) { - throw new RuntimeException(e); + + if (i > 0) { + ThreadUtl.sleep(100L); + } + + if (i >= 3) { +// log.info("写入次数超过3次而失败"); + throw new RuntimeException("写入次数超过3次而失败"); + } + ++i; } - } + } - public boolean controlByNewConn (Map < String, Object > itemValues){ + public boolean controlByNewConn(Map itemValues) { - Iterator> it = itemValues.entrySet().iterator(); + Iterator> it = itemValues.entrySet().iterator(); - ItemValue[] p2; - p2 = new ItemValue[itemValues.size()]; - int i = 0; - while (it.hasNext()) { - Map.Entry entry = it.next(); - System.out.println("即将写入值:" + entry.getKey() + ":" + entry.getValue()); - p2[i] = new ItemValue(); - p2[i].setItem_code(entry.getKey()); - p2[i].setItem_value(entry.getValue()); - i++; + ItemValue[] p2; + p2 = new ItemValue[itemValues.size()]; + int i = 0; + while (it.hasNext()) { + Map.Entry entry = it.next(); + System.out.println("即将写入值:" + entry.getKey() + ":" + entry.getValue()); + p2[i] = new ItemValue(); + p2[i].setItem_code(entry.getKey()); + p2[i].setItem_value(entry.getValue()); + i++; + } + + return this.controlByNewConn(p2); + } + + public boolean control(Map itemValues) { + + Iterator> it = itemValues.entrySet().iterator(); + + ItemValue[] p2; + p2 = new ItemValue[itemValues.size()]; + int i = 0; + while (it.hasNext()) { + Map.Entry entry = it.next(); + System.out.println("即将写入值:" + entry.getKey() + ":" + entry.getValue()); + p2[i] = new ItemValue(); + p2[i].setItem_code(entry.getKey()); + p2[i].setItem_value(entry.getValue()); + i++; + } + + return this.control(p2); + } + + + public boolean control(ItemValue[] itemValues) { + if (itemValues != null && itemValues.length != 0) { + String this_items = JsonUtl.parseWithoutException(itemValues); + boolean need_write = false; + StringBuilder sb = new StringBuilder(); + ItemValue[] var5 = itemValues; + int var6 = itemValues.length; + + for (int var7 = 0; var7 < var6; ++var7) { + ItemValue itemValue = var5[var7]; + String code = itemValue.getItem_code(); + Object udw_value = this.getUdwValue(code); + Object write_value = itemValue.getItem_value(); + sb.append(code); + sb.append(":"); + sb.append(JsonUtl.parseWithoutException(udw_value)); + sb.append(";"); + if (!need_write && !UnifiedDataAppService.isEquals(udw_value, write_value)) { + need_write = true; + } else { + //log.warn("下发信号点位{} 当前写入值:{} 与系统内存值:{} 相同,不再写入 ", code, write_value, udw_value ); } - - return this.controlByNewConn(p2); } + // need_write = true; - public boolean control (Map < String, Object > itemValues){ - - Iterator> it = itemValues.entrySet().iterator(); - - ItemValue[] p2; - p2 = new ItemValue[itemValues.size()]; - int i = 0; - while (it.hasNext()) { - Map.Entry entry = it.next(); - System.out.println("即将写入值:" + entry.getKey() + ":" + entry.getValue()); - p2[i] = new ItemValue(); - p2[i].setItem_code(entry.getKey()); - p2[i].setItem_value(entry.getValue()); - i++; - } - - return this.control(p2); - } - - - public boolean control (ItemValue[]itemValues){ - if (itemValues != null && itemValues.length != 0) { - String this_items = JsonUtl.parseWithoutException(itemValues); - boolean need_write = false; - StringBuilder sb = new StringBuilder(); - ItemValue[] var5 = itemValues; - int var6 = itemValues.length; - - for (int var7 = 0; var7 < var6; ++var7) { - ItemValue itemValue = var5[var7]; - String code = itemValue.getItem_code(); - Object udw_value = this.getUdwValue(code); - Object write_value = itemValue.getItem_value(); - sb.append(code); - sb.append(":"); - sb.append(JsonUtl.parseWithoutException(udw_value)); - sb.append(";"); - if (!need_write && !UnifiedDataAppService.isEquals(udw_value, write_value)) { - need_write = true; - } else { - //log.warn("下发信号点位{} 当前写入值:{} 与系统内存值:{} 相同,不再写入 ", code, write_value, udw_value ); - } - } - // need_write = true; - - if (need_write) { - Date date = new Date(); + if (need_write) { + Date date = new Date(); /*if (StringUtl.isEqual(this_items, this.last_items) && date.getTime() - this.sendTime.getTime() < (long) WcsConfig.opc_write_repeat_check) { log.trace("发送时间因为小于{}毫秒,而被无视", WcsConfig.opc_write_repeat_check); return false; }*/ - this.last_items = this_items; - this.sendTime = date; + this.last_items = this_items; + this.sendTime = date; /* this.execute_log.setResource(this.getDevice().getCode(), this.getDevice().getName()); this.execute_log.log("原始记录{}->变更为{}", new Object[]{sb, this_items}); OpcServerService opcServerService = OpcServerFactory.getOpcServerService();*/ - OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerServiceImpl.class); + OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerServiceImpl.class); - opcServerService.writeInteger(this.getOpcServer(), itemValues); - UnifiedDataAccessor opcValueAccessor = this.getOpcValueAccessor(); - ItemValue[] var17 = itemValues; - int var18 = itemValues.length; + opcServerService.writeInteger(this.getOpcServer(), itemValues); + UnifiedDataAccessor opcValueAccessor = this.getOpcValueAccessor(); + ItemValue[] var17 = itemValues; + int var18 = itemValues.length; - for (int var19 = 0; var19 < var18; ++var19) { - ItemValue itemValue = var17[var19]; - String code = itemValue.getItem_code(); - Object value = itemValue.getItem_value(); - opcValueAccessor.setValue(code, value); - } - } - - return true; - } else { - throw new RuntimeException("下发 无内容"); + for (int var19 = 0; var19 < var18; ++var19) { + ItemValue itemValue = var17[var19]; + String code = itemValue.getItem_code(); + Object value = itemValue.getItem_value(); + opcValueAccessor.setValue(code, value); } } + return true; + } else { + throw new RuntimeException("下发 无内容"); + } + } - public boolean controlByNewConn (ItemValue[]itemValues){ - if (itemValues != null && itemValues.length != 0) { - String this_items = JsonUtl.parseWithoutException(itemValues); - boolean need_write = false; - StringBuilder sb = new StringBuilder(); - ItemValue[] var5 = itemValues; - int var6 = itemValues.length; + + public boolean controlByNewConn(ItemValue[] itemValues) { + if (itemValues != null && itemValues.length != 0) { + String this_items = JsonUtl.parseWithoutException(itemValues); + boolean need_write = false; + StringBuilder sb = new StringBuilder(); + ItemValue[] var5 = itemValues; + int var6 = itemValues.length; // for (int var7 = 0; var7 < var6; ++var7) { // ItemValue itemValue = var5[var7]; // String code = itemValue.getItem_code(); @@ -271,36 +246,36 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc // log.warn("下发信号点位{} 当前写入值:{} 与系统内存值:{} 相同,不再写入 ", code, write_value, udw_value ); // } // } - need_write = true; - if (need_write) { - Date date = new Date(); + need_write = true; + if (need_write) { + Date date = new Date(); /*if (StringUtl.isEqual(this_items, this.last_items) && date.getTime() - this.sendTime.getTime() < (long) WcsConfig.opc_write_repeat_check) { log.trace("发送时间因为小于{}毫秒,而被无视", WcsConfig.opc_write_repeat_check); return false; }*/ - this.last_items = this_items; - this.sendTime = date; - OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerServiceImpl.class); + this.last_items = this_items; + this.sendTime = date; + OpcServerService opcServerService = SpringContextHolder.getBean(OpcServerServiceImpl.class); - opcServerService.writeIntegerByNewConn(this.getOpcServer(), itemValues); + opcServerService.writeIntegerByNewConn(this.getOpcServer(), itemValues); - UnifiedDataAccessor opcValueAccessor = this.getOpcValueAccessor(); - ItemValue[] var17 = itemValues; - int var18 = itemValues.length; + UnifiedDataAccessor opcValueAccessor = this.getOpcValueAccessor(); + ItemValue[] var17 = itemValues; + int var18 = itemValues.length; - for (int var19 = 0; var19 < var18; ++var19) { - ItemValue itemValue = var17[var19]; - String code = itemValue.getItem_code(); - Object value = itemValue.getItem_value(); - opcValueAccessor.setValue(code, value); - } - } - - return true; - } else { - throw new RuntimeException("下发 无内容"); + for (int var19 = 0; var19 < var18; ++var19) { + ItemValue itemValue = var17[var19]; + String code = itemValue.getItem_code(); + Object value = itemValue.getItem_value(); + opcValueAccessor.setValue(code, value); } } + + return true; + } else { + throw new RuntimeException("下发 无内容"); } + } +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/BoxStorageOutConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/BoxStorageOutConveyorDeviceDriver.java index e34ccb88a..447d805a4 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/BoxStorageOutConveyorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/BoxStorageOutConveyorDeviceDriver.java @@ -76,7 +76,7 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); - LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); + LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); //当前指令 @@ -192,56 +192,65 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i } if (move != 0 && task > 0) { - if (null!=inst) { + if (null != inst) { inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code(); } update_instruction_status(); } - } catch (Exception var17) { - var17.printStackTrace(); - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); - } - - - if (move != last_move && move==0 && last_move==1) { - requireSucess = false; - clearWrite(); - } - - if (mode == 0) { - this.setIsonline(false); - message = "脱机"; - - //有报警 - } else { - this.setIsonline(true); - this.setIserror(false); - if (error != 0) { - this.setIserror(true); - message = "有警报"; + if (move != last_move && move == 0 && last_move == 1) { + requireSucess = false; + clearWrite(); } - Instruction instruction = null; - List toInstructions; + if (mode == 0) { + this.setIsonline(false); + message = "脱机"; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 2: - break; - case 25: - if ( StrUtil.isEmpty(material_barcode)) { - message = "子卷码为空"; - }else { - //二楼到一楼输送线申请行架任务 - if (move == 1 && !requireSucess) { - applyManipulatorTask(); + //有报警 + } else { + this.setIsonline(true); + this.setIserror(false); + if (error != 0) { + this.setIserror(true); + message = "有警报"; + }else { + this.setIserror(false); + } + + Instruction instruction = null; + List toInstructions; + + switch (mode) { + case 1: + log.debug("设备运转模式:等待工作"); + break; + case 2: + break; + case 25: + if (StrUtil.isEmpty(material_barcode)) { + message = "子卷码为空"; + } else { + //二楼到一楼输送线申请行架任务 + if (move == 1 && !requireSucess) { + applyManipulatorTask(); + } } - } - break; + break; + } } + } catch (Exception var17) { + this.iserror = true; + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(this.device_code+ "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + + var17.printStackTrace(); } + + last_mode = mode; last_move = move; last_error = error; @@ -259,21 +268,22 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i private void clearWrite() { List list = new ArrayList<>(); Map map = new HashMap<>(); - map.put("code","to_target"); - map.put("value","0"); + map.put("code", "to_target"); + map.put("value", "0"); list.add(map); Map map2 = new HashMap<>(); - map2.put("code","to_task"); - map2.put("value","0"); + map2.put("code", "to_task"); + map2.put("value", "0"); list.add(map2); Map map4 = new HashMap<>(); - map4.put("code","to_container_type"); - map4.put("value","0"); + map4.put("code", "to_container_type"); + map4.put("value", "0"); list.add(map4); this.writing(list); - message=null; - vehicle_code=null; + message = null; + vehicle_code = null; + inst_message = null; } @@ -379,7 +389,7 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i luceneExecuteLogService.deviceExecuteLog(logDto2); this.requireSucess = true; } else { - this.iserror = false; + this.iserror = true; message = "二楼到一楼输送线申请行架任务报错,返回参数:" + jo; LuceneLogDto logDto2 = LuceneLogDto.builder() .device_code(device_code) @@ -577,7 +587,7 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() , inst.getInstruction_code())) { this.writing(list); - LuceneLogDto logDto = LuceneLogDto.builder() + LuceneLogDto logDto = LuceneLogDto.builder() .device_code(device_code) .content(device_code + inst.getInstruction_code() + "再次下发电气信号") .build(); @@ -651,7 +661,7 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i map.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(this.getError()))); map.put("requireSucess", requireSucess); map.put("driver_type", "siemens_conveyor"); - map.put("message",message); + map.put("message", message); map.put("inst_message", this.inst_message); map.put("last_inst_message", this.last_inst_message); map.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/ItemProtocol.java index 76da017eb..00b127add 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_storage_out_conveyor/ItemProtocol.java @@ -150,7 +150,7 @@ public class ItemProtocol { } else { return value; } - return "0"; + return ""; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java index f6ecfd3d2..0bbac9a6f 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/box_subvolumes_conveyor/BoxSubvolumesConveyorDeviceDriver.java @@ -192,79 +192,88 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i requireSucess = false; } if (move != 0 && task > 0) { - if (null!=inst) { + if (null != inst) { inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code(); - } update_instruction_status(); + } + update_instruction_status(); + } + + if (move != last_move && move == 0 && last_move == 1) { + requireSucess = false; + clearWrite(); + } + + + if (mode == 0) { + this.setIsonline(false); + + } else { + this.setIsonline(true); + this.setIserror(false); + if (error != 0) { + this.setIserror(true); + message = "有报警"; + } + + Instruction instruction = null; + List toInstructions; + + switch (mode) { + case 1: + log.debug("设备运转模式:等待工作"); + break; + case 19: + //申请AGV任务 + if (move == 1 && !requireSucess) { + if (StrUtil.isEmpty(material_barcode)) { + message = "条码为空"; + } else { + applyAgvTask(); + } + + } + break; + case 2: + //申请任务 + if (move > 0 && !requireSucess) { + instruction_require(); + } else { + String remark = ""; + ; + if (mode != 2) { + remark = "universal_remark2"; + } + if (move != 0) { + remark = "universal_remark3"; + } + if (task != 0) { + remark = "universal_remark4"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = "universal_remark5"; + } + this.setNotCreateInstMessage(remark); + //} + } + break; + } } } catch (Exception var17) { + this.iserror = true; + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(this.device_code + "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + var17.printStackTrace(); - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); } - if (move != last_move && move == 0 && last_move == 1) { - requireSucess = false; - clearWrite(); - } - - - if (mode == 0) { - this.setIsonline(false); - - } else { - this.setIsonline(true); - this.setIserror(false); - if (error != 0) { - this.setIserror(true); - message = "有报警"; - } - - Instruction instruction = null; - List toInstructions; - - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 19: - //申请AGV任务 - if (move == 1 && !requireSucess) { - if (StrUtil.isEmpty(material_barcode)) { - message = "条码为空"; - }else { - applyAgvTask(); - } - - } - break; - case 2: - //申请任务 - if (move > 0 && !requireSucess) { - instruction_require(); - } else { - String remark = ""; - ; - if (mode != 2) { - remark = "universal_remark2"; - } - if (move != 0) { - remark = "universal_remark3"; - } - if (task != 0) { - remark = "universal_remark4"; - if (ObjectUtil.isNotEmpty(this.inst)) { - this.inst = null; - } - } - if (requireSucess) { - remark = "universal_remark5"; - } - this.setNotCreateInstMessage(remark); - //} - } - break; - } - } last_mode = mode; last_move = move; last_carrier_direction = carrier_direction; @@ -298,6 +307,7 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i this.writing(list); message = null; vehicle_code = null; + inst_message = null; } @@ -388,9 +398,9 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i this.writing(list); logServer.deviceExecuteLog(this.device_code, "", "", "申请AGV任务,返回参数:" + jo); requireSucess = true; - }else { + } else { message = "申请AGV任务报错,参数,接口返回:" + jo; - this.iserror = false; + this.iserror = true; } } @@ -424,6 +434,7 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i itemMap.put(to_command, command); this.control(itemMap); } + @Override public JSONObject getDeviceStatusName() { JSONObject jo = new JSONObject(); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableDeviceDriver.java index 43585d2ef..6b7c55273 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/FinishedProductOutBindLableDeviceDriver.java @@ -200,105 +200,113 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr if (move != 0 && task > 0) { update_instruction_status(); } + if (move != last_move && move==0 && last_move==1) { + requireSucess = false; + clearWrite(); + } + + + if (mode == 0) { + this.setIsonline(false); + message = "脱机"; + + //有报警 + + } else { + this.setIsonline(true); + this.setIserror(false); + if (error != 0) { + this.setIserror(true); + message = "有警报"; + } + + Instruction instruction = null; + List toInstructions; + + switch (mode) { + case 1: + log.debug("设备运转模式:等待工作"); + break; + case 2: + //申请任务 + if (move > 0 && !requireSucess) { + instruction_require(); + }else { + String remark = ""; + ; + if (mode != 2) { + remark = "universal_remark2"; + } + if (move != 0) { + remark = "universal_remark3"; + } + if (task != 0) { + remark = "universal_remark4"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = "universal_remark5"; + } + this.setNotCreateInstMessage(remark); + //} + } + break; + case 5: + //申请贴标 + applyLabeling(mode); + break; + case 10: + //申请捆轧贴标信息 + if (move > 0 && !requireSucess) { + applyLaStrangulationAndLabeling(mode); + } + break; + case 12: + //申请贴标(未贴标) + applyLabeling(mode); + break; + case 13: + //申请捆轧贴标信息(未捆扎) + if (move > 0 && !requireSucess) { + applyLaStrangulationAndLabeling(mode); + } + break; + case 14: + //申请捆轧贴标信息(未贴标) + if (move > 0 && !requireSucess) { + applyLaStrangulationAndLabeling(mode); + } + break; + case 16: + //申请捆轧贴标信息(未贴标,未捆扎) + if (move > 0 && !requireSucess) { + applyLaStrangulationAndLabeling(mode); + } + case 17: + //申请调试贴标 + if(move > 0 && !requireSucess){ + applyLaStrangulationAndLabeling(mode); + } + break; + } + } } catch (Exception var17) { + this.iserror = true; + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(this.device_code + "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + var17.printStackTrace(); - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); } - if (move != last_move && move==0 && last_move==1) { - requireSucess = false; - clearWrite(); - } - - if (mode == 0) { - this.setIsonline(false); - message = "脱机"; - - //有报警 - - } else { - this.setIsonline(true); - this.setIserror(false); - if (error != 0) { - this.setIserror(true); - message = "有警报"; - } - - Instruction instruction = null; - List toInstructions; - - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 2: - //申请任务 - if (move > 0 && !requireSucess) { - instruction_require(); - }else { - String remark = ""; - ; - if (mode != 2) { - remark = "universal_remark2"; - } - if (move != 0) { - remark = "universal_remark3"; - } - if (task != 0) { - remark = "universal_remark4"; - if (ObjectUtil.isNotEmpty(this.inst)) { - this.inst = null; - } - } - if (requireSucess) { - remark = "universal_remark5"; - } - this.setNotCreateInstMessage(remark); - //} - } - break; - case 5: - //申请贴标 - applyLabeling(mode); - break; - case 10: - //申请捆轧贴标信息 - if (move > 0 && !requireSucess) { - applyLaStrangulationAndLabeling(mode); - } - break; - case 12: - //申请贴标(未贴标) - applyLabeling(mode); - break; - case 13: - //申请捆轧贴标信息(未捆扎) - if (move > 0 && !requireSucess) { - applyLaStrangulationAndLabeling(mode); - } - break; - case 14: - //申请捆轧贴标信息(未贴标) - if (move > 0 && !requireSucess) { - applyLaStrangulationAndLabeling(mode); - } - break; - case 16: - //申请捆轧贴标信息(未贴标,未捆扎) - if (move > 0 && !requireSucess) { - applyLaStrangulationAndLabeling(mode); - } - case 17: - //申请调试贴标 - if(move > 0 && !requireSucess){ - applyLaStrangulationAndLabeling(mode); - } - break; - } - } last_mode = mode; last_move = move; last_carrier_direction = carrier_direction; @@ -330,6 +338,7 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr this.writing(list); message=null; + inst_message = null; } private void applyLaStrangulationAndLabeling(int mode) { @@ -368,7 +377,7 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr packagePLCData(jo.getString("data"), mode); requireSucess = true; } else { - this.iserror = false; + this.iserror = true; LuceneLogDto logDto2 = LuceneLogDto.builder() .device_code(device_code) .content("申请捆扎失败,接口返回:" + response) diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/ItemProtocol.java index b511bfb3e..9c7b234ea 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/finished_product_out_with_bind_lable_conveyor/ItemProtocol.java @@ -205,7 +205,7 @@ public class ItemProtocol { } else { return value; } - return "0"; + return ""; } public static List getReadableItemDtos() { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/FoldDiscSiteDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/FoldDiscSiteDeviceDriver.java index 0b4fd52f2..1d0c8837c 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/FoldDiscSiteDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/FoldDiscSiteDeviceDriver.java @@ -18,6 +18,7 @@ import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.FeedLmsRealFailed; import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; import org.nl.acs.enums.StorageTypeEnum; @@ -197,101 +198,109 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements if (move != 0 && task > 0) { update_instruction_status(); } + if (move != last_move && move == 0 && last_move == 1) { + requireSucess = false; + clearWrite(); + } + + + //托盘去扫码位 + if (mode == 4) { + List list1 = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_command"); + map.put("value", 0); + list1.add(map); + this.writing(list1); + } + + if (mode == 0) { + this.setIsonline(false); + message = "脱机"; + + //有报警 + } else if (error != 0) { + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + + //申请空托盘入库 + if (mode == 9 && move == 1 && !requireSucess) { + if (container_type == 0) { + message = "托盘类型为空"; + } else { + applyEmptyTask(StorageTypeEnum.DISKS_IN.getType(), mode); + } + } + + + //申请空托盘出库 + if (mode == 8 && !requireSucess) { + if (container_type == 0) { + message = "托盘类型为空"; + } else { + applyEmptyTask(StorageTypeEnum.DISKS_OUT.getType(), mode); + } + + } + + + //碟盘位申请任务 + if (mode == 2 && move == 1 && !requireSucess) { + boolean res = instruction_require(); + if (res) { + notCreateInstMessage = ""; + notCreateTaskMessage = ""; + feedMessage = ""; + } + } else { + if (mode == 2) { + //if (!requireSucess) { + String remark = ""; + ; + if (mode != 2) { + remark = "universal_remark2"; + } + if (move != 0) { + remark = "universal_remark3"; + } + if (task != 0) { + remark = LangProcess.msg("universal_remark4"); + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = LangProcess.msg("universal_remark5"); + } + this.setNotCreateTaskMessage(remark); + //} + } + } + + } } catch (Exception var17) { + this.iserror = true; + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(this.device_code + "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + var17.printStackTrace(); - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); } - if (move != last_move && move == 0 && last_move == 1) { - requireSucess = false; - clearWrite(); - } - - //托盘去扫码位 - if (mode == 4) { - List list1 = new ArrayList(); - Map map = new HashMap(); - map.put("code", "to_command"); - map.put("value", 0); - list1.add(map); - this.writing(list1); - } - - if (mode == 0) { - this.setIsonline(false); - message = "脱机"; - - //有报警 - } else if (error != 0) { - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - - //申请空托盘入库 - if (mode == 9 && move == 1 && !requireSucess) { - if (container_type == 0) { - message = "托盘类型为空"; - } else { - applyEmptyTask(StorageTypeEnum.DISKS_IN.getType(), mode); - } - } - - - //申请空托盘出库 - if (mode == 8 && !requireSucess) { - if (container_type == 0) { - message = "托盘类型为空"; - } else { - applyEmptyTask(StorageTypeEnum.DISKS_OUT.getType(), mode); - } - - } - - - //碟盘位申请任务 - if (mode == 2 && move == 1 && !requireSucess) { - boolean res = instruction_require(); - if (res) { - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - feedMessage = ""; - } - } else { - if (mode == 2) { - //if (!requireSucess) { - String remark = ""; - ; - if (mode != 2) { - remark = "universal_remark2"; - } - if (move != 0) { - remark = "universal_remark3"; - } - if (task != 0) { - remark = LangProcess.msg("universal_remark4"); - if (ObjectUtil.isNotEmpty(this.inst)) { - this.inst = null; - } - } - if (requireSucess) { - remark = LangProcess.msg("universal_remark5"); - } - this.setNotCreateTaskMessage(remark); - //} - } - } - - } last_mode = mode; last_move = move; last_action = action; @@ -325,6 +334,7 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements this.writing(list); message = null; vehicle_code = null; + inst_message = null; } @@ -418,9 +428,28 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements requireSucess = false; return true; } + //关联站点判断 + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + BeltConveyorDeviceDriver beltConveyorDeviceDriver; + if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { + beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver(); + //判断对接位和关联站点光电信号 + getDeviceCodeList = beltConveyorDeviceDriver.getExtraDeviceCodes("link_device_code"); + if (CollUtil.isNotEmpty(getDeviceCodeList)) { + String linkDeviceCode = getDeviceCodeList.get(0); + Device linkDevice = deviceAppService.findDeviceByCode(linkDeviceCode); + BeltConveyorDeviceDriver linkDeviceDriver; + if (linkDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { + linkDeviceDriver = (BeltConveyorDeviceDriver) linkDevice.getDeviceDriver(); + if ((beltConveyorDeviceDriver.getMode() == 0 || beltConveyorDeviceDriver.getMove() == 1) || (linkDeviceDriver.getMode() == 0 || linkDeviceDriver.getMove() == 1)) { + this.message = "DDJ对接位或关联输送线存在正在移动的货物或者未联机"; + requireSucess = false; + return true; + } + } - Device startdevice = deviceAppservice.findDeviceByCode(start_device_code); - Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code); + } + } String next_point_code; if (StrUtil.equals(deviceAppservice.findDeviceTypeByCode(next_device_code), "storage")) { next_point_code = taskdto.getTo_x() + "-" + taskdto.getTo_y() + "-" + taskdto.getTo_z(); @@ -457,7 +486,7 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex()); taskserver.update(taskdto); requireSucess = true; - String next_addr = nextdevice.getExtraValue().get("address").toString(); + String next_addr = nextDevice.getExtraValue().get("address").toString(); List list = new ArrayList(); Map map = new HashMap(); @@ -610,7 +639,7 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements this.writing(list1); this.requireSucess = true; } else { - this.iserror = false; + this.iserror = true; message = "申请空托盘出入库报错,接口返回:" + jo; LuceneLogDto logDto2 = LuceneLogDto.builder() .device_code(device_code) diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/ItemProtocol.java index 04161b0b8..79e29d781 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/fold_disc_site/ItemProtocol.java @@ -123,7 +123,7 @@ public class ItemProtocol { } else { return value; } - return "0"; + return ""; } public static List getReadableItemDtos() { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java index 6a0b61b4a..7428930ee 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ConveyorWithScannerWeightDeviceDriver.java @@ -278,105 +278,113 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv update_instruction_status(); } - } catch (Exception e) { - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + Arrays.toString(e.getStackTrace())); - - } - - if (mode == 0) { - this.setIsonline(false); - //有报警 - } else if (error != 0) { - this.setIserror(true); - message = "有报警"; - //申请异常位任务 - applyErrorTask(); - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - //木箱入库申请入库任务 - if (mode == 6 && !requireSucess) { - if (StrUtil.isEmpty(barcode) || StrUtil.isEmpty(material_barcode)) { - message = "托盘条码为空、或者子卷码为空"; - } else { - applyIn(StorageTypeEnum.BOX_IN.getType(), mode); - } - - } - - //子卷入库申请入库任务 - if (mode == 7 && move == 1 && !requireSucess) { - if (StrUtil.isEmpty(barcode) || StrUtil.isEmpty(material_barcode)) { - message = "托盘条码为空、或者子卷码为空"; - } else { - applyIn(StorageTypeEnum.STORAGE.getType(), mode); - } - - } - - - //申请空托盘入库 - if (mode == 9 && move == 1 && !requireSucess) { - if (container_type == 0 || StrUtil.isEmpty(barcode)) { - message = "托盘类型为空"; - } else { - applyEmptyTask(StorageTypeEnum.DISKS_IN.getType(), mode); - } - } - - //申请退货入库 - if (mode == 18 && move == 1 && !requireSucess) { - if (StrUtil.isEmpty(barcode)) { - message = "托盘条码为空"; - } else { - applyBoxReturnTask(StorageTypeEnum.BOX_RETURN.getType(), mode); - } - - } - //申请高度 - if (mode == 23 && !requireSucess) { - if (StrUtil.isEmpty(barcode) || StrUtil.isEmpty(material_barcode)) { - message = "条码为空"; - } else { - applyErrorHeight(); - } - - } - - //申请入库指令、异常位指令 - if (mode == 2 && move == 1 && !requireSucess) { - boolean res = instruction_require(); - if (res) { - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - feedMessage = ""; - } + if (mode == 0) { + this.setIsonline(false); + //有报警 + } else if (error != 0) { + this.setIserror(true); + message = "有报警"; + //申请异常位任务 + applyErrorTask(); } else { - String remark = ""; - ; - if (mode != 2) { - remark = "universal_remark2"; + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + //木箱入库申请入库任务 + if (mode == 6 && !requireSucess) { + if (StrUtil.isEmpty(barcode) || StrUtil.isEmpty(material_barcode)) { + message = "托盘条码为空、或者子卷码为空"; + } else { + applyIn(StorageTypeEnum.BOX_IN.getType(), mode); + } + } - if (move != 0) { - remark = "universal_remark3"; + + //子卷入库申请入库任务 + if (mode == 7 && move == 1 && !requireSucess) { + if (StrUtil.isEmpty(barcode) || StrUtil.isEmpty(material_barcode)) { + message = "托盘条码为空、或者子卷码为空"; + } else { + applyIn(StorageTypeEnum.STORAGE.getType(), mode); + } + } - if (task != 0) { - remark = "universal_remark4"; - if (ObjectUtil.isNotEmpty(this.inst)) { - this.inst = null; + + + //申请空托盘入库 + if (mode == 9 && move == 1 && !requireSucess) { + if (container_type == 0 || StrUtil.isEmpty(barcode)) { + message = "托盘类型为空"; + } else { + applyEmptyTask(StorageTypeEnum.DISKS_IN.getType(), mode); } } - if (requireSucess) { - remark = "universal_remark5"; - } - this.setNotCreateInstMessage(remark); - //} - } + //申请退货入库 + if (mode == 18 && move == 1 && !requireSucess) { + if (StrUtil.isEmpty(barcode)) { + message = "托盘条码为空"; + } else { + applyBoxReturnTask(StorageTypeEnum.BOX_RETURN.getType(), mode); + } + + } + //申请高度 + if (mode == 23 && !requireSucess) { + if (StrUtil.isEmpty(barcode) || StrUtil.isEmpty(material_barcode)) { + message = "条码为空"; + } else { + applyErrorHeight(); + } + + } + + //申请入库指令、异常位指令 + if (mode == 2 && move == 1 && !requireSucess) { + boolean res = instruction_require(); + if (res) { + notCreateInstMessage = ""; + notCreateTaskMessage = ""; + feedMessage = ""; + } + } else { + String remark = ""; + ; + if (mode != 2) { + remark = "universal_remark2"; + } + if (move != 0) { + remark = "universal_remark3"; + } + if (task != 0) { + remark = "universal_remark4"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = "universal_remark5"; + } + this.setNotCreateInstMessage(remark); + //} + } + + } + } catch (Exception e) { + this.iserror = true; + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(this.device_code + "读取信号值时出现异常:" + e.getMessage() + ",this.itemProtocol is null") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + + e.printStackTrace(); } + + last_mode = mode; last_move = move; last_action = action; @@ -447,6 +455,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv this.writing(list2); requireSucess = true; } else { + this.iserror = true; LuceneLogDto logDto2 = LuceneLogDto.builder() .device_code(device_code) .content("申请高度等级,返回参数:" + response) @@ -508,6 +517,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv this.writing(list1); this.requireSucess = true; } else { + this.iserror = true; LuceneLogDto logDto2 = LuceneLogDto.builder() .device_code(device_code) .content("申请退货入库,返回参数:" + response) @@ -541,6 +551,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv message = null; vehicle_code = null; hand_barcode = null; + inst_message = null; } @@ -618,7 +629,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv this.writing(list1); this.requireSucess = true; } else { - this.iserror = false; + this.iserror = true; message = "申请空托盘出入库报错,返回参数:" + jo; LuceneLogDto logDto2 = LuceneLogDto.builder() .device_code(device_code) @@ -683,7 +694,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv this.writing(list1); requireSucess = true; } else { - this.iserror = false; + this.iserror = true; LuceneLogDto logDto2 = LuceneLogDto.builder() .device_code(device_code) .content("木箱、子卷入库申请入库任务,返回参数:" + response) @@ -753,6 +764,10 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv TaskDto taskdto = taskserver.findByVehicleCodeCodeAndReady(hand_barcode); if (!ObjectUtil.isEmpty(taskdto)) { if (creatInstruction(taskdto)) return false; + } else { + //如果不存在则直接找对应指令直接下发信号 + if (pushPLC()) return false; + } } else { if (StrUtil.isNotBlank(barcode)) { @@ -760,6 +775,10 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv TaskDto taskdto = taskserver.findByVehicleCodeCodeAndReady(barcode); if (!ObjectUtil.isEmpty(taskdto)) { if (creatInstruction(taskdto)) return false; + }else { + //如果不存在则直接找对应指令直接下发信号 + if (pushPLC()) return false; + } } } @@ -767,6 +786,52 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv } } + private boolean pushPLC() { + Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code); + if (ObjectUtil.isEmpty(inst)) { + return true; + } + + Device nextdevice = deviceAppservice.findDeviceByCode(inst.getNext_device_code()); + String next_addr = nextdevice.getExtraValue().get("address").toString(); + + List list = new ArrayList(); + Map map = new HashMap(); + map.put("code", "to_target"); + map.put("value", next_addr); + list.add(map); + Map map2 = new HashMap(); + map2.put("code", "to_task"); + map2.put("value", inst.getInstruction_code()); + list.add(map2); + Map map3 = new HashMap(); + map3.put("code", "to_command"); + map3.put("value", "1"); + list.add(map3); + this.writing(list); + requireSucess = true; + while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString() + , inst.getInstruction_code())) { + this.writing(list); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code + inst.getInstruction_code() + "再次下发电气信号") + .build(); + logDto.setLog_level(3); + luceneExecuteLogService.deviceExecuteLog(logDto); + try { + Thread.sleep(500); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (ObjectUtil.isEmpty(instructionService.findByDeviceCodeFromCache(this.device_code))) { + requireSucess = false; + return true; + } + } + return false; + } + private boolean creatInstruction(TaskDto taskdto) { String taskid = taskdto.getTask_id(); String taskcode = taskdto.getTask_code(); @@ -802,6 +867,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv requireSucess = false; return true; } + //关联站点判断 Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); BeltConveyorDeviceDriver beltConveyorDeviceDriver; if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { @@ -814,7 +880,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv BeltConveyorDeviceDriver linkDeviceDriver; if (linkDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { linkDeviceDriver = (BeltConveyorDeviceDriver) linkDevice.getDeviceDriver(); - if ((beltConveyorDeviceDriver.getMode() == 0 || beltConveyorDeviceDriver.getMove() == 1) && (linkDeviceDriver.getMode() == 0 || linkDeviceDriver.getMove() == 1)) { + if ((beltConveyorDeviceDriver.getMode() == 0 || beltConveyorDeviceDriver.getMove() == 1) || (linkDeviceDriver.getMode() == 0 || linkDeviceDriver.getMove() == 1)) { this.message = "DDJ对接位或关联输送线存在正在移动的货物或者未联机"; requireSucess = false; return true; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ItemProtocol.java index ff6736587..80be9bce6 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/scanner_weight_conveyor/ItemProtocol.java @@ -166,7 +166,7 @@ public class ItemProtocol { } else { return value; } - return "0"; + return ""; } public int getOpcIntegerValue(String protocol) { @@ -191,7 +191,7 @@ public class ItemProtocol { setIsonline(true); return value; } - return 0; + return value; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/ItemProtocol.java index 909d2492e..32abccf20 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/ItemProtocol.java @@ -189,7 +189,7 @@ public class ItemProtocol { } else { return value; } - return "0"; + return ""; } public static List getReadableItemDtos() { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java index e9bf657d8..cef1b3ca3 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_conveyor/un_box_lable_conveyor/UnBoxLableConveyorDeviceDriver.java @@ -178,48 +178,55 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl to_target = this.itemProtocol.getTo_target(); to_task = this.itemProtocol.getTo_task(); heartbeat = this.itemProtocol.getHeartbeat(); + if (mode != last_mode) { - } catch (Exception e) { - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + Arrays.toString(e.getStackTrace())); - - } - - if (mode != last_mode) { - - requireSucess = false; - } - if (mode == 0) { - this.setIsonline(false); - message = "脱机"; - - //有报警 - - } else { - this.setIsonline(true); - this.setIserror(false); - if (error != 0) { - this.setIserror(true); - message = "有报警"; - } - inst = checkInst(); - if (inst != null) { - inst_message = "当前指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); + requireSucess = false; } + if (mode == 0) { + this.setIsonline(false); + message = "脱机"; - Instruction instruction = instructionService.findByCode(String.valueOf(task)); - //空箱出库开盖位,申请开盖 - if (mode == 15 && move == 1 && task > 0 ) { - //不允许开盖,完成出库任务,自动去扫码位 - if (StrUtil.isEmpty(instruction.getVehicle_code())){ - message = "任务托盘码为空"; + //有报警 + + } else { + this.setIsonline(true); + this.setIserror(false); + if (error != 0) { + this.setIserror(true); + message = "有报警"; + } + inst = checkInst(); + if (inst != null) { + inst_message = "当前指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); } - applyUnbox(instruction.getVehicle_code()); + Instruction instruction = instructionService.findByCode(String.valueOf(task)); + //空箱出库开盖位,申请开盖 + if (mode == 15 && move == 1 && task > 0 ) { + //不允许开盖,完成出库任务,自动去扫码位 + if (StrUtil.isEmpty(instruction.getVehicle_code())){ + message = "任务托盘码为空"; + } + applyUnbox(instruction.getVehicle_code()); + + } } + } catch (Exception e) { + this.iserror = true; + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(this.device_code + "读取信号值时出现异常:" + e.getMessage() + ",this.itemProtocol is null") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + + e.printStackTrace(); } + + last_mode =mode; last_move =move; last_carrier_direction =carrier_direction; @@ -285,8 +292,14 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl } }else { + LuceneLogDto logDto2 = LuceneLogDto.builder() + .device_code(device_code) + .content("木箱开盖报错,接口返回:" + response) + .build(); + logDto2.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto2); message = "木箱开盖报错,返回参数:" + jo; - this.iserror = false; + this.iserror = true; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_package_manipulator/BoxPackageManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_package_manipulator/BoxPackageManipulatorDeviceDriver.java index c608b2a05..343524224 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_package_manipulator/BoxPackageManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_package_manipulator/BoxPackageManipulatorDeviceDriver.java @@ -164,7 +164,6 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i @Override public void execute() { - String message = null; try { device_code = this.getDeviceCode(); mode = this.itemProtocol.getMode(); @@ -195,59 +194,66 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i } updateInstrction(); } + if (mode == 0) { + this.setIsonline(false); + message = "universal_off-line"; - } catch (Exception e) { - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + Arrays.toString(e.getStackTrace())); + //有报警 + } else if (error != 0) { + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; - } - - if (mode == 0) { - this.setIsonline(false); - message = "universal_off-line"; - - //有报警 - } else if (error != 0) { - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - - //行架机械手申请任务 - if (mode == 2 && move == 0 && !requireSucess) { - boolean res = applyTask(); - if (res) { - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - feedMessage = ""; - } - }else { - String remark = ""; - ; - if (mode != 2) { - remark = "universal_remark2"; - } - if (move != 0) { - remark = "universal_remark3"; - } - if (task != 0) { - remark = "universal_remark4"; - if (ObjectUtil.isNotEmpty(this.inst)) { - this.inst = null; + //行架机械手申请任务 + if (mode == 2 && move == 0 && !requireSucess) { + boolean res = applyTask(); + if (res) { + notCreateInstMessage = ""; + notCreateTaskMessage = ""; + feedMessage = ""; } + }else { + String remark = ""; + ; + if (mode != 2) { + remark = "universal_remark2"; + } + if (move != 0) { + remark = "universal_remark3"; + } + if (task != 0) { + remark = "universal_remark4"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = "universal_remark5"; + } + this.setNotCreateInstMessage(remark); + //} } - if (requireSucess) { - remark = "universal_remark5"; - } - this.setNotCreateInstMessage(remark); - //} - } + } + } catch (Exception e) { + this.iserror = true; + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(this.device_code + "读取信号值时出现异常:" + e.getMessage() + ",this.itemProtocol is null") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + + e.printStackTrace(); } + + last_mode = mode; last_move = move; last_action = action; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_package_manipulator/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_package_manipulator/ItemProtocol.java index b4c2891f0..0ed37036a 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_package_manipulator/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_package_manipulator/ItemProtocol.java @@ -199,7 +199,7 @@ public class ItemProtocol { } else { return value; } - return "0"; + return ""; } public float getOpcFloatValue(String protocol) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/BoxStorageManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/BoxStorageManipulatorDeviceDriver.java index 15c67264a..338fd3362 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/BoxStorageManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/BoxStorageManipulatorDeviceDriver.java @@ -136,7 +136,6 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i @Override public void execute() { - String message = null; try { device_code = this.getDeviceCode(); mode = this.itemProtocol.getMode(); @@ -165,64 +164,68 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i } updateInstructionStatus(); } + if (mode == 0) { + this.setIsonline(false); + message = "universal_off-line"; - } catch (Exception e) { - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("读取信号值时出现异常" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + Arrays.toString(e.getStackTrace())) - .build(); - logDto.setLog_level(2); - luceneExecuteLogService.deviceExecuteLog(logDto); - - } - - if (mode == 0) { - this.setIsonline(false); - message = "universal_off-line"; - - //有报警 - } else if (error != 0) { - this.setIserror(true); - message = "universal_message3"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - - //行架机械手申请任务 - if (mode == 2 && move == 0 && task == 0 && !requireSucess) { - boolean res = applyTask(); - if (res) { - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - feedMessage = ""; - } + //有报警 + } else if (error != 0) { + this.setIserror(true); + message = "universal_message3"; + //无报警 } else { - String remark = ""; - ; - if (mode != 2) { - remark = "universal_remark2"; - } - if (move != 0) { - remark = "universal_remark3"; - } - if (task != 0) { - remark = "universal_remark4"; - if (ObjectUtil.isNotEmpty(this.inst)) { - this.inst = null; + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + + //行架机械手申请任务 + if (mode == 2 && move == 0 && task == 0 && !requireSucess) { + boolean res = applyTask(); + if (res) { + notCreateInstMessage = ""; + notCreateTaskMessage = ""; + feedMessage = ""; } + } else { + String remark = ""; + ; + if (mode != 2) { + remark = "universal_remark2"; + } + if (move != 0) { + remark = "universal_remark3"; + } + if (task != 0) { + remark = "universal_remark4"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = "universal_remark5"; + } + this.setNotCreateInstMessage(remark); + //} } - if (requireSucess) { - remark = "universal_remark5"; - } - this.setNotCreateInstMessage(remark); - //} + } + } catch (Exception e) { + this.iserror = true; + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(this.device_code + "读取信号值时出现异常:" + e.getMessage() + ",this.itemProtocol is null") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + + e.printStackTrace(); + } + + last_mode =mode; last_action = action; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/ItemProtocol.java index ed75bc350..78d04d793 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/box_storage_manipulator/ItemProtocol.java @@ -209,7 +209,7 @@ public class ItemProtocol { } else { return value; } - return "0"; + return ""; } public static List getReadableItemDtos() { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/ReturnGoodManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/ReturnGoodManipulatorDeviceDriver.java index 2a4e902d2..ea1ef6f8e 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/ReturnGoodManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/return_good_manipulator/ReturnGoodManipulatorDeviceDriver.java @@ -152,7 +152,6 @@ public class ReturnGoodManipulatorDeviceDriver extends AbstractOpcDeviceDriver i @Override public void execute() { - String message = null; try { device_code = this.getDeviceCode(); mode = this.itemProtocol.getMode(); @@ -178,60 +177,68 @@ public class ReturnGoodManipulatorDeviceDriver extends AbstractOpcDeviceDriver i } updateInstructionStatus(); } + if (mode == 0) { + this.setIsonline(false); + message = "universal_off-line"; + + //有报警 + } else if (error != 0) { + this.setIserror(true); + message = "universal_message3"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + + //行架机械手申请任务 + if (mode == 2 && move == 0 && task == 0 && !requireSucess) { + boolean res = applyTask(); + if (res) { + notCreateInstMessage = ""; + notCreateTaskMessage = ""; + feedMessage = ""; + } + } else { + String remark = ""; + ; + if (mode != 2) { + remark = "universal_remark2"; + } + if (move != 0) { + remark = "universal_remark3"; + } + if (task != 0) { + remark = "universal_remark4"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = "universal_remark5"; + } + this.setNotCreateInstMessage(remark); + //} + } + + } } catch (Exception e) { - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + Arrays.toString(e.getStackTrace())); - + this.iserror = true; + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(this.device_code + "读取信号值时出现异常:" + e.getMessage() + ",this.itemProtocol is null") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + + e.printStackTrace(); } - if (mode == 0) { - this.setIsonline(false); - message = "universal_off-line"; - //有报警 - } else if (error != 0) { - this.setIserror(true); - message = "universal_message3"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - - //行架机械手申请任务 - if (mode == 2 && move == 0 && task == 0 && !requireSucess) { - boolean res = applyTask(); - if (res) { - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - feedMessage = ""; - } - } else { - String remark = ""; - ; - if (mode != 2) { - remark = "universal_remark2"; - } - if (move != 0) { - remark = "universal_remark3"; - } - if (task != 0) { - remark = "universal_remark4"; - if (ObjectUtil.isNotEmpty(this.inst)) { - this.inst = null; - } - } - if (requireSucess) { - remark = "universal_remark5"; - } - this.setNotCreateInstMessage(remark); - //} - } - - } last_mode = mode; last_move = move; last_action = action; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/standard_manipulator/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/standard_manipulator/ItemProtocol.java index b257434dc..463541857 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/standard_manipulator/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/standard_manipulator/ItemProtocol.java @@ -91,7 +91,7 @@ ItemProtocol { } else { return value; } - return "0"; + return ""; } public static List getReadableItemDtos() { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/standard_manipulator/StandardManipulatoDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/standard_manipulator/StandardManipulatoDeviceDriver.java index ca1adc0b7..ae2c2e809 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/standard_manipulator/StandardManipulatoDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/standard_manipulator/StandardManipulatoDeviceDriver.java @@ -163,32 +163,38 @@ public class StandardManipulatoDeviceDriver extends AbstractOpcDeviceDriver impl if (mode != last_mode) { requireSucess = false; } + if (mode == 0) { + this.setIsonline(false); + message = "universal_off-line"; + //有报警 + } else if (error != 0) { + this.setIserror(true); + message = "universal_message3"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + + } + } catch (Exception var17) { + this.iserror = true; + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(this.device_code + "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); var17.printStackTrace(); - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); } - if (mode == 0) { - this.setIsonline(false); - message = "universal_off-line"; - //有报警 - } else if (error != 0) { - this.setIserror(true); - message = "universal_message3"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - - - } last_mode = mode; last_move = move; last_action = action; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/TrappedManipulatorManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/TrappedManipulatorManipulatorDeviceDriver.java index c43eb1975..3af5f930c 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/TrappedManipulatorManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/trapped_manipulator/TrappedManipulatorManipulatorDeviceDriver.java @@ -147,7 +147,6 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice @Override public void execute() { - String message = null; try { device_code = this.getDeviceCode(); mode = this.itemProtocol.getMode(); @@ -173,60 +172,64 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice } updateInstructionStatus(); } - - } catch (Exception var17) { - var17.printStackTrace(); - // feedMessage = var17.getMessage(); - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); - - } - - if (mode == 0) { - this.setIsonline(false); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - - //行架机械手申请任务 - if (mode == 2 && move == 0 && task == 0 && !requireSucess) { - boolean res = applyTask(); - if (res) { - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - feedMessage = ""; - } + if (mode == 0) { + this.setIsonline(false); + //有报警 + } else if (error != 0) { + this.setIserror(true); + message = "universal_message3"; + //无报警 } else { - String remark = ""; - ; - if (mode != 2) { - remark = "universal_remark2"; - } - if (move != 0) { - remark = "universal_remark3"; - } - if (task != 0) { - remark = "universal_remark4"; - if (ObjectUtil.isNotEmpty(this.inst)) { - this.inst = null; + this.setIsonline(true); + this.setIserror(false); + Instruction instruction = null; + List toInstructions; + + //行架机械手申请任务 + if (mode == 2 && move == 0 && task == 0 && !requireSucess) { + boolean res = applyTask(); + if (res) { + notCreateInstMessage = ""; + notCreateTaskMessage = ""; + feedMessage = ""; } + } else { + String remark = ""; + ; + if (mode != 2) { + remark = "universal_remark2"; + } + if (move != 0) { + remark = "universal_remark3"; + } + if (task != 0) { + remark = "universal_remark4"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = "universal_remark5"; + } + this.setNotCreateInstMessage(remark); + //} } - if (requireSucess) { - remark = "universal_remark5"; - } - this.setNotCreateInstMessage(remark); - //} + } + } catch (Exception var17) { + this.iserror = true; + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(this.device_code + "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + var17.printStackTrace(); + } + + last_mode = mode; last_move = move; last_action = action; @@ -401,10 +404,18 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice } - BeltConveyorDeviceDriver beltConveyorDeviceDriver; + BeltConveyorDeviceDriver beltConveyorDeviceDriverStart; + BeltConveyorDeviceDriver beltConveyorDeviceDriverEnd; if (startDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { - beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) startDevice.getDeviceDriver(); - if (beltConveyorDeviceDriver.getMove() != 1 && beltConveyorDeviceDriver.getMode() != 2) { + beltConveyorDeviceDriverStart = (BeltConveyorDeviceDriver) startDevice.getDeviceDriver(); + if (beltConveyorDeviceDriverStart.getMove() != 1 && beltConveyorDeviceDriverStart.getMode() != 2) { + notCreateInstMessage = "universal_notCreateInstMessage2"; + return false; + } + } + if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) { + beltConveyorDeviceDriverEnd = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver(); + if (beltConveyorDeviceDriverEnd.getMove() != 1 && beltConveyorDeviceDriverEnd.getMode() != 2) { notCreateInstMessage = "universal_notCreateInstMessage2"; return false; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/volume_two_manipulator/VolumeTwoManipulatorManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/volume_two_manipulator/VolumeTwoManipulatorManipulatorDeviceDriver.java index a27486c0e..2db780f9b 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/volume_two_manipulator/VolumeTwoManipulatorManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/one_manipulator/volume_two_manipulator/VolumeTwoManipulatorManipulatorDeviceDriver.java @@ -167,7 +167,6 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi @Override public void execute() { - String message = null; try { device_code = this.getDeviceCode(); mode = this.itemProtocol.getMode(); @@ -211,60 +210,67 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi Integer actionType = ActionTypeEnum.IN_FINISHING.getCode(); creatAGV(actionType, action); } + if (mode == 0) { + this.setIsonline(false); + message = "universal_off-line"; - } catch (Exception var17) { - var17.printStackTrace(); - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); - - } - - if (mode == 0) { - this.setIsonline(false); - message = "universal_off-line"; - - //有报警 - } else if (error != 0) { - this.setIserror(true); - message = "universal_message3"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - - //行架机械手申请任务 - if (mode == 2 && move == 0 && task == 0 && !requireSucess) { - boolean res = applyTask(); - if (res) { - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - feedMessage = ""; - } + //有报警 + } else if (error != 0) { + this.setIserror(true); + message = "universal_message3"; + //无报警 } else { - String remark = ""; - ; - if (mode != 2) { - remark = "universal_remark2"; - } - if (move != 0) { - remark = "universal_remark3"; - } - if (task != 0) { - remark = "universal_remark4"; - if (ObjectUtil.isNotEmpty(this.inst)) { - this.inst = null; + this.setIsonline(true); + this.setIserror(false); + message = ""; + Instruction instruction = null; + List toInstructions; + + //行架机械手申请任务 + if (mode == 2 && move == 0 && task == 0 && !requireSucess) { + boolean res = applyTask(); + if (res) { + notCreateInstMessage = ""; + notCreateTaskMessage = ""; + feedMessage = ""; } + } else { + String remark = ""; + ; + if (mode != 2) { + remark = "universal_remark2"; + } + if (move != 0) { + remark = "universal_remark3"; + } + if (task != 0) { + remark = "universal_remark4"; + if (ObjectUtil.isNotEmpty(this.inst)) { + this.inst = null; + } + } + if (requireSucess) { + remark = "universal_remark5"; + } + this.setNotCreateInstMessage(remark); + //} } - if (requireSucess) { - remark = "universal_remark5"; - } - this.setNotCreateInstMessage(remark); - //} + } + } catch (Exception var17) { + this.iserror = true; + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(this.device_code + "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + var17.printStackTrace(); + } + + last_mode = mode; last_move = move; last_action = action; @@ -290,7 +296,7 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi param.put("actionType",actionType ); LuceneLogDto logDto = LuceneLogDto.builder() .device_code(device_code) - .content("行架取放货完成请求lms,参数:" + task + "--" +ActionTypeEnum.RELEASE_FINISHING.getStatus()) + .content("行架取放货完成请求lms,参数:" + task + "--" +ActionTypeEnum.getStatus(actionType)) .build(); logDto.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(logDto); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/ItemProtocol.java index e40088514..2ab327c17 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/ItemProtocol.java @@ -280,7 +280,7 @@ public class ItemProtocol { String value = this.driver.getStringValue(protocol); if (value == null) { setIsonline(false); - return "0"; + return ""; } else { setIsonline(true); return value; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java index 05b13c410..e44c66c98 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/StandardStackerDeviceDriver.java @@ -9,6 +9,9 @@ import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.common.base.CommonFinalParam; +import org.nl.acs.custompolicy.CustomerStragetyCacheService; +import org.nl.acs.custompolicy.StackerInstruction; +import org.nl.acs.custompolicy.StackerStrategyDto; import org.nl.acs.device.domain.Device; import org.nl.acs.device.enums.DeviceType; import org.nl.acs.device.service.DeviceExtraService; @@ -19,6 +22,7 @@ import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver; import org.nl.acs.device_driver.conveyor.siemens_conveyor.SiemensConveyorDeviceDriver; import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.device_driver.stacker.standard_stacker.enums.CustomPolicyTaskTypeEnum; import org.nl.acs.device_driver.storage.standard_storage.StandardStorageDeviceDriver; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; @@ -46,7 +50,9 @@ import org.nl.config.lucene.service.dto.LuceneLogDto; import org.springframework.beans.factory.annotation.Autowired; import java.util.*; +import java.util.concurrent.LinkedBlockingQueue; import java.util.regex.Pattern; +import java.util.stream.Collectors; /** * 单工位堆垛机驱动 @@ -80,6 +86,9 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme @Autowired private RedisUtils redisUtils; + + private CustomerStragetyCacheService customerStragetyCacheService = SpringContextHolder.getBean(CustomerStragetyCacheService.class);; + /** * 禁止入库 */ @@ -270,6 +279,9 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme List getDeviceCodeList = null; List putDeviceCodeList = null; + + + /** * 请求成功标记 */ @@ -295,7 +307,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme Boolean iserror = false; String inst_message; - + //阻塞队列,保证指令顺序执行 + LinkedBlockingQueue tackerInstructionQueue = new LinkedBlockingQueue<>(); @Override public Device getDevice() { @@ -333,16 +346,14 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } } - // 更新指令状态 if (mode == 3 && task > 0 && command == 1 && error == 0) { - if (null!=inst) { + if (null != inst) { inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code(); } Date date = new Date(); if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) { log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out); - } else { this.instruction_update_time = date; //更改指令状态 @@ -358,211 +369,218 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } } } + //不同任务限制清零 + if (!Objects.equals(task, last_task)) { + this.isonline = true; + count = 0; + } + + if (mode == 0 || command == 9) { + this.setIsonline(false); + message = "universal_off"; + } else { + this.setIsonline(true); + } + if (error != 0) { + this.setIserror(true); + message = "universal_message3"; + } else { + this.setIserror(false); + } + if (mode != 3 || requireSucess) { + message = "one_message7"; + } else { + if (error != 0) { + erroBlock(); + } + List list = new ArrayList(); + switch (command) { + case 0: + boolean b = applyTask(); + if (b) { + requireSucess = false; + } + break; + case 1: + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content("取货中") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + message = "universal_delivery"; + + if (updateCommand("1")) break; + break; + case 2: + LuceneLogDto logDto1 = LuceneLogDto.builder() + .device_code(device_code) + .content("取货完成") + .build(); + logDto1.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto1); + message = "universal_completed"; + if (updateCommand("2")) break; + Instruction instruction2 = checkInst(); + if (ObjectUtil.isEmpty(instruction2)) { + message = "universal_message4"; + break; + } + String next_device_code = instruction2.getNext_device_code(); + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + if (StrUtil.equals(nextDevice.getDevice_type(), DeviceType.conveyor.name())) { + packageDevicePoint(nextDevice, list); + } + if (StrUtil.equals(nextDevice.getDevice_type(), DeviceType.storage.name())) { + String pattern = "\\d+"; + Pattern compile = Pattern.compile(pattern); + Map map = new HashMap<>(); + map.put("code", "to_y"); + map.put("value", inst.getTo_z()); + list.add(map); + if (inst.getTo_x().length() > 1 && !compile.matcher(inst.getTo_x()).matches()) { + String substring = inst.getTo_x().substring(1); + Map map1 = new HashMap<>(); + map1.put("code", "to_z"); + map1.put("value", substring); + list.add(map1); + } else { + Map map2 = new HashMap<>(); + map2.put("code", "to_z"); + map2.put("value", inst.getTo_x()); + list.add(map2); + } + Map map3 = new HashMap<>(); + map3.put("code", "to_x"); + map3.put("value", inst.getTo_y()); + list.add(map3); + } + Map map4 = new HashMap<>(); + map4.put("code", "to_command"); + map4.put("value", 2); + list.add(map4); + requireSucess = false; + break; + case 3: + LuceneLogDto logDto2 = LuceneLogDto.builder() + .device_code(device_code) + .content("放货") + .build(); + logDto2.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto2); + message = "universal_releasing"; + if (updateCommand("3")) break; + break; + case 4: + message = "one_message1"; + Instruction instruction1 = checkInst(); + String next_device_code1 = instruction1.getNext_device_code(); + Device nextDevice1 = deviceAppService.findDeviceByCode(next_device_code1); + if (ObjectUtil.isNotNull(instruction1)) { + //指令为执行 + SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; + if (nextDevice1.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { + siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) nextDevice1.getDeviceDriver(); + if (siemensConveyorDeviceDriver.getMode() != 2 || siemensConveyorDeviceDriver.getMove() == 1) { + notCreateInstMessage = "未下发电气信号原因->输送线-货架对接位:" + siemensConveyorDeviceDriver.getDevice_code() + + "有货或未联机,无法下发指令!指令号:" + inst.getInstruction_code(); + return; + } + } + Map map = new HashMap<>(); + map.put("code", "to_command"); + map.put("value", 4); + list.add(map); + } + requireSucess = false; + break; + case 5: + LuceneLogDto logDto3 = LuceneLogDto.builder() + .device_code(device_code) + .content("放货完成") + .build(); + logDto3.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto3); + message = "universal_releasing_completed"; + Map map = new HashMap<>(); + List list5 = new ArrayList(); + map.put("code", "to_command"); + map.put("value", 11); + list5.add(map); + this.writing(list5); + Instruction inst = checkInst(); + try { + if ("3".equals(inst.getPriority()) && errorInst != null) { + //存在同排移库做完后直接出库 + String start_device_code = errorInst.getStart_device_code(); + Device startDevice = deviceAppService.findDeviceByCode(start_device_code); + List listError = new ArrayList(); + pakageCommand(listError, errorInst.getInstruction_code()); + if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.storage.name()) && !prohibitOutWarehouse) { + pakagePlc(errorInst, listError, "1"); + } + if (ObjectUtil.isNotEmpty(listError)) { + this.writing(listError); + } + finish_instruction(inst); + errorInst = null; + } else { + finish_instruction(inst); + } + } catch (Exception e) { + e.printStackTrace(); + } + + inst = null; + requireSucess = false; + break; + case 6: + message = "one_message2"; + Map map1 = new HashMap<>(); + map1.put("code", "to_command"); + map1.put("value", 6); + list.add(map1); + requireSucess = false; + break; + case 7: + message = "one_message3"; + Map map2 = new HashMap<>(); + map2.put("code", "to_command"); + map2.put("value", 7); + list.add(map2); + requireSucess = false; + break; + case 8: + message = "one_message4"; + Map map3 = new HashMap<>(); + map3.put("code", "to_command"); + map3.put("value", 8); + list.add(map3); + requireSucess = false; + break; + default: + message = "one_message5"; + requireSucess = false; + break; + } + if (list.size() != 0) { + this.writing(list); + } + + } } catch (Exception var17) { + this.iserror = true; + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(this.device_code + "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null") + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + var17.printStackTrace(); - logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); } - //不同任务限制清零 - if (!Objects.equals(task, last_task)) { - this.isonline=true; - count = 0; - } - - if (mode == 0 || command == 9) { - this.setIsonline(false); - message = "universal_off"; - }else { - this.setIsonline(true); - } - if (error != 0) { - this.setIserror(true); - message = "universal_message3"; - } else { - this.setIserror(false); - } - if (mode != 3 || requireSucess) { - message = "one_message7"; - } else { - if (error != 0) { - erroBlock(); - } - List list = new ArrayList(); - switch (command) { - case 0: - boolean b = applyTask(); - if (b) { - requireSucess = false; - } - break; - case 1: - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content("取货中") - .build(); - logDto.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto); - message = "universal_delivery"; - - if (updateCommand("1")) break; - break; - case 2: - LuceneLogDto logDto1 = LuceneLogDto.builder() - .device_code(device_code) - .content("取货完成") - .build(); - logDto1.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto1); - message = "universal_completed"; - if (updateCommand("2")) break; - Instruction instruction2 = checkInst(); - if (ObjectUtil.isEmpty(instruction2)) { - message = "universal_message4"; - break; - } - String next_device_code = instruction2.getNext_device_code(); - Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); - if (StrUtil.equals(nextDevice.getDevice_type(), DeviceType.conveyor.name())) { - packageDevicePoint(nextDevice, list); - } - if (StrUtil.equals(nextDevice.getDevice_type(), DeviceType.storage.name())) { - String pattern = "\\d+"; - Pattern compile = Pattern.compile(pattern); - Map map = new HashMap<>(); - map.put("code", "to_y"); - map.put("value", inst.getTo_z() ); - list.add(map); - if (inst.getTo_x().length() > 1 && !compile.matcher(inst.getTo_x()).matches()) { - String substring = inst.getTo_x().substring(1); - Map map1 = new HashMap<>(); - map1.put("code", "to_z"); - map1.put("value", substring); - list.add(map1); - } else { - Map map2 = new HashMap<>(); - map2.put("code", "to_z"); - map2.put("value", inst.getTo_x()); - list.add(map2); - } - Map map3 = new HashMap<>(); - map3.put("code", "to_x"); - map3.put("value", inst.getTo_y()); - list.add(map3); - } - Map map4 = new HashMap<>(); - map4.put("code", "to_command"); - map4.put("value", 2); - list.add(map4); - requireSucess = false; - break; - case 3: - LuceneLogDto logDto2 = LuceneLogDto.builder() - .device_code(device_code) - .content("放货") - .build(); - logDto2.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto2); - message = "universal_releasing"; - if (updateCommand("3")) break; - break; - case 4: - message = "one_message1"; - Instruction instruction1 = checkInst(); - String next_device_code1 = instruction1.getNext_device_code(); - Device nextDevice1 = deviceAppService.findDeviceByCode(next_device_code1); - if (ObjectUtil.isNotNull(instruction1)) { - //指令为执行 - SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; - if (nextDevice1.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { - siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) nextDevice1.getDeviceDriver(); - if (siemensConveyorDeviceDriver.getMode() != 2 || siemensConveyorDeviceDriver.getMove() == 1) { - notCreateInstMessage = "未下发电气信号原因->输送线-货架对接位:" + siemensConveyorDeviceDriver.getDevice_code() + - "有货或未联机,无法下发指令!指令号:" + inst.getInstruction_code(); - return; - } - } - Map map = new HashMap<>(); - map.put("code", "to_command"); - map.put("value", 4); - list.add(map); - } - requireSucess = false; - break; - case 5: - LuceneLogDto logDto3 = LuceneLogDto.builder() - .device_code(device_code) - .content("放货完成") - .build(); - logDto3.setLog_level(4); - luceneExecuteLogService.deviceExecuteLog(logDto3); - message = "universal_releasing_completed"; - Map map = new HashMap<>(); - List list5 = new ArrayList(); - map.put("code", "to_command"); - map.put("value", 11); - list5.add(map); - this.writing(list5); - Instruction inst = checkInst(); - try { - if ("3".equals(inst.getPriority()) && errorInst != null) { - //存在同排移库做完后直接出库 - String start_device_code = errorInst.getStart_device_code(); - Device startDevice = deviceAppService.findDeviceByCode(start_device_code); - List listError = new ArrayList(); - pakageCommand(listError , errorInst.getInstruction_code()); - if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.storage.name()) && !prohibitOutWarehouse) { - pakagePlc(errorInst, listError,"1"); - } - if (ObjectUtil.isNotEmpty(listError)) { - this.writing(listError); - } - finish_instruction(inst); - errorInst = null; - } else { - finish_instruction(inst); - } - } catch (Exception e) { - e.printStackTrace(); - } - - inst = null; - requireSucess = false; - break; - case 6: - message = "one_message2"; - Map map1 = new HashMap<>(); - map1.put("code", "to_command"); - map1.put("value", 6); - list.add(map1); - requireSucess = false; - break; - case 7: - message = "one_message3"; - Map map2 = new HashMap<>(); - map2.put("code", "to_command"); - map2.put("value", 7); - list.add(map2); - requireSucess = false; - break; - case 8: - message = "one_message4"; - Map map3 = new HashMap<>(); - map3.put("code", "to_command"); - map3.put("value", 8); - list.add(map3); - requireSucess = false; - break; - default: - message = "one_message5"; - requireSucess = false; - break; - } - if (list.size() != 0) { - this.writing(list); - } - - } last_heartbeat = heartbeat; last_item_deviceCode = item_deviceCode; @@ -632,7 +650,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme instructionService.update(instruction0); return false; } - return true; + //异常后上个动作命令是取货完成也要下发信号 + return false; } @@ -716,7 +735,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme luceneExecuteLogService.deviceExecuteLog(logDto1); String response = acsToWmsService.applyUpdatePointCode(param); JSONObject jo = JSON.parseObject(response); - if ( jo.getInteger("status") == 200) { + if (jo.getInteger("status") == 200) { try { //清警 cleanErro(); @@ -875,7 +894,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme //放货完成 if (forkCargo == 0) { //取货中或者取货完成(分入库出库) - if ("1".equals(instructionErro.getExecute_code()) || "2".equals(instructionErro.getExecute_code())) { + if ("1".equals(instructionErro.getExecute_code())) { List list = new ArrayList(); String startDeviceCode = instructionErro.getStart_device_code(); Device startDeviceError = deviceAppService.findDeviceByCode(startDeviceCode); @@ -884,37 +903,37 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme requireSucess = true; return true; } - }else { + } else { message = "one_message19"; } } //放货中报警 - if ("3".equals(instructionErro.getExecute_code()) && forkCargo == 2) { + if (("3".equals(instructionErro.getExecute_code()) && forkCargo == 2) || "2".equals(instructionErro.getExecute_code())) { List list = new ArrayList(); if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.conveyor.name())) { pakagePLCData(list, instructionErro.getTo_x(), instructionErro.getTo_y(), instructionErro.getTo_z(), "2", instructionErro.getInstruction_code()); requireSucess = true; return true; } - }else { + } else { message = "one_message20"; } } //出库报警 if (startDevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) { //取货报警 - if ("1".equals(instructionErro.getExecute_code()) || "2".equals(instructionErro.getExecute_code())) { + if ("1".equals(instructionErro.getExecute_code())) { List list = new ArrayList(); if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.storage.name())) { pakagePLCData(list, instructionErro.getFrom_x(), instructionErro.getFrom_y(), instructionErro.getFrom_z(), "1", instructionErro.getInstruction_code()); requireSucess = true; return true; } - }else { + } else { message = "one_message19"; } //放货中报警 - if ("3".equals(instructionErro.getExecute_code()) && forkCargo == 2) { + if (("3".equals(instructionErro.getExecute_code()) && forkCargo == 2) || "2".equals(instructionErro.getExecute_code())) { String next_device_code = instructionErro.getNext_device_code(); Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); List list = new ArrayList(); @@ -923,7 +942,13 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme requireSucess = true; return true; } - }else { + //同排移库报警 + if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.storage.name())) { + pakagePLCData(list, nextDevice.getExtraValue().get("x").toString(), nextDevice.getExtraValue().get("z").toString(), nextDevice.getExtraValue().get("y").toString(), "2", instructionErro.getInstruction_code()); + requireSucess = true; + return true; + } + } else { message = "one_message20"; } } @@ -978,7 +1003,22 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme return false; } instructionList = this.sortInst(instructionList); - inst = instructionList.get(0); + + //堆垛机策略 + StackerStrategyDto stragety = customerStragetyCacheService.getStragety(device_code); + List instructionStragetyList = new ArrayList<>(); + if (ObjectUtil.isNotEmpty(stragety)) { + //根据筛选指令,指令中包含策略起点终点的指令 + stragetySort(stragety, instructionList, instructionStragetyList); + if (!instructionStragetyList.isEmpty()) { + inst = instructionStragetyList.get(0); + } else { + inst = instructionList.get(0); + } + } else { + inst = instructionList.get(0); + } + //指令未执行 if (StrUtil.equals(inst.getInstruction_status(), "0")) { String start_device_code = inst.getStart_device_code(); @@ -1004,9 +1044,9 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme } List list = new ArrayList(); pakageCommand(list, inst.getInstruction_code()); - packagePlcCoordinate(startDevice, list,"1"); + packagePlcCoordinate(startDevice, list, "1"); if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.storage.name()) && !prohibitOutWarehouse) { - pakagePlc(inst, list,"1"); + pakagePlc(inst, list, "1"); } if (ObjectUtil.isNotEmpty(list)) { this.writing(list); @@ -1017,6 +1057,78 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme return true; } + private void stragetySort(StackerStrategyDto stragety, List instructionList, List instructionStragetyList) { + List plan = stragety.getPlan(); + Map> startDeviceCodes = instructionList.stream().collect(Collectors.groupingBy(Instruction::getStart_device_code)); + Map> endDeviceCodes = instructionList.stream().collect(Collectors.groupingBy(Instruction::getNext_device_code)); + //初始化队列 + if (CollUtil.isNotEmpty(plan)){ + if (tackerInstructionQueue.isEmpty()) { + for (StackerInstruction stackerInstruction : plan) { + tackerInstructionQueue.offer(stackerInstruction); + } + } + } + //找到满足策略的指令跳出循环 + for (StackerInstruction stackerInstruction : tackerInstructionQueue) { + //从头拿队列 + //入库策略 + if (StrUtil.isNotEmpty(stackerInstruction.getFrom())) { + if (startDeviceCodes.containsKey(stackerInstruction.getFrom())) { + instructionStragetyList.add(startDeviceCodes.get(stackerInstruction.getFrom()).get(0)); + //从头移除队列 + tackerInstructionQueue.poll(); + break; + } + } + //出库策略 + if (StrUtil.isNotEmpty(stackerInstruction.getTo())) { + if (endDeviceCodes.containsKey(stackerInstruction.getTo())) { + instructionStragetyList.add(endDeviceCodes.get(stackerInstruction.getTo()).get(0)); + //从头移除队列 + tackerInstructionQueue.poll(); + break; + } + } + //起点终点都为空根据类型做任务 + if (StrUtil.isEmpty(stackerInstruction.getFrom()) && StrUtil.isEmpty(stackerInstruction.getTo())){ + //入库 + if (CustomPolicyTaskTypeEnum.IN.getCode().equals(stackerInstruction.getType())){ + List instIn = instructionList.stream().filter(item -> item.getNext_device_code().contains("L")).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(instIn)){ + instructionStragetyList.add(instIn.get(0)); + //从头移除队列 + tackerInstructionQueue.poll(); + break; + } + } + //出库 + if (CustomPolicyTaskTypeEnum.OUT.getCode().equals(stackerInstruction.getType())){ + List instOut = instructionList.stream().filter(item -> item.getStart_device_code().contains("L")).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(instOut)){ + instructionStragetyList.add(instOut.get(0)); + //从头移除队列 + tackerInstructionQueue.poll(); + break; + } + } + //移库 + if (CustomPolicyTaskTypeEnum.MOVE.getCode().equals(stackerInstruction.getType())){ + List instInAndOut = instructionList.stream().filter(item -> item.getStart_device_code().contains("L") && item.getNext_device_code().contains("L") ).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(instInAndOut)){ + instructionStragetyList.add(instInAndOut.get(0)); + //从头移除队列 + tackerInstructionQueue.poll(); + break; + } + } + + } + + + } + } + private void packagePlcCoordinate(Device startDevice, List list, String toCommand) { if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.conveyor.name()) && !prohibitInWarehouse) { if (ObjectUtil.isNotEmpty(startDevice.getExtraValue().get("z"))) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/enums/CustomPolicyTaskTypeEnum.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/enums/CustomPolicyTaskTypeEnum.java new file mode 100644 index 000000000..67b909073 --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/stacker/standard_stacker/enums/CustomPolicyTaskTypeEnum.java @@ -0,0 +1,38 @@ +/** + * @author ls + * @date 2023/11/20 13:33 + */ +package org.nl.acs.device_driver.stacker.standard_stacker.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + + +@Getter +@AllArgsConstructor +public enum CustomPolicyTaskTypeEnum { + /** + * 入库 + */ + OUT(1, "入库"), + /** + * 出库 + */ + IN(2, "出库"), + /** + * 移库 + */ + MOVE(3, "移库"); + + Integer code; + String status; + + public static String getStatus(Integer code) { + for (CustomPolicyTaskTypeEnum value : values()) { + if (value.code.equals(code)) { + return value.status; + } + } + return null; + } +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/die_manipulator/DieManipulatorDefination.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/die_manipulator/DieManipulatorDefination.java new file mode 100644 index 000000000..0cb46016e --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/die_manipulator/DieManipulatorDefination.java @@ -0,0 +1,57 @@ +package org.nl.acs.device_driver.two_conveyor.die_manipulator; + +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.enums.DeviceType; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; +import org.springframework.stereotype.Service; + +import java.util.LinkedList; +import java.util.List; + +@Service +public class DieManipulatorDefination implements OpcDeviceDriverDefination { + @Override + public String getDriverCode() { + return "die_manipulator"; + } + + @Override + public String getDriverName() { + return "管芯行架机械手"; + } + + @Override + public String getDriverDescription() { + return "管芯行架机械手"; + } + + @Override + public DeviceDriver getDriverInstance(Device device) { + return (new DieManipulatorDriver()).setDevice(device).setDriverDefination(this); + } + + @Override + public Class getDeviceDriverType() { + return DieManipulatorDriver.class; + } + + @Override + public List getFitDeviceTypes() { + List types = new LinkedList(); + types.add(DeviceType.robot); + return types; + } + + @Override + public List getReadableItemDtos(){ + return ItemProtocol.getReadableItemDtos(); + } + + @Override + public List getWriteableItemDtos(){ + return ItemProtocol.getWriteableItemDtos(); + } + +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/die_manipulator/DieManipulatorDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/die_manipulator/DieManipulatorDriver.java new file mode 100644 index 000000000..5c8418c7d --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/die_manipulator/DieManipulatorDriver.java @@ -0,0 +1,265 @@ +package org.nl.acs.device_driver.two_conveyor.die_manipulator; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.common.base.CommonFinalParam; +import org.nl.acs.device.domain.Device; +import org.nl.acs.device.service.DeviceExtraService; +import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; +import org.nl.acs.device_driver.DeviceDriver; +import org.nl.acs.device_driver.FeedLmsRealFailed; +import org.nl.acs.device_driver.RouteableDeviceDriver; +import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; +import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; +import org.nl.acs.ext.wms.data.ApplyfeedbackSubVolumeWeightRequest; +import org.nl.acs.ext.wms.data.ApplyfeedbackSubVolumeWeightResponse; +import org.nl.acs.ext.wms.service.AcsToWmsService; +import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; +import org.nl.acs.history.ErrorUtil; +import org.nl.acs.history.service.DeviceErrorLogService; +import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl; +import org.nl.acs.instruction.domain.Instruction; +import org.nl.acs.instruction.enums.InstructionStatusEnum; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.log.service.DeviceExecuteLogService; +import org.nl.acs.monitor.DeviceStageMonitor; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.opc.DeviceAppServiceImpl; +import org.nl.acs.route.service.RouteLineService; +import org.nl.acs.route.service.impl.RouteLineServiceImpl; +import org.nl.acs.task.service.TaskService; +import org.nl.config.SpringContextHolder; +import org.nl.config.language.LangProcess; +import org.nl.config.lucene.service.LuceneExecuteLogService; +import org.nl.config.lucene.service.dto.LuceneLogDto; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +/** + * 管芯行架机械手 + */ +@Slf4j +@Data +@RequiredArgsConstructor +public class DieManipulatorDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed { + + protected ItemProtocol itemProtocol = new ItemProtocol(this); + @Autowired + DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); + @Autowired + TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); + @Autowired + InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); + @Autowired + DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + @Autowired + RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); + @Autowired + DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class); + @Autowired + DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); + @Autowired + LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class); + @Autowired + AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); + //工作模式 + int mode = 0; + int last_mode = 0; + //光电信号 + int move = 0; + int last_move = 0; + //动作信号 + int action = 0; + int last_action = 0; + //行走列 + int walk_y = 0; + int last_walk_y = 0; + //报警信号 + int error = 0; + int last_error = 0; + //任务号 + int task = 0; + int last_task = 0; + // x坐标 + float x_position = 0; + float last_x_position = 0; + // y坐标 + float y_position = 0; + float last_y_position = 0; + + int heartbeat = 0; + int last_heartbeat = 0; + int to_command = 0; + int last_to_command = 0; + + int to_target = 0; + int last_to_target = 0; + + int to_task = 0; + int last_to_task = 0; + + int to_onset = 0; + int last_to_onset = 0; + + + Boolean isonline = true; + int hasGoods = 0; + String message = null; + Boolean iserror = false; + + String device_code; + //行架机械手申请任务成功标识 + boolean requireSucess = false; + + private String error_type = "hxhj_error_type"; + + //当前指令 + Instruction inst = null; + + @Override + public Device getDevice() { + return this.device; + } + + @Override + public void execute() { + try { + device_code = this.getDeviceCode(); + mode = this.itemProtocol.getMode(); + move = this.itemProtocol.getMove(); + action = this.itemProtocol.getAction(); + walk_y = this.itemProtocol.getWalk_y(); + error = this.itemProtocol.getError(); + task = this.itemProtocol.getTask(); + heartbeat = this.itemProtocol.getHeartbeat(); + to_command = this.itemProtocol.getTo_command(); + to_target = this.itemProtocol.getTo_target(); + to_task = this.itemProtocol.getTo_task(); + to_onset = this.itemProtocol.getTo_onset(); + x_position = this.itemProtocol.getX_position(); + y_position = this.itemProtocol.getY_position(); + + } catch (Exception var17) { + var17.printStackTrace(); + // feedMessage = var17.getMessage(); + logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol)); + + } + + if (mode == 0) { + this.setIsonline(false); + message = "未联机"; + //有报警 + } else if (error != 0) { + this.setIserror(true); + message = "有报警"; + //无报警 + } else { + this.setIsonline(true); + this.setIserror(false); + } + + last_mode = mode; + last_move = move; + last_action = action; + last_walk_y = walk_y; + last_error = error; + last_task = task; + last_heartbeat = heartbeat; + last_to_task = to_task; + last_to_command = to_command; + last_to_target = to_target; + last_to_onset = to_onset; + last_x_position = x_position; + last_y_position = y_position; + } + + + @Override + public JSONObject getDeviceStatusName() { + Map map = new LinkedHashMap<>(); + String mode = ""; + String move = ""; + String action = ""; + String walk_y = ""; + if (this.getMode() == 0) { + mode = LangProcess.msg("universal_off-line"); + } else if (this.getMode() == 1) { + mode = LangProcess.msg("universal_stand-alone"); + } else if (this.getMode() == 2) { + mode = LangProcess.msg("universal_standby"); + } else if (this.getMode() == 3) { + mode = LangProcess.msg("universal_operation"); + } + + if (this.getMove() == 0) { + move = LangProcess.msg("universal_no"); + } else if (this.getMove() == 1) { + move = LangProcess.msg("universal_yes"); + } + + + String requireSucess = LangProcess.msg("universal_actionMessage4"); + if (this.requireSucess) { + requireSucess = LangProcess.msg("universal_actionMessage5"); + } + map.put("requireSucess", requireSucess); + if (this.getAction() == 1) { + action = LangProcess.msg("universal_delivery"); + } else if (this.getAction() == 2) { + action = LangProcess.msg("universal_completed"); + } else if (this.getAction() == 3) { + action = LangProcess.msg("universal_releasing"); + } else if (this.getAction() == 4) { + action = LangProcess.msg("universal_releasing_completed"); + }else if (this.getAction() == 0){ + action = "无动作"; + } + if(error == 0 && this.itemProtocol.isError){ + iserror = true; + }else if(error == 0 && !(this.itemProtocol.isError)){ + iserror = false; + } + map.put("device_name", this.getDevice().getDevice_name()); + map.put("mode", mode); + map.put("move", move); + map.put("action", action); + map.put("isOnline", this.getIsonline()); + map.put("error", ErrorUtil.getDictDetail("bhhj_error_type", String.valueOf(this.getError()))); + map.put("isError", this.getIserror()); + map.put("message", message); + map.put("driver_type", "siemens_conveyor"); + map.put("is_click", true); + JSONObject jo = new JSONObject(map); + return jo; + } + + @Override + public void setDeviceStatus(JSONObject data) { + String requestSucess = data.getString("requireSucess"); + if (StrUtil.equals(requestSucess, "0")) { + this.requireSucess = false; + } else if (StrUtil.equals(requestSucess, "1")) { + this.requireSucess = true; + } + } + + @Override + public JSONObject feedLmsRealFailedInfo() { + JSONObject jo = new JSONObject(); + jo.put("device_code", this.getDevice().getDevice_code()); + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("fault_code", String.valueOf(error)); + jo.put("fault_info", ErrorUtil.getDictDetail(error_type, String.valueOf(this.getError()))); + jo.put("fault_type", error_type); + return jo; + } +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/die_manipulator/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/die_manipulator/ItemProtocol.java new file mode 100644 index 000000000..55ddf74fc --- /dev/null +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/die_manipulator/ItemProtocol.java @@ -0,0 +1,168 @@ +package org.nl.acs.device_driver.two_conveyor.die_manipulator; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.device_driver.standard_inspect.ItemDto; + +import java.util.ArrayList; +import java.util.List; + +@Slf4j +@Data +public class ItemProtocol { + //心跳 + public static String item_heartbeat = "heartbeat"; + //工作模式 + public static String item_mode = "mode"; + //光电信号 + public static String item_move = "move"; + //动作信号 + public static String item_action = "action"; + //行走列 + public static String item_walk_y = "walk_y"; + //任务号 + public static String item_task = "task"; + //报警 + public static String item_error = "error"; + //x轴坐标 + public static String item_x_position = "x"; + //y轴坐标 + public static String item_y_position = "y"; + + //下发命令 + public static String item_to_command = "to_command"; + //下发起始站 + public static String item_to_onset = "to_onset"; + //下发目标站 + public static String item_to_target = "to_target"; + //下发任务号 + public static String item_to_task = "to_task"; + + private DieManipulatorDriver driver; + + public ItemProtocol(DieManipulatorDriver driver){ + this.driver=driver; + } + + public int getHeartbeat() { + return this.getOpcIntegerValue(item_heartbeat); + } + + public int getMode() { + return this.getOpcIntegerValue(item_mode); + } + + public int getMove() { + return this.getOpcIntegerValue(item_move); + } + + + public int getAction() { + return this.getOpcIntegerValue(item_action); + } + + public int getWalk_y() { + return this.getOpcIntegerValue(item_walk_y); + } + + public int getError() { + return this.getOpcIntegerValue(item_error); + } + + public int getTask() { + return this.getOpcIntegerValue(item_task); + } + + public int getTo_task() { + return this.getOpcIntegerValue(item_to_task); + } + + public int getTo_onset() { + return this.getOpcIntegerValue(item_to_onset); + } + + public int getTo_command() { + return this.getOpcIntegerValue(item_to_command); + } + + public int getTo_target() { + return this.getOpcIntegerValue(item_to_target); + } + + public float getX_position() { + return this.getOpcFloatValue(item_x_position); + } + + public float getY_position() { + return this.getOpcFloatValue(item_y_position); + } + + + Boolean isonline; + Boolean isError = false; + + public int getOpcIntegerValue(String protocol) { + Integer value = this.driver.getIntegeregerValue(protocol); + if(ObjectUtil.isEmpty(value)){ + isError = true; + }else if (item_heartbeat.equals(protocol)) { + isError = false; + } + if (value == null) { + setIsonline(false); + } else { + setIsonline(true); + return value; + } + return 0; + + } + + public String getOpcStringValue(String protocol) { + String value = this.driver.getStringValue(protocol); + if (StrUtil.isEmpty(value)) { + setIsonline(false); + } else { + return value; + } + return "0"; + } + + public float getOpcFloatValue(String protocol) { + Float value = this.driver.getDoubleValue(protocol); + if (value == null) { + // log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); + setIsonline(false); + } else { + setIsonline(true); + return value; + } + return 0; + + } + + public static List getReadableItemDtos() { + ArrayList list = new ArrayList<>(); + list.add(new ItemDto(item_heartbeat, "心跳", "DB13.B0")); + list.add(new ItemDto(item_mode, "工作模式", "DB13.B1")); + list.add(new ItemDto(item_move, "光电信号", "DB13.B2")); + list.add(new ItemDto(item_action, "动作信号", "DB13.B3")); + list.add(new ItemDto(item_walk_y, "行走列", "DB13.B4")); + list.add(new ItemDto(item_error, "报警信号", "DB13.B5")); + list.add(new ItemDto(item_task, "任务号", "DB13.D6")); + list.add(new ItemDto(item_x_position, "x坐标", "DB13.REAL10")); + list.add(new ItemDto(item_y_position, "y坐标", "DB13.REAL14")); + return list; + } + + public static List getWriteableItemDtos() { + ArrayList list = new ArrayList<>(); + list.add(new ItemDto(item_to_command, "下发命令", "DB14.W0")); + list.add(new ItemDto(item_to_onset, "下发起始站", "DB14.W2")); + list.add(new ItemDto(item_to_target, "下发目标站", "DB14.W4")); + list.add(new ItemDto(item_to_task, "下发任务号", "DB14.D6")); + return list; + } +} diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/ItemProtocol.java index 0f4496203..483a6e362 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/inflatable_shaft_library/ItemProtocol.java @@ -47,7 +47,7 @@ public class ItemProtocol { return this.getOpcIntegerValue(item_qty); } public int getItem_type(){ - return this.getItem_type(); + return this.getOpcIntegerValue(item_type); } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDeviceDriver.java index 0c970f40a..e45725f18 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/OvenGantryManipulatorDeviceDriver.java @@ -79,7 +79,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i @Autowired LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class); - final Executor EXECUTOR = ThreadPoolExecutorUtil.getPoll(); +// final Executor EXECUTOR = ThreadPoolExecutorUtil.getPoll(); //工作模式 int mode = 0; @@ -856,9 +856,9 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver(); - EXECUTOR.execute(() -> { +// EXECUTOR.execute(() -> { toOpenDoor(device); - }); +// }); int mode = hongXiangConveyorDeviceDriver.getMode(); int door = hongXiangConveyorDeviceDriver.getDoor(); int action = hongXiangConveyorDeviceDriver.getAction(); @@ -922,9 +922,9 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver; if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver(); - EXECUTOR.execute(() -> { +// EXECUTOR.execute(() -> { toCloseDoor(device); - }); +// }); int mode = hongXiangConveyorDeviceDriver.getMode(); int door = hongXiangConveyorDeviceDriver.getDoor(); int action = hongXiangConveyorDeviceDriver.getAction(); @@ -1058,9 +1058,9 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i LampThreecolorDeviceDriver lampThreecolorDeviceDriver; if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) { hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver(); - EXECUTOR.execute(() -> { +// EXECUTOR.execute(() -> { toCloseDoor(nextDevice); - }); +// }); if (StrUtil.isNotEmpty(taskDto.getOven_time())) { //下发烘箱时间 int time = Integer.parseInt(taskDto.getOven_time()); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDeviceDriver.java index cf10cf5f3..76157e2fe 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/plug_pull_device_site/PlugPullDeviceSiteDeviceDriver.java @@ -2,6 +2,7 @@ package org.nl.acs.device_driver.two_conveyor.plug_pull_device_site; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpResponse; import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; @@ -264,6 +265,15 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl applyTask(mode); } break; + case 10: + if (!requireSucess) { + //请求密集库出气胀轴,申请行架任务 + boolean b =applyQzz(mode); + if(b){ + requireSucess = true; + } + } + break; default: log.info("未知模式"); break; @@ -304,7 +314,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); return; } else { - logServer.deviceExecuteLog(this.device_code,"","","申请套管"); + logServer.deviceExecuteLog(this.device_code, "", "", "申请套管"); ApplyPlugPullSiteRequest applyPlugPullSiteRequest = new ApplyPlugPullSiteRequest(); ApplyPlugPullSitResponse applyPlugPullSitResponse; applyPlugPullSiteRequest.setDevice_code(device_code); @@ -346,19 +356,28 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl String to_spec2 = data.get("rightSpec"); Map map = new LinkedHashMap<>(); //下发纸管信息 + if (ObjectUtil.isEmpty(to_material1) && ObjectUtil.isNotEmpty(to_material2)) { + map.put("to_material1", to_material2); + if (StrUtil.isNotEmpty(rightSize)) { + map.put("to_size1", rightSize); + } + if (ObjectUtil.isNotEmpty(to_spec2)) { + map.put("to_spec1", to_spec2); + } + } else { + map.put("to_material1", to_material1); + map.put("to_material2", to_material2); - map.put("to_material1", to_material1); - map.put("to_material2", to_material2); - - if (StrUtil.isNotEmpty(leftSize)) { - map.put("to_size1", leftSize); - } - if (StrUtil.isNotEmpty(rightSize)) { - map.put("to_size2", rightSize); - } - map.put("to_spec1", to_spec1); - if (ObjectUtil.isNotEmpty(to_spec2)) { - map.put("to_spec2", to_spec2); + if (StrUtil.isNotEmpty(leftSize)) { + map.put("to_size1", leftSize); + } + if (StrUtil.isNotEmpty(rightSize)) { + map.put("to_size2", rightSize); + } + map.put("to_spec1", to_spec1); + if (ObjectUtil.isNotEmpty(to_spec2)) { + map.put("to_spec2", to_spec2); + } } map.put("to_command", mode); map.put("to_qty1", number); @@ -367,7 +386,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl logServer.deviceExecuteLog(this.device_code, "", "", "申请套管成功,返回参数:" + applyPlugPullSitResponse.getData()); message = "申请套管成功"; } - if (StrUtil.equals("2", is_bushing)){ + if (StrUtil.equals("2", is_bushing)) { Map map = new LinkedHashMap<>(); map.put("to_command", 97); this.writing(map); @@ -381,7 +400,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl luceneExecuteLogService.deviceExecuteLog(logDto1); logServer.deviceExecuteLog(this.device_code, "", "", message); } - if (StrUtil.equals("0", is_bushing)){ + if (StrUtil.equals("0", is_bushing)) { Map map = new LinkedHashMap<>(); map.put("to_command", 98); this.writing(map); @@ -404,7 +423,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl message = "申请套管失败"; LuceneLogDto logDto1 = LuceneLogDto.builder() .device_code(device_code) - .content("申请套管反馈失败,返回参数:"+applyPlugPullSitResponse) + .content("申请套管反馈失败,返回参数:" + applyPlugPullSitResponse) .build(); logDto1.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(logDto1); @@ -484,7 +503,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); return; } else { - logServer.deviceExecuteLog(this.device_code,"","","拔轴完成"); + logServer.deviceExecuteLog(this.device_code, "", "", "拔轴完成"); ApplyPlugPullSiteRequest applyPlugPullSiteRequest = new ApplyPlugPullSiteRequest(); ApplyPlugPullSitResponse applyPlugPullSitResponse; applyPlugPullSiteRequest.setDevice_code(device_code); @@ -510,7 +529,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl logServer.deviceExecuteLog(this.device_code, "", "", "申请拔轴完成任务,返回参数:" + applyPlugPullSitResponse.getData()); LuceneLogDto logDto1 = LuceneLogDto.builder() .device_code(device_code) - .content("申请拔轴完成,返回参数:"+applyPlugPullSitResponse.getData()) + .content("申请拔轴完成,返回参数:" + applyPlugPullSitResponse.getData()) .build(); logDto1.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(logDto1); @@ -524,7 +543,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl message = "拔轴完成失败"; LuceneLogDto logDto1 = LuceneLogDto.builder() .device_code(device_code) - .content("拔轴完成反馈失败,返回参数:"+applyPlugPullSitResponse.getData()) + .content("拔轴完成反馈失败,返回参数:" + applyPlugPullSitResponse.getData()) .build(); logDto1.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(logDto1); @@ -542,7 +561,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); return; } else { - logServer.deviceExecuteLog(this.device_code,"","","申请拔轴"); + logServer.deviceExecuteLog(this.device_code, "", "", "申请拔轴"); ApplyPlugPullSiteRequest applyPlugPullSiteRequest = new ApplyPlugPullSiteRequest(); ApplyPlugPullSitResponse applyPlugPullSitResponse; applyPlugPullSiteRequest.setDevice_code(device_code); @@ -576,17 +595,27 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl Object to_spec4 = data.get("currentRightSpec"); Object to_qty2 = data.get("pullCount"); Map map = new LinkedHashMap<>(); - map.put("to_material3", to_material3); - if (ObjectUtil.isNotEmpty(to_material4)) { - map.put("to_material4", to_material4); - } - map.put("to_size3", to_size3); - if (ObjectUtil.isNotEmpty(to_size4)) { - map.put("to_size4", to_size4); - } - map.put("to_spec3", to_spec3); - if (ObjectUtil.isNotEmpty(to_spec4)) { - map.put("to_spec4", to_spec4); + if (ObjectUtil.isEmpty(to_material3) && ObjectUtil.isNotEmpty(to_material4)) { + map.put("to_material3", to_material4); + if (ObjectUtil.isNotEmpty(to_size4)) { + map.put("to_size3", to_size4); + } + if (ObjectUtil.isNotEmpty(to_spec4)) { + map.put("to_spec3", to_spec4); + } + } else { + map.put("to_material3", to_material3); + if (ObjectUtil.isNotEmpty(to_material4)) { + map.put("to_material4", to_material4); + } + map.put("to_size3", to_size3); + if (ObjectUtil.isNotEmpty(to_size4)) { + map.put("to_size4", to_size4); + } + map.put("to_spec3", to_spec3); + if (ObjectUtil.isNotEmpty(to_spec4)) { + map.put("to_spec4", to_spec4); + } } map.put("to_qty2", to_qty2); map.put("to_qzz_type", size); @@ -597,7 +626,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl message = "申请拔轴成功"; LuceneLogDto logDto1 = LuceneLogDto.builder() .device_code(device_code) - .content("申请拔轴任务,返回参数:"+applyPlugPullSitResponse.getData()) + .content("申请拔轴任务,返回参数:" + applyPlugPullSitResponse.getData()) .build(); logDto.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(logDto1); @@ -610,7 +639,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl message = "申请拔轴失败"; LuceneLogDto logDto1 = LuceneLogDto.builder() .device_code(device_code) - .content("申请拔轴反馈失败,返回参数:"+applyPlugPullSitResponse.getData()) + .content("申请拔轴反馈失败,返回参数:" + applyPlugPullSitResponse.getData()) .build(); logDto.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(logDto1); @@ -628,7 +657,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); return; } else { - logServer.deviceExecuteLog(this.device_code,"","","缓存线已满,生成行架任务"); + logServer.deviceExecuteLog(this.device_code, "", "", "缓存线已满,生成行架任务"); ApplyPlugPullSiteRequest applyPlugPullSiteRequest = new ApplyPlugPullSiteRequest(); ApplyPlugPullSitResponse applyPlugPullSitResponse; applyPlugPullSiteRequest.setDevice_code(device_code); @@ -674,6 +703,64 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl } } + /** + * 请求密集库出气胀轴,申请行架任务 + */ + private boolean applyQzz(int mode) throws Exception { + Date date = new Date(); + if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) { + log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); + return false; + } else { + JSONObject jo = new JSONObject(); + jo.put("device_code",this.getDevice_code()); + jo.put("size",this.getSize()); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content("请求密集库出气胀轴,请求参数:" + jo) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + logServer.deviceExecuteLog(this.device_code, "", "", "请求密集库出气胀轴,参数:" + jo); + HttpResponse httpResponse = acsToWmsService.callShaftFromCache(jo); + JSONObject jsonObject = null; + if(ObjectUtil.isNotEmpty(httpResponse)){ + String body = httpResponse.body(); + jsonObject = JSONObject.parseObject(body); + } + if(ObjectUtil.isNotNull(jsonObject) && jsonObject.getInteger("status") == 200){ + Map map = new HashMap(); + map.put("to_command", 10); + try { + this.writing(map); + LuceneLogDto logDto1 = LuceneLogDto.builder() + .device_code(device_code) + .content("请求密集库出气胀轴,返回参数" + jsonObject) + .build(); + logDto1.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto1); + } catch (Exception e) { + LuceneLogDto logDto1 = LuceneLogDto.builder() + .device_code(device_code) + .content("请求密集库出气胀轴" + map) + .build(); + logDto1.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto1); + } + return true; + }else{ + LuceneLogDto logDto2 = LuceneLogDto.builder() + .device_code(device_code) + .content("请求密集库出气胀轴" + httpResponse.body()) + .build(); + logDto2.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto2); + return false; + } + } + + } + /** * 下发电气信号 * diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/ItemProtocol.java index 3f62dbc02..3d34273dd 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/ItemProtocol.java @@ -48,6 +48,36 @@ public class ItemProtocol { public static String item_to_barcode = "to_barcode"; + //下发套管纸管1编号 + public static String item_to_material1 = "to_material1"; + //下发套管纸管2编号 + public static String item_to_material2 = "to_material2"; + //下发套管纸管1规格 + public static String item_to_spec1 = "to_spec1"; + //下发套管纸管2规格 + public static String item_to_spec2 = "to_spec2"; + //套管纸管数量 + public static String item_to_qty1 = "to_qty1"; + //套管纸管1尺寸 + public static String item_to_size1 = "to_size1"; + //套管纸管2尺寸 + public static String item_to_size2 = "to_size2"; + + //下发拔轴纸管1编号 + public static String item_to_material3 = "to_material3"; + //下发拔轴纸管2编号 + public static String item_to_material4 = "to_material4"; + //下发拔轴纸管1规格 + public static String item_to_spec3 = "to_spec3"; + //下发拔轴纸管2规格 + public static String item_to_spec4 = "to_spec4"; + //拔轴纸管数量 + public static String item_to_qty2 = "to_qty2"; + //拔轴纸管1尺寸 + public static String item_to_size3 = "to_size3"; + //套拔轴纸管2尺寸 + public static String item_to_size4 = "to_size4"; + private PullHeadManipulatorDeviceDriver driver; @@ -194,6 +224,20 @@ public class ItemProtocol { list.add(new ItemDto(item_to_pull, "是否拔轴", "DB12.W8")); list.add(new ItemDto(item_to_sleeve, "是否套轴", "DB12.W10")); list.add(new ItemDto(item_to_size, "气涨轴尺寸", "DB12.W12")); + list.add(new ItemDto(item_to_material1, "下发套管纸管1编号", "DB12.String603.60")); + list.add(new ItemDto(item_to_material2, "下发套管纸管2编号", "DB12.String604.60")); + list.add(new ItemDto(item_to_spec1, "套管纸管1规格", "DB12.String605.60")); + list.add(new ItemDto(item_to_spec2, "套管纸管2规格", "DB12.String606.60")); + list.add(new ItemDto(item_to_qty1, "套管纸管数量", "DB12.W14")); + list.add(new ItemDto(item_to_size1, "套管纸管1尺寸", "DB12.W16")); + list.add(new ItemDto(item_to_size2, "套管纸管2尺寸", "DB12.W18")); + list.add(new ItemDto(item_to_material3, "下发套管纸管1编号", "DB12.String607.60")); + list.add(new ItemDto(item_to_material4, "下发套管纸管2编号", "DB12.String608.60")); + list.add(new ItemDto(item_to_spec3, "拔轴纸管1规格", "DB12.String609.60")); + list.add(new ItemDto(item_to_spec4, "拔轴纸管2规格", "DB12.String610.60")); + list.add(new ItemDto(item_to_qty2, "拔轴纸管数量", "DB12.W20")); + list.add(new ItemDto(item_to_size3, "拔轴纸管1尺寸", "DB12.W22")); + list.add(new ItemDto(item_to_size4, "拔轴纸管2尺寸", "DB12.W24")); return list; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java index efb3377df..00ca26a90 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/pull_head_manipulator/PullHeadManipulatorDeviceDriver.java @@ -127,7 +127,6 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp String lastToBarcode = null; - Boolean isonline = true; int hasGoods = 0; String message = null; @@ -248,7 +247,6 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp } - } catch (Exception var17) { var17.printStackTrace(); // feedMessage = var17.getMessage(); @@ -361,7 +359,7 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp Device device = deviceAppService.findDeviceByCode(nextDeviceCode); if (device.getDeviceDriver() instanceof PlugPullDeviceSiteDeviceDriver) { plugPullDeviceSiteDeviceDriver = (PlugPullDeviceSiteDeviceDriver) device.getDeviceDriver(); - if (plugPullDeviceSiteDeviceDriver.getMode() != 2 || plugPullDeviceSiteDeviceDriver.getMove() != 0 || plugPullDeviceSiteDeviceDriver.getAction() != 2) { + if (plugPullDeviceSiteDeviceDriver.getMove() != 0 || plugPullDeviceSiteDeviceDriver.getAction() != 2) { notCreateInstMessage = "universal_notCreateInstMessage9"; continue; } @@ -391,131 +389,139 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp return true; } } - } else { - List taskDtoList = taskserver.findByTrappedManipulatorReady(); - if (ObjectUtil.isNotEmpty(taskDtoList)) { - List taskDtosReady = new ArrayList<>(); - for (TaskDto taskDto1 : taskDtoList) { - if (getDeviceCodeList.contains(taskDto1.getStart_device_code())) { - taskDtosReady.add(taskDto1); + } else { + List taskDtoList = taskserver.findByTrappedManipulatorReady(); + if (ObjectUtil.isNotEmpty(taskDtoList)) { + List taskDtosReady = new ArrayList<>(); + for (TaskDto taskDto1 : taskDtoList) { + if (getDeviceCodeList.contains(taskDto1.getStart_device_code())) { + taskDtosReady.add(taskDto1); + } + } +// task = taskDtosReady.get(0); + List readyTaskDtos = new ArrayList<>(); + for (int j = 0; j < taskDtosReady.size(); j++) { + task = taskDtosReady.get(j); + String firstDeviceCode = task.getStart_device_code(); + Device start_device = deviceAppService.findDeviceByCode(firstDeviceCode); + if (start_device.getDeviceDriver() instanceof PlugPullDeviceSiteDeviceDriver) { + plugPullDeviceSiteDeviceDriver = (PlugPullDeviceSiteDeviceDriver) start_device.getDeviceDriver(); + if (plugPullDeviceSiteDeviceDriver.getAction() != 1) { + notCreateInstMessage = "universal_notCreateInstMessage12"; + continue; } } - //按照优先级排序 优先级相等按照创建时间排序 - taskDtosReady = this.sortTask(taskDtosReady); - task = taskDtosReady.get(0); - } - if (ObjectUtil.isNotEmpty(task)) { - break; + String nextDeviceCode = task.getNext_device_code(); + Device next_device = deviceAppService.findDeviceByCode(nextDeviceCode); + if (next_device.getDeviceDriver() instanceof PlugPullDeviceSiteDeviceDriver) { + plugPullDeviceSiteDeviceDriver = (PlugPullDeviceSiteDeviceDriver) next_device.getDeviceDriver(); + String remark = ""; +// if (plugPullDeviceSiteDeviceDriver.getMode() != 2) { +// remark = "universal_notCreateInstMessage9"; +// notCreateInstMessage = remark; +// continue; +// } + if (plugPullDeviceSiteDeviceDriver.getMove() != 0) { + remark = "universal_notCreateInstMessage9"; + notCreateInstMessage = remark; + continue; + } + if (plugPullDeviceSiteDeviceDriver.getAction() != 2) { + remark = "universal_notCreateInstMessage11"; + notCreateInstMessage = remark; + continue; + } + } + readyTaskDtos.add(task); } + //按照优先级排序 优先级相等按照创建时间排序 + readyTaskDtos = this.sortTask(readyTaskDtos); + task = readyTaskDtos.get(0); + } + if (ObjectUtil.isNotEmpty(task)) { + break; } } - if (!ObjectUtil.isEmpty(task)) { - String firstDeviceCode = task.getStart_device_code(); - Device start_device = deviceAppService.findDeviceByCode(firstDeviceCode); - if (start_device.getDeviceDriver() instanceof PlugPullDeviceSiteDeviceDriver) { - plugPullDeviceSiteDeviceDriver = (PlugPullDeviceSiteDeviceDriver) start_device.getDeviceDriver(); - if (plugPullDeviceSiteDeviceDriver.getAction() != 1) { - notCreateInstMessage = "universal_notCreateInstMessage12"; - return false; - } - } - String nextDeviceCode = task.getNext_device_code(); - Device next_device = deviceAppService.findDeviceByCode(nextDeviceCode); - if (next_device.getDeviceDriver() instanceof PlugPullDeviceSiteDeviceDriver) { - plugPullDeviceSiteDeviceDriver = (PlugPullDeviceSiteDeviceDriver) next_device.getDeviceDriver(); - String remark = ""; - if (plugPullDeviceSiteDeviceDriver.getMode() != 2) { - remark = "universal_notCreateInstMessage9"; - notCreateInstMessage = remark; - return false; - } - if (plugPullDeviceSiteDeviceDriver.getMove() != 0) { - remark = "universal_notCreateInstMessage9"; - notCreateInstMessage = remark; - return false; - } - if (plugPullDeviceSiteDeviceDriver.getAction() != 2) { - remark = "universal_notCreateInstMessage11"; - notCreateInstMessage = remark; - return false; - } - } - String taskId = task.getTask_id(); - String taskCode = task.getTask_code(); - String vehicleCode = task.getVehicle_code(); - String priority = task.getPriority(); - String startPointCode = task.getStart_point_code(); - String routePlanCode = task.getRoute_plan_code(); - String nextPointCode = task.getNext_point_code(); - - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(routePlanCode); - instdto.setRemark(task.getRemark()); - instdto.setMaterial(task.getMaterial()); - instdto.setQuantity(task.getQuantity()); - instdto.setTask_id(taskId); - instdto.setTask_code(taskCode); - instdto.setVehicle_code(vehicleCode); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by(SecurityUtils.getCurrentNickName()); - instdto.setStart_device_code(firstDeviceCode); - instdto.setNext_device_code(nextDeviceCode); - instdto.setStart_point_code(startPointCode); - instdto.setNext_point_code(nextPointCode); - instdto.setPriority(priority); - instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); - instdto.setExecute_device_code(startPointCode); - try { - instructionService.create(instdto); - } catch (Exception e) { - notCreateInstMessage = e.getMessage(); - LuceneLogDto logDto = LuceneLogDto.builder() - .device_code(device_code) - .content(device_code + "创建指令时出现异常:" + e.getMessage()) - .build(); - luceneExecuteLogService.deviceExecuteLog(logDto); - return false; - } - //创建指令后修改任务状态 - task.setTask_status(TaskStatusEnum.BUSY.getIndex()); - task.setUpdate_time(DateUtil.now()); - taskserver.update(task); - - Device startDevice = deviceAppService.findDeviceByCode(instdto.getStart_device_code()); - Device nextDevice = deviceAppService.findDeviceByCode(instdto.getNext_device_code()); - if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) { - notCreateInstMessage = "universal_notCreateInstMessage1"; - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); - throw new BadRequestException(LangProcess.msg("device_checkAdd", startDevice.getDevice_code())); - } - if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) { - notCreateInstMessage = "universal_notCreateInstMessage1"; - logServer.deviceExecuteLog(this.getDevice_code(), "", "", "设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); - throw new BadRequestException(LangProcess.msg("device_checkAdd", nextDevice.getDevice_code())); - - } - String startAddr = startDevice.getExtraValue().get("address").toString(); - String nextAddr = nextDevice.getExtraValue().get("address").toString(); - String interaction_json = task.getInteraction_json(); - Map map = toStringObjectMap(instdto, startAddr, nextAddr, interaction_json); - this.writing(map); - this.setRequireSucess(true); - notCreateInstMessage = ""; - notCreateTaskMessage = ""; - } else { - notCreateInstMessage = "universal_notCreateInstMessage"; - } - return true; } + if (!ObjectUtil.isEmpty(task)) { + String taskId = task.getTask_id(); + String taskCode = task.getTask_code(); + String vehicleCode = task.getVehicle_code(); + String priority = task.getPriority(); + String startPointCode = task.getStart_point_code(); + String routePlanCode = task.getRoute_plan_code(); + String nextPointCode = task.getNext_point_code(); + String firstDeviceCode = task.getStart_device_code(); + String nextDeviceCode = task.getNext_device_code(); + + Instruction instdto = new Instruction(); + instdto.setInstruction_id(IdUtil.simpleUUID()); + instdto.setRoute_plan_code(routePlanCode); + instdto.setRemark(task.getRemark()); + instdto.setMaterial(task.getMaterial()); + instdto.setQuantity(task.getQuantity()); + instdto.setTask_id(taskId); + instdto.setTask_code(taskCode); + instdto.setVehicle_code(vehicleCode); + String now = DateUtil.now(); + instdto.setCreate_time(now); + instdto.setCreate_by(SecurityUtils.getCurrentNickName()); + instdto.setStart_device_code(firstDeviceCode); + instdto.setNext_device_code(nextDeviceCode); + instdto.setStart_point_code(startPointCode); + instdto.setNext_point_code(nextPointCode); + instdto.setPriority(priority); + instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); + instdto.setExecute_device_code(startPointCode); + try { + instructionService.create(instdto); + } catch (Exception e) { + notCreateInstMessage = e.getMessage(); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(device_code) + .content(device_code + "创建指令时出现异常:" + e.getMessage()) + .build(); + luceneExecuteLogService.deviceExecuteLog(logDto); + return false; + } + //创建指令后修改任务状态 + task.setTask_status(TaskStatusEnum.BUSY.getIndex()); + task.setUpdate_time(DateUtil.now()); + taskserver.update(task); + + Device startDevice = deviceAppService.findDeviceByCode(instdto.getStart_device_code()); + Device nextDevice = deviceAppService.findDeviceByCode(instdto.getNext_device_code()); + if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) { + notCreateInstMessage = "universal_notCreateInstMessage1"; + logServer.deviceExecuteLog(this.getDevice_code(), "", "", "设备:" + startDevice.getDevice_code() + "未设置电气调度号!"); + throw new BadRequestException(LangProcess.msg("device_checkAdd", startDevice.getDevice_code())); + } + if (ObjectUtil.isEmpty(nextDevice.getExtraValue().get("address"))) { + notCreateInstMessage = "universal_notCreateInstMessage1"; + logServer.deviceExecuteLog(this.getDevice_code(), "", "", "设备:" + nextDevice.getDevice_code() + "未设置电气调度号!"); + throw new BadRequestException(LangProcess.msg("device_checkAdd", nextDevice.getDevice_code())); + + } + String startAddr = startDevice.getExtraValue().get("address").toString(); + String nextAddr = nextDevice.getExtraValue().get("address").toString(); + String interaction_json = task.getInteraction_json(); + Map map = toStringObjectMap(instdto, startAddr, nextAddr, interaction_json); + this.writing(map); + this.setRequireSucess(true); + notCreateInstMessage = ""; + notCreateTaskMessage = ""; + } else { + notCreateInstMessage = "universal_notCreateInstMessage"; + } + return true; } + } @NotNull private Map toStringObjectMap(Instruction instdto, String startAddr, String nextAddr, String interaction_json) { Map map = new LinkedHashMap<>(); - if(StrUtil.isNotEmpty(interaction_json) && !"".equals(interaction_json)){ + if (StrUtil.isNotEmpty(interaction_json) && !"".equals(interaction_json)) { JSONObject jsonObject = JSONObject.parseObject(interaction_json); //套管1物料 Object to_material1 = jsonObject.get("left"); @@ -556,34 +562,54 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp map.put("to_task", instdto.getInstruction_code()); map.put("to_target", nextAddr); //toTranscription(taskDto,map); - map.put("to_material1", to_material1); - if (ObjectUtil.isNotEmpty(to_material2)) { - map.put("to_material2", to_material2); + if (ObjectUtil.isEmpty(to_material1) && ObjectUtil.isNotEmpty(to_material2)) { + map.put("to_material1", to_material2); + if (ObjectUtil.isNotEmpty(to_spec2)) { + map.put("to_spec1", to_spec2); + } + if (ObjectUtil.isNotEmpty(to_size2)) { + map.put("to_size1", to_size2); + } + } else { + map.put("to_material1", to_material1); + if (ObjectUtil.isNotEmpty(to_material2)) { + map.put("to_material2", to_material2); + } + map.put("to_spec1", to_spec1); + if (ObjectUtil.isNotEmpty(to_spec2)) { + map.put("to_spec2", to_spec2); + } + map.put("to_size1", to_size1); + if (ObjectUtil.isNotEmpty(to_size2)) { + map.put("to_size2", to_size2); + } } - map.put("to_spec1", to_spec1); - if (ObjectUtil.isNotEmpty(to_spec2)) { - map.put("to_spec2", to_spec2); - } - map.put("to_size1", to_size1); - if (ObjectUtil.isNotEmpty(to_size2)) { - map.put("to_size2", to_size2); - } - map.put("to_material3", to_material3); - if (ObjectUtil.isNotEmpty(to_material4)) { - map.put("to_material4", to_material4); - } - map.put("to_size3", to_size3); - if (ObjectUtil.isNotEmpty(to_size4)) { - map.put("to_size4", to_size4); - } - map.put("to_spec3", to_spec3); - if (ObjectUtil.isNotEmpty(to_spec4)) { - map.put("to_spec4", to_spec4); + if (ObjectUtil.isEmpty(to_material3) && ObjectUtil.isNotEmpty(to_material4)) { + map.put("to_material3", to_material4); + if (ObjectUtil.isNotEmpty(to_size4)) { + map.put("to_size3", to_size4); + } + if (ObjectUtil.isNotEmpty(to_spec4)) { + map.put("to_spec3", to_spec4); + } + }else { + map.put("to_material3", to_material3); + if (ObjectUtil.isNotEmpty(to_material4)) { + map.put("to_material4", to_material4); + } + map.put("to_size3", to_size3); + if (ObjectUtil.isNotEmpty(to_size4)) { + map.put("to_size4", to_size4); + } + map.put("to_spec3", to_spec3); + if (ObjectUtil.isNotEmpty(to_spec4)) { + map.put("to_spec4", to_spec4); + } } map.put("to_qty1", to_qty1); map.put("to_qty2", to_qty2); return map; - }else{ + } else { map.put("to_command", CommonFinalParam.ONE); map.put("to_onset", startAddr); map.put("to_task", instdto.getInstruction_code()); @@ -592,33 +618,33 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp } } - private void toTranscription(TaskDto taskDto,Map map){ + private void toTranscription(TaskDto taskDto, Map map) { String interactionJson = taskDto.getInteraction_json(); InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class); - if(ObjectUtil.isNotEmpty(interactionJsonDTO)){ - toDevice(interactionJsonDTO.getToPull(),"to_pull",map); - toDevice(interactionJsonDTO.getIsBushing(),"is_bushing",map); - toDevice(interactionJsonDTO.getToSize(),"to_size",map); - toDevice(interactionJsonDTO.getToBarcode(),"to_barcode",map); - toDevice(interactionJsonDTO.getToMaterial1(),"to_material1",map); - toDevice(interactionJsonDTO.getToMaterial2(),"to_material2",map); - toDevice(interactionJsonDTO.getToSpec1(),"to_spec1",map); - toDevice(interactionJsonDTO.getToSpec2(),"to_spec2",map); - toDevice(interactionJsonDTO.getToQty1(),"to_qty1",map); - toDevice(interactionJsonDTO.getToSize1(),"to_size1",map); - toDevice(interactionJsonDTO.getToSize2(),"to_size2",map); - toDevice(interactionJsonDTO.getToMaterial3(),"to_material3",map); - toDevice(interactionJsonDTO.getToMaterial4(),"to_material4",map); - toDevice(interactionJsonDTO.getToSpec3(),"to_spec3",map); - toDevice(interactionJsonDTO.getToSpec4(),"to_spec4",map); - toDevice(interactionJsonDTO.getToQty2(),"to_qty2",map); - toDevice(interactionJsonDTO.getToSize3(),"to_size3",map); - toDevice(interactionJsonDTO.getToSize4(),"to_size4",map); + if (ObjectUtil.isNotEmpty(interactionJsonDTO)) { + toDevice(interactionJsonDTO.getToPull(), "to_pull", map); + toDevice(interactionJsonDTO.getIsBushing(), "is_bushing", map); + toDevice(interactionJsonDTO.getToSize(), "to_size", map); + toDevice(interactionJsonDTO.getToBarcode(), "to_barcode", map); + toDevice(interactionJsonDTO.getToMaterial1(), "to_material1", map); + toDevice(interactionJsonDTO.getToMaterial2(), "to_material2", map); + toDevice(interactionJsonDTO.getToSpec1(), "to_spec1", map); + toDevice(interactionJsonDTO.getToSpec2(), "to_spec2", map); + toDevice(interactionJsonDTO.getToQty1(), "to_qty1", map); + toDevice(interactionJsonDTO.getToSize1(), "to_size1", map); + toDevice(interactionJsonDTO.getToSize2(), "to_size2", map); + toDevice(interactionJsonDTO.getToMaterial3(), "to_material3", map); + toDevice(interactionJsonDTO.getToMaterial4(), "to_material4", map); + toDevice(interactionJsonDTO.getToSpec3(), "to_spec3", map); + toDevice(interactionJsonDTO.getToSpec4(), "to_spec4", map); + toDevice(interactionJsonDTO.getToQty2(), "to_qty2", map); + toDevice(interactionJsonDTO.getToSize3(), "to_size3", map); + toDevice(interactionJsonDTO.getToSize4(), "to_size4", map); } } - private void toDevice(String toOrder,String signal,Map map){ - if(ObjectUtil.isNotEmpty(toOrder)){ + private void toDevice(String toOrder, String signal, Map map) { + if (ObjectUtil.isNotEmpty(toOrder)) { map.put(signal, toOrder); } } @@ -710,12 +736,12 @@ public class PullHeadManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp action = LangProcess.msg("universal_releasing"); } else if (this.getAction() == 4) { action = LangProcess.msg("universal_releasing_completed"); - }else { + } else { action = "无动作"; } - if(error == 0 && this.itemProtocol.isError){ + if (error == 0 && this.itemProtocol.isError) { iserror = true; - }else if(error == 0 && !this.itemProtocol.isError){ + } else if (error == 0 && !this.itemProtocol.isError) { iserror = false; } map.put("device_name", this.getDevice().getDevice_name()); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java index dd1af3069..93a542745 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/slit_two_manipulator/SlitTwoManipulatorDeviceDriver.java @@ -769,8 +769,8 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl @Override public JSONObject getDeviceStatusName() { - Map map = new LinkedHashMap<>(); - +// Map map = new LinkedHashMap<>(); + JSONObject jo = new JSONObject(); String move_1 = ""; String move_2 = ""; String action = ""; @@ -841,26 +841,25 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl iserror = false; } } - map.put("device_name", this.getDevice().getDevice_name()); - map.put("mode", mode); - map.put("action", action); - map.put("walk_y", walk_y); - map.put("error", ErrorUtil.getDictDetail("error_type", String.valueOf(this.getError()))); - map.put("task", this.getTask()); - map.put("isOnline", this.getIsonline()); - map.put("isError", this.getIserror()); - map.put("is_disable1", this.getIs_disable()); - map.put("is_disable", is_disable); - map.put("is_click", true); - map.put("driver_type", "slit_two_manipulator"); - map.put("requireSucess", requireSucess); - map.put("move_1", move_1); - map.put("move_2", move_2); - map.put("message", message); - map.put("notCreateTaskMessage", LangProcess.msg(notCreateTaskMessage)); - map.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); - map.put("feedMessage", LangProcess.msg(feedMessage)); - JSONObject jo = new JSONObject(map); + jo.put("device_name", this.getDevice().getDevice_name()); + jo.put("mode", mode); + jo.put("action", action); + jo.put("walk_y", walk_y); + jo.put("error", ErrorUtil.getDictDetail("error_type", String.valueOf(this.getError()))); + jo.put("task", this.getTask()); + jo.put("isOnline", this.getIsonline()); + jo.put("isError", this.getIserror()); + jo.put("is_disable1", this.getIs_disable()); + jo.put("is_disable", is_disable); + jo.put("is_click", true); + jo.put("driver_type", "slit_two_manipulator"); + jo.put("requireSucess", requireSucess); + jo.put("move_1", move_1); + jo.put("move_2", move_2); + jo.put("message", message); + jo.put("notCreateTaskMessage", LangProcess.msg(notCreateTaskMessage)); + jo.put("notCreateInstMessage", LangProcess.msg(notCreateInstMessage)); + jo.put("feedMessage", LangProcess.msg(feedMessage)); return jo; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java index 97c58156d..4018df073 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java @@ -111,7 +111,7 @@ public class WmsToAcsController { } @PostMapping("/getTubeMsg") - @Log("wms下发废箔重量") + @Log("下发管芯信息") @SaIgnore public ResponseEntity getTubeMes(@RequestBody String whereJson) throws Exception { return new ResponseEntity<>(wmstoacsService.getTubeMes(whereJson), HttpStatus.OK); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java index 5c7d46db2..1de6f9f02 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java @@ -200,6 +200,13 @@ public interface AcsToWmsService { */ HttpResponse feedbackDies(JSONObject param); + /** + * 请求密集库出气胀轴,申请行架任务 + * @param param + * @return + */ + HttpResponse callShaftFromCache(JSONObject param); + String secondaryAllocationPoint(JSONObject param); /** diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java index 48bf4dd10..7abde1d30 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java @@ -555,18 +555,18 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { JSONObject jsonObject = JSONObject.parseObject(result); log.info("RGV工位上有货申请行架任务----返回参数{}", result); applyManipulatorActionResponse = JSONObject.toJavaObject(jsonObject, ApplyManipulatorActionResponse.class); + LuceneLogDto luceneLogDto = new LuceneLogDto(4, "applyManipulatorAction", String.valueOf(applyManipulatorActionResponse.getCode()), + JSON.toJSONString(param), String.valueOf(result), "RGV工位上有货申请行架任务"); + luceneLogService.interfaceExecuteLog(luceneLogDto); } catch (Exception e) { String message = e.getMessage(); JSONObject jsonObject = JSONObject.parseObject(result); log.info("RGV工位上有货申请行架任务----返回参数{}", result); applyManipulatorActionResponse = JSONObject.toJavaObject(jsonObject, ApplyManipulatorActionResponse.class); LuceneLogDto luceneLogDto = new LuceneLogDto(4, "applyManipulatorAction", String.valueOf(applyManipulatorActionResponse.getCode()), - JSON.toJSONString(param), message, "RGV工位上有货申请行架任务失败"); + JSON.toJSONString(param), String.valueOf(result), "RGV工位上有货申请行架任务失败"); luceneLogService.interfaceExecuteLog(luceneLogDto); } - LuceneLogDto luceneLogDto = new LuceneLogDto(4, "applyManipulatorAction", String.valueOf(applyManipulatorActionResponse.getCode()), - JSON.toJSONString(param), String.valueOf(applyManipulatorActionResponse), "RGV工位上有货申请行架任务"); - luceneLogService.interfaceExecuteLog(luceneLogDto); } return applyManipulatorActionResponse; } @@ -755,6 +755,40 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { } + @Override + public HttpResponse callShaftFromCache(JSONObject param) { + HttpResponse result2 = null; + try { + String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue(); + AddressDto addressDto = addressService.findByCode("callShaftFromCache"); + String url = wmsurl + addressDto.getMethods_url(); + log.info("callShaftFromCache - 请求密集库出气胀轴,申请行架任务请求路径{}", param); + try { + result2 = HttpRequest.post(url) + .header("Authorization", token) + .body(String.valueOf(param)) + .execute(); + } catch (Exception e) { + String msg = e.getMessage(); + log.info("callShaftFromCache-----请求密集库出气胀轴,申请行架任务输出参数{}", msg); + //网络不通 + } + log.info("callShaftFromCache - 请求密集库出气胀轴,申请行架任务{}", result2.body()); + LuceneLogDto luceneLogDto = new LuceneLogDto(4,"callShaftFromCache", String.valueOf(result2.getStatus()), + String.valueOf(param), + String.valueOf(result2.body()), "请求密集库出气胀轴,申请行架任务"); + luceneLogService.interfaceExecuteLog(luceneLogDto); + return result2; + } catch (Exception e) { + LuceneLogDto luceneLogDto = new LuceneLogDto(4,"callShaftFromCache", String.valueOf(result2.getStatus()), + JSON.toJSONString(result2.body()), + String.valueOf(result2.body()), "请求密集库出气胀轴,申请行架任务报错"); + luceneLogService.interfaceExecuteLog(luceneLogDto); + return null; + } + } + + @Override public JSONObject queryStationState(Instruction inst) { try { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java index 70746a245..b1fd8b609 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java @@ -15,6 +15,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.AcsConfig; import org.nl.acs.device.domain.Device; +import org.nl.acs.device.enums.DeviceType; import org.nl.acs.device_driver.agv.ndctwo.AgvNdcTwoDeviceDriver; import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver; import org.nl.acs.device_driver.conveyor.siemens_conveyor.SiemensConveyorDeviceDriver; @@ -94,9 +95,13 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { public CreateTaskResponse crateTask(String param) { try { MDC.put(log_file_type, log_type); - log.info("crateTask-----输入参数{}", param); - LuceneLogDto luceneLogDto = new LuceneLogDto(4, param, "acs接收lms任务"); - luceneLogService.interfaceExecuteLog(luceneLogDto); + log.info("ACS接收WMS任务-----输入参数{}", param); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code("ACS接收WMS任务") + .content("ACS接收WMS任务-----输入参数:" + param) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); JSONArray datas = JSONArray.parseArray(param); CreateTaskResponse response = new CreateTaskResponse(); // ParamService paramService = SpringContextHolder.getBean(ParamService.class); @@ -391,7 +396,13 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { } response.setErrArr(errArr); } - log.info("createFromWms--------------:输出参数:" + JSON.toJSONString(response)); + LuceneLogDto logDto1 = LuceneLogDto.builder() + .device_code("ACS接收WMS任务") + .content("ACS接收WMS任务-----返回参数:" + JSON.toJSONString(response)) + .build(); + logDto1.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto1); + log.info("ACS接收WMS任务--------------:输出参数:" + JSON.toJSONString(response)); return response; } finally { @@ -407,7 +418,13 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { @Override public Map updateTask(String whereJson) { JSONArray datas = JSONArray.parseArray(whereJson); - log.info("updateTask--------------:输入参数" + datas.toString()); + log.info("WMS更新任务点位状态--------------:输入参数" + datas.toString()); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code("WMS更新任务点位状态") + .content("WMS更新任务点位状态-----输入参数:" + whereJson) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); JSONArray errArr = new JSONArray(); if (datas.size() > 0) { for (int i = 0; i < datas.size(); i++) { @@ -475,6 +492,12 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { resultJson.put("errArr", errArr); } } + LuceneLogDto logDto1 = LuceneLogDto.builder() + .device_code("WMS更新任务点位状态") + .content("WMS更新任务点位状态-----返回参数:" + resultJson) + .build(); + logDto1.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto1); return resultJson; } @@ -495,10 +518,14 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { @Override public PutActionResponse putAction(String jsonObject) throws Exception { - log.info("putAction--------------:输入参数" + jsonObject); + log.info("WMS下发点位信号--------------:输入参数" + jsonObject); String date = new Date().toString(); - LuceneLogDto luceneLogDto = new LuceneLogDto(4, jsonObject, date + "LMS反馈ACS动作信号"); - luceneLogService.interfaceExecuteLog(luceneLogDto); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code("WMS下发点位信号") + .content("WMS下发点位信号-----输入参数:" + jsonObject) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); JSONArray datas = JSONArray.parseArray(jsonObject); PutActionResponse response = new PutActionResponse(); JSONArray errArr = new JSONArray(); @@ -555,19 +582,26 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { } response.setStatus(200); response.setMessage("success"); - LuceneLogDto luceneLogDto1 = new LuceneLogDto(4, "putAction", String.valueOf(response.getCode()), - jsonObject, String.valueOf(response), "LMS下发动作"); - luceneExecuteLogService.interfaceExecuteLog(luceneLogDto); - log.info("putAction--------------:输出参数:" + response); + LuceneLogDto logDto1 = LuceneLogDto.builder() + .device_code("WMS下发点位信号") + .content("WMS下发点位信号-----返回参数:" + JSON.toJSONString(response)) + .build(); + logDto1.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto1); + log.info("WMS下发点位信号--------------:输出参数:" + JSON.toJSONString(response)); return response; } @Override public Map putWeightAction(String jsonObject) throws Exception { - log.info("putWeightAction--------------:输入参数" + jsonObject); + log.info("wms下发废箔重量--------------:输入参数" + jsonObject); String date = new Date().toString(); - LuceneLogDto luceneLogDto = new LuceneLogDto(4, jsonObject, date + "LMS反馈ACS废箔重量"); - luceneLogService.interfaceExecuteLog(luceneLogDto); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code("wms下发废箔重量") + .content("wms下发废箔重量-----输入参数:" + jsonObject) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); JSONArray datas = JSONArray.parseArray(jsonObject); JSONObject jo = new JSONObject(); for (int i = 0; i < datas.size(); i++) { @@ -586,31 +620,27 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { if (StrUtil.equals("1", type)) { wasteFoilWeighingStationDriver.writing("to_command", "6"); Thread.sleep(1000); //休眠1秒 - while (true) { - if (wasteFoilWeighingStationDriver.getMode() == 6) { + while (wasteFoilWeighingStationDriver.getMode() == 6) { jo.put("currentWeight", wasteFoilWeighingStationDriver.getWeight());//当前重量 jo.put("lastWeight", wasteFoilWeighingStationDriver.getOld_weight());//上一次重量 jo.put("weightGap", wasteFoilWeighingStationDriver.getGap_weight());//重量差 break; } - } wasteFoilWeighingStationDriver.writing("to_command", "0"); } //称重确认信号 else if (StrUtil.equals("2", type)) { wasteFoilWeighingStationDriver.writing("to_command", "7"); Thread.sleep(1000); //休眠1秒 - while (true) { - if (wasteFoilWeighingStationDriver.getMode() == 7) { + while (wasteFoilWeighingStationDriver.getMode() == 7) { jo.put("currentWeight", wasteFoilWeighingStationDriver.getWeight());//当前重量 jo.put("lastWeight", wasteFoilWeighingStationDriver.getOld_weight());//上一次重量 jo.put("weightGap", wasteFoilWeighingStationDriver.getGap_weight());//重量差 break; - } } wasteFoilWeighingStationDriver.writing("to_command", "0"); } - } catch (InterruptedException e) { + } catch (Exception e) { e.printStackTrace(); } } @@ -619,17 +649,25 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { resultJson.put("status", HttpStatus.OK.value()); resultJson.put("message", "操作成功"); resultJson.put("data", jo); - log.info("putWeightAction--------------:输出参数" + resultJson.toString()); + LuceneLogDto logDto1 = LuceneLogDto.builder() + .device_code("wms下发废箔重量") + .content("wms下发废箔重量-----返回参数:" + resultJson) + .build(); + logDto1.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto1); + log.info("wms下发废箔重量--------------:输出参数" + resultJson.toString()); return resultJson; } @Override public Map getTubeMes(String jsonObject) throws Exception { - log.info("getTubeMes--------------:输入参数" + jsonObject); - LuceneLogDto luceneLogDto = new LuceneLogDto(4, "getTubeMes", "", - String.valueOf(jsonObject), - "", "下发管芯信息"); - luceneLogService.interfaceExecuteLog(luceneLogDto); + log.info("下发管芯信息--------------:输入参数" + jsonObject); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code("下发管芯信息") + .content("下发管芯信息-----输入参数:" + jsonObject) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); JSONArray datas = JSONArray.parseArray(jsonObject); Map map = new HashMap(); for (int i = 0; i < datas.size(); i++) { @@ -660,6 +698,12 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { JSONObject resultJson = new JSONObject(); resultJson.put("status", HttpStatus.OK.value()); resultJson.put("message", "操作成功"); + LuceneLogDto logDto1 = LuceneLogDto.builder() + .device_code("下发管芯信息") + .content("下发管芯信息-----返回参数:" + resultJson) + .build(); + logDto1.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto1); return resultJson; } @@ -667,6 +711,12 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { public Map queryDevice(String jsonObject) throws Exception { try { MDC.put(log_file_type, log_type); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code("WMS查询设备状态") + .content("WMS查询设备状态-----输入参数:" + jsonObject) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); JSONArray backja = new JSONArray(); JSONArray datas = JSONArray.parseArray(jsonObject); //表处下料行架机械手 @@ -859,9 +909,12 @@ public class WmsToAcsServiceImpl implements WmsToAcsService { resultJson.put("status", HttpStatus.OK.value()); resultJson.put("message", "操作成功"); resultJson.put("data", backja); - LuceneLogDto luceneLogDto = new LuceneLogDto(4, "queryDevice", String.valueOf(resultJson.get("status")), - jsonObject, String.valueOf(resultJson), "LMS查询设备状态"); - luceneExecuteLogService.interfaceExecuteLog(luceneLogDto); + LuceneLogDto logDto1 = LuceneLogDto.builder() + .device_code("WMS查询设备状态") + .content("WMS查询设备状态-----返回参数:" + resultJson) + .build(); + logDto1.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto1); return resultJson; } finally { MDC.remove(log_file_type); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/history/ErrorUtil.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/history/ErrorUtil.java index cb87e0412..5d0db5155 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/history/ErrorUtil.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/history/ErrorUtil.java @@ -37,32 +37,33 @@ public class ErrorUtil { for (int i = 0; i < dictDetailDtos.size(); i++) { Dict dictDetailDto = dictDetailDtos.get(i); String value = dictDetailDto.getValue(); -// String label = dictDetailDto.getLabel(); String en_label = dictDetailDto.getEn_label(); String in_label = dictDetailDto.getIn_label(); String zh_label = dictDetailDto.getZh_label(); - if (StrUtil.equals(value, error_code) && ObjectUtil.isNotEmpty(language)) { - if (language.contains("zh")){ - detail = zh_label; - break; - } - if (language.contains("in")){ - detail = in_label; - break; - } - if (language.contains("en")){ - detail = en_label; - break; - } - if(StrUtil.isEmpty(language)){ - detail = en_label; - break; - } + + if (!StrUtil.equals(value, error_code)) { + continue; + } + if (language.contains("zh")) { + detail = zh_label; + break; + } + if (language.contains("in")) { + detail = in_label; + break; + } + if (language.contains("en")) { + detail = en_label; + break; + } + if (StrUtil.isEmpty(language)) { + detail = en_label; + break; } } } - return detail == null ? LangProcess.msg("error_not_configured") : detail; - } + return detail ==null?LangProcess.msg("error_not_configured"):detail; +} public static Map getDictDetailByName(String type) { getDict(); @@ -100,8 +101,8 @@ public class ErrorUtil { String message; if (agvErrorNum == 0) { - code = "0"; - message = "正常"; + code = "0"; + message = "正常"; } else if (agvErrorNum < 0) { code = "-1"; message = "AGV上报报警代码有误"; diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 8ab17083a..0c8073ea3 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -421,8 +421,8 @@ public class InstructionServiceImpl extends CommonServiceImpl protocols; OpcServerManageDto OpcServer; + LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class); int error_num; String message; int maxResartNum; @@ -203,7 +205,7 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC if (!UnifiedDataAppService.isEquals(value, his)) { OpcItemDto itemDto = this.getItem(itemId); if (true) { -// this.logItemChanged(itemId, accessor_value, value, itemDto); + this.logItemChanged(itemId, accessor_value, value, itemDto); } if(!ObjectUtil.isEmpty(value) || "".equals(value)){ accessor_value.setValue(itemId, value); @@ -231,6 +233,17 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC if (log.isWarnEnabled()) { log.warn("OPC数据源: {} 所有内容都为空,检查网络, all_null:{} ,暂定{}s", tag, all_null,3); } + while (var18.hasNext()) { + Item item = (Item) var18.next(); + String itemId = item.getId(); + OpcItemDto itemDto = this.getItem(itemId); + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code("OPC数据源") + .content("OPC数据源:" + tag + "内容为:" + itemDto) + .build(); + logDto.setLog_level(4); + luceneExecuteLogService.deviceExecuteLog(logDto); + } ThreadUtl.sleep( 3000); break start; } else if (this.all_null < 6) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/rest/TaskController.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/rest/TaskController.java index 8b72ec2b8..9f644d289 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/rest/TaskController.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/rest/TaskController.java @@ -101,6 +101,13 @@ public class TaskController { return new ResponseEntity<>(HttpStatus.OK); } + @Log("取消任务和指令") + @PostMapping(value = "/cancelAndInst/{id}") + public ResponseEntity cancelAndInst(@RequestBody String id) throws Exception { + taskService.cancelAndInst(id); + return new ResponseEntity<>(HttpStatus.OK); + } + @Log("手动创建指令") @PostMapping(value = "/createInst/{id}") public ResponseEntity createInst(@RequestBody String id) throws Exception { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/TaskService.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/TaskService.java index 73a3e12ac..f14fe7d93 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/TaskService.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/TaskService.java @@ -303,6 +303,16 @@ public interface TaskService extends CommonService { void cancel(String ids) throws Exception; + + /** + * 取消任务和指令 + * + * @param ids + * @throws Exception + */ + void cancelAndInst(String ids) throws Exception; + + /** * 手动创建指令 * diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index dce19578c..78bdc2b7d 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -881,6 +881,38 @@ public class TaskServiceImpl extends CommonServiceImpl impleme } } + @Override + @Transactional(rollbackFor = Exception.class) + public void cancelAndInst(String id) throws Exception { + TaskDto entity = this.findById(id); + if (entity == null) { + throw new BadRequestException(LangProcess.msg("error_sysAuth")); + } + + InstructionDto instdto = instructionService.findByTaskid(id, "instruction_status <2 "); + if (instdto != null) { + instructionService.cancel(instdto.getInstruction_id()); + } + + String currentUsername = SecurityUtils.getCurrentNickName(); + String now = DateUtil.now(); + entity.setUpdate_time(now); + entity.setUpdate_by(currentUsername); + entity.setTask_status(TaskStatusEnum.CANCEL.getIndex()); + + Task task = ConvertUtil.convert(entity, Task.class); + taskMapper.updateById(task); + + //移除任务缓存信息 + this.removeByCodeFromCache(entity.getTask_code()); + //反馈上位系统任务状态 + this.feedWmsTaskStatus(entity); + //关闭仙工运单序列 + if(StrUtil.equals(task.getTask_type(),TaskTypeEnum.Standard_AGV_Task.getCode()) && (StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.One_NDC_System_Type.getCode())||StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.XG_System_Type.getCode()))) { + this.markComplete(entity); + } + } + @Override public Instruction createInst(String ids) throws Exception { @@ -1656,7 +1688,14 @@ public class TaskServiceImpl extends CommonServiceImpl impleme JSONArray ja = new JSONArray(); ja.add(feed_jo); //TODO 有需要根据上位系统反馈的信息再做进一步处理 - acstowmsService.feedTaskStatus(ja); + CompletableFuture.runAsync(() -> { + acstowmsService.feedTaskStatus(ja); + // 异步更新任务状态 + try { + } catch (Exception e) { + e.printStackTrace(); + } + }); } } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/SecurityUtils.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/SecurityUtils.java index b434369ee..3bd6023c0 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/SecurityUtils.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/common/utils/SecurityUtils.java @@ -29,7 +29,11 @@ public class SecurityUtils { return json.toBean(CurrentUser.class); } } catch (Exception e) { - return new CurrentUser(); + CurrentUser currentUser = new CurrentUser(); + currentUser.setId("2"); + currentUser.setPresonName("外部系统用户"); + currentUser.setUsername("default"); + return currentUser; } return null; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/config/lucene/config/AsyncLuceneAppender.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/config/lucene/config/AsyncLuceneAppender.java index d5156de66..1c11641e7 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/config/lucene/config/AsyncLuceneAppender.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/config/lucene/config/AsyncLuceneAppender.java @@ -37,7 +37,11 @@ public class AsyncLuceneAppender extends AspectLogbackAsyncAppender { } MDC.clear(); } - super.append(event); + try { + super.append(event); + }catch (Exception e){ + e.printStackTrace(); + } } } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/user/UserController.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/user/UserController.java index 3a952322d..04ec08eab 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/user/UserController.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/controller/user/UserController.java @@ -65,7 +65,6 @@ public class UserController { } @Log("新增用户") - @PostMapping // @SaCheckPermission("user:add") public ResponseEntity create(@RequestBody Map user){ @@ -74,7 +73,6 @@ public class UserController { } @Log("修改用户") - @PutMapping // @SaCheckPermission("user:edit") public ResponseEntity update( @RequestBody Map resources) throws Exception { @@ -83,7 +81,6 @@ public class UserController { } @Log("修改用户:个人中心") - public ResponseEntity center(@RequestBody SysUser resources){ if(!resources.getUser_id().equals(StpUtil.getLoginIdAsLong())){ throw new BadRequestException(LangProcess.msg("error_sysAuth")); @@ -93,7 +90,6 @@ public class UserController { } @Log("删除用户") - @DeleteMapping public ResponseEntity delete(@RequestBody Set ids) { userService.removeByIds(ids); diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/AutoCreateInst.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/AutoCreateInst.java index e0c7121a9..45c0d30ef 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/AutoCreateInst.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/AutoCreateInst.java @@ -207,6 +207,7 @@ public class AutoCreateInst { } //创建指令后修改任务状态 acsTask.setTask_status(TaskStatusEnum.BUSY.getIndex()); + acsTask.setUpdate_time(DateUtil.now()); taskserver.update(acsTask); } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/user/impl/ISysUserServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/user/impl/ISysUserServiceImpl.java index db8ea9c7c..c17023930 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/user/impl/ISysUserServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/user/impl/ISysUserServiceImpl.java @@ -78,6 +78,17 @@ public class ISysUserServiceImpl extends ServiceImpl imp @SneakyThrows public void create(Map userDetail) { SysUser sysUser = new SysUser(); + //userDetail 中 createTime是string类型BeanUtils.populate不支持解析或者使用MapStruct + ConvertUtils.register((m, o) -> { + try { + if (o == null) { + return null; + } + return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(o.toString()); + } catch (Exception ex) { + return new Date(); + } + }, Date.class); BeanUtils.populate(sysUser,userDetail); // 默认密码 123456 if (ObjectUtil.isEmpty(sysUser.getPassword())) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/resources/config/application.yml b/acs2/nladmin-system/nlsso-server/src/main/resources/config/application.yml index e214136b0..a038b7eb6 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/resources/config/application.yml +++ b/acs2/nladmin-system/nlsso-server/src/main/resources/config/application.yml @@ -51,7 +51,7 @@ spring: monitorInterval: 8 tomcatTp: # tomcat webserver 线程池配置 threadPoolAliasName: tomcat 线程池 # 线程池别名,可选 - corePoolSize: 10 + corePoolSize: 30 maximumPoolSize: 50 keepAliveTime: 60 runTimeout: 10000 @@ -60,8 +60,8 @@ spring: - threadPoolName: dtpExecutor1 # 线程池名称,必填 threadPoolAliasName: core_thread # 线程池别名,可选 executorType: common # 线程池类型 common、eager、ordered、scheduled、priority,默认 common - corePoolSize: 10 # 核心线程数,默认1 - maximumPoolSize: 30 # 最大线程数,默认cpu核数 + corePoolSize: 30 # 核心线程数,默认1 + maximumPoolSize: 50 # 最大线程数,默认cpu核数 queueCapacity: 1024 # 队列容量,默认1024 queueType: VariableLinkedBlockingQueue # 任务队列,查看源码QueueTypeEnum枚举类,默认VariableLinkedBlockingQueue rejectedHandlerType: CallerRunsPolicy # 拒绝策略,查看RejectedTypeEnum枚举类,默认AbortPolicy diff --git a/acs2/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml b/acs2/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml index 89e91ef1f..229eeefe3 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml +++ b/acs2/nladmin-system/nlsso-server/src/main/resources/logback-spring.xml @@ -54,7 +54,7 @@ https://juejin.cn/post/6844903775631572999 - + 0 500 diff --git a/acs2/nladmin-ui/src/api/acs/task/task.js b/acs2/nladmin-ui/src/api/acs/task/task.js index 4238a9a4d..f118e1124 100644 --- a/acs2/nladmin-ui/src/api/acs/task/task.js +++ b/acs2/nladmin-ui/src/api/acs/task/task.js @@ -40,6 +40,14 @@ export function cancel(task_id) { }) } +export function cancelAndInst(task_id) { + return request({ + url: 'api/task/cancelAndInst/' + task_id, + method: 'post', + data: task_id + }) +} + export function createInst(task_id) { return request({ url: 'api/task/createInst/' + task_id, @@ -95,5 +103,5 @@ export function reload() { }) } -export default { add, edit, del, finish, cancel, createTaskByClick, deviceAskTask, ordinaryTaskCreate, specialTaskCreate, createInst, reload } +export default { add, edit, del, finish, cancel, createTaskByClick, deviceAskTask, ordinaryTaskCreate, specialTaskCreate, createInst, reload ,cancelAndInst} diff --git a/acs2/nladmin-ui/src/i18n/langs/task/en.js b/acs2/nladmin-ui/src/i18n/langs/task/en.js index 12a4304b9..2a76c045f 100644 --- a/acs2/nladmin-ui/src/i18n/langs/task/en.js +++ b/acs2/nladmin-ui/src/i18n/langs/task/en.js @@ -44,6 +44,7 @@ export default { 'In_progress': 'In Progress', 'Completed': 'Completed', 'Forced_Completed': 'Forced Completed', + 'Cancel_Tasks_And_Commands': 'Cancel tasks and commands', 'Pickup_point': 'Pickup Point', 'Delivery_point': 'Delivery Point', 'Remark': 'Remark', diff --git a/acs2/nladmin-ui/src/i18n/langs/task/in.js b/acs2/nladmin-ui/src/i18n/langs/task/in.js index 3563c5868..006a4862c 100644 --- a/acs2/nladmin-ui/src/i18n/langs/task/in.js +++ b/acs2/nladmin-ui/src/i18n/langs/task/in.js @@ -44,6 +44,7 @@ export default { 'In_progress': 'Sedang Berlangsung', 'Completed': 'Selesai', 'Forced_Completed': 'Penyelesaian wajib', + 'Cancel_Tasks_And_Commands': 'Batalkan misi dan perintah', 'Pickup_point': 'Titik Pengambilan', 'Delivery_point': 'Titik Pengiriman', 'Remark': 'Catatan', diff --git a/acs2/nladmin-ui/src/i18n/langs/task/zh.js b/acs2/nladmin-ui/src/i18n/langs/task/zh.js index 6c734df0a..2c537da26 100644 --- a/acs2/nladmin-ui/src/i18n/langs/task/zh.js +++ b/acs2/nladmin-ui/src/i18n/langs/task/zh.js @@ -44,6 +44,7 @@ export default { 'In_progress': '执行中', 'Completed': '完成', 'Forced_Completed': '强制完成', + 'Cancel_Tasks_And_Commands': '取消任务和指令', 'Pickup_point': '取货点', 'Delivery_point': '放货点', 'Remark': '备注', diff --git a/acs2/nladmin-ui/src/views/acs/device/config.vue b/acs2/nladmin-ui/src/views/acs/device/config.vue index 9e7d96372..c14de0f08 100644 --- a/acs2/nladmin-ui/src/views/acs/device/config.vue +++ b/acs2/nladmin-ui/src/views/acs/device/config.vue @@ -112,6 +112,7 @@ import dry_manipulator from '@/views/acs/device/driver/dry_manipulator.vue' import blanking_button from '@/views/acs/device/driver/blanking_button.vue' import pull_head_manipulator from '@/views/acs/device/driver/pull_head_manipulator.vue' import pull_tail_manipulator from '@/views/acs/device/driver/pull_tail_manipulator.vue' +import die_manipulator from '@/views/acs/device/driver/die_manipulator.vue' import green_foil_machine_button from '@/views/acs/device/driver/green_foil_machine_button.vue' import inflatable_shaft_library from '@/views/acs/device/driver/inflatable_shaft_library.vue' import manipulator_agv_station from '@/views/acs/device/driver/manipulator_agv_station.vue' @@ -196,7 +197,8 @@ export default { volume_two_manipulator, manipulator_cache, paper_tube_pick_size, - one_rgv + one_rgv, + die_manipulator }, dicts: ['device_type'], mixins: [crud], diff --git a/acs2/nladmin-ui/src/views/acs/device/customPolicy/task/index.vue b/acs2/nladmin-ui/src/views/acs/device/customPolicy/task/index.vue index 06257468d..adf753535 100644 --- a/acs2/nladmin-ui/src/views/acs/device/customPolicy/task/index.vue +++ b/acs2/nladmin-ui/src/views/acs/device/customPolicy/task/index.vue @@ -7,7 +7,7 @@
- +
- - - - - - - - - - + - + + + + + + + + + + +