diff --git a/acs/produceshiftorderdetail.js b/acs/produceshiftorderdetail.js deleted file mode 100644 index 3c60214..0000000 --- a/acs/produceshiftorderdetail.js +++ /dev/null @@ -1,27 +0,0 @@ -import request from '@/utils/request' - -export function add(data) { - return request({ - url: 'api/produceshiftorderdetail', - method: 'post', - data - }) -} - -export function del(ids) { - return request({ - url: 'api/produceshiftorderdetail/', - method: 'delete', - data: ids - }) -} - -export function edit(data) { - return request({ - url: 'api/produceshiftorderdetail', - method: 'put', - data - }) -} - -export default { add, edit, del } diff --git a/nladmin-system/pom.xml b/nladmin-system/pom.xml index affa150..4c14d29 100644 --- a/nladmin-system/pom.xml +++ b/nladmin-system/pom.xml @@ -19,13 +19,6 @@ 7.6.1 - - - e-iceblue - spire.xls.free - 5.1.0 - - net.logstash.logback logstash-logback-encoder @@ -39,21 +32,6 @@ mongo-java-driver 3.4.2 - - - - com.alicp.jetcache @@ -320,10 +298,6 @@ - - com.e-iceblue - http://repo.e-iceblue.cn/repository/maven-public/ - diff --git a/nladmin-system/src/main/java/org/nl/acs/agv/rest/AgvController.java b/nladmin-system/src/main/java/org/nl/acs/agv/rest/AgvController.java deleted file mode 100644 index b2c1d4f..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/agv/rest/AgvController.java +++ /dev/null @@ -1,103 +0,0 @@ -package org.nl.acs.agv.rest; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.device.service.DeviceService; -import org.nl.annotation.Log; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletRequest; -import java.util.Enumeration; - -@RestController -@RequiredArgsConstructor -@Api(tags = "AGV任务") -@RequestMapping("/api") -@Slf4j -public class AgvController { - @Autowired - AgvService agvService; - @Autowired - DeviceService deviceService; - - - @PostMapping("/agvack/{device}") - @Log("AGV请求离开") - @ApiOperation("AGV请求离开") - //@PreAuthorize("@el.check('routePlan:list')") - public ResponseEntity requestAck(@PathVariable String device) { -// String device= MapUtil.getStr(param,"device"); - return new ResponseEntity<>(agvService.requestAck(device), HttpStatus.OK); - } - - @GetMapping("/autodoor/doors/{device}") - @Log("查询自动门状态") - @ApiOperation("查询自动门状态") - public ResponseEntity queryDoorStatus(HttpServletRequest req) { - String serviceName = req.getRequestURI(); - String param = StringUtils.substringAfterLast(serviceName, "/"); - return new ResponseEntity<>(agvService.queryDoorStatus(param), HttpStatus.OK); - } - - @GetMapping("/autodoor/doors") - @Log("查询自动门状态") - @ApiOperation("查询自动门状态") - public ResponseEntity queryAllDoorStatus(HttpServletRequest req) { - return new ResponseEntity<>(agvService.queryAllDoorStatus(), HttpStatus.OK); - } - - @PostMapping("/autodoor/doors/{device}") - @Log("请求自动门开门关门") - @ApiOperation("请求自动门开门关门") - public ResponseEntity requestOpenOrCloseDoor(@PathVariable String device, HttpServletRequest req) { - Enumeration parameterNames = req.getParameterNames(); - String paramName = (String) parameterNames.nextElement(); - String parameterValue = req.getParameter(paramName); - return new ResponseEntity<>(agvService.requestOpenOrCloseDoor(device, parameterValue), HttpStatus.OK); - - } - - @GetMapping("/agvInst/{instcode}") - @Log("下发agv任务") - @ApiOperation("下发agv任务") - //@PreAuthorize("@el.check('routePlan:list')") - public ResponseEntity sendAgvInst(@PathVariable String instcode) throws Exception { - return new ResponseEntity<>(agvService.sendAgvInstToMagic(instcode), HttpStatus.OK); - } - - @GetMapping("/waitPointRequest/locationDevices/{param}") - @Log("agv等待点请求") - @ApiOperation("下发agv任务") - //@PreAuthorize("@el.check('routePlan:list')") - public ResponseEntity waitPointRequest(HttpServletRequest req) throws Exception { - String serviceName = req.getRequestURI(); - String param = StringUtils.substringAfterLast(serviceName, "/"); - return new ResponseEntity<>(agvService.waitPointRequest(param), HttpStatus.OK); - } - - @GetMapping("/findAllAgvFromCache") - @Log("查询内存AGV设备状态") - @ApiOperation("查询内存AGV设备状态") - //@PreAuthorize("@el.check('routePlan:list')") - public ResponseEntity findAllAgvFromCache() throws Exception { - return new ResponseEntity<>(agvService.findAllAgvFromCache(), HttpStatus.OK); - } - - - @GetMapping("/queryDeviceStation") - @Log("查询库位同步") - @ApiOperation("查询库位同步") - //@PreAuthorize("@el.check('routePlan:list')") - public ResponseEntity queryDevice() throws Exception { - return new ResponseEntity<>(agvService.queryDeviceStation(), HttpStatus.OK); - } - - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvService.java b/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvService.java deleted file mode 100644 index 904240e..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvService.java +++ /dev/null @@ -1,182 +0,0 @@ -package org.nl.acs.agv.server; - -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSONObject; -import org.nl.acs.agv.server.dto.AgvDto; -import org.nl.acs.instruction.service.dto.Instruction; - -import java.util.Map; - -public interface AgvService { - - /** - * 下发agv任务 - * - * @param inst 指令对象 - */ - public HttpResponse sendAgvInstToMagic(Instruction inst) throws Exception; - - public HttpResponse markComplete(String code) throws Exception; - - public HttpResponse sendAgvInstToMagic(String code) throws Exception; - - public void sendAgvInstToNDC(Instruction inst) throws Exception; - - public void sendAgvInstToNDC(String code) throws Exception; - - public HttpResponse queryAgvInstStatus(String instCode); - - public HttpResponse queryMagicAgvDeviceStatus(); - - public HttpResponse queryXZAgvDeviceStatus(); - - public HttpResponse queryXZAgvInstStatus(String instCode); - - Map findAllAgvFromCache(); - - void updateAgvFromCache(AgvDto dto); - - /** - * 删除magic任务 - * - * @param instCode - * @return - */ - public HttpResponse deleteAgvInst(String instCode); - - /** - * 删除先知任务 - * - * @param instCode - * @return - */ - public HttpResponse deleteXZAgvInst(String instCode); - - /** - * 删除NDC任务 - * - * @param inst - * @throws Exception - */ - public void deleteAgvInstToNDC(Instruction inst) throws Exception; - - - /** - * 查询Magic AGV任务状态调用 - * - * @param jobno - * @param type - * @param address - * @param action - * @param processingVehicle - * @return - */ - public String process(String jobno, String type, String address, String action, String processingVehicle); - - /** - * Magic AGV 请求离开调用 - * - * @param device - * @return - */ - public String requestAck(String device); - - /** - * 先工agv 等待点请求 - * - * @param - * @return - */ - public String waitPointRequest(String param); - - /** - * 请求开门、关门 - * - * @param device - * @return - */ - public String requestOpenOrCloseDoor(String device, String param); - - /** - * 查询自动门状态 - * - * @param device - * @return - */ - public String queryDoorStatus(String device); - - public String queryAllDoorStatus(); - - - /** - * 下发NDC agv单工动作指令 - * - * @param phase - * @param index - * @param result1 - * @param result2 - */ - public byte[] sendAgvOneModeInst(int phase, int index, int result1, int result2); - - /** - * 下发agv单工动作指令 - * - * @param phase - * @param index - */ - public byte[] sendAgvOneModeInst(int phase, int index); - - /** - * 反馈agv单工动作指令 - * - * @param phase - * @param index - */ - public byte[] sendAgvOneModeInst(int phase, int index, int result); - - - /** - * 下发运单序列 - * - * @param inst - * @return - * @throws Exception - */ - public HttpResponse sendOrderSequencesToXZ(Instruction inst) throws Exception; - - public HttpResponse addOrderSequences(Instruction inst) throws Exception; - - /** - * 组织json数据 - * - * @param - * @return - * @throws Exception - */ - public String sendOrderSequencesParam(Instruction inst) throws Exception; - - public JSONObject createOrederData(Instruction inst, String type); - - /** - * magic 全部暂停车辆 - */ - public HttpResponse pause() throws Exception; - - /** - * magic 暂停指定车辆 - */ - public HttpResponse pause(String device_code) throws Exception; - - /** - * magic 全部恢复车辆 - */ - public HttpResponse resume() throws Exception; - - /** - * magic 恢复指定车辆 - */ - public HttpResponse resume(String device_code) throws Exception; - - - String queryDeviceStation(); -} diff --git a/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java b/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java deleted file mode 100644 index ed1333a..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.nl.acs.agv.server.dto; - -import lombok.Data; - -import java.io.Serializable; - -@Data -public class AgvDto implements Serializable { - - /** - * 名称 - */ - private String name; - - /** - * 机器人当前的自身状态 - *

- * UNKNOWN:未知状态 - * UNAVAILABLE:通信超时或者已断开连接 - * ERROR:错误状态 - * IDLE:空闲状态 - * EXECUTING:正在执行运单 - * CHARGING:正在充电 - */ - private String state; - - /** - * 机器人的剩余电量值(单位:整数百分比) - */ - private String energyLevel; - - /** - * - */ - private String energyLevelGood; - - /** - * 机器人在 SRD 系统中的在线状态 - *

- * TO_BE_IGNORED:机器人处于离线状态,SRD 不会标识出机器人位置。 - * TO_BE_NOTICED:机器人处于离线状态,SRD 标识出机器人的位置。 - * TO_BE_RESPECTED:机器人处于在线状态,但不能接受新的运单。 - * TO_BE_UTILIZED:机器人处于在线状态,可以接受并执行新的运单。 - */ - private String integrationLevel; - - /** - * 机器人当前的运单执行状态 - *

- * UNAVAILABLE:无法执行任何运单和任务 - * IDLE:空闲状态 - * AWAITING_ORDER:机器人在等待运单中新的子任务 - * PROCESSING_ORDER:机器人正在执行运单 - */ - private String procState; - - /** - * 角度 - */ - private String positionAngle; - - /** - * X坐标 - */ - private String positionX; - - /** - * Y坐标 - */ - private String positionY; - - /** - * 当前任务号 - */ - private String transportOrder; - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java b/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java deleted file mode 100644 index d846ff5..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java +++ /dev/null @@ -1,1750 +0,0 @@ -package org.nl.acs.agv.server.impl; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpRequest; -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.agv.server.dto.AgvDto; -import org.nl.acs.config.AcsConfig; -import org.nl.acs.config.server.AcsConfigService; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device.service.impl.DeviceServiceImpl; -import org.nl.acs.device_driver.machines_site.MachinesSiteDeviceDriver; -import org.nl.acs.device_driver.special_ordinary_site.SpecialOrdinarySiteDeviceDriver; -import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver; -import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; -import org.nl.acs.device_driver.standard_manipulator_inspect_site.StandardManipulatorInspectSiteDeviceDriver; -import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; -import org.nl.acs.device_driver.standard_storage.StandardStorageDeviceDriver; -import org.nl.acs.device_driver.weighing_site.WeighingSiteDeviceDriver; -import org.nl.acs.ext.erp.service.AcsToErpService; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.log.service.LogServer; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.acs.opc.DeviceType; -import org.nl.acs.task.service.TaskService; -import org.nl.exception.BadRequestException; -import org.nl.start.auto.run.NDCSocketConnectionAutoRun; -import org.nl.utils.SpringContextHolder; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.*; - -@Slf4j -@Service -@RequiredArgsConstructor -public class AgvServiceImpl implements AgvService { - - @Autowired - DeviceAppService deviceAppService; - @Autowired - TaskService taskService; - @Autowired - InstructionService instructionService; - @Autowired - AcsConfigService acsConfigService; - @Autowired - AcsToErpService acsToErpService; - @Autowired - AcsToWmsService acsToWmsService; - - private final LogServer logServer; - - Map AGVDeviceStatus = new HashMap(); - - /** - * 获得之后num个天的时间 - * - * @param num - * @return - */ - public static String getNextDay(int num) { - Calendar calendar = Calendar.getInstance(); - calendar.add(Calendar.DAY_OF_MONTH, num); - Date date = calendar.getTime(); - TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai"); - DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - df.setTimeZone(tz); - String nowAsISO = df.format(date); - return nowAsISO; - } - - /** - * 返回一个点位操作子任务 - * - * @param locationName 点位 - * @param operation 点位操作 - * @param propertiesType 子任务类型 - * @param pro 子任务参数 - * 调用demo:destination("sh15p", "Spin", "2", "3.14") - * demo:destination("cz14", "JackUnload", "3", "") - * @return - */ - public static JSONObject destination(String locationName, String operation, String propertiesType, String pro) { - //新增业务订单 - JSONObject destinationOrder = new JSONObject(); - //目标工作站 - destinationOrder.put("locationName", locationName); - //机器人在工作站要执行的操作 - destinationOrder.put("operation", operation); - if (propertiesType.equals("1")) {//取货前等待、取货后等待 - - //pro 1 进入离开等待 - if ("1".equals(pro)) { - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - pro1.put("key", "EntryRequired"); - pro1.put("value", "True"); - properties.add(pro1); - JSONObject pro2 = new JSONObject(); - pro2.put("key", "PauseOnStation"); - pro2.put("value", "True"); - properties.add(pro2); - destinationOrder.put("properties", properties); - //进入等待 离开不等待 - } else if ("2".equals(pro)) { - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - pro1.put("key", "EntryRequired"); - pro1.put("value", "True"); - properties.add(pro1); - JSONObject pro2 = new JSONObject(); - pro2.put("key", "PauseOnStation"); - pro2.put("value", "False"); - properties.add(pro2); - destinationOrder.put("properties", properties); - //进入不等待 离开等待 - } else if ("3".equals(pro)) { - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - pro1.put("key", "EntryRequired"); - pro1.put("value", "False"); - properties.add(pro1); - JSONObject pro2 = new JSONObject(); - pro2.put("key", "PauseOnStation"); - pro2.put("value", "True"); - properties.add(pro2); - destinationOrder.put("properties", properties); - //不等待 - } else { - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - pro1.put("key", "EntryRequired"); - pro1.put("value", "False"); - properties.add(pro1); - JSONObject pro2 = new JSONObject(); - pro2.put("key", "PauseOnStation"); - pro2.put("value", "False"); - properties.add(pro2); - destinationOrder.put("properties", properties); - } - - } else if (propertiesType.equals("2")) {//Spin转动 - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - pro1.put("key", "global_spin_angle");//坐标系类型,global_spin_angle为全局坐标系 - pro1.put("value", pro);//弧度值,如3.14 - properties.add(pro1); - JSONObject pro2 = new JSONObject(); - pro2.put("key", "spin_direction");//固定值 - pro2.put("value", "0");//弧度值,如0 - properties.add(pro2); - destinationOrder.put("properties", properties); - } else if (propertiesType.equals("3")) {//JackUnload,Jackload不操作 - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - pro1.put("key", "recognize");//固定值 - pro1.put("value", "false");//固定值 - properties.add(pro1); - destinationOrder.put("properties", properties); - } else if (propertiesType.equals("4")) { - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - pro1.put("key", "robot_spin_angle");//坐标系类型,robot_spin_angle为机器人坐标系 - pro1.put("value", pro);//弧度值,如3.14 - properties.add(pro1); - JSONObject pro2 = new JSONObject(); - pro2.put("key", "spin_direction");//固定值 - pro2.put("value", "0");//弧度值,如0 - properties.add(pro2); - destinationOrder.put("properties", properties); - } - return destinationOrder; - } - - /** - * 返回一个点位操作子任务 先知使用 - * - * @param locationName 点位 - * @param operation 点位操作 - * @param propertiesType 子任务类型 - * @param pro 子任务参数 - * 调用demo:destination("sh15p", "Spin", "2", "3.14") - * demo:destination("cz14", "JackUnload", "3", "") - * @return - */ - public static JSONObject destination2(String locationName, String operation, String propertiesType, String pro) { - //新增业务订单 - JSONObject destinationOrder = new JSONObject(); - //目标工作站 - destinationOrder.put("locationName", locationName); - //机器人在工作站要执行的操作 - destinationOrder.put("operation", operation); - if (propertiesType.equals("1")) {//Wait请求是否继续 - JSONArray properties = new JSONArray(); - JSONObject pro2 = new JSONObject(); - pro2.put("key", "device:queryAtExecuted");//固定值 - pro2.put("value", pro + ":wait");//pro为wait请求的标识,一般用点位拼接的字符串 - properties.add(pro2); - destinationOrder.put("properties", properties); - } else if (propertiesType.equals("2")) {//Spin转动 - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - pro1.put("key", "global_spin_angle");//坐标系类型,global_spin_angle为全局坐标系 - pro1.put("value", pro);//弧度值,如3.14 - properties.add(pro1); - JSONObject pro2 = new JSONObject(); - pro2.put("key", "spin_direction");//固定值 - pro2.put("value", "0");//弧度值,如0 - properties.add(pro2); - destinationOrder.put("properties", properties); - } else if (propertiesType.equals("3")) {//JackUnload,Jackload不操作 - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - pro1.put("key", "recognize");//固定值 - pro1.put("value", "false");//固定值 - properties.add(pro1); - destinationOrder.put("properties", properties); - } else if (propertiesType.equals("4")) { - JSONArray properties = new JSONArray(); - JSONObject pro1 = new JSONObject(); - pro1.put("key", "robot_spin_angle");//坐标系类型,robot_spin_angle为机器人坐标系 - pro1.put("value", pro);//弧度值,如3.14 - properties.add(pro1); - JSONObject pro2 = new JSONObject(); - pro2.put("key", "spin_direction");//固定值 - pro2.put("value", "0");//弧度值,如0 - properties.add(pro2); - destinationOrder.put("properties", properties); - } else if (propertiesType.equals("5")) {//Wait请求是否继续 - JSONArray properties = new JSONArray(); - JSONObject pro2 = new JSONObject(); - - destinationOrder.put("properties", "[]"); - } - return destinationOrder; - } - - @Override - public HttpResponse sendAgvInstToMagic(Instruction inst) throws Exception { - JSONArray ja = new JSONArray(); - JSONObject orderjo = new JSONObject(); - String instno = inst.getInstruction_code(); - String compound_inst_data = inst.getCompound_inst_data(); - String[] str = null; - List pathlist = null; - - if (StrUtil.equals("2", inst.getInstruction_type()) && !StrUtil.isEmpty(compound_inst_data)) { - str = compound_inst_data.split("->"); - pathlist = Arrays.asList(str); - - for (int i = 0; i < pathlist.size(); i++) { - String device_code = pathlist.get(i); - Device device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device)) { - throw new BadRequestException("未找到该设备【" + device_code + "】"); - } - if (i == 0) { - ja.add(destination(device_code, "Load", "1", "1")); - } else if (i == pathlist.size() - 1) { - ja.add(destination(device_code, "Unload", "1", "1")); - } else { - ja.add(destination(device_code, "OP_DUMP", "1", "4")); - } - - } - - //指定agv车号 暂时不用 - //orderjo.put("intendedVehicle", ""); - //设置任务最终时间 - orderjo.put("deadline", getNextDay(1)); - - orderjo.put("destinations", ja); - - JSONObject prijo = new JSONObject(); - prijo.put("key", "priority"); - prijo.put("value", inst.getPriority()); - - JSONArray prija = new JSONArray(); - prija.add(prijo); - orderjo.put("properties", prija); - - - } else { - - String startAddress = inst.getStart_point_code(); - String nextAddress = inst.getNext_point_code(); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device nextdevice = appService.findDeviceByCode(nextAddress); - Device startdevice = appService.findDeviceByCode(startAddress); - //指定agv车号 暂时不用 - //orderjo.put("intendedVehicle", ""); - //设置任务最终时间 - orderjo.put("deadline", getNextDay(1)); - //拼接起点子任务动作,待完善,动作码需要从数据库取值 - ja.add(destination(startAddress, "Load", "1", "1")); - //拼接终点子任务动作,待完善,动作码需要从数据库取值 - ja.add(destination(nextAddress, "Unload", "1", "1")); - - orderjo.put("destinations", ja); - - JSONObject prijo = new JSONObject(); - prijo.put("key", "priority"); - prijo.put("value", inst.getPriority()); - - JSONArray prija = new JSONArray(); - prija.add(prijo); - orderjo.put("properties", prija); - - } - - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { - String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); - String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); - - agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + instno; - - log.info("下发agv指令参数:{}", orderjo.toString()); - - HttpResponse result = null; - try { - result = HttpRequest.post(agvurl) - .body(String.valueOf(orderjo))//表单内容 - .timeout(20000)//超时,毫秒 - .execute(); - } catch (Exception e) { - throw new RuntimeException("下发agv失败!"); - } - return result; - } else { - return null; - } - - - } - - @Override - public HttpResponse markComplete(String code) throws Exception { - - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { - String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); - String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); - - agvurl = agvurl + ":" + agvport + "/api/route/orderSequences/" + code + "/markComplete"; - log.info("关闭agv运单序列请求:{}", agvurl); - - HttpResponse result = HttpRequest.post(agvurl) - //.body(String.valueOf(orderjo))//表单内容 - .timeout(20000)//超时,毫秒 - .execute(); - log.info("关闭agv运单序列请求反馈:{}", result); - - return result; - } else { - return null; - } - - } - - @Override - public HttpResponse sendAgvInstToMagic(String instcode) throws Exception { - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - Instruction inst = instructionService.findByCodeFromCache(instcode); - HttpResponse result = this.sendAgvInstToMagic(inst); - return result; - } - - @Override - public void sendAgvInstToNDC(Instruction inst) { - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { - String instcode = inst.getInstruction_code(); - int type = Integer.parseInt(inst.getInstruction_type()); - int priority = Integer.parseInt(inst.getPriority()) + 128; - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); - int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code()); - int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code()); - - byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode)); - byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode)); - byte typehigh = (byte) IntToHexHigh(type); - byte typelow = (byte) IntToHexLow(type); - byte qhdhigh = (byte) IntToHexHigh(startAddress); - byte qhdlow = (byte) IntToHexLow(startAddress); - byte fhdhigh = (byte) IntToHexHigh(nextAddress); - byte fhdlow = (byte) IntToHexLow(nextAddress); - byte prioritylow = (byte) IntToHexLow(priority); - - String str = "十进制下发:"; - String str1 = "十六进制下发:"; - str += "ikey:" + (Integer.parseInt(instcode)); - str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF); - - str += "/type:" + (type); - str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF); - - str += "/qhd:" + (startAddress); - str1 += "/qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF); - str += "/fhd:" + (nextAddress); - str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF); - - str += "/priority:" + (priority); - str1 += "/priority:" + hexToString(prioritylow & 0xFF); - - System.out.println(str); - System.out.println(str1); - - byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X12, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X71, - (byte) 0X00, (byte) 0X0E, - (byte) 0X01, prioritylow, - (byte) 0X00, (byte) 0X01, - (byte) ikeyhigh, (byte) ikeylow, - (byte) ikeyhigh, (byte) ikeylow, - (byte) typehigh, (byte) typelow, - (byte) qhdhigh, (byte) qhdlow, - (byte) fhdhigh, (byte) fhdlow - }; - log.info("下发AGV作业指令--{}", str1); - - NDCSocketConnectionAutoRun.write(b); - System.out.println("下发agv指令数据:" + Bytes2HexString(b)); - } - } - - @Override - public void sendAgvInstToNDC(String instcode) throws Exception { - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - Instruction inst = instructionService.findByCodeFromCache(instcode); - sendAgvInstToNDC(inst); - } - - - @Override - public HttpResponse queryAgvInstStatus(String instCode) { - - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { - String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); - String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); - - agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + instCode; - - HttpResponse result = HttpRequest.get(agvurl) - .timeout(20000)//超时,毫秒 - .execute(); - System.out.println("查询agv指令数据:" + result.body()); - - return result; - } else { - - return null; - } - } - - @Override - public HttpResponse queryMagicAgvDeviceStatus() { - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { - String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); - String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); - - agvurl = agvurl + ":" + agvport + "/v1/vehicles"; - - HttpResponse result = HttpRequest.get(agvurl) - .timeout(20000)//超时,毫秒 - .execute(); - System.out.println("查询agv状态数据:" + result.body()); - if (result.getStatus() == 200) { - JSONArray ja = (JSONArray)JSONArray.parse(result.body()); - for (int i = 0; i < ja.size(); i++) { - JSONObject jo = (JSONObject) ja.get(i); - String name = jo.getString("name"); - String state = jo.getString("state"); - String energyLevel = jo.getString("energyLevel"); - String transportOrder = jo.getString("transportOrder"); - String positionAngle = jo.getString("positionAngle"); - String positionX = jo.getString("positionX"); - String positionY = jo.getString("positionY"); - AgvDto dto = new AgvDto(); - dto.setName(name); - dto.setEnergyLevel(energyLevel); - dto.setState(state); - dto.setPositionAngle(positionAngle); - dto.setPositionX(positionX); - dto.setPositionY(positionY); - dto.setTransportOrder(transportOrder); - - if (AGVDeviceStatus.containsKey(name)) { - AGVDeviceStatus.remove(name); - AGVDeviceStatus.put(name, dto); - } else { - AGVDeviceStatus.put(name, dto); - } - } - } - return result; - } else { - return null; - } - } - - @Override - public HttpResponse queryXZAgvDeviceStatus() { - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { - String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); - String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); - - String agvurl1 = agvurl + ":" + agvport + "/api/route/vehicles"; - String agvurl2 = agvurl + ":" + agvport + "/api/route/vehicleDetails"; - - HttpResponse result = HttpRequest.get(agvurl1) - .timeout(20000)//超时,毫秒 - .execute(); - - - HttpResponse result2 = HttpRequest.get(agvurl2) - .timeout(20000)//超时,毫秒 - .execute(); - - System.out.println("查询agv状态数据:" + result.body()); - if (result.getStatus() == 200) { - JSONArray ja = (JSONArray)JSONArray.parse(result.body()); - - for (int i = 0; i < ja.size(); i++) { - JSONObject jo = (JSONObject) ja.get(i); - String name = jo.getString("name"); - String state = jo.getString("state"); - String energyLevel = jo.getString("energyLevel"); - String transportOrder = jo.getString("transportOrder"); - JSONObject detailjo = (JSONObject)JSONObject.parse(result2.body()); - JSONObject item = (JSONObject) detailjo.get(name); - String x = item.getString("x"); - String y = item.getString("y"); - String angle = item.getString("angle"); - AgvDto dto = new AgvDto(); - dto.setName(name); - dto.setEnergyLevel(energyLevel); - dto.setState(state); - dto.setTransportOrder(transportOrder); - dto.setPositionAngle(angle); - dto.setPositionX(x); - dto.setPositionY(y); - if (AGVDeviceStatus.containsKey(name)) { - AGVDeviceStatus.remove(name); - AGVDeviceStatus.put(name, dto); - } else { - AGVDeviceStatus.put(name, dto); - } - } - } - return result; - } else { - return null; - } - } - - - - @Override - public HttpResponse queryXZAgvInstStatus(String instCode) { - - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { - String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); - String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); - - agvurl = agvurl + ":" + agvport + "/api/route/transportOrders/" + instCode; - - HttpResponse result = HttpRequest.get(agvurl) - .timeout(20000)//超时,毫秒 - .execute(); - System.out.println("查询agv指令数据:" + result.body()); - - return result; - } else { - - return null; - } - - - } - - @Override - public Map findAllAgvFromCache() { - return AGVDeviceStatus; - } - - @Override - public void updateAgvFromCache(AgvDto dto) { - if (AGVDeviceStatus.containsKey(dto.getName())) { - AGVDeviceStatus.remove(dto.getName()); - } - AGVDeviceStatus.put(dto.getName(), dto); - } - - @Override - public HttpResponse deleteAgvInst(String instCode) { - - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { - String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); - String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); - - agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + instCode + "/withdrawal"; - log.info("删除agv指令请求agvurl:{}", agvurl); - - HttpResponse result = null; - try { - result = HttpRequest.post(agvurl) - .timeout(20000)//超时,毫秒 - .execute(); - log.info("删除agv指令请求反馈:{}", result); - } catch (Exception e) { - throw new RuntimeException("下发agv失败!"); - } - - return result; - - } else { - - return null; - } - - } - - @Override - public HttpResponse deleteXZAgvInst(String instCode) { - - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { - String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); - String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); - - agvurl = agvurl + ":" + agvport + "/api/route/transportOrders/" + instCode + "/withdrawal"; - log.info("删除agv指令请求agvurl:{}", agvurl); - HttpResponse result = HttpRequest.post(agvurl) - .timeout(20000)//超时,毫秒 - .execute(); - log.info("删除agv指令请求反馈:{}", result); - - return result; - - } else { - - return null; - } - - } - - @Override - public void deleteAgvInstToNDC(Instruction inst) throws Exception { - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { - int index = Integer.parseInt(inst.getAgv_jobno()); - - byte indexhigh = (byte) IntToHexHigh(index); - byte indexlow = (byte) IntToHexLow(index); - - String str = "十进制下发:"; - String str1 = "十六进制下发:"; - str += "index:" + index; - str1 += "ikey:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF); - System.out.println(str); - System.out.println(str1); - - byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X06, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X6E, - (byte) 0X00, (byte) 0X02, - (byte) indexhigh, (byte) indexlow, - }; - log.info("下发删除AGV指令--{}", Bytes2HexString(b)); - - NDCSocketConnectionAutoRun.write(b); - System.out.println("下发删除agv指令数据:" + Bytes2HexString(b)); - } - } - - //1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - @Override - public synchronized String process(String jobno, String type, String address, String action, String processingVehicle) { - log.info("查询到AGV请求参数,jobno:{},address:{}", jobno + ",address:" + address + ",type:" + type + ",action:" + action); - boolean is_feedback = false; - String str = ""; - String backaddress = address; - if (address.indexOf(".") > 0) { - str = address.substring(address.indexOf("."), address.length()); - address = address.substring(0, address.indexOf(".")); - } else if (address.indexOf("-") > 0) { - address = address.substring(0, address.indexOf("-")); - } - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - Instruction inst = instructionService.findByCodeFromCache(jobno); - - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device addressdevice = appService.findDeviceByCode(address); - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - SpecialOrdinarySiteDeviceDriver specialOrdinarySiteDeviceDriver; - //请求进入 - if ("onEntry".equals(type)) { - - if (addressdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) addressdevice.getDeviceDriver(); - //请求取货 - if ("Load".equals(action)) { - if (standardInspectSiteDeviceDriver.getMode() == 2 && standardInspectSiteDeviceDriver.getMove() > 0) { - inst.setExecute_status("1"); - is_feedback = true; - } - //请求放货 - } else if ("Unload".equals(action)) { - if (standardInspectSiteDeviceDriver.getMode() == 2 && standardInspectSiteDeviceDriver.getMove() == 0) { - inst.setExecute_status("3"); - is_feedback = true; - } - } - } - if (addressdevice.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) { - specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver(); - //请求取货 - if ("Load".equals(action)) { - if (addressdevice.getHas_goods() > 0) { - inst.setExecute_status("1"); - is_feedback = true; - } - //请求放货 - } else if ("Unload".equals(action)) { - if (addressdevice.getHas_goods() == 0) { - inst.setExecute_status("3"); - is_feedback = true; - } - } - - } - if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver(); - //请求取货 - if ("Load".equals(action)) { - if (addressdevice.getHas_goods() > 0) { - inst.setExecute_status("1"); - is_feedback = true; - } - //请求放货 - } else if ("Unload".equals(action)) { - if (addressdevice.getHas_goods() == 0) { - inst.setExecute_status("3"); - is_feedback = true; - } - } - } - - if (addressdevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - //请求取货 - if ("Load".equals(action)) { - inst.setExecute_status("1"); - is_feedback = true; - //请求放货 - } else if ("Unload".equals(action)) { - inst.setExecute_status("3"); - is_feedback = true; - } - } - - //取放货完成 - } else if ("onStation".equals(type)) { - - System.out.println("取放货完成"); - if (addressdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) addressdevice.getDeviceDriver(); - //取货完成 - if ("Load".equals(action)) { - if (standardInspectSiteDeviceDriver.getMode() == 2 && standardInspectSiteDeviceDriver.getMove() == 0) { - inst.setExecute_device_code(processingVehicle); - inst.setExecute_status("2"); - is_feedback = true; - } - //放货完成 - } else if ("Unload".equals(action)) { - if (standardInspectSiteDeviceDriver.getMode() == 2 && standardInspectSiteDeviceDriver.getMove() > 0) { - inst.setExecute_device_code(address); - inst.setExecute_status("4"); - is_feedback = true; - } - } - - } - if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver(); - //取货完成 - if ("Load".equals(action)) { - inst.setExecute_device_code(processingVehicle); - inst.setExecute_status("2"); - is_feedback = true; - //放货完成 - } else if ("Unload".equals(action)) { - inst.setExecute_device_code(address); - inst.setExecute_status("4"); - is_feedback = true; - } - - } - if (addressdevice.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) { - specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver(); - //取货完成 - if ("Load".equals(action)) { - inst.setExecute_device_code(processingVehicle); - inst.setExecute_status("2"); - is_feedback = true; - //放货完成 - } else if ("Unload".equals(action)) { - inst.setExecute_device_code(processingVehicle); - inst.setExecute_status("4"); - is_feedback = true; - } - } - if (addressdevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) { - //取货完成 - if ("Load".equals(action)) { - inst.setExecute_device_code(processingVehicle); - inst.setExecute_status("2"); - is_feedback = true; - //放货完成 - } else if ("Unload".equals(action)) { - inst.setExecute_device_code(processingVehicle); - inst.setExecute_status("4"); - is_feedback = true; - } - } - } - - JSONObject requestjo = new JSONObject(); - JSONArray ja = new JSONArray(); - if (is_feedback) { - String param = ""; - JSONObject jo = new JSONObject(); - if (str.length() > 0) { - backaddress = backaddress + str; - } - if ("onEntry".equals(type)) { - param = "EntryPermitted-" + backaddress + action; - } else if ("onStation".equals(type)) { - param = "ContinueOnStation-" + backaddress + action; - } - - jo.put("key", param); - jo.put("value", "False"); - ja.add(jo); - requestjo.put("properties", ja); - log.info("反馈AGV请求数据:{}", requestjo); - System.out.println("back agv:" + requestjo); - - String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); - String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); - - agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + jobno + "/interact"; - - HttpResponse result = HttpRequest.post(agvurl) - .body(String.valueOf(requestjo)) - .timeout(20000)//超时,毫秒 - .execute(); - } - is_feedback = false; - - return requestjo.toString(); - - } - - @Override - public String waitPointRequest(String param) { - log.info("收到AGV请求参数:{}", param); - String[] strs = param.split("-"); - String address = strs[0]; - String inst_code = strs[1]; - String type = strs[2]; - String newaddress = null; - // 前置点会加上p - if (address.endsWith("IN")) { - newaddress = address.substring(0, address.length() - 2); - } else if (address.endsWith("OUT")) { - newaddress = address.substring(0, address.length() - 3); - } else if (address.endsWith("P") || address.endsWith("L") || address.endsWith("R")) { - newaddress = address.substring(0, address.length() - 1); - } else if (address.endsWith("CZ")) { - newaddress = address.substring(0, address.length() - 2); - } else if (address.endsWith("IQ") || address.endsWith("OQ")) { - newaddress = address.substring(0, address.length() - 2); - } else { - newaddress = address; - } - boolean is_feedback = false; - - Device device = deviceAppService.findDeviceByCode(newaddress); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - MachinesSiteDeviceDriver machinesSiteDeviceDriver; - WeighingSiteDeviceDriver weighingSiteDeviceDriver; - StandardManipulatorInspectSiteDeviceDriver sandardManipulatorInspectSiteDeviceDriver; - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - //人工确认信号 - if (standardOrdinarySiteDeviceDriver.getManua_confirm() == 2) { - is_feedback = true; - standardOrdinarySiteDeviceDriver.setManua_confirm(0); - } else { - standardOrdinarySiteDeviceDriver.setManua_confirm(1); - } - } - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - //请求取货 - if (StrUtil.equals(type, "01") && address.endsWith("IN") - && standardInspectSiteDeviceDriver.getMove() != 0) { - standardInspectSiteDeviceDriver.writing(1, 1); - is_feedback = true; - } - //取货完成 - else if (StrUtil.equals(type, "02")) { - standardInspectSiteDeviceDriver.writing(1, 2); - is_feedback = true; - } - //取货完成离开 - else if (StrUtil.equals(type, "05") && address.endsWith("OUT") - && standardInspectSiteDeviceDriver.getMove() == 0) { - standardInspectSiteDeviceDriver.writing(1, 5); - is_feedback = true; - } - //请求放货 - else if (StrUtil.equals(type, "03") && address.endsWith("IN") - && standardInspectSiteDeviceDriver.getMove() == 0) { - standardInspectSiteDeviceDriver.writing(1, 3); - is_feedback = true; - } - //放货完成 - else if (StrUtil.equals(type, "04")) { - standardInspectSiteDeviceDriver.writing(1, 4); - is_feedback = true; - } - //放货完成离开 - else if (StrUtil.equals(type, "06") && address.endsWith("OUT") - && standardInspectSiteDeviceDriver.getMove() != 0) { - standardInspectSiteDeviceDriver.writing(1, 6); - is_feedback = true; - } - - } - if (device.getDeviceDriver() instanceof StandardManipulatorInspectSiteDeviceDriver) { - sandardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) device.getDeviceDriver(); - //请求进 - if (StrUtil.equals(type, "07") && address.endsWith("IQ") - && (sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 1 || sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 3)) { - sandardManipulatorInspectSiteDeviceDriver.writing(1, 7); - is_feedback = true; - } - //请求取货 - else if (StrUtil.equals(type, "01") && address.endsWith("IN") - && (sandardManipulatorInspectSiteDeviceDriver.getActoin() == 1 || sandardManipulatorInspectSiteDeviceDriver.getActoin() == 3) - && sandardManipulatorInspectSiteDeviceDriver.getMove() != 0) { - sandardManipulatorInspectSiteDeviceDriver.writing(1, 1); - is_feedback = true; - } - //取货完成 - else if (StrUtil.equals(type, "02")) { - sandardManipulatorInspectSiteDeviceDriver.writing(1, 2); - is_feedback = true; - } - //取货完成离开 - else if (StrUtil.equals(type, "05") && address.endsWith("OUT") - && sandardManipulatorInspectSiteDeviceDriver.getMove() == 0) { - sandardManipulatorInspectSiteDeviceDriver.writing(1, 5); - is_feedback = true; - } - //请求离开 - else if (StrUtil.equals(type, "08") && address.endsWith("OQ") - && (sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 2 || sandardManipulatorInspectSiteDeviceDriver.getIo_action() == 3)) { - sandardManipulatorInspectSiteDeviceDriver.writing(1, 8); - is_feedback = true; - } - //请求放货 - else if (StrUtil.equals(type, "03") && address.endsWith("IN") - && (sandardManipulatorInspectSiteDeviceDriver.getActoin() == 2 || sandardManipulatorInspectSiteDeviceDriver.getActoin() == 3) - && sandardManipulatorInspectSiteDeviceDriver.getMove() == 0) { - sandardManipulatorInspectSiteDeviceDriver.writing(1, 3); - is_feedback = true; - } - //放货完成 - else if (StrUtil.equals(type, "04")) { - sandardManipulatorInspectSiteDeviceDriver.writing(1, 4); - is_feedback = true; - } - //放货完成离开 - else if (StrUtil.equals(type, "06") && address.endsWith("OUT") - && sandardManipulatorInspectSiteDeviceDriver.getMove() != 0) { - sandardManipulatorInspectSiteDeviceDriver.writing(1, 6); - is_feedback = true; - } - - } - if (device.getDeviceDriver() instanceof WeighingSiteDeviceDriver) { - weighingSiteDeviceDriver = (WeighingSiteDeviceDriver) device.getDeviceDriver(); - Instruction inst = instructionService.findByCodeFromCache(inst_code); - weighingSiteDeviceDriver.setInst(inst); - //调用erp接口 - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.HASOTHERSYSTEM).toString(), "1")) { - log.info("请求ERP接口参数:{}", inst.getStart_device_code()); - JSONObject jo = acsToErpService.sendDeviceToWms(inst.getStart_device_code()); - log.info("ERP接口反馈:{}", jo); - } - is_feedback = true; - } - if (device.getDeviceDriver() instanceof MachinesSiteDeviceDriver) { - machinesSiteDeviceDriver = (MachinesSiteDeviceDriver) device.getDeviceDriver(); - //请求进 - if (address.endsWith("IN")) { - if (machinesSiteDeviceDriver.getIoaction() == 1 || machinesSiteDeviceDriver.getIoaction() == 3) { - is_feedback = true; - } else { - machinesSiteDeviceDriver.writing(6); - } - } - //请求离开 - else if (address.endsWith("OUT")) { - machinesSiteDeviceDriver.writing(6); - machinesSiteDeviceDriver.writing(6); - is_feedback = true; - - } else { - - if (machinesSiteDeviceDriver.getIoaction() == 2 || machinesSiteDeviceDriver.getIoaction() == 3) { - is_feedback = true; - } else { - machinesSiteDeviceDriver.writing(5); - machinesSiteDeviceDriver.writing(2, device.getAddress() == null ? 0 : Integer.parseInt(device.getAddress())); - } - } - } - JSONObject jo = new JSONObject(); - if (is_feedback) { - jo.put("name", param); - jo.put("lastAction", "wait"); - jo.put("lastActionStatus", "DONE"); - jo.put("status", "IDLE"); - } else { - jo.put("name", param); - jo.put("lastAction", "wait"); - jo.put("lastActionStatus", "FAILED"); - jo.put("status", "IDLE"); - } - is_feedback = false; - log.info("反馈AGV请求参数:{}", jo.toString()); - - return jo.toString(); - } - - @Override - public String requestAck(String address) { - log.info("AGV请求离开参数:{}", address); - boolean flag = false; - - if (address.indexOf(".") > 0) { - address = address.substring(0, address.indexOf(".")); - } - if (address.indexOf("-") > 0) { - address = address.substring(0, address.indexOf("-")); - } - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device addressdevice = appService.findDeviceByCode(address); - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - StandardStorageDeviceDriver standardStorageDeviceDriver; - //mes = AgvClientXZ.mes(zlbh, device, type); - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - if ((addressdevice.getDeviceDriver() instanceof StandardStorageDeviceDriver)) { - flag = true; - } - - if (addressdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) addressdevice.getDeviceDriver(); - flag = true; - log.info("agvstatus:" + standardInspectSiteDeviceDriver.getFlag() + ""); - //取货完成离开 - if (standardInspectSiteDeviceDriver.getFlag() == 2) { - if (standardInspectSiteDeviceDriver.getMove() == 0) { - flag = true; - standardInspectSiteDeviceDriver.setFlag(5); - } - } - //放货完成离开 - if (standardInspectSiteDeviceDriver.getFlag() == 4) { - if (standardInspectSiteDeviceDriver.getMove() == 1) { - flag = true; - standardInspectSiteDeviceDriver.setFlag(6); - } - } - } - - if (addressdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) addressdevice.getDeviceDriver(); - flag = true; - log.info("agvstatus:" + standardOrdinarySiteDeviceDriver.getFlag() + ""); - - //取货完成离开 - if (standardOrdinarySiteDeviceDriver.getFlag() == 2) { - flag = true; - standardOrdinarySiteDeviceDriver.setFlag(5); - } - //放货完成离开 - if (standardOrdinarySiteDeviceDriver.getFlag() == 4) { - flag = true; - standardOrdinarySiteDeviceDriver.setFlag(6); - } - } - - if (flag) { - log.info("AGV请求离开,反馈成功:{}", address); - System.out.println("AGV请求离开,反馈成功 " + address); - return "OK"; - } else { - log.info("AGV请求离开,反馈失败{}", address); - System.out.println("AGV请求离开,反馈失败 " + address); - throw new RuntimeException("AGV请求离开,反馈失败 " + address); - } - } - - @Override - public String requestOpenOrCloseDoor(String device, String param) { - log.info("AGV请求开关门参数,设备:{},参数:{}", device, param); - int type = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.BUSINESSTYPE)); - switch (type) { - case 4: - acsToWmsService.applyOpenOrCloseDoor(device, param); - break; - default: - StandardAutodoorDeviceDriver autodoor; - Device doordevice = deviceAppService.findDeviceByCode(device); - if (ObjectUtil.isEmpty(doordevice)) { - throw new BadRequestException("未找到对应设备"); - } - if (doordevice.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - autodoor = (StandardAutodoorDeviceDriver) doordevice.getDeviceDriver(); - if (StrUtil.equals("open", param)) { - autodoor.OpenOrClose("1"); - log.info("下发开门请求"); - - } else if (StrUtil.equals("close", param)) { - autodoor.OpenOrClose("2"); - log.info("下发关门请求"); - } - } - break; - - } - return null; - } - - @Override - public String queryDoorStatus(String device) { - log.info("AGV查询自动门状态,参数:{}", device); - int type = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.BUSINESSTYPE)); - switch (type) { - case 4: - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.HASOTHERSYSTEM).toString(), "1")) { - String result = acsToWmsService.queryDoorsStatus().body(); - JSONArray ja = JSONArray.parseArray(result); - log.info("AGV查询自动门状态,反馈:{}", ja.toString()); - return ja.toString(); - } - return null; - default: - if (StrUtil.equals("doors", device)) { - List list = deviceAppService.findDevice(DeviceType.autodoor); - JSONArray ja = new JSONArray(); - for (int i = 0; i < list.size(); i++) { - Device doordevice = deviceAppService.findDeviceByCode(list.get(i).getDevice_code()); - if (ObjectUtil.isEmpty(doordevice)) { - throw new BadRequestException("未找到对应设备"); - } - String mes = null; - StandardAutodoorDeviceDriver autodoor; - if (doordevice.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - autodoor = (StandardAutodoorDeviceDriver) doordevice.getDeviceDriver(); - mes = autodoor.getStatus(); - } - JSONObject jo = JSONObject.parseObject(mes); - ja.add(jo); - } - log.info("AGV查询自动门状态,反馈:{}", ja.toString()); - return ja.toString(); - - } else { - Device doordevice = deviceAppService.findDeviceByCode(device); - if (ObjectUtil.isEmpty(doordevice)) { - throw new BadRequestException("未找到对应设备"); - } - String mes = null; - StandardAutodoorDeviceDriver autodoor; - if (doordevice.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - autodoor = (StandardAutodoorDeviceDriver) doordevice.getDeviceDriver(); - mes = autodoor.getStatus(); - } - JSONObject jo = JSONObject.parseObject(mes); - log.info("AGV查询自动门状态,反馈:{}", jo.toString()); - return jo.toString(); - } - } - } - - @Override - public String queryAllDoorStatus() { - log.info("AGV查询全部自动门状态"); - List list = deviceAppService.findDevice(DeviceType.autodoor); - JSONArray ja = new JSONArray(); - for (int i = 0; i < list.size(); i++) { - Device doordevice = deviceAppService.findDeviceByCode(list.get(i).getDevice_code()); - if (ObjectUtil.isEmpty(doordevice)) { - throw new BadRequestException("未找到对应设备"); - } - String mes = null; - StandardAutodoorDeviceDriver autodoor; - if (doordevice.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - autodoor = (StandardAutodoorDeviceDriver) doordevice.getDeviceDriver(); - mes = autodoor.getStatus(); - } - JSONObject jo = JSONObject.parseObject(mes); - ja.add(jo); - } - log.info("AGV查询全部自动门状态,反馈:{}", ja.toString()); - return ja.toString(); - } - - - @Override - public byte[] sendAgvOneModeInst(int phase, int index, int result1, int result2) { - if (phase < 0 || index < 0) - return null; - byte indexhigh = (byte) IntToHexHigh(index); - byte indexlow = (byte) IntToHexLow(index); - byte phasehigh = (byte) IntToHexHigh(phase); - byte phaselow = (byte) IntToHexLow(phase); - byte resulthigh1 = (byte) IntToHexHigh(result1); - byte resultlow1 = (byte) IntToHexLow(result1); - byte resulthigh2 = (byte) IntToHexHigh(result2); - byte resultlow2 = (byte) IntToHexLow(result2); - - byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X0D, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X6D, - (byte) 0X00, (byte) 0X08, - (byte) indexhigh, (byte) indexlow, - (byte) 0X01, (byte) 0X12, - (byte) phasehigh, (byte) phaselow, - (byte) resulthigh1, (byte) resultlow1, - (byte) resulthigh2, (byte) resultlow2 - }; - - log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF)); - //87CD 0008 000C 0001 006D 0008 0000 0114 000E 0000 - //87CD 0008 000C 0001 006D 0008 0003 0114 008F 0000 - System.out.println("反馈agv动作数据:" + Bytes2HexString(b)); - return b; - } - - @Override - public byte[] sendAgvOneModeInst(int phase, int index) { - return new byte[0]; - } - - @Override - public byte[] sendAgvOneModeInst(int phase, int index, int result) { - if (phase < 0 || index < 0) - return null; - byte indexhigh = (byte) IntToHexHigh(index); - byte indexlow = (byte) IntToHexLow(index); - byte phasehigh = (byte) IntToHexHigh(phase); - byte phaselow = (byte) IntToHexLow(phase); - byte resulthigh = (byte) IntToHexHigh(result); - byte resultlow = (byte) IntToHexLow(result); - - int type = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.BUSINESSTYPE)); - byte[] b = new byte[]{}; - switch (type) { - case 0: - b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X0A, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X6D, - (byte) 0X00, (byte) 0X06, - (byte) indexhigh, (byte) indexlow, - (byte) 0X01, (byte) 0X12, - (byte) phasehigh, (byte) phaselow - }; - break; - case 1: - b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X0D, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X6D, - (byte) 0X00, (byte) 0X08, - (byte) indexhigh, (byte) indexlow, - (byte) 0X01, (byte) 0X12, - (byte) phasehigh, (byte) phaselow, - (byte) resulthigh, (byte) resultlow - }; - break; - case 2: - b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X0A, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X6D, - (byte) 0X00, (byte) 0X06, - (byte) indexhigh, (byte) indexlow, - (byte) 0X01, (byte) 0X12, - (byte) phasehigh, (byte) phaselow - }; - break; - case 5: - b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X0A, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X6D, - (byte) 0X00, (byte) 0X06, - (byte) indexhigh, (byte) indexlow, - (byte) 0X01, (byte) 0X12, - (byte) phasehigh, (byte) phaselow - }; - break; - case 7: - b = new byte[]{(byte) 0X87, (byte) 0XCD, - (byte) 0X00, (byte) 0X08, - (byte) 0X00, (byte) 0X0A, - (byte) 0X00, (byte) 0X01, - (byte) 0X00, (byte) 0X6D, - (byte) 0X00, (byte) 0X06, - (byte) indexhigh, (byte) indexlow, - (byte) 0X01, (byte) 0X12, - (byte) phasehigh, (byte) phaselow - }; - break; - } - - - log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF)); - - System.out.println("反馈agv动作数据:" + Bytes2HexString(b)); - return b; - } - - @Override - public HttpResponse sendOrderSequencesToXZ(Instruction inst) throws Exception { - - JSONObject jo = new JSONObject(); - jo.put("intendedVehicle", ""); - jo.put("category", ""); - jo.put("failureFatal", false); - jo.put("complete", false); - JSONArray transports = new JSONArray(); - JSONObject orderjo = new JSONObject(); - orderjo.put("name", inst.getInstruction_code()); - orderjo.put("order", createOrederData(inst, "1")); - transports.add(orderjo); - jo.put("transports", transports); - - JSONArray ja1 = new JSONArray(); - JSONObject jo1 = new JSONObject(); - jo1.put("key", ""); - jo1.put("value", ""); - ja1.add(jo1); - jo.put("properties", ja1); - - log.info("任务号:{},指令号{},下发agv订单序列参数:{}", inst.getTask_code(), inst.getInstruction_code(), jo.toString()); - - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { - String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); - String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); - - agvurl = agvurl + ":" + agvport + "/api/route/orderSequences/" + inst.getTask_code(); - - HttpResponse result = HttpRequest.post(agvurl) - .body(String.valueOf(jo))//表单内容 - .timeout(20000)//超时,毫秒 - .execute(); - log.info(agvurl); - log.info("任务号:{},指令号{},状态{},下发agv订单序列反馈:{}", inst.getTask_code(), inst.getInstruction_code(), result.getStatus(), result.body()); - - return result; - } else { - return null; - } - } - - @Override - public HttpResponse addOrderSequences(Instruction inst) throws Exception { - JSONObject orderjo = createOrederData(inst, "1"); - log.info("指令号:{},追加agv订单序列参数:{}", inst.getInstruction_code(), orderjo.toString()); - - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { - String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); - String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); - - agvurl = agvurl + ":" + agvport + "/api/route/transportOrders/" + inst.getInstruction_code(); - - HttpResponse result = HttpRequest.post(agvurl) - .body(String.valueOf(orderjo))//表单内容 - .timeout(20000)//超时,毫秒 - .execute(); - log.info(agvurl); - log.info("任务号:{},指令号{},状态{},追加agv订单序列参数:{}", inst.getTask_code(), inst.getInstruction_code(), result.getStatus(), result.body()); - - return result; - } else { - return null; - } - } - - @Override - public String sendOrderSequencesParam(Instruction inst) throws Exception { - JSONObject jo = new JSONObject(); - jo.put("intendedVehicle", ""); - jo.put("category", "Park"); - jo.put("failureFatal", true); - jo.put("complete", false); - JSONArray transports = new JSONArray(); - JSONObject orderjo = createOrederData(inst, "0"); - JSONObject order = new JSONObject(); - orderjo.put("order", order); - orderjo.put("name", inst.getInstruction_code()); - transports.add(orderjo); - jo.put("transports", transports); - return jo.toString(); - } - - @Override - public JSONObject createOrederData(Instruction inst, String inst_type) { - String inst_code = inst.getInstruction_code(); - String task_code = inst.getTask_code(); - String compound_inst_data = inst.getCompound_inst_data(); - String[] str = null; - List pathlist = null; - if (!StrUtil.isEmpty(compound_inst_data)) { - str = compound_inst_data.split("->"); - pathlist = Arrays.asList(str); - } - JSONArray ja = new JSONArray(); - JSONObject orderjo = new JSONObject(); - - //1表示追加任务,需将task_code赋值给wrappingSequence - if (StrUtil.equals("1", inst_type)) { - orderjo.put("wrappingSequence", task_code); - } - String instno = inst.getInstruction_code(); - //指定agv车号 暂时不用 - //orderjo.put("intendedVehicle", ""); - //设置任务最终时间 - orderjo.put("deadline", getNextDay(1)); - orderjo.put("category", ""); - //拼接起点子任务动作,待完善,动作码需要从数据库取值 - int type = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.BUSINESSTYPE)); - - switch (type) { - case 3: - break; - case 4: - if (StrUtil.equals(inst.getCompound_inst(), "1")) { - for (int i = 0; i < pathlist.size(); i++) { - String device_code = pathlist.get(i); - Device device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device)) { - throw new BadRequestException("未找到该设备【" + device_code + "】"); - } - - MachinesSiteDeviceDriver machinesSiteDeviceDriver; - if (device.getDeviceDriver() instanceof MachinesSiteDeviceDriver) { - ja.add(destination2(device_code + "IN", "Wait", "1", device_code + "IN" - + "-" + inst_code + "-" + "01")); - ja.add(destination2(device_code, "Wait", "1", device_code - + "-" + inst_code + "-" + "01")); - ja.add(destination2(device_code + "OUT", "Wait", "1", device_code + "OUT" - + "-" + inst_code + "-" + "01")); - - } else { - ja.add(destination2(device_code, "Wait", "1", device_code + "-" + inst_code + "-" + "01")); - } - } - - ja.add(destination2(inst.getNext_point_code(), "Wait", "1", inst.getNext_point_code() + "-" + inst_code + "-" + "01")); - - } else { - String startAddress = inst.getStart_device_code(); - String nextAddress = inst.getNext_device_code(); - //追加则下发目标点 不追加就下方起点、目标点 - if (StrUtil.equals("1", inst_type)) { - Device device = deviceAppService.findDeviceByCode(nextAddress); - MachinesSiteDeviceDriver machinesSiteDeviceDriver; - if (device.getDeviceDriver() instanceof MachinesSiteDeviceDriver) { - ja.add(destination2(startAddress, "Wait", "5", startAddress - + "-" + inst_code + "-" + "01")); - ja.add(destination2(nextAddress + "IN", "Wait", "1", nextAddress + "IN" - + "-" + inst_code + "-" + "01")); - ja.add(destination2(nextAddress, "Wait", "1", nextAddress - + "-" + inst_code + "-" + "01")); - ja.add(destination2(nextAddress + "OUT", "Wait", "1", nextAddress + "OUT" - + "-" + inst_code + "-" + "01")); - } else { - ja.add(destination2(startAddress, "Wait", "1", startAddress - + "-" + inst_code + "-" + "01")); - ja.add(destination2(nextAddress, "Wait", "1", nextAddress - + "-" + inst_code + "-" + "01")); - } - - } else { - ja.add(destination2(startAddress, "Wait", "1", startAddress - + "-" + inst_code + "-" + "01")); - ja.add(destination2(nextAddress, "Wait", "1", nextAddress - + "-" + inst_code + "-" + "01")); - } - } - break; - case 6: - String startAddress = inst.getStart_device_code(); - String nextAddress = inst.getNext_device_code(); - Device startdevice = deviceAppService.findDeviceByCode(startAddress); - Device nextdevice = deviceAppService.findDeviceByCode(nextAddress); - StandardManipulatorInspectSiteDeviceDriver standardManipulatorInspectSiteDeviceDriver; - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - //起点 - if (startdevice.getDeviceDriver() instanceof StandardManipulatorInspectSiteDeviceDriver) { - - ja.add(destination2(startAddress + "IQ", "Wait", "1", startAddress + "IQ" - + "-" + inst_code + "-" + "07")); - ja.add(destination2(startAddress + "IN", "Wait", "1", startAddress + "IN" - + "-" + inst_code + "-" + "01")); - ja.add(destination2(startAddress, "Load", "3", startAddress - + "-" + inst_code + "-" + "02")); - ja.add(destination2(startAddress + "OUT", "Wait", "1", startAddress + "OUT" - + "-" + inst_code + "-" + "05")); - ja.add(destination2(startAddress + "OQ", "Wait", "1", startAddress + "OQ" - + "-" + inst_code + "-" + "08")); - - } else if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - - ja.add(destination2(startAddress + "IN", "Wait", "1", startAddress + "IN" - + "-" + inst_code + "-" + "01")); - ja.add(destination2(startAddress, "Load", "3", startAddress - + "-" + inst_code + "-" + "02")); - ja.add(destination2(startAddress + "OUT", "Wait", "1", startAddress + "OUT" - + "-" + inst_code + "-" + "05")); - - } else { - ja.add(destination2(nextAddress, "Wait", "1", startAddress - + "-" + inst_code + "-" + "01")); - ja.add(destination2(startAddress, "Load", "3", startAddress - + "-" + inst_code + "-" + "01")); - } - - //终点 - if (nextdevice.getDeviceDriver() instanceof StandardManipulatorInspectSiteDeviceDriver) { - ja.add(destination2(nextAddress + "IQ", "Wait", "1", nextAddress + "IQ" - + "-" + inst_code + "-" + "07")); - ja.add(destination2(nextAddress + "IN", "Wait", "1", nextAddress + "IN" - + "-" + inst_code + "-" + "03")); - ja.add(destination2(nextAddress, "ForkLoad", "3", nextAddress - + "-" + inst_code + "-" + "04")); - ja.add(destination2(nextAddress + "OUT", "Wait", "1", nextAddress + "OUT" - + "-" + inst_code + "-" + "06")); - ja.add(destination2(nextAddress + "OQ", "Wait", "1", nextAddress + "OQ" - + "-" + inst_code + "-" + "08")); - } else if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - ja.add(destination2(nextAddress + "IN", "Wait", "1", nextAddress + "IN" - + "-" + inst_code + "-" + "03")); - ja.add(destination2(nextAddress, "ForkLoad", "3", nextAddress - + "-" + inst_code + "-" + "04")); - ja.add(destination2(nextAddress + "OUT", "Wait", "1", nextAddress + "OUT" - + "-" + inst_code + "-" + "06")); - } else { - ja.add(destination2(nextAddress, "Wait", "1", nextAddress - + "-" + inst_code + "-" + "01")); - ja.add(destination2(nextAddress, "ForkLoad", "3", nextAddress - + "-" + inst_code + "-" + "01")); - } - break; - } - - orderjo.put("destinations", ja); - JSONObject prijo = new JSONObject(); - prijo.put("key", "duration"); - prijo.put("value", "101"); - - JSONArray prija = new JSONArray(); - prija.add(prijo); - orderjo.put("properties", prija); - - return orderjo; - } - - @Override - public HttpResponse pause() throws Exception { - - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { - String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); - String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); - - agvurl = agvurl + ":" + agvport + "/v1/vehicles/pause"; - log.info("暂停所有agv请求:{}", agvurl); - - HttpResponse result = HttpRequest.post(agvurl) - .timeout(20000)//超时,毫秒 - .execute(); - log.info("暂停所有agv请求反馈:{}", result); - String type = ""; - if (result.getStatus() == 200) { - type = "info"; - } else { - type = "error"; - } - logServer.log("", "pause", type, "", result.body(), String.valueOf(result.getStatus()), agvurl, ""); - return result; - } else { - return null; - } - } - - @Override - public HttpResponse pause(String device_code) throws Exception { - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { - String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); - String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); - - agvurl = agvurl + ":" + agvport + "/v1/vehicles/" + device_code + "/pause"; - log.info("暂停{} agv请求:{}", device_code, agvurl); - - HttpResponse result = HttpRequest.post(agvurl) - .timeout(20000)//超时,毫秒 - .execute(); - log.info("暂停{} agv请求反馈:{}", device_code, result); - String type = ""; - return result; - } else { - return null; - } - } - - @Override - public HttpResponse resume() throws Exception { - - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { - String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); - String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); - - agvurl = agvurl + ":" + agvport + "/v1/vehicles/resume"; - log.info("恢复所有agv请求:{}", agvurl); - - HttpResponse result = HttpRequest.post(agvurl) - .timeout(20000)//超时,毫秒 - .execute(); - log.info("恢复所有agv请求反馈:{}", result); - String type = ""; - if (result.getStatus() == 200) { - type = "info"; - } else { - type = "error"; - } - logServer.log("", "resume", type, "", result.body(), String.valueOf(result.getStatus()), agvurl, ""); - return result; - } else { - return null; - } - } - - @Override - public HttpResponse resume(String device_code) throws Exception { - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) { - String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); - String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT); - - agvurl = agvurl + ":" + agvport + "/v1/vehicles/" + device_code + "/resume"; - log.info("恢复{} agv请求:{}", device_code, agvurl); - - HttpResponse result = HttpRequest.post(agvurl) - .timeout(20000)//超时,毫秒 - .execute(); - log.info("恢复{} agv请求反馈:{}", device_code, result); - - return result; - } else { - return null; - } - } - - @Override - public String queryDeviceStation() { - return null; - } - - String hexToString(int i) { - return (i < 16 ? "0" + Integer.toHexString(i) : Integer.toHexString(i)).toUpperCase(); - } - - - public static int IntToHexHigh(int b) { - int big = (b & 0xFF00) >> 8; - return big; - } - - public static int IntToHexLow(int b) { - int little = b & 0xFF; - return little; - } - - - public static String Bytes2HexString(byte[] b) { - String ret = ""; - for (int i = 0; i < b.length; i++) { - String hex = Integer.toHexString(b[i] & 0xFF); - if (hex.length() == 1) { - hex = '0' + hex; - } - ret += hex.toUpperCase(); - } - return ret; - } - - public static void main(String[] args) { - String address = "L1-01-01"; - if (address.indexOf("-") > 0) { - String str = address.substring(address.indexOf("-"), address.length()); - address = address.substring(0, address.indexOf("-")); - System.out.println(address); - } - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java b/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java index ff6b4f1..4584a1b 100644 --- a/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java +++ b/nladmin-system/src/main/java/org/nl/acs/device/rest/DeviceController.java @@ -214,7 +214,6 @@ public class DeviceController { @ApiOperation("改变电子围栏状态") //@PreAuthorize("@el.check('device:add')") public ResponseEntity changeFenceStatus(@RequestBody JSONObject json) { - deviceService.changeFenceStatus(json); return new ResponseEntity<>(HttpStatus.CREATED); } @@ -223,7 +222,6 @@ public class DeviceController { @ApiOperation("响应请求") //@PreAuthorize("@el.check('device:add')") public ResponseEntity responseAgv(@RequestBody JSONObject json) { - deviceService.responseAgv(json); return new ResponseEntity<>(HttpStatus.CREATED); } diff --git a/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java b/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java index 138e782..baddaa5 100644 --- a/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java +++ b/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java @@ -1,8 +1,6 @@ package org.nl.acs.device.service; - - import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import org.nl.acs.device.service.dto.DeviceDto; @@ -176,12 +174,6 @@ public interface DeviceService { */ void changeDeviceStatus(JSONObject form); - /** - * 改变电子围栏状态 - * - * @param form - */ - void changeFenceStatus(JSONObject form); /** * 呼叫请求 @@ -197,12 +189,6 @@ public interface DeviceService { */ void addMaterial(JSONObject form); - /** - * 响应请求参数 - * - * @param form - */ - void responseAgv(JSONObject form); void autoCreateTask(JSONObject json); diff --git a/nladmin-system/src/main/java/org/nl/acs/device/service/impl/ConveyorDevice.java b/nladmin-system/src/main/java/org/nl/acs/device/service/impl/ConveyorDevice.java deleted file mode 100644 index 9a685f3..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device/service/impl/ConveyorDevice.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.nl.acs.device.service.impl; - -import lombok.Data; -import lombok.SneakyThrows; -import org.nl.acs.instruction.service.dto.InstructionDto; -import org.nl.acs.opc.OpcUtl; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.acs.task.service.impl.TaskServiceImpl; - -@Data -public class ConveyorDevice { - - String id; - - int jobNo = -1; - - int lastjobNo = -1; - - String palletNo; - - InstructionDto inst; - - RecvThread rt; - - public ConveyorDevice(String id) { - if (id == null) { - throw new NullPointerException("ID is null"); - } else { - this.id = id; - } - System.out.println("id:" + id); - rt = new RecvThread(); - rt.run(); - } - - public void adviseData() { - System.out.println("test"); - } - - private class RecvThread implements Runnable { - - @SneakyThrows - @Override - public void run() { - System.out.println("test"); - String MODE = "RD1.RD1." + id + ".mode"; - String code = OpcUtl.read(MODE); - if ("2".equals(code)) { - TaskService taskserver = new TaskServiceImpl(); - TaskDto dto = new TaskDto(); - dto.setStart_point_code(id); - dto.setNext_point_code("1002"); - taskserver.create(dto); - } - } - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java b/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java index 617fa61..8c70395 100644 --- a/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java +++ b/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java @@ -18,15 +18,7 @@ import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; import org.nl.acs.device.service.*; import org.nl.acs.device.service.dto.*; import org.nl.acs.device_driver.DeviceDriverDefination; -import org.nl.acs.device_driver.ScannerDeviceDriver; import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.device_driver.electric_fence.ElectricFenceDeviceDriver; -import org.nl.acs.device_driver.special_ordinary_site.SpecialOrdinarySiteDeviceDriver; -import org.nl.acs.device_driver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; -import org.nl.acs.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver; -import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; -import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; -import org.nl.acs.device_driver.standard_scanner.StandardScannerDeviceDriver; import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppServiceImpl; @@ -142,7 +134,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial public DeviceDto findByCode(String code) { WQLObject wo = WQLObject.getWQLObject("acs_device"); JSONObject json = wo.query("device_code ='" + code + "'").uniqueResult(0); - final DeviceDto obj = JSON.parseObject(String.valueOf(json), DeviceDto.class); + final DeviceDto obj = JSON.parseObject(String.valueOf(json), DeviceDto.class); return obj; } @@ -191,7 +183,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial dto.setUpdate_by(currentUsername); WQLObject wo = WQLObject.getWQLObject("acs_device"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); + JSONObject json = (JSONObject) JSONObject.toJSON(dto); wo.update(json); } @@ -236,7 +228,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial Iterator iterator = allDevice.iterator(); while (iterator.hasNext()) { Device device = iterator.next(); - if (StrUtil.equals(device.getDevice_code(),device_code)) { + if (StrUtil.equals(device.getDevice_code(), device_code)) { iterator.remove(); } } @@ -407,13 +399,6 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial json.put("checked", false); json.put("device_name", obj.getString("device_name")); Device device = deviceAppService.findDeviceByCode(obj.getString("device_code")); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - json.put("quantity", standardOrdinarySiteDeviceDriver.getQty()); - json.put("material_type", standardOrdinarySiteDeviceDriver.getMaterial()); - json.put("remark", standardOrdinarySiteDeviceDriver.getRemark()); - } JSONArray extraArr = extraTab.query("device_id = '" + obj.getString("device_id") + "'").getResultJSONArray(0); for (int m = 0; m < extraArr.size(); m++) { JSONObject jsonObject = extraArr.getJSONObject(m); @@ -456,13 +441,6 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial json.put("device_code", obj.getString("device_code")); json.put("device_name", obj.getString("device_name")); Device device = deviceAppService.findDeviceByCode(obj.getString("device_code")); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - json.put("quantity", standardOrdinarySiteDeviceDriver.getQty()); - json.put("material_type", standardOrdinarySiteDeviceDriver.getMaterial()); - json.put("remark", standardOrdinarySiteDeviceDriver.getRemark()); - } JSONArray extraArr = extraTab.query("device_id = '" + obj.getString("device_id") + "'").getResultJSONArray(0); for (int m = 0; m < extraArr.size(); m++) { JSONObject jsonObject = extraArr.getJSONObject(m); @@ -505,13 +483,6 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial json.put("checked", false); json.put("device_name", obj.getString("device_name")); Device device = deviceAppService.findDeviceByCode(obj.getString("device_code")); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - json.put("quantity", standardOrdinarySiteDeviceDriver.getQty()); - json.put("material_type", standardOrdinarySiteDeviceDriver.getMaterial()); - json.put("remark", standardOrdinarySiteDeviceDriver.getRemark()); - } JSONArray extraArr = extraTab.query("device_id = '" + obj.getString("device_id") + "'").getResultJSONArray(0); for (int m = 0; m < extraArr.size(); m++) { JSONObject jsonObject = extraArr.getJSONObject(m); @@ -541,10 +512,8 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial @Override public JSONArray selectDeviceDevicerInfo(String status) { - JSONArray deviceInfo = new JSONArray(); DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; JSONArray arr = WQLObject.getWQLObject("acs_device").query("is_delete= '0' AND is_active= '1' and region != '' and is_config= 'true' ").getResultJSONArray(0); JSONArray result = new JSONArray(); @@ -556,20 +525,6 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial String region = obj.getString("region"); String device_code = obj.getString("device_code"); Device device = appService.findDeviceByCode(device_code); - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - int branchProtocol = standardOrdinarySiteDeviceDriver.getBranchProtocol(); - if (branchProtocol == 2) { - devicejo.put("device_code", device_code); - devicejo.put("branchProtocol", branchProtocol); - devicejo.put("region", region); - devicejo.put("qty", standardOrdinarySiteDeviceDriver.getQty()); - devicejo.put("remark", standardOrdinarySiteDeviceDriver.getRemark()); - devicejo.put("material", standardOrdinarySiteDeviceDriver.getMaterial()); - devicejo.put("status", standardOrdinarySiteDeviceDriver.isRequireSucess()); - deviceInfo.add(devicejo); - } - } } } else if (status.equals("3")) { for (int i = 0; i < arr.size(); i++) { @@ -578,20 +533,6 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial String region = obj.getString("region"); String device_code = obj.getString("device_code"); Device device = appService.findDeviceByCode(device_code); - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - int branchProtocol = standardOrdinarySiteDeviceDriver.getBranchProtocol(); - if (branchProtocol == 3) { - devicejo.put("device_code", device_code); - devicejo.put("branchProtocol", branchProtocol); - devicejo.put("region", region); - devicejo.put("qty", standardOrdinarySiteDeviceDriver.getQty()); - devicejo.put("material", standardOrdinarySiteDeviceDriver.getMaterial()); - devicejo.put("remark", standardOrdinarySiteDeviceDriver.getRemark()); - devicejo.put("status", standardOrdinarySiteDeviceDriver.isRequireSucess()); - deviceInfo.add(devicejo); - } - } } } else { for (int i = 0; i < arr.size(); i++) { @@ -600,42 +541,8 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial String region = obj.getString("region"); String device_code = obj.getString("device_code"); Device device = appService.findDeviceByCode(device_code); - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - int branchProtocol = standardOrdinarySiteDeviceDriver.getBranchProtocol(); - devicejo.put("device_code", device_code); - devicejo.put("branchProtocol", branchProtocol); - devicejo.put("region", region); - devicejo.put("qty", standardOrdinarySiteDeviceDriver.getQty()); - devicejo.put("material", standardOrdinarySiteDeviceDriver.getMaterial()); - devicejo.put("remark", standardOrdinarySiteDeviceDriver.getRemark()); - devicejo.put("status", standardOrdinarySiteDeviceDriver.isRequireSucess()); - deviceInfo.add(devicejo); - } } } - - -// for(int i=0; i readableItemDtos = opcDeviceDriverDefination.getReadableItemDtos(); List readableItemJsons = new ArrayList<>(); for (int i = 0; i < readableItemDtos.size(); i++) { ItemDto itemDto = readableItemDtos.get(i); JSONObject readableItemJson = new JSONObject(); - readableItemJson.put("code",itemDto.getCode()); - readableItemJson.put("name",itemDto.getName()); + readableItemJson.put("code", itemDto.getCode()); + readableItemJson.put("name", itemDto.getName()); // readableItemJson.put("db",itemDto.getDb()); readableItemJsons.add(readableItemJson); } @@ -1244,7 +933,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial String code = split[split.length - 1]; robj.put("code", code); robj.put("name", rs.getJSONObject(i).getString("remark")); - if (readableItemJsons.contains(robj)){ + if (readableItemJsons.contains(robj)) { robj.put("code", rs.getJSONObject(i).getString("extra_code")); robj.put("db", rs.getJSONObject(i).getString("extra_name")); r_arry.add(robj); @@ -1258,16 +947,16 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial code = split[split.length - 1]; JSONObject jsonObject = new JSONObject(); jsonObject.put("code", code); - jsonObject.put("name",rJson.getString("name")); + jsonObject.put("name", rJson.getString("name")); rarry.add(jsonObject); } for (int i = 0; i < readableItemDtos.size(); i++) { ItemDto itemDto = readableItemDtos.get(i); JSONObject readableItemJson = new JSONObject(); - readableItemJson.put("code",itemDto.getCode()); - readableItemJson.put("name",itemDto.getName()); - if (!rarry.contains(readableItemJson)){ - readableItemJson.put("db",itemDto.getDb()); + readableItemJson.put("code", itemDto.getCode()); + readableItemJson.put("name", itemDto.getName()); + if (!rarry.contains(readableItemJson)) { + readableItemJson.put("db", itemDto.getDb()); r_arry.add(readableItemJson); } } @@ -1278,8 +967,8 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial for (int i = 0; i < writeableItemDtos.size(); i++) { ItemDto itemDto = writeableItemDtos.get(i); JSONObject writeableItemJson = new JSONObject(); - writeableItemJson.put("code",itemDto.getCode()); - writeableItemJson.put("name",itemDto.getName()); + writeableItemJson.put("code", itemDto.getCode()); + writeableItemJson.put("name", itemDto.getName()); //writeableItemJson.put("db",itemDto.getDb()); writeableItemJsons.add(writeableItemJson); } @@ -1290,7 +979,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial JSONObject robj = new JSONObject(); robj.put("code", code); robj.put("name", ws.getJSONObject(i).getString("remark")); - if (writeableItemJsons.contains(robj)){ + if (writeableItemJsons.contains(robj)) { robj.put("code", ws.getJSONObject(i).getString("extra_code")); robj.put("db", ws.getJSONObject(i).getString("extra_name")); w_arry.add(robj); @@ -1303,17 +992,17 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial String[] split = code.split("\\."); code = split[split.length - 1]; JSONObject jsonObject = new JSONObject(); - jsonObject.put("code",code); - jsonObject.put("name",wJson.getString("name")); + jsonObject.put("code", code); + jsonObject.put("name", wJson.getString("name")); warry.add(jsonObject); } for (int i = 0; i < writeableItemDtos.size(); i++) { ItemDto itemDto = writeableItemDtos.get(i); JSONObject writeableItemJson = new JSONObject(); - writeableItemJson.put("code",itemDto.getCode()); - writeableItemJson.put("name",itemDto.getName()); - if (!warry.contains(writeableItemJson)){ - writeableItemJson.put("db",itemDto.getDb()); + writeableItemJson.put("code", itemDto.getCode()); + writeableItemJson.put("name", itemDto.getName()); + if (!warry.contains(writeableItemJson)) { + writeableItemJson.put("db", itemDto.getDb()); w_arry.add(writeableItemJson); } } @@ -1533,14 +1222,8 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial @Override public String queryScannerByCode(String device_code) throws Exception { - Device device = deviceAppService.findDeviceByCode(device_code); - StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver = null; - String str = null; - if (device.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) { - standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) device.getDeviceDriver(); - str = standardCoveyorControlWithScannerDeviceDriver.barcode(); - } - return str; + + return null; } @Override @@ -1598,15 +1281,6 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial @Override public void updateBarcode(JSONObject json) throws Exception { - String device_code = json.getString("device_code"); - String barcode = json.getString("barcode"); - Device device = deviceAppService.findDeviceByCode(device_code); - StandardScannerDeviceDriver standardScannerDeviceDriver; - if (device.getDeviceDriver() instanceof ScannerDeviceDriver) { - standardScannerDeviceDriver = (StandardScannerDeviceDriver) device.getDeviceDriver(); - standardScannerDeviceDriver.writeBarcode(barcode); - } - } } diff --git a/nladmin-system/src/main/java/org/nl/acs/device/service/impl/Test.java b/nladmin-system/src/main/java/org/nl/acs/device/service/impl/Test.java deleted file mode 100644 index 8e73a4e..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device/service/impl/Test.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.nl.acs.device.service.impl; - -import java.util.ArrayList; -import java.util.List; - -public class Test { - - public static void main(String[] args) { - String device = "1001,1002"; - List list = new ArrayList<>(); - list.add("1001"); - list.add("1002"); - for (int i = 0; i < list.size(); i++) { - ConveyorDevice condev = new ConveyorDevice(list.get(i).toString()); - } - - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/electric_fence/ElectricFenceDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/electric_fence/ElectricFenceDefination.java deleted file mode 100644 index 7370aae..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/electric_fence/ElectricFenceDefination.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.nl.acs.device_driver.electric_fence; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.device_driver.standard_autodoor.ItemProtocol; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 自动门驱动定义 - */ -@Service -public class ElectricFenceDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "electric_fence"; - } - - @Override - public String getDriverName() { - return "标准版-电子围栏"; - } - - @Override - public String getDriverDescription() { - return "标准版-电子围栏"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new ElectricFenceDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return ElectricFenceDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", true)); - list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B4")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/electric_fence/ElectricFenceDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/electric_fence/ElectricFenceDeviceDriver.java deleted file mode 100644 index ad78b17..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/electric_fence/ElectricFenceDeviceDriver.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.nl.acs.device_driver.electric_fence; - -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.opc.Device; -import org.nl.utils.SpringContextHolder; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.HashMap; -import java.util.Map; - -/** - * 电子围栏驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class ElectricFenceDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - - @Autowired - AgvService agvService = SpringContextHolder.getBean("agvServiceImpl"); - - String devicecode; - int mode = 0; - int action = 0; - int error = 0; - Boolean iserror = false; - - int move = 0; - int task = 0; - int last_action = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - //是否暂停 true为暂停 false为恢复 - Boolean suspended = false; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() throws Exception { - - String device_code = this.getDevice().getDevice_code(); - mode = this.itemProtocol.getMode(); - action = this.itemProtocol.getAction(); - error = this.itemProtocol.getError(); - if (mode != last_mode) { - } - if (action != last_action) { - } - if (error != last_error) { - if (this.error == 1) { - agvService.pause(); - } else if (this.error == 0){ - agvService.resume(); - } - } - last_action = action; - last_mode = mode; - last_error = error; - } - - public void writing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - ReadUtil.write(itemMap, server); - log.info("下发PLC信号:{},{}", to_command, command); - System.out.println("设备:" + devicecode + ",下发PLC信号:" + to_command + ",value:" + command); - - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/electric_fence/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/electric_fence/ItemProtocol.java deleted file mode 100644 index b91dd96..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/electric_fence/ItemProtocol.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.nl.acs.device_driver.electric_fence; - -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; - -import java.util.ArrayList; -import java.util.List; - -@Slf4j -public class ItemProtocol { - public static String item_heartbeat = "heartbeat"; - public static String item_mode = "mode"; - public static String item_action = "action"; - public static String item_error = "error"; - public static String item_to_command = "to_command"; - - - private ElectricFenceDeviceDriver driver; - - public ItemProtocol(ElectricFenceDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - log.error("读取错误!"); - } else { - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB51.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB51.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_action, "动作信号", "DB51.B2")); - list.add(new ItemDto(item_error, "报警信号", "DB51.B4")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB52.W2", Boolean.valueOf(true))); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/feedback_agv_status_site/FeedbackAGVStatusSiteDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/feedback_agv_status_site/FeedbackAGVStatusSiteDefination.java deleted file mode 100644 index 78f357d..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/feedback_agv_status_site/FeedbackAGVStatusSiteDefination.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.nl.acs.device_driver.feedback_agv_status_site; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * 上报AGV状态站点 - */ -@Service -public class FeedbackAGVStatusSiteDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "feedback_agv_status_site"; - } - - @Override - public String getDriverName() { - return "上报AGV状态站点"; - } - - @Override - public String getDriverDescription() { - return "上报AGV状态站点"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new FeedbackAGVStatusSiteDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return FeedbackAGVStatusSiteDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - - @Override - public List getReadableItemDtos() { - return null; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/feedback_agv_status_site/FeedbackAGVStatusSiteDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/feedback_agv_status_site/FeedbackAGVStatusSiteDeviceDriver.java deleted file mode 100644 index fed54d6..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/feedback_agv_status_site/FeedbackAGVStatusSiteDeviceDriver.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.nl.acs.device_driver.feedback_agv_status_site; - -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device_driver.DeviceDriver; -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.opc.Device; -import org.openscada.opc.lib.da.Server; - -import java.util.HashMap; -import java.util.Map; - -/** - * 上报AGV状态站点 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class FeedbackAGVStatusSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_status; - - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - ReadUtil.write(itemMap, server); - - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/feedback_agv_status_site/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/feedback_agv_status_site/ItemProtocol.java deleted file mode 100644 index fac8dd9..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/feedback_agv_status_site/ItemProtocol.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.nl.acs.device_driver.feedback_agv_status_site; - -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_to_status = "to_status"; - - private FeedbackAGVStatusSiteDeviceDriver driver; - - public ItemProtocol(FeedbackAGVStatusSiteDeviceDriver driver) { - this.driver = driver; - } - - public int getToStatus() { - return this.getOpcIntegerValue(item_to_status); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_status, "agv状态", "DB608.B0", Boolean.valueOf(true))); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lamp_three_color/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lamp_three_color/ItemProtocol.java deleted file mode 100644 index 7734926..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lamp_three_color/ItemProtocol.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.nl.acs.device_driver.lamp_three_color; - -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; - -import java.util.ArrayList; -import java.util.List; - -@Slf4j -public class ItemProtocol { - public static String item_heartbeat = "heartbeat"; - public static String item_mode = "mode"; - public static String item_action = "action"; - public static String item_error = "error"; - public static String item_to_command = "to_command"; - - - private LampThreecolorDeviceDriver driver; - - public ItemProtocol(LampThreecolorDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - //log.error("读取错误!"); - } else { - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB51.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB51.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_action, "动作信号", "DB51.B2")); - list.add(new ItemDto(item_error, "报警信号", "DB51.B4")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB52.W2", Boolean.valueOf(true))); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lamp_three_color/LampThreecolorDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lamp_three_color/LampThreecolorDefination.java deleted file mode 100644 index b1421f4..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lamp_three_color/LampThreecolorDefination.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.nl.acs.device_driver.lamp_three_color; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 自动门驱动定义 - */ -@Service -public class LampThreecolorDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "lamp_three_color"; - } - - @Override - public String getDriverName() { - return "标准版-三色灯"; - } - - @Override - public String getDriverDescription() { - return "标准版-三色灯"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new LampThreecolorDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return LampThreecolorDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", true)); - list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B4")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lamp_three_color/LampThreecolorDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lamp_three_color/LampThreecolorDeviceDriver.java deleted file mode 100644 index 8b2e6a7..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lamp_three_color/LampThreecolorDeviceDriver.java +++ /dev/null @@ -1,155 +0,0 @@ -package org.nl.acs.device_driver.lamp_three_color; - -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.opc.Device; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.task.service.TaskService; -import org.nl.utils.SpringContextHolder; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -/** - * 检测站点驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class LampThreecolorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - String devicecode; - int mode = 0; - int action = 0; - int error = 0; - int move = 0; - int task = 0; - int last_action = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - protected boolean hasGoods = false; - boolean isFold = false; - private String assemble_check_tag; - private Boolean sampleMode0; - private Boolean sampleMode3; - private Integer sampleError; - private Boolean sampleOnline; - protected String displayMessage = null; - public int display_message_time_out = 30000; - public Date display_message_time; - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - - String device_code = this.getDevice().getDevice_code(); - mode = this.itemProtocol.getMode(); - action = this.itemProtocol.getAction(); - error = this.itemProtocol.getError(); - if (mode != last_mode) { - } - if (action != last_action) { - } - if (error != last_error) { - } - last_action = action; - last_mode = mode; - last_error = error; - //message = StringFormatUtl.format("设备报警:{}", new Object[]{}); - -// String manual_create_task = this.getDevice().getExtraValue().get("manual_create_task").toString(); - - - } - - public synchronized String getStatus() { - JSONObject jo = new JSONObject(); - - if (action == 1) { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "OPEN"); - - } else if (action == 2) { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "CLOSE"); - - } else { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "ERROR"); - } - return jo.toString(); - } - - - public void writing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.standard_inspect_site.ItemProtocol.item_to_command; - - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - ReadUtil.write(itemMap, server); - log.info("下发PLC信号:{},{}", to_command, command); - System.out.println("设备:" + devicecode + ",下发PLC信号:" + to_command + ",value:" + command); - } - - public synchronized void OpenOrClose(String type) { - - writing(Integer.parseInt(type)); - - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/ItemProtocol.java deleted file mode 100644 index 62c1e19..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/ItemProtocol.java +++ /dev/null @@ -1,123 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_fold_disc_site; - -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_status = "status"; - public static String item_open_time = "open_time"; - public static String item_close_time = "close_time"; - public static String item_standby_time = "standby_time "; - public static String item_production_time = "production_time"; - public static String item_error_time = "error_time"; - public static String item_container_qty = "container_qty"; - public static String item_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_task = "to_task"; - Boolean isonline; - - private LnshFoldDiscSiteDeviceDriver driver; - - public ItemProtocol(LnshFoldDiscSiteDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getStatus() { - return this.getOpcIntegerValue(item_status); - } - - public int getOpen_time() { - return this.getOpcIntegerValue(item_open_time); - } - - public int getClose_time() { - return this.getOpcIntegerValue(item_close_time); - } - - public int getStandby_time() { - return this.getOpcIntegerValue(item_standby_time); - } - - public int getProduction_time() { - return this.getOpcIntegerValue(item_production_time); - } - - public int getError_time() { - return this.getOpcIntegerValue(item_error_time); - } - - public int getContainer_qty() { - return this.getOpcIntegerValue(item_container_qty); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getToTarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getToTask() { - return this.getOpcIntegerValue(item_to_task); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_status, "设备状态", "DB600.B2")); - list.add(new ItemDto(item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(item_close_time, "关机时间", "DB600.D5")); - list.add(new ItemDto(item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(item_error_time, "故障时间", "DB600.D8")); - list.add(new ItemDto(item_container_qty, "托盘数", "DB600.D8")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "下发命令反馈", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_target, "下发目标站", "DB601.W4")); - list.add(new ItemDto(item_to_task, "下发任务号", "DB601.D8")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/LnshFoldDiscSiteDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/LnshFoldDiscSiteDefination.java deleted file mode 100644 index e7c7d55..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/LnshFoldDiscSiteDefination.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_fold_disc_site; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 晟华叠盘工位 - */ -@Service -public class LnshFoldDiscSiteDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "lnsh_fold_disc_site"; - } - - @Override - public String getDriverName() { - return "晟华-叠盘工位"; - } - - @Override - public String getDriverDescription() { - return "晟华-叠盘工位"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new LnshFoldDiscSiteDeviceDriver()).setDevice(device).setDriverDefination(this); - } - - @Override - public Class getDeviceDriverType() { - return LnshFoldDiscSiteDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(ItemProtocol.item_status, "设备状态", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_close_time, "关机时间", "DB600.D5")); - list.add(new ItemDto(ItemProtocol.item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(ItemProtocol.item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(ItemProtocol.item_error_time, "故障时间", "DB600.D8")); - list.add(new ItemDto(ItemProtocol.item_container_qty, "托盘数", "DB600.D8")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/LnshFoldDiscSiteDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/LnshFoldDiscSiteDeviceDriver.java deleted file mode 100644 index 06eb47a..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_fold_disc_site/LnshFoldDiscSiteDeviceDriver.java +++ /dev/null @@ -1,336 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_fold_disc_site; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -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.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 晟华叠盘工位 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class LnshFoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - - - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - - String device_code; - int mode = 0; - int error = 0; - int move = 0; - int action; - int io_action; - int task = 0; - int container_type = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - int last_container_type; - Boolean isonline = true; - int hasGoods = 0; - Boolean iserror = false; - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - private Boolean sampleMode0; - private Boolean sampleMode3; - private Integer sampleError; - private Boolean sampleOnline; - protected String displayMessage = null; - public int display_message_time_out = 30000; - public Date display_message_time; - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out = 3000; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int heartbeat; - int last_heartbeat; - private Date checkHeartbeattime = new Date(); - private Date last_checkHeartbeattime = new Date(); - - int branchProtocol = 0; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - String message; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - device_code = this.getDeviceCode(); - - mode = this.itemProtocol.getMode(); - - } catch (Exception var17) { - return; - } - - //急停 - if (this.isStop()) { - - //未在线无心跳 - } else if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 2: - - break; - case 3: - - break; - case 4: - break; - } - } - - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - last_container_type = container_type; - } - - - protected void thingToNothing() throws Exception { - this.setRequireSucess(false); - } - - public void finish_instruction(Instruction instruction) throws Exception { - instruction_finished(instruction); - } - - /** - * 完成指令 - * - * @param instruction - * @return - */ - public boolean instruction_finished(Instruction instruction) throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - instructionService.finish(instruction.getInstruction_id()); - this.instruction_finished_time = date; - return true; - } - } - - /** - * 完成并创建下一条指令 - * - * @param instruction - * @param needCreateNext - * @return - */ - public boolean instruction_finished(Instruction instruction, boolean needCreateNext) { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - this.instruction_finished_time = date; - return true; - } - } - - - private Instruction findInstruction() { - Instruction instruction = null; - if (this.instruction_num != 0) { - instruction = (Instruction) instructionService.findByCodeFromCache(String.valueOf(instruction_num)); - } - if (instruction != null) { - //可进行校验 - - - } else { - List container_instructions = new ArrayList(); - String barcode = this.getLast_container(); - - if (!StrUtil.isEmpty(barcode)) { - Map map = new HashMap(); - map.put("vehicle_code", barcode); - container_instructions = instructionService.queryAll(map); - } - - if (((List) container_instructions).size() > 1) { - log.debug("容器存在多个指令"); - } else { - if (((List) container_instructions).size() > 0) { - instruction = (Instruction) ((List) container_instructions).get(0); - } - } - } - return instruction; - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_lane/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_lane/ItemProtocol.java deleted file mode 100644 index 38d2a95..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_lane/ItemProtocol.java +++ /dev/null @@ -1,123 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_kiln_lane; - -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_status = "status"; - public static String item_open_time = "open_time"; - public static String item_standby_time = "standby_time "; - public static String item_production_time = "production_time"; - public static String item_error_time = "error_time"; - public static String item_car_sum = "car_sum"; - public static String item_nullCar_qty = "nullCar_qty"; - public static String item_burning_car_qty = "burning_car_qty"; - public static String item_to_command = "to_command"; - public static String item_to_material_code = "to_material_code"; - Boolean isonline; - - private LnshKilnLaneDeviceDriver driver; - - public ItemProtocol(LnshKilnLaneDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getStatus() { - return this.getOpcIntegerValue(item_status); - } - - public int getOpen_time() { - return this.getOpcIntegerValue(item_open_time); - } - - public int getStandby_time() { - return this.getOpcIntegerValue(item_standby_time); - } - - public int getProduction_time() { - return this.getOpcIntegerValue(item_production_time); - } - - public int getError_time() { - return this.getOpcIntegerValue(item_error_time); - } - - public int getCar_sum() { - return this.getOpcIntegerValue(item_car_sum); - } - - public int getNullCar_qty() { - return this.getOpcIntegerValue(item_nullCar_qty); - } - - public int getBurning_car_qty() { - return this.getOpcIntegerValue(item_burning_car_qty); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getTo_material_code() { - return this.getOpcIntegerValue(item_to_material_code); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_status, "设备状态", "DB600.B3")); - list.add(new ItemDto(item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(item_error_time, "故障时间", "DB600.D8")); - list.add(new ItemDto(item_car_sum, "窑车总数", "DB600.B4")); - list.add(new ItemDto(item_nullCar_qty, "空窑车数", "DB600.B6")); - list.add(new ItemDto(item_burning_car_qty, "在烧窑车数", "DB600.D8")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "下发命令", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_material_code, "下发物料编号", "DB601.W4")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_lane/LnshKilnLaneDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_lane/LnshKilnLaneDefination.java deleted file mode 100644 index e803a0c..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_lane/LnshKilnLaneDefination.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_kiln_lane; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 晟华窑车道 - */ -@Service -public class LnshKilnLaneDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "lnsh_kiln_lane"; - } - - @Override - public String getDriverName() { - return "晟华-窑车道"; - } - - @Override - public String getDriverDescription() { - return "晟华-窑车道"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new LnshKilnLaneDeviceDriver()).setDevice(device).setDriverDefination(this); - } - - @Override - public Class getDeviceDriverType() { - return LnshKilnLaneDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(ItemProtocol.item_status, "设备状态", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(ItemProtocol.item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(ItemProtocol.item_error_time, "故障时间", "DB600.D8")); - list.add(new ItemDto(ItemProtocol.item_car_sum, "窑车总数", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_nullCar_qty, "空窑车数", "DB600.B6")); - list.add(new ItemDto(ItemProtocol.item_burning_car_qty, "在烧窑车数", "DB600.D8")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_lane/LnshKilnLaneDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_lane/LnshKilnLaneDeviceDriver.java deleted file mode 100644 index 8e8c6d3..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_lane/LnshKilnLaneDeviceDriver.java +++ /dev/null @@ -1,334 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_kiln_lane; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -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.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 晟华窑车道 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class LnshKilnLaneDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - - - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - - String device_code; - int mode = 0; - int error = 0; - int move = 0; - int action; - int io_action; - int task = 0; - int container_type = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - int last_container_type; - Boolean isonline = true; - int hasGoods = 0; - Boolean iserror = false; - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - private Boolean sampleMode0; - private Boolean sampleMode3; - private Integer sampleError; - private Boolean sampleOnline; - protected String displayMessage = null; - public int display_message_time_out = 30000; - public Date display_message_time; - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out = 3000; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int heartbeat; - int last_heartbeat; - private Date checkHeartbeattime = new Date(); - private Date last_checkHeartbeattime = new Date(); - - int branchProtocol = 0; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - String message; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - device_code = this.getDeviceCode(); - - } catch (Exception var17) { - return; - } - - //急停 - if (this.isStop()) { - - //未在线无心跳 - } else if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 2: - - break; - case 3: - - break; - case 4: - break; - } - } - - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - last_container_type = container_type; - } - - - protected void thingToNothing() throws Exception { - this.setRequireSucess(false); - } - - public void finish_instruction(Instruction instruction) throws Exception { - instruction_finished(instruction); - } - - /** - * 完成指令 - * - * @param instruction - * @return - */ - public boolean instruction_finished(Instruction instruction) throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - instructionService.finish(instruction.getInstruction_id()); - this.instruction_finished_time = date; - return true; - } - } - - /** - * 完成并创建下一条指令 - * - * @param instruction - * @param needCreateNext - * @return - */ - public boolean instruction_finished(Instruction instruction, boolean needCreateNext) { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - this.instruction_finished_time = date; - return true; - } - } - - - private Instruction findInstruction() { - Instruction instruction = null; - if (this.instruction_num != 0) { - instruction = (Instruction) instructionService.findByCodeFromCache(String.valueOf(instruction_num)); - } - if (instruction != null) { - //可进行校验 - - - } else { - List container_instructions = new ArrayList(); - String barcode = this.getLast_container(); - - if (!StrUtil.isEmpty(barcode)) { - Map map = new HashMap(); - map.put("vehicle_code", barcode); - container_instructions = instructionService.queryAll(map); - } - - if (((List) container_instructions).size() > 1) { - log.debug("容器存在多个指令"); - } else { - if (((List) container_instructions).size() > 0) { - instruction = (Instruction) ((List) container_instructions).get(0); - } - } - } - return instruction; - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_truss/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_truss/ItemProtocol.java deleted file mode 100644 index b16c777..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_truss/ItemProtocol.java +++ /dev/null @@ -1,141 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_kiln_truss; - -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_status = "status"; - public static String item_outKiln_move = "outKiln_move"; - public static String item_inKiln_move = "inKiln_move"; - public static String item_inKiln_barcode = "inKiln_barcode"; - public static String item_outKiln_barcode = "outKiln_barcode"; - public static String item_inKiln_device = "inKiln_device"; - public static String item_open_time = "open_time"; - public static String item_standby_time = "standby_time "; - public static String item_production_time = "production_time"; - public static String item_error_time = "error_time"; - public static String item_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_task = "to_task"; - Boolean isonline; - - private LnshKilnTrussDeviceDriver driver; - - public ItemProtocol(LnshKilnTrussDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getStatus() { - return this.getOpcIntegerValue(item_status); - } - - public int getOutKiln_move() { - return this.getOpcIntegerValue(item_outKiln_move); - } - - public int getInKiln_move() { - return this.getOpcIntegerValue(item_inKiln_move); - } - - public int getInKiln_barcode() { - return this.getOpcIntegerValue(item_inKiln_barcode); - } - - public int getOutKiln_barcode() { - return this.getOpcIntegerValue(item_outKiln_barcode); - } - - public int getInKiln_device() { - return this.getOpcIntegerValue(item_inKiln_device); - } - - public int getOpen_time() { - return this.getOpcIntegerValue(item_open_time); - } - - public int getStandby_time() { - return this.getOpcIntegerValue(item_standby_time); - } - - public int getProduction_time() { - return this.getOpcIntegerValue(item_production_time); - } - - public int getError_time() { - return this.getOpcIntegerValue(item_error_time); - } - - public int getTo_command() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getTo_target() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getTo_task() { - return this.getOpcIntegerValue(item_to_task); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_status, "设备状态", "DB600.B2")); - list.add(new ItemDto(item_outKiln_move, "出窑光电", "DB600.B2")); - list.add(new ItemDto(item_inKiln_move, "入窑光电", "DB600.B2")); - list.add(new ItemDto(item_inKiln_barcode, "入窑条码", "DB600.B2")); - list.add(new ItemDto(item_outKiln_barcode, "出窑条码", "DB600.B2")); - list.add(new ItemDto(item_inKiln_device, "入窑设备号", "DB600.B2")); - list.add(new ItemDto(item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(item_error_time, "故障时间", "DB600.D8")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "下发命令反馈", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_target, "下发目标站", "DB601.D8")); - list.add(new ItemDto(item_to_task, "下发任务号", "DB601.D8")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_truss/LnshKilnTrussDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_truss/LnshKilnTrussDefination.java deleted file mode 100644 index 1ea802c..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_truss/LnshKilnTrussDefination.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_kiln_truss; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 晟华入窑桁架 - */ -@Service -public class LnshKilnTrussDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "lnsh_kiln_truss"; - } - - @Override - public String getDriverName() { - return "晟华-入窑桁架"; - } - - @Override - public String getDriverDescription() { - return "晟华-入窑桁架"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new LnshKilnTrussDeviceDriver()).setDevice(device).setDriverDefination(this); - } - - @Override - public Class getDeviceDriverType() { - return LnshKilnTrussDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(ItemProtocol.item_status, "设备状态", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_outKiln_move, "出窑光电", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_inKiln_move, "入窑光电", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_inKiln_barcode, "入窑条码", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_outKiln_barcode, "出窑条码", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_inKiln_device, "入窑设备号", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(ItemProtocol.item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(ItemProtocol.item_error_time, "故障时间", "DB600.D8")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_truss/LnshKilnTrussDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_truss/LnshKilnTrussDeviceDriver.java deleted file mode 100644 index be61aa2..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_kiln_truss/LnshKilnTrussDeviceDriver.java +++ /dev/null @@ -1,347 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_kiln_truss; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -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.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 晟华入窑桁架 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class LnshKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - - - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - - String device_code; - int mode = 0; - int error = 0; - int move = 0; - int action; - int io_action; - int task = 0; - int container_type = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - int last_container_type; - Boolean isonline = true; - int hasGoods = 0; - Boolean iserror = false; - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - private Boolean sampleMode0; - private Boolean sampleMode3; - private Integer sampleError; - private Boolean sampleOnline; - protected String displayMessage = null; - public int display_message_time_out = 30000; - public Date display_message_time; - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out = 3000; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int heartbeat; - int last_heartbeat; - private Date checkHeartbeattime = new Date(); - private Date last_checkHeartbeattime = new Date(); - - int branchProtocol = 0; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - String message; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - device_code = this.getDeviceCode(); - - mode = this.itemProtocol.getMode(); - - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (move != last_move) { - thingToNothing(); - } - if (error != last_error) { - } - if (container_type != last_container_type) { - } - - } catch (Exception var17) { - return; - } - - //急停 - if (this.isStop()) { - - //未在线无心跳 - } else if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 2: - - break; - case 3: - - break; - case 4: - break; - } - } - - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - last_container_type = container_type; - } - - - protected void thingToNothing() throws Exception { - this.setRequireSucess(false); - } - - public void finish_instruction(Instruction instruction) throws Exception { - instruction_finished(instruction); - } - - /** - * 完成指令 - * - * @param instruction - * @return - */ - public boolean instruction_finished(Instruction instruction) throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - instructionService.finish(instruction.getInstruction_id()); - this.instruction_finished_time = date; - return true; - } - } - - /** - * 完成并创建下一条指令 - * - * @param instruction - * @param needCreateNext - * @return - */ - public boolean instruction_finished(Instruction instruction, boolean needCreateNext) { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - this.instruction_finished_time = date; - return true; - } - } - - - private Instruction findInstruction() { - Instruction instruction = null; - if (this.instruction_num != 0) { - instruction = (Instruction) instructionService.findByCodeFromCache(String.valueOf(instruction_num)); - } - if (instruction != null) { - //可进行校验 - - - } else { - List container_instructions = new ArrayList(); - String barcode = this.getLast_container(); - - if (!StrUtil.isEmpty(barcode)) { - Map map = new HashMap(); - map.put("vehicle_code", barcode); - container_instructions = instructionService.queryAll(map); - } - - if (((List) container_instructions).size() > 1) { - log.debug("容器存在多个指令"); - } else { - if (((List) container_instructions).size() > 0) { - instruction = (Instruction) ((List) container_instructions).get(0); - } - } - } - return instruction; - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_labeling_machine/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_labeling_machine/ItemProtocol.java deleted file mode 100644 index 5f766e6..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_labeling_machine/ItemProtocol.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_labeling_machine; - -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_status = "status"; - public static String item_open_time = "open_time"; - public static String item_close_time = "close_time"; - public static String item_standby_time = "standby_time "; - public static String item_production_time = "production_time"; - public static String item_error_time = "error_time"; - public static String item_labeling_qty = "labeling_qty"; - public static String item_to_command = "to_command"; - public static String item_to_material_code = "to_material_code"; - Boolean isonline; - - private LnshLabelingMachineDeviceDriver driver; - - public ItemProtocol(LnshLabelingMachineDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getStatus() { - return this.getOpcIntegerValue(item_status); - } - - public int getOpen_time() { - return this.getOpcIntegerValue(item_open_time); - } - - public int getClose_time() { - return this.getOpcIntegerValue(item_close_time); - } - - public int getStandby_time() { - return this.getOpcIntegerValue(item_standby_time); - } - - public int getProduction_time() { - return this.getOpcIntegerValue(item_production_time); - } - - public int getError_time() { - return this.getOpcIntegerValue(item_error_time); - } - - public int getLabeling_qty() { - return this.getOpcIntegerValue(item_labeling_qty); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getTo_material_code() { - return this.getOpcIntegerValue(item_to_material_code); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_status, "设备状态", "DB600.B2")); - list.add(new ItemDto(item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(item_close_time, "关机时间", "DB600.D5")); - list.add(new ItemDto(item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(item_error_time, "故障时间", "DB600.D8")); - list.add(new ItemDto(item_labeling_qty, "贴标数量", "DB600.D8")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "下发命令", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_material_code, "下发物料编号", "DB601.D8")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_labeling_machine/LnshLabelingMachineDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_labeling_machine/LnshLabelingMachineDefination.java deleted file mode 100644 index dd72655..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_labeling_machine/LnshLabelingMachineDefination.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_labeling_machine; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 晟华贴标机 - */ -@Service -public class LnshLabelingMachineDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "lnsh_labeling_machine"; - } - - @Override - public String getDriverName() { - return "晟华-贴标机"; - } - - @Override - public String getDriverDescription() { - return "晟华-贴标机"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new LnshLabelingMachineDeviceDriver()).setDevice(device).setDriverDefination(this); - } - - @Override - public Class getDeviceDriverType() { - return LnshLabelingMachineDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(ItemProtocol.item_status, "设备状态", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_close_time, "关机时间", "DB600.D5")); - list.add(new ItemDto(ItemProtocol.item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(ItemProtocol.item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(ItemProtocol.item_error_time, "故障时间", "DB600.D8")); - list.add(new ItemDto(ItemProtocol.item_labeling_qty, "贴标数量", "DB600.D8")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_labeling_machine/LnshLabelingMachineDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_labeling_machine/LnshLabelingMachineDeviceDriver.java deleted file mode 100644 index 5e32ea4..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_labeling_machine/LnshLabelingMachineDeviceDriver.java +++ /dev/null @@ -1,348 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_labeling_machine; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -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.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 晟华贴标机 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class LnshLabelingMachineDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - - - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - - String device_code; - int mode = 0; - int error = 0; - int move = 0; - int action; - int io_action; - int task = 0; - int container_type = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - int last_container_type; - Boolean isonline = true; - int hasGoods = 0; - Boolean iserror = false; - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - private Boolean sampleMode0; - private Boolean sampleMode3; - private Integer sampleError; - private Boolean sampleOnline; - protected String displayMessage = null; - public int display_message_time_out = 30000; - public Date display_message_time; - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out = 3000; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int heartbeat; - int last_heartbeat; - private Date checkHeartbeattime = new Date(); - private Date last_checkHeartbeattime = new Date(); - - int branchProtocol = 0; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - String message; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - device_code = this.getDeviceCode(); - - mode = this.itemProtocol.getMode(); - - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (move != last_move) { - thingToNothing(); - } - if (error != last_error) { - } - if (container_type != last_container_type) { - } - - } catch (Exception var17) { - return; - } - - //急停 - if (this.isStop()) { - - //未在线无心跳 - } else if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 2: - - break; - case 3: - - break; - case 4: - break; - } - } - - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - last_container_type = container_type; - } - - - protected void thingToNothing() throws Exception { - this.setRequireSucess(false); - } - - public void finish_instruction(Instruction instruction) throws Exception { - instruction_finished(instruction); - } - - /** - * 完成指令 - * - * @param instruction - * @return - */ - public boolean instruction_finished(Instruction instruction) throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - instructionService.finish(instruction.getInstruction_id()); - this.instruction_finished_time = date; - return true; - } - } - - /** - * 完成并创建下一条指令 - * - * @param instruction - * @param needCreateNext - * @return - */ - public boolean instruction_finished(Instruction instruction, boolean needCreateNext) { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - this.instruction_finished_time = date; - return true; - } - } - - - private Instruction findInstruction() { - Instruction instruction = null; - if (this.instruction_num != 0) { - instruction = (Instruction) instructionService.findByCodeFromCache(String.valueOf(instruction_num)); - } - if (instruction != null) { - //可进行校验 - - - } else { - List container_instructions = new ArrayList(); - String barcode = this.getLast_container(); - - if (!StrUtil.isEmpty(barcode)) { - Map map = new HashMap(); - map.put("vehicle_code", barcode); - container_instructions = instructionService.queryAll(map); - } - - if (((List) container_instructions).size() > 1) { - log.debug("容器存在多个指令"); - } else { - if (((List) container_instructions).size() > 0) { - instruction = (Instruction) ((List) container_instructions).get(0); - } - } - } - return instruction; - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/ItemProtocol.java deleted file mode 100644 index 887a705..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/ItemProtocol.java +++ /dev/null @@ -1,151 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_mixing_mill; - -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_status = "status"; - public static String item_error = "error"; - public static String item_open_time = "open_time"; - public static String item_standby_time = "standby_time "; - public static String item_production_time = "production_time"; - public static String item_error_time = "error_time"; - public static String item_weight = "weight"; - public static String item_order_No = "order_No"; - public static String item_mix_num = "mix_num"; - public static String item_material = "material"; - public static String item_to_command = "to_command"; - public static String item_to_error = "to_error"; - public static String item_to_task = "to_task"; - public static String item_to_weight = "to_weight"; - public static String item_to_material_code = "to_material_code"; - - - private LnshMixingMillDeviceDriver driver; - - public ItemProtocol(LnshMixingMillDeviceDriver driver) { - this.driver = driver; - } - - public int getMode() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getStatus() { - return this.getOpcIntegerValue(item_status); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getOpen_time() { - return this.getOpcIntegerValue(item_open_time); - } - - public int getWeight() { - return this.getOpcIntegerValue(item_weight); - } - - public int getStandby_time() { - return this.getOpcIntegerValue(item_standby_time); - } - - public int getProduction_time() { - return this.getOpcIntegerValue(item_production_time); - } - - public int getError_time() { - return this.getOpcIntegerValue(item_error_time); - } - - public int getMaterial() { - return this.getOpcIntegerValue(item_material); - } - - public int getOrder_No() { - return this.getOpcIntegerValue(item_order_No); - } - - public int getMix_num() { - return this.getOpcIntegerValue(item_mix_num); - } - - public int getTo_error() { - return this.getOpcIntegerValue(item_to_error); - } - - public int getTo_task() { - return this.getOpcIntegerValue(item_to_task); - } - - public int getTo_command() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getTo_weight() { - return this.getOpcIntegerValue(item_to_weight); - } - - public int getTo_material_code() { - return this.getOpcIntegerValue(item_to_material_code); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true))); - list.add(new ItemDto(item_status, "设备状态", "DB600.B3")); - list.add(new ItemDto(item_error, "故障代码", "DB600.B3")); - list.add(new ItemDto(item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(item_error_time, "故障时间", "DB600.D8")); - list.add(new ItemDto(item_weight, "当前生产重量", "DB600.D8")); - list.add(new ItemDto(item_order_No, "工单号", "DB600.D8"));; - list.add(new ItemDto(item_mix_num, "碾次", "DB600.D8"));; - list.add(new ItemDto(item_material, "当前生产物料", "DB600.D9")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "反馈", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_error, "error", "DB601.W2")); - list.add(new ItemDto(item_to_task, "工单号", "DB601.W2")); - list.add(new ItemDto(item_to_weight, "生产重量", "DB601.W2")); - list.add(new ItemDto(item_to_material_code, "下发物料编号", "DB601.W10")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDefination.java deleted file mode 100644 index e99b3b9..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDefination.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_mixing_mill; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 晟华混碾机 - * - */ -@Service -public class LnshMixingMillDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "lnsh_mixing_mill"; - } - - @Override - public String getDriverName() { - return "晟华-混碾机"; - } - - @Override - public String getDriverDescription() { - return "晟华-混碾机"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new LnshMixingMillDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return LnshMixingMillDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true))); - list.add(new ItemDto(ItemProtocol.item_status, "设备状态", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_error, "故障代码", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(ItemProtocol.item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(ItemProtocol.item_error_time, "故障时间", "DB600.D8")); - list.add(new ItemDto(ItemProtocol.item_weight, "当前生产重量", "DB600.D8")); - list.add(new ItemDto(ItemProtocol.item_order_No, "工单号", "DB600.D8"));; - list.add(new ItemDto(ItemProtocol.item_mix_num, "碾次", "DB600.D8"));; - list.add(new ItemDto(ItemProtocol.item_material, "当前生产物料", "DB600.D9")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDeviceDriver.java deleted file mode 100644 index 33052ce..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_mixing_mill/LnshMixingMillDeviceDriver.java +++ /dev/null @@ -1,323 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_mixing_mill; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -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.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 晟华混碾机 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class LnshMixingMillDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - int mode = 0; - int error = 0; - int last_mode = 0; - int last_error = 0; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - String material; - //批次 - String batch; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - //申请搬运任务 - private Boolean apply_handling = false; - //申请物料 - private Boolean apply_material = false; - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag; - - String devicecode; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - String device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (error != last_error) { - } - - } catch (Exception var17) { - return; - } - - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - return; - case 2: - if (material.length() > 0 && qty.length() > 0 && !requireSucess) { - this.instruction_require(container); - } - } - - switch (flag) { - //取货完成 - case 1: - writing(2); - return; - //放货完成 - case 2: - writing(3); - return; - - } - - } - last_mode = mode; - last_error = error; - - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_material_code = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_material_code; - if (appendMessage == null) { - appendMessage = ""; - } - if (instruction != null) { - instruction_num = Integer.parseInt(instruction.getInstruction_code()); - } - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, 1); - ReadUtil.write(itemMap, server); - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - ReadUtil.write(itemMap, server); - - } - - public void writing(int type, int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_material_code = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_material_code; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - if (type == 1) { - itemMap.put(to_command, command); - } else if (type == 2) { - itemMap.put(to_material_code, command); - - } - ReadUtil.write(itemMap, server); - - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_out_kiln_truss/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_out_kiln_truss/ItemProtocol.java deleted file mode 100644 index 0f8dd14..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_out_kiln_truss/ItemProtocol.java +++ /dev/null @@ -1,129 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_out_kiln_truss; - -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_status = "status"; - public static String item_outKiln_move = "outKiln_move"; - public static String item_outKiln_barcode = "outKiln_barcode"; - public static String item_outKiln_device = "outKiln_device"; - public static String item_open_time = "open_time"; - public static String item_standby_time = "standby_time "; - public static String item_production_time = "production_time"; - public static String item_error_time = "error_time"; - public static String item_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_task = "to_task"; - Boolean isonline; - - private LnshOutKilnTrussDeviceDriver driver; - - public ItemProtocol(LnshOutKilnTrussDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getStatus() { - return this.getOpcIntegerValue(item_status); - } - - public int getOutKiln_move() { - return this.getOpcIntegerValue(item_outKiln_move); - } - - public int getOutKiln_barcode() { - return this.getOpcIntegerValue(item_outKiln_barcode); - } - - public int getOutKiln_device() { - return this.getOpcIntegerValue(item_outKiln_device); - } - - public int getOpen_time() { - return this.getOpcIntegerValue(item_open_time); - } - - public int getStandby_time() { - return this.getOpcIntegerValue(item_standby_time); - } - - public int getProduction_time() { - return this.getOpcIntegerValue(item_production_time); - } - - public int getError_time() { - return this.getOpcIntegerValue(item_error_time); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getToTarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getToTask() { - return this.getOpcIntegerValue(item_to_task); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_status, "设备状态", "DB600.B2")); - list.add(new ItemDto(item_outKiln_move, "出窑光电", "DB600.B2")); - list.add(new ItemDto(item_outKiln_barcode, "出窑条码", "DB600.B2")); - list.add(new ItemDto(item_outKiln_device, "出窑设备", "DB600.B2")); - list.add(new ItemDto(item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(item_error_time, "故障时间", "DB600.D8")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "下发命令反馈", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_target, "下发目标站", "DB601.W4")); - list.add(new ItemDto(item_to_task, "下发任务号", "DB601.D8")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_out_kiln_truss/LnshOutKilnTrussDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_out_kiln_truss/LnshOutKilnTrussDefination.java deleted file mode 100644 index 0ac8356..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_out_kiln_truss/LnshOutKilnTrussDefination.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_out_kiln_truss; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 晟华出窑桁架 - */ -@Service -public class LnshOutKilnTrussDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "lnsh_out_kiln_truss"; - } - - @Override - public String getDriverName() { - return "晟华-出窑桁架"; - } - - @Override - public String getDriverDescription() { - return "晟华-出窑桁架"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new LnshOutKilnTrussDeviceDriver()).setDevice(device).setDriverDefination(this); - } - - @Override - public Class getDeviceDriverType() { - return LnshOutKilnTrussDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(ItemProtocol.item_status, "设备状态", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_outKiln_move, "出窑光电", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_outKiln_barcode, "出窑条码", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_outKiln_device, "出窑设备", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(ItemProtocol.item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(ItemProtocol.item_error_time, "故障时间", "DB600.D8")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_out_kiln_truss/LnshOutKilnTrussDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_out_kiln_truss/LnshOutKilnTrussDeviceDriver.java deleted file mode 100644 index 8a9c7fc..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_out_kiln_truss/LnshOutKilnTrussDeviceDriver.java +++ /dev/null @@ -1,346 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_out_kiln_truss; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -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.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 晟华出窑桁架 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class LnshOutKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - - - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - - String device_code; - int mode = 0; - int error = 0; - int move = 0; - int action; - int io_action; - int task = 0; - int container_type = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - int last_container_type; - Boolean isonline = true; - int hasGoods = 0; - Boolean iserror = false; - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - private Boolean sampleMode0; - private Boolean sampleMode3; - private Integer sampleError; - private Boolean sampleOnline; - protected String displayMessage = null; - public int display_message_time_out = 30000; - public Date display_message_time; - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out = 3000; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int heartbeat; - int last_heartbeat; - private Date checkHeartbeattime = new Date(); - private Date last_checkHeartbeattime = new Date(); - - int branchProtocol = 0; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - String message; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - device_code = this.getDeviceCode(); - - mode = this.itemProtocol.getMode(); - - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (move != last_move) { - thingToNothing(); - } - if (error != last_error) { - } - if (container_type != last_container_type) { - } - - } catch (Exception var17) { - return; - } - - //急停 - if (this.isStop()) { - - //未在线无心跳 - } else if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 2: - - break; - case 3: - - break; - case 4: - break; - } - } - - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - last_container_type = container_type; - } - - - protected void thingToNothing() throws Exception { - this.setRequireSucess(false); - } - - public void finish_instruction(Instruction instruction) throws Exception { - instruction_finished(instruction); - } - - /** - * 完成指令 - * - * @param instruction - * @return - */ - public boolean instruction_finished(Instruction instruction) throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - instructionService.finish(instruction.getInstruction_id()); - this.instruction_finished_time = date; - return true; - } - } - - /** - * 完成并创建下一条指令 - * - * @param instruction - * @param needCreateNext - * @return - */ - public boolean instruction_finished(Instruction instruction, boolean needCreateNext) { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - this.instruction_finished_time = date; - return true; - } - } - - - private Instruction findInstruction() { - Instruction instruction = null; - if (this.instruction_num != 0) { - instruction = (Instruction) instructionService.findByCodeFromCache(String.valueOf(instruction_num)); - } - if (instruction != null) { - //可进行校验 - - - } else { - List container_instructions = new ArrayList(); - String barcode = this.getLast_container(); - - if (!StrUtil.isEmpty(barcode)) { - Map map = new HashMap(); - map.put("vehicle_code", barcode); - container_instructions = instructionService.queryAll(map); - } - - if (((List) container_instructions).size() > 1) { - log.debug("容器存在多个指令"); - } else { - if (((List) container_instructions).size() > 0) { - instruction = (Instruction) ((List) container_instructions).get(0); - } - } - } - return instruction; - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_line/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_line/ItemProtocol.java deleted file mode 100644 index 882a915..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_line/ItemProtocol.java +++ /dev/null @@ -1,129 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_package_line; - -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_status = "status"; - public static String item_open_time = "open_time"; - public static String item_standby_time = "standby_time "; - public static String item_production_time = "production_time"; - public static String item_error_time = "error_time"; - public static String item_barcode = "barcode"; - public static String item_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_task = "to_task"; - public static String item_to_code_message = "to_code_message"; - public static String item_to_isPackage = "to_isPackage"; - Boolean isonline; - - private LnshPackageLineDeviceDriver driver; - - public ItemProtocol(LnshPackageLineDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getStatus() { - return this.getOpcIntegerValue(item_status); - } - - public int getOpen_time() { - return this.getOpcIntegerValue(item_open_time); - } - - public int getStandby_time() { - return this.getOpcIntegerValue(item_standby_time); - } - - public int getProduction_time() { - return this.getOpcIntegerValue(item_production_time); - } - - public int getError_time() { - return this.getOpcIntegerValue(item_error_time); - } - - public int getBarcode() { - return this.getOpcIntegerValue(item_barcode); - } - - public int getTo_command() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getTo_target() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getTo_task() { - return this.getOpcIntegerValue(item_to_task); - } - - public int getTo_code_message() { - return this.getOpcIntegerValue(item_to_code_message); - } - - public int getTo_isPackage() { - return this.getOpcIntegerValue(item_to_isPackage); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_status, "设备状态", "DB600.B2")); - list.add(new ItemDto(item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(item_error_time, "故障时间", "DB600.D8")); - list.add(new ItemDto(item_barcode, "条码", "DB600.D8")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "下发命令", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_target, "下发目标站", "DB601.W4")); - list.add(new ItemDto(item_to_task, "下发任务号", "DB601.D8")); - list.add(new ItemDto(item_to_code_message, "打码信息", "DB601.D8")); - list.add(new ItemDto(item_to_isPackage, "是否包装", "DB601.D8")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_line/LnshPackageLineDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_line/LnshPackageLineDefination.java deleted file mode 100644 index ac7ba54..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_line/LnshPackageLineDefination.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_package_line; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 晟华包装线 - */ -@Service -public class LnshPackageLineDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "lnsh_package_line"; - } - - @Override - public String getDriverName() { - return "晟华-包装线"; - } - - @Override - public String getDriverDescription() { - return "晟华-包装线"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new LnshPackageLineDeviceDriver()).setDevice(device).setDriverDefination(this); - } - - @Override - public Class getDeviceDriverType() { - return LnshPackageLineDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(ItemProtocol.item_status, "设备状态", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(ItemProtocol.item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(ItemProtocol.item_error_time, "故障时间", "DB600.D8")); - list.add(new ItemDto(ItemProtocol.item_barcode, "条码", "DB600.D8")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_line/LnshPackageLineDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_line/LnshPackageLineDeviceDriver.java deleted file mode 100644 index 62ec7e6..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_line/LnshPackageLineDeviceDriver.java +++ /dev/null @@ -1,346 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_package_line; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -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.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 晟华包装线 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class LnshPackageLineDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - - - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - - String device_code; - int mode = 0; - int error = 0; - int move = 0; - int action; - int io_action; - int task = 0; - int container_type = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - int last_container_type; - Boolean isonline = true; - int hasGoods = 0; - Boolean iserror = false; - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - private Boolean sampleMode0; - private Boolean sampleMode3; - private Integer sampleError; - private Boolean sampleOnline; - protected String displayMessage = null; - public int display_message_time_out = 30000; - public Date display_message_time; - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out = 3000; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int heartbeat; - int last_heartbeat; - private Date checkHeartbeattime = new Date(); - private Date last_checkHeartbeattime = new Date(); - - int branchProtocol = 0; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - String message; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - device_code = this.getDeviceCode(); - - mode = this.itemProtocol.getMode(); - - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (move != last_move) { - thingToNothing(); - } - if (error != last_error) { - } - if (container_type != last_container_type) { - } - - } catch (Exception var17) { - return; - } - - //急停 - if (this.isStop()) { - - //未在线无心跳 - } else if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 2: - - break; - case 3: - - break; - case 4: - break; - } - } - - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - last_container_type = container_type; - } - - - protected void thingToNothing() throws Exception { - this.setRequireSucess(false); - } - - public void finish_instruction(Instruction instruction) throws Exception { - instruction_finished(instruction); - } - - /** - * 完成指令 - * - * @param instruction - * @return - */ - public boolean instruction_finished(Instruction instruction) throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - instructionService.finish(instruction.getInstruction_id()); - this.instruction_finished_time = date; - return true; - } - } - - /** - * 完成并创建下一条指令 - * - * @param instruction - * @param needCreateNext - * @return - */ - public boolean instruction_finished(Instruction instruction, boolean needCreateNext) { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - this.instruction_finished_time = date; - return true; - } - } - - - private Instruction findInstruction() { - Instruction instruction = null; - if (this.instruction_num != 0) { - instruction = (Instruction) instructionService.findByCodeFromCache(String.valueOf(instruction_num)); - } - if (instruction != null) { - //可进行校验 - - - } else { - List container_instructions = new ArrayList(); - String barcode = this.getLast_container(); - - if (!StrUtil.isEmpty(barcode)) { - Map map = new HashMap(); - map.put("vehicle_code", barcode); - container_instructions = instructionService.queryAll(map); - } - - if (((List) container_instructions).size() > 1) { - log.debug("容器存在多个指令"); - } else { - if (((List) container_instructions).size() > 0) { - instruction = (Instruction) ((List) container_instructions).get(0); - } - } - } - return instruction; - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/ItemProtocol.java deleted file mode 100644 index cfb0c87..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/ItemProtocol.java +++ /dev/null @@ -1,179 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_package_pallet_manipulator; - -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_status = "status"; - public static String item_error = "error"; - public static String item_putStation = "putStation"; - public static String item_barcode = "barcode"; - public static String item_material = "material"; - public static String item_qty = "qty"; - public static String item_open_time = "open_time"; - public static String item_standby_time = "standby_time "; - public static String item_production_time = "production_time"; - public static String item_error_time = "error_time"; - public static String item_order_No = "order_No"; - public static String item_to_heartbeat = "to_heartbeat"; - public static String item_to_feedback = "to_feedback"; - public static String item_to_error = "to_error"; - public static String item_to_material_qty = "to_material_qty"; - public static String item_to_allow_pallet_qty = "to_allow_pallet_qty"; - public static String item_to_material_type = "to_material_type"; - public static String item_to_material_code = "to_material_code"; - public static String item_to_order_No = "to_order_No"; - - - private LnshPackagePalletManipulatorDeviceDriver driver; - - public ItemProtocol(LnshPackagePalletManipulatorDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getStatus() { - return this.getOpcIntegerValue(item_status); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getPutStation() { - return this.getOpcIntegerValue(item_putStation); - } - - public int getBarcode() { - return this.getOpcIntegerValue(item_barcode); - } - - public int getMaterial() { - return this.getOpcIntegerValue(item_material); - } - - public int getQty() { - return this.getOpcIntegerValue(item_qty); - } - - public int getOpen_time() { - return this.getOpcIntegerValue(item_open_time); - } - - public int getStandby_time() { - return this.getOpcIntegerValue(item_standby_time); - } - - public int getProduction_time() { - return this.getOpcIntegerValue(item_production_time); - } - - public int getError_time() { - return this.getOpcIntegerValue(item_error_time); - } - - public int getOrder_No() { - return this.getOpcIntegerValue(item_order_No); - } - - public int getTo_heartbeat() { - return this.getOpcIntegerValue(item_to_heartbeat); - } - - public int getTo_feedback() { - return this.getOpcIntegerValue(item_to_feedback); - } - - public int getTo_error() { - return this.getOpcIntegerValue(item_to_error); - } - - public int getTo_material_qty() { - return this.getOpcIntegerValue(item_to_material_qty); - } - - public int getTo_allow_pallet_qty() { - return this.getOpcIntegerValue(item_to_allow_pallet_qty); - } - - public int getTo_material_type() { - return this.getOpcIntegerValue(item_to_material_type); - } - - public int getTo_material_code() { - return this.getOpcIntegerValue(item_to_material_code); - } - - public int getTo_order_No() { - return this.getOpcIntegerValue(item_to_order_No); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true))); - list.add(new ItemDto(item_status, "设备状态", "DB600.B3")); - list.add(new ItemDto(item_error, "故障代码", "DB600.B3")); - list.add(new ItemDto(item_putStation, "当前码盘工位", "DB600.B3")); - list.add(new ItemDto(item_barcode, "当前码盘工位条码", "DB600.B3")); - list.add(new ItemDto(item_material, "码盘工位当前物料", "DB600.B3")); - list.add(new ItemDto(item_qty, "数量", "DB600.B3")); - list.add(new ItemDto(item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(item_error_time, "故障时间", "DB600.D8")); - list.add(new ItemDto(item_order_No, "工单号", "DB600.D9")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_heartbeat, "心跳", "DB601.W0")); - list.add(new ItemDto(item_to_feedback, "机器人动作反馈", "DB601.W0")); - list.add(new ItemDto(item_to_error, "故障代码", "DB601.W0")); - list.add(new ItemDto(item_to_material_qty, "托盘上数量", "DB601.W0")); - list.add(new ItemDto(item_to_allow_pallet_qty, "允许码垛数量", "DB601.W0")); - list.add(new ItemDto(item_to_material_type, "托盘类型", "DB601.W0")); - list.add(new ItemDto(item_to_material_code, "下发物料编号", "DB601.W10")); - list.add(new ItemDto(item_to_order_No, "工单号", "DB601.W10")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDefination.java deleted file mode 100644 index 1840b0a..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDefination.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_package_pallet_manipulator; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 晟华包装码垛机械手 - * - */ -@Service -public class LnshPackagePalletManipulatorDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "lnsh_package_pallet_manipulator"; - } - - @Override - public String getDriverName() { - return "晟华-包装码垛机械手"; - } - - @Override - public String getDriverDescription() { - return "晟华-包装码垛机械手"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new LnshPackagePalletManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return LnshPackagePalletManipulatorDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true))); - list.add(new ItemDto(ItemProtocol.item_status, "设备状态", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_error, "故障代码", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_putStation, "当前码盘工位", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_barcode, "当前码盘工位条码", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_material, "码盘工位当前物料", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_qty, "数量", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(ItemProtocol.item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(ItemProtocol.item_error_time, "故障时间", "DB600.D8")); - list.add(new ItemDto(ItemProtocol.item_order_No, "工单号", "DB600.D9")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java deleted file mode 100644 index 2b387fb..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_package_pallet_manipulator/LnshPackagePalletManipulatorDeviceDriver.java +++ /dev/null @@ -1,267 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_package_pallet_manipulator; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -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.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -/** - * 晟华干燥窑 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - int mode = 0; - int error = 0; - int last_mode = 0; - int last_error = 0; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - String material; - //批次 - String batch; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - //申请搬运任务 - private Boolean apply_handling = false; - //申请物料 - private Boolean apply_material = false; - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag; - - String devicecode; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - String device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (error != last_error) { - } - - } catch (Exception var17) { - return; - } - - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - return; - case 2: - if (material.length() > 0 && qty.length() > 0 && !requireSucess) { - this.instruction_require(container); - } - } - - switch (flag) { - //取货完成 - case 1: - return; - //放货完成 - case 2: - return; - - } - - } - last_mode = mode; - last_error = error; - - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_pallet_storage/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_pallet_storage/ItemProtocol.java deleted file mode 100644 index b14c111..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_pallet_storage/ItemProtocol.java +++ /dev/null @@ -1,129 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_pallet_storage; - -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_status = "status"; - public static String item_open_time = "open_time"; - public static String item_close_time = "close_time"; - public static String item_standby_time = "standby_time "; - public static String item_production_time = "production_time"; - public static String item_error_time = "error_time"; - public static String item_tray_crib_qty = "tray_crib_qty"; - public static String item_total_container = "total_container"; - public static String item_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_task = "to_task"; - Boolean isonline; - - private LnshPalletStorageDeviceDriver driver; - - public ItemProtocol(LnshPalletStorageDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getStatus() { - return this.getOpcIntegerValue(item_status); - } - - public int getOpen_time() { - return this.getOpcIntegerValue(item_open_time); - } - - public int getClose_time() { - return this.getOpcIntegerValue(item_close_time); - } - - public int getStandby_time() { - return this.getOpcIntegerValue(item_standby_time); - } - - public int getProduction_time() { - return this.getOpcIntegerValue(item_production_time); - } - - public int getError_time() { - return this.getOpcIntegerValue(item_error_time); - } - - public int getTray_crib_qty() { - return this.getOpcIntegerValue(item_tray_crib_qty); - } - - public int getTotal_container() { - return this.getOpcIntegerValue(item_total_container); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getToTarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getToTask() { - return this.getOpcIntegerValue(item_to_task); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_status, "设备状态", "DB600.B2")); - list.add(new ItemDto(item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(item_close_time, "关机时间", "DB600.D5")); - list.add(new ItemDto(item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(item_error_time, "故障时间", "DB600.D8")); - list.add(new ItemDto(item_tray_crib_qty, "托盘垛数", "DB600.D8")); - list.add(new ItemDto(item_total_container, "托盘总数量", "DB600.D8")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "下发命令", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_target, "下发目标站", "DB601.W4")); - list.add(new ItemDto(item_to_task, "下发任务号", "DB601.D8")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_pallet_storage/LnshPalletStorageDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_pallet_storage/LnshPalletStorageDefination.java deleted file mode 100644 index 549b42c..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_pallet_storage/LnshPalletStorageDefination.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_pallet_storage; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 晟华托盘存储线 - */ -@Service -public class LnshPalletStorageDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "lnsh_pallet_storage"; - } - - @Override - public String getDriverName() { - return "晟华-托盘存储线"; - } - - @Override - public String getDriverDescription() { - return "晟华-托盘存储线"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new LnshPalletStorageDeviceDriver()).setDevice(device).setDriverDefination(this); - } - - @Override - public Class getDeviceDriverType() { - return LnshPalletStorageDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(ItemProtocol.item_status, "设备状态", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_close_time, "关机时间", "DB600.D5")); - list.add(new ItemDto(ItemProtocol.item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(ItemProtocol.item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(ItemProtocol.item_error_time, "故障时间", "DB600.D8")); - list.add(new ItemDto(ItemProtocol.item_tray_crib_qty, "托盘垛数", "DB600.D8")); - list.add(new ItemDto(ItemProtocol.item_total_container, "托盘总数量", "DB600.D8")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_pallet_storage/LnshPalletStorageDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_pallet_storage/LnshPalletStorageDeviceDriver.java deleted file mode 100644 index 0d888fd..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_pallet_storage/LnshPalletStorageDeviceDriver.java +++ /dev/null @@ -1,346 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_pallet_storage; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -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.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 晟华托盘存储线 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class LnshPalletStorageDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - - - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - - String device_code; - int mode = 0; - int error = 0; - int move = 0; - int action; - int io_action; - int task = 0; - int container_type = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - int last_container_type; - Boolean isonline = true; - int hasGoods = 0; - Boolean iserror = false; - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - private Boolean sampleMode0; - private Boolean sampleMode3; - private Integer sampleError; - private Boolean sampleOnline; - protected String displayMessage = null; - public int display_message_time_out = 30000; - public Date display_message_time; - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out = 3000; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int heartbeat; - int last_heartbeat; - private Date checkHeartbeattime = new Date(); - private Date last_checkHeartbeattime = new Date(); - - int branchProtocol = 0; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - String message; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - device_code = this.getDeviceCode(); - - mode = this.itemProtocol.getMode(); - - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (move != last_move) { - thingToNothing(); - } - if (error != last_error) { - } - if (container_type != last_container_type) { - } - - } catch (Exception var17) { - return; - } - - //急停 - if (this.isStop()) { - - //未在线无心跳 - } else if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 2: - - break; - case 3: - - break; - case 4: - break; - } - } - - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - last_container_type = container_type; - } - - - protected void thingToNothing() throws Exception { - this.setRequireSucess(false); - } - - public void finish_instruction(Instruction instruction) throws Exception { - instruction_finished(instruction); - } - - /** - * 完成指令 - * - * @param instruction - * @return - */ - public boolean instruction_finished(Instruction instruction) throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - instructionService.finish(instruction.getInstruction_id()); - this.instruction_finished_time = date; - return true; - } - } - - /** - * 完成并创建下一条指令 - * - * @param instruction - * @param needCreateNext - * @return - */ - public boolean instruction_finished(Instruction instruction, boolean needCreateNext) { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - this.instruction_finished_time = date; - return true; - } - } - - - private Instruction findInstruction() { - Instruction instruction = null; - if (this.instruction_num != 0) { - instruction = (Instruction) instructionService.findByCodeFromCache(String.valueOf(instruction_num)); - } - if (instruction != null) { - //可进行校验 - - - } else { - List container_instructions = new ArrayList(); - String barcode = this.getLast_container(); - - if (!StrUtil.isEmpty(barcode)) { - Map map = new HashMap(); - map.put("vehicle_code", barcode); - container_instructions = instructionService.queryAll(map); - } - - if (((List) container_instructions).size() > 1) { - log.debug("容器存在多个指令"); - } else { - if (((List) container_instructions).size() > 0) { - instruction = (Instruction) ((List) container_instructions).get(0); - } - } - } - return instruction; - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator/ItemProtocol.java deleted file mode 100644 index 5ed418c..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator/ItemProtocol.java +++ /dev/null @@ -1,162 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_palletizing_manipulator; - -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_status = "status"; - public static String item_action = "action"; - public static String item_error = "error"; - public static String item_put_station = "put_station"; - public static String item_barcode = "barcode"; - public static String item_material = "material"; - public static String item_encoder_qty = "encoder_qty"; - public static String item_open_time = "open_time"; - public static String item_standby_time = "standby_time "; - public static String item_production_time = "production_time"; - public static String item_error_time = "error_time"; - public static String item_to_heartbeat = "to_heartbeat"; - public static String item_to_feedback = "to_feedback"; - public static String item_to_error = "to_error"; - public static String item_to_materialQty = "to_materialQty"; - public static String item_to_material_type = "to_material_type"; - public static String item_to_material_code = "to_material_code"; - - - private LnshPalletizingManipulatorDeviceDriver driver; - - public ItemProtocol(LnshPalletizingManipulatorDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getStatus() { - return this.getOpcIntegerValue(item_status); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getPut_station() { - return this.getOpcIntegerValue(item_put_station); - } - - public int getBarcode() { - return this.getOpcIntegerValue(item_barcode); - } - - public int getMaterial() { - return this.getOpcIntegerValue(item_material); - } - - public int getEncoder_qty() { - return this.getOpcIntegerValue(item_encoder_qty); - } - - public int getOpen_time() { - return this.getOpcIntegerValue(item_open_time); - } - - public int getStandby_time() { - return this.getOpcIntegerValue(item_standby_time); - } - - public int getProduction_time() { - return this.getOpcIntegerValue(item_production_time); - } - - public int getError_time() { - return this.getOpcIntegerValue(item_error_time); - } - - public int getTo_heartbeat() { - return this.getOpcIntegerValue(item_to_heartbeat); - } - - public int getTo_feedback() { - return this.getOpcIntegerValue(item_to_feedback); - } - - public int getTo_error() { - return this.getOpcIntegerValue(item_to_error); - } - - public int getTo_materialQty() { - return this.getOpcIntegerValue(item_to_materialQty); - } - - public int getTo_material_type() { - return this.getOpcIntegerValue(item_to_material_type); - } - - public int getTo_material_code() { - return this.getOpcIntegerValue(item_to_material_code); - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true))); - list.add(new ItemDto(item_status, "设备状态", "DB600.B3")); - list.add(new ItemDto(item_action, "动作", "DB600.B3")); - list.add(new ItemDto(item_error, "故障代码", "DB600.B3")); - list.add(new ItemDto(item_put_station, "当前码盘工位", "DB600.B3")); - list.add(new ItemDto(item_barcode, "当前码盘工位条码", "DB600.B3")); - list.add(new ItemDto(item_material, "码盘工位当前物料", "DB600.B3")); - list.add(new ItemDto(item_encoder_qty, "码盘位当前码盘数量", "DB600.B3")); - list.add(new ItemDto(item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(item_error_time, "故障时间", "DB600.D8")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_heartbeat, "心跳", "DB601.W2")); - list.add(new ItemDto(item_to_feedback, "机器人动作反馈", "DB601.W2")); - list.add(new ItemDto(item_to_error, "故障代码", "DB601.W2")); - list.add(new ItemDto(item_to_materialQty, "托盘砖数量", "DB601.W2")); - list.add(new ItemDto(item_to_material_type, "箱型", "DB601.W2")); - list.add(new ItemDto(item_to_material_code, "下发物料编号", "DB601.W10")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator/LnshPalletizingManipulatorDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator/LnshPalletizingManipulatorDefination.java deleted file mode 100644 index d44f6d0..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator/LnshPalletizingManipulatorDefination.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_palletizing_manipulator; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 晟华码垛机械手 - * - */ -@Service -public class LnshPalletizingManipulatorDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "lnsh_palletizing_manipulator"; - } - - @Override - public String getDriverName() { - return "晟华-码垛机械手"; - } - - @Override - public String getDriverDescription() { - return "晟华-码垛机械手"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new LnshPalletizingManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return LnshPalletizingManipulatorDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true))); - list.add(new ItemDto(ItemProtocol.item_status, "设备状态", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_action, "动作", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_error, "故障代码", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_put_station, "当前码盘工位", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_barcode, "当前码盘工位条码", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_material, "码盘工位当前物料", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_encoder_qty, "码盘位当前码盘数量", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(ItemProtocol.item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(ItemProtocol.item_error_time, "故障时间", "DB600.D8")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator/LnshPalletizingManipulatorDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator/LnshPalletizingManipulatorDeviceDriver.java deleted file mode 100644 index d0ffc16..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_palletizing_manipulator/LnshPalletizingManipulatorDeviceDriver.java +++ /dev/null @@ -1,313 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_palletizing_manipulator; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -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.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 晟华码垛机械手 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class LnshPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - int mode = 0; - int error = 0; - int last_mode = 0; - int last_error = 0; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - String material; - //批次 - String batch; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - //申请搬运任务 - private Boolean apply_handling = false; - //申请物料 - private Boolean apply_material = false; - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag; - - String devicecode; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - String device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (error != last_error) { - } - - } catch (Exception var17) { - return; - } - - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - return; - case 2: - if (material.length() > 0 && qty.length() > 0 && !requireSucess) { - this.instruction_require(container); - } - } - - switch (flag) { - //取货完成 - case 1: - writing(2); - return; - //放货完成 - case 2: - writing(3); - return; - - } - - } - last_mode = mode; - last_error = error; - - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - String to_material_code = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_material_code; - if (appendMessage == null) { - appendMessage = ""; - } - if (instruction != null) { - instruction_num = Integer.parseInt(instruction.getInstruction_code()); - } - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - ReadUtil.write(itemMap, server); - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - ReadUtil.write(itemMap, server); - - } - - public void writing(int type, int command) { - String to_material_code = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_material_code; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - if (type == 2) { - itemMap.put(to_material_code, command); - - } - ReadUtil.write(itemMap, server); - - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_press/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_press/ItemProtocol.java deleted file mode 100644 index 31d244f..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_press/ItemProtocol.java +++ /dev/null @@ -1,167 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_press; - -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_status = "status"; - public static String item_error = "error"; - public static String item_open_time = "open_time"; - public static String item_standby_time = "standby_time "; - public static String item_production_time = "production_time"; - public static String item_error_time = "error_time"; - public static String item_material = "material"; - public static String item_qty = "qty"; - public static String item_weight = "weight"; - public static String item_qualified = "qualified"; - public static String item_unqualified = "unqualified"; - public static String item_order_No = "order_No"; - public static String item_to_command = "to_command"; - public static String item_to_error = "to_error"; - public static String item_to_order_No = "to_order_No"; - public static String item_to_qty = "to_qty"; - public static String item_to_material_code = "to_material_code"; - - - private LnshPressDeviceDriver driver; - - public ItemProtocol(LnshPressDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getStatus() { - return this.getOpcIntegerValue(item_status); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getOpen_time() { - return this.getOpcIntegerValue(item_open_time); - } - - public int getStandby_time() { - return this.getOpcIntegerValue(item_standby_time); - } - - public int getProduction_time() { - return this.getOpcIntegerValue(item_production_time); - } - - public int getError_time() { - return this.getOpcIntegerValue(item_error_time); - } - - public int getMaterial() { - return this.getOpcIntegerValue(item_material); - } - - public int getQty() { - return this.getOpcIntegerValue(item_qty); - } - - public int getWeight() { - return this.getOpcIntegerValue(item_weight); - } - - public int getQualified() { - return this.getOpcIntegerValue(item_qualified); - } - - public int getUnqualified() { - return this.getOpcIntegerValue(item_unqualified); - } - - public int getOrder_No() { - return this.getOpcIntegerValue(item_order_No); - } - - public int getTo_command() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getTo_error() { - return this.getOpcIntegerValue(item_to_error); - } - - public int getTo_order_No() { - return this.getOpcIntegerValue(item_to_order_No); - } - - public int getTo_qty() { - return this.getOpcIntegerValue(item_to_qty); - } - - public int getTo_material_code() { - return this.getOpcIntegerValue(item_to_material_code); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true))); - list.add(new ItemDto(item_status, "设备状态", "DB600.B3")); - list.add(new ItemDto(item_error, "故障", "DB600.B3")); - list.add(new ItemDto(item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(item_error_time, "故障时间", "DB600.D8")); - list.add(new ItemDto(item_material, "当前生产物料", "DB600.D9")); - list.add(new ItemDto(item_qty, "当前已生产数量", "DB600.D10")); - list.add(new ItemDto(item_weight, "当前已生产重量", "DB600.D10")); - list.add(new ItemDto(item_qualified, "当前已生产合格数", "DB600.D11")); - list.add(new ItemDto(item_unqualified, "当前已生产不合格数", "DB600.D12")); - list.add(new ItemDto(item_order_No, "工单号", "DB600.D13")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "反馈", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_error, "error", "DB601.W2")); - list.add(new ItemDto(item_to_order_No, "工单号", "DB601.W2")); - list.add(new ItemDto(item_to_qty, "生产重量", "DB601.W2")); - list.add(new ItemDto(item_to_material_code, "下发物料编号", "DB601.W10")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_press/LnshPressDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_press/LnshPressDefination.java deleted file mode 100644 index 0ca16f6..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_press/LnshPressDefination.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_press; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 晟华压力机 - * - */ -@Service -public class LnshPressDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "lnsh_press"; - } - - @Override - public String getDriverName() { - return "晟华-压力机"; - } - - @Override - public String getDriverDescription() { - return "晟华-压力机"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new LnshPressDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return LnshPressDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true))); - list.add(new ItemDto(ItemProtocol.item_status, "设备状态", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_error, "故障", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(ItemProtocol.item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(ItemProtocol.item_error_time, "故障时间", "DB600.D8")); - list.add(new ItemDto(ItemProtocol.item_material, "当前生产物料", "DB600.D9")); - list.add(new ItemDto(ItemProtocol.item_qty, "当前已生产数量", "DB600.D10")); - list.add(new ItemDto(ItemProtocol.item_weight, "当前已生产重量", "DB600.D10")); - list.add(new ItemDto(ItemProtocol.item_qualified, "当前已生产合格数", "DB600.D11")); - list.add(new ItemDto(ItemProtocol.item_unqualified, "当前已生产不合格数", "DB600.D12")); - list.add(new ItemDto(ItemProtocol.item_order_No, "工单号", "DB600.D13")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_press/LnshPressDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_press/LnshPressDeviceDriver.java deleted file mode 100644 index 12dd35e..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_press/LnshPressDeviceDriver.java +++ /dev/null @@ -1,313 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_press; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -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.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 晟华压力机 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class LnshPressDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - int mode = 0; - int error = 0; - int last_mode = 0; - int last_error = 0; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - String material; - //批次 - String batch; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - //申请搬运任务 - private Boolean apply_handling = false; - //申请物料 - private Boolean apply_material = false; - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag; - - String devicecode; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - String device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (error != last_error) { - } - - } catch (Exception var17) { - return; - } - - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - return; - case 2: - if (material.length() > 0 && qty.length() > 0 && !requireSucess) { - this.instruction_require(container); - } - } - - switch (flag) { - //取货完成 - case 1: - writing(2); - return; - //放货完成 - case 2: - writing(3); - return; - - } - - } - last_mode = mode; - last_error = error; - - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - String to_material_code = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_material_code; - if (appendMessage == null) { - appendMessage = ""; - } - if (instruction != null) { - instruction_num = Integer.parseInt(instruction.getInstruction_code()); - } - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - ReadUtil.write(itemMap, server); - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - ReadUtil.write(itemMap, server); - - } - - public void writing(int type, int command) { - String to_material_code = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_material_code; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - if (type == 2) { - itemMap.put(to_material_code, command); - - } - ReadUtil.write(itemMap, server); - - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/ItemProtocol.java deleted file mode 100644 index 8743d75..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/ItemProtocol.java +++ /dev/null @@ -1,178 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_rgv; - -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_status = "status"; - public static String item_move_1 = "move_1"; - public static String item_move_2 = "move_2"; - public static String item_action_1 = "action_1"; - public static String item_action_2 = "action_2"; - public static String item_walk_y = "walk_y"; - public static String item_error = "error"; - public static String item_task1 = "task1"; - public static String item_task2 = "task2"; - public static String item_open_time = "open_time"; - public static String item_standby_time = "standby_time "; - public static String item_production_time = "production_time"; - public static String item_error_time = "error_time"; - public static String item_to_command = "to_command"; - public static String item_to_onset1 = "to_onset1"; - public static String item_to_target1 = "to_target1"; - public static String item_to_task = "to_task"; - public static String item_to_onset2 = "to_onset2"; - public static String item_to_target2 = "to_target2"; - - private LnshRGVDeviceDriver driver; - - public ItemProtocol(LnshRGVDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getStatus() { - return this.getOpcIntegerValue(item_status); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getOpen_time() { - return this.getOpcIntegerValue(item_open_time); - } - - public int getStandby_time() { - return this.getOpcIntegerValue(item_standby_time); - } - - public int getProduction_time() { - return this.getOpcIntegerValue(item_production_time); - } - - public int getError_time() { - return this.getOpcIntegerValue(item_error_time); - } - - public int getMove_1() { - return this.getOpcIntegerValue(item_move_1); - } - - public int getMove_2() { - return this.getOpcIntegerValue(item_move_2); - } - - public int getAction_1() { - return this.getOpcIntegerValue(item_action_1); - } - - public int getAction_2() { - return this.getOpcIntegerValue(item_action_2); - } - - public int getWalk_y() { - return this.getOpcIntegerValue(item_walk_y); - } - - public int getTask1() { - return this.getOpcIntegerValue(item_task1); - } - - public int getTask2() { - return this.getOpcIntegerValue(item_task2); - } - - public int getTo_command() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getTo_onset1() { - return this.getOpcIntegerValue(item_to_onset1); - } - - public int getTo_onset2() { - return this.getOpcIntegerValue(item_to_onset2); - } - - public int getTo_target1() { - return this.getOpcIntegerValue(item_to_target1); - } - - public int getTo_target2() { - return this.getOpcIntegerValue(item_to_target2); - } - - public int getTo_task() { - return this.getOpcIntegerValue(item_to_task); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true))); - list.add(new ItemDto(item_status, "设备状态", "DB600.B3")); - list.add(new ItemDto(item_move_1, "前工位光电信号", "DB600.B3")); - list.add(new ItemDto(item_move_2, "后工位光电信号", "DB600.B3")); - list.add(new ItemDto(item_action_1, "前工位动作信号", "DB600.B3")); - list.add(new ItemDto(item_action_2, "后工位动作信号", "DB600.B3")); - list.add(new ItemDto(item_walk_y, "行走列", "DB600.B3")); - list.add(new ItemDto(item_error, "车体报警", "DB600.B3")); - list.add(new ItemDto(item_task1, "前工位任务号", "DB600.B3")); - list.add(new ItemDto(item_task2, "后工位任务号", "DB600.B3")); - list.add(new ItemDto(item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(item_error_time, "故障时间", "DB600.D8")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "下发命令", "DB601.W02")); - list.add(new ItemDto(item_to_onset1, "下发起始站", "DB601.W4")); - list.add(new ItemDto(item_to_target1, "下发目标站", "DB601.W6")); - list.add(new ItemDto(item_to_task, "下发任务号", "DB601.W10")); - list.add(new ItemDto(item_to_onset2, "下发起始站", "DB601.W10")); - list.add(new ItemDto(item_to_target2, "下发目标站", "DB601.W10")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDefination.java deleted file mode 100644 index 35b9731..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDefination.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_rgv; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 晟华RGV - * - */ -@Service -public class LnshRGVDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "lnsh_rgv"; - } - - @Override - public String getDriverName() { - return "晟华-RGV"; - } - - @Override - public String getDriverDescription() { - return "晟华-RGV"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new LnshRGVDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return LnshRGVDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true))); - list.add(new ItemDto(ItemProtocol.item_status, "设备状态", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_move_1, "前工位光电信号", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_move_2, "后工位光电信号", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_action_1, "前工位动作信号", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_action_2, "后工位动作信号", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_walk_y, "行走列", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_error, "车体报警", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_task1, "前工位任务号", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_task2, "后工位任务号", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(ItemProtocol.item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(ItemProtocol.item_error_time, "故障时间", "DB600.D8")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java deleted file mode 100644 index d24c366..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_rgv/LnshRGVDeviceDriver.java +++ /dev/null @@ -1,305 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_rgv; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -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.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 晟华RGV - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - int mode = 0; - int error = 0; - int last_mode = 0; - int last_error = 0; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - String material; - //批次 - String batch; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - //申请搬运任务 - private Boolean apply_handling = false; - //申请物料 - private Boolean apply_material = false; - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag; - - String devicecode; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - String device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (error != last_error) { - } - - } catch (Exception var17) { - return; - } - - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - return; - case 2: - if (material.length() > 0 && qty.length() > 0 && !requireSucess) { - this.instruction_require(container); - } - } - - switch (flag) { - //取货完成 - case 1: - writing(2); - return; - //放货完成 - case 2: - writing(3); - return; - - } - - } - last_mode = mode; - last_error = error; - - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - if (appendMessage == null) { - appendMessage = ""; - } - if (instruction != null) { - instruction_num = Integer.parseInt(instruction.getInstruction_code()); - } - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - ReadUtil.write(itemMap, server); - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - ReadUtil.write(itemMap, server); - - } - - public void writing(int type, int command) { - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - ReadUtil.write(itemMap, server); - - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/ItemProtocol.java deleted file mode 100644 index cc9f440..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/ItemProtocol.java +++ /dev/null @@ -1,143 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_split_manipulator; - -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_error = "error"; - public static String item_getStation = "getStation"; - public static String item_barcode = "barcode"; - public static String item_open_time = "open_time"; - public static String item_standby_time = "standby_time "; - public static String item_production_time = "production_time"; - public static String item_error_time = "error_time"; - public static String item_material = "material"; - public static String item_total_split = "total_split"; - public static String item_to_heartbeat = "to_heartbeat"; - public static String item_to_feedback = "to_feedback"; - public static String item_to_error = "to_error"; - public static String item_to_material = "to_material"; - - - private LnshSplitManipulatorDeviceDriver driver; - - public ItemProtocol(LnshSplitManipulatorDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getBarcode() { - return this.getOpcIntegerValue(item_barcode); - } - - public int getOpen_time() { - return this.getOpcIntegerValue(item_open_time); - } - - public int getStandby_time() { - return this.getOpcIntegerValue(item_standby_time); - } - - public int getProduction_time() { - return this.getOpcIntegerValue(item_production_time); - } - - public int getError_time() { - return this.getOpcIntegerValue(item_error_time); - } - - public int getGetStation() { - return this.getOpcIntegerValue(item_getStation); - } - - public int getMaterial() { - return this.getOpcIntegerValue(item_material); - } - - public int getTotal_split() { - return this.getOpcIntegerValue(item_total_split); - } - - public int getTo_heartbeat() { - return this.getOpcIntegerValue(item_to_heartbeat); - } - - public int getTo_feedback() { - return this.getOpcIntegerValue(item_to_feedback); - } - - public int getTo_error() { - return this.getOpcIntegerValue(item_to_error); - } - - public int getTo_material() { - return this.getOpcIntegerValue(item_to_material); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true))); - list.add(new ItemDto(item_error, "故障", "DB600.B3")); - list.add(new ItemDto(item_getStation, "当前抓取工位", "DB600.B3")); - list.add(new ItemDto(item_barcode, "条码", "DB600.B3")); - list.add(new ItemDto(item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(item_error_time, "故障时间", "DB600.D8")); - list.add(new ItemDto(item_material, "物料", "DB600.D8")); - list.add(new ItemDto(item_total_split, "累计拆垛数量", "DB600.D13")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_heartbeat, "心跳", "DB601.W10")); - list.add(new ItemDto(item_to_feedback, "机器人动作反馈", "DB601.W10")); - list.add(new ItemDto(item_to_error, "故障代码", "DB601.W10")); - list.add(new ItemDto(item_to_material, "物料", "DB601.W10")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/LnshSplitManipulatorDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/LnshSplitManipulatorDefination.java deleted file mode 100644 index 2c6b73c..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/LnshSplitManipulatorDefination.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_split_manipulator; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 晟华拆垛机械手 - * - */ -@Service -public class LnshSplitManipulatorDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "lnsh_split_manipulator"; - } - - @Override - public String getDriverName() { - return "晟华-拆垛机械手"; - } - - @Override - public String getDriverDescription() { - return "晟华-拆垛机械手"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new LnshSplitManipulatorDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return LnshSplitManipulatorDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true))); - list.add(new ItemDto(ItemProtocol.item_error, "故障", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_getStation, "当前抓取工位", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_barcode, "条码", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_open_time, "开机时间", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_standby_time, "待机时间", "DB600.D6")); - list.add(new ItemDto(ItemProtocol.item_production_time, "生产时间", "DB600.D7")); - list.add(new ItemDto(ItemProtocol.item_error_time, "故障时间", "DB600.D8")); - list.add(new ItemDto(ItemProtocol.item_material, "物料", "DB600.D8")); - list.add(new ItemDto(ItemProtocol.item_total_split, "累计拆垛数量", "DB600.D13")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/LnshSplitManipulatorDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/LnshSplitManipulatorDeviceDriver.java deleted file mode 100644 index 97d5c8c..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_split_manipulator/LnshSplitManipulatorDeviceDriver.java +++ /dev/null @@ -1,305 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_split_manipulator; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -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.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 晟华拆垛机械手 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class LnshSplitManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - int mode = 0; - int error = 0; - int last_mode = 0; - int last_error = 0; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - String material; - //批次 - String batch; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - //申请搬运任务 - private Boolean apply_handling = false; - //申请物料 - private Boolean apply_material = false; - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag; - - String devicecode; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - String device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (error != last_error) { - } - - } catch (Exception var17) { - return; - } - - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - return; - case 2: - if (material.length() > 0 && qty.length() > 0 && !requireSucess) { - this.instruction_require(container); - } - } - - switch (flag) { - //取货完成 - case 1: - writing(2); - return; - //放货完成 - case 2: - writing(3); - return; - - } - - } - last_mode = mode; - last_error = error; - - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - if (appendMessage == null) { - appendMessage = ""; - } - if (instruction != null) { - instruction_num = Integer.parseInt(instruction.getInstruction_code()); - } - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - ReadUtil.write(itemMap, server); - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - ReadUtil.write(itemMap, server); - - } - - public void writing(int type, int command) { - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - ReadUtil.write(itemMap, server); - - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/ItemProtocol.java deleted file mode 100644 index b36e1fc..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/ItemProtocol.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_station; - -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_ioaction = "ioaction"; - public static String item_error = "error"; - public static String item_task = "task"; - public static String item_weight = "weight"; - public static String item_material = "material"; - public static String item_barcode = "barcode"; - public static String item_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_task = "to_task"; - - - Boolean isonline; - - private LnshStationDeviceDriver driver; - - public ItemProtocol(LnshStationDeviceDriver 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 getIoAction() { - return this.getOpcIntegerValue(item_ioaction); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getWeight() { - return this.getOpcIntegerValue(item_weight); - } - - public int getMaterial() { - return this.getOpcIntegerValue(item_material); - } - - public int getBarcode() { - return this.getOpcIntegerValue(item_barcode); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getToTarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getToTask() { - return this.getOpcIntegerValue(item_to_task); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true))); - list.add(new ItemDto(item_move, "光电开关信号", "DB600.B3")); - list.add(new ItemDto(item_action, "取放信号", "DB600.B4")); - list.add(new ItemDto(item_ioaction, "进出信号", "DB600.B5")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B7")); - list.add(new ItemDto(item_task, "任务号", "DB600.D10")); - list.add(new ItemDto(item_weight, "重量", "DB600.D14")); - list.add(new ItemDto(item_material, "物料", "DB600.D18")); - list.add(new ItemDto(item_barcode, "条码", "DB600.D68")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_target, "目标站", "DB601.W4")); - list.add(new ItemDto(item_to_task, "任务号", "DB601.D8")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDefination.java deleted file mode 100644 index 4844194..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDefination.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_station; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 晟华-工位(交互模板) - * - */ -@Service -public class LnshStationDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "lnsh_station"; - } - - @Override - public String getDriverName() { - return "晟华-工位(交互模板)"; - } - - @Override - public String getDriverDescription() { - return "晟华-工位(交互模板)"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new LnshStationDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return LnshStationDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true))); - list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_ioaction, "进出信号", "DB600.B5")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B7")); - list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB600.D10")); - list.add(new ItemDto(ItemProtocol.item_weight, "重量", "DB600.D14")); - list.add(new ItemDto(ItemProtocol.item_material, "物料", "DB600.D18")); - list.add(new ItemDto(ItemProtocol.item_barcode, "条码", "DB600.D68")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDeviceDriver.java deleted file mode 100644 index 1a68b92..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/lnsh/lnsh_station/LnshStationDeviceDriver.java +++ /dev/null @@ -1,538 +0,0 @@ -package org.nl.acs.device_driver.lnsh.lnsh_station; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver; -import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 晟华-工位(交互模板) - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class LnshStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - String devicecode; - int mode = 0; - int error = 0; - int move = 0; - int actoin; - int io_action; - int task = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - Boolean isonline = true; - int hasGoods = 0; - Boolean iserror = false; - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - private Boolean sampleMode0; - private Boolean sampleMode3; - private Integer sampleError; - private Boolean sampleOnline; - protected String displayMessage = null; - public int display_message_time_out = 30000; - public Date display_message_time; - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out = 3000; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int heartbeat; - int last_heartbeat; - private Date checkHeartbeattime = new Date(); - private Date last_checkHeartbeattime = new Date(); - - - int branchProtocol = 0; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - String message; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - String device_code = this.getDeviceCode(); - - mode = this.itemProtocol.getMode(); - error = this.itemProtocol.getError(); - move = this.itemProtocol.getMove(); - task = this.itemProtocol.getTask(); - hasGoods = this.itemProtocol.getMove(); - io_action = this.itemProtocol.getIoAction(); - actoin = this.itemProtocol.getAction(); - - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (move != last_move) { - if (move == 0) { - thingToNothing(); - } - } - if (error != last_error) { - } - - } catch (Exception var17) { - return; - } - - //急停 - if (this.isStop()) { - - //未在线无心跳 - } else if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 2: - break; - case 3: - //申请空盘 - if (!requireSucess && this.move == 0) { - applyEmpty(); - } - break; - case 4: - //申请搬运任务 - if (!requireSucess && this.move != 0) { - autoCreateTask(); - } - break; - case 5: - break; - } - } - - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - } - - /** - * 生成搬运任务 - * - * @return - */ - public synchronized boolean autoCreateTask() { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setStart_device_code(this.getDevice().getDevice_code()); - dto.setTask_status("0"); - dto.setPriority("101"); - String next_device_code = ""; - - String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + dto.getRoute_plan_code() + "'").uniqueResult(0).getString("plan_uuid"); - JSONArray ja = routelineserver.queryNextLine(this.getDevice().getDevice_code(), plan_uuid); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - for (int i = 0; i < ja.size(); i++) { - JSONObject jo = (JSONObject) ja.get(i); - next_device_code = jo.get("next_device_code").toString(); - Device nextdevice = appService.findDeviceByCode(next_device_code); - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); - String maxTaskNum = WQLObject.getWQLObject("sys_param").query("code= 'onePointMaxTask' and is_active='1' ").uniqueResult(0).getString("value"); - - if (taskserver.checkAllowCreate(next_device_code) >= Integer.parseInt(maxTaskNum)) { - next_device_code = ""; - continue; - } - if (standardInspectSiteDeviceDriver.getMode() == 2 && standardInspectSiteDeviceDriver.getMove() == 0) { - break; - } - } - } - if (StrUtil.isEmpty(next_device_code)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_code); - dto.setNext_device_code(next_device_code); - dto.setUpdate_time(now); - dto.setCreate_time(now); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - try { - taskserver.create(dto); - } catch (Exception e) { - e.printStackTrace(); - } - this.setRequireSucess(true); - return true; - } - - } - - - public synchronized boolean applyEmpty() { - - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setTask_status("0"); - dto.setPriority("101"); - String start_device_code = ""; - String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + dto.getRoute_plan_code() + "'").uniqueResult(0).getString("plan_uuid"); - - JSONArray ja = routelineserver.querySuperiorLine(this.getDevice().getDevice_code(), plan_uuid); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - for (int i = 0; i < ja.size(); i++) { - JSONObject jo = (JSONObject) ja.get(i); - start_device_code = jo.get("device_code").toString(); - Device start_device = appService.findDeviceByCode(start_device_code); - StandardEmptyPalletSiteDeviceDriver standardEmptyPalletSiteDeviceDriver; - if (start_device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) start_device.getDeviceDriver(); - //根据路由 寻找取空盘的设备 -// if(standardEmptyPalletSiteDeviceDriver.getNumber() < Integer.parseInt(standardEmptyPalletSiteDeviceDriver.getDevice().getExtraValue().get("max_emptypalletnum").toString()) ) { -// break; -// } - if (standardEmptyPalletSiteDeviceDriver.getMode() == 2 && standardEmptyPalletSiteDeviceDriver.getNumber() > 0) { - break; - } - } - } - dto.setTask_type("1"); - dto.setEmptypallet_num("1"); - dto.setNext_device_code(this.getDevice().getDevice_code()); - dto.setNext_point_code(this.getDevice().getDevice_code()); - dto.setStart_point_code(start_device_code); - dto.setStart_device_code(start_device_code); - if (StrUtil.isEmpty(start_device_code)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setUpdate_time(now); - dto.setCreate_time(now); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - try { - taskserver.create(dto); - } catch (Exception e) { - e.printStackTrace(); - } - this.setRequireSucess(true); - this.setBranchProtocol(0); - return true; - } - } - - public void finish_instruction(Instruction instruction) throws Exception { - instruction_finished(instruction); - } - - /** - * 完成指令 - * - * @param instruction - * @return - */ - public boolean instruction_finished(Instruction instruction) throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - instructionService.finish(instruction.getInstruction_id()); - this.instruction_finished_time = date; - return true; - } - } - - /** - * 完成并创建下一条指令 - * - * @param instruction - * @param needCreateNext - * @return - */ - public boolean instruction_finished(Instruction instruction, boolean needCreateNext) { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - this.instruction_finished_time = date; - return true; - } - } - - - private Instruction findInstruction() { - Instruction instruction = null; - if (this.instruction_num != 0) { - instruction = (Instruction) instructionService.findByCodeFromCache(String.valueOf(instruction_num)); - } - if (instruction != null) { - //可进行校验 - - - } else { - List container_instructions = new ArrayList(); - String barcode = this.getLast_container(); - - if (!StrUtil.isEmpty(barcode)) { - Map map = new HashMap(); - map.put("vehicle_code", barcode); - container_instructions = instructionService.queryAll(map); - } - - if (((List) container_instructions).size() > 1) { - log.debug("容器存在多个指令"); - } else { - if (((List) container_instructions).size() > 0) { - instruction = (Instruction) ((List) container_instructions).get(0); - } - } - } - return instruction; - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.set_last_container(container, container_type_desc); - this.setRequireSucess(false); - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - if (appendMessage == null) { - appendMessage = ""; - } - if (instruction != null) { - instruction_num = Integer.parseInt(instruction.getInstruction_code()); - } - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, 1); - itemMap.put(to_task, instruction_num); - ReadUtil.write(itemMap, server); - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - - public void writing(int type, int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - if (type == 1) { - itemMap.put(to_command, command); - } else if (type == 2) { - itemMap.put(to_target, command); - - } else if (type == 3) { - itemMap.put(to_task, command); - } - ReadUtil.write(itemMap, server); - - } - - public String toString() { - return ""; - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/machines_site/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/machines_site/ItemProtocol.java deleted file mode 100644 index e92763f..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/machines_site/ItemProtocol.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.nl.acs.device_driver.machines_site; - -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_ioaction = "ioaction"; - public static String item_error = "error"; - public static String item_task = "task"; - public static String item_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_task = "to_task"; - public static String item_weight = "weight"; - - private MachinesSiteDeviceDriver driver; - - public ItemProtocol(MachinesSiteDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getIoaction() { - return this.getOpcIntegerValue(item_ioaction); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getToTarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getToTask() { - return this.getOpcIntegerValue(item_to_task); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_ioaction, "取放信号", "DB600.B4")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(item_task, "任务号", "DB600.D8")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_target, "目标站", "DB601.W4")); - list.add(new ItemDto(item_to_task, "任务号", "DB601.D8")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/machines_site/MachinesSiteDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/machines_site/MachinesSiteDefination.java deleted file mode 100644 index 187d9ca..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/machines_site/MachinesSiteDefination.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.nl.acs.device_driver.machines_site; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.device_driver.standard_inspect_site.ItemProtocol; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 检测站点驱动定义 - * 说明:该站点为普通带光电检测站点 - */ -@Service -public class MachinesSiteDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "machines_site"; - } - - @Override - public String getDriverName() { - return "标准版-机台设备"; - } - - @Override - public String getDriverDescription() { - return "标准版-机台设备"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new MachinesSiteDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return MachinesSiteDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", true)); - list.add(new ItemDto(ItemProtocol.item_ioaction, "取放信号", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB600.D8")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/machines_site/MachinesSiteDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/machines_site/MachinesSiteDeviceDriver.java deleted file mode 100644 index 57c93cc..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/machines_site/MachinesSiteDeviceDriver.java +++ /dev/null @@ -1,346 +0,0 @@ -package org.nl.acs.device_driver.machines_site; - -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.task.service.TaskService; -import org.nl.utils.SpringContextHolder; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 机台设备驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class MachinesSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - int mode = 0; - int error = 0; - int move = 0; - int task = 0; - int ioaction = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - String material; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - //申请搬运任务 - private Boolean apply_handling = false; - //申请物料 - private Boolean apply_material = false; - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag; - - String device_code; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - error = this.itemProtocol.getError(); - task = this.itemProtocol.getTask(); - ioaction = this.itemProtocol.getIoaction(); - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (move != last_move) { - } - if (error != last_error) { - } - - - } catch (Exception var17) { - return; - } - - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - return; - case 2: - //申请任务 -// if (this.getApply_handling()) { -// String link_device_code = this.getDevice().getExtraValue().get("link_device_code").toString(); -// DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); -// Device link_device = appService.findDeviceByCode(link_device_code); -// StandardInspectSiteDeviceDriver standardInspectSiteDevicedriver; -// if(link_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { -// standardInspectSiteDevicedriver = (StandardInspectSiteDeviceDriver) link_device.getDeviceDriver(); -// if(standardInspectSiteDevicedriver.getMode() != 2){ -// log.debug("设备未待机"); -// return; -// } -// if(standardInspectSiteDevicedriver.getMove() != 0){ -// log.debug("设备不满足放货条件"); -// return; -// } -// -// //如果目标设备申请叫料 则允许生成任务 -// if(standardInspectSiteDevicedriver.getApply_material()){ -// TaskDto dto = new TaskDto(); -// String now = DateUtil.now(); -// dto.setTask_id(IdUtil.simpleUUID()); -// dto.setCreate_by(this.getDevice().getDevice_code()); -// dto.setUpdate_by(this.getDevice().getDevice_code()); -// dto.setStart_point_code(this.getDevice().getDevice_code()); -// -// String taskcode = CodeGenerateUtil.getNewCode("TASK_NO"); -// dto.setTask_code("-"+taskcode); -// dto.setTask_status("0"); -// dto.setPriority("101"); -// RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); -// String next_device_codecode = jo.getNext_device_code(); -// if(StrUtil.isEmpty(next_device_codecode)){ -// throw new RuntimeException("该设备未找到对应路由"); -// } -// dto.setNext_point_code(next_device_codecode); -// dto.setUpdate_time(now); -// dto.setCreate_time(now); -// -// WQLObject wo = WQLObject.getWQLObject("acs_task"); -// JSONObject json = (JSONObject) JSONObject.toJSON(dto); - -// wo.insert(json); -// standardInspectSiteDevicedriver.setApply_material(false); -// } -// } -// this.setApply_handling(false); -// } - - if (material.length() > 0 && qty.length() > 0 && !requireSucess) { - this.instruction_require(container); - } - } - - switch (flag) { - //取货完成 - case 1: - writing(2); - return; - //放货完成 - case 2: - writing(3); - return; - - } - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - } - - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - if (appendMessage == null) { - appendMessage = ""; - } - if (instruction != null) { - instruction_num = Integer.parseInt(instruction.getInstruction_code()); - } - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, 1); - itemMap.put(to_task, instruction_num); - ReadUtil.write(itemMap, server); - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - ReadUtil.write(itemMap, server); - log.info("下发PLC信号:{},{}", to_command, command); - } - - public void writing(int type, int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - if (type == 1) { - itemMap.put(to_command, command); - } else if (type == 2) { - itemMap.put(to_target, command); - - } else if (type == 3) { - itemMap.put(to_task, command); - } - ReadUtil.write(itemMap, server); - - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - return true; - } - - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/magic_agv/MagicAgvDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/magic_agv/MagicAgvDefination.java deleted file mode 100644 index afaba90..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/magic_agv/MagicAgvDefination.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.nl.acs.device_driver.magic_agv; - -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.DeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * 普通站点定义 - */ -@Service -public class MagicAgvDefination implements DeviceDriverDefination { - @Override - public String getDriverCode() { - return "magic_agv"; - } - - @Override - public String getDriverName() { - return "标准版-MagicAgv"; - } - - @Override - public String getDriverDescription() { - return "标准版-MagicAgv"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new MagicAgvDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return MagicAgvDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/magic_agv/MagicAgvDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/magic_agv/MagicAgvDeviceDriver.java deleted file mode 100644 index d712f20..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/magic_agv/MagicAgvDeviceDriver.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.nl.acs.device_driver.magic_agv; - -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.DeviceDriverDefination; -import org.nl.acs.device_driver.driver.AbstractDeviceDriver; -import org.nl.acs.opc.Device; -import org.springframework.stereotype.Service; - -/** - * 普通站点 - */ -@Slf4j -@Service -public class MagicAgvDeviceDriver extends AbstractDeviceDriver implements DeviceDriver { - @Override - public Device getDevice() { - return null; - } - - @Override - public DeviceDriverDefination getDriverDefination() { - return null; - } - - @Override - public DeviceDriver setDriverDefination(DeviceDriverDefination var1) { - return null; - } - - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/manipulator_inspect_site_NDC/ManipulatorInspectSiteNDCDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/manipulator_inspect_site_NDC/ManipulatorInspectSiteNDCDefination.java deleted file mode 100644 index 9af54e7..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/manipulator_inspect_site_NDC/ManipulatorInspectSiteNDCDefination.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.nl.acs.device_driver.manipulator_inspect_site_NDC; - -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.DeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * 区域管制设备交互站点-NDC - */ -@Service -public class ManipulatorInspectSiteNDCDefination implements DeviceDriverDefination { - @Override - public String getDriverCode() { - return "manipulator_inspect_site_NDC"; - } - - @Override - public String getDriverName() { - return "区域管制站点-NDC"; - } - - @Override - public String getDriverDescription() { - return "区域管制站点-NDC"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new ManipulatorInspectSiteNDCDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return ManipulatorInspectSiteNDCDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/manipulator_inspect_site_NDC/ManipulatorInspectSiteNDCDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/manipulator_inspect_site_NDC/ManipulatorInspectSiteNDCDeviceDriver.java deleted file mode 100644 index 97e5b61..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/manipulator_inspect_site_NDC/ManipulatorInspectSiteNDCDeviceDriver.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.nl.acs.device_driver.manipulator_inspect_site_NDC; - -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; - - -/** - * 区域管制设备交互站点-NDC - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class ManipulatorInspectSiteNDCDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - String relevance_device_code; - - @Override - public void execute() { - } -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/non_line_inspect_site/NonLineInspectSiteDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/non_line_inspect_site/NonLineInspectSiteDefination.java deleted file mode 100644 index b489f47..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/non_line_inspect_site/NonLineInspectSiteDefination.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.nl.acs.device_driver.non_line_inspect_site; - -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.DeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * 普通站点定义 - */ -@Service -public class NonLineInspectSiteDefination implements DeviceDriverDefination { - @Override - public String getDriverCode() { - return "non_line_inspect_site"; - } - - @Override - public String getDriverName() { - return "检测站点-无PLC"; - } - - @Override - public String getDriverDescription() { - return "检测站点-无PLC"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new NonLineInspectSiteDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return NonLineInspectSiteDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/non_line_inspect_site/NonLineInspectSiteDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/non_line_inspect_site/NonLineInspectSiteDeviceDriver.java deleted file mode 100644 index a1b6de7..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/non_line_inspect_site/NonLineInspectSiteDeviceDriver.java +++ /dev/null @@ -1,393 +0,0 @@ -package org.nl.acs.device_driver.non_line_inspect_site; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.device_driver.special_ordinary_site.SpecialOrdinarySiteDeviceDriver; -import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.springframework.beans.factory.annotation.Autowired; - -import java.math.BigDecimal; -import java.util.Date; - - -/** - * 检测站点-无PLC - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class NonLineInspectSiteDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - - Integer hasGoods = 0; - int error = 0; - Boolean iserror = false; - Boolean islock = false; - - int branchProtocol = 0; - int last_branchProtocol = 0; - //是否需要输入物料 - String input_material = "0"; - //备注 - String remark = ""; - //数量 - String qty = ""; - //批次 - String batch = ""; - //物料 - String material = ""; - //是否在线 - Boolean is_online = true; - //目标点位 - String purpose = ""; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - boolean requireSucess = false; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - //申请搬运任务 - private Boolean apply_handling = false; - //申请物料 - private Boolean apply_material = false; - - // 1取货完成 2放货完成 3进入区域 4离开区域 - private int flag; - - //人工确认信号 默认0 agv到达后请求置1 等人工确认后变为2 反馈agv后继续为0 - private int manua_confirm = 0; - - String devicecode; - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - - String message; - - int mode = 2; - - int move; - - int action; - - int ioaction; - - @Override - public void execute() { - hasGoods = this.getDevice().getHas_goods(); - material = this.getDevice().getMaterial_type(); - batch = this.getDevice().getBatch(); - devicecode = this.getDeviceCode(); - if (branchProtocol != last_branchProtocol) { - requireSucess = false; - } - switch (branchProtocol) { - case 1: - break; - //呼叫请求 - case 2: - if (material.length() > 0 && Integer.parseInt(this.getQty()) > 0 && !requireSucess) { - } - break; - //响应生成任务 - case 3: - if (material.length() > 0 && qty.length() > 0 && purpose.length() > 0 && !requireSucess) { - this.instruction_require(material, qty, this.getRemark(), purpose); - } - break; - //自动创建任务 叫料 - case 4: - if (!requireSucess) { - autoCreateTask(); - } - break; - //搬运空车、空托 - case 5: - if (!requireSucess) { - autoCreateEmptyPallet(); - } - break; - } - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - - /** - * 自动创建任务 - * - * @return - */ - public synchronized boolean autoCreateTask() { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); -// dto.setVehicle_code(container_code); -// dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - String next_device_code = ""; - - String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + dto.getRoute_plan_code() + "'").uniqueResult(0).getString("plan_uuid"); - JSONArray ja = routelineserver.queryNextLine(this.getDevice().getDevice_code(), plan_uuid); - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - for (int i = 0; i < ja.size(); i++) { - JSONObject jo = (JSONObject) ja.get(i); - next_device_code = jo.get("next_device_code").toString(); - Device nextdevice = appService.findDeviceByCode(next_device_code); - NonLineInspectSiteDeviceDriver standardOrdinarySiteDeviceDriver; - if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (NonLineInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); - String maxTaskNum = WQLObject.getWQLObject("sys_param").query("code= 'onePointMaxTask' and is_active='1' ").uniqueResult(0).getString("value"); - - if (taskserver.checkAllowCreate(next_device_code) >= Integer.parseInt(maxTaskNum)) { - continue; - } - if (standardOrdinarySiteDeviceDriver.getHasGoods() == 0) { - break; - } - } - } - if (StrUtil.isEmpty(next_device_code)) { - throw new RuntimeException("该设备未找到对应路由"); - } - - - dto.setNext_point_code(next_device_code); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - this.setIslock(true); - requireSucess = false; - branchProtocol = 0; - return true; - } - - } - - /** - * 自动创建搬运空车任务 - * - * @return - */ - public synchronized boolean autoCreateEmptyPallet() { - 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 { - //存在空位才能执行 - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - String next_device_code = ""; - dto.setRoute_plan_code("one"); - String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + dto.getRoute_plan_code() + "'").uniqueResult(0).getString("plan_uuid"); - - JSONArray ja = routelineserver.queryNextLine(this.getDevice().getDevice_code(), plan_uuid); - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - for (int j = 0; j < ja.size(); j++) { - JSONObject jo = (JSONObject) ja.get(j); - next_device_code = jo.get("next_device_code").toString(); - Device nextdevice = appService.findDeviceByCode(next_device_code); - SpecialOrdinarySiteDeviceDriver specialOrdinarySiteDeviceDriver; - if (nextdevice.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) { - specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) nextdevice.getDeviceDriver(); - String maxTaskNum = WQLObject.getWQLObject("sys_param").query("code= 'onePointMaxTask' and is_active='1' ").uniqueResult(0).getString("value"); - specialOrdinarySiteDeviceDriver.setIslock(true); - if (taskserver.checkAllowCreate(next_device_code) >= Integer.parseInt(maxTaskNum)) { - continue; - } - if (specialOrdinarySiteDeviceDriver.getMode() == 2 && specialOrdinarySiteDeviceDriver.getMove() == 0) { - break; - } - } - } - if (StrUtil.isEmpty(next_device_code)) { - throw new RuntimeException("该设备未找到对应路由"); - } - - dto.setNext_point_code(next_device_code); - dto.setUpdate_time(now); - dto.setCreate_time(now); - dto.setMaterial(material); - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - this.setIslock(true); - requireSucess = false; - branchProtocol = 0; - return true; - } - } - - /** - * 请求任务 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - branchProtocol = 0; - return true; - } - } - - /** - * 请求任务 - * - * @param - * @param - */ - public synchronized boolean instruction_require(String material, String qty, String remark, String purpose) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(""); - dto.setVehicle_type(""); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - dto.setMaterial(this.getMaterial()); - dto.setQuantity(new BigDecimal(this.getQty())); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device purposedevice = appService.findDeviceByCode(purpose); - NonLineInspectSiteDeviceDriver standardOrdinarySiteDeviceDriver = null; - if (purposedevice.getDeviceDriver() instanceof NonLineInspectSiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (NonLineInspectSiteDeviceDriver) purposedevice.getDeviceDriver(); - standardOrdinarySiteDeviceDriver.setBranchProtocol(0); - standardOrdinarySiteDeviceDriver.setPurpose(null); - standardOrdinarySiteDeviceDriver.setRemark(null); - } - dto.setNext_point_code(purpose); - dto.setUpdate_time(now); - dto.setCreate_time(now); - dto.setRemark(getRemark()); - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - last_branchProtocol = 2; - this.setBranchProtocol(0); - this.setRemark(null); - this.setPurpose(null); - this.setRequireSucess(true); - return true; - } - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/non_line_manipulator_inspect_site/NonLineManipulatorInspectSiteDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/non_line_manipulator_inspect_site/NonLineManipulatorInspectSiteDefination.java deleted file mode 100644 index 1d42401..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/non_line_manipulator_inspect_site/NonLineManipulatorInspectSiteDefination.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.nl.acs.device_driver.non_line_manipulator_inspect_site; - -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.DeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * 普通站点定义 - */ -@Service -public class NonLineManipulatorInspectSiteDefination implements DeviceDriverDefination { - @Override - public String getDriverCode() { - return "non_line_manipulator_inspect_site"; - } - - @Override - public String getDriverName() { - return "区域管制设备交互站点-无PLC"; - } - - @Override - public String getDriverDescription() { - return "区域管制设备交互站点-无PLC"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new NonLineManipulatorInspectSiteDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return NonLineManipulatorInspectSiteDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/non_line_manipulator_inspect_site/NonLineManipulatorInspectSiteDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/non_line_manipulator_inspect_site/NonLineManipulatorInspectSiteDeviceDriver.java deleted file mode 100644 index 32c68b4..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/non_line_manipulator_inspect_site/NonLineManipulatorInspectSiteDeviceDriver.java +++ /dev/null @@ -1,393 +0,0 @@ -package org.nl.acs.device_driver.non_line_manipulator_inspect_site; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.device_driver.special_ordinary_site.SpecialOrdinarySiteDeviceDriver; -import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.springframework.beans.factory.annotation.Autowired; - -import java.math.BigDecimal; -import java.util.Date; - - -/** - * 区域管制站点-无PLC - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class NonLineManipulatorInspectSiteDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - - Integer hasGoods = 0; - int error = 0; - Boolean iserror = false; - Boolean islock = false; - - int branchProtocol = 0; - int last_branchProtocol = 0; - //是否需要输入物料 - String input_material = "0"; - //备注 - String remark = ""; - //数量 - String qty = ""; - //是否在线 - Boolean is_online = true; - //批次 - String batch = ""; - //物料 - String material = ""; - //目标点位 - String purpose = ""; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - boolean requireSucess = false; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - //申请搬运任务 - private Boolean apply_handling = false; - //申请物料 - private Boolean apply_material = false; - - // 1取货完成 2放货完成 3进入区域 4离开区域 - private int flag; - - //人工确认信号 默认0 agv到达后请求置1 等人工确认后变为2 反馈agv后继续为0 - private int manua_confirm = 0; - - String devicecode; - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - - String message; - - int mode = 2; - - int move; - - int action; - - int ioaction; - - @Override - public void execute() { - hasGoods = this.getDevice().getHas_goods(); - material = this.getDevice().getMaterial_type(); - batch = this.getDevice().getBatch(); - devicecode = this.getDeviceCode(); - if (branchProtocol != last_branchProtocol) { - requireSucess = false; - } - switch (branchProtocol) { - case 1: - break; - //呼叫请求 - case 2: - if (material.length() > 0 && Integer.parseInt(this.getQty()) > 0 && !requireSucess) { - } - break; - //响应生成任务 - case 3: - if (material.length() > 0 && qty.length() > 0 && purpose.length() > 0 && !requireSucess) { - this.instruction_require(material, qty, this.getRemark(), purpose); - } - break; - //自动创建任务 叫料 - case 4: - if (!requireSucess) { - autoCreateTask(); - } - break; - //搬运空车、空托 - case 5: - if (!requireSucess) { - autoCreateEmptyPallet(); - } - break; - } - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - - /** - * 自动创建任务 - * - * @return - */ - public synchronized boolean autoCreateTask() { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); -// dto.setVehicle_code(container_code); -// dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - String next_device_code = ""; - - String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + dto.getRoute_plan_code() + "'").uniqueResult(0).getString("plan_uuid"); - JSONArray ja = routelineserver.queryNextLine(this.getDevice().getDevice_code(), plan_uuid); - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - for (int i = 0; i < ja.size(); i++) { - JSONObject jo = (JSONObject) ja.get(i); - next_device_code = jo.get("next_device_code").toString(); - Device nextdevice = appService.findDeviceByCode(next_device_code); - NonLineManipulatorInspectSiteDeviceDriver standardOrdinarySiteDeviceDriver; - if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (NonLineManipulatorInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); - String maxTaskNum = WQLObject.getWQLObject("sys_param").query("code= 'onePointMaxTask' and is_active='1' ").uniqueResult(0).getString("value"); - - if (taskserver.checkAllowCreate(next_device_code) >= Integer.parseInt(maxTaskNum)) { - continue; - } - if (standardOrdinarySiteDeviceDriver.getHasGoods() == 0) { - break; - } - } - } - if (StrUtil.isEmpty(next_device_code)) { - throw new RuntimeException("该设备未找到对应路由"); - } - - - dto.setNext_point_code(next_device_code); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - this.setIslock(true); - requireSucess = false; - branchProtocol = 0; - return true; - } - - } - - /** - * 自动创建搬运空车任务 - * - * @return - */ - public synchronized boolean autoCreateEmptyPallet() { - 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 { - //存在空位才能执行 - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - String next_device_code = ""; - dto.setRoute_plan_code("one"); - String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + dto.getRoute_plan_code() + "'").uniqueResult(0).getString("plan_uuid"); - - JSONArray ja = routelineserver.queryNextLine(this.getDevice().getDevice_code(), plan_uuid); - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - for (int j = 0; j < ja.size(); j++) { - JSONObject jo = (JSONObject) ja.get(j); - next_device_code = jo.get("next_device_code").toString(); - Device nextdevice = appService.findDeviceByCode(next_device_code); - SpecialOrdinarySiteDeviceDriver specialOrdinarySiteDeviceDriver; - if (nextdevice.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) { - specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) nextdevice.getDeviceDriver(); - String maxTaskNum = WQLObject.getWQLObject("sys_param").query("code= 'onePointMaxTask' and is_active='1' ").uniqueResult(0).getString("value"); - specialOrdinarySiteDeviceDriver.setIslock(true); - if (taskserver.checkAllowCreate(next_device_code) >= Integer.parseInt(maxTaskNum)) { - continue; - } - if (specialOrdinarySiteDeviceDriver.getMode() == 2 && specialOrdinarySiteDeviceDriver.getMove() == 0) { - break; - } - } - } - if (StrUtil.isEmpty(next_device_code)) { - throw new RuntimeException("该设备未找到对应路由"); - } - - dto.setNext_point_code(next_device_code); - dto.setUpdate_time(now); - dto.setCreate_time(now); - dto.setMaterial(material); - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - this.setIslock(true); - requireSucess = false; - branchProtocol = 0; - return true; - } - } - - /** - * 请求任务 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - branchProtocol = 0; - return true; - } - } - - /** - * 请求任务 - * - * @param - * @param - */ - public synchronized boolean instruction_require(String material, String qty, String remark, String purpose) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(""); - dto.setVehicle_type(""); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - dto.setMaterial(this.getMaterial()); - dto.setQuantity(new BigDecimal(this.getQty())); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device purposedevice = appService.findDeviceByCode(purpose); - NonLineManipulatorInspectSiteDeviceDriver standardOrdinarySiteDeviceDriver = null; - if (purposedevice.getDeviceDriver() instanceof NonLineManipulatorInspectSiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (NonLineManipulatorInspectSiteDeviceDriver) purposedevice.getDeviceDriver(); - standardOrdinarySiteDeviceDriver.setBranchProtocol(0); - standardOrdinarySiteDeviceDriver.setPurpose(null); - standardOrdinarySiteDeviceDriver.setRemark(null); - } - dto.setNext_point_code(purpose); - dto.setUpdate_time(now); - dto.setCreate_time(now); - dto.setRemark(getRemark()); - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - last_branchProtocol = 2; - this.setBranchProtocol(0); - this.setRemark(null); - this.setPurpose(null); - this.setRequireSucess(true); - return true; - } - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/oumulong_plc/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/oumulong_plc/ItemProtocol.java deleted file mode 100644 index ece85be..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/oumulong_plc/ItemProtocol.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.nl.acs.device_driver.oumulong_plc; - -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; - -import java.util.ArrayList; -import java.util.List; - -@Slf4j -public class ItemProtocol { - public static String item_heartbeat = "heartbeat"; - public static String item_mode = "mode"; - public static String item_action = "action"; - public static String item_error = "error"; - public static String item_to_command = "to_command"; - - - private OumulongPlcDeviceDriver driver; - - public ItemProtocol(OumulongPlcDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - log.error("读取错误!"); - } else { - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "D00000")); - list.add(new ItemDto(item_mode, "工作状态", "D00002", Boolean.valueOf(true))); - list.add(new ItemDto(item_action, "动作信号", "D00004")); - list.add(new ItemDto(item_error, "报警信号", "D00006")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "D00008", Boolean.valueOf(true))); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/oumulong_plc/OumulongPlcDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/oumulong_plc/OumulongPlcDefination.java deleted file mode 100644 index 84b3ecf..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/oumulong_plc/OumulongPlcDefination.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.nl.acs.device_driver.oumulong_plc; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 自动门驱动定义 - */ -@Service -public class OumulongPlcDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "oumulong_plc"; - } - - @Override - public String getDriverName() { - return "标准版-自动门-欧姆龙plc"; - } - - @Override - public String getDriverDescription() { - return "标准版-自动门-欧姆龙plc"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new OumulongPlcDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return OumulongPlcDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "D00000")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "D00002", true)); - list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "D00004")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "D00006")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/oumulong_plc/OumulongPlcDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/oumulong_plc/OumulongPlcDeviceDriver.java deleted file mode 100644 index 56536b2..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/oumulong_plc/OumulongPlcDeviceDriver.java +++ /dev/null @@ -1,162 +0,0 @@ -package org.nl.acs.device_driver.oumulong_plc; - -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.opc.Device; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.task.service.TaskService; -import org.nl.utils.SpringContextHolder; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -/** - * 自动门驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class OumulongPlcDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - String devicecode; - int mode = 0; - int action = 0; - int error = 0; - Boolean iserror = false; - - int move = 0; - int task = 0; - int last_action = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - protected boolean hasGoods = false; - boolean isFold = false; - private String assemble_check_tag; - private Boolean sampleMode0; - private Boolean sampleMode3; - private Integer sampleError; - private Boolean sampleOnline; - protected String displayMessage = null; - public int display_message_time_out = 30000; - public Date display_message_time; - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - - String device_code = this.getDevice().getDevice_code(); - mode = this.itemProtocol.getMode(); - action = this.itemProtocol.getAction(); - error = this.itemProtocol.getError(); - if (mode != last_mode) { - } - if (action != last_action) { - } - if (error != last_error) { - } - last_action = action; - last_mode = mode; - last_error = error; - //message = StringFormatUtl.format("设备报警:{}", new Object[]{}); - -// String manual_create_task = this.getDevice().getExtraValue().get("manual_create_task").toString(); - - } - - public synchronized String getStatus() { - JSONObject jo = new JSONObject(); - - if (action == 1) { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "OPEN"); - - } else if (action == 2) { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "CLOSE"); - - } else { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "ERROR"); - } - return jo.toString(); - } - - - public void writeing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - ReadUtil.write(itemMap, server); - log.info("下发PLC信号:{},{}", to_command, command); - System.out.println("设备:" + devicecode + ",下发PLC信号:" + to_command + ",value:" + command); - - } - - public synchronized void OpenOrClose(String type) { - - //开门 - if ("1".equals(type)) { - writeing(1); - } else { - writeing(2); - } - - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/special_ordinary_site/SpecialOrdinarySiteDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/special_ordinary_site/SpecialOrdinarySiteDefination.java deleted file mode 100644 index a8ab696..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/special_ordinary_site/SpecialOrdinarySiteDefination.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.nl.acs.device_driver.special_ordinary_site; - -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.DeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * 普通站点定义 - */ -@Service -public class SpecialOrdinarySiteDefination implements DeviceDriverDefination { - @Override - public String getDriverCode() { - return "special_ordinary_site"; - } - - @Override - public String getDriverName() { - return "特殊版-普通站点-关联锁定"; - } - - @Override - public String getDriverDescription() { - return "特殊版-普通站点-关联锁定"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new SpecialOrdinarySiteDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return SpecialOrdinarySiteDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/special_ordinary_site/SpecialOrdinarySiteDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/special_ordinary_site/SpecialOrdinarySiteDeviceDriver.java deleted file mode 100644 index 4607678..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/special_ordinary_site/SpecialOrdinarySiteDeviceDriver.java +++ /dev/null @@ -1,439 +0,0 @@ -package org.nl.acs.device_driver.special_ordinary_site; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -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.config.AcsConfig; -import org.nl.acs.config.server.AcsConfigService; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.springframework.beans.factory.annotation.Autowired; - -import java.math.BigDecimal; -import java.util.Date; -import java.util.List; - - -/** - * 无光电特殊站点 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class SpecialOrdinarySiteDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - @Autowired - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - @Autowired - DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class); - @Autowired - RouteLineService routeLineServer = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - TaskService taskServer = SpringContextHolder.getBean(TaskService.class); - @Autowired - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); - @Autowired - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - - Integer hasGoods = 0; - int error = 0; - Boolean iserror = false; - - int branchProtocol = 0; - int last_branchProtocol = 0; - //是否需要输入物料 - String input_material = "0"; - //备注 - String remark = ""; - //数量 - String qty = ""; - //物料 - String material = ""; - //批次 - String batch = ""; - //目标点位 - String purpose = ""; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - boolean requireSucess = false; - - //任务锁 - Boolean islock = false; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - //申请搬运任务 - private Boolean apply_handling = false; - //申请物料 - private Boolean apply_material = false; - - // 1取货完成 2放货完成 3进入区域 4离开区域 - private int flag; - - String devicecode; - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out = 3000; - - String message; - - int mode = 2; - - int move; - - @Override - public void execute() { - hasGoods = this.getDevice().getHas_goods(); - material = this.getDevice().getMaterial_type(); - batch = this.getDevice().getBatch(); - islock = Boolean.getBoolean(this.getDevice().getIslock()); - - devicecode = this.getDeviceCode(); - if (branchProtocol != last_branchProtocol) { - requireSucess = false; - } - switch (branchProtocol) { - case 1: - break; - //呼叫请求 - case 2: - if (material.length() > 0 && Integer.parseInt(this.getQty()) > 0 && !requireSucess) { - } - break; - //响应生成任务 - case 3: - if (material.length() > 0 && qty.length() > 0 && purpose.length() > 0 && !requireSucess) { - this.instruction_require(material, qty, this.getRemark(), purpose); - } - break; - //自动创建任务 叫料 - case 4: - if (!requireSucess) { - autoCreateTask(); - } - break; - //送走空车、空托 - case 5: - if (!requireSucess) { - autoCreateEmptyPallet(); - } - break; - } - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - - /** - * 自动创建任务 - * - * @return - */ - public synchronized boolean autoCreateTask() { - 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 { - //存在空位才能执行 - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - String start_device_code = ""; - List ja = routeLineServer.getSuperiorShortPathLinesByCode(this.getDevice().getDevice_code(), "normal"); - boolean flag = false; - for (int j = 0; j < ja.size(); j++) { - RouteLineDto jo = ja.get(j); - start_device_code = jo.getDevice_code(); - Device startdevice = appService.findDeviceByCode(start_device_code); - SpecialOrdinarySiteDeviceDriver specialOrdinarySiteDeviceDriver; - if (startdevice.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) { - specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) startdevice.getDeviceDriver(); - String maxTaskNum = acsConfigService.findConfigFromCache().get(AcsConfig.ONEPOINTMAXTASK); - if (taskServer.checkAllowCreate(start_device_code) >= Integer.parseInt(maxTaskNum)) { - break; - } - if (specialOrdinarySiteDeviceDriver.hasGoods != 0 && !StrUtil.equals(specialOrdinarySiteDeviceDriver.getMaterial(), "0") - && !StrUtil.equals(specialOrdinarySiteDeviceDriver.getMaterial(), "1") - && (StrUtil.equals(startdevice.getIslock(), "false") || StrUtil.isEmpty(startdevice.getIslock()))) { - flag = true; - dto.setMaterial(specialOrdinarySiteDeviceDriver.getMaterial()); - break; - } else { - continue; - } - } - } - if (!flag) { - return false; - } - if (StrUtil.isEmpty(start_device_code)) { - requireSucess = true; - branchProtocol = 0; - //throw new RuntimeException("该设备未找到对应路由"); - log.debug("该设备未找到对应路由"); - } - dto.setStart_point_code(start_device_code); - dto.setStart_device_code(start_device_code); - dto.setNext_device_code(this.getDevice().getDevice_code()); - dto.setNext_point_code(this.getDevice().getDevice_code()); - dto.setUpdate_time(now); - dto.setCreate_time(now); - try { - taskServer.create(dto); - } catch (Exception e) { - e.printStackTrace(); - } - requireSucess = true; - JSONObject jo = new JSONObject(); - jo.put("device_code", start_device_code); - jo.put("islock", "true"); - jo.put("hasGoodStatus", "2"); - jo.put("batch", this.getBatch()); - jo.put("material_type", this.getMaterial()); - deviceService.changeDeviceStatus(jo); - JSONObject jo1 = new JSONObject(); - jo1.put("device_code", this.getDevicecode()); - jo.put("hasGoodStatus", "0"); - jo1.put("islock", "true"); - deviceService.changeDeviceStatus(jo1); - branchProtocol = 0; - return true; - } - } - - - /** - * 自动创建搬运空车任务 - * - * @return - */ - public synchronized boolean autoCreateEmptyPallet() { - 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 { - //存在空位才能执行 - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setTask_status("0"); - dto.setPriority("101"); - String next_device_code = ""; - - List ja = routeLineServer.getShortPathLinesByCode(this.getDevice().getDevice_code(), "normal"); - if (ObjectUtil.isEmpty(ja)) { - requireSucess = false; - log.debug("该设备未找到对应路由"); - branchProtocol = 0; - return false; - } - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - boolean flag = false; - - for (int j = 0; j < ja.size(); j++) { - RouteLineDto jo = ja.get(j); - next_device_code = jo.getNext_device_code(); - Device nextdevice = appService.findDeviceByCode(next_device_code); - SpecialOrdinarySiteDeviceDriver specialOrdinarySiteDeviceDriver; - if (nextdevice.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) { - specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) nextdevice.getDeviceDriver(); - String maxTaskNum = acsConfigService.findConfigFromCache().get(AcsConfig.ONEPOINTMAXTASK); - specialOrdinarySiteDeviceDriver.setIslock(true); - if (taskServer.checkAllowCreate(next_device_code) >= Integer.parseInt(maxTaskNum)) { - continue; - } - - if (specialOrdinarySiteDeviceDriver.hasGoods == 0 && !StrUtil.equals(nextdevice.getIslock(), "true")) { - dto.setMaterial("1"); - flag = true; - break; - } else { - continue; - } - } - - } - if (!flag) { - return false; - } - - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setStart_device_code(this.getDevice().getDevice_code()); - dto.setNext_point_code(next_device_code); - dto.setNext_device_code(next_device_code); - dto.setUpdate_time(now); - dto.setCreate_time(now); - dto.setMaterial(material); - try { - taskServer.create(dto); - } catch (Exception e) { - e.printStackTrace(); - } - JSONObject jo = new JSONObject(); - jo.put("device_code", next_device_code); - jo.put("islock", "true"); - deviceService.changeDeviceStatus(jo); - - JSONObject jo1 = new JSONObject(); - jo1.put("device_code", this.getDevicecode()); - jo1.put("islock", "true"); - - deviceService.changeDeviceStatus(jo1); - requireSucess = true; - branchProtocol = 0; - return true; - } - } - - /** - * 请求任务 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routeLineServer.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - try { - taskServer.create(dto); - } catch (Exception e) { - e.printStackTrace(); - } - requireSucess = false; - branchProtocol = 0; - return true; - } - } - - /** - * 请求任务 - * - * @param - * @param - */ - public synchronized boolean instruction_require(String material, String qty, String remark, String purpose) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(""); - dto.setVehicle_type(""); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - dto.setMaterial(this.getMaterial()); - dto.setQuantity(new BigDecimal(this.getQty())); - RouteLineDto jo = routeLineServer.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - - Device purposedevice = appService.findDeviceByCode(purpose); - SpecialOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver = null; - if (purposedevice.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) purposedevice.getDeviceDriver(); - standardOrdinarySiteDeviceDriver.setBranchProtocol(0); - standardOrdinarySiteDeviceDriver.setPurpose(null); - standardOrdinarySiteDeviceDriver.setRemark(null); - } - dto.setNext_point_code(purpose); - dto.setUpdate_time(now); - dto.setCreate_time(now); - dto.setRemark(getRemark()); - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - last_branchProtocol = 2; - this.setBranchProtocol(0); - this.setRemark(null); - this.setPurpose(null); - this.setRequireSucess(true); - return true; - } - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor/ItemProtocol.java deleted file mode 100644 index bd81d1b..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor/ItemProtocol.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.nl.acs.device_driver.standard_autodoor; - -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; - -import java.util.ArrayList; -import java.util.List; - -@Slf4j -public class ItemProtocol { - public static String item_heartbeat = "heartbeat"; - public static String item_mode = "mode"; - public static String item_action = "action"; - public static String item_error = "error"; - public static String item_to_command = "to_command"; - - - private StandardAutodoorDeviceDriver driver; - - public ItemProtocol(StandardAutodoorDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - log.error("读取错误!"); - } else { - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB51.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB51.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_action, "动作信号", "DB51.B2")); - list.add(new ItemDto(item_error, "报警信号", "DB51.B4")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB52.W2", Boolean.valueOf(true))); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor/StandardAutodoorDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor/StandardAutodoorDefination.java deleted file mode 100644 index 5b6b3fd..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor/StandardAutodoorDefination.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.nl.acs.device_driver.standard_autodoor; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 自动门驱动定义 - */ -@Service -public class StandardAutodoorDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_autodoor"; - } - - @Override - public String getDriverName() { - return "标准版-自动门"; - } - - @Override - public String getDriverDescription() { - return "标准版-自动门"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardAutodoorDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return StandardAutodoorDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", true)); - list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B4")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor/StandardAutodoorDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor/StandardAutodoorDeviceDriver.java deleted file mode 100644 index 4f1c09f..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_autodoor/StandardAutodoorDeviceDriver.java +++ /dev/null @@ -1,163 +0,0 @@ -package org.nl.acs.device_driver.standard_autodoor; - -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.opc.Device; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.task.service.TaskService; -import org.nl.utils.SpringContextHolder; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -/** - * 自动门驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - String devicecode; - int mode = 0; - int action = 0; - int error = 0; - Boolean iserror = false; - - int move = 0; - int task = 0; - int last_action = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - protected boolean hasGoods = false; - boolean isFold = false; - private String assemble_check_tag; - private Boolean sampleMode0; - private Boolean sampleMode3; - private Integer sampleError; - private Boolean sampleOnline; - protected String displayMessage = null; - public int display_message_time_out = 30000; - public Date display_message_time; - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - - String device_code = this.getDevice().getDevice_code(); - mode = this.itemProtocol.getMode(); - action = this.itemProtocol.getAction(); - error = this.itemProtocol.getError(); - if (mode != last_mode) { - } - if (action != last_action) { - } - if (error != last_error) { - //this.execute_log.setContainer(""); - } - last_action = action; - last_mode = mode; - last_error = error; - //message = StringFormatUtl.format("设备报警:{}", new Object[]{}); - -// String manual_create_task = this.getDevice().getExtraValue().get("manual_create_task").toString(); - - } - - public synchronized String getStatus() { - JSONObject jo = new JSONObject(); - - if (action == 1) { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "OPEN"); - - } else if (action == 2) { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "CLOSE"); - - } else { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "ERROR"); - } - return jo.toString(); - } - - - public void writeing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - ReadUtil.write(itemMap, server); - log.info("下发PLC信号:{},{}", to_command, command); - System.out.println("设备:" + devicecode + ",下发PLC信号:" + to_command + ",value:" + command); - - } - - public synchronized void OpenOrClose(String type) { - - //开门 - if ("1".equals(type)) { - writeing(1); - } else { - writeing(2); - } - - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/ItemProtocol.java deleted file mode 100644 index 7d368cf..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/ItemProtocol.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.nl.acs.device_driver.standard_conveyor_control; - -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_ioaction = "ioaction"; - public static String item_height = "height"; - public static String item_error = "error"; - public static String item_direction = "direction"; - public static String item_operation_type = "operation_type"; - public static String item_task = "task"; - - public static String item_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_task = "to_task"; - public static String item_weight = "weight"; - - private StandardCoveyorControlDeviceDriver driver; - - public ItemProtocol(StandardCoveyorControlDeviceDriver 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 getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getOperation_type() { - return this.getOpcIntegerValue(item_operation_type); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getToTarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getToTask() { - return this.getOpcIntegerValue(item_to_task); - } - - - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_move, "光电开关信号", "DB600.B2")); - list.add(new ItemDto(item_action, "取放信号", "DB600.B3")); - list.add(new ItemDto(item_ioaction, "进出类型", "DB600.B4")); - list.add(new ItemDto(item_height, "高度类型", "DB600.B5")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(item_direction, "电机方向", "DB600.B7")); - list.add(new ItemDto(item_operation_type, "作业类型", "DB600.B8")); - list.add(new ItemDto(item_task, "任务号", "DB600.D22")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_target, "目标站", "DB601.W4")); - list.add(new ItemDto(item_to_task, "任务号", "DB601.D8")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/StandardConveyorControlDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/StandardConveyorControlDefination.java deleted file mode 100644 index 2d9aa72..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/StandardConveyorControlDefination.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.nl.acs.device_driver.standard_conveyor_control; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 检测站点驱动定义 - * 说明:该站点为普通带光电检测站点 - */ -@Service -public class StandardConveyorControlDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_conveyor_control"; - } - - @Override - public String getDriverName() { - return "标准版-输送机-控制点"; - } - - @Override - public String getDriverDescription() { - return "标准版-输送机-控制点"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardCoveyorControlDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return StandardCoveyorControlDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_ioaction, "进出类型", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_height, "高度类型", "DB600.B5")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(ItemProtocol.item_direction, "电机方向", "DB600.B7")); - list.add(new ItemDto(ItemProtocol.item_operation_type, "作业类型", "DB600.B8")); - list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB600.D22")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/StandardCoveyorControlDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/StandardCoveyorControlDeviceDriver.java deleted file mode 100644 index d4e15b0..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control/StandardCoveyorControlDeviceDriver.java +++ /dev/null @@ -1,438 +0,0 @@ -package org.nl.acs.device_driver.standard_conveyor_control; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -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.config.server.AcsConfigService; -import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 输送机-控制点驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class StandardCoveyorControlDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - @Autowired - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - int mode = 0; - int error = 0; - int move = 0; - int task = 0; - //出入库模式 - int operation_type = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - private Date instruction_apply_time = new Date(); - private int instruction_require_time_out = 3000; - //请求成功标记 - Boolean requireSucess = false; - //申请指令成功标记 - Boolean applySucess = false; - String inst_message; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - String material; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - //申请搬运任务 - private Boolean apply_handling = false; - //申请物料 - private Boolean apply_material = false; - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag = 0; - - String device_code; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() throws Exception { - String message = null; - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - error = this.itemProtocol.getError(); - move = this.itemProtocol.getMove(); - task = this.itemProtocol.getTask(); - hasGoods = this.itemProtocol.getMove(); - operation_type = this.itemProtocol.getOperation_type(); - if (mode != last_mode) { - } - if (move != last_move) { - if (move == 0) { - thingToNothing(); - } - this.setRequireSucess(false); - - } - if (error != last_error) { - } - - if (mode == 2 && move != 0 && task > 0) { - //inst_message - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - if (inst != null) { - inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); - if (StrUtil.equals(inst.getInstruction_status(), "1") && StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { - finish_instruction(); - } - if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { - inst.setInstruction_status("1"); - instructionService.update(inst); - } - } - } - } catch (Exception var17) { - return; - } - - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 2: - //申请任务 - if (!StrUtil.isEmpty(material) && !StrUtil.isEmpty(qty) && material.length() > 0 && qty.length() > 0 && !requireSucess) { - this.instruction_require(container); - } - break; - case 3: - - break; - case 4: - //叫料 - - break; - case 5: - //申请空盘 - if (move == 0 && !requireSucess) { - apply_OutEmpty(); - } - break; - case 6: - //申请入库 - if (move != 0 && !applySucess) { - instruction_apply(); - } - if (move != 0 && !requireSucess) { - apply_InEmpty(); - } - break; - } - - - switch (flag) { - //取货完成 - case 1: - writing(2); - break; - //放货完成 - case 2: - writing(3); - break; - - } - - } - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - } - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.setRequireSucess(false); - this.setApplySucess(false); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.setInst_message(null); - this.setContainer(null); - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - if (appendMessage == null) { - appendMessage = ""; - } - if (instruction != null) { - instruction_num = Integer.parseInt(instruction.getInstruction_code()); - } - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, 1); - itemMap.put(to_task, instruction_num); - ReadUtil.write(itemMap, server); - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - ReadUtil.write(itemMap, server); - - } - - public void writing(int command, int target, int task) { - - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - itemMap.put(to_target, target); - itemMap.put(to_task, task); - ReadUtil.write(itemMap, server); - } - - public void writing(int type, int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - if (type == 1) { - itemMap.put(to_command, command); - } else if (type == 2) { - itemMap.put(to_target, command); - - } else if (type == 3) { - itemMap.put(to_task, command); - } - ReadUtil.write(itemMap, server); - - } - - public boolean instruction_apply() throws Exception { - return false; - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } - - public void apply_OutEmpty() { - - } - - public synchronized boolean apply_InEmpty() throws Exception { - return false; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_plcscanner/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_plcscanner/ItemProtocol.java deleted file mode 100644 index ca6f68e..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_plcscanner/ItemProtocol.java +++ /dev/null @@ -1,162 +0,0 @@ -package org.nl.acs.device_driver.standard_conveyor_control_with_plcscanner; - -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_ioaction = "ioaction"; - public static String item_height = "height"; - public static String item_error = "error"; - public static String item_direction = "direction"; - public static String item_operation_type = "operation_type"; - public static String item_barcode = "barcode"; - public static String item_weight = "weight"; - public static String item_task = "task"; - - public static String item_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_task = "to_task"; - - private StandardCoveyorControlWithPlcScannerDeviceDriver driver; - - public ItemProtocol(StandardCoveyorControlWithPlcScannerDeviceDriver 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 String getBarcode() { - return this.getOpcStringValue(item_barcode); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - public int getIoAction() { - return this.getOpcIntegerValue(item_ioaction); - } - - public int getHeight() { - return this.getOpcIntegerValue(item_height); - } - - public int getDirection() { - return this.getOpcIntegerValue(item_direction); - } - - public int getOperation_type() { - return this.getOpcIntegerValue(item_operation_type); - } - - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getToTarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getToTask() { - return this.getOpcIntegerValue(item_to_task); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!"); - setIsonline(false); - } else { - setIsonline(true); - return value; - } - return 0; - - } - - public int[] getOpcIntegerArrayValue(String protocol) { - int[] value = this.driver.getIntegeregerArrayValue(protocol); - if (value == null) { - //throw new BusinessException("{} : {}", new Object[]{protocol, DeviceErrorProtocol.getMessage(10000)}); - } else { - return value; - } - return value; - } - - - public String getOpcStringValue(String protocol) { - String value = this.driver.getStringValue(protocol); - if (value == null) { - //throw new BusinessException("{} : {}", new Object[]{protocol, DeviceErrorProtocol.getMessage(10000)}); - - } else { - return value; - } - return "0"; - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_move, "光电开关信号", "DB600.B2")); - list.add(new ItemDto(item_action, "取放信号", "DB600.B3")); - list.add(new ItemDto(item_ioaction, "进出类型", "DB600.B4")); - list.add(new ItemDto(item_height, "高度类型", "DB600.B5")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(item_direction, "电机方向", "DB600.B7")); - list.add(new ItemDto(item_operation_type, "作业类型", "DB600.B8")); - list.add(new ItemDto(item_task, "任务号", "DB600.D22")); - list.add(new ItemDto(item_barcode, "托盘号", "DB600.S26")); - - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_target, "目标站", "DB601.W4")); - list.add(new ItemDto(item_to_task, "任务号", "DB601.D8")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_plcscanner/StandardConveyorControlWithPlcScannerDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_plcscanner/StandardConveyorControlWithPlcScannerDefination.java deleted file mode 100644 index 97af9aa..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_plcscanner/StandardConveyorControlWithPlcScannerDefination.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.nl.acs.device_driver.standard_conveyor_control_with_plcscanner; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 输送机-控制点-PLC扫码器驱动定义 - */ -@Service -public class StandardConveyorControlWithPlcScannerDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_conveyor_control_with_plcscanner"; - } - - @Override - public String getDriverName() { - return "标准版-输送机-控制点-PLC扫码器"; - } - - @Override - public String getDriverDescription() { - return "标准版-输送机-控制点-PLC扫码器"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardCoveyorControlWithPlcScannerDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return StandardCoveyorControlWithPlcScannerDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_ioaction, "进出类型", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_height, "高度类型", "DB600.B5")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(ItemProtocol.item_direction, "电机方向", "DB600.B7")); - list.add(new ItemDto(ItemProtocol.item_operation_type, "作业类型", "DB600.B8")); - list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB600.D22")); - list.add(new ItemDto(ItemProtocol.item_barcode, "托盘号", "DB600.S26")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_plcscanner/StandardConveyorWithPlcScannerConfig.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_plcscanner/StandardConveyorWithPlcScannerConfig.java deleted file mode 100644 index 7f5a6d1..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_plcscanner/StandardConveyorWithPlcScannerConfig.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.nl.acs.device_driver.standard_conveyor_control_with_plcscanner; - -public class StandardConveyorWithPlcScannerConfig { - public static String relation_scanner = "link_scanner"; - public static String ignoreInstructionCheck = "ignoreInstructionCheck"; - public static String empty_tray_in = "emptyTrayIn"; - public static String empty_tray_out = "emptyTrayOut"; - public static String execute_time_out = "executeTimeOut"; - - public StandardConveyorWithPlcScannerConfig() { - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_plcscanner/StandardCoveyorControlWithPlcScannerDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_plcscanner/StandardCoveyorControlWithPlcScannerDeviceDriver.java deleted file mode 100644 index e698d37..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_plcscanner/StandardCoveyorControlWithPlcScannerDeviceDriver.java +++ /dev/null @@ -1,839 +0,0 @@ -package org.nl.acs.device_driver.standard_conveyor_control_with_plcscanner; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.ObjectUtils; -import org.nl.acs.config.AcsConfig; -import org.nl.acs.config.server.AcsConfigService; -import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.service.AcsToWmsService; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; - -import java.util.*; - -/** - * 输送机控制点-带扫描驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class StandardCoveyorControlWithPlcScannerDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); - ; - - String barcode = null; - String formatcode = null; - - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - int mode = 0; - int error = 0; - int move = 0; - int task = 0; - int height = 0; - int action = 0; - int ioaction = 0; - int direction = 0; - int operation_type = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - String foramteBarcode = null; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - String str = null; - String inst_message; - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - private Date instruction_apply_time = new Date(); - private int instruction_require_time_out = 3000; - //请求成功标记 - Boolean requireSucess = false; - //申请指令成功标记 - Boolean applySucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - String material; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - //申请搬运任务 - private Boolean apply_handling = false; - //申请物料 - private Boolean apply_material = false; - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag; - - String device_code; - - - @Override - public Device getDevice() { - return this.device; - } - - @Override - public void execute() throws Exception { - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - error = this.itemProtocol.getError(); - move = this.itemProtocol.getMove(); - task = this.itemProtocol.getTask(); - action = this.itemProtocol.getAction(); - ioaction = this.itemProtocol.getIoAction(); - height = this.itemProtocol.getHeight(); - operation_type = this.itemProtocol.getOperation_type(); - direction = this.itemProtocol.getDirection(); - hasGoods = this.itemProtocol.getMove(); - barcode = this.itemProtocol.getBarcode(); - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (move != last_move) { - if (move == 0) { - thingToNothing(); - } - } - if (error != last_error) { - } - if (mode == 2 && move != 0 && task > 0) { - //inst_message - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - if (inst != null) { - inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); - if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { - inst.setInstruction_status("1"); - instructionService.update(inst); - } - if (StrUtil.equals(inst.getInstruction_status(), "1") && StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { - finish_instruction(); - } - } - } - - if (!StrUtil.equals(this.getBarcode(), "0")) { - message = this.getBarcode(); - } - } catch (Exception var17) { - return; - } - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 2: - //申请任务 - if (hasGoods > 0 && !StrUtil.equals("0", barcode) && height > 0 && !requireSucess) { - instruction_require(barcode); - } - if (hasGoods > 0 && !StrUtil.equals("0", barcode) && height > 0 && !applySucess) { - instruction_apply(barcode); - } - } - switch (flag) { - //取货完成 - case 1: - writing(2); - break; - //放货完成 - case 2: - writing(3); - break; - - } - } - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - } - - private void forametPlcBarcode(int[] plcbarcode) { - StringBuffer sb = new StringBuffer(); - for (int i = 0; i < plcbarcode.length; i++) { - int a = plcbarcode[i]; - sb.append(stringToascii(a)); - } - foramteBarcode = sb.toString(); - } - - public String stringToascii(int num) { - String str = ""; - switch (num) { - case 48: - str = "0"; - break; - case 49: - str = "1"; - break; - case 50: - str = "2"; - break; - case 51: - str = "3"; - break; - case 52: - str = "4"; - break; - case 53: - str = "5"; - break; - case 54: - str = "6"; - break; - case 55: - str = "7"; - break; - case 56: - str = "8"; - break; - case 57: - str = "9"; - break; - case 65: - str = "A"; - break; - case 66: - str = "B"; - break; - case 67: - str = "C"; - break; - case 68: - str = "D"; - break; - case 69: - str = "E"; - break; - case 70: - str = "F"; - break; - case 71: - str = "G"; - break; - case 72: - str = "H"; - break; - case 73: - str = "I"; - break; - case 74: - str = "J"; - break; - case 75: - str = "K"; - break; - case 76: - str = "L"; - break; - case 77: - str = "M"; - break; - case 78: - str = "N"; - break; - case 79: - str = "O"; - break; - case 80: - str = "P"; - break; - case 81: - str = "Q"; - break; - case 82: - str = "R"; - break; - case 83: - str = "S"; - break; - case 84: - str = "T"; - break; - case 85: - str = "U"; - break; - case 86: - str = "V"; - break; - case 87: - str = "W"; - break; - case 88: - str = "X"; - break; - case 89: - str = "Y"; - break; - case 90: - str = "Z"; - break; - - case 97: - str = "a"; - break; - case 98: - str = "b"; - break; - case 99: - str = "c"; - break; - case 100: - str = "d"; - break; - case 101: - str = "e"; - break; - case 102: - str = "f"; - break; - case 103: - str = "g"; - break; - case 104: - str = "h"; - break; - case 105: - str = "i"; - break; - case 106: - str = "j"; - break; - case 107: - str = "k"; - break; - case 108: - str = "l"; - break; - case 109: - str = "m"; - break; - case 110: - str = "n"; - break; - case 111: - str = "o"; - break; - case 112: - str = "p"; - break; - case 113: - str = "q"; - break; - case 114: - str = "r"; - break; - case 115: - str = "s"; - break; - case 116: - str = "t"; - break; - case 117: - str = "u"; - break; - case 118: - str = "v"; - break; - case 119: - str = "w"; - break; - case 120: - str = "x"; - break; - case 121: - str = "y"; - break; - case 122: - str = "z"; - break; - - case 40: - str = "("; - break; - case 41: - str = ")"; - break; - case 43: - str = "+"; - break; - case 45: - str = "-"; - break; - case 47: - str = "/"; - break; - case 91: - str = "["; - break; - case 93: - str = "]"; - break; - case 95: - str = "_"; - break; - default: - str = ""; - } - - return str; - } - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } - - protected void thingToNothing() throws Exception { - this.setBarcode(null); - this.setRequireSucess(false); - this.setApplySucess(false); - writing(1, 0); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.setInst_message(null); - this.setContainer(null); - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - if (appendMessage == null) { - appendMessage = ""; - } - if (instruction != null) { - instruction_num = Integer.parseInt(instruction.getInstruction_code()); - } - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, 1); - itemMap.put(to_task, instruction_num); - ReadUtil.write(itemMap, server); - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing() { - - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, 1); - itemMap.put(to_target, deviceAppservice.findDeviceByCode(inst.getNext_device_code()).getAddress()); - itemMap.put(to_task, inst.getInstruction_code()); - ReadUtil.write(itemMap, server); - } - - public void writing(int command, int target, int task) { - - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - itemMap.put(to_target, target); - itemMap.put(to_task, task); - - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - ReadUtil.write(itemMap, server); - } - - public void writing(int type, int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - if (type == 1) { - itemMap.put(to_command, command); - } else if (type == 2) { - itemMap.put(to_target, command); - - } else if (type == 3) { - itemMap.put(to_task, command); - } - - ReadUtil.write(itemMap, server); - } - - public boolean instruction_require(String container_code) throws Exception { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - @Transactional(rollbackFor = Exception.class) - public synchronized boolean instruction_apply(String container_code) throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - this.instruction_apply_time = date; - //container_code - TaskDto task = taskserver.findByContainer(container_code); - if (!ObjectUtil.isEmpty(task) && StrUtil.equals(task.getTask_status(), "0")) { - String taskid = task.getTask_id(); - String taskcode = task.getTask_code(); - String vehiclecode = task.getVehicle_code(); - String priority = task.getPriority(); - String start_point_code = task.getStart_point_code(); - String start_device_code = task.getStart_device_code(); - String route_plan_code = task.getRoute_plan_code(); - String next_device_code = ""; - - /** - * 开始平均分配 - */ - String this_device_code = taskserver.queryAssignedByDevice(device_code, task.getNext_device_code()); - if (StrUtil.isEmpty(this_device_code)) { - List shortPathsList = routeLineService.getShortPathLines(start_device_code, task.getNext_device_code(), route_plan_code); - RouteLineDto routeLineDto = shortPathsList.get(0); - - String path = routeLineDto.getPath(); - String type = routeLineDto.getType(); - String[] str = path.split("->"); - if (!StrUtil.equals(type, "0")) { - return false; - } - List pathlist = Arrays.asList(str); - int index = 0; - for (int m = 0; m < pathlist.size(); m++) { - if (pathlist.get(m).equals(start_device_code)) { - index = m + 1; - break; - } - } - next_device_code = pathlist.get(index); - } else { - next_device_code = this_device_code; - } - //校验路由关系 - List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); - if (ObjectUtils.isEmpty(shortPathsList)) { - throw new RuntimeException("路由不通!"); - } - - 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 = task.getTo_x() + "-" + task.getTo_y() + "-" + task.getTo_z(); - } else { - next_point_code = next_device_code; - } - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - 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("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setPriority(priority); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(start_point_code); - try { - instructionService.create(instdto); - } catch (Exception e) { - task.setRemark("指令创建失败:" + e); - taskserver.updateByCodeFromCache(task); - throw new RuntimeException("指令创建失败:" + e); - } - //创建指令后修改任务状态 - WQLObject taskwo = WQLObject.getWQLObject("acs_task"); - task.setTask_status("1"); - task.setRemark(null); - JSONObject json = (JSONObject) JSONObject.toJSON(task); - taskwo.update(json); - applySucess = true; - } else { - log.info("未找到载具号{}对应任务", barcode); - } - } - return true; - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - @Transactional(rollbackFor = Exception.class) - public synchronized boolean instruction_require(String container_code, String container_type) 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 { - this.instruction_require_time = date; - //container_code - TaskDto task = taskserver.findByContainer(container_code); - if (!ObjectUtil.isEmpty(task) && StrUtil.equals(task.getTask_status(), "0")) { - String taskid = task.getTask_id(); - String taskcode = task.getTask_code(); - String vehiclecode = task.getVehicle_code(); - String priority = task.getPriority(); - String start_point_code = task.getStart_point_code(); - String start_device_code = task.getStart_device_code(); - String route_plan_code = task.getRoute_plan_code(); - String next_device_code = ""; - - /** - * 开始平均分配 - */ - String this_device_code = taskserver.queryAssignedByDevice(device_code, task.getNext_device_code()); - if (StrUtil.isEmpty(this_device_code)) { - List shortPathsList = routeLineService.getShortPathLines(start_device_code, task.getNext_device_code(), route_plan_code); - RouteLineDto routeLineDto = shortPathsList.get(0); - - String path = routeLineDto.getPath(); - String type = routeLineDto.getType(); - String[] str = path.split("->"); - if (!StrUtil.equals(type, "0")) { - return false; - } - List pathlist = Arrays.asList(str); - int index = 0; - for (int m = 0; m < pathlist.size(); m++) { - if (pathlist.get(m).equals(start_device_code)) { - index = m + 1; - break; - } - } - next_device_code = pathlist.get(index); - } else { - next_device_code = this_device_code; - } - //校验路由关系 - List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); - if (ObjectUtils.isEmpty(shortPathsList)) { - throw new RuntimeException("路由不通!"); - } - - 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 = task.getTo_x() + "-" + task.getTo_y() + "-" + task.getTo_z(); - } else { - next_point_code = next_device_code; - } - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - 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("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setPriority(priority); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(start_point_code); - try { - instructionService.create(instdto); - } catch (Exception e) { - task.setRemark("指令创建失败:" + e); - taskserver.updateByCodeFromCache(task); - throw new RuntimeException("指令创建失败:" + e); - } - //创建指令后修改任务状态 - WQLObject taskwo = WQLObject.getWQLObject("acs_task"); - task.setTask_status("1"); - task.setRemark(null); - JSONObject json = (JSONObject) JSONObject.toJSON(task); - taskwo.update(json); - requireSucess = true; - applySucess = true; - } else { - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.HASWMS).toString(), "1")) { - String str = acsToWmsService.applyTaskToWms(this.getDeviceCode(), container_code, height, 0); - JSONObject jo = JSON.parseObject(str); - if (ObjectUtil.isEmpty(jo)) { - message = "接口不通"; - } else { - if (jo.getInteger("status") == 200) { - requireSucess = true; - } else { - requireSucess = false; - } - } - - } - } - return true; - } - } - - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_scanner/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_scanner/ItemProtocol.java deleted file mode 100644 index dae1985..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_scanner/ItemProtocol.java +++ /dev/null @@ -1,133 +0,0 @@ -package org.nl.acs.device_driver.standard_conveyor_control_with_scanner; - -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_ioaction = "ioaction"; - public static String item_height = "height"; - public static String item_error = "error"; - public static String item_direction = "direction"; - public static String item_operation_type = "operation_type"; - public static String item_task = "task"; - - public static String item_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_task = "to_task"; - public static String item_weight = "weight"; - - private StandardCoveyorControlWithScannerDeviceDriver driver; - - public ItemProtocol(StandardCoveyorControlWithScannerDeviceDriver 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 getIoAction() { - return this.getOpcIntegerValue(item_ioaction); - } - - public int getHeight() { - return this.getOpcIntegerValue(item_height); - } - - public int getDirection() { - return this.getOpcIntegerValue(item_direction); - } - - public int getOperation_type() { - return this.getOpcIntegerValue(item_operation_type); - } - - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getToTarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getToTask() { - return this.getOpcIntegerValue(item_to_task); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_move, "光电开关信号", "DB600.B2")); - list.add(new ItemDto(item_action, "取放信号", "DB600.B3")); - list.add(new ItemDto(item_ioaction, "进出类型", "DB600.B4")); - list.add(new ItemDto(item_height, "高度类型", "DB600.B5")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(item_direction, "电机方向", "DB600.B7")); - list.add(new ItemDto(item_operation_type, "作业类型", "DB600.B8")); - list.add(new ItemDto(item_task, "任务号", "DB600.D22")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_target, "目标站", "DB601.W4")); - list.add(new ItemDto(item_to_task, "任务号", "DB601.D8")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_scanner/StandardConveyorControlWithScannerDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_scanner/StandardConveyorControlWithScannerDefination.java deleted file mode 100644 index 56b2e28..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_scanner/StandardConveyorControlWithScannerDefination.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.nl.acs.device_driver.standard_conveyor_control_with_scanner; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 检测站点驱动定义 - * 说明:该站点为普通带光电检测站点 - */ -@Service -public class StandardConveyorControlWithScannerDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_conveyor_control_with_scanner"; - } - - @Override - public String getDriverName() { - return "标准版-输送机-控制点-关联扫码器"; - } - - @Override - public String getDriverDescription() { - return "标准版-输送机-控制点-关联扫码器"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardCoveyorControlWithScannerDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return StandardCoveyorControlWithScannerDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_ioaction, "进出类型", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_height, "高度类型", "DB600.B5")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(ItemProtocol.item_direction, "电机方向", "DB600.B7")); - list.add(new ItemDto(ItemProtocol.item_operation_type, "作业类型", "DB600.B8")); - list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB600.D22")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_scanner/StandardConveyorWithScannerConfig.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_scanner/StandardConveyorWithScannerConfig.java deleted file mode 100644 index d60206a..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_scanner/StandardConveyorWithScannerConfig.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.nl.acs.device_driver.standard_conveyor_control_with_scanner; - -public class StandardConveyorWithScannerConfig { - public static String relation_scanner = "link_scanner"; - public static String ignoreInstructionCheck = "ignoreInstructionCheck"; - public static String empty_tray_in = "emptyTrayIn"; - public static String empty_tray_out = "emptyTrayOut"; - public static String execute_time_out = "executeTimeOut"; - - public StandardConveyorWithScannerConfig() { - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java deleted file mode 100644 index ee9b37f..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_control_with_scanner/StandardCoveyorControlWithScannerDeviceDriver.java +++ /dev/null @@ -1,650 +0,0 @@ -package org.nl.acs.device_driver.standard_conveyor_control_with_scanner; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.ObjectUtils; -import org.nl.acs.config.AcsConfig; -import org.nl.acs.config.server.AcsConfigService; -import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.ScannerDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 输送机控制点-带扫描驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - TaskService taskserver = SpringContextHolder.getBean(TaskService.class); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class); - ; - - protected String barcode = null; - protected String formatcode = null; - - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - int mode = 0; - int error = 0; - int move = 0; - int task = 0; - int height = 0; - int action = 0; - int ioaction = 0; - int direction = 0; - int operation_type = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - String inst_message; - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - private Date instruction_apply_time = new Date(); - private int instruction_require_time_out = 3000; - //请求成功标记 - Boolean requireSucess = false; - //申请指令成功标记 - Boolean applySucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - String material; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - //申请搬运任务 - private Boolean apply_handling = false; - //申请物料 - private Boolean apply_material = false; - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag; - - String device_code; - - public boolean exe_declaration() { - try { - this.barcode = this.barcode(); - this.formatcode = this.formatBarcode(); - return true; - } catch (Exception var3) { - String message = "获取条码异常"; - return false; - } - } - - public String formatBarcode() throws Exception { - String barcode = this.barcode(); - if (!StrUtil.isEmpty(barcode)) { - barcode = barcode.trim(); - } - - return barcode; - } - - public String barcode() throws Exception { - ScannerDeviceDriver scanner = this.getScanner(); - return scanner.readBarcode(); - } - - public void clearBarcode() throws Exception { - ScannerDeviceDriver scanner = this.getScanner(); - scanner.cleanBarcode(); - } - - - private ScannerDeviceDriver getScanner() throws Exception { - String scanner_code = (String) this.getDevice().getExtraValue().get(StandardConveyorWithScannerConfig.relation_scanner); - if (StrUtil.isEmpty(scanner_code)) { - throw new Exception("未配置读码器"); - } else { - Device device = deviceAppservice.findDeviceByCode(scanner_code); - if (device == null) { - throw new Exception("无设备:" + scanner_code); - } else { - DeviceDriver deviceDriver = device.getDeviceDriver(); - if (!(deviceDriver instanceof ScannerDeviceDriver)) { - throw new Exception("扫码器类型不对,不是ScannerDeviceDriver"); - } else { - ScannerDeviceDriver driver = (ScannerDeviceDriver) deviceDriver; - return driver; - } - } - } - } - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() throws Exception { - String message = null; - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - error = this.itemProtocol.getError(); - move = this.itemProtocol.getMove(); - task = this.itemProtocol.getTask(); - action = this.itemProtocol.getAction(); - ioaction = this.itemProtocol.getIoAction(); - height = this.itemProtocol.getHeight(); - operation_type = this.itemProtocol.getOperation_type(); - direction = this.itemProtocol.getDirection(); - hasGoods = this.itemProtocol.getMove(); - - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (move != last_move) { - if (move == 0) { - thingToNothing(); - } - } - if (error != last_error) { - } - if (mode == 2 && move != 0 && task > 0) { - //inst_message - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - if (inst != null) { - inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); - if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { - inst.setInstruction_status("1"); - instructionService.update(inst); - } - if (StrUtil.equals(inst.getInstruction_status(), "1") && StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { - finish_instruction(); - } - } - } - - if (getBarcode() != null) { - - } - } catch (Exception var17) { - return; - } - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 2: - //申请任务 - if (hasGoods > 0 && !StrUtil.isEmpty(barcode()) && height > 0 && !requireSucess) { - instruction_require(barcode()); - } - if (hasGoods > 0 && !StrUtil.isEmpty(barcode()) && height > 0 && !applySucess) { - instruction_apply(barcode()); - } - } - switch (flag) { - //取货完成 - case 1: - writing(2); - break; - //放货完成 - case 2: - writing(3); - break; - - } - } - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - } - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } - - protected void thingToNothing() throws Exception { - this.setBarcode(null); - this.setRequireSucess(false); - this.setApplySucess(false); - clearBarcode(); - writing(1, 0); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.setInst_message(null); - this.setContainer(null); - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - if (appendMessage == null) { - appendMessage = ""; - } - if (instruction != null) { - instruction_num = Integer.parseInt(instruction.getInstruction_code()); - } - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, 1); - itemMap.put(to_task, instruction_num); - ReadUtil.write(itemMap, server); - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing() { - - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, 1); - itemMap.put(to_target, deviceAppservice.findDeviceByCode(inst.getNext_device_code()).getAddress()); - itemMap.put(to_task, inst.getInstruction_code()); - ReadUtil.write(itemMap, server); - } - - public void writing(int command, int target, int task) { - - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - itemMap.put(to_target, target); - itemMap.put(to_task, task); - - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - ReadUtil.write(itemMap, server); - } - - public void writing(int type, int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - if (type == 1) { - itemMap.put(to_command, command); - } else if (type == 2) { - itemMap.put(to_target, command); - - } else if (type == 3) { - itemMap.put(to_task, command); - } - - ReadUtil.write(itemMap, server); - } - - public boolean instruction_require(String container_code) throws Exception { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - public synchronized boolean instruction_apply(String container_code) throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out); - return false; - } else { - this.instruction_apply_time = date; - //container_code - TaskDto task = taskserver.findByContainer(container_code); - if (!ObjectUtil.isEmpty(task)) { - String taskid = task.getTask_id(); - String taskcode = task.getTask_code(); - String vehiclecode = task.getVehicle_code(); - String priority = task.getPriority(); - String start_point_code = task.getStart_point_code(); - String start_device_code = task.getStart_device_code(); - String route_plan_code = task.getRoute_plan_code(); - String next_device_code = ""; - - /** - * 开始平均分配 - */ - String this_device_code = taskserver.queryAssignedByDevice(device_code, task.getNext_device_code()); - if (StrUtil.isEmpty(this_device_code)) { - List shortPathsList = routeLineService.getShortPathLines(start_device_code, task.getNext_device_code(), route_plan_code); - RouteLineDto routeLineDto = shortPathsList.get(0); - - String path = routeLineDto.getPath(); - String type = routeLineDto.getType(); - String[] str = path.split("->"); - if (!StrUtil.equals(type, "0")) { - return false; - } - List pathlist = Arrays.asList(str); - int index = 0; - for (int m = 0; m < pathlist.size(); m++) { - if (pathlist.get(m).equals(start_device_code)) { - index = m + 1; - break; - } - } - next_device_code = pathlist.get(index); - } else { - next_device_code = this_device_code; - } - //校验路由关系 - List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); - if (ObjectUtils.isEmpty(shortPathsList)) { - throw new RuntimeException("路由不通!"); - } - - 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 = task.getTo_x() + "-" + task.getTo_y() + "-" + task.getTo_z(); - } else { - next_point_code = next_device_code; - } - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - 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("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setPriority(priority); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(start_point_code); - instructionService.create(instdto); - //创建指令后修改任务状态 - WQLObject taskwo = WQLObject.getWQLObject("acs_task"); - - task.setTask_status("1"); - //创建指令后修改任务状态 - task.setTask_status("1"); - taskserver.update(task); - - applySucess = true; - } else { - log.info("未找到载具号{}对应任务", container_code); - } - } - return true; - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) 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 { - this.instruction_require_time = date; - //container_code - TaskDto task = taskserver.findByContainer(container_code); - if (!ObjectUtil.isEmpty(task)) { - if(!ObjectUtils.isEmpty(instructionService.findByBarcodeFromCache(container_code))){ - return false; - } - String taskid = task.getTask_id(); - String taskcode = task.getTask_code(); - String vehiclecode = task.getVehicle_code(); - String priority = task.getPriority(); - String start_point_code = task.getStart_point_code(); - String start_device_code = task.getStart_device_code(); - String route_plan_code = task.getRoute_plan_code(); - String next_device_code = ""; - - /** - * 开始平均分配 - */ - String this_device_code = taskserver.queryAssignedByDevice(device_code, task.getNext_device_code()); - if (StrUtil.isEmpty(this_device_code)) { - List shortPathsList = routeLineService.getShortPathLines(start_device_code, task.getNext_device_code(), route_plan_code); - RouteLineDto routeLineDto = shortPathsList.get(0); - - String path = routeLineDto.getPath(); - String type = routeLineDto.getType(); - String[] str = path.split("->"); - if (!StrUtil.equals(type, "0")) { - return false; - } - List pathlist = Arrays.asList(str); - int index = 0; - for (int m = 0; m < pathlist.size(); m++) { - if (pathlist.get(m).equals(start_device_code)) { - index = m + 1; - break; - } - } - next_device_code = pathlist.get(index); - } else { - next_device_code = this_device_code; - } - //校验路由关系 - List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); - if (ObjectUtils.isEmpty(shortPathsList)) { - throw new RuntimeException("路由不通!"); - } - - 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 = task.getTo_x() + "-" + task.getTo_y() + "-" + task.getTo_z(); - } else { - next_point_code = next_device_code; - } - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - 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("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setPriority(priority); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(start_point_code); - instructionService.create(instdto); - //创建指令后修改任务状态 - task.setTask_status("1"); - taskserver.update(task); - requireSucess = true; - applySucess = true; - } else { - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.HASWMS).toString(), "1")) { - message = "申请任务中..."; - String str = acsToWmsService.applyTaskToWms(this.getDeviceCode(), container_code, height, 0); - JSONObject jo = JSON.parseObject(str); - if (ObjectUtil.isEmpty(jo)) { - message = "接口不通"; - } else { - if (jo.getInteger("status") == 200) { - requireSucess = true; - } else { - requireSucess = false; - message = jo.get("message").toString(); - } - } - - } - } - return true; - } - } - - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_monitor/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_monitor/ItemProtocol.java deleted file mode 100644 index c6f74ef..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_monitor/ItemProtocol.java +++ /dev/null @@ -1,113 +0,0 @@ -package org.nl.acs.device_driver.standard_conveyor_monitor; - -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_ioaction = "ioaction"; - public static String item_height = "height"; - public static String item_error = "error"; - public static String item_direction = "direction"; - public static String item_operation_type = "operation_type"; - public static String item_task = "task"; - - public static String item_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_task = "to_task"; - public static String item_weight = "weight"; - - private StandardCoveyorMonitorDeviceDriver driver; - - public ItemProtocol(StandardCoveyorMonitorDeviceDriver 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 getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getToTarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getToTask() { - return this.getOpcIntegerValue(item_to_task); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_move, "光电开关信号", "DB600.B2")); - list.add(new ItemDto(item_action, "取放信号", "DB600.B3")); - list.add(new ItemDto(item_ioaction, "进出类型", "DB600.B4")); - list.add(new ItemDto(item_height, "高度类型", "DB600.B5")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(item_direction, "电机方向", "DB600.B7")); - list.add(new ItemDto(item_operation_type, "作业类型", "DB600.B8")); - list.add(new ItemDto(item_task, "任务号", "DB600.D22")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_monitor/StandardConveyorMonitorDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_monitor/StandardConveyorMonitorDefination.java deleted file mode 100644 index e923429..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_monitor/StandardConveyorMonitorDefination.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.nl.acs.device_driver.standard_conveyor_monitor; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 输送机-监控点驱动定义 - * 说明:该站点为普通带光电检测站点 - */ -@Service -public class StandardConveyorMonitorDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_conveyor_monitor"; - } - - @Override - public String getDriverName() { - return "标准版-输送机-监控点"; - } - - @Override - public String getDriverDescription() { - return "标准版-输送机-监控点"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardCoveyorMonitorDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return StandardCoveyorMonitorDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_ioaction, "进出类型", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_height, "高度类型", "DB600.B5")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(ItemProtocol.item_direction, "电机方向", "DB600.B7")); - list.add(new ItemDto(ItemProtocol.item_operation_type, "作业类型", "DB600.B8")); - list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB600.D22")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_monitor/StandardCoveyorMonitorDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_monitor/StandardCoveyorMonitorDeviceDriver.java deleted file mode 100644 index 660a015..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_conveyor_monitor/StandardCoveyorMonitorDeviceDriver.java +++ /dev/null @@ -1,358 +0,0 @@ -package org.nl.acs.device_driver.standard_conveyor_monitor; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.StrUtil; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 输送机-监控点驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class StandardCoveyorMonitorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - int mode = 0; - int error = 0; - int move = 0; - int task = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - String material; - //当前指令 - Instruction inst = null; - String inst_message; - - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - //申请搬运任务 - private Boolean apply_handling = false; - //申请物料 - private Boolean apply_material = false; - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag; - - String devicecode; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() throws Exception { - String message = null; - try { - String device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - error = this.itemProtocol.getError(); - move = this.itemProtocol.getMove(); - task = this.itemProtocol.getTask(); - hasGoods = this.itemProtocol.getMove(); - - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (move != last_move) { - } - if (error != last_error) { - } - } catch (Exception var17) { - return; - } - - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - return; - case 2: - if (mode == 2 && move != 0 && task > 0) { - //inst_message - inst = instructionService.findByCodeFromCache(String.valueOf(task)); - if (inst != null) { - inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); - if (StrUtil.equals(inst.getInstruction_status(), "1") && StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) { - finish_instruction(); - } - if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) { - inst.setInstruction_status("1"); - instructionService.update(inst); - } - } - } - return; - } - switch (flag) { - //取货完成 - case 1: - writing(2); - return; - //放货完成 - case 2: - writing(3); - return; - - } - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - } - - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - public synchronized boolean finish_instruction() throws Exception { - instructionService.finish(inst); - return true; - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - if (appendMessage == null) { - appendMessage = ""; - } - if (instruction != null) { - instruction_num = Integer.parseInt(instruction.getInstruction_code()); - } - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, 1); - itemMap.put(to_task, instruction_num); - ReadUtil.write(itemMap, server); - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - ReadUtil.write(itemMap, server); - - } - - public void writing(int type, int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - if (type == 1) { - itemMap.put(to_command, command); - } else if (type == 2) { - itemMap.put(to_target, command); - - } else if (type == 3) { - itemMap.put(to_task, command); - } - ReadUtil.write(itemMap, server); - - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setStart_device_code(this.getDevice().getDevice_code()); - - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_device_code(next_device_codecode); - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - try { - taskserver.create(dto); - } catch (Exception e) { - e.printStackTrace(); - } - requireSucess = false; - return true; - } - } - - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_emptypallet_site/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_emptypallet_site/ItemProtocol.java deleted file mode 100644 index 7f74f5d..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_emptypallet_site/ItemProtocol.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.nl.acs.device_driver.standard_emptypallet_site; - -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_number = "number"; - public static String item_error = "error"; - public static String item_task = "task"; - public static String item_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_task = "to_task"; - - private StandardEmptyPalletSiteDeviceDriver driver; - - public ItemProtocol(StandardEmptyPalletSiteDeviceDriver 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 getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getNumber() { - return this.getOpcIntegerValue(item_number); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getToTarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getToTask() { - return this.getOpcIntegerValue(item_to_task); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_move, "光电开关信号", "DB600.B2")); - list.add(new ItemDto(item_number, "数量", "DB600.B3")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B5")); - list.add(new ItemDto(item_task, "任务号", "DB600.D6")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_target, "目标站", "DB601.W4")); - list.add(new ItemDto(item_to_task, "任务号", "DB601.D8")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_emptypallet_site/StandardEmptyPalletSiteDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_emptypallet_site/StandardEmptyPalletSiteDefination.java deleted file mode 100644 index dfcd287..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_emptypallet_site/StandardEmptyPalletSiteDefination.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.nl.acs.device_driver.standard_emptypallet_site; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 空盘堆叠站点驱动定义 - * 说明:该站点为普通带光电检测站点 - */ -@Service -public class StandardEmptyPalletSiteDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_emptypallet_site"; - } - - @Override - public String getDriverName() { - return "标准版-空盘堆叠站点"; - } - - @Override - public String getDriverDescription() { - return "标准版-空盘堆叠站点"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardEmptyPalletSiteDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return StandardEmptyPalletSiteDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", true)); - list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_number, "数量", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B5")); - list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB600.D6")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_emptypallet_site/StandardEmptyPalletSiteDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_emptypallet_site/StandardEmptyPalletSiteDeviceDriver.java deleted file mode 100644 index dee4d3d..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_emptypallet_site/StandardEmptyPalletSiteDeviceDriver.java +++ /dev/null @@ -1,505 +0,0 @@ -package org.nl.acs.device_driver.standard_emptypallet_site; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -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.config.AcsConfig; -import org.nl.acs.config.server.AcsConfigService; -import org.nl.acs.config.server.impl.AcsConfigServiceImpl; -import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 空盘堆叠站点驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class StandardEmptyPalletSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - @Autowired - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigServiceImpl.class); - @Autowired - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - @Autowired - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - String devicecode; - int mode = 0; - int error = 0; - int move = 0; - int task = 0; - int number = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - int last_number = 0; - Boolean isonline = true; - Boolean iserror = false; - - int hasGoods = 0; - String message = null; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - - public int display_message_time_out = 30000; - public Date display_message_time; - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - - try { - String device_code = this.getDeviceCode(); - int max_emptypalletnum = Integer.parseInt(this.getDevice().getExtraValue().get("max_emptypalletnum").toString()); - - mode = this.itemProtocol.getMode(); - error = this.itemProtocol.getError(); - move = this.itemProtocol.getMove(); - task = this.itemProtocol.getTask(); - number = this.itemProtocol.getNumber(); - hasGoods = this.itemProtocol.hasGoods(move); - - if (mode != last_mode) { - } - if (move != last_move) { - if (move == 0) { - requireSucess = false; - } - } - if (number != last_number) { - } - if (error != last_error) { - } - - - //急停 - if (this.isStop()) { - - - //未在线无心跳 - } else if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - return; - case 2: - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.HASWMS), "1")) { - if (number == max_emptypalletnum && !requireSucess && move > 0) { - apply_InEmpty(); - } - } else { - //当前数量等于最大数量,则生成搬运任务 - if (number == max_emptypalletnum && !requireSucess && move > 0) { - //判断逻辑 - //需要检查关联的另一设备也满足数量后才能入库 - Object[] linkobj = (Object[]) this.getDevice().getExtraValue().get("link_device_code"); - for (int i = 0; i < linkobj.length; i++) { - String linkDevice = linkobj[i].toString(); - Device device = appService.findDeviceByCode(linkDevice); - StandardEmptyPalletSiteDeviceDriver standardEmptyPalletSiteDeviceDriver; - if (device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) device.getDeviceDriver(); - if (Integer.parseInt(this.getDevice().getExtraValue().get("max_emptypalletnum").toString()) != standardEmptyPalletSiteDeviceDriver.getNumber()) { - return; - } - } - } - Object[] obj = (Object[]) this.getDevice().getExtraValue().get("garget_device_code"); - for (int i = 0; i < obj.length; i++) { - - String gargetDevice = obj[i].toString(); - Device device = appService.findDeviceByCode(gargetDevice); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (standardOrdinarySiteDeviceDriver.getMove() != 0) { - break; - } - } - boolean result = this.instruction_require("", this.getLast_container_type_desc(), gargetDevice); - if (result) { - break; - } - - } - } - } - break; - default: - - } - - - switch (branchProtocol) { - case 1: - if (this.getDevice().getIs_exist()) { - message = "出口:有货等待作业"; - - } else if (mode == 2) { - try { -// if (StrUtil.isEmpty(container)) { -// //判断条码是否为空,否则申请任务 -// return; -// } - - - } catch (Exception var21) { - message = "申请指令异常"; - log.debug("申请指令异常"); - } - } else { - message = "设备运转中, 待申请指令"; - log.debug("设备运转中, 待申请指令"); - } - break; - case 2: - if (mode == 2) { - try { - - this.executing(instruction); - - } catch (Exception var20) { - message = "指令下发异常"; - - } - } else { - message = "设备运转中,待下发指令"; - - } - break; - case 3: - if (mode == 2) { - try { - //执行中 - Instruction inst = instructionService.findByCodeFromCache(String.valueOf(instruction_num)); - if (StrUtil.equals(inst.getInstruction_status(), "1")) { - inst.setInstruction_status("1"); - instructionService.update(inst); - last_task = task; - } - - } catch (Exception var20) { - message = "指令异常"; - - } - } else { - message = "设备运转中"; - - } - break; - case 4: - if (mode == 2) { - try { - Instruction inst = instructionService.findByCodeFromCache(String.valueOf(task)); - this.finish_instruction(inst); - } catch (Exception var19) { - message = "指令完成异常"; - - } - } else { - message = "设备运转中,待完成指令"; - - } - break; - default: - - } - } - - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - last_number = number; - - - } catch (Exception var17) { - - } - - } - - public void apply_InEmpty() { - //{"status":200,"message":"任务状态反馈成功!","data":{},"errArr":[]} - String result = acsToWmsService.apply_InEmpty(this.getDeviceCode(), "1", String.valueOf(this.getNumber()), this.container); - JSONObject jo = (JSONObject) JSONObject.toJSON(result); - if (ObjectUtil.isEmpty(jo)) { - message = "接口不通"; - } else { - if (jo.getInteger("status") == 200) { - this.setRequireSucess(true); - } else { - this.setRequireSucess(false); - } - } - } - - - public void finish_instruction(Instruction instruction) throws Exception { - instruction_finished(instruction); - } - - /** - * 完成指令 - * - * @param instruction - * @return - */ - public boolean instruction_finished(Instruction instruction) throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - instructionService.finish(instruction.getInstruction_id()); - this.instruction_finished_time = date; - return true; - } - } - - /** - * 完成并创建下一条指令 - * - * @param instruction - * @param needCreateNext - * @return - */ - public boolean instruction_finished(Instruction instruction, boolean needCreateNext) { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - this.instruction_finished_time = date; - return true; - } - } - - - private Instruction findInstruction() { - Instruction instruction = null; - if (this.instruction_num != 0) { - instruction = (Instruction) instructionService.findByCodeFromCache(String.valueOf(instruction_num)); - } - if (instruction != null) { - //可进行校验 - - - } else { - List container_instructions = new ArrayList(); - String barcode = this.getLast_container(); - - if (!StrUtil.isEmpty(barcode)) { - Map map = new HashMap(); - map.put("vehicle_code", barcode); - container_instructions = instructionService.queryAll(map); - } - - if (((List) container_instructions).size() > 1) { - log.debug("容器存在多个指令"); - } else { - if (((List) container_instructions).size() > 0) { - instruction = (Instruction) ((List) container_instructions).get(0); - } - } - } - return instruction; - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - if (appendMessage == null) { - appendMessage = ""; - } - if (instruction != null) { - instruction_num = Integer.parseInt(instruction.getInstruction_code()); - } - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, 1); - itemMap.put(to_task, instruction_num); - ReadUtil.write(itemMap, server); - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type, String linkdevice) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_device_code(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - dto.setNext_device_code(linkdevice); - dto.setNext_point_code(linkdevice); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - try { - taskserver.create(dto); - } catch (Exception e) { - e.printStackTrace(); - } - requireSucess = true; - return true; - } - } - - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/ItemProtocol.java deleted file mode 100644 index 446a29c..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/ItemProtocol.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.nl.acs.device_driver.standard_inspect_site; - -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_ioaction = "ioaction"; - public static String item_error = "error"; - public static String item_task = "task"; - public static String item_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_task = "to_task"; - public static String item_weight = "weight"; - - private StandardInspectSiteDeviceDriver driver; - - public ItemProtocol(StandardInspectSiteDeviceDriver 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 getIoaction() { - return this.getOpcIntegerValue(item_ioaction); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getToTarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getToTask() { - return this.getOpcIntegerValue(item_to_task); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_move, "光电开关信号", "DB600.B2")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(item_task, "任务号", "DB600.D8")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_target, "目标站", "DB601.W4")); - list.add(new ItemDto(item_to_task, "任务号", "DB601.D8")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDefination.java deleted file mode 100644 index ab6211e..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDefination.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.nl.acs.device_driver.standard_inspect_site; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 检测站点驱动定义 - * 说明:该站点为普通带光电检测站点 - */ -@Service -public class StandardInspectSiteDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_inspect_site"; - } - - @Override - public String getDriverName() { - return "标准版-检测站点"; - } - - @Override - public String getDriverDescription() { - return "标准版-检测站点"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardInspectSiteDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return StandardInspectSiteDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", true)); - list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB600.D8")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java deleted file mode 100644 index a0afa12..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_inspect_site/StandardInspectSiteDeviceDriver.java +++ /dev/null @@ -1,441 +0,0 @@ -package org.nl.acs.device_driver.standard_inspect_site; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -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.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 检测站点驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - int mode = 0; - int error = 0; - int move = 0; - int task = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - String material; - //批次 - String batch; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - //申请搬运任务 - private Boolean apply_handling = false; - //申请物料 - private Boolean apply_material = false; - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag; - - String devicecode; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - String device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - error = this.itemProtocol.getError(); - move = this.itemProtocol.getMove(); - task = this.itemProtocol.getTask(); - hasGoods = this.itemProtocol.getMove(); - - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (move != last_move) { - } - if (error != last_error) { - } - - if (this.getApply_handling()) { - String link_device_code = this.getDevice().getExtraValue().get("link_device_code").toString(); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device link_device = appService.findDeviceByCode(link_device_code); - StandardInspectSiteDeviceDriver standardInspectSiteDevicedriver; - if (link_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDevicedriver = (StandardInspectSiteDeviceDriver) link_device.getDeviceDriver(); -// if(standardInspectSiteDevicedriver.getMode() != 2){ -// log.debug("设备未待机"); -// return; -// } -// if(standardInspectSiteDevicedriver.getMove() != 0){ -// log.debug("设备不满足放货条件"); -// return; -// } - - //如果目标设备申请叫料 则允许生成任务 - if (standardInspectSiteDevicedriver.getApply_material()) { - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); -// RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); -// String next_device_codecode = jo.getNext_device_code(); -// if(StrUtil.isEmpty(next_device_codecode)){ -// throw new RuntimeException("该设备未找到对应路由"); -// } - dto.setNext_point_code(standardInspectSiteDevicedriver.getDevicecode()); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - standardInspectSiteDevicedriver.setApply_material(false); - } - } - this.setApply_handling(false); - } - - } catch (Exception var17) { - return; - } - - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - return; - case 2: - //申请任务 -// if (this.getApply_handling()) { -// String link_device_code = this.getDevice().getExtraValue().get("link_device_code").toString(); -// DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); -// Device link_device = appService.findDeviceByCode(link_device_code); -// StandardInspectSiteDeviceDriver standardInspectSiteDevicedriver; -// if(link_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { -// standardInspectSiteDevicedriver = (StandardInspectSiteDeviceDriver) link_device.getDeviceDriver(); -// if(standardInspectSiteDevicedriver.getMode() != 2){ -// log.debug("设备未待机"); -// return; -// } -// if(standardInspectSiteDevicedriver.getMove() != 0){ -// log.debug("设备不满足放货条件"); -// return; -// } -// -// //如果目标设备申请叫料 则允许生成任务 -// if(standardInspectSiteDevicedriver.getApply_material()){ -// TaskDto dto = new TaskDto(); -// String now = DateUtil.now(); -// dto.setTask_id(IdUtil.simpleUUID()); -// dto.setCreate_by(this.getDevice().getDevice_code()); -// dto.setUpdate_by(this.getDevice().getDevice_code()); -// dto.setStart_point_code(this.getDevice().getDevice_code()); -// -// String taskcode = CodeGenerateUtil.getNewCode("TASK_NO"); -// dto.setTask_code("-"+taskcode); -// dto.setTask_status("0"); -// dto.setPriority("101"); -// RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); -// String next_device_codecode = jo.getNext_device_code(); -// if(StrUtil.isEmpty(next_device_codecode)){ -// throw new RuntimeException("该设备未找到对应路由"); -// } -// dto.setNext_point_code(next_device_codecode); -// dto.setUpdate_time(now); -// dto.setCreate_time(now); -// -// WQLObject wo = WQLObject.getWQLObject("acs_task"); -// JSONObject json = (JSONObject) JSONObject.toJSON(dto); - -// wo.insert(json); -// standardInspectSiteDevicedriver.setApply_material(false); -// } -// } -// this.setApply_handling(false); -// } - - if (material.length() > 0 && qty.length() > 0 && !requireSucess) { - this.instruction_require(container); - } - } - - switch (flag) { - //取货完成 - case 1: - writing(2); - return; - //放货完成 - case 2: - writing(3); - return; - - } - - } - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - if (appendMessage == null) { - appendMessage = ""; - } - if (instruction != null) { - instruction_num = Integer.parseInt(instruction.getInstruction_code()); - } - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, 1); - itemMap.put(to_task, instruction_num); - ReadUtil.write(itemMap, server); - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - ReadUtil.write(itemMap, server); - - } - - public void writing(int type, int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - if (type == 1) { - itemMap.put(to_command, command); - } else if (type == 2) { - itemMap.put(to_target, command); - - } else if (type == 3) { - itemMap.put(to_task, command); - } - ReadUtil.write(itemMap, server); - - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_manipulator_inspect_site/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_manipulator_inspect_site/ItemProtocol.java deleted file mode 100644 index 0ba497e..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_manipulator_inspect_site/ItemProtocol.java +++ /dev/null @@ -1,113 +0,0 @@ -package org.nl.acs.device_driver.standard_manipulator_inspect_site; - -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_ioaction = "ioaction"; - public static String item_error = "error"; - public static String item_task = "task"; - public static String item_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_task = "to_task"; - - - Boolean isonline; - - private StandardManipulatorInspectSiteDeviceDriver driver; - - public ItemProtocol(StandardManipulatorInspectSiteDeviceDriver 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 getIoAction() { - return this.getOpcIntegerValue(item_ioaction); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getToTarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getToTask() { - return this.getOpcIntegerValue(item_to_task); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_move, "光电开关信号", "DB600.B2")); - list.add(new ItemDto(item_action, "取放信号", "DB600.B3")); - list.add(new ItemDto(item_ioaction, "进出信号", "DB600.B4")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(item_task, "任务号", "DB600.D8")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_target, "目标站", "DB601.W4")); - list.add(new ItemDto(item_to_task, "任务号", "DB601.D8")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_manipulator_inspect_site/StandardManipulatorInspectSiteDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_manipulator_inspect_site/StandardManipulatorInspectSiteDefination.java deleted file mode 100644 index e58de97..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_manipulator_inspect_site/StandardManipulatorInspectSiteDefination.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.nl.acs.device_driver.standard_manipulator_inspect_site; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 机械手站点驱动定义 - * 说明:该站点为需要进行区域管制交互时使用 - */ -@Service -public class StandardManipulatorInspectSiteDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_manipulator_inspect_site"; - } - - @Override - public String getDriverName() { - return "标准版-区域管制设备-检测站点"; - } - - @Override - public String getDriverDescription() { - return "标准版-区域管制设备-检测站点"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardManipulatorInspectSiteDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return StandardManipulatorInspectSiteDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", true)); - list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_ioaction, "进出信号", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB600.D8")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_manipulator_inspect_site/StandardManipulatorInspectSiteDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_manipulator_inspect_site/StandardManipulatorInspectSiteDeviceDriver.java deleted file mode 100644 index 96c2835..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_manipulator_inspect_site/StandardManipulatorInspectSiteDeviceDriver.java +++ /dev/null @@ -1,538 +0,0 @@ -package org.nl.acs.device_driver.standard_manipulator_inspect_site; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver; -import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 区域管制设备交互站点驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class StandardManipulatorInspectSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - String devicecode; - int mode = 0; - int error = 0; - int move = 0; - int actoin; - int io_action; - int task = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - Boolean isonline = true; - int hasGoods = 0; - Boolean iserror = false; - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - private Boolean sampleMode0; - private Boolean sampleMode3; - private Integer sampleError; - private Boolean sampleOnline; - protected String displayMessage = null; - public int display_message_time_out = 30000; - public Date display_message_time; - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out = 3000; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int heartbeat; - int last_heartbeat; - private Date checkHeartbeattime = new Date(); - private Date last_checkHeartbeattime = new Date(); - - - int branchProtocol = 0; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - String message; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - String device_code = this.getDeviceCode(); - - mode = this.itemProtocol.getMode(); - error = this.itemProtocol.getError(); - move = this.itemProtocol.getMove(); - task = this.itemProtocol.getTask(); - hasGoods = this.itemProtocol.getMove(); - io_action = this.itemProtocol.getIoAction(); - actoin = this.itemProtocol.getAction(); - - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (move != last_move) { - if (move == 0) { - thingToNothing(); - } - } - if (error != last_error) { - } - - } catch (Exception var17) { - return; - } - - //急停 - if (this.isStop()) { - - //未在线无心跳 - } else if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 2: - break; - case 3: - //申请空盘 - if (!requireSucess && this.move == 0) { - applyEmpty(); - } - break; - case 4: - //申请搬运任务 - if (!requireSucess && this.move != 0) { - autoCreateTask(); - } - break; - case 5: - break; - } - } - - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - } - - /** - * 生成搬运任务 - * - * @return - */ - public synchronized boolean autoCreateTask() { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setStart_device_code(this.getDevice().getDevice_code()); - dto.setTask_status("0"); - dto.setPriority("101"); - String next_device_code = ""; - - String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + dto.getRoute_plan_code() + "'").uniqueResult(0).getString("plan_uuid"); - JSONArray ja = routelineserver.queryNextLine(this.getDevice().getDevice_code(), plan_uuid); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - for (int i = 0; i < ja.size(); i++) { - JSONObject jo = (JSONObject) ja.get(i); - next_device_code = jo.get("next_device_code").toString(); - Device nextdevice = appService.findDeviceByCode(next_device_code); - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); - String maxTaskNum = WQLObject.getWQLObject("sys_param").query("code= 'onePointMaxTask' and is_active='1' ").uniqueResult(0).getString("value"); - - if (taskserver.checkAllowCreate(next_device_code) >= Integer.parseInt(maxTaskNum)) { - next_device_code = ""; - continue; - } - if (standardInspectSiteDeviceDriver.getMode() == 2 && standardInspectSiteDeviceDriver.getMove() == 0) { - break; - } - } - } - if (StrUtil.isEmpty(next_device_code)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_code); - dto.setNext_device_code(next_device_code); - dto.setUpdate_time(now); - dto.setCreate_time(now); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - try { - taskserver.create(dto); - } catch (Exception e) { - e.printStackTrace(); - } - this.setRequireSucess(true); - return true; - } - - } - - - public synchronized boolean applyEmpty() { - - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setTask_status("0"); - dto.setPriority("101"); - String start_device_code = ""; - String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + dto.getRoute_plan_code() + "'").uniqueResult(0).getString("plan_uuid"); - - JSONArray ja = routelineserver.querySuperiorLine(this.getDevice().getDevice_code(), plan_uuid); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - for (int i = 0; i < ja.size(); i++) { - JSONObject jo = (JSONObject) ja.get(i); - start_device_code = jo.get("device_code").toString(); - Device start_device = appService.findDeviceByCode(start_device_code); - StandardEmptyPalletSiteDeviceDriver standardEmptyPalletSiteDeviceDriver; - if (start_device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) start_device.getDeviceDriver(); - //根据路由 寻找取空盘的设备 -// if(standardEmptyPalletSiteDeviceDriver.getNumber() < Integer.parseInt(standardEmptyPalletSiteDeviceDriver.getDevice().getExtraValue().get("max_emptypalletnum").toString()) ) { -// break; -// } - if (standardEmptyPalletSiteDeviceDriver.getMode() == 2 && standardEmptyPalletSiteDeviceDriver.getNumber() > 0) { - break; - } - } - } - dto.setTask_type("1"); - dto.setEmptypallet_num("1"); - dto.setNext_device_code(this.getDevice().getDevice_code()); - dto.setNext_point_code(this.getDevice().getDevice_code()); - dto.setStart_point_code(start_device_code); - dto.setStart_device_code(start_device_code); - if (StrUtil.isEmpty(start_device_code)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setUpdate_time(now); - dto.setCreate_time(now); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - try { - taskserver.create(dto); - } catch (Exception e) { - e.printStackTrace(); - } - this.setRequireSucess(true); - this.setBranchProtocol(0); - return true; - } - } - - public void finish_instruction(Instruction instruction) throws Exception { - instruction_finished(instruction); - } - - /** - * 完成指令 - * - * @param instruction - * @return - */ - public boolean instruction_finished(Instruction instruction) throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - instructionService.finish(instruction.getInstruction_id()); - this.instruction_finished_time = date; - return true; - } - } - - /** - * 完成并创建下一条指令 - * - * @param instruction - * @param needCreateNext - * @return - */ - public boolean instruction_finished(Instruction instruction, boolean needCreateNext) { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - this.instruction_finished_time = date; - return true; - } - } - - - private Instruction findInstruction() { - Instruction instruction = null; - if (this.instruction_num != 0) { - instruction = (Instruction) instructionService.findByCodeFromCache(String.valueOf(instruction_num)); - } - if (instruction != null) { - //可进行校验 - - - } else { - List container_instructions = new ArrayList(); - String barcode = this.getLast_container(); - - if (!StrUtil.isEmpty(barcode)) { - Map map = new HashMap(); - map.put("vehicle_code", barcode); - container_instructions = instructionService.queryAll(map); - } - - if (((List) container_instructions).size() > 1) { - log.debug("容器存在多个指令"); - } else { - if (((List) container_instructions).size() > 0) { - instruction = (Instruction) ((List) container_instructions).get(0); - } - } - } - return instruction; - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.set_last_container(container, container_type_desc); - this.setRequireSucess(false); - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - if (appendMessage == null) { - appendMessage = ""; - } - if (instruction != null) { - instruction_num = Integer.parseInt(instruction.getInstruction_code()); - } - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, 1); - itemMap.put(to_task, instruction_num); - ReadUtil.write(itemMap, server); - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - - public void writing(int type, int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - if (type == 1) { - itemMap.put(to_command, command); - } else if (type == 2) { - itemMap.put(to_target, command); - - } else if (type == 3) { - itemMap.put(to_task, command); - } - ReadUtil.write(itemMap, server); - - } - - public String toString() { - return ""; - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_manipulator_stacking_site/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_manipulator_stacking_site/ItemProtocol.java deleted file mode 100644 index 08e9cbe..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_manipulator_stacking_site/ItemProtocol.java +++ /dev/null @@ -1,123 +0,0 @@ -package org.nl.acs.device_driver.standard_manipulator_stacking_site; - -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_ioaction = "ioaction"; - public static String item_container_type = "container_type"; - public static String item_error = "error"; - public static String item_task = "task"; - public static String item_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_task = "to_task"; - public static String item_to_container_type = "to_container_type"; - Boolean isonline; - - private StandardManipulatorStackingSiteDeviceDriver driver; - - public ItemProtocol(StandardManipulatorStackingSiteDeviceDriver 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 getIoAction() { - return this.getOpcIntegerValue(item_ioaction); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getToTarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getToTask() { - return this.getOpcIntegerValue(item_to_task); - } - - public int getToContainerType() { - return this.getOpcIntegerValue(item_to_container_type); - } - - public int getContainerType() { - return this.getOpcIntegerValue(item_container_type); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_move, "光电开关信号", "DB600.B2")); - list.add(new ItemDto(item_action, "取放信号", "DB600.B3")); - list.add(new ItemDto(item_ioaction, "进出信号", "DB600.B4")); - list.add(new ItemDto(item_container_type, "托盘类型", "DB600.B5")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(item_task, "任务号", "DB600.D8")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_target, "目标站", "DB601.W4")); - list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB601.W6")); - list.add(new ItemDto(item_to_task, "任务号", "DB601.D8")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_manipulator_stacking_site/StandardManipulatorStackingSiteDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_manipulator_stacking_site/StandardManipulatorStackingSiteDefination.java deleted file mode 100644 index e522ef8..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_manipulator_stacking_site/StandardManipulatorStackingSiteDefination.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.nl.acs.device_driver.standard_manipulator_stacking_site; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 机械手码垛驱动(区分托盘类型) - */ -@Service -public class StandardManipulatorStackingSiteDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_manipulator_stacking_site"; - } - - @Override - public String getDriverName() { - return "机械手码垛驱动(区分托盘类型)"; - } - - @Override - public String getDriverDescription() { - return "机械手码垛驱动(区分托盘类型)"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardManipulatorStackingSiteDeviceDriver()).setDevice(device).setDriverDefination(this); - } - - @Override - public Class getDeviceDriverType() { - return StandardManipulatorStackingSiteDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", true)); - list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_ioaction, "进出信号", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_container_type, "托盘类型", "DB600.B5")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB600.D8")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_manipulator_stacking_site/StandardManipulatorStackingSiteDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_manipulator_stacking_site/StandardManipulatorStackingSiteDeviceDriver.java deleted file mode 100644 index ed2f339..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_manipulator_stacking_site/StandardManipulatorStackingSiteDeviceDriver.java +++ /dev/null @@ -1,977 +0,0 @@ -package org.nl.acs.device_driver.standard_manipulator_stacking_site; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.device_driver.standard_photoelectric_inspect_site.StandardPhotoelectricInspectSiteDeviceDriver; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 机械手码垛驱动(区分托盘类型) - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class StandardManipulatorStackingSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - - - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - - String device_code; - int mode = 0; - int error = 0; - int move = 0; - int action; - int io_action; - int task = 0; - int container_type = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - int last_container_type; - Boolean isonline = true; - int hasGoods = 0; - Boolean iserror = false; - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - private Boolean sampleMode0; - private Boolean sampleMode3; - private Integer sampleError; - private Boolean sampleOnline; - protected String displayMessage = null; - public int display_message_time_out = 30000; - public Date display_message_time; - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out = 3000; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int heartbeat; - int last_heartbeat; - private Date checkHeartbeattime = new Date(); - private Date last_checkHeartbeattime = new Date(); - - int branchProtocol = 0; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - String message; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - device_code = this.getDeviceCode(); - - mode = this.itemProtocol.getMode(); - error = this.itemProtocol.getError(); - move = this.itemProtocol.getMove(); - task = this.itemProtocol.getTask(); - container_type = this.itemProtocol.getContainerType(); - hasGoods = this.itemProtocol.getMove(); - action = this.itemProtocol.getAction(); - io_action = this.itemProtocol.getIoAction(); - - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (move != last_move) { - thingToNothing(); - } - if (error != last_error) { - } - if (container_type != last_container_type) { - } - - } catch (Exception var17) { - return; - } - - //急停 - if (this.isStop()) { - - //未在线无心跳 - } else if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - break; - case 2: - - break; - case 3: - - break; - case 4: - //待机 - if (!requireSucess && this.move == 0 && this.container_type != 0) { - standby(); - } - break; - case 5: - //申请空盘 - if (!requireSucess && this.move == 0 && this.container_type != 0) { - applyEmpty(); - } - break; - case 6: - //申请入库(满托入窑) - if (!requireSucess && this.move != 0 && this.container_type != 0) { - applyEnter(); - } - break; - case 7: - //换盘去应急位 - if (!requireSucess && this.move != 0 && this.container_type != 0) { - emergency(); - } - break; - case 8: - //换盘去托盘库 - if (!requireSucess && this.move != 0 && this.container_type != 0) { - trayLibrary(); - } - break; - case 9: - //入托盘 - if (!requireSucess && this.move != 0 && this.container_type != 0) { - intoTray(); - } - break; - } - } - - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - last_container_type = container_type; - } - - - protected void thingToNothing() throws Exception { - this.setRequireSucess(false); - } - - /** - * 待机 - * - * @return - */ - public synchronized boolean standby() { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - - dto.setTask_status("0"); - dto.setPriority("101"); - String device_code = ""; - StandardPhotoelectricInspectSiteDeviceDriver standardPhotoelectricInspectSiteDeviceDriver; - List list = routelineserver.getPathLinesByCode(this.device_code, "normal"); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - - for (int i = 0; i < list.size(); i++) { - RouteLineDto routeLineDto = list.get(i); - device_code = routeLineDto.getDevice_code(); - Device device = appService.findDeviceByCode(device_code); - if (device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) device.getDeviceDriver(); - if (this.container_type == standardPhotoelectricInspectSiteDeviceDriver.getContainer_type() - && standardPhotoelectricInspectSiteDeviceDriver.getMove() != 0 - && standardPhotoelectricInspectSiteDeviceDriver.getPriority() == 1 - && ObjectUtil.isEmpty(taskserver.findByNextCode(this.device_code)) - && ObjectUtil.isEmpty(taskserver.findByStartCode(device_code)) - && standardPhotoelectricInspectSiteDeviceDriver.getMode() != 0) { - break; - } else { - device_code = ""; - } - } else { - device_code = ""; - } - } - if (StrUtil.isEmpty(device_code)) { - for (int i = 0; i < list.size(); i++) { - RouteLineDto routeLineDto = list.get(i); - device_code = routeLineDto.getDevice_code(); - Device device = appService.findDeviceByCode(device_code); - if (device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardPhotoelectricInspectSiteDeviceDriver.getMove() != 0 - && this.container_type == standardPhotoelectricInspectSiteDeviceDriver.getContainer_type() - && ObjectUtil.isEmpty(taskserver.findByNextCode(this.device_code)) - && ObjectUtil.isEmpty(taskserver.findByStartCode(device_code)) - && standardPhotoelectricInspectSiteDeviceDriver.getMode() != 0) { - break; - } else { - device_code = ""; - } - } else { - device_code = ""; - } - } - } - if (StrUtil.isEmpty(device_code)) { - for (int i = 0; i < list.size(); i++) { - RouteLineDto routeLineDto = list.get(i); - device_code = routeLineDto.getDevice_code(); - Device device = appService.findDeviceByCode(device_code); - StandardManipulatorStackingSiteDeviceDriver standardManipulatorStackingSiteDeviceDriver; - if (device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) device.getDeviceDriver(); - if (standardManipulatorStackingSiteDeviceDriver.getMove() != 0 - && this.container_type == 4 - && standardManipulatorStackingSiteDeviceDriver.getContainer_type() == 4 - && ObjectUtil.isEmpty(taskserver.findByNextCode(this.device_code)) - && ObjectUtil.isEmpty(taskserver.findByStartCode(device_code)) - && standardManipulatorStackingSiteDeviceDriver.getMode() != 0) { - break; - } else { - device_code = ""; - } - } else { - device_code = ""; - } - } - } - - if (StrUtil.isEmpty(device_code)) { - throw new RuntimeException("该设备未找到对应路由"); - } - - dto.setStart_point_code(device_code); - dto.setStart_device_code(device_code); - dto.setNext_point_code(this.device_code); - dto.setNext_device_code(this.device_code); - dto.setVehicle_type(String.valueOf(this.container_type)); - dto.setUpdate_time(now); - dto.setCreate_time(now); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - this.setRequireSucess(true); - return true; - } - } - - /** - * 生成搬运任务 - * - * @return - */ - public synchronized boolean autoCreateTask() { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setTask_status("0"); - dto.setPriority("101"); - String next_device_code = ""; - String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + dto.getRoute_plan_code() + "'").uniqueResult(0).getString("plan_uuid"); - JSONArray ja = routelineserver.queryNextLine(this.getDevice().getDevice_code(), plan_uuid); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - for (int i = 0; i < ja.size(); i++) { - JSONObject jo = (JSONObject) ja.get(i); - next_device_code = jo.get("next_device_code").toString(); - Device nextdevice = appService.findDeviceByCode(next_device_code); - StandardManipulatorStackingSiteDeviceDriver standardManipulatorStackingSiteDeviceDriver; - if (nextdevice.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) nextdevice.getDeviceDriver(); - String maxTaskNum = WQLObject.getWQLObject("sys_param").query("code= 'onePointMaxTask' and is_active='1' ").uniqueResult(0).getString("value"); - - if (taskserver.checkAllowCreate(next_device_code) >= Integer.parseInt(maxTaskNum)) { - next_device_code = ""; - continue; - } - if (standardManipulatorStackingSiteDeviceDriver.getMode() == 2 - && standardManipulatorStackingSiteDeviceDriver.getMove() == 0) { - break; - } - } - } - if (StrUtil.isEmpty(next_device_code)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setStart_point_code(this.device_code); - dto.setStart_device_code(this.device_code); - dto.setNext_point_code(next_device_code); - dto.setNext_device_code(next_device_code); - dto.setVehicle_type(String.valueOf(this.container_type)); - dto.setUpdate_time(now); - dto.setCreate_time(now); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - this.setRequireSucess(true); - return true; - } - - } - - /** - * 生成空盘 - * - * @return - */ - public synchronized boolean applyEmpty() { - //device_code - - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setTask_status("0"); - dto.setPriority("101"); - String start_device_code = ""; - List list = routelineserver.getPathLinesByCode(this.device_code, "normal"); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - for (int i = 0; i < list.size(); i++) { - RouteLineDto routeLineDto = list.get(i); - start_device_code = routeLineDto.getDevice_code(); - Device startdevice = appService.findDeviceByCode(start_device_code); - StandardManipulatorStackingSiteDeviceDriver standardManipulatorStackingSiteDeviceDriver; - if (startdevice.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) startdevice.getDeviceDriver(); - if (this.container_type == standardManipulatorStackingSiteDeviceDriver.getContainer_type() - && standardManipulatorStackingSiteDeviceDriver.getMode() != 0 - && standardManipulatorStackingSiteDeviceDriver.move != 0 - && ObjectUtil.isEmpty(taskserver.findByNextCode(start_device_code)) - && ObjectUtil.isEmpty(taskserver.findByStartCode(this.device_code))) { - break; - } else { - start_device_code = ""; - } - } else { - start_device_code = ""; - } - - } - if (StrUtil.isEmpty(start_device_code)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setStart_point_code(start_device_code); - dto.setStart_device_code(start_device_code); - dto.setNext_point_code(this.getDevice().getDevice_code()); - dto.setNext_device_code(this.getDevice().getDevice_code()); - dto.setVehicle_type(String.valueOf(this.container_type)); - dto.setUpdate_time(now); - dto.setCreate_time(now); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - this.setRequireSucess(true); - return true; - } - } - - /** - * 申请入库 - * - * @return - */ - public synchronized boolean applyEnter() { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setTask_status("0"); - dto.setPriority("101"); - String next_device_code = ""; - List list = routelineserver.getShortPathLinesByCode(this.device_code, "normal"); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - - for (int i = 0; i < list.size(); i++) { - RouteLineDto routeLineDto = list.get(i); - next_device_code = routeLineDto.getNext_device_code(); - Device nextdevice = appService.findDeviceByCode(next_device_code); - StandardManipulatorStackingSiteDeviceDriver standardManipulatorStackingSiteDeviceDriver; - if (nextdevice.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) nextdevice.getDeviceDriver(); - if (this.container_type == standardManipulatorStackingSiteDeviceDriver.getContainer_type() - && StrUtil.equals(standardManipulatorStackingSiteDeviceDriver.getDevice().getExtraValue().get("priority_storage").toString(), "true") - && standardManipulatorStackingSiteDeviceDriver.move == 0 - && ObjectUtil.isEmpty(taskserver.findByNextCode(next_device_code)) - && ObjectUtil.isEmpty(taskserver.findByStartCode(this.device_code)) - && standardManipulatorStackingSiteDeviceDriver.getMode() != 0) { - break; - } else { - next_device_code = ""; - } - } else { - next_device_code = ""; - } - } - if (StrUtil.isEmpty(next_device_code)) { - for (int i = 0; i < list.size(); i++) { - RouteLineDto routeLineDto = list.get(i); - next_device_code = routeLineDto.getNext_device_code(); - Device nextdevice = appService.findDeviceByCode(next_device_code); - StandardPhotoelectricInspectSiteDeviceDriver standardPhotoelectricInspectSiteDeviceDriver; - if (nextdevice.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); - if (standardPhotoelectricInspectSiteDeviceDriver.getMode() == 2 - && standardPhotoelectricInspectSiteDeviceDriver.getMove() == 0 - && ObjectUtil.isEmpty(taskserver.findByNextCode(next_device_code)) - && ObjectUtil.isEmpty(taskserver.findByStartCode(this.device_code)) - && standardPhotoelectricInspectSiteDeviceDriver.getMode() != 0) { - break; - } else { - next_device_code = ""; - } - } else { - next_device_code = ""; - } - } - } - - if (StrUtil.isEmpty(next_device_code)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setStart_point_code(this.device_code); - dto.setStart_device_code(this.device_code); - dto.setNext_point_code(next_device_code); - dto.setNext_device_code(next_device_code); - dto.setVehicle_type(String.valueOf(this.container_type)); - dto.setUpdate_time(now); - dto.setCreate_time(now); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - this.setRequireSucess(true); - return true; - } - } - - /** - * 换盘去应急位 - */ - public synchronized Boolean emergency() { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setTask_status("0"); - dto.setPriority("101"); - String next_device_code = ""; - List list = routelineserver.getShortPathLinesByCode(this.device_code, "normal"); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - - for (int i = 0; i < list.size(); i++) { - RouteLineDto routeLineDto = list.get(i); - next_device_code = routeLineDto.getNext_device_code(); - Device nextdevice = appService.findDeviceByCode(next_device_code); - StandardManipulatorStackingSiteDeviceDriver standardManipulatorStackingSiteDeviceDriver; - if (nextdevice.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) nextdevice.getDeviceDriver(); - if (this.container_type == standardManipulatorStackingSiteDeviceDriver.getContainer_type() - && StrUtil.equals(standardManipulatorStackingSiteDeviceDriver.getDevice().getExtraValue().get("emergency").toString(), "true") - && standardManipulatorStackingSiteDeviceDriver.move == 0 - && standardManipulatorStackingSiteDeviceDriver.getMode() != 0) { - if (ObjectUtil.isEmpty(taskserver.findByStartCode(this.device_code)) - && ObjectUtil.isEmpty(taskserver.findByNextCode(next_device_code))) { - break; - } else { - throw new RuntimeException("货位已满"); - } - }else { - next_device_code = ""; - } - } - } - - if (StrUtil.isEmpty(next_device_code)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setStart_point_code(this.device_code); - dto.setStart_device_code(this.device_code); - dto.setNext_point_code(next_device_code); - dto.setNext_device_code(next_device_code); - dto.setVehicle_type(String.valueOf(this.container_type)); - dto.setUpdate_time(now); - dto.setCreate_time(now); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - this.setRequireSucess(true); - return true; - } - } - - /** - * 换盘去托盘库 - * - * @return - */ - public synchronized Boolean trayLibrary() { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setTask_status("0"); - dto.setPriority("101"); - String next_device_code = ""; - List list = routelineserver.getShortPathLinesByCode(this.device_code, "normal"); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - - for (int i = 0; i < list.size(); i++) { - RouteLineDto routeLineDto = list.get(i); - next_device_code = routeLineDto.getNext_device_code(); - Device nextdevice = appService.findDeviceByCode(next_device_code); - StandardManipulatorStackingSiteDeviceDriver standardManipulatorStackingSiteDeviceDriver; - if (nextdevice.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) nextdevice.getDeviceDriver(); - if (this.container_type == standardManipulatorStackingSiteDeviceDriver.getContainer_type() - && StrUtil.equals(standardManipulatorStackingSiteDeviceDriver.getDevice().getExtraValue().get("tray_library").toString(), "true") - && standardManipulatorStackingSiteDeviceDriver.move == 0 - && ObjectUtil.isEmpty(taskserver.findByStartCode(this.device_code)) - && ObjectUtil.isEmpty(taskserver.findByNextCode(next_device_code)) - && standardManipulatorStackingSiteDeviceDriver.getMode() != 0) { - break; - } else { - next_device_code = ""; - } - } else { - next_device_code = ""; - } - } - - if (StrUtil.isEmpty(next_device_code)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setStart_point_code(this.device_code); - dto.setStart_device_code(this.device_code); - dto.setNext_point_code(next_device_code); - dto.setNext_device_code(next_device_code); - dto.setVehicle_type(String.valueOf(this.container_type)); - dto.setUpdate_time(now); - dto.setCreate_time(now); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - this.setRequireSucess(true); - return true; - } - } - - /** - * 入托盘库 - * - * @return - */ - public synchronized boolean intoTray() { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setTask_status("0"); - dto.setPriority("101"); - String next_device_code = ""; - List list = routelineserver.getShortPathLinesByCode(this.device_code, "normal"); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - - for (int i = 0; i < list.size(); i++) { - RouteLineDto routeLineDto = list.get(i); - next_device_code = routeLineDto.getNext_device_code(); - Device nextdevice = appService.findDeviceByCode(next_device_code); - StandardManipulatorStackingSiteDeviceDriver standardManipulatorStackingSiteDeviceDriver; - if (nextdevice.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) nextdevice.getDeviceDriver(); - if (this.container_type == standardManipulatorStackingSiteDeviceDriver.getContainer_type() - && standardManipulatorStackingSiteDeviceDriver.getMove() == 0 - && ObjectUtil.isEmpty(taskserver.findByStartCode(this.device_code)) - && ObjectUtil.isEmpty(taskserver.findByNextCode(next_device_code)) - && standardManipulatorStackingSiteDeviceDriver.getMode() != 0) { - break; - } else { - next_device_code = ""; - } - } else { - next_device_code = ""; - } - } - - if (StrUtil.isEmpty(next_device_code)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setStart_point_code(this.device_code); - dto.setStart_device_code(this.device_code); - dto.setNext_point_code(next_device_code); - dto.setNext_device_code(next_device_code); - dto.setVehicle_type(String.valueOf(this.container_type)); - dto.setUpdate_time(now); - dto.setCreate_time(now); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - this.setRequireSucess(true); - return true; - } - } - - public void finish_instruction(Instruction instruction) throws Exception { - instruction_finished(instruction); - } - - /** - * 完成指令 - * - * @param instruction - * @return - */ - public boolean instruction_finished(Instruction instruction) throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - instructionService.finish(instruction.getInstruction_id()); - this.instruction_finished_time = date; - return true; - } - } - - /** - * 完成并创建下一条指令 - * - * @param instruction - * @param needCreateNext - * @return - */ - public boolean instruction_finished(Instruction instruction, boolean needCreateNext) { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - this.instruction_finished_time = date; - return true; - } - } - - - private Instruction findInstruction() { - Instruction instruction = null; - if (this.instruction_num != 0) { - instruction = (Instruction) instructionService.findByCodeFromCache(String.valueOf(instruction_num)); - } - if (instruction != null) { - //可进行校验 - - - } else { - List container_instructions = new ArrayList(); - String barcode = this.getLast_container(); - - if (!StrUtil.isEmpty(barcode)) { - Map map = new HashMap(); - map.put("vehicle_code", barcode); - container_instructions = instructionService.queryAll(map); - } - - if (((List) container_instructions).size() > 1) { - log.debug("容器存在多个指令"); - } else { - if (((List) container_instructions).size() > 0) { - instruction = (Instruction) ((List) container_instructions).get(0); - } - } - } - return instruction; - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - if (appendMessage == null) { - appendMessage = ""; - } - if (instruction != null) { - instruction_num = Integer.parseInt(instruction.getInstruction_code()); - } - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, 1); - itemMap.put(to_task, instruction_num); - ReadUtil.write(itemMap, server); - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - - public void writing(int type, int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - String to_container_type = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_container_type; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - if (type == 1) { - itemMap.put(to_command, command); - } else if (type == 2) { - itemMap.put(to_target, command); - } else if (type == 3) { - itemMap.put(to_task, command); - } else if (type == 4) { - itemMap.put(to_container_type, command); - } - ReadUtil.write(itemMap, server); - - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_ordinary_site/StandardOrdinarySiteDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_ordinary_site/StandardOrdinarySiteDefination.java deleted file mode 100644 index cac8f65..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_ordinary_site/StandardOrdinarySiteDefination.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.nl.acs.device_driver.standard_ordinary_site; - -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.DeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * 普通站点定义 - */ -@Service -public class StandardOrdinarySiteDefination implements DeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_ordinary_site"; - } - - @Override - public String getDriverName() { - return "标准版-无光电普通站点"; - } - - @Override - public String getDriverDescription() { - return "标准版-无光电普通站点"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardOrdinarySiteDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return StandardOrdinarySiteDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java deleted file mode 100644 index 45a4683..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_ordinary_site/StandardOrdinarySiteDeviceDriver.java +++ /dev/null @@ -1,389 +0,0 @@ -package org.nl.acs.device_driver.standard_ordinary_site; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.device_driver.special_ordinary_site.SpecialOrdinarySiteDeviceDriver; -import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.springframework.beans.factory.annotation.Autowired; - -import java.math.BigDecimal; -import java.util.Date; - - -/** - * 普通站点 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - - Integer hasGoods = 0; - int error = 0; - Boolean iserror = false; - Boolean islock = false; - - int branchProtocol = 0; - int last_branchProtocol = 0; - //是否需要输入物料 - String input_material = "0"; - //备注 - String remark = ""; - //数量 - String qty = ""; - //批次 - String batch = ""; - //物料 - String material = ""; - //目标点位 - String purpose = ""; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - boolean requireSucess = false; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - //申请搬运任务 - private Boolean apply_handling = false; - //申请物料 - private Boolean apply_material = false; - - // 1取货完成 2放货完成 3进入区域 4离开区域 - private int flag; - - //人工确认信号 默认0 agv到达后请求置1 等人工确认后变为2 反馈agv后继续为0 - private int manua_confirm = 0; - - String devicecode; - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - - String message; - - int mode = 2; - - int move; - - @Override - public void execute() { - hasGoods = this.getDevice().getHas_goods(); - batch = this.getDevice().getBatch(); - devicecode = this.getDeviceCode(); - if (branchProtocol != last_branchProtocol) { - requireSucess = false; - } - switch (branchProtocol) { - case 1: - break; - //呼叫请求 - case 2: - if (material.length() > 0 && Integer.parseInt(this.getQty()) > 0 && !requireSucess) { - } - break; - //响应生成任务 - case 3: - if (material.length() > 0 && qty.length() > 0 && purpose.length() > 0 && !requireSucess) { - this.instruction_require(material, qty, this.getRemark(), purpose); - } - break; - //自动创建任务 叫料 - case 4: - if (!requireSucess) { - autoCreateTask(); - } - break; - //搬运空车、空托 - case 5: - if (!requireSucess) { - autoCreateEmptyPallet(); - } - break; - } - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - - /** - * 自动创建任务 - * - * @return - */ - public synchronized boolean autoCreateTask() { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - String next_device_code = ""; - - String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + dto.getRoute_plan_code() + "'").uniqueResult(0).getString("plan_uuid"); - JSONArray ja = routelineserver.queryNextLine(this.getDevice().getDevice_code(), plan_uuid); - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - for (int i = 0; i < ja.size(); i++) { - JSONObject jo = (JSONObject) ja.get(i); - next_device_code = jo.get("next_device_code").toString(); - Device nextdevice = appService.findDeviceByCode(next_device_code); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) nextdevice.getDeviceDriver(); - String maxTaskNum = WQLObject.getWQLObject("sys_param").query("code= 'onePointMaxTask' and is_active='1' ").uniqueResult(0).getString("value"); - - if (taskserver.checkAllowCreate(next_device_code) >= Integer.parseInt(maxTaskNum)) { - continue; - } - if (standardOrdinarySiteDeviceDriver.getHasGoods() == 0) { - break; - } - } - } - if (StrUtil.isEmpty(next_device_code)) { - throw new RuntimeException("该设备未找到对应路由"); - } - - dto.setNext_point_code(next_device_code); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - try { - taskserver.create(dto); - } catch (Exception e) { - e.printStackTrace(); - } - this.setIslock(true); - requireSucess = false; - branchProtocol = 0; - return true; - } - - } - - /** - * 自动创建搬运空车任务 - * - * @return - */ - public synchronized boolean autoCreateEmptyPallet() { - 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 { - //存在空位才能执行 - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - String next_device_code = ""; - dto.setRoute_plan_code("one"); - String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + dto.getRoute_plan_code() + "'").uniqueResult(0).getString("plan_uuid"); - - JSONArray ja = routelineserver.queryNextLine(this.getDevice().getDevice_code(), plan_uuid); - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - for (int j = 0; j < ja.size(); j++) { - JSONObject jo = (JSONObject) ja.get(j); - next_device_code = jo.get("next_device_code").toString(); - Device nextdevice = appService.findDeviceByCode(next_device_code); - SpecialOrdinarySiteDeviceDriver specialOrdinarySiteDeviceDriver; - if (nextdevice.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) { - specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) nextdevice.getDeviceDriver(); - String maxTaskNum = WQLObject.getWQLObject("sys_param").query("code= 'onePointMaxTask' and is_active='1' ").uniqueResult(0).getString("value"); - specialOrdinarySiteDeviceDriver.setIslock(true); - if (taskserver.checkAllowCreate(next_device_code) >= Integer.parseInt(maxTaskNum)) { - continue; - } - if (specialOrdinarySiteDeviceDriver.getMode() == 2 && specialOrdinarySiteDeviceDriver.getMove() == 0) { - break; - } - } - } - if (StrUtil.isEmpty(next_device_code)) { - throw new RuntimeException("该设备未找到对应路由"); - } - - dto.setNext_point_code(next_device_code); - dto.setUpdate_time(now); - dto.setCreate_time(now); - dto.setMaterial(material); - try { - taskserver.create(dto); - } catch (Exception e) { - e.printStackTrace(); - } - this.setIslock(true); - requireSucess = false; - branchProtocol = 0; - return true; - } - } - - /** - * 请求任务 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - try { - taskserver.create(dto); - } catch (Exception e) { - e.printStackTrace(); - } - requireSucess = false; - branchProtocol = 0; - return true; - } - } - - /** - * 请求任务 - * - * @param - * @param - */ - public synchronized boolean instruction_require(String material, String qty, String remark, String purpose) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setStart_device_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(""); - dto.setVehicle_type(""); - dto.setRoute_plan_code("normal"); - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - dto.setMaterial(this.getMaterial()); - dto.setQuantity(new BigDecimal(this.getQty())); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device purposedevice = appService.findDeviceByCode(purpose); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver = null; - if (purposedevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) purposedevice.getDeviceDriver(); - standardOrdinarySiteDeviceDriver.setBranchProtocol(0); - standardOrdinarySiteDeviceDriver.setPurpose(null); - standardOrdinarySiteDeviceDriver.setRemark(null); - } - dto.setNext_point_code(purpose); - dto.setNext_device_code(purpose); - dto.setUpdate_time(now); - dto.setCreate_time(now); - dto.setRemark(getRemark()); - try { - taskserver.create(dto); - } catch (Exception e) { - e.printStackTrace(); - } - last_branchProtocol = 2; - this.setBranchProtocol(0); - this.setRemark(null); - this.setPurpose(null); - this.setRequireSucess(true); - return true; - } - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_photoelectric_inspect_site/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_photoelectric_inspect_site/ItemProtocol.java deleted file mode 100644 index 39fdd21..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_photoelectric_inspect_site/ItemProtocol.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.nl.acs.device_driver.standard_photoelectric_inspect_site; - -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_error = "error"; - public static String item_task = "task"; - public static String item_ioaction = "ioaction"; - public static String item_container_type = "container_type"; - public static String item_priority = "priority"; - - public static String item_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_container_type = "to_container_type"; - - public static String item_to_task = "to_task"; - private StandardPhotoelectricInspectSiteDeviceDriver driver; - - public ItemProtocol(StandardPhotoelectricInspectSiteDeviceDriver 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 getIoAction() { - return this.getOpcIntegerValue(item_ioaction); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getToTarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getToTask() { - return this.getOpcIntegerValue(item_to_task); - } - - public int getToContainerType() { - return this.getOpcIntegerValue(item_to_container_type); - } - - public int getContainerType() { - return this.getOpcIntegerValue(item_container_type); - } - - public int getPriority() { - return this.getOpcIntegerValue(item_priority); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_move, "光电开关信号", "DB600.B2")); - list.add(new ItemDto(item_ioaction, "进出信号", "DB600.B4")); - list.add(new ItemDto(item_container_type, "托盘类型", "DB600.B5")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(item_priority, "优先出库", "DB600.B7")); - list.add(new ItemDto(item_task, "任务号", "DB600.D8")); - - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_target, "目标站", "DB601.W4")); - list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB601.W6")); - list.add(new ItemDto(item_to_task, "任务号", "DB601.D8")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_photoelectric_inspect_site/StandardPhotoelectricInspectSiteDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_photoelectric_inspect_site/StandardPhotoelectricInspectSiteDefination.java deleted file mode 100644 index 1f48add..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_photoelectric_inspect_site/StandardPhotoelectricInspectSiteDefination.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.nl.acs.device_driver.standard_photoelectric_inspect_site; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 光电检测站点(优先出库) - */ -@Service -public class StandardPhotoelectricInspectSiteDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_photoelectric_inspect_site"; - } - - @Override - public String getDriverName() { - return "光电检测站点(优先出库)"; - } - - @Override - public String getDriverDescription() { - return "光电检测站点(优先出库)"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardPhotoelectricInspectSiteDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return StandardPhotoelectricInspectSiteDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", true)); - list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "DB600.B2")); - list.add(new ItemDto(ItemProtocol.item_ioaction, "进出信号", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_container_type, "托盘类型", "DB600.B5")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(ItemProtocol.item_priority, "优先出库", "DB600.B7")); - list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB600.D8")); - - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_photoelectric_inspect_site/StandardPhotoelectricInspectSiteDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_photoelectric_inspect_site/StandardPhotoelectricInspectSiteDeviceDriver.java deleted file mode 100644 index 5b430ea..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_photoelectric_inspect_site/StandardPhotoelectricInspectSiteDeviceDriver.java +++ /dev/null @@ -1,444 +0,0 @@ -package org.nl.acs.device_driver.standard_photoelectric_inspect_site; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -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.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * 光电检测站点(优先出库) - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class StandardPhotoelectricInspectSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - - int mode = 0; - int error = 0; - int move = 0; - int task = 0; - int io_action = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - int container_type = 0; - int priority = 0; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - String material; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - //申请搬运任务 - private Boolean apply_handling = false; - //申请物料 - private Boolean apply_material = false; - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag; - - String devicecode; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - try { - String device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - error = this.itemProtocol.getError(); - move = this.itemProtocol.getMove(); - task = this.itemProtocol.getTask(); - hasGoods = this.itemProtocol.getMove(); - container_type = this.itemProtocol.getContainerType(); - priority = this.itemProtocol.getPriority(); - io_action = this.itemProtocol.getIoAction(); - if (mode != last_mode) { - this.setRequireSucess(false); - } - if (move != last_move) { - } - if (error != last_error) { - } - - if (this.getApply_handling()) { - String link_device_code = this.getDevice().getExtraValue().get("link_device_code").toString(); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device link_device = appService.findDeviceByCode(link_device_code); - StandardPhotoelectricInspectSiteDeviceDriver standardPhotoelectricInspectSiteDeviceDriver; - if (link_device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) link_device.getDeviceDriver(); -// if(standardInspectSiteDevicedriver.getMode() != 2){ -// log.debug("设备未待机"); -// return; -// } -// if(standardInspectSiteDevicedriver.getMove() != 0){ -// log.debug("设备不满足放货条件"); -// return; -// } - - //如果目标设备申请叫料 则允许生成任务 - if (standardPhotoelectricInspectSiteDeviceDriver.getApply_material()) { - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); -// RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); -// String next_device_codecode = jo.getNext_device_code(); -// if(StrUtil.isEmpty(next_device_codecode)){ -// throw new RuntimeException("该设备未找到对应路由"); -// } - dto.setNext_point_code(standardPhotoelectricInspectSiteDeviceDriver.getDevicecode()); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - standardPhotoelectricInspectSiteDeviceDriver.setApply_material(false); - } - } - this.setApply_handling(false); - } - - } catch (Exception var17) { - return; - } - - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - return; - case 2: - //申请任务 -// if (this.getApply_handling()) { -// String link_device_code = this.getDevice().getExtraValue().get("link_device_code").toString(); -// DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); -// Device link_device = appService.findDeviceByCode(link_device_code); -// StandardInspectSiteDeviceDriver standardInspectSiteDevicedriver; -// if(link_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { -// standardInspectSiteDevicedriver = (StandardInspectSiteDeviceDriver) link_device.getDeviceDriver(); -// if(standardInspectSiteDevicedriver.getMode() != 2){ -// log.debug("设备未待机"); -// return; -// } -// if(standardInspectSiteDevicedriver.getMove() != 0){ -// log.debug("设备不满足放货条件"); -// return; -// } -// -// //如果目标设备申请叫料 则允许生成任务 -// if(standardInspectSiteDevicedriver.getApply_material()){ -// TaskDto dto = new TaskDto(); -// String now = DateUtil.now(); -// dto.setTask_id(IdUtil.simpleUUID()); -// dto.setCreate_by(this.getDevice().getDevice_code()); -// dto.setUpdate_by(this.getDevice().getDevice_code()); -// dto.setStart_point_code(this.getDevice().getDevice_code()); -// -// String taskcode = CodeGenerateUtil.getNewCode("TASK_NO"); -// dto.setTask_code("-"+taskcode); -// dto.setTask_status("0"); -// dto.setPriority("101"); -// RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); -// String next_device_codecode = jo.getNext_device_code(); -// if(StrUtil.isEmpty(next_device_codecode)){ -// throw new RuntimeException("该设备未找到对应路由"); -// } -// dto.setNext_point_code(next_device_codecode); -// dto.setUpdate_time(now); -// dto.setCreate_time(now); -// -// WQLObject wo = WQLObject.getWQLObject("acs_task"); -// JSONObject json = (JSONObject) JSONObject.toJSON(dto); - -// wo.insert(json); -// standardInspectSiteDevicedriver.setApply_material(false); -// } -// } -// this.setApply_handling(false); -// } - - } - - switch (flag) { - //取货完成 - case 1: - writing(2); - return; - //放货完成 - case 2: - writing(3); - return; - - } - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - } - - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.standard_inspect_site.ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.standard_inspect_site.ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.standard_inspect_site.ItemProtocol.item_to_task; - if (appendMessage == null) { - appendMessage = ""; - } - if (instruction != null) { - instruction_num = Integer.parseInt(instruction.getInstruction_code()); - } - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, 1); - itemMap.put(to_task, instruction_num); - ReadUtil.write(itemMap, server); - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + org.nl.acs.device_driver.standard_inspect_site.ItemProtocol.item_to_command; - - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - ReadUtil.write(itemMap, server); - - } - - public void writing(int type, int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - String to_container_type = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_container_type; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - if (type == 1) { - itemMap.put(to_command, command); - } else if (type == 2) { - itemMap.put(to_target, command); - - } else if (type == 3) { - itemMap.put(to_task, command); - } else if (type == 4) { - itemMap.put(to_container_type, command); - } - ReadUtil.write(itemMap, server); - - } - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_rgv/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_rgv/ItemProtocol.java deleted file mode 100644 index cbd0060..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_rgv/ItemProtocol.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.nl.acs.device_driver.standard_rgv; - -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_container_type = "container_type"; - public static String item_error = "error"; - public static String item_task = "task"; - public static String item_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_onset = "to_onset"; - public static String item_to_task = "to_task"; - public static String item_weight = "weight"; - public static String item_to_container_type = "to_container_type"; - - private StandardRGVDeviceDriver driver; - - public ItemProtocol(StandardRGVDeviceDriver 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 getWalk_y() { - return this.getOpcIntegerValue(item_walk_y); - } - - public int getContainer_type() { - return this.getOpcIntegerValue(item_container_type); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getToTarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getToOnset() { - return this.getOpcIntegerValue(item_to_onset); - } - - public int getToTask() { - return this.getOpcIntegerValue(item_to_task); - } - - public int getTo_container_type() { - return this.getOpcIntegerValue(item_to_container_type); - } - - //是否有货 - public int hasGoods(int move) { - return move; - } - - Boolean isonline; - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B2", Boolean.valueOf(true))); - list.add(new ItemDto(item_move, "光电开关信号", "DB600.B3")); - list.add(new ItemDto(item_action, "动作信号", "DB600.B4")); - list.add(new ItemDto(item_walk_y, "行走列", "DB600.B5")); - list.add(new ItemDto(item_container_type, "托盘类型", "DB600.B6")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B7")); - list.add(new ItemDto(item_task, "任务号", "DB600.D10")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_onset, "起始站", "DB601.W4")); - list.add(new ItemDto(item_to_target, "目标站", "DB601.W6")); - list.add(new ItemDto(item_to_container_type, "托盘类型", "DB601.W8")); - list.add(new ItemDto(item_to_task, "任务号", "DB601.D10")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_rgv/StandardRGVDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_rgv/StandardRGVDeviceDriver.java deleted file mode 100644 index 870c065..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_rgv/StandardRGVDeviceDriver.java +++ /dev/null @@ -1,363 +0,0 @@ -package org.nl.acs.device_driver.standard_rgv; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.utils.SpringContextHolder; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * RGV驱动 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class StandardRGVDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - @Autowired - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); - @Autowired - DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class); - @Autowired - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - private Date instruction_apply_time = new Date(); - private int instruction_require_time_out = 3000; - - //请求成功标记 - Boolean requireSucess = false; - //申请指令成功标记 - Boolean applySucess = false; - - int mode = 0; - int error = 0; - int move = 0; - int task = 0; - int action = 0; - int container_type = 0; - //行走列 - int walk_y = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - int last_action = 0; - int last_container_type = 0; - int last_walk_y = 0; - Boolean isonline = true; - int hasGoods = 0; - String message = null; - Boolean iserror = false; - - String Container = null; - String device_code = null; - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - String material; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - int flag; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() throws Exception { - String message = null; - try { - device_code = this.getDeviceCode(); - mode = this.itemProtocol.getMode(); - error = this.itemProtocol.getError(); - move = this.itemProtocol.getMove(); - walk_y = this.itemProtocol.getWalk_y(); - container_type = this.itemProtocol.getContainer_type(); - action = this.itemProtocol.getAction(); - task = this.itemProtocol.getTask(); - hasGoods = this.itemProtocol.getMove(); - - if (mode != last_mode) { - } - if (move != last_move) { - } - if (error != last_error) { - } - if (container_type != last_container_type) { - } - - - } catch (Exception var17) { - return; - } - - if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - this.setIserror(true); - message = "信号量同步异常"; - //未联机 - } else if (mode == 0) { - this.setIsonline(false); - this.setIserror(true); - message = "未联机"; - //有报警 - } else if (error != 0) { - this.setIsonline(false); - this.setIserror(true); - message = "有报警"; - //无报警 - } else { - this.setIsonline(true); - this.setIserror(false); - message = ""; - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - return; - case 2: - //申请任务 - if (mode == 2 && walk_y == 1 && move == 0 && !applySucess ) { - instruction_apply(); - } - - - } - - switch (flag) { - //取货完成 - case 1: - writing(2); - return; - //放货完成 - case 2: - writing(3); - return; - - } - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - } - - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - if (appendMessage == null) { - appendMessage = ""; - } - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - public void writing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - ReadUtil.write(itemMap, server); - - } - - public void writing(int type, int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_onset = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_onset; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - if (type == 1) { - itemMap.put(to_command, command); - } else if (type == 2) { - itemMap.put(to_target, command); - - } else if (type == 3) { - itemMap.put(to_task, command); - } - ReadUtil.write(itemMap, server); - } - - - public void writing(Instruction inst) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_onset = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_onset; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, 1); - itemMap.put(to_onset,appService.findDeviceByCode(inst.getStart_device_code()).getAddress()); - itemMap.put(to_target,appService.findDeviceByCode(inst.getNext_device_code()).getAddress()); - itemMap.put(to_task, inst.getInstruction_code()); - ReadUtil.write(itemMap, server); - } - - /** - * 请求指令 - */ - public synchronized boolean instruction_apply() 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 { - this.instruction_require_time = date; - - Object[] value = (Object[])this.device.getExtraValue().get("get_device_code"); - Object[] value2 = (Object[])this.device.getExtraValue().get("put_device_code"); - - for (int i = 0; i < value.length; i++) { - String get_device_code = value[i].toString(); - //Device device = appService.findDeviceByCode(get_device_code); - TaskDto task = taskserver.findByStartCode(get_device_code); - if(!ObjectUtil.isEmpty(task)){ - for(int j=0;j getDeviceDriverType() { - return StandardRGVDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B2", true)); - list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "DB600.B3")); - list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "DB600.B4")); - list.add(new ItemDto(ItemProtocol.item_walk_y, "行走列", "DB600.B5")); - list.add(new ItemDto(ItemProtocol.item_container_type, "托盘类型", "DB600.B6")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B7")); - list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB600.D10")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_scanner/StandardScannerDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_scanner/StandardScannerDefination.java deleted file mode 100644 index 867b752..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_scanner/StandardScannerDefination.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.nl.acs.device_driver.standard_scanner; - -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.DeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * 扫码器 - */ -@Service -public class StandardScannerDefination implements DeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_scanner"; - } - - @Override - public String getDriverName() { - return "标准版-扫码器"; - } - - @Override - public String getDriverDescription() { - return "标准版-扫码器"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardScannerDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return StandardScannerDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.scanner); - return types; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_scanner/StandardScannerDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_scanner/StandardScannerDeviceDriver.java deleted file mode 100644 index 93dced7..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_scanner/StandardScannerDeviceDriver.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.nl.acs.device_driver.standard_scanner; - -import cn.hutool.core.util.StrUtil; -import lombok.Data; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.ScannerDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractDeviceDriver; -import org.nl.acs.socket.SocketConfig; -import org.nl.modules.udw.UnifiedDataAccessor; -import org.nl.modules.udw.UnifiedDataAccessorFactory; - - -/** - * 标准版扫码器 - */ -@Slf4j -@Data -public class StandardScannerDeviceDriver extends AbstractDeviceDriver implements ScannerDeviceDriver, DeviceDriver { - - UnifiedDataAccessor accessor_value; - - public StandardScannerDeviceDriver() { - this.accessor_value = UnifiedDataAccessorFactory.getAccessor(SocketConfig.udw_unit_key); - } - - public String getIp() { - String ip = (String) this.getDevice().getExtraValue().get("scannerIP"); - return StrUtil.isEmpty(ip) ? null : ip; - } - - public String readBarcode() throws Exception { - String ip = this.getIp(); - if (StrUtil.isEmpty(ip)) { - throw new Exception("ip未配置"); - } else { - String result = (String) this.accessor_value.getValue(this.getIp()); - return result; - } - } - - public void writeBarcode(String barcode) throws Exception { - String ip = this.getIp(); - if (StrUtil.isEmpty(ip)) { - throw new Exception("ip未配置"); - } else { - this.accessor_value.setValueWithPersistence(this.getIp(), barcode); - } - } - - public void cleanBarcode() throws Exception { - String ip = this.getIp(); - if (StrUtil.isEmpty(ip)) { - throw new Exception("ip未配置"); - } else { - this.accessor_value.setValueWithPersistence(this.getIp(), (Object) null); - } - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_special_inspect_site/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_special_inspect_site/ItemProtocol.java deleted file mode 100644 index 01ada8c..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_special_inspect_site/ItemProtocol.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.nl.acs.device_driver.standard_special_inspect_site; - -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_error = "error"; - public static String item_task = "task"; - public static String item_to_command = "to_command"; - public static String item_to_target = "to_target"; - public static String item_to_task = "to_task"; - Boolean isonline; - - private StandardSpecialInspectSiteDeviceDriver driver; - - public ItemProtocol(StandardSpecialInspectSiteDeviceDriver 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 getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getTask() { - return this.getOpcIntegerValue(item_task); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - public int getToTarget() { - return this.getOpcIntegerValue(item_to_target); - } - - public int getToTask() { - return this.getOpcIntegerValue(item_to_task); - } - - - //是否有货 - public int hasGoods(int move) { - return move; - } - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(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, "心跳", "DB600.B0")); - list.add(new ItemDto(item_mode, "工作状态", "DB600.B1", Boolean.valueOf(true))); - list.add(new ItemDto(item_move, "光电开关信号", "DB600.B2")); - list.add(new ItemDto(item_action, "取放信号", "DB600.B3")); - list.add(new ItemDto(item_error, "报警信号", "DB600.B6")); - list.add(new ItemDto(item_task, "任务号", "DB600.D7")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "DB601.W2", Boolean.valueOf(true))); - list.add(new ItemDto(item_to_target, "目标站", "DB601.W4")); - list.add(new ItemDto(item_to_task, "任务号", "DB601.D8")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_special_inspect_site/StandardSpecialInspectSiteDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_special_inspect_site/StandardSpecialInspectSiteDefination.java deleted file mode 100644 index a5312f9..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_special_inspect_site/StandardSpecialInspectSiteDefination.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.nl.acs.device_driver.standard_special_inspect_site; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 专机设备交互站点驱动定义 - * 说明:该站点为专机设备交互站点 - */ -@Service -public class StandardSpecialInspectSiteDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_special_inspect_site"; - } - - @Override - public String getDriverName() { - return "标准版-专机设备-检测站点"; - } - - @Override - public String getDriverDescription() { - return "标准版-专机设备-检测站点"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardSpecialInspectSiteDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return StandardSpecialInspectSiteDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB51.B0")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB51.B1", true)); - list.add(new ItemDto(ItemProtocol.item_move, "光电开关信号", "DB51.B2")); - list.add(new ItemDto(ItemProtocol.item_action, "取放信号", "DB51.B3")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB51.B6")); - list.add(new ItemDto(ItemProtocol.item_task, "任务号", "DB51.D8")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_special_inspect_site/StandardSpecialInspectSiteDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_special_inspect_site/StandardSpecialInspectSiteDeviceDriver.java deleted file mode 100644 index cc30200..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_special_inspect_site/StandardSpecialInspectSiteDeviceDriver.java +++ /dev/null @@ -1,472 +0,0 @@ -package org.nl.acs.device_driver.standard_special_inspect_site; - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -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.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -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.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.WcsConfig; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.*; - -/** - * 专机设备交互站点 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class StandardSpecialInspectSiteDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - String devicecode; - int mode = 0; - int error = 0; - int move = 0; - int task = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - Boolean isonline = true; - int hasGoods = 0; - Boolean iserror = false; - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - boolean isFold = false; - private String assemble_check_tag; - private Boolean sampleMode0; - private Boolean sampleMode3; - private Integer sampleError; - private Boolean sampleOnline; - protected String displayMessage = null; - public int display_message_time_out = 30000; - public Date display_message_time; - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - //备注 - String remark; - //数量 - String qty; - //物料 - String material; - //当前指令 - Instruction inst = null; - //上次指令 - Instruction last_inst = null; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - - String message = null; - String device_code; - try { - device_code = this.getDeviceCode().toString(); - - mode = this.itemProtocol.getMode(); - error = this.itemProtocol.getError(); - move = this.itemProtocol.getMove(); - task = this.itemProtocol.getTask(); - hasGoods = this.itemProtocol.hasGoods(move); - - } catch (Exception var17) { - return; - } - - //急停 - if (this.isStop()) { - - //未在线无心跳 - } else if (!this.itemProtocol.getIsonline()) { - this.setIsonline(false); - message = "信号量同步异常"; - - //未联机 - } else if (mode == 0) { - this.setIserror(true); - message = "信号量同步异常"; - //有报警 - } else if (error != 0) { - this.setIserror(true); - message = "报警"; - //无报警 - } else { - - Instruction instruction = null; - List toInstructions; - switch (mode) { - case 1: - log.debug("设备运转模式:等待工作"); - return; - case 2: - - if (task > 0 && task != last_task) { - Instruction inst = (Instruction) instructionService.findByCodeFromCache(String.valueOf(task)); - //指令号起点与当前设备相同 则指令执行中 - if (StrUtil.equals(inst.getStart_point_code(), this.getDeviceCode()) && - task != 0 && task != last_task & move > 0) { - branchProtocol = 3; - } - //指令号终点与当前设备相同、有货、指令号与当前设备指令号相同则指令完成 - if (StrUtil.equals(inst.getNext_point_code(), this.getDeviceCode()) && - task != 0 && task != last_task & move > 0) { - branchProtocol = 4; - } - } - break; - - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - if (move != last_move) { - requireSucess = true; - } - if (move > 0 && requireSucess) { - String barcode = this.getLast_container(); - barcode = "T123456"; - if (StrUtil.isEmpty(barcode)) { - message = "无托盘编号,请补码"; - return; - } - - if (StrUtil.isEmpty(this.getLast_container_type_desc())) { - this.instruction_require(barcode); - } else { - this.instruction_require(barcode, this.getLast_container_type_desc()); - } - } - break; - default: - - } - - - switch (branchProtocol) { - case 1: - if (this.getDevice().getIs_exist()) { - message = "出口:有货等待作业"; - - } else if (mode == 2) { - try { -// if (StrUtil.isEmpty(container)) { -// //判断条码是否为空,否则申请任务 -// return; -// } - - - } catch (Exception var21) { - message = "申请指令异常"; - log.debug("申请指令异常"); - } - } else { - message = "设备运转中, 待申请指令"; - log.debug("设备运转中, 待申请指令"); - } - break; - case 2: - if (mode == 2) { - try { - - this.executing(instruction); - - } catch (Exception var20) { - message = "指令下发异常"; - - } - } else { - message = "设备运转中,待下发指令"; - - } - break; - case 3: - if (mode == 2) { - try { - //执行中 - Instruction inst = instructionService.findByCodeFromCache(String.valueOf(instruction_num)); - if (StrUtil.equals(inst.getInstruction_status(), "1")) { - inst.setInstruction_status("1"); - instructionService.update(inst); - last_task = task; - } - - } catch (Exception var20) { - message = "指令异常"; - - } - } else { - message = "设备运转中"; - - } - break; - case 4: - if (mode == 2) { - try { - Instruction inst = instructionService.findByCodeFromCache(String.valueOf(task)); - this.finish_instruction(inst); - } catch (Exception var19) { - message = "指令完成异常"; - - } - } else { - message = "设备运转中,待完成指令"; - - } - break; - default: - - } - } - - last_mode = mode; - last_error = error; - last_move = move; - last_task = task; - } - - - public void finish_instruction(Instruction instruction) throws Exception { - instruction_finished(instruction); - } - - /** - * 完成指令 - * - * @param instruction - * @return - */ - public boolean instruction_finished(Instruction instruction) throws Exception { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - instructionService.finish(instruction.getInstruction_id()); - this.instruction_finished_time = date; - return true; - } - } - - /** - * 完成并创建下一条指令 - * - * @param instruction - * @param needCreateNext - * @return - */ - public boolean instruction_finished(Instruction instruction, boolean needCreateNext) { - Date date = new Date(); - if (date.getTime() - this.instruction_finished_time.getTime() < (long) this.instruction_finished_time_out) { - log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_finished_time_out); - return false; - } else { - this.instruction_finished_time = date; - return true; - } - } - - - private Instruction findInstruction() { - Instruction instruction = null; - if (this.instruction_num != 0) { - instruction = (Instruction) instructionService.findByCodeFromCache(String.valueOf(instruction_num)); - } - if (instruction != null) { - //可进行校验 - - - } else { - List container_instructions = new ArrayList(); - String barcode = this.getLast_container(); - - if (!StrUtil.isEmpty(barcode)) { - Map map = new HashMap(); - map.put("vehicle_code", barcode); - container_instructions = instructionService.queryAll(map); - } - - if (((List) container_instructions).size() > 1) { - log.debug("容器存在多个指令"); - } else { - if (((List) container_instructions).size() > 0) { - instruction = (Instruction) ((List) container_instructions).get(0); - } - } - } - return instruction; - } - - - public boolean exe_error() { - if (this.error == 0) { - return true; - } else { - log.debug("设备报警"); - return false; - } - } - - protected void thingToNothing() { - log.debug("从有货到无货 清理数据"); - this.set_last_container(container, container_type_desc); - } - - public void set_last_container(String barcode, String type_desc) { - this.set_last_container(barcode); - this.set_last_container_type_desc(type_desc); - } - - public void set_last_container(String barcode) { - } - - public void set_last_container_type_desc(String type) { - } - - public boolean exe_business() { - return true; - } - - protected void executing(Instruction instruction) { - this.executing(1, instruction, ""); - } - - public void executing(int command, Instruction instruction, String appendMessage) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_target; - String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_task; - if (appendMessage == null) { - appendMessage = ""; - } - if (instruction != null) { - instruction_num = Integer.parseInt(instruction.getInstruction_code()); - } - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, 1); - itemMap.put(to_task, instruction_num); - ReadUtil.write(itemMap, server); - - } - - public void executing(Server server, Map itemMap) { - ReadUtil.write(itemMap, server); - } - - - public boolean instruction_require(String container_code) { - return instruction_require(container_code, WcsConfig.task_container_type_default_desc); - } - - /** - * 请求指令 - * - * @param container_code - * @param container_type - */ - public synchronized boolean instruction_require(String container_code, String container_type) { - 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 { - this.instruction_require_time = date; - TaskDto dto = new TaskDto(); - String now = DateUtil.now(); - dto.setTask_id(IdUtil.simpleUUID()); - dto.setCreate_by(this.getDevice().getDevice_code()); - dto.setUpdate_by(this.getDevice().getDevice_code()); - dto.setStart_point_code(this.getDevice().getDevice_code()); - dto.setVehicle_code(container_code); - dto.setVehicle_type(container_type); - - String taskcode = CodeUtil.getNewCode("TASK_NO"); - dto.setTask_code("-" + taskcode); - dto.setTask_status("0"); - dto.setPriority("101"); - RouteLineDto jo = routelineserver.findByCode(this.getDevice().getDevice_code()); - String next_device_codecode = jo.getNext_device_code(); - if (StrUtil.isEmpty(next_device_codecode)) { - throw new RuntimeException("该设备未找到对应路由"); - } - dto.setNext_point_code(next_device_codecode); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - requireSucess = false; - return true; - } - } - - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_storage/StandardStorageDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_storage/StandardStorageDefination.java deleted file mode 100644 index fa5b71d..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_storage/StandardStorageDefination.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.nl.acs.device_driver.standard_storage; - -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.DeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * 货架 - */ -@Service -public class StandardStorageDefination implements DeviceDriverDefination { - @Override - public String getDriverCode() { - return "standard_storage"; - } - - @Override - public String getDriverName() { - return "标准版-货架"; - } - - @Override - public String getDriverDescription() { - return "标准版-货架"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StandardStorageDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return StandardStorageDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.storage); - return types; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_storage/StandardStorageDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_storage/StandardStorageDeviceDriver.java deleted file mode 100644 index 5765682..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/standard_storage/StandardStorageDeviceDriver.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.nl.acs.device_driver.standard_storage; - -import lombok.Data; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.StorageDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractDeviceDriver; - - -/** - * 标准版货架 - */ -@Slf4j -@Data -public class StandardStorageDeviceDriver extends AbstractDeviceDriver implements RouteableDeviceDriver, StorageDeviceDriver, DeviceDriver { - public StandardStorageDeviceDriver() { - - } - - public boolean isTakeReady() { - return true; - } - - public boolean isPutReady() { - return true; - } - - public boolean fixTypes(Integer type) { - return true; - } - - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/traffic_light/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/traffic_light/ItemProtocol.java deleted file mode 100644 index 5f49e02..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/traffic_light/ItemProtocol.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.nl.acs.device_driver.traffic_light; - -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; - -import java.util.ArrayList; -import java.util.List; - -@Slf4j -public class ItemProtocol { - public static String item_heartbeat = "heartbeat"; - public static String item_mode = "mode"; - public static String item_action = "action"; - public static String item_error = "error"; - public static String item_to_command = "to_command"; - - - private TrafficLightDeviceDriver driver; - - public ItemProtocol(TrafficLightDeviceDriver driver) { - this.driver = driver; - } - - public int getHeartbeat() { - return this.getOpcIntegerValue(item_heartbeat); - } - - public int getMode() { - return this.getOpcIntegerValue(item_mode); - } - - public int getAction() { - return this.getOpcIntegerValue(item_action); - } - - public int getError() { - return this.getOpcIntegerValue(item_error); - } - - public int getToCommand() { - return this.getOpcIntegerValue(item_to_command); - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - //log.error("读取错误!"); - } else { - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_heartbeat, "心跳", "D00000")); - list.add(new ItemDto(item_mode, "工作状态", "D00010", Boolean.valueOf(true))); - list.add(new ItemDto(item_action, "动作信号", "D00012")); - list.add(new ItemDto(item_error, "报警信号", "D00014")); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_command, "作业命令", "D00016", Boolean.valueOf(true))); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/traffic_light/TrafficLightDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/traffic_light/TrafficLightDefination.java deleted file mode 100644 index e863afe..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/traffic_light/TrafficLightDefination.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.nl.acs.device_driver.traffic_light; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 标准版-交通灯-欧姆龙plc - */ -@Service -public class TrafficLightDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "traffic_light"; - } - - @Override - public String getDriverName() { - return "标准版-交通灯-欧姆龙plc"; - } - - @Override - public String getDriverDescription() { - return "标准版-交通灯-欧姆龙plc"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new TrafficLightDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return TrafficLightDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "D00000")); - list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "D00010", true)); - list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "D00012")); - list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "D00014")); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/traffic_light/TrafficLightDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/traffic_light/TrafficLightDeviceDriver.java deleted file mode 100644 index b7c6f88..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/traffic_light/TrafficLightDeviceDriver.java +++ /dev/null @@ -1,152 +0,0 @@ -package org.nl.acs.device_driver.traffic_light; - -import com.alibaba.fastjson.JSONObject; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.opc.Device; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.task.service.TaskService; -import org.nl.utils.SpringContextHolder; -import org.openscada.opc.lib.da.Server; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -/** - * 标准版-交通灯-欧姆龙plc - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class TrafficLightDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - @Autowired - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - @Autowired - DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - //放货准备锁 - String putReadyLock = null; - //有货标记 - protected boolean has_goods_tag = false; - String devicecode; - int mode = 0; - int action = 0; - int error = 0; - int move = 0; - int task = 0; - int last_action = 0; - int last_mode = 0; - int last_error = 0; - int last_move = 0; - int last_task = 0; - - boolean hasVehicle = false; - boolean isReady = false; - protected int instruction_num = 0; - protected int instruction_num_truth = 0; - protected boolean hasGoods = false; - boolean isFold = false; - private String assemble_check_tag; - private Boolean sampleMode0; - private Boolean sampleMode3; - private Integer sampleError; - private Boolean sampleOnline; - protected String displayMessage = null; - public int display_message_time_out = 30000; - public Date display_message_time; - protected String current_stage_instruction_message; - protected String last_stage_instruction_message; - Integer heartbeat_tag; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - boolean requireSucess = false; - - private int instruction_finished_time_out; - - int branchProtocol = 0; - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - String message = null; - - String device_code = this.getDevice().getDevice_code(); - mode = this.itemProtocol.getMode(); - action = this.itemProtocol.getAction(); - error = this.itemProtocol.getError(); - if (mode != last_mode) { - } - if (action != last_action) { - } - if (error != last_error) { - } - last_action = action; - last_mode = mode; - last_error = error; - - - } - - public synchronized String getStatus() { - JSONObject jo = new JSONObject(); - - if (action == 1) { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "OPEN"); - - } else if (action == 2) { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "CLOSE"); - - } else { - jo.put("name", this.getDevice().getDevice_code()); - jo.put("status", "ERROR"); - } - return jo.toString(); - } - - - public void writing(int command) { - String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + ItemProtocol.item_to_command; - - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_command, command); - ReadUtil.write(itemMap, server); - log.info("下发PLC信号:{},{}", to_command, command); - System.out.println("设备:" + devicecode + ",下发PLC信号:" + to_command + ",value:" + command); - } - - public synchronized void OpenOrClose(String type) { - - writing(Integer.parseInt(type)); - - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/weighing_site/WeighingSiteDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/weighing_site/WeighingSiteDefination.java deleted file mode 100644 index 6a09715..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/weighing_site/WeighingSiteDefination.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.nl.acs.device_driver.weighing_site; - -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.DeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * 货架 - */ -@Service -public class WeighingSiteDefination implements DeviceDriverDefination { - @Override - public String getDriverCode() { - return "weighing_site"; - } - - @Override - public String getDriverName() { - return "标准版-称重设备-无PLC"; - } - - @Override - public String getDriverDescription() { - return "标准版-称重设备-无PLC"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new WeighingSiteDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return WeighingSiteDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/weighing_site/WeighingSiteDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/weighing_site/WeighingSiteDeviceDriver.java deleted file mode 100644 index 7955aa6..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/weighing_site/WeighingSiteDeviceDriver.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.nl.acs.device_driver.weighing_site; - -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.ObjectUtils; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.task.service.TaskService; -import org.nl.utils.SpringContextHolder; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Date; - - -/** - * 称重站点 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class WeighingSiteDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver { - @Autowired - RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); - @Autowired - TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl"); - - Integer hasGoods = 0; - int error = 0; - Boolean iserror = false; - Boolean islock = false; - - int branchProtocol = 0; - int last_branchProtocol = 0; - //是否需要输入物料 - String input_material = "0"; - //备注 - String remark = ""; - //数量 - String qty = ""; - //批次 - String batch = ""; - //物料 - String material = ""; - //目标点位 - String purpose = ""; - //当前指令 - Instruction inst = null; - String inst_message; - //上次指令 - Instruction last_inst = null; - - boolean requireSucess = false; - - //触摸屏手动触发任务 - private Boolean is_has_task = false; - - //申请搬运任务 - private Boolean apply_handling = false; - //申请物料 - private Boolean apply_material = false; - - // 1取货完成 2放货完成 3进入区域 4离开区域 - private int flag; - - String devicecode; - String container; - String container_type_desc; - String last_container_type_desc; - String last_container; - private Date instruction_require_time = new Date(); - private Date instruction_finished_time = new Date(); - - private int instruction_require_time_out; - - String message; - - int mode = 2; - - int move; - - @Override - public void execute() { - if (!ObjectUtils.isEmpty(inst)) { - inst_message = "任务号:" + inst.getTask_code() + ",指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code(); - } - } -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_ball_mill_device/BallMillDeviceDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_ball_mill_device/BallMillDeviceDefination.java deleted file mode 100644 index 239e49c..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_ball_mill_device/BallMillDeviceDefination.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.nl.acs.device_driver.whxr.whxr_ball_mill_device; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 自动门驱动定义 - */ -@Service -public class BallMillDeviceDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "whxr_ball_mill"; - } - - @Override - public String getDriverName() { - return "武汉新锐-球磨机"; - } - - @Override - public String getDriverDescription() { - return "武汉新锐-球磨机"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new BallMillDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return BallMillDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_ball_mill_device/BallMillDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_ball_mill_device/BallMillDeviceDriver.java deleted file mode 100644 index 1855ef6..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_ball_mill_device/BallMillDeviceDriver.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.nl.acs.device_driver.whxr.whxr_ball_mill_device; - -import cn.hutool.core.util.StrUtil; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.opc.Device; -import org.openscada.opc.lib.da.Server; - -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; - -/** - * 武汉新锐-球磨机 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class BallMillDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - - } - - public static Boolean isExistFieldName(String fieldName, Object obj) throws NoSuchFieldException { - if (obj == null || StrUtil.isEmpty(fieldName)) { - return null; - } - //获取这个类的所有属性 - Field[] fields = obj.getClass().getDeclaredFields(); - boolean flag = false; - //循环遍历所有的fields - for (int i = 0; i < fields.length; i++) { - if (fields[i].getName().equals(fieldName)) { - flag = true; - break; - } - } - return flag; - } - - - public void writing(String param, String value) { - - String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + param; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_param, Integer.parseInt(value)); - - ReadUtil.write(itemMap, server); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_ball_mill_device/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_ball_mill_device/ItemProtocol.java deleted file mode 100644 index 78bce71..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_ball_mill_device/ItemProtocol.java +++ /dev/null @@ -1,102 +0,0 @@ -package org.nl.acs.device_driver.whxr.whxr_ball_mill_device; - -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; - -import java.util.ArrayList; -import java.util.List; - -@Slf4j -public class ItemProtocol { - //喷雾塔故障 0否 1是 - public static String item_to_error = "to_error"; - //98%酒精选择 0否 1是 - public static String item_to_alcohol1 = "to_alcohol1"; - //92%酒精选择 0否 1是 - public static String item_to_alcohol2 = "to_alcohol2"; - //预磨次数设定 - public static String item_to_pre_grinding_number = "to_pre_grinding_number"; - //预磨1时间设定值(小时) - public static String item_to_pre_grinding1_time = "to_pre_grinding1_time"; - //预磨2时间设定值(小时) - public static String item_to_pre_grinding2_time = "to_pre_grinding2_time"; - //预磨1酒精设定值 - public static String item_to_pre_grinding1_alcohol = "to_pre_grinding1_alcohol"; - //预磨2酒精设定值 - public static String item_to_pre_grinding2_alcohol = "to_pre_grinding2_alcohol"; - //预磨时间设定值(小时) - public static String item_to_pre_grinding_time = "to_pre_grinding_time"; - //工艺酒精加量设定值 - public static String item_to_process_alcohol = "to_process_alcohol"; - //第一次续磨时间设定(小时) - public static String item_to_continue1_time = "to_to_continue1_time"; - //第二次续磨时间设定(小时) - public static String item_to_continue2_time = "to_to_continue2_time"; - //补磨阶段运行时间设置 - public static String item_to_supplement_grinding_runningtime = "to_supplement_grinding_runningtime"; - //卸料次数设定值 - public static String item_to_discharge_time = "to_discharge_time"; - //卸料酒精每次加量设定值 - public static String item_to_discharge_addalcohol = "to_discharge_addalcohol"; - //卸料加酒精间隔时间设定 - public static String item_to_discharge_addalcohol_interval = "to_discharge_addalcohol_interval"; - //复杂清洗次数设定值 - public static String item_to_cleaning_number = "to_to_cleaning_number"; - //卸料加酒精间隔时间设定 - public static String item_to_cleaning_addalcohol = "to_cleaning_addalcohol"; - //复杂清洗间隔时间设定值(分钟) - public static String item_to_cleaning_interval_time = "to_cleaning_interval_time"; - - private BallMillDeviceDriver driver; - - public ItemProtocol(BallMillDeviceDriver driver) { - this.driver = driver; - } - - public ItemProtocol() { - - } - - - public int getOpcIntegerValue(String protocol) { - Integer value = this.driver.getIntegeregerValue(protocol); - if (value == null) { - log.error("读取错误!"); - } else { - return value; - } - return 0; - - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_error, "喷雾塔故障", "DB200.D0")); - list.add(new ItemDto(item_to_alcohol1, "98%酒精选择", "DB200.B371.3")); - list.add(new ItemDto(item_to_alcohol2, "92%酒精选择", "DB200.B371.4")); - list.add(new ItemDto(item_to_pre_grinding_number, "预磨次数设定", "DB200.D132")); - list.add(new ItemDto(item_to_pre_grinding1_time, "预磨1时间设定值(小时)", "DB200.D242")); - list.add(new ItemDto(item_to_pre_grinding2_time, "预磨2时间设定值(小时)", "DB200.D256")); - list.add(new ItemDto(item_to_pre_grinding1_alcohol, "预磨1酒精设定值", "DB200.D120")); - list.add(new ItemDto(item_to_pre_grinding2_alcohol, "预磨2酒精设定值", "DB200.D124")); - list.add(new ItemDto(item_to_pre_grinding_time, "预磨时间设定值(小时)", "DB200.D24")); - list.add(new ItemDto(item_to_process_alcohol, "工艺酒精加量设定值", "DB200.D20")); - list.add(new ItemDto(item_to_continue1_time, "第一次续磨时间设定(小时)", "DB200.D214")); - list.add(new ItemDto(item_to_continue2_time, "第二次续磨时间设定(小时)", "DB200.D226")); - list.add(new ItemDto(item_to_supplement_grinding_runningtime, "补磨阶段运行时间设置", "DB200.D372")); - list.add(new ItemDto(item_to_discharge_time, "卸料次数设定值", "DB200.D52")); - list.add(new ItemDto(item_to_discharge_addalcohol, "卸料酒精每次加量设定值", "DB200.D44")); - list.add(new ItemDto(item_to_discharge_addalcohol_interval, "卸料加酒精间隔时间设定", "DB200.D350")); - list.add(new ItemDto(item_to_cleaning_number, "复杂清洗次数设定值", "DB200.D88")); - list.add(new ItemDto(item_to_cleaning_addalcohol, "卸料加酒精间隔时间设定", "DB200.D84")); - list.add(new ItemDto(item_to_cleaning_interval_time, "复杂清洗间隔时间设定值(分钟)", "DB200.D64")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_spary_tower_device/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_spary_tower_device/ItemProtocol.java deleted file mode 100644 index be839a9..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_spary_tower_device/ItemProtocol.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.nl.acs.device_driver.whxr.whxr_spary_tower_device; - -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; - -import java.util.ArrayList; -import java.util.List; - -@Slf4j -public class ItemProtocol { -// //设备开机 0停机 1开机 -// public static String item_open_status = "open_status"; -// //设备状态 0待生产 1生产中 -// public static String item_running_status = "unning_status"; -// //故障停机 0否 1是  -// public static String item_error_pause = "error_pause"; -// //上料手自动模式 0手动 1自动 -// public static String item_feeding_mode = "feeding_mode"; -// //自动上料请求 0否 1是  -// public static String item_auto_feeding = "auto_feeding"; -// //手动上料请求 0否 1是  -// public static String item_manual_feeding = "manual_feeding"; -// //下料手自动模式 0手动 1自动 -// public static String item_blanking_mode = "blanking_mode"; -// //下料电磁阀开到位 0否 1是  -// public static String item_blanking_open = "blanking_open"; -// //下料电磁阀关到位 0否 1是  -// public static String item_blanking_close = "blanking_close"; -// -// //每桶重量 kg -// public static String item_to_everyone_weight = "to_one_weight"; -// //是否最后一桶 0否 1是  -// public static String item_to_lastbucket = "to_last_bucket"; -// //允许出料 0否 1是  -// public static String item_to_allow_blanking = "to_allow_blanking"; -// //超时报警 0否 1是  -// public static String item_to_timeout_alarm = "to_timeout_alarm"; - - //搅拌槽夹套温度 - public static String item_to_temperature1 = "to_temperature1"; - //孔板直径 mm 0.0 - public static String item_to_diameter = "to_diameter"; - //雾化压力 KPa - public static String item_to_pressure = "to_pressure"; - //出口温度SV - public static String item_to_temperature2 = "to_temperature2"; - - - private SparyTowerDeviceDriver driver; - - public ItemProtocol(SparyTowerDeviceDriver driver) { - this.driver = driver; - } - - public String getItem_to_temperature1() { - return this.getOpcStringValue(item_to_temperature1); - } - - public String getItem_to_temperature2() { - return this.getOpcStringValue(item_to_temperature1); - } - - public String getItem_to_diameter() { - return this.getOpcStringValue(item_to_diameter); - } - - public String getItem_to_pressure() { - return this.getOpcStringValue(item_to_pressure); - } - - public String getOpcStringValue(String protocol) { - String value = this.driver.getStringValue(protocol); - if (value == null) { - log.error("读取错误!"); - } else { - return value; - } - return "0"; - } - - public static List getReadableItemDtos() { - ArrayList list = new ArrayList(); - return list; - } - - public static List getWriteableItemDtos() { - ArrayList list = new ArrayList(); - list.add(new ItemDto(item_to_temperature1, "搅拌槽夹套温度", "DB203.REAL20")); - list.add(new ItemDto(item_to_diameter, "孔板直径", "DB203.REAL24")); - list.add(new ItemDto(item_to_pressure, "雾化压力", "DB203.REAL28")); - list.add(new ItemDto(item_to_temperature2, "出口温度SV", "DB203.REAL32")); - return list; - } - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_spary_tower_device/SparyTowerDeviceDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_spary_tower_device/SparyTowerDeviceDefination.java deleted file mode 100644 index 5f92f27..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_spary_tower_device/SparyTowerDeviceDefination.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.nl.acs.device_driver.whxr.whxr_spary_tower_device; - -import org.nl.acs.device.device_driver.standard_inspect.ItemDto; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -/** - * 喷雾塔动定义 - */ -@Service -public class SparyTowerDeviceDefination implements OpcDeviceDriverDefination { - @Override - public String getDriverCode() { - return "whxr_spary_tower"; - } - - @Override - public String getDriverName() { - return "武汉新锐-喷雾塔"; - } - - @Override - public String getDriverDescription() { - return "武汉新锐-喷雾塔"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new SparyTowerDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return SparyTowerDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.conveyor); - return types; - } - - @Override - public List getReadableItemDtos() { - return getReadableItemDtos2(); - } - - public static List getReadableItemDtos2() { - List list = new ArrayList(); - return list; - } - - @Override - public List getWriteableItemDtos() { - return ItemProtocol.getWriteableItemDtos(); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_spary_tower_device/SparyTowerDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_spary_tower_device/SparyTowerDeviceDriver.java deleted file mode 100644 index 76fdf95..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_spary_tower_device/SparyTowerDeviceDriver.java +++ /dev/null @@ -1,68 +0,0 @@ -package org.nl.acs.device_driver.whxr.whxr_spary_tower_device; - -import cn.hutool.core.util.StrUtil; -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.device_driver.standard_inspect.ReadUtil; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver; -import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; -import org.nl.acs.opc.Device; -import org.openscada.opc.lib.da.Server; - -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; - -/** - * 武汉新锐-球磨机 - */ -@Slf4j -@Data -@RequiredArgsConstructor -public class SparyTowerDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver { - protected ItemProtocol itemProtocol = new ItemProtocol(this); - - @Override - public Device getDevice() { - return this.device; - } - - - @Override - public void execute() { - - } - - public static Boolean isExistFieldName(String fieldName, Object obj) throws NoSuchFieldException { - if (obj == null || StrUtil.isEmpty(fieldName)) { - return null; - } - //获取这个类的所有属性 - Field[] fields = obj.getClass().getDeclaredFields(); - boolean flag = false; - //循环遍历所有的fields - for (int i = 0; i < fields.length; i++) { - if (fields[i].getName().equals(fieldName)) { - flag = true; - break; - } - } - return flag; - } - - - public void writing(String param, String value) { - - String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() - + "." + param; - String opcservcerid = this.getDevice().getOpc_server_id(); - Server server = ReadUtil.getServer(opcservcerid); - Map itemMap = new HashMap(); - itemMap.put(to_param, Integer.parseInt(value)); - - ReadUtil.write(itemMap, server); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_storage_conveyor/StorageConveyorDefination.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_storage_conveyor/StorageConveyorDefination.java deleted file mode 100644 index 3f75392..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_storage_conveyor/StorageConveyorDefination.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.nl.acs.device_driver.whxr.whxr_storage_conveyor; - -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.DeviceDriverDefination; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceType; -import org.springframework.stereotype.Service; - -import java.util.LinkedList; -import java.util.List; - -/** - * 货架 - */ -@Service -public class StorageConveyorDefination implements DeviceDriverDefination { - @Override - public String getDriverCode() { - return "whxr_storage_conveyor"; - } - - @Override - public String getDriverName() { - return "武汉新锐-立库对接位"; - } - - @Override - public String getDriverDescription() { - return "武汉新锐-立库对接位"; - } - - @Override - public DeviceDriver getDriverInstance(Device device) { - return (new StorageConveyorDeviceDriver()).setDevice(device).setDriverDefination(this); - - } - - @Override - public Class getDeviceDriverType() { - return StorageConveyorDeviceDriver.class; - } - - @Override - public List getFitDeviceTypes() { - List types = new LinkedList(); - types.add(DeviceType.storage); - return types; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_storage_conveyor/StorageConveyorDeviceDriver.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_storage_conveyor/StorageConveyorDeviceDriver.java deleted file mode 100644 index 029fb7c..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/whxr/whxr_storage_conveyor/StorageConveyorDeviceDriver.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.nl.acs.device_driver.whxr.whxr_storage_conveyor; - -import lombok.Data; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device_driver.DeviceDriver; -import org.nl.acs.device_driver.RouteableDeviceDriver; -import org.nl.acs.device_driver.StorageDeviceDriver; -import org.nl.acs.device_driver.driver.AbstractDeviceDriver; - - -/** - * 武汉新锐-立库对接位 - */ -@Slf4j -@Data -public class StorageConveyorDeviceDriver extends AbstractDeviceDriver implements RouteableDeviceDriver, StorageDeviceDriver, DeviceDriver { - public StorageConveyorDeviceDriver() { - - } - - public boolean isTakeReady() { - return true; - } - - public boolean isPutReady() { - return true; - } - - public boolean fixTypes(Integer type) { - return true; - } - - -} - diff --git a/nladmin-system/src/main/java/org/nl/acs/ext/erp/service/AcsToErpService.java b/nladmin-system/src/main/java/org/nl/acs/ext/erp/service/AcsToErpService.java deleted file mode 100644 index 4268631..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/ext/erp/service/AcsToErpService.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.nl.acs.ext.erp.service; - - -import com.alibaba.fastjson.JSONObject; - -/** - * Created by ZZ on 2021/9/23. - */ -public interface AcsToErpService { - /** - * ACS向WMS申请任务 - * - * @param device_code 条件 - * @return JSONObject - */ - JSONObject sendDeviceToWms(String device_code); -} diff --git a/nladmin-system/src/main/java/org/nl/acs/ext/erp/service/impl/AcsToErpServiceImpl.java b/nladmin-system/src/main/java/org/nl/acs/ext/erp/service/impl/AcsToErpServiceImpl.java deleted file mode 100644 index 269dac1..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/ext/erp/service/impl/AcsToErpServiceImpl.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.nl.acs.ext.erp.service.impl; - -import cn.hutool.http.HttpRequest; -import com.alibaba.fastjson.JSONObject; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.config.AcsConfig; -import org.nl.acs.config.server.AcsConfigService; -import org.nl.acs.ext.erp.service.AcsToErpService; -import org.nl.exception.BadRequestException; -import org.nl.wql.core.bean.WQLObject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Service; - - -/** - * Created by ZZ on 2021/9/23. - */ -@Slf4j -@Service -@RequiredArgsConstructor -public class AcsToErpServiceImpl implements AcsToErpService { - @Autowired - AcsConfigService acsConfigService; - - @Override - public JSONObject sendDeviceToWms(String device_code) { - log.info("sendDeviceToWms----输入参数是:{}", device_code); - JSONObject resultJson = new JSONObject(); - JSONObject erp_map = WQLObject.getWQLObject("acs_device_erpmapping").query("device_code = '" + device_code + "'").uniqueResult(0); - if (erp_map == null) { - throw new BadRequestException("该设备:" + device_code + "未找到对应的ERP设备!"); - } - String erp_code = erp_map.getString("erp_code"); - JSONObject jo = new JSONObject(); - jo.put("device_code", erp_code); - log.info("sendDeviceToWms----erp_code是:{}", erp_code); - String result2 = ""; - try { - String url = acsConfigService.findConfigFromCache().get(AcsConfig.ERPURL).toString(); - result2 = HttpRequest.post(url) - .body(jo.toString()) - .execute().body(); - System.out.println(result2); - resultJson.put("code", HttpStatus.OK); - resultJson.put("message", "发送成功"); - } catch (Exception e) { - String msg = e.getMessage(); - //网络不通 - System.out.println(msg); - resultJson.put("code", HttpStatus.BAD_REQUEST); - resultJson.put("message", msg); - } - return resultJson; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java b/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java deleted file mode 100644 index 51ebb12..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java +++ /dev/null @@ -1,75 +0,0 @@ - -package org.nl.acs.ext.wms.rest; - - -import com.alibaba.fastjson.JSONArray; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.annotation.Log; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.Map; - -/** - * @author ludj - * @date 2021-07-21 - **/ -@RestController -@RequiredArgsConstructor -@Api(tags = "wms接口") -@RequestMapping("/api/wms") -@Slf4j -public class AcsToWmsController { - private final AcsToWmsService acstowmsService; - - @PostMapping("/applyTask") - @Log("向WMS申请任务") - @ApiOperation("向WMS申请任务") - public ResponseEntity applyTaskToWms(@RequestBody String device_code, String container_code, int height, int weight) { - return new ResponseEntity<>(acstowmsService.applyTaskToWms(device_code, container_code, height, weight), HttpStatus.OK); - } - - @PostMapping("/taskStatusFeedback") - @Log("向WMS反馈任务状态") - @ApiOperation("向WMS反馈任务状态") - public ResponseEntity feedbackTaskStatusToWms(@RequestBody Map whereJson) { - JSONArray data = JSONArray.parseArray(String.valueOf(whereJson)); - return new ResponseEntity<>(acstowmsService.feedbackTaskStatusToWms(data), HttpStatus.OK); - } - - @PostMapping("/pointStatusFeedback") - @Log("向WMS反馈点位状态") - @ApiOperation("向WMS反馈点位状态") - public ResponseEntity feedbackPointStatusToWms(@RequestBody Map whereJson) { - return new ResponseEntity<>(acstowmsService.feedbackPointStatusToWms(whereJson), HttpStatus.OK); - } - - @PostMapping("/feedbackAgvStatus") - @Log("反馈AGV设备状态") - @ApiOperation("反馈AGV设备状态") - public ResponseEntity feedbackAgvStatus(@RequestBody String device_code, String error, String error_message) { - return new ResponseEntity<>(acstowmsService.feedbackAgvStatus(device_code, error, error_message), HttpStatus.OK); - } - - @PostMapping("/feedbackAgv") - @Log("反馈AGV设备信息") - @ApiOperation("反馈AGV设备信息") - public ResponseEntity feedbackAgv(@RequestBody JSONArray from) { - return new ResponseEntity<>(acstowmsService.feedbackAgv(from), HttpStatus.OK); - } - - @PostMapping("/feedbackDeviceStatus") - @Log("反馈设备状态") - @ApiOperation("反馈设备状态") - public ResponseEntity feedbackDeviceStatus(@RequestBody String device_code, String code, String value) { - return new ResponseEntity<>(acstowmsService.feedbackDeviceStatus(device_code, code, value), HttpStatus.OK); - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java b/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java deleted file mode 100644 index 91d0bab..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java +++ /dev/null @@ -1,73 +0,0 @@ - -package org.nl.acs.ext.wms.rest; - - -import com.alibaba.fastjson.JSONObject; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.ext.wms.service.WmsToAcsService; -import org.nl.annotation.Log; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author ludj - * @date 2021-07-21 - **/ -@RestController -@RequiredArgsConstructor -@Api(tags = "wms接口") -@RequestMapping("/api/wms") -@Slf4j -public class WmsToAcsController { - private final WmsToAcsService wmstoacsService; - - @PostMapping("/task") - @Log("接收WMS任务") - @ApiOperation("接收WMS任务") - public ResponseEntity createFromWms(@RequestBody String whereJson) { - return new ResponseEntity<>(wmstoacsService.createFromWms(whereJson), HttpStatus.OK); - } - - @PostMapping("/cancelTask") - @Log("WMS取消任务") - @ApiOperation("WMS取消任务") - public ResponseEntity cancelFromWms(@RequestBody String whereJson) throws Exception { - return new ResponseEntity<>(wmstoacsService.cancelFromWms(whereJson), HttpStatus.OK); - } - - @PostMapping("/updateDeviceGoodsFromWms") - @Log("WMS修改点位状态") - @ApiOperation("WMS修改点位状态") - public ResponseEntity updateDeviceGoodsFromWms(@RequestBody String whereJson) { - return new ResponseEntity<>(wmstoacsService.updateDeviceGoodsFromWms(whereJson), HttpStatus.OK); - } - - @PostMapping("/areaControl") - @Log("区域控制") - @ApiOperation("区域控制") - public ResponseEntity areaControl(@RequestBody JSONObject whereJson) { - return new ResponseEntity<>(wmstoacsService.areaControl(whereJson), HttpStatus.OK); - } - - @PostMapping("/action") - @Log("下发动作") - @ApiOperation("WMS修改点位状态") - public ResponseEntity putAction(@RequestBody String whereJson) throws Exception { - return new ResponseEntity<>(wmstoacsService.putAction(whereJson), HttpStatus.OK); - } - - @PostMapping("/querydevice") - @Log("查询设备状态") - @ApiOperation("查询设备状态") - public ResponseEntity queryDevice(@RequestBody String whereJson) throws Exception { - return new ResponseEntity<>(wmstoacsService.queryDevice(whereJson), HttpStatus.OK); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java b/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java deleted file mode 100644 index d7f7e72..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java +++ /dev/null @@ -1,95 +0,0 @@ -package org.nl.acs.ext.wms.service; - -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSONArray; - -import java.util.Map; - -public interface AcsToWmsService { - - /** - * ACS向WMS申请任务 - */ - String applyTaskToWms(String device_code, String container_code, int height, int weight); - - /** - * 向WMS反馈任务状态 - * - * @return Map - */ - public HttpResponse feedbackTaskStatusToWms(JSONArray arr); - - /** - * 向WMS反馈点位状态 - * - * @param jsonObject 条件 - * @return Map - */ - Map feedbackPointStatusToWms(Map jsonObject); - - /** - * 向WMS获取设备状态 - * - * @return - */ - JSONArray getDeviceStatusToWms(); - - /** - * 请求信号交互 - * - * @param - * @return - */ - public HttpResponse requestSignalInteraction(String device_code, String vehicle_code, String action); - - public String requestTaskAgain(String address, String task_id, String vehicle_code); - - public String apply_InEmpty(String device_code, String type, String quantity, String pallet); - - public String apply_OutEmpty(String device_code); - - /** - * 反馈AGV设备状态 - * - * @param device_code - * @param error - * @param error_message - * @return - */ - HttpResponse feedbackAgvStatus(String device_code, String error, String error_message); - - /** - * 反馈AGV设备状态 - * - * @param device_code - * @return - */ - HttpResponse feedbackDeviceStatus(String device_code, String code, String value); - - /** - * 反馈AGV设备信息 - * - * @param from - * @return - */ - HttpResponse feedbackAgv(JSONArray from); - - /** - * 请求开门或关门 - * - * @param device_code - * @param status - * @return - */ - HttpResponse applyOpenOrCloseDoor(String device_code, String status); - - /** - * 查询自动门状态 - * - * @param - * @returna - */ - HttpResponse queryDoorsStatus(); - - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java b/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java deleted file mode 100644 index 2bf207c..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.nl.acs.ext.wms.service; - - - -import com.alibaba.fastjson.JSONObject; - -import java.util.Map; - -public interface WmsToAcsService { - /** - * 创建任务 - * - * @param jsonObject 条件 - * @return - */ - Map createFromWms(String jsonObject); - - /** - * 取消任务 - * - * @param jsonObject 条件 - * @return Map - */ - Map cancelFromWms(String jsonObject) throws Exception; - - /** - * 修改设置有无货属性 - * - * @param jsonObject 条件 - * @return Map - */ - Map updateDeviceGoodsFromWms(String jsonObject); - - /** - * 区域控制 - * - * @param jsonObject 条件 - * @return Map - */ - Map areaControl(JSONObject jsonObject); - - /** - * 下发动作 - * - * @param jsonObject 条件 - * @return Map - */ - Map putAction(String jsonObject) throws Exception; - - /** - * 查询设备状态 - * - * @param jsonObject 条件 - * @return Map - */ - Map queryDevice(String jsonObject) throws Exception; -} diff --git a/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java b/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java deleted file mode 100644 index d447177..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java +++ /dev/null @@ -1,442 +0,0 @@ -package org.nl.acs.ext.wms.service.impl; - -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpRequest; -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.config.AcsConfig; -import org.nl.acs.config.server.AcsConfigService; -import org.nl.acs.device.address.service.AddressService; -import org.nl.acs.device.address.service.dto.AddressDto; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.log.service.LogServer; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.acs.util.DateUtil; -import org.nl.exception.BadRequestException; -import org.nl.wql.core.bean.WQLObject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Service; - -import java.util.Map; - -@Service -@RequiredArgsConstructor -@Slf4j -public class AcsToWmsServiceImpl implements AcsToWmsService { - - @Autowired - AcsConfigService acsConfigService; - - @Autowired - DeviceService deviceService; - - @Autowired - AddressService addressService; - - @Autowired - TaskService taskService; - - @Autowired - LogServer logServer; - - @Value("${acsTowms.token}") - public String token; - - @Override - public String applyTaskToWms(String device_code, String container_code, int height, int weight) { - - String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL); - AddressDto addressDto = addressService.findByCode("applyTaskToWms"); - String url = wmsurl + addressDto.getMethods_url(); - JSONObject param = new JSONObject(); - param.put("height", height); - param.put("weight", weight); - String parent_device_code = ""; - JSONObject jo = new JSONObject(); - JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + device_code + "'").uniqueResult(0); - if (!device_json.isEmpty()) { - parent_device_code = (String) device_json.get("parent_storage_cell") == null ? device_code : (String) device_json.get("parent_storage_cell"); - } - jo.put("device_code", parent_device_code); - jo.put("container_code", container_code); - jo.put("param", param); - log.info("applyTaskToWms-----请求参数{}", jo.toString()); - HttpResponse result2 = null; - try { - //{"status":400,"timestamp":"2021-10-22 16:32:22","message":"业务类型不正确!"} - result2 = HttpRequest.post(url) - .header("Authorization", token) - .body(String.valueOf(jo)) - .execute(); - System.out.println(result2); - } catch (Exception e) { - String msg = e.getMessage(); - //网络不通 - System.out.println(msg); - } - String type = ""; - if (result2.getStatus() == 200) { - type = "info"; - } else { - type = "error"; - } - logServer.log("", "applyTaskToWms", type, jo.toString(), result2.body(), String.valueOf(result2.getStatus()), url, container_code); - log.info("applyTaskToWms-----输出参数{}", result2.body()); - return result2.body(); - } - - @Override - public HttpResponse feedbackTaskStatusToWms(JSONArray data) { - String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL); - - String task_code = ""; - for (int i = 0; i < data.size(); i++) { - JSONObject json = (JSONObject) data.get(i); - task_code = json.getString("task_code"); - } - TaskDto taskDto = taskService.findByCode(task_code); - String vehicle_code = taskDto.getVehicle_code(); - - HttpResponse result2 = null; - log.info("feedbackTaskStatusToWms-----请求参数{}", data.toString()); - - AddressDto addressDto = addressService.findByCode("feedbackTaskStatusToWms"); - String methods_url = addressDto.getMethods_url(); - try { - result2 = HttpRequest.post(wmsurl + methods_url) - .header("Authorization", token).body(String.valueOf(data)) - .execute(); - System.out.println(result2); - } catch (Exception e) { - String msg = e.getMessage(); - //网络不通 - System.out.println(msg); - } - - String type = ""; - if (result2.getStatus() == 200) { - type = "info"; - } else { - type = "error"; - } - - logServer.log(task_code, "feedbackTaskStatusToWms", type, data.toString(), result2.body(), String.valueOf(result2.getStatus()), wmsurl + methods_url, vehicle_code); - JSONObject jo = JSONObject.parseObject(result2.body()); - log.info("feedbackTaskStatusToWms-----输出参数{}", jo.toString()); - return result2; - } - - @Override - public Map feedbackPointStatusToWms(Map jsonObject) { - - AddressDto addressDto = addressService.findByCode("feedbackPointStatusToWms"); - String methods_url = addressDto.getMethods_url(); - String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL); - String url = wmsurl + methods_url; - - JSONObject json = new JSONObject(); - json.put("task_uuid", jsonObject.get("device_code")); - json.put("task_code", jsonObject.get("point_status")); - json.put("task_status", jsonObject.get("point_mode")); - json.put("point_error", jsonObject.get("point_error")); - log.info("feedbackPointStatusToWms----请求参数{}", json.toString()); - try { - String result2 = HttpRequest.post(url) - .body(String.valueOf(json)) - .execute().body(); - System.out.println(result2); - } catch (Exception e) { - String msg = e.getMessage(); - //网络不通 - System.out.println(msg); - - } - - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.OK); - resultJson.put("message", "操作成功"); - resultJson.put("data", new JSONArray()); - log.info("feedbackPointStatusToWms----输出参数{}", resultJson.toString()); - return resultJson; - } - - @Override - public JSONArray getDeviceStatusToWms() { - String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL); - AddressDto addressDto = addressService.findByCode("getDeviceStatusToWms"); - String methods_url = addressDto.getMethods_url(); - String url = wmsurl + methods_url; - String result = ""; - try { - result = HttpRequest.get(url) - .execute().body(); - System.out.println(result); - log.info("getTaskStatusToWms----返回参数{}", result); - } catch (Exception e) { - System.out.println(e.getMessage()); - } - JSONArray jsonArray = JSONArray.parseArray(result); - return jsonArray; - - } - - @Override - public HttpResponse requestSignalInteraction(String device_code, String vehicle_code, String action) { - String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL); - JSONObject json = new JSONObject(); - json.put("device_code", device_code); - json.put("vehicle_code", vehicle_code); - json.put("action", action); - - AddressDto addressDto = addressService.findByCode("requestSignalInteraction"); - String methods_url = addressDto.getMethods_url(); - String url = wmsurl + methods_url; - HttpResponse result = null; - log.info("requestSignalInteraction----请求参数{}", json.toString()); - try { - result = HttpRequest.post(url) - .body(String.valueOf(json)) - .execute(); - System.out.println(result); - log.info("requestSignalInteraction----返回参数{}", result); - } catch (Exception e) { - String msg = e.getMessage(); - //网络不通 - System.out.println(msg); - - } - return result; - } - - - @Override - public String requestTaskAgain(String address, String task_id, String vehicle_code) { - String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL); - String device_code = deviceService.queryDeviceCodeByAddress(Integer.parseInt(address)); - JSONObject jo = new JSONObject(); - jo.put("device_code", device_code); - jo.put("task_id", task_id); - jo.put("vehicle_code", vehicle_code); - String result2 = null; - - AddressDto addressDto = addressService.findByCode("requestTaskAgain"); - String methods_url = addressDto.getMethods_url(); - String url = wmsurl + methods_url; - log.info("requestTaskAgain----请求参数{}", jo); - - try { - result2 = HttpRequest.post(url) - .body(String.valueOf(jo)) - .execute().body(); - System.out.println(result2); - log.info("requestTaskAgain----返回参数{}", result2); - } catch (Exception e) { - String msg = e.getMessage(); - //网络不通 - System.out.println(msg); - } - return result2; - } - - @Override - public String apply_InEmpty(String device_code, String type, String quantity, String container_code) { - if (StrUtil.isEmpty(container_code)) { - log.info("apply_InEmpty----空盘入库申请校验失败,{}{}", device_code, "设备条码为空"); - throw new BadRequestException("地址对应设备未找到"); - } - String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL); - JSONObject jo = new JSONObject(); - jo.put("device_code", device_code); - jo.put("type", type); - jo.put("quantity", quantity); - jo.put("container_code", container_code); - - String result2 = ""; - - AddressDto addressDto = addressService.findByCode("apply_InEmpty"); - String methods_url = addressDto.getMethods_url(); - String url = wmsurl + methods_url; - log.info("requestTaskAgain----请求参数{}", jo); - - try { - result2 = HttpRequest.post(url) - .header("Authorization", token) - .body(String.valueOf(jo)) - .execute().body(); - System.out.println(result2); - log.info("requestTaskAgain----返回参数{}", result2); - } catch (Exception e) { - String msg = e.getMessage(); - //网络不通 - System.out.println(msg); - } - return result2; - } - - @Override - public String apply_OutEmpty(String device_code) { - String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL); - JSONObject jo = new JSONObject(); - jo.put("device_code", device_code); - String result2 = ""; - - AddressDto addressDto = addressService.findByCode("apply_OutEmpty"); - String methods_url = addressDto.getMethods_url(); - String url = wmsurl + methods_url; - log.info("apply_OutEmpty----请求参数{}", jo); - try { - result2 = HttpRequest.post(url) - .header("Authorization", token) - .body(String.valueOf(jo)) - .execute().body(); - System.out.println(result2); - log.info("apply_OutEmpty----返回参数{}", result2); - } catch (Exception e) { - String msg = e.getMessage(); - //网络不通 - System.out.println(msg); - } - return result2; - } - - @Override - public HttpResponse feedbackAgvStatus(String device_code, String error, String error_message) { - String wmsUrl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL); - - JSONObject json = new JSONObject(); - json.put("device_code", device_code); - json.put("error", error); - json.put("error_message", error_message); - - AddressDto addressDto = addressService.findByCode("feedbackAgvStatus"); - String methods_url = addressDto.getMethods_url(); - String url = wmsUrl + methods_url; - HttpResponse result = null; - log.info("feedbackAgvStatus----请求参数{}", json); - - try { - result = HttpRequest.post(url) - .body(String.valueOf(json)) - .execute(); - System.out.println(result); - log.info("feedbackAgvStatus----返回参数{}", result); - } catch (Exception e) { - String msg = e.getMessage(); - //网络不通 - System.out.println(msg); - } - return result; - } - - @Override - public HttpResponse feedbackDeviceStatus(String device_code, String code, String value) { - String wmsUrl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL); - - JSONObject json = new JSONObject(); - json.put("device_code", device_code); - json.put("back_time", DateUtil.getStringAllDate()); - JSONArray ja = new JSONArray(); - JSONObject jo = new JSONObject(); - jo.put("code", code); - jo.put("value", value); - ja.add(jo); - json.put("data", ja); - AddressDto addressDto = addressService.findByCode("feedbackDeviceStatus"); - String methods_url = addressDto.getMethods_url(); - String url = wmsUrl + methods_url; - HttpResponse result = null; - log.info("feedbackDeviceStatus----请求参数{}", json); - - try { - result = HttpRequest.post(url) - .body(String.valueOf(json)) - .execute(); - System.out.println(result); - log.info("feedbackDeviceStatus----返回参数{}", result); - } catch (Exception e) { - String msg = e.getMessage(); - //网络不通 - System.out.println(msg); - } - return result; - } - - @Override - public HttpResponse feedbackAgv(JSONArray from) { - String wmsUrl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL); - - AddressDto addressDto = addressService.findByCode("feedbackAgv"); - String methods_url = addressDto.getMethods_url(); - String url = wmsUrl + methods_url; - HttpResponse result = null; - log.info("feedbackAgv----请求参数{}", from); - - try { - result = HttpRequest.post(url) - .body(String.valueOf(from)) - .execute(); - System.out.println(result); - log.info("feedbackAgv----返回参数{}", result); - } catch (Exception e) { - String msg = e.getMessage(); - //网络不通 - System.out.println(msg); - } - return result; - } - - @Override - public HttpResponse applyOpenOrCloseDoor(String device_code, String status) { - String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL); - JSONObject jo = new JSONObject(); - jo.put("device_code", device_code); - jo.put("status", status); - HttpResponse result = null; - log.info("applyOpenOrCloseDoor-----请求参数{}", jo.toString()); - - AddressDto addressDto = addressService.findByCode("applyOpenOrCloseDoor"); - String methods_url = addressDto.getMethods_url(); - try { - result = HttpRequest.post(wmsurl + methods_url) - .body(String.valueOf(jo)) - .execute(); - System.out.println(result); - log.info("applyOpenOrCloseDoor-----返回参数{}", result); - } catch (Exception e) { - String msg = e.getMessage(); - //网络不通 - System.out.println(msg); - } - return result; - } - - @Override - public HttpResponse queryDoorsStatus() { - String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL); - - HttpResponse result = null; - log.info("queryDoorStatus-----请求"); - AddressDto addressDto = addressService.findByCode("queryDoorsStatus"); - String methods_url = addressDto.getMethods_url(); - try { - result = HttpRequest.get(wmsurl + methods_url) - .body("") - .execute(); - log.info("queryDoorStatus-----输出参数{}", result.body().toString()); - } catch (Exception e) { - String msg = e.getMessage(); - //网络不通 - System.out.println(msg); - - } - return result; - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java b/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java deleted file mode 100644 index a18d94a..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java +++ /dev/null @@ -1,863 +0,0 @@ -package org.nl.acs.ext.wms.service.impl; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.config.AcsConfig; -import org.nl.acs.config.server.AcsConfigService; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.electric_fence.ElectricFenceDeviceDriver; -import org.nl.acs.device_driver.machines_site.MachinesSiteDeviceDriver; -import org.nl.acs.device_driver.non_line_inspect_site.NonLineInspectSiteDeviceDriver; -import org.nl.acs.device_driver.non_line_manipulator_inspect_site.NonLineManipulatorInspectSiteDeviceDriver; -import org.nl.acs.device_driver.special_ordinary_site.SpecialOrdinarySiteDeviceDriver; -import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver; -import org.nl.acs.device_driver.standard_conveyor_control.StandardCoveyorControlDeviceDriver; -import org.nl.acs.device_driver.standard_conveyor_control_with_plcscanner.StandardCoveyorControlWithPlcScannerDeviceDriver; -import org.nl.acs.device_driver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; -import org.nl.acs.device_driver.standard_conveyor_monitor.StandardCoveyorMonitorDeviceDriver; -import org.nl.acs.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver; -import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; -import org.nl.acs.device_driver.standard_manipulator_inspect_site.StandardManipulatorInspectSiteDeviceDriver; -import org.nl.acs.device_driver.standard_manipulator_stacking_site.StandardManipulatorStackingSiteDeviceDriver; -import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; -import org.nl.acs.device_driver.standard_photoelectric_inspect_site.StandardPhotoelectricInspectSiteDeviceDriver; -import org.nl.acs.device_driver.standard_scanner.StandardScannerDeviceDriver; -import org.nl.acs.device_driver.weighing_site.WeighingSiteDeviceDriver; -import org.nl.acs.device_driver.whxr.whxr_ball_mill_device.BallMillDeviceDriver; -import org.nl.acs.device_driver.whxr.whxr_ball_mill_device.ItemProtocol; -import org.nl.acs.device_driver.whxr.whxr_spary_tower_device.SparyTowerDeviceDriver; -import org.nl.acs.ext.wms.service.WmsToAcsService; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.exception.WDKException; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Service; - -import java.util.List; -import java.util.Map; - -@Service -@RequiredArgsConstructor -@Slf4j -public class WmsToAcsServiceImpl implements WmsToAcsService { - - private final InstructionService InstructionService; - private final TaskService TaskService; - private final DeviceService DeviceService; - private final DeviceAppService DeviceAppService; - private final RouteLineService RouteLineService; - - @Override - public Map createFromWms(String param) { - JSONArray tasks = JSONArray.parseArray(param); - JSONObject resultJson = new JSONObject(); - log.info("createFromWms--------------:输入参数:" + tasks.toString()); - try{ - JSONArray errArr = new JSONArray(); - for (int i = 0; i < tasks.size(); i++) { - JSONObject task = tasks.getJSONObject(i); - String ext_task_uuid = task.getString("task_uuid"); - String task_code = task.getString("task_code"); - String start_point_code = task.getString("start_device_code"); - String next_point_code = task.getString("next_device_code"); - String start_device_code = ""; - String next_device_code = ""; - if (StrUtil.isEmpty(task_code)) { - throw new WDKException("任务号不能为空"); - } - if (StrUtil.isEmpty(start_point_code)) { - throw new WDKException("起点不能为空"); - } - if (StrUtil.isEmpty(next_point_code)) { - throw new WDKException("终点不能为空"); - } - if (StrUtil.isEmpty(ext_task_uuid)) { - throw new WDKException("外部系统标识不能为空"); - } - - JSONObject start_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + start_point_code + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(start_device_json)) { - start_point_code = (String) start_device_json.get("parent_storage_code") == null ? start_point_code : (String) start_device_json.get("storage_code"); - } - JSONObject next_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + next_point_code + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(next_device_json)) { - next_point_code = (String) next_device_json.get("parent_storage_code") == null ? next_point_code : (String) next_device_json.get("storage_code"); - } - String priority = task.getString("priority"); - String vehicle_code = task.getString("vehicle_code"); - String vehicle_type = task.getString("vehicle_type"); - String route_plan_code = task.getString("route_plan_code"); - String task_type = task.getString("task_type"); - String remark = task.getString("remark"); - String params = task.getString("params"); - - if (start_point_code.indexOf("-") > 0) { - String str[] = start_point_code.split("-"); - start_device_code = str[0]; - } else { - start_device_code = start_point_code; - } - - if (next_point_code.indexOf("-") > 0) { - String str[] = next_point_code.split("-"); - next_device_code = str[0]; - } else { - next_device_code = next_point_code; - } - - if (StrUtil.isEmpty(route_plan_code)) { - route_plan_code = "normal"; - } - List list = RouteLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); - - if (ObjectUtil.isEmpty(list)) { - throw new WDKException("路由不通!"); - } - TaskDto taskDto = TaskService.findByCodeFromCache(task_code); - if (taskDto != null) { - throw new WDKException("不能存在相同的任务号!"); - } - if (!StrUtil.isEmpty(vehicle_code)) { - TaskDto vehicle_dto = TaskService.findByContainer(vehicle_code); - if (vehicle_dto != null) { - throw new WDKException("已存在该载具号的任务!"); - } - } - JSONObject jo = new JSONObject(); - jo.put("task_code", task_code); - jo.put("ext_task_uuid", ext_task_uuid); - jo.put("start_point_code", start_point_code); - jo.put("next_point_code", next_point_code); - jo.put("start_parent_code", start_point_code); - jo.put("next_parent_code", next_point_code); - jo.put("start_device_code", start_device_code); - jo.put("next_device_code", next_device_code); - jo.put("priority", priority); - jo.put("vehicle_code", vehicle_code); - jo.put("vehicle_type", vehicle_type); - jo.put("remark", remark); - jo.put("params", params); - jo.put("task_type", StrUtil.isEmpty(task_type) ? 1 : Integer.parseInt(task_type)); - - TaskDto task_dto = jo.toJavaObject(TaskDto.class); - try { - TaskService.create(task_dto); - } catch (Exception e) { - e.printStackTrace(); - JSONObject json = new JSONObject(); - json.put("task_code", task_code); - json.put("task_uuid", ext_task_uuid); - json.put("message", e.getMessage()); - errArr.add(json); - } - } - if (ObjectUtil.isEmpty(errArr)) { - resultJson.put("status", 200); - } else { - resultJson.put("status", 400); - } - resultJson.put("errArr", errArr); - resultJson.put("message", "操作成功"); - resultJson.put("data", new JSONObject()); - log.info("createFromWms--------------:输出参数:" + resultJson.toString()); - - } catch (Exception e) { - resultJson.put("status", 400); - resultJson.put("errArr", e.getMessage()); - resultJson.put("message", e.getMessage()); - resultJson.put("data", new JSONObject()); - log.info("createFromWms--------------:输出参数:" + resultJson.toString()); - } - - - return resultJson; - } - - - @Override - public Map cancelFromWms(String param) throws Exception { - JSONArray tasks = JSONArray.parseArray(param); - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); - InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); - log.debug(tasks.toString()); - log.info("cancelFromWms--------------:输入参数" + tasks.toString()); - for (int i = 0; i < tasks.size(); i++) { - JSONObject task = tasks.getJSONObject(i); - String task_uuid = task.getString("task_id"); - String task_code = task.getString("task_code"); - String vehicle_code = task.getString("vehicle_code"); - String params = task.getString("params"); - - if (StrUtil.isEmpty(task_uuid)) { - throw new WDKException("任务标识不能为空"); - } - if (StrUtil.isEmpty(task_code)) { - throw new WDKException("任务号不能为空"); - } - String cancelTaskCheck = acsConfigService.findConfigFromCache().get(AcsConfig.CANCELTASKCHECK); - if (StrUtil.equals(cancelTaskCheck, "1")) { - TaskService.cancel(task_uuid); - } else if (StrUtil.equals(cancelTaskCheck, "0")) { - Instruction inst = instructionService.findByTaskcode(task_code); - if (inst == null) { - TaskService.cancel(task_uuid); - } else { - throw new RuntimeException("指令正在执行中,操作失败!"); - } - } - - } - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.OK); - resultJson.put("message", "操作成功"); - resultJson.put("data", new JSONObject()); - log.info("cancelFromWms--------------:输出参数" + resultJson.toString()); - return resultJson; - } - - @Override - public Map updateDeviceGoodsFromWms(String param) { - JSONArray datas = JSONArray.parseArray(param); - log.info("updateDeviceGoodsFromWms--------------:输入参数" + datas.toString()); - for (int i = 0; i < datas.size(); i++) { - JSONObject data = datas.getJSONObject(i); - String device_code = data.getString("point_code"); - String has_goods = data.getString("has_goods"); - - JSONObject jo = new JSONObject(); - jo.put("device_code", device_code); - jo.put("hasGoodStatus", has_goods); - DeviceService.changeDeviceStatus(jo); - - } - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.OK); - resultJson.put("message", "操作成功"); - resultJson.put("data", new JSONObject()); - log.info("updateDeviceGoodsFromWms--------------:输出参数" + resultJson.toString()); - return resultJson; - } - - @Override - public Map areaControl(JSONObject form) { - String device_code = form.getString("device_code"); - String type = form.getString("type"); - - Device device = DeviceAppService.findDeviceByCode(device_code); - ElectricFenceDeviceDriver electricFenceDeviceDriver; - if (device.getDeviceDriver() instanceof ElectricFenceDeviceDriver) { - electricFenceDeviceDriver = (ElectricFenceDeviceDriver) device.getDeviceDriver(); - if (electricFenceDeviceDriver.getSuspended()) { - throw new RuntimeException("交通管制无法进入"); - } else if (StrUtil.equals(type,"1")) { - electricFenceDeviceDriver.setSuspended(true); - } else if (StrUtil.equals(type,"2")) { - electricFenceDeviceDriver.setSuspended(false); - } - } - - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.OK); - resultJson.put("message", "操作成功"); - resultJson.put("data", new JSONObject()); - log.info("updateDeviceGoodsFromWms--------------:输出参数" + resultJson.toString()); - return resultJson; - } - - @Override - public Map putAction(String jsonObject) throws Exception { - JSONArray datas = JSONArray.parseArray(jsonObject); - log.info("putAction--------------:输入参数" + datas.toString()); - for (int i = 0; i < datas.size(); i++) { - JSONObject data = datas.getJSONObject(i); - String device_code = data.getString("device_code"); - String code = data.getString("code"); - String value = data.getString("value"); - Device device = DeviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device)) { - throw new Exception("未找到对应设备:" + device_code); - } - BallMillDeviceDriver ballMillDeviceDriver; - SparyTowerDeviceDriver sparyTowerDeviceDriver; - if (device.getDeviceDriver() instanceof BallMillDeviceDriver) { - ballMillDeviceDriver = (BallMillDeviceDriver) device.getDeviceDriver(); - ItemProtocol itemProtocol = new ItemProtocol(); - if (!ballMillDeviceDriver.isExistFieldName(code, itemProtocol)) { - throw new Exception("设备:" + device_code + "未找到对应信号:" + code); - } - ballMillDeviceDriver.writing(code, value); - } - if (device.getDeviceDriver() instanceof SparyTowerDeviceDriver) { - sparyTowerDeviceDriver = (SparyTowerDeviceDriver) device.getDeviceDriver(); - ItemProtocol itemProtocol = new ItemProtocol(); - if (!sparyTowerDeviceDriver.isExistFieldName(code, itemProtocol)) { - throw new Exception("设备:" + device_code + "未找到对应信号:" + code); - } - sparyTowerDeviceDriver.writing(code, value); - } - } - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.OK); - resultJson.put("message", "操作成功"); - resultJson.put("data", new JSONObject()); - log.info("putAction--------------:输出参数" + resultJson.toString()); - return resultJson; - } - - @Override - public Map queryDevice(String jsonObject) throws Exception { - log.info("queryDevice--------------:输入参数" + jsonObject.toString()); - JSONArray backja = new JSONArray(); - JSONArray datas = JSONArray.parseArray(jsonObject); - - //无光电普通站点 - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - //无光电特殊站点 - SpecialOrdinarySiteDeviceDriver specialOrdinarySiteDeviceDriver; - //空盘站点 - StandardEmptyPalletSiteDeviceDriver standardEmptyPalletSiteDeviceDriver; - //检测站点 - StandardInspectSiteDeviceDriver standardInspectSiteDevicedriver; - //检测站点-无PLC - NonLineInspectSiteDeviceDriver nonLineInspectSiteDeviceDriver; - //区域管制站点(机械手) - StandardManipulatorInspectSiteDeviceDriver standardManipulatorInspectSiteDeviceDriver; - //区域管制站点-无PLC - NonLineManipulatorInspectSiteDeviceDriver nonLineManipulatorInspectSiteDeviceDriver; - //控制点 - StandardCoveyorControlDeviceDriver standardCoveyorControlDeviceDriver; - //控制点-带扫码 - StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver; - //控制点-PLC扫码 - StandardCoveyorControlWithPlcScannerDeviceDriver standardCoveyorControlWithPlcScannerDeviceDriver; - //监控点 - StandardCoveyorMonitorDeviceDriver standardCoveyorMonitorDeviceDriver; - //扫码器 - StandardScannerDeviceDriver standardScannerDeviceDriver; - //机台设备 - MachinesSiteDeviceDriver machinesSiteDeviceDriver; - //自动门 - StandardAutodoorDeviceDriver standardAutodoorDeviceDriver; - //称重设备 - WeighingSiteDeviceDriver weighingSiteDeviceDriver; - //机械手码垛驱动(区分托盘类型) - StandardManipulatorStackingSiteDeviceDriver standardManipulatorStackingSiteDeviceDriver; - //光电检测站点(优先入库) - StandardPhotoelectricInspectSiteDeviceDriver standardPhotoelectricInspectSiteDeviceDriver; - - if (datas.size() == 0) { - List list = DeviceService.findCacheDevice(); - for (int i = 0, j = list.size(); i < j; i++) { - Device device = list.get(i); - JSONObject obj = new JSONObject(); - String device_code = device.getDevice_code(); - JSONObject jo = new JSONObject(); - if (ObjectUtil.isNull(device)) { - continue; - } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardCoveyorControlDeviceDriver.getMode()); - jo.put("move", standardCoveyorControlDeviceDriver.getMove()); - jo.put("hasGoods", standardCoveyorControlDeviceDriver.getHasGoods()); - jo.put("isOnline", standardCoveyorControlDeviceDriver.getIsonline()); - jo.put("error", standardCoveyorControlDeviceDriver.getError()); - jo.put("isError", standardCoveyorControlDeviceDriver.getIserror()); - jo.put("requestSucess", standardCoveyorControlDeviceDriver.getRequireSucess()); - jo.put("applySucess", standardCoveyorControlDeviceDriver.getApplySucess()); - jo.put("message", standardCoveyorControlDeviceDriver.getMessage()); - } else if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardAutodoorDeviceDriver.getMode()); - jo.put("action", standardAutodoorDeviceDriver.getAction()); - jo.put("isOnline", true); - jo.put("error", standardAutodoorDeviceDriver.getError()); - jo.put("isError", standardAutodoorDeviceDriver.getIserror()); - } else if (device.getDeviceDriver() instanceof StandardCoveyorMonitorDeviceDriver) { - standardCoveyorMonitorDeviceDriver = (StandardCoveyorMonitorDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardCoveyorMonitorDeviceDriver.getMode()); - jo.put("move", standardCoveyorMonitorDeviceDriver.getMove()); - jo.put("hasGoods", standardCoveyorMonitorDeviceDriver.getHasGoods()); - jo.put("isOnline", standardCoveyorMonitorDeviceDriver.getIsonline()); - jo.put("error", standardCoveyorMonitorDeviceDriver.getError()); - jo.put("isError", standardCoveyorMonitorDeviceDriver.getIserror()); - jo.put("message", standardCoveyorMonitorDeviceDriver.getMessage()); - } else if (device.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) { - standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardCoveyorControlWithScannerDeviceDriver.getMode()); - jo.put("move", standardCoveyorControlWithScannerDeviceDriver.getMove()); - jo.put("hasGoods", standardCoveyorControlWithScannerDeviceDriver.getHasGoods()); - jo.put("isOnline", standardCoveyorControlWithScannerDeviceDriver.getIsonline()); - jo.put("error", standardCoveyorControlWithScannerDeviceDriver.getError()); - jo.put("isError", standardCoveyorControlWithScannerDeviceDriver.getIserror()); - jo.put("height", standardCoveyorControlWithScannerDeviceDriver.getHeight()); - jo.put("operation_type", standardCoveyorControlWithScannerDeviceDriver.getOperation_type()); - jo.put("direction", standardCoveyorControlWithScannerDeviceDriver.getDirection()); - jo.put("action", standardCoveyorControlWithScannerDeviceDriver.getAction()); - jo.put("ioaction", standardCoveyorControlWithScannerDeviceDriver.getIoaction()); - jo.put("container", StrUtil.isEmpty(standardCoveyorControlWithScannerDeviceDriver.barcode()) ? "" : standardCoveyorControlWithScannerDeviceDriver.barcode()); - jo.put("message", standardCoveyorControlWithScannerDeviceDriver.getMessage()); - jo.put("requestSucess", standardCoveyorControlWithScannerDeviceDriver.getRequireSucess().toString()); - jo.put("applySucess", standardCoveyorControlWithScannerDeviceDriver.getApplySucess().toString()); - jo.put("instruction_message", standardCoveyorControlWithScannerDeviceDriver.getInst_message()); - } else if (device.getDeviceDriver() instanceof StandardCoveyorControlWithPlcScannerDeviceDriver) { - standardCoveyorControlWithPlcScannerDeviceDriver = (StandardCoveyorControlWithPlcScannerDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardCoveyorControlWithPlcScannerDeviceDriver.getMode()); - jo.put("move", standardCoveyorControlWithPlcScannerDeviceDriver.getMove()); - jo.put("hasGoods", standardCoveyorControlWithPlcScannerDeviceDriver.getHasGoods()); - jo.put("isOnline", standardCoveyorControlWithPlcScannerDeviceDriver.getIsonline()); - jo.put("error", standardCoveyorControlWithPlcScannerDeviceDriver.getError()); - jo.put("isError", standardCoveyorControlWithPlcScannerDeviceDriver.getIserror()); - jo.put("height", standardCoveyorControlWithPlcScannerDeviceDriver.getHeight()); - jo.put("operation_type", standardCoveyorControlWithPlcScannerDeviceDriver.getOperation_type()); - jo.put("direction", standardCoveyorControlWithPlcScannerDeviceDriver.getDirection()); - jo.put("action", standardCoveyorControlWithPlcScannerDeviceDriver.getAction()); - jo.put("ioaction", standardCoveyorControlWithPlcScannerDeviceDriver.getIoaction()); - jo.put("container", StrUtil.isEmpty(standardCoveyorControlWithPlcScannerDeviceDriver.getBarcode()) ? "" : standardCoveyorControlWithPlcScannerDeviceDriver.getBarcode()); - jo.put("message", standardCoveyorControlWithPlcScannerDeviceDriver.getMessage()); - jo.put("requestSucess", standardCoveyorControlWithPlcScannerDeviceDriver.getRequireSucess().toString()); - jo.put("applySucess", standardCoveyorControlWithPlcScannerDeviceDriver.getApplySucess().toString()); - jo.put("instruction_message", standardCoveyorControlWithPlcScannerDeviceDriver.getInst_message()); - } - //检测站点 - else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDevicedriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardInspectSiteDevicedriver.getMode()); - jo.put("move", standardInspectSiteDevicedriver.getMove()); - jo.put("hasGoods", standardInspectSiteDevicedriver.getHasGoods()); - jo.put("isOnline", standardInspectSiteDevicedriver.getIsonline()); - jo.put("error", standardInspectSiteDevicedriver.getError()); - jo.put("isError", standardInspectSiteDevicedriver.getIserror()); - jo.put("container", standardInspectSiteDevicedriver.getContainer()); - jo.put("message", standardInspectSiteDevicedriver.getMessage()); - } - //检测站点-无PLC - else if (device.getDeviceDriver() instanceof NonLineInspectSiteDeviceDriver) { - nonLineInspectSiteDeviceDriver = (NonLineInspectSiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", nonLineInspectSiteDeviceDriver.getMode()); - jo.put("move", nonLineInspectSiteDeviceDriver.getMove()); - jo.put("isOnline", nonLineInspectSiteDeviceDriver.getIs_online()); - jo.put("hasGoods", nonLineInspectSiteDeviceDriver.getHasGoods()); - jo.put("error", nonLineInspectSiteDeviceDriver.getError()); - jo.put("isError", nonLineInspectSiteDeviceDriver.getIserror()); - jo.put("container", nonLineInspectSiteDeviceDriver.getContainer()); - jo.put("message", nonLineInspectSiteDeviceDriver.getMessage()); - } - //区域管制站点(机械手) - else if (device.getDeviceDriver() instanceof StandardManipulatorInspectSiteDeviceDriver) { - standardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardManipulatorInspectSiteDeviceDriver.getMode()); - jo.put("move", standardManipulatorInspectSiteDeviceDriver.getMove()); - jo.put("action", standardManipulatorInspectSiteDeviceDriver.getActoin()); - jo.put("io_action", standardManipulatorInspectSiteDeviceDriver.getIo_action()); - jo.put("hasGoods", standardManipulatorInspectSiteDeviceDriver.getHasGoods()); - jo.put("isOnline", standardManipulatorInspectSiteDeviceDriver.getIsonline()); - jo.put("error", standardManipulatorInspectSiteDeviceDriver.getError()); - jo.put("isError", standardManipulatorInspectSiteDeviceDriver.getIserror()); - jo.put("container", standardManipulatorInspectSiteDeviceDriver.getContainer()); - jo.put("message", standardManipulatorInspectSiteDeviceDriver.getMessage()); - } - //区域管制站点-无PLC(机械手) - else if (device.getDeviceDriver() instanceof NonLineManipulatorInspectSiteDeviceDriver) { - nonLineManipulatorInspectSiteDeviceDriver = (NonLineManipulatorInspectSiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", nonLineManipulatorInspectSiteDeviceDriver.getMode()); - jo.put("move", nonLineManipulatorInspectSiteDeviceDriver.getMove()); - jo.put("action", nonLineManipulatorInspectSiteDeviceDriver.getAction()); - jo.put("io_action", nonLineManipulatorInspectSiteDeviceDriver.getIoaction()); - jo.put("hasGoods", nonLineManipulatorInspectSiteDeviceDriver.getHasGoods()); - jo.put("isOnline", nonLineManipulatorInspectSiteDeviceDriver.getIs_online()); - jo.put("error", nonLineManipulatorInspectSiteDeviceDriver.getError()); - jo.put("isError", nonLineManipulatorInspectSiteDeviceDriver.getIserror()); - jo.put("container", nonLineManipulatorInspectSiteDeviceDriver.getContainer()); - jo.put("message", nonLineManipulatorInspectSiteDeviceDriver.getMessage()); - } - //空盘站点 - else if (device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardEmptyPalletSiteDeviceDriver.getMode()); - jo.put("move", standardEmptyPalletSiteDeviceDriver.getMove()); - jo.put("number", standardEmptyPalletSiteDeviceDriver.getNumber()); - jo.put("hasGoods", standardEmptyPalletSiteDeviceDriver.getHasGoods()); - jo.put("isOnline", standardEmptyPalletSiteDeviceDriver.getIsonline()); - jo.put("isError", standardEmptyPalletSiteDeviceDriver.getIserror()); - jo.put("error", standardEmptyPalletSiteDeviceDriver.getError()); - jo.put("container", standardEmptyPalletSiteDeviceDriver.getContainer()); - jo.put("message", standardEmptyPalletSiteDeviceDriver.getMessage()); - } - //普通站点 - else if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("move", standardOrdinarySiteDeviceDriver.getMove()); - jo.put("container", standardOrdinarySiteDeviceDriver.getContainer()); - jo.put("hasGoods", standardOrdinarySiteDeviceDriver.getHasGoods()); - jo.put("isOnline", true); - //点击弹出 - jo.put("is_click", true); - jo.put("device_type", device.getDevice_type()); - jo.put("error", standardOrdinarySiteDeviceDriver.getError()); - jo.put("isError", standardOrdinarySiteDeviceDriver.getIserror()); - jo.put("container", standardOrdinarySiteDeviceDriver.getContainer()); - jo.put("message", standardOrdinarySiteDeviceDriver.getMessage()); - jo.put("material", standardOrdinarySiteDeviceDriver.getMaterial()); - jo.put("batch", standardOrdinarySiteDeviceDriver.getBatch()); - - } - //无光电特殊站点 - else if (device.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) { - specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("move", specialOrdinarySiteDeviceDriver.getMove()); - jo.put("container", specialOrdinarySiteDeviceDriver.getContainer()); - jo.put("hasGoods", specialOrdinarySiteDeviceDriver.getHasGoods()); - jo.put("isOnline", true); - //点击弹出 - jo.put("is_click", true); - jo.put("device_type", device.getDevice_type()); - jo.put("error", specialOrdinarySiteDeviceDriver.getError()); - jo.put("isError", specialOrdinarySiteDeviceDriver.getIserror()); - jo.put("container", specialOrdinarySiteDeviceDriver.getContainer()); - jo.put("message", specialOrdinarySiteDeviceDriver.getMessage()); - jo.put("material", specialOrdinarySiteDeviceDriver.getMaterial()); - jo.put("batch", specialOrdinarySiteDeviceDriver.getBatch()); - } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDevicedriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardInspectSiteDevicedriver.getMode()); - jo.put("move", standardInspectSiteDevicedriver.getMove()); - jo.put("hasGoods", standardInspectSiteDevicedriver.getHasGoods()); - jo.put("isOnline", standardInspectSiteDevicedriver.getIsonline()); - jo.put("error", standardInspectSiteDevicedriver.getError()); - jo.put("isError", standardInspectSiteDevicedriver.getIserror()); - jo.put("container", standardInspectSiteDevicedriver.getContainer()); - jo.put("message", standardInspectSiteDevicedriver.getMessage()); - } else if (device.getDeviceDriver() instanceof StandardScannerDeviceDriver) { - standardScannerDeviceDriver = (StandardScannerDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("isOnline", true); - jo.put("device_type", device.getDevice_type()); - //点击弹出 - jo.put("is_click", true); - jo.put("ip", standardScannerDeviceDriver.getIp()); - jo.put("container", StrUtil.isEmpty(standardScannerDeviceDriver.readBarcode()) ? "" : standardScannerDeviceDriver.readBarcode()); - } else if (device.getDeviceDriver() instanceof WeighingSiteDeviceDriver) { - weighingSiteDeviceDriver = (WeighingSiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("isOnline", true); - jo.put("instruction_message", weighingSiteDeviceDriver.getInst_message()); - } else if (device.getDeviceDriver() instanceof MachinesSiteDeviceDriver) { - machinesSiteDeviceDriver = (MachinesSiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", machinesSiteDeviceDriver.getMode()); - jo.put("io_action", machinesSiteDeviceDriver.getIoaction()); - jo.put("isOnline", machinesSiteDeviceDriver.getIsonline()); - } - //机械手码垛驱动(区分托盘类型) - else if (device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardManipulatorStackingSiteDeviceDriver.getMode()); - jo.put("move", standardManipulatorStackingSiteDeviceDriver.getMove()); - jo.put("action", standardManipulatorStackingSiteDeviceDriver.getAction()); - jo.put("io_action", standardManipulatorStackingSiteDeviceDriver.getIo_action()); - jo.put("hasGoods", standardManipulatorStackingSiteDeviceDriver.getHasGoods()); - jo.put("isOnline", standardManipulatorStackingSiteDeviceDriver.getIsonline()); - jo.put("error", standardManipulatorStackingSiteDeviceDriver.getError()); - jo.put("isError", standardManipulatorStackingSiteDeviceDriver.getIserror()); - jo.put("container", standardManipulatorStackingSiteDeviceDriver.getContainer()); - jo.put("message", standardManipulatorStackingSiteDeviceDriver.getMessage()); - } else if (device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardPhotoelectricInspectSiteDeviceDriver.getMode()); - jo.put("move", standardPhotoelectricInspectSiteDeviceDriver.getMove()); - jo.put("hasGoods", standardPhotoelectricInspectSiteDeviceDriver.getHasGoods()); - jo.put("isOnline", standardPhotoelectricInspectSiteDeviceDriver.getIsonline()); - jo.put("error", standardPhotoelectricInspectSiteDeviceDriver.getError()); - jo.put("isError", standardPhotoelectricInspectSiteDeviceDriver.getIserror()); - jo.put("container", standardPhotoelectricInspectSiteDeviceDriver.getContainer()); - jo.put("message", standardPhotoelectricInspectSiteDeviceDriver.getMessage()); - } else { - jo.put("device_code", device.getDevice_code()); - } - backja.add(jo); - } - } else { - for (int i = 0; i < datas.size(); i++) { - JSONObject jo = new JSONObject(); - JSONObject data = datas.getJSONObject(i); - String device_code = data.getString("device_code"); - Device device = DeviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isEmpty(device)) { - throw new Exception("未找到对应设备:" + device_code); - } - - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardCoveyorControlDeviceDriver.getMode()); - jo.put("move", standardCoveyorControlDeviceDriver.getMove()); - jo.put("hasGoods", standardCoveyorControlDeviceDriver.getHasGoods()); - jo.put("isOnline", standardCoveyorControlDeviceDriver.getIsonline()); - jo.put("error", standardCoveyorControlDeviceDriver.getError()); - jo.put("isError", standardCoveyorControlDeviceDriver.getIserror()); - jo.put("requestSucess", standardCoveyorControlDeviceDriver.getRequireSucess()); - jo.put("applySucess", standardCoveyorControlDeviceDriver.getApplySucess()); - jo.put("message", standardCoveyorControlDeviceDriver.getMessage()); - } else if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardAutodoorDeviceDriver.getMode()); - jo.put("action", standardAutodoorDeviceDriver.getAction()); - jo.put("isOnline", true); - jo.put("error", standardAutodoorDeviceDriver.getError()); - jo.put("isError", standardAutodoorDeviceDriver.getIserror()); - } else if (device.getDeviceDriver() instanceof StandardCoveyorMonitorDeviceDriver) { - standardCoveyorMonitorDeviceDriver = (StandardCoveyorMonitorDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardCoveyorMonitorDeviceDriver.getMode()); - jo.put("move", standardCoveyorMonitorDeviceDriver.getMove()); - jo.put("hasGoods", standardCoveyorMonitorDeviceDriver.getHasGoods()); - jo.put("isOnline", standardCoveyorMonitorDeviceDriver.getIsonline()); - jo.put("error", standardCoveyorMonitorDeviceDriver.getError()); - jo.put("isError", standardCoveyorMonitorDeviceDriver.getIserror()); - jo.put("message", standardCoveyorMonitorDeviceDriver.getMessage()); - } else if (device.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) { - standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardCoveyorControlWithScannerDeviceDriver.getMode()); - jo.put("move", standardCoveyorControlWithScannerDeviceDriver.getMove()); - jo.put("hasGoods", standardCoveyorControlWithScannerDeviceDriver.getHasGoods()); - jo.put("isOnline", standardCoveyorControlWithScannerDeviceDriver.getIsonline()); - jo.put("error", standardCoveyorControlWithScannerDeviceDriver.getError()); - jo.put("isError", standardCoveyorControlWithScannerDeviceDriver.getIserror()); - jo.put("height", standardCoveyorControlWithScannerDeviceDriver.getHeight()); - jo.put("operation_type", standardCoveyorControlWithScannerDeviceDriver.getOperation_type()); - jo.put("direction", standardCoveyorControlWithScannerDeviceDriver.getDirection()); - jo.put("action", standardCoveyorControlWithScannerDeviceDriver.getAction()); - jo.put("ioaction", standardCoveyorControlWithScannerDeviceDriver.getIoaction()); - jo.put("container", StrUtil.isEmpty(standardCoveyorControlWithScannerDeviceDriver.barcode()) ? "" : standardCoveyorControlWithScannerDeviceDriver.barcode()); - jo.put("message", standardCoveyorControlWithScannerDeviceDriver.getMessage()); - jo.put("requestSucess", standardCoveyorControlWithScannerDeviceDriver.getRequireSucess().toString()); - jo.put("applySucess", standardCoveyorControlWithScannerDeviceDriver.getApplySucess().toString()); - jo.put("instruction_message", standardCoveyorControlWithScannerDeviceDriver.getInst_message()); - } else if (device.getDeviceDriver() instanceof StandardCoveyorControlWithPlcScannerDeviceDriver) { - standardCoveyorControlWithPlcScannerDeviceDriver = (StandardCoveyorControlWithPlcScannerDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardCoveyorControlWithPlcScannerDeviceDriver.getMode()); - jo.put("move", standardCoveyorControlWithPlcScannerDeviceDriver.getMove()); - jo.put("hasGoods", standardCoveyorControlWithPlcScannerDeviceDriver.getHasGoods()); - jo.put("isOnline", standardCoveyorControlWithPlcScannerDeviceDriver.getIsonline()); - jo.put("error", standardCoveyorControlWithPlcScannerDeviceDriver.getError()); - jo.put("isError", standardCoveyorControlWithPlcScannerDeviceDriver.getIserror()); - jo.put("height", standardCoveyorControlWithPlcScannerDeviceDriver.getHeight()); - jo.put("operation_type", standardCoveyorControlWithPlcScannerDeviceDriver.getOperation_type()); - jo.put("direction", standardCoveyorControlWithPlcScannerDeviceDriver.getDirection()); - jo.put("action", standardCoveyorControlWithPlcScannerDeviceDriver.getAction()); - jo.put("ioaction", standardCoveyorControlWithPlcScannerDeviceDriver.getIoaction()); - jo.put("container", StrUtil.isEmpty(standardCoveyorControlWithPlcScannerDeviceDriver.getBarcode()) ? "" : standardCoveyorControlWithPlcScannerDeviceDriver.getBarcode()); - jo.put("message", standardCoveyorControlWithPlcScannerDeviceDriver.getMessage()); - jo.put("requestSucess", standardCoveyorControlWithPlcScannerDeviceDriver.getRequireSucess().toString()); - jo.put("applySucess", standardCoveyorControlWithPlcScannerDeviceDriver.getApplySucess().toString()); - jo.put("instruction_message", standardCoveyorControlWithPlcScannerDeviceDriver.getInst_message()); - } - //检测站点 - else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDevicedriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardInspectSiteDevicedriver.getMode()); - jo.put("move", standardInspectSiteDevicedriver.getMove()); - jo.put("hasGoods", standardInspectSiteDevicedriver.getHasGoods()); - jo.put("isOnline", standardInspectSiteDevicedriver.getIsonline()); - jo.put("error", standardInspectSiteDevicedriver.getError()); - jo.put("isError", standardInspectSiteDevicedriver.getIserror()); - jo.put("container", standardInspectSiteDevicedriver.getContainer()); - jo.put("message", standardInspectSiteDevicedriver.getMessage()); - } - //检测站点-无PLC - else if (device.getDeviceDriver() instanceof NonLineInspectSiteDeviceDriver) { - nonLineInspectSiteDeviceDriver = (NonLineInspectSiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", nonLineInspectSiteDeviceDriver.getMode()); - jo.put("move", nonLineInspectSiteDeviceDriver.getMove()); - jo.put("isOnline", nonLineInspectSiteDeviceDriver.getIs_online()); - jo.put("hasGoods", nonLineInspectSiteDeviceDriver.getHasGoods()); - jo.put("error", nonLineInspectSiteDeviceDriver.getError()); - jo.put("isError", nonLineInspectSiteDeviceDriver.getIserror()); - jo.put("container", nonLineInspectSiteDeviceDriver.getContainer()); - jo.put("message", nonLineInspectSiteDeviceDriver.getMessage()); - } - //区域管制站点(机械手) - else if (device.getDeviceDriver() instanceof StandardManipulatorInspectSiteDeviceDriver) { - standardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardManipulatorInspectSiteDeviceDriver.getMode()); - jo.put("move", standardManipulatorInspectSiteDeviceDriver.getMove()); - jo.put("action", standardManipulatorInspectSiteDeviceDriver.getActoin()); - jo.put("io_action", standardManipulatorInspectSiteDeviceDriver.getIo_action()); - jo.put("hasGoods", standardManipulatorInspectSiteDeviceDriver.getHasGoods()); - jo.put("isOnline", standardManipulatorInspectSiteDeviceDriver.getIsonline()); - jo.put("error", standardManipulatorInspectSiteDeviceDriver.getError()); - jo.put("isError", standardManipulatorInspectSiteDeviceDriver.getIserror()); - jo.put("container", standardManipulatorInspectSiteDeviceDriver.getContainer()); - jo.put("message", standardManipulatorInspectSiteDeviceDriver.getMessage()); - } - //区域管制站点-无PLC(机械手) - else if (device.getDeviceDriver() instanceof NonLineManipulatorInspectSiteDeviceDriver) { - nonLineManipulatorInspectSiteDeviceDriver = (NonLineManipulatorInspectSiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", nonLineManipulatorInspectSiteDeviceDriver.getMode()); - jo.put("move", nonLineManipulatorInspectSiteDeviceDriver.getMove()); - jo.put("action", nonLineManipulatorInspectSiteDeviceDriver.getAction()); - jo.put("io_action", nonLineManipulatorInspectSiteDeviceDriver.getIoaction()); - jo.put("hasGoods", nonLineManipulatorInspectSiteDeviceDriver.getHasGoods()); - jo.put("isOnline", nonLineManipulatorInspectSiteDeviceDriver.getIs_online()); - jo.put("error", nonLineManipulatorInspectSiteDeviceDriver.getError()); - jo.put("isError", nonLineManipulatorInspectSiteDeviceDriver.getIserror()); - jo.put("container", nonLineManipulatorInspectSiteDeviceDriver.getContainer()); - jo.put("message", nonLineManipulatorInspectSiteDeviceDriver.getMessage()); - } - //空盘站点 - else if (device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardEmptyPalletSiteDeviceDriver.getMode()); - jo.put("move", standardEmptyPalletSiteDeviceDriver.getMove()); - jo.put("number", standardEmptyPalletSiteDeviceDriver.getNumber()); - jo.put("hasGoods", standardEmptyPalletSiteDeviceDriver.getHasGoods()); - jo.put("isOnline", standardEmptyPalletSiteDeviceDriver.getIsonline()); - jo.put("isError", standardEmptyPalletSiteDeviceDriver.getIserror()); - jo.put("error", standardEmptyPalletSiteDeviceDriver.getError()); - jo.put("container", standardEmptyPalletSiteDeviceDriver.getContainer()); - jo.put("message", standardEmptyPalletSiteDeviceDriver.getMessage()); - } - //普通站点 - else if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("move", standardOrdinarySiteDeviceDriver.getMove()); - jo.put("container", standardOrdinarySiteDeviceDriver.getContainer()); - jo.put("hasGoods", standardOrdinarySiteDeviceDriver.getHasGoods()); - jo.put("isOnline", true); - //点击弹出 - jo.put("is_click", true); - jo.put("device_type", device.getDevice_type()); - jo.put("error", standardOrdinarySiteDeviceDriver.getError()); - jo.put("isError", standardOrdinarySiteDeviceDriver.getIserror()); - jo.put("container", standardOrdinarySiteDeviceDriver.getContainer()); - jo.put("message", standardOrdinarySiteDeviceDriver.getMessage()); - jo.put("material", standardOrdinarySiteDeviceDriver.getMaterial()); - jo.put("batch", standardOrdinarySiteDeviceDriver.getBatch()); - - } - //无光电特殊站点 - else if (device.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) { - specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("move", specialOrdinarySiteDeviceDriver.getMove()); - jo.put("container", specialOrdinarySiteDeviceDriver.getContainer()); - jo.put("hasGoods", specialOrdinarySiteDeviceDriver.getHasGoods()); - jo.put("isOnline", true); - //点击弹出 - jo.put("is_click", true); - jo.put("device_type", device.getDevice_type()); - jo.put("error", specialOrdinarySiteDeviceDriver.getError()); - jo.put("isError", specialOrdinarySiteDeviceDriver.getIserror()); - jo.put("container", specialOrdinarySiteDeviceDriver.getContainer()); - jo.put("message", specialOrdinarySiteDeviceDriver.getMessage()); - jo.put("material", specialOrdinarySiteDeviceDriver.getMaterial()); - jo.put("batch", specialOrdinarySiteDeviceDriver.getBatch()); - } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDevicedriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardInspectSiteDevicedriver.getMode()); - jo.put("move", standardInspectSiteDevicedriver.getMove()); - jo.put("hasGoods", standardInspectSiteDevicedriver.getHasGoods()); - jo.put("isOnline", standardInspectSiteDevicedriver.getIsonline()); - jo.put("error", standardInspectSiteDevicedriver.getError()); - jo.put("isError", standardInspectSiteDevicedriver.getIserror()); - jo.put("container", standardInspectSiteDevicedriver.getContainer()); - jo.put("message", standardInspectSiteDevicedriver.getMessage()); - } else if (device.getDeviceDriver() instanceof StandardScannerDeviceDriver) { - standardScannerDeviceDriver = (StandardScannerDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("isOnline", true); - jo.put("device_type", device.getDevice_type()); - //点击弹出 - jo.put("is_click", true); - jo.put("ip", standardScannerDeviceDriver.getIp()); - jo.put("container", StrUtil.isEmpty(standardScannerDeviceDriver.readBarcode()) ? "" : standardScannerDeviceDriver.readBarcode()); - } else if (device.getDeviceDriver() instanceof WeighingSiteDeviceDriver) { - weighingSiteDeviceDriver = (WeighingSiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("isOnline", true); - jo.put("instruction_message", weighingSiteDeviceDriver.getInst_message()); - } else if (device.getDeviceDriver() instanceof MachinesSiteDeviceDriver) { - machinesSiteDeviceDriver = (MachinesSiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", machinesSiteDeviceDriver.getMode()); - jo.put("io_action", machinesSiteDeviceDriver.getIoaction()); - jo.put("isOnline", machinesSiteDeviceDriver.getIsonline()); - } - //机械手码垛驱动(区分托盘类型) - else if (device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardManipulatorStackingSiteDeviceDriver.getMode()); - jo.put("move", standardManipulatorStackingSiteDeviceDriver.getMove()); - jo.put("action", standardManipulatorStackingSiteDeviceDriver.getAction()); - jo.put("io_action", standardManipulatorStackingSiteDeviceDriver.getIo_action()); - jo.put("hasGoods", standardManipulatorStackingSiteDeviceDriver.getHasGoods()); - jo.put("isOnline", standardManipulatorStackingSiteDeviceDriver.getIsonline()); - jo.put("error", standardManipulatorStackingSiteDeviceDriver.getError()); - jo.put("isError", standardManipulatorStackingSiteDeviceDriver.getIserror()); - jo.put("container", standardManipulatorStackingSiteDeviceDriver.getContainer()); - jo.put("message", standardManipulatorStackingSiteDeviceDriver.getMessage()); - } else if (device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) device.getDeviceDriver(); - jo.put("device_code", device.getDevice_code()); - jo.put("mode", standardPhotoelectricInspectSiteDeviceDriver.getMode()); - jo.put("move", standardPhotoelectricInspectSiteDeviceDriver.getMove()); - jo.put("hasGoods", standardPhotoelectricInspectSiteDeviceDriver.getHasGoods()); - jo.put("isOnline", standardPhotoelectricInspectSiteDeviceDriver.getIsonline()); - jo.put("error", standardPhotoelectricInspectSiteDeviceDriver.getError()); - jo.put("isError", standardPhotoelectricInspectSiteDeviceDriver.getIserror()); - jo.put("container", standardPhotoelectricInspectSiteDeviceDriver.getContainer()); - jo.put("message", standardPhotoelectricInspectSiteDeviceDriver.getMessage()); - } else { - jo.put("device_code", device.getDevice_code()); - } - backja.add(jo); - } - } - JSONObject resultJson = new JSONObject(); - resultJson.put("status", HttpStatus.OK); - resultJson.put("message", "操作成功"); - resultJson.put("data", backja); - log.info("queryDevice--------------:输出参数" + resultJson.toString()); - return resultJson; - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/ext/xr_lk/rest/AcsToXrlkController.java b/nladmin-system/src/main/java/org/nl/acs/ext/xr_lk/rest/AcsToXrlkController.java deleted file mode 100644 index f464d80..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/ext/xr_lk/rest/AcsToXrlkController.java +++ /dev/null @@ -1,58 +0,0 @@ - -package org.nl.acs.ext.xr_lk.rest; - - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.ext.xr_lk.service.AcsToXrlkService; -import org.nl.annotation.Log; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author ludj - * @date 2021-07-21 - **/ -@RestController -@RequiredArgsConstructor -@Api(tags = "新锐立库接口") -@RequestMapping("/api/xrlk") -@Slf4j -public class AcsToXrlkController { - private final AcsToXrlkService acsToXrlkService; - - @PostMapping("/isPutPermission") - @Log("获取对接位是否允许放货") - @ApiOperation("获取对接位是否允许放货") - public ResponseEntity getPutPermission(@RequestBody String device_code) { - return new ResponseEntity<>(acsToXrlkService.isPutPermission(device_code), HttpStatus.OK); - } - - @PostMapping("/isTakePermission") - @Log("获取对接位是否允许取货") - @ApiOperation("获取对接位是否允许取货") - public ResponseEntity getTakePermission(@RequestBody String device_code) { - return new ResponseEntity<>(acsToXrlkService.isTakePermission(device_code), HttpStatus.OK); - } - - @PostMapping("/invokeDoor") - @Log("获取是否允许进入") - @ApiOperation("获取是否允许进入") - public ResponseEntity getInOutMode(@RequestBody String device_code) { - return new ResponseEntity<>(acsToXrlkService.invokeDoor(device_code), HttpStatus.OK); - } - - @PostMapping("/AGVWorkStatus") - @Log("动作完成") - @ApiOperation("动作完成") - public ResponseEntity AGVWorkStatus(@RequestBody String device_code, String type) { - return new ResponseEntity<>(acsToXrlkService.AGVWorkStatus(device_code, type), HttpStatus.OK); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/ext/xr_lk/rest/XrlkToAcsController.java b/nladmin-system/src/main/java/org/nl/acs/ext/xr_lk/rest/XrlkToAcsController.java deleted file mode 100644 index 5662aae..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/ext/xr_lk/rest/XrlkToAcsController.java +++ /dev/null @@ -1,25 +0,0 @@ - -package org.nl.acs.ext.xr_lk.rest; - - -import io.swagger.annotations.Api; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.ext.xr_lk.service.XrlkToAcsService; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author wangs - * @date 2021-07-21 - **/ -@RestController -@RequiredArgsConstructor -@Api(tags = "新锐立库接口") -@RequestMapping("/api/xrlk") -@Slf4j -public class XrlkToAcsController { - private final XrlkToAcsService xrlkToAcsService; - - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/ext/xr_lk/service/AcsToXrlkService.java b/nladmin-system/src/main/java/org/nl/acs/ext/xr_lk/service/AcsToXrlkService.java deleted file mode 100644 index e6992dc..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/ext/xr_lk/service/AcsToXrlkService.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.nl.acs.ext.xr_lk.service; - -import cn.hutool.http.HttpResponse; - -public interface AcsToXrlkService { - - /** - * 获取是否允许进入: - * - * @param device_code - * @return - */ - HttpResponse invokeDoor(String device_code); - - /** - * 获取对接位是否允许放货: - * - * @param device_code - * @return - */ - HttpResponse isPutPermission(String device_code); - - /** - * 获取对接位是否允许取货 - * - * @param device_code - * @return - */ - HttpResponse isTakePermission(String device_code); - - - /** - * 动作完成 - * - * @param device_code - * @return - */ - HttpResponse AGVWorkStatus(String device_code, String type); - - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/ext/xr_lk/service/XrlkToAcsService.java b/nladmin-system/src/main/java/org/nl/acs/ext/xr_lk/service/XrlkToAcsService.java deleted file mode 100644 index 3def5bf..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/ext/xr_lk/service/XrlkToAcsService.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.nl.acs.ext.xr_lk.service; - - -public interface XrlkToAcsService { - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/ext/xr_lk/service/impl/AcsToXRlkServiceImpl.java b/nladmin-system/src/main/java/org/nl/acs/ext/xr_lk/service/impl/AcsToXRlkServiceImpl.java deleted file mode 100644 index 5386d37..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/ext/xr_lk/service/impl/AcsToXRlkServiceImpl.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.nl.acs.ext.xr_lk.service.impl; - -import cn.hutool.http.HttpRequest; -import cn.hutool.http.HttpResponse; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.config.AcsConfig; -import org.nl.acs.config.server.AcsConfigService; -import org.nl.acs.device.address.service.AddressService; -import org.nl.acs.device.address.service.dto.AddressDto; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.ext.xr_lk.service.AcsToXrlkService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -@RequiredArgsConstructor -@Slf4j -public class AcsToXRlkServiceImpl implements AcsToXrlkService { - - @Autowired - AcsConfigService acsConfigService; - - @Autowired - DeviceService deviceService; - - @Autowired - AddressService addressService; - - @Override - public HttpResponse invokeDoor(String device_code) { - String wcsurl = acsConfigService.findConfigFromCache().get(AcsConfig.ERPURL); - AddressDto addressDto = addressService.findByCode("invokeDoor"); - String url = wcsurl + addressDto.getMethods_url() + device_code; - HttpResponse result = null; - try { - //{"status":400,"timestamp":"2021-10-22 16:32:22","message":"业务类型不正确!"} - result = HttpRequest.get(url) - .execute(); - System.out.println(result); - } catch (Exception e) { - String msg = e.getMessage(); - //网络不通 - System.out.println(msg); - } - return result; - } - - @Override - public HttpResponse isPutPermission(String device_code) { - String wcsurl = acsConfigService.findConfigFromCache().get(AcsConfig.ERPURL); - AddressDto addressDto = addressService.findByCode("isPutPermission"); - String url = wcsurl + addressDto.getMethods_url() + device_code; - HttpResponse result = null; - try { - //{"status":400,"timestamp":"2021-10-22 16:32:22","message":"业务类型不正确!"} - result = HttpRequest.get(url) - .execute(); - System.out.println(result); - } catch (Exception e) { - String msg = e.getMessage(); - //网络不通 - System.out.println(msg); - } - return result; - } - - @Override - public HttpResponse isTakePermission(String device_code) { - String wcsurl = acsConfigService.findConfigFromCache().get(AcsConfig.ERPURL); - AddressDto addressDto = addressService.findByCode("isTakePermission"); - String url = wcsurl + addressDto.getMethods_url() + device_code; - HttpResponse result = null; - try { - //{"status":400,"timestamp":"2021-10-22 16:32:22","message":"业务类型不正确!"} - result = HttpRequest.get(url) - .execute(); - System.out.println(result); - } catch (Exception e) { - String msg = e.getMessage(); - //网络不通 - System.out.println(msg); - } - return result; - } - - @Override - public HttpResponse AGVWorkStatus(String device_code, String type) { - String wcsurl = acsConfigService.findConfigFromCache().get(AcsConfig.ERPURL); - AddressDto addressDto = addressService.findByCode("AGVWorkStatus"); - String url = wcsurl + addressDto.getMethods_url(); - HttpResponse result = null; - try { - //{"status":400,"timestamp":"2021-10-22 16:32:22","message":"业务类型不正确!"} - result = HttpRequest.get(url) - .execute(); - System.out.println(result); - } catch (Exception e) { - String msg = e.getMessage(); - //网络不通 - System.out.println(msg); - } - return result; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/ext/xr_lk/service/impl/XrlkToAcsServiceImpl.java b/nladmin-system/src/main/java/org/nl/acs/ext/xr_lk/service/impl/XrlkToAcsServiceImpl.java deleted file mode 100644 index 41a50b9..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/ext/xr_lk/service/impl/XrlkToAcsServiceImpl.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.nl.acs.ext.xr_lk.service.impl; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.ext.xr_lk.service.XrlkToAcsService; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.task.service.TaskService; -import org.springframework.stereotype.Service; - -@Service -@RequiredArgsConstructor -@Slf4j -public class XrlkToAcsServiceImpl implements XrlkToAcsService { - - private final InstructionService InstructionService; - private final TaskService TaskService; - private final DeviceService DeviceService; - private final DeviceAppService DeviceAppService; - private final RouteLineService RouteLineService; - - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/instruction/TestToAgv.java b/nladmin-system/src/main/java/org/nl/acs/instruction/TestToAgv.java deleted file mode 100644 index a742698..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/instruction/TestToAgv.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.nl.acs.instruction; - - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -/** - * https://cd6aa570.wiz06.com/wapp/pages/view/share/s/3dqGlM0Ui17F2QV-4016Y0t20oFsyh2yAkDF245TFI2TPBvo - * 从1001--1002 - * 测试A仙知系统GV下发 - *

- * 指令状态:00生成 ,01:确定起点,02、确定终点,03、起点和终点都确认,04:下发,可以下发, 05、执行中 06、完成 - * 完成方式:00自动,01:wcs删除,02、wms删除,03、发给wcs失败自动删除 - */ -public class TestToAgv { - public static void main(String[] args) { - JSONObject issue = issue(null); - System.out.println(issue.toString()); - System.out.println(123); - } - - /** - * AGV下发接口 - * - * @param inst - * @return - */ - public static JSONObject issue(JSONObject inst) { - JSONObject result = new JSONObject(); - JSONArray arr = new JSONArray(); - //取货点1001 - JSONObject locationNameJson1 = new JSONObject(); - locationNameJson1.put("locationName", "1001"); - locationNameJson1.put("operation", "JackLoad"); - JSONArray properties = new JSONArray(); - JSONObject keys1 = new JSONObject(); - keys1.put("key", "recognize"); - keys1.put("value", "false"); - properties.add(keys1); - locationNameJson1.put("properties", properties); - - //放货点1002 - JSONObject locationNameJson2 = new JSONObject(); - locationNameJson2.put("locationName", "1002"); - locationNameJson2.put("operation", "JackUnload"); - JSONArray properties2 = new JSONArray(); - JSONObject keys2 = new JSONObject(); - keys2.put("key", "recognize"); - keys2.put("value", "false"); - properties.add(keys2); - locationNameJson2.put("properties", properties); - - - arr.add(locationNameJson1); - arr.add(locationNameJson2); - - result.put("destinations", arr); - //任务号 - result.put("name", "1726"); - //截止时间,AGV超过这个时间就作废。(一般指令生成的时候加一天) - result.put("deadline", "2021-01-09 17:59:04"); - return result; - } - - /** - * @param inst 查询指令状态 - * @return - */ - public static JSONObject queryInstructStatus(JSONObject inst) { - //get : host:post+ /api/route/transportOrders/{ name} - JSONObject result = new JSONObject(); - //指令状态 - result.put("state", "BEING_PROCESSED"); - //车号 - result.put("processingVehicle", "AMB-02"); - return result; - } - - /** - * 查询多辆车的状态,结果为JSON数组 - * - * @return - */ - public static JSONArray queryAgvStatus() { - JSONArray arr = new JSONArray(); - for (int i = 0; i < 1; i++) { - JSONObject param = new JSONObject(); - param.put("name", "AMB-01"); - arr.add(param); - } - return arr; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/instruction/common/InstructFinishTypeEnum.java b/nladmin-system/src/main/java/org/nl/acs/instruction/common/InstructFinishTypeEnum.java deleted file mode 100644 index 87569bc..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/instruction/common/InstructFinishTypeEnum.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.nl.acs.instruction.common; - -public enum InstructFinishTypeEnum { -} diff --git a/nladmin-system/src/main/java/org/nl/acs/instruction/common/InstructStatusEnum.java b/nladmin-system/src/main/java/org/nl/acs/instruction/common/InstructStatusEnum.java deleted file mode 100644 index dafc5d2..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/instruction/common/InstructStatusEnum.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.nl.acs.instruction.common; - -public class InstructStatusEnum { -} diff --git a/nladmin-system/src/main/java/org/nl/acs/instruction/common/InstructTypeEnum.java b/nladmin-system/src/main/java/org/nl/acs/instruction/common/InstructTypeEnum.java deleted file mode 100644 index 6c15431..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/instruction/common/InstructTypeEnum.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.nl.acs.instruction.common; - -/** - * 指令状态:00生成 ,01:确定起点,02、确定终点,03、起点和终点都确认,04:下发,可以下发, 05、执行中 06、完成 - * 完成方式:00自动,01:wcs删除,02、wms删除,03、发给wcs失败自动删除 - */ -public enum InstructTypeEnum { - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/instruction/enums/InstCreateEnum.java b/nladmin-system/src/main/java/org/nl/acs/instruction/enums/InstCreateEnum.java deleted file mode 100644 index 67f378e..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/instruction/enums/InstCreateEnum.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.nl.acs.instruction.enums; - - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -/** - * 任务生成方式 - */ -public enum InstCreateEnum { - AUTO(1, "AUTO", "自动创建"), - MANDATORY_CREATE(2, "MANDATORY_CREATE", "强制生成"); - - //索引 - private int index; - //编码 - private String code; - //名字 - private String name; - //描述 - private String desc; - - // 构造方法 - InstCreateEnum(int index, String code, String name) { - this.index = index; - this.code = code; - this.name = name; - - } - - public static JSONArray getList() { - JSONArray arr = new JSONArray(); - JSONObject json = new JSONObject(); - for (InstCreateEnum em : InstCreateEnum.values()) { - json.put("code", em.getCode()); - json.put("name", em.getName()); - arr.add(json); - } - return arr; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDesc() { - return desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - - public static String getName(String code) { - for (InstCreateEnum c : InstCreateEnum.values()) { - if (c.code == code) { - return c.name; - } - } - return null; - } - - public int getIndex() { - return index; - } - - public void setIndex(int index) { - this.index = index; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/instruction/enums/InstErrorEnum.java b/nladmin-system/src/main/java/org/nl/acs/instruction/enums/InstErrorEnum.java deleted file mode 100644 index 93e5ab6..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/instruction/enums/InstErrorEnum.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.nl.acs.instruction.enums; - - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -/** - * 任务异常 - */ -public enum InstErrorEnum { - NORMAL(1, "NORMAL", "正常"), - AGV_ERROR(2, "AGV_ERROR", "AGV异常"); - - - //索引 - private int index; - //编码 - private String code; - //名字 - private String name; - //描述 - private String desc; - - // 构造方法 - InstErrorEnum(int index, String code, String name) { - this.index = index; - this.code = code; - this.name = name; - - } - - public static JSONArray getList() { - JSONArray arr = new JSONArray(); - JSONObject json = new JSONObject(); - for (InstErrorEnum em : InstErrorEnum.values()) { - json.put("code", em.getCode()); - json.put("name", em.getName()); - arr.add(json); - } - return arr; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDesc() { - return desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - - public static String getName(String code) { - for (InstErrorEnum c : InstErrorEnum.values()) { - if (c.code == code) { - return c.name; - } - } - return null; - } - - public int getIndex() { - return index; - } - - public void setIndex(int index) { - this.index = index; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/instruction/enums/InstFinishEnum.java b/nladmin-system/src/main/java/org/nl/acs/instruction/enums/InstFinishEnum.java deleted file mode 100644 index fbfd444..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/instruction/enums/InstFinishEnum.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.nl.acs.instruction.enums; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - - -/** - * 任务完成方式 - */ -public enum InstFinishEnum { - AUTO_FINISH(1, "AUTO_FINISH", "自动完成"), - ACS_MANDATORY_FINISH(2, "ACS_MANDATORY_FINISH", "ACS强制完成"), - WMS_MANDATORY_FINISH(3, "WMS_MANDATORY_FINISH", "WMS强制完成"), - MES_MANDATORY_FINISH(4, "MES_MANDATORY_FINISH", "MES强制完成"), - AUTO_DELETE(5, "AUTO_DELETE", "自动删除"), - ACS_MANDATORY_DELETE(6, "ACS_MANDATORY_DELETE", "ACS强制删除"), - WMS_MANDATORY_DELETE(7, "WMS_MANDATORY_DELETE", "WMS强制删除"), - MES_MANDATORY_DELETE(8, "MES_MANDATORY_DELETE", "MES强制删除"), - DEVICE_DELETE(9, "DEVICE_DELETE", "设备删除"); - - //索引 - private int index; - //编码 - private String code; - //名字 - private String name; - //描述 - private String desc; - - // 构造方法 - InstFinishEnum(int index, String code, String name) { - this.index = index; - this.code = code; - this.name = name; - - } - - public static JSONArray getList() { - JSONArray arr = new JSONArray(); - JSONObject json = new JSONObject(); - for (InstFinishEnum em : InstFinishEnum.values()) { - json.put("code", em.getCode()); - json.put("name", em.getName()); - arr.add(json); - } - return arr; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDesc() { - return desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - - public static String getName(String code) { - for (InstFinishEnum c : InstFinishEnum.values()) { - if (c.code == code) { - return c.name; - } - } - return null; - } - - public int getIndex() { - return index; - } - - public void setIndex(int index) { - this.index = index; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/instruction/enums/InstStatusEnum.java b/nladmin-system/src/main/java/org/nl/acs/instruction/enums/InstStatusEnum.java deleted file mode 100644 index 71d6d3a..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/instruction/enums/InstStatusEnum.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.nl.acs.instruction.enums; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - - -/** - * 任务状态 - */ -public enum InstStatusEnum { - READY(1, "READY", "就绪"), - ISSUE(2, "ISSUE", "已下发"), - BUSY(3, "BUSY", "执行中"), - FINISHED(4, "FINISHED", "完成"); - - - //索引 - private int index; - //编码 - private String code; - //名字 - private String name; - //描述 - private String desc; - - // 构造方法 - InstStatusEnum(int index, String code, String name) { - this.index = index; - this.code = code; - this.name = name; - - } - - public static JSONArray getList() { - JSONArray arr = new JSONArray(); - JSONObject json = new JSONObject(); - for (InstStatusEnum em : InstStatusEnum.values()) { - json.put("code", em.getCode()); - json.put("name", em.getName()); - arr.add(json); - } - return arr; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDesc() { - return desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - - public static String getName(String code) { - for (InstStatusEnum c : InstStatusEnum.values()) { - if (c.code == code) { - return c.name; - } - } - return null; - } - - public int getIndex() { - return index; - } - - public void setIndex(int index) { - this.index = index; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/instruction/enums/InstTypeEnum.java b/nladmin-system/src/main/java/org/nl/acs/instruction/enums/InstTypeEnum.java deleted file mode 100644 index 19f8487..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/instruction/enums/InstTypeEnum.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.nl.acs.instruction.enums; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - - -/** - * 任务类型 - */ -public enum InstTypeEnum { - IN(1, "IN", "入库"), - OUT(2, "OUT", "整盘出库"), - PICK_OUT(3, "PICK_OUT", "拣选出库"), - AGV_ONE(4, "AGV_ONE", "AGV单工"), - AGV_TWO(5, "AGV_TWO", "AGV双工"); - - - //索引 - private int index; - //编码 - private String code; - //名字 - private String name; - //描述 - private String desc; - - // 构造方法 - InstTypeEnum(int index, String code, String name) { - this.index = index; - this.code = code; - this.name = name; - - } - - public static JSONArray getList() { - JSONArray arr = new JSONArray(); - JSONObject json = new JSONObject(); - for (InstTypeEnum em : InstTypeEnum.values()) { - json.put("code", em.getCode()); - json.put("name", em.getName()); - arr.add(json); - } - return arr; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDesc() { - return desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - - public static String getName(String code) { - for (InstTypeEnum c : InstTypeEnum.values()) { - if (c.code == code) { - return c.name; - } - } - return null; - } - - public int getIndex() { - return index; - } - - public void setIndex(int index) { - this.index = index; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/instruction/rest/InstructionController.java b/nladmin-system/src/main/java/org/nl/acs/instruction/rest/InstructionController.java deleted file mode 100644 index b6dec60..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/instruction/rest/InstructionController.java +++ /dev/null @@ -1,140 +0,0 @@ - -package org.nl.acs.instruction.rest; - - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.annotation.Log; -import org.springframework.data.domain.Pageable; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.Map; - -/** - * @author ldjun - * @date 2021-03-18 - **/ -@RestController -@RequiredArgsConstructor -@Api(tags = "指令管理") -@RequestMapping("/api/instruction") -@Slf4j -public class InstructionController { - - private final InstructionService instructionService; - - @GetMapping - @Log("查询指令") - @ApiOperation("查询指令") - //@PreAuthorize("@el.check('instruction:list')") - public ResponseEntity query(@RequestParam Map whereJson, Pageable page) { - return new ResponseEntity<>(instructionService.queryAll(whereJson, page), HttpStatus.OK); - } - - @GetMapping("/getAll") - @Log("历史查询指令") - @ApiOperation("历史查询指令") - //@PreAuthorize("@el.check('instruction:list')") - public ResponseEntity get(@RequestParam Map whereJson, Pageable page) { - return new ResponseEntity<>(instructionService.getAll(whereJson, page), HttpStatus.OK); - } - - @GetMapping("/reload") - @Log("数据同步") - @ApiOperation("数据同步") - //@PreAuthorize("@el.check('task:list')") - public ResponseEntity reload() { - instructionService.reload(); - return new ResponseEntity<>(HttpStatus.OK); - } - - @GetMapping("/unfinish") - @Log("查询所有未完成指令") - @ApiOperation("查询所有未完成指令") - //@PreAuthorize("@el.check('instruction:list')") - public ResponseEntity queryUnFinish() { - return new ResponseEntity<>(instructionService.queryAll("instruction_status < 2"), HttpStatus.OK); - } - - @PostMapping - @Log("新增指令") - @ApiOperation("新增指令") - //@PreAuthorize("@el.check('instruction:add')") - public ResponseEntity create(@Validated @RequestBody Instruction dto) throws Exception { - instructionService.create(dto); - return new ResponseEntity<>(HttpStatus.CREATED); - } - - @PutMapping - @Log("修改指令") - @ApiOperation("修改指令") - //@PreAuthorize("@el.check('instruction:edit')") - public ResponseEntity update(@Validated @RequestBody Instruction dto) { - instructionService.update(dto); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - @Log("删除指令") - @ApiOperation("删除指令") - //@PreAuthorize("@el.check('instruction:del')") - @DeleteMapping - public ResponseEntity delete(@RequestBody String[] ids) throws Exception { - instructionService.deleteAll(ids); - return new ResponseEntity<>(HttpStatus.OK); - } - - @Log("完成指令") - @ApiOperation("完成指令") - @PostMapping(value = "/finish/{id}") - public ResponseEntity finish(@RequestBody String id) throws Exception { - instructionService.finish(id); - return new ResponseEntity<>(HttpStatus.OK); - } - - @Log("取消指令") - @ApiOperation("取消指令") - @PostMapping(value = "/cancel/{id}") - public ResponseEntity cancel(@RequestBody String id) throws Exception { - instructionService.cancel(id); - return new ResponseEntity<>(HttpStatus.OK); - } - - @Log("导出指令") - @ApiOperation("导出指令") - @GetMapping(value = "/download") - //@PreAuthorize("@el.check('instruction:list')") - public void download(HttpServletResponse response, Map whereJson) throws IOException { - instructionService.download(instructionService.queryAll(whereJson), response); - } - - - @Log("缓存查询指令") - @ApiOperation("缓存查询指令") - @PostMapping(value = "/findByCodeFromCache/{id}") - public ResponseEntity findByCodeFromCache(@RequestBody String id) { - return new ResponseEntity<>(instructionService.findByCodeFromCache(id), HttpStatus.OK); - } - - @Log("查询缓存所有指令") - @ApiOperation("查询缓存指令") - @PostMapping(value = "/findAllInstFromCache") - public ResponseEntity findAllInstFromCache() { - return new ResponseEntity<>(instructionService.findAllInstFromCache(), HttpStatus.OK); - } - - @Log("查询指定任务的所有指令") - @ApiOperation("查询指定任务的所有指令") - @PostMapping(value = "/queryByTaskId/{taskId}") - public ResponseEntity queryByTaskId(@RequestBody String taskId) { - return new ResponseEntity<>(instructionService.getByTaskId(taskId), HttpStatus.OK); - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java b/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java deleted file mode 100644 index 3342ef3..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java +++ /dev/null @@ -1,245 +0,0 @@ - -package org.nl.acs.instruction.service; - -import org.nl.acs.instruction.service.dto.Instruction; -import org.springframework.data.domain.Pageable; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.List; -import java.util.Map; - -/** - * @author ldjun - * @description 服务接口 - * @date 2021-03-18 - **/ -public interface InstructionService { - - /** - * 查询数据分页 - * - * @param whereJson 条件 - * @param page 分页参数 - * @return Map - */ - Map queryAll(Map whereJson, Pageable page); - - /** - * 查询数据分页 - * - * @param page 分页参数 - * @return Map - */ - Map getAll(Map whereJson, Pageable page); - - /** - * 数据同步 - */ - void reload(); - - /** - * 查询指定任务的所有指令不分页 - * - * @param id - * @return - */ - Map getByTaskId(String id); - - /** - * 查询所有数据不分页 - * - * @param whereJson 条件参数 - * @return List - */ - List queryAll(Map whereJson); - - /** - * 查询所有数据不分页 - * - * @param whereJson 条件参数 - * @return List - */ - List queryAll(String whereJson); - - /** - * 根据ID查询 - * - * @param instruction_id ID - * @return Instruction - */ - Instruction findById(String instruction_id); - - /** - * 根据编码查询 - * - * @param code code - * @return Instruction - */ - Instruction findByCode(String code); - - /** - * 根据任务code查询 - * - * @param code code - * @return Instruction - */ - Instruction findByTaskcode(String code); - - /** - * 根据任务id查询 - * - * @param id id - * @return Instruction - */ - Instruction findByTaskid(String id, String wherecase); - - /** - * 创建 - * - * @param dto / - */ - void create(Instruction dto) throws Exception; - - /** - * 再次创建 - * - * @param dto - * @throws Exception - */ - void createAgain(Instruction dto) throws Exception; - - /** - * 编辑 - * - * @param dto / - */ - void update(Instruction dto); - - /** - * 多选删除 - * - * @param ids / - */ - void deleteAll(String[] ids) throws Exception; - - /** - * 导出数据 - * - * @param dtos 待导出的数据 - * @param response / - * @throws IOException / - */ - void download(List dtos, HttpServletResponse response) throws IOException; - - /** - * 完成指令 - * - * @param id - */ - void finish(String id) throws Exception; - - /** - * 完成指令 - * - * @param - */ - void finish(Instruction dto) throws Exception; - - - /** - * 完成并创建下一条指令 - * - * @param - */ - void finishAndCreateNextInst(Instruction dto) throws Exception; - - - /** - * 取消指令 - * - * @param id - */ - void cancel(String id) throws Exception; - - /** - * 取消指令不下发agv - * - * @param id - */ - void cancelNOSendAgv(String id) throws Exception; - - /** - * 根据编码缓存查询 - * - * @param code code - * @return Instruction - */ - Instruction findByCodeFromCache(String code); - - - Instruction findByBarcodeFromCache(String barcode); - - /** - * 根据设备缓存查询 - * - * @param devicecode code - * @return Instruction - */ - Instruction findByDeviceCodeFromCache(String devicecode); - - /** - * 根据设备id查询 - * - * @param id - * @return Instruction - */ - Instruction findByIdFromCache(String id); - - /** - * @param inst - */ - Instruction foramte(Instruction inst); - - /** - * 缓存中查询所有指令 - * - * @return - */ - List findAllInstFromCache(); - - /** - * 查询相同终点指令的数量 - * - * @param code - * @return - */ - Integer querySameDestinationInst(String code); - - /** - * 查询相同指令类型的数量 - * - * @param inst_type - * @return - */ - Integer querySameInstType(String inst_type); - - /** - * 查询相同起点指令的数量 - * - * @param code - * @return - */ - Integer querySameOriginInst(String code); - - /** - * 查询相同起点、终点指令的数量 - * - * @param code - * @return - */ - //Integer querySameOriginInst(String code); - - boolean removeByCodeFromCache(String code); - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/Instruction.java b/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/Instruction.java deleted file mode 100644 index 3efb475..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/Instruction.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.nl.acs.instruction.service.dto; - -import lombok.Data; - -@Data -public class Instruction extends InstructionDto { - - private static final long serialVersionUID = 1L; - - public Instruction() { - } - - -} \ No newline at end of file diff --git a/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/InstructionDto.java b/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/InstructionDto.java deleted file mode 100644 index 5bc0624..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/InstructionDto.java +++ /dev/null @@ -1,248 +0,0 @@ -package org.nl.acs.instruction.service.dto; - -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; - -/** - * @author ldjun - * @description / - * @date 2021-04-01 - **/ -@Data -public class InstructionDto implements Serializable { - - /** - * 指令标识 - */ - private String instruction_id; - - /** - * 任务标识 - */ - private String task_id; - - /** - * 指令编码 - */ - private String instruction_code; - - /** - * 指令由哪台设备做 - */ - private String execute_device_code; - - /** - * 执行状态 - */ - //暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域 - private String execute_status; - - /** - * 执行状态描述 - */ - private String execute_status_description; - - /** - * 下一条指令由哪台设备做 - */ - private String follow_device_code; - - /** - * 指令类型 - */ - private String instruction_type = "1"; - - /** - * 指令状态 - */ - private String instruction_status; - - /** - * 创建类型 - */ - private String create_type; - - /** - * 完成类型 - */ - private String finish_type; - - /** - * 优先级 - */ - private String priority = "0"; - - /** - * 执行编码 - */ - private String execute_code; - - /** - * 执行信息 - */ - private String execute_message; - - /** - * 起始点位编码 - */ - private String start_point_code; - - /** - * 起始设备编码 - */ - private String start_device_code; - - /** - * 目标点位编码 - */ - private String next_point_code; - - /** - * 目标设备编码 - */ - private String next_device_code; - - /** - * 排 - */ - private String from_x; - - /** - * 列 - */ - private String from_y; - - /** - * 层 - */ - private String from_z; - - /** - * 排 - */ - private String to_x; - - /** - * 列 - */ - private String to_y; - - /** - * 层 - */ - private String to_z; - - /** - * 最后一条指令标识 - */ - private String last_instruction_id; - - /** - * 是否允许修改 - */ - private String can_modify; - - /** - * 备注 - */ - private String remark; - - /** - * 是否启用 - */ - private String is_active; - - /** - * 是否删除 - */ - private String is_delete; - - /** - * 创建者 - */ - private String create_by; - - /** - * 创建时间 - */ - private String create_time; - - /** - * 修改者 - */ - private String update_by; - - /** - * 修改时间 - */ - private String update_time; - - /** - * 任务号 - */ - private String task_code; - - /** - * 载具号 - */ - private String vehicle_code; - - /** - * 载具类型 - */ - private String vehicle_type; - - /** - * agv车号 - */ - private String carno; - - /** - * 物料类型 - */ - private String material; - - /** - * 物料数量 - */ - private BigDecimal quantity; - - /** - * 物料批次 - */ - private String batch; - - private String route_plan_code = "normal"; - - /** - * 是否复合任务 - */ - private String compound_inst; - - /** - * 复合任务数据 - */ - private String compound_inst_data; - - /** - * agv任务号(NDC系统使用) - */ - private String agv_jobno; - - /** - * 下发agv状态 0未下发 1成功 2失败 - */ - private String send_status; - - /** - * 起点父级编码 - */ - private String start_parent_code; - - /** - * 终点父级编码 - */ - private String next_parent_code; -} diff --git a/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java deleted file mode 100644 index f700fb9..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ /dev/null @@ -1,1219 +0,0 @@ - -package org.nl.acs.instruction.service.impl; - - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.ObjectUtils; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.config.AcsConfig; -import org.nl.acs.config.server.AcsConfigService; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device.service.impl.DeviceServiceImpl; -import org.nl.acs.device_driver.lamp_three_color.LampThreecolorDeviceDriver; -import org.nl.acs.device_driver.standard_conveyor_control.StandardCoveyorControlDeviceDriver; -import org.nl.acs.device_driver.standard_conveyor_control_with_plcscanner.StandardCoveyorControlWithPlcScannerDeviceDriver; -import org.nl.acs.device_driver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; -import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; -import org.nl.acs.device_driver.standard_storage.StandardStorageDeviceDriver; -import org.nl.acs.device_driver.traffic_light.TrafficLightDeviceDriver; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.opc.Device; -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.dto.RouteLineDto; -import org.nl.acs.route.service.impl.RouteLineServiceImpl; -import org.nl.acs.task.enums.TaskTypeEnum; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.exception.BadRequestException; -import org.nl.exception.WDKException; -import org.nl.modules.system.util.CodeUtil; -import org.nl.start.auto.initial.ApplicationAutoInitial; -import org.nl.utils.FileUtil; -import org.nl.utils.SecurityUtils; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.WQL; -import org.nl.wql.core.bean.WQLObject; -import org.nl.wql.util.WqlUtil; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.*; -import java.util.regex.Pattern; - -/** - * @author ldjun - * @description 服务实现 - * @date 2021-03-18 - **/ -@Service -@RequiredArgsConstructor -@Slf4j -public class InstructionServiceImpl implements InstructionService, ApplicationAutoInitial { - - List instructions = new ArrayList(); - - @Autowired - DeviceAppService deviceAppService; - @Autowired - AgvService agvService; - @Autowired - AcsConfigService acsConfigService; - @Autowired - RouteLineService routeLineService; - @Autowired - TaskService taskService; - - - @Override - public void autoInitial() { - this.reload(); - } - - public synchronized void reload() { - this.instructions = this.queryAll("instruction_status <2 and is_delete =0"); - } - - @Override - public Map queryAll(Map whereJson, Pageable page) { - /*WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "instruction_status < 2 and is_delete =0 ", "update_time desc"); - */ - this.reload(); - HashMap map = new HashMap<>(); - map.put("flag", "1"); - String code = (String) whereJson.get("code"); - String vehicle_code = (String) whereJson.get("vehicle_code"); - String material_type = (String) whereJson.get("material_type"); - String status = (String) whereJson.get("status"); - String point_code = (String) whereJson.get("point_code"); - String is_over = (String) whereJson.get("is_over"); - if (!StrUtil.isEmpty(code)) { - map.put("code", code); - } - if (!StrUtil.isEmpty(vehicle_code)) { - map.put("vehicle_code", vehicle_code); - } - if (!StrUtil.isEmpty(material_type)) { - map.put("material_type", material_type); - } - if (!StrUtil.isEmpty(status)) { - map.put("status", status); - } - if (!StrUtil.isEmpty(point_code)) { - map.put("point_code", point_code); - } - if (!StrUtil.isEmpty(is_over)) { - map.put("is_over", is_over); - } - - - final JSONObject jo = WQL.getWO("QINST_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), ""); - return jo; - } - - @Override - public Map getAll(Map whereJson, Pageable page) { - HashMap map = new HashMap<>(); - map.put("flag", "2"); - String code = (String) whereJson.get("code"); - String vehicle_code = (String) whereJson.get("vehicle_code"); - String material_type = (String) whereJson.get("material_type"); - String status = (String) whereJson.get("status"); - String point_code = (String) whereJson.get("point_code"); - String create_time = (String) whereJson.get("createTime"); - String end_time = (String) whereJson.get("end_time"); - if (!StrUtil.isEmpty(code)) { - map.put("code", code); - } - if (!StrUtil.isEmpty(vehicle_code)) { - map.put("vehicle_code", vehicle_code); - } - if (!StrUtil.isEmpty(material_type)) { - map.put("material_type", material_type); - } - if (!StrUtil.isEmpty(status)) { - map.put("status", status); - } - if (!StrUtil.isEmpty(point_code)) { - map.put("point_code", point_code); - } - if (!StrUtil.isEmpty(create_time) && !StrUtil.isEmpty(end_time)) { - map.put("create_time", create_time); - map.put("end_time", end_time); - } - - final JSONObject jo = WQL.getWO("QINST_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "create_time desc"); - return jo; - } - - @Override - public Map getByTaskId(String id) { - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject jsonObject = wo.query("task_id='" + id + "'").pageResult(); - JSONArray content = jsonObject.getJSONArray("content"); - JSONArray array = new JSONArray(); - for (int i = 0; i < content.size(); i++) { - JSONObject jo = (JSONObject) content.get(i); - JSONObject ins = new JSONObject(); - ins.put("task_id", jo.get("instruction_id")); - ins.put("task_code", jo.get("instruction_code")); - ins.put("task_status", jo.get("instruction_status")); - ins.put("start_point_code", jo.get("start_point_code")); - ins.put("next_point_code", jo.get("next_point_code")); - ins.put("matarial", jo.get("matarial")); - ins.put("remark", jo.get("remark")); - ins.put("create_by", jo.get("create_by")); - ins.put("create_time", jo.get("create_time")); - array.add(ins); - } - jsonObject.put("content", array); - return jsonObject; - } - - @Override - public List queryAll(Map whereJson) { - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONArray arr = wo.query().getResultJSONArray(0); - List list = arr.toJavaList(Instruction.class); - return list; - } - - @Override - public List queryAll(String whereJson) { - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONArray arr = wo.query(whereJson).getResultJSONArray(0); - List list = arr.toJavaList(Instruction.class); - return list; - } - - @Override - public Instruction findById(String instruction_id) { - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = wo.query("instruction_id ='" + instruction_id + "'").uniqueResult(0); - final Instruction obj = json.toJavaObject(Instruction.class); - return obj; - } - - @Override - public Instruction findByCode(String code) { - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = wo.query("instruction_code ='" + code + "'").uniqueResult(0); - final Instruction obj = json.toJavaObject(Instruction.class); - return obj; - } - - @Override - public Instruction findByTaskcode(String code) { - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = wo.query("task_code ='" + code + "'").uniqueResult(0); - final Instruction obj = json.toJavaObject(Instruction.class); - return obj; - } - - @Override - public Instruction findByTaskid(String id, String wherecaluse) { - if (!StrUtil.isEmpty(wherecaluse)) { - wherecaluse = " and " + wherecaluse; - } - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = wo.query("task_id ='" + id + "'" + wherecaluse).uniqueResult(0); - if (ObjectUtil.isNotEmpty(json)) - return json.toJavaObject(Instruction.class); - return null; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void create(Instruction dto) throws Exception { - dto = foramte(dto); - String task_code = dto.getTask_code(); - TaskDto task = taskService.findByCodeFromCache(task_code); - String excutetype = null; - //起点输送、终点货架 -- 入库 - if (StrUtil.equals(deviceAppService.findDeviceByCode(task.getStart_device_code()).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(), "conveyor") - && StrUtil.equals(deviceAppService.findDeviceByCode(task.getNext_device_code()).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(), "storage")) { - excutetype = TaskTypeEnum.IN.getName(); - //起点货架、终点输送 -- 出库 - } else if (StrUtil.equals(deviceAppService.findDeviceByCode(task.getStart_device_code()).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(), "storage") - && StrUtil.equals(deviceAppService.findDeviceByCode(task.getNext_device_code()).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(), "conveyor")) { - excutetype = TaskTypeEnum.OUT.getName(); - //起点输送、终点输送 -- 移动 - } else { - excutetype = TaskTypeEnum.MOVE.getName(); - } - - WQLObject instwo = WQLObject.getWQLObject("acs_instruction"); - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - if (StrUtil.isEmpty(dto.getRoute_plan_code())) { - dto.setRoute_plan_code(task.getRoute_plan_code()); - } - if (StrUtil.isEmpty(dto.getPriority())) { - dto.setPriority(task.getPriority()); - } - if (StrUtil.isEmpty(dto.getInstruction_code())) { - dto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO")); - } - if (StrUtil.isEmpty(dto.getInstruction_id())) { - dto.setInstruction_id(IdUtil.simpleUUID()); - } - dto.setInstruction_type(task.getTask_type()); - List shortPathsList = routeLineService.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), dto.getRoute_plan_code()); - if (ObjectUtils.isEmpty(shortPathsList)) { - throw new Exception(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由不通"); - } - String type = shortPathsList.get(0).getType(); - if (!StrUtil.equals(type, "0")) { - JSONObject instcheckjson = instwo.query(" instruction_status <2 and next_point_code= '" + dto.getNext_point_code() + "'" + " and start_point_code = '" + dto.getStart_point_code() + "'" + " and task_id = '" + dto.getTask_id() + "'").uniqueResult(0); - if (instcheckjson != null) { - throw new Exception(dto.getTask_code() + ":该任务已存在待完成指令!"); - } - } - if (!StrUtil.isEmpty(dto.getVehicle_code())) { - Instruction inst_dto = this.findByContainer(dto.getVehicle_code()); - if (ObjectUtils.isNotEmpty(inst_dto) && !StrUtil.equals(inst_dto.getTask_id(), dto.getTask_id())) { - throw new WDKException("已存在该载具号的指令!"); - } - } - //起点设备与终点设备相同则为初始指令 - if (StrUtil.equals(task.getStart_device_code(), dto.getStart_device_code())) { - if (!StrUtil.equals(dto.getCompound_inst(), "0") && StrUtil.equals(task.getCompound_task(), "1")) { - dto.setCompound_inst("1"); - dto.setCompound_inst_data(task.getCompound_task_data()); - } - } - - dto.setCreate_by(currentUsername); - dto.setUpdate_by(currentUsername); - dto.setUpdate_time(now); - dto.setCreate_time(now); - dto.setStart_parent_code(task.getStart_parent_code()); - dto.setNext_parent_code(task.getNext_parent_code()); - - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device startdevice = appService.findDeviceByCode(dto.getStart_device_code()); - Device nextdevice = appService.findDeviceByCode(dto.getNext_device_code()); - - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - LampThreecolorDeviceDriver lampThreecolorDeviceDriver; - StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver; - StandardCoveyorControlWithPlcScannerDeviceDriver standardCoveyorControlWithPlcScannerDeviceDriver; - StandardCoveyorControlDeviceDriver standardCoveyorControlDeviceDriver; - StandardStorageDeviceDriver standardStorageDeviceDriver; - //将指令赋予对象 下发指令号给电气 - if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver(); - standardInspectSiteDeviceDriver.setBranchProtocol(2); - standardInspectSiteDeviceDriver.setInst(dto); - standardInspectSiteDeviceDriver.setMessage("下发指令:dto.getInstruction_code(),执行中"); - standardInspectSiteDeviceDriver.writing(3, 1); - } - if (startdevice.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) { - standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) startdevice.getDeviceDriver(); - if (StrUtil.equals(excutetype, TaskTypeEnum.IN.getName())) { - if (standardCoveyorControlWithScannerDeviceDriver.getOperation_type() != 1) { - throw new RuntimeException("输送线非入库模式,无法下发"); - } - } - if (StrUtil.equals(excutetype, TaskTypeEnum.OUT.getName())) { - if (standardCoveyorControlWithScannerDeviceDriver.getOperation_type() != 2) { - throw new RuntimeException("输送线非出库模式,无法下发"); - } - } - standardCoveyorControlWithScannerDeviceDriver.setInst(dto); - if (!StrUtil.equals(nextdevice.getDeviceDriverDefination().getFitDeviceTypes().get(0).name(), "storage") && isInteger(nextdevice.getAddress())) { - standardCoveyorControlWithScannerDeviceDriver.writing(1, Integer.parseInt(nextdevice.getAddress()), Integer.parseInt(dto.getInstruction_code())); - } - } - if (startdevice.getDeviceDriver() instanceof StandardCoveyorControlWithPlcScannerDeviceDriver) { - standardCoveyorControlWithPlcScannerDeviceDriver = (StandardCoveyorControlWithPlcScannerDeviceDriver) startdevice.getDeviceDriver(); - if (StrUtil.equals(excutetype, TaskTypeEnum.IN.getName())) { - if (standardCoveyorControlWithPlcScannerDeviceDriver.getOperation_type() != 1) { - throw new RuntimeException("输送线非入库模式,无法下发"); - } - } - if (StrUtil.equals(excutetype, TaskTypeEnum.OUT.getName())) { - if (standardCoveyorControlWithPlcScannerDeviceDriver.getOperation_type() != 2) { - throw new RuntimeException("输送线非出库模式,无法下发"); - } - } - standardCoveyorControlWithPlcScannerDeviceDriver.setInst(dto); - if (!StrUtil.equals(nextdevice.getDeviceDriverDefination().getFitDeviceTypes().get(0).name(), "storage") && isInteger(nextdevice.getAddress())) { - standardCoveyorControlWithPlcScannerDeviceDriver.writing(1, Integer.parseInt(nextdevice.getAddress()), Integer.parseInt(dto.getInstruction_code())); - } - } - if (startdevice.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) startdevice.getDeviceDriver(); - if (StrUtil.equals(excutetype, TaskTypeEnum.IN.getName()) -// || StrUtil.equals(excutetype, TaskTypeEnum.MOVE.getName()) - ) { - if (standardCoveyorControlDeviceDriver.getOperation_type() != 1) { - throw new RuntimeException("输送线非入库模式,无法下发"); - } - } - if (StrUtil.equals(excutetype, TaskTypeEnum.OUT.getName())) { - if (standardCoveyorControlDeviceDriver.getOperation_type() != 2) { - throw new RuntimeException("输送线非出库模式,无法下发"); - } - } - standardCoveyorControlDeviceDriver.setInst(dto); - if (!StrUtil.equals(nextdevice.getDeviceDriverDefination().getFitDeviceTypes().get(0).name(), "storage") && isInteger(nextdevice.getAddress())) { - standardCoveyorControlDeviceDriver.writing(1, Integer.parseInt(nextdevice.getAddress()), Integer.parseInt(dto.getInstruction_code())); - } - } - - if (!ObjectUtils.isEmpty(nextdevice.getExtraValue().get("link_three_lamp"))) { - String lamd_device = nextdevice.getExtraValue().get("link_three_lamp").toString(); - Device lamddevice = appService.findDeviceByCode(lamd_device); - - if (lamddevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { - lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) lamddevice.getDeviceDriver(); - lampThreecolorDeviceDriver.writing(2); - } - } - - if (nextdevice.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) { - standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) nextdevice.getDeviceDriver(); - if (StrUtil.equals(excutetype, TaskTypeEnum.IN.getName())) { - if (standardCoveyorControlWithScannerDeviceDriver.getOperation_type() != 1) { - throw new RuntimeException("输送线非入库模式,无法下发"); - } - } - if (StrUtil.equals(excutetype, TaskTypeEnum.OUT.getName())) { - if (standardCoveyorControlWithScannerDeviceDriver.getOperation_type() != 2) { - throw new RuntimeException("输送线非出库模式,无法下发"); - } - } - } - if (nextdevice.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) nextdevice.getDeviceDriver(); - if (StrUtil.equals(excutetype, TaskTypeEnum.IN.getName())) { - if (standardCoveyorControlDeviceDriver.getOperation_type() != 1) { - throw new RuntimeException("指令终点输送线非入库模式,无法下发"); - } - } - if (StrUtil.equals(excutetype, TaskTypeEnum.OUT.getName()) -// || StrUtil.equals(excutetype, TaskTypeEnum.MOVE.getName()) - ) { - if (standardCoveyorControlDeviceDriver.getOperation_type() != 2) { - throw new RuntimeException("指令终点输送线非出库模式,无法下发"); - } - } - - } - - - try { - // != 0 为agv任务 - if (!StrUtil.equals(type, "0")) { - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "1")) { - HttpResponse result = agvService.sendAgvInstToMagic(dto); - if (ObjectUtils.isEmpty(result) || result.getStatus() != 200) { - dto.setSend_status("2"); - } else { - dto.setSend_status("1"); - } - } else if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "2")) { - agvService.sendAgvInstToNDC(dto); - dto.setSend_status("1"); - - } else if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "3")) { - if (StrUtil.equals(task.getRequest_again_success(), "1")) { - //追加订单 - HttpResponse result = agvService.addOrderSequences(dto); - if (ObjectUtils.isEmpty(result) || result.getStatus() != 200) { - dto.setSend_status("2"); - } else { - dto.setSend_status("1"); - } - } else { - //创建订单序列 - HttpResponse result = agvService.sendOrderSequencesToXZ(dto); - if (ObjectUtils.isEmpty(result) || result.getStatus() != 200) { - dto.setSend_status("2"); - } else { - dto.setSend_status("1"); - } - } - } - } - } catch (Exception e) { - dto.setSend_status("2"); - e.printStackTrace(); - } - - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - instructions.add(dto); - } - - - @Override - @Transactional(rollbackFor = Exception.class) - public void createAgain(Instruction dto) throws Exception { - String task_code = dto.getTask_code(); - TaskDto task = taskService.findByCodeFromCache(task_code); - WQLObject instwo = WQLObject.getWQLObject("acs_instruction"); - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - if (StrUtil.isEmpty(dto.getRoute_plan_code())) { - dto.setRoute_plan_code(task.getRoute_plan_code()); - } - if (StrUtil.isEmpty(dto.getInstruction_code())) { - dto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO")); - } - if (StrUtil.isEmpty(dto.getInstruction_id())) { - dto.setInstruction_id(IdUtil.simpleUUID()); - } - List shortPathsList = routeLineService.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), dto.getRoute_plan_code()); - if (ObjectUtils.isEmpty(shortPathsList)) { - throw new Exception(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由不通"); - } - String type = shortPathsList.get(0).getType(); - if (!StrUtil.equals(type, "0")) { - JSONObject instcheckjson = instwo.query(" instruction_status <3 and next_point_code= '" + dto.getNext_point_code() + "'" + " and start_point_code = '" + dto.getStart_point_code() + "'" + " and task_id = '" + dto.getTask_id() + "'").uniqueResult(0); - if (instcheckjson != null) { - throw new Exception(dto.getTask_code() + ":该任务已存在待完成指令!"); - } - } - - if (!StrUtil.equals(dto.getCompound_inst(), "0") && StrUtil.equals(task.getCompound_task(), "1")) { - dto.setCompound_inst("1"); - dto.setCompound_inst_data(task.getCompound_task_data()); - } - - dto.setCreate_by(currentUsername); - dto.setUpdate_by(currentUsername); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device startdevice = appService.findDeviceByCode(dto.getStart_device_code()); - Device nextdevice = appService.findDeviceByCode(dto.getNext_device_code()); - - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - LampThreecolorDeviceDriver lampThreecolorDeviceDriver; - StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver; - - //将指令赋予对象 下发指令号给电气 - if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver(); - standardInspectSiteDeviceDriver.setBranchProtocol(2); - standardInspectSiteDeviceDriver.setInst(dto); - standardInspectSiteDeviceDriver.writing(3, 1); - } - if (startdevice.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) { - standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) startdevice.getDeviceDriver(); - standardCoveyorControlWithScannerDeviceDriver.setInst(dto); - standardCoveyorControlWithScannerDeviceDriver.writing(); - } - - if (!ObjectUtils.isEmpty(nextdevice.getExtraValue().get("link_three_lamp"))) { - String lamd_device = nextdevice.getExtraValue().get("link_three_lamp").toString(); - Device lamddevice = appService.findDeviceByCode(lamd_device); - - if (lamddevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { - lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) lamddevice.getDeviceDriver(); - lampThreecolorDeviceDriver.writing(2); - } - } - - - // != 0 为agv任务 -// if(!StrUtil.equals(type,"0")){ -// if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "1")) { -// agvService.sendAgvInstToMagic(dto); -// } else if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "2")) { -// agvService.sendAgvInstToNDC(dto); -// } else if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "3")) { -// agvService.addOrderSequences(dto); -// } -// } - instructions.add(dto); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(Instruction dto) { - Instruction entity = this.findById(dto.getInstruction_id()); - //if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); - - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - dto.setUpdate_time(now); - dto.setUpdate_by(currentUsername); - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.update(json); - - Iterator iterator = instructions.iterator(); - while (iterator.hasNext()) { - Instruction instruction = iterator.next(); - if (instruction.getInstruction_code().equals(dto.getInstruction_code())) { - iterator.remove(); - } - } - if (StrUtil.equals(dto.getInstruction_status(), "0") || StrUtil.equals(dto.getInstruction_status(), "1")) { - instructions.add(dto); - } - - - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteAll(String[] ids) throws Exception { - for (String instruction_id : ids) { - this.cancel(instruction_id); - } - } - - @Override - public void download(List all, HttpServletResponse response) throws IOException { - List> list = new ArrayList<>(); - for (Instruction instruction : all) { - Map map = new LinkedHashMap<>(); - map.put("任务标识", instruction.getTask_id()); - map.put("指令编码", instruction.getInstruction_code()); - map.put("指令由哪台设备做", instruction.getExecute_device_code()); - map.put("执行状态", instruction.getExecute_status()); - map.put("执行状态描述", instruction.getExecute_status_description()); - map.put("下一条指令由哪台设备做", instruction.getFollow_device_code()); - map.put("指令类型", instruction.getInstruction_type()); - map.put("指令状态", instruction.getInstruction_status()); - map.put("创建类型", instruction.getCreate_type()); - map.put("完成类型", instruction.getFinish_type()); - map.put("优先级", instruction.getPriority()); - map.put("执行编码", instruction.getExecute_code()); - map.put("执行信息", instruction.getExecute_message()); - map.put("起始点位编码", instruction.getStart_point_code()); - map.put("起始设备编码", instruction.getStart_device_code()); - map.put("目标点位编码", instruction.getNext_point_code()); - map.put("目标设备编码", instruction.getNext_device_code()); - map.put("排", instruction.getFrom_x()); - map.put("列", instruction.getFrom_y()); - map.put("层", instruction.getFrom_z()); - map.put("排", instruction.getTo_x()); - map.put("列", instruction.getTo_y()); - map.put("层", instruction.getTo_z()); - map.put("最后一条指令标识", instruction.getLast_instruction_id()); - map.put("是否允许修改", instruction.getCan_modify()); - map.put("备注", instruction.getRemark()); - map.put("是否启用", instruction.getIs_active()); - map.put("是否删除", instruction.getIs_delete()); - map.put("创建者", instruction.getCreate_by()); - map.put("创建时间", instruction.getCreate_time()); - map.put("修改者", instruction.getUpdate_by()); - map.put("修改时间", instruction.getUpdate_time()); - list.add(map); - } - FileUtil.downloadExcel(list, response); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void finish(String id) throws Exception { - Instruction entity = this.findById(id); - //if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - entity.setUpdate_time(now); - entity.setUpdate_by(currentUsername); - entity.setInstruction_status("2"); - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - String instnextdevice = entity.getNext_device_code(); - String insttaskid = entity.getTask_id(); - WQLObject taskwo = WQLObject.getWQLObject("acs_task"); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device startdevice = appService.findDeviceByCode(entity.getStart_device_code()); - if (ObjectUtils.isEmpty(startdevice)) { - log.debug("地址对应设备未找到"); - throw new BadRequestException("地址对应设备未找到"); - } - if (instnextdevice.indexOf(".") != -1) { - instnextdevice = instnextdevice.substring(0, instnextdevice.indexOf(".")); - } - Device device = appService.findDeviceByCode(instnextdevice); - if (device == null) { - log.debug("地址对应设备未找到"); - throw new BadRequestException("地址对应设备未找到"); - } - DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); - - JSONObject jo1 = new JSONObject(); - jo1.put("device_code", instnextdevice); - if (StrUtil.equals(entity.getMaterial(), "1")) { - jo1.put("hasGoodStatus", "1"); - } else { - jo1.put("hasGoodStatus", "2"); - } - jo1.put("material_type", startdevice.getMaterial_type()); - jo1.put("quantity", startdevice.getQuantity()); - jo1.put("remark", startdevice.getRemark()); - jo1.put("batch", startdevice.getBatch()); - jo1.put("vehicle_code", entity.getVehicle_code()); - jo1.put("islock", "false"); - jo1.put("barrels_code", startdevice.getBarrels_code()); - jo1.put("cooperate_code", startdevice.getCooperate_code()); - jo1.put("powder_name", startdevice.getPowder_name()); - jo1.put("barrels_status", startdevice.getBarrels_status()); - deviceService.changeDeviceStatus(jo1); - // 如果是无光电的设备 指令完成变更起点、终点状态 - JSONObject jo = new JSONObject(); - jo.put("device_code", entity.getStart_device_code()); - jo.put("hasGoodStatus", "0"); - jo.put("material_type", ""); - jo.put("quantity", ""); - jo.put("remark", ""); - jo.put("batch", ""); - jo.put("islock", "false"); - deviceService.changeDeviceStatus(jo); - - JSONObject json = (JSONObject) JSONObject.toJSON(entity); - wo.update(json); - JSONObject taskjson = taskwo.query("task_id ='" + insttaskid + "'").uniqueResult(0); - TaskDto obj = taskjson.toJavaObject(TaskDto.class); - // =0 则不用再次请求 - if (StrUtil.equals(obj.getRequest_again(), "0")) { - if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) { - taskService.finish(obj.getTask_id()); - } else { - finishAndCreateNextInst(entity); - } - } - LampThreecolorDeviceDriver lampThreecolorDeviceDriver; - //交通灯 - TrafficLightDeviceDriver trafficLightDeviceDriver; - //变更三色灯状态 - if (!ObjectUtils.isEmpty(device.getExtraValue().get("link_three_lamp"))) { - String lamd_device = device.getExtraValue().get("link_three_lamp").toString(); - Device lamddevice = appService.findDeviceByCode(lamd_device); - if (lamddevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { - lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) lamddevice.getDeviceDriver(); - lampThreecolorDeviceDriver.writing(0); - } - } - //变更交通灯状态 - if (!ObjectUtils.isEmpty(device.getExtraValue().get("link_three_lamp"))) { - String lamd_device = device.getExtraValue().get("link_three_lamp").toString(); - Device lamddevice = appService.findDeviceByCode(lamd_device); - if (lamddevice.getDeviceDriver() instanceof TrafficLightDeviceDriver) { - trafficLightDeviceDriver = (TrafficLightDeviceDriver) lamddevice.getDeviceDriver(); - trafficLightDeviceDriver.writing(2); - } - } - removeByCodeFromCache(entity.getInstruction_code()); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void finish(Instruction dto) throws Exception { - String now = DateUtil.now(); - dto.setInstruction_status("2"); - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.update(json); - String instnextdevice = dto.getNext_device_code(); - String insttaskid = dto.getTask_id(); - WQLObject taskwo = WQLObject.getWQLObject("acs_task"); - JSONObject taskjson = taskwo.query("task_id ='" + insttaskid + "'").uniqueResult(0); - TaskDto obj = taskjson.toJavaObject(TaskDto.class); - // =0 则不用再次请求 - if (StrUtil.equals(obj.getRequest_again(), "0")) { - if (StrUtil.equals(obj.getNext_device_code(), instnextdevice)) { - taskService.finish(obj.getTask_id()); - } else { - finishAndCreateNextInst(dto); - } - } - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); - Device device = appService.findDeviceByCode(instnextdevice); - if (device == null) { - log.debug("地址对应设备未找到"); - return; - } - // 如果是无光电的设备 放货任务完成需要变更有货状态 -// StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; -// if(device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { -// standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); -// standardOrdinarySiteDeviceDriver.setMove(2); -// } - - // 如果是无光电的设备 指令完成变更起点、终点状态 - JSONObject jo = new JSONObject(); - jo.put("device_code", dto.getStart_point_code()); - jo.put("hasGoodStatus", "0"); - jo.put("material_type", ""); - jo.put("batch", ""); - deviceService.changeDeviceStatus(jo); - - JSONObject jo1 = new JSONObject(); - jo1.put("device_code", dto.getNext_point_code()); - jo1.put("hasGoodStatus", "1"); - jo1.put("material_type", dto.getMaterial()); - jo1.put("batch", dto.getBatch()); - deviceService.changeDeviceStatus(jo1); - LampThreecolorDeviceDriver lampThreecolorDeviceDriver; - - - //变更三色灯状态 - if (!ObjectUtils.isEmpty(device.getExtraValue().get("link_three_lamp"))) { - String lamd_device = device.getExtraValue().get("link_three_lamp").toString(); - Device lamddevice = appService.findDeviceByCode(lamd_device); - - if (lamddevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { - lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) lamddevice.getDeviceDriver(); - lampThreecolorDeviceDriver.writing(0); - } - } - - removeByCodeFromCache(dto.getInstruction_code()); - - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void finishAndCreateNextInst(Instruction dto) throws Exception { - dto = foramte(dto); - String device_code = dto.getNext_device_code(); - WQLObject taskwo = WQLObject.getWQLObject("acs_task"); - JSONObject taskjson = taskwo.query("task_id ='" + dto.getTask_id() + "'").uniqueResult(0); - TaskDto acsTask = taskjson.toJavaObject(TaskDto.class); - RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class); - List list = routeLineService.getShortPathLines(dto.getNext_device_code(), acsTask.getNext_device_code(), acsTask.getRoute_plan_code()); - if (ObjectUtils.isEmpty(list)) { - throw new BadRequestException("路由不通"); - } - RouteLineDto routeLineDto = (RouteLineDto) list.get(0); - String[] path = routeLineDto.getPath().split("->"); - List pathlist = Arrays.asList(path); - int index = 0; - for (int m = 0; m < pathlist.size(); m++) { - if (pathlist.get(m).equals(dto.getNext_device_code())) { - index = m + 1; - break; - } - } - String next_device_code = pathlist.get(index); - String start_device_code = dto.getNext_device_code(); - String start_point_code = null; - String next_point_code = null; - String start_device = deviceAppService.findDeviceByCode(start_device_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(); - String next_device = deviceAppService.findDeviceByCode(next_device_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(); - if (StrUtil.equals("storage", start_device)) { - start_point_code = start_device_code + "-" + acsTask.getFrom_y() + "-" + acsTask.getFrom_z(); - } else { - start_point_code = start_device_code; - } - if (StrUtil.equals("storage", next_device)) { - next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z(); - } else { - next_point_code = next_device_code; - } - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(acsTask.getRoute_plan_code()); - instdto.setRemark(acsTask.getRemark()); - instdto.setMaterial(acsTask.getMaterial()); - instdto.setQuantity(acsTask.getQuantity()); - instdto.setTask_id(acsTask.getTask_id()); - instdto.setTask_code(acsTask.getTask_code()); - instdto.setVehicle_code(acsTask.getVehicle_code()); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setPriority(acsTask.getPriority()); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(dto.getNext_device_code()); - this.create(instdto); - } - - @Override - public void cancel(String id) throws Exception { - //flag= true时取消指令 - boolean flag = false; - Instruction entity = this.findById(id); - if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); - TaskDto task = taskService.findByCodeFromCache(entity.getTask_code()); - if (StrUtil.isEmpty(entity.getRoute_plan_code())) { - entity.setRoute_plan_code(task.getRoute_plan_code()); - } - - List shortPathsList = routeLineService.getShortPathLines(entity.getStart_device_code(), entity.getNext_device_code(), entity.getRoute_plan_code()); - String type = shortPathsList.get(0).getType(); - // != 0 为agv任务 1=magic 2=NDC 3=XZ - if (!StrUtil.equals(type, "0")) { - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "1") - && !StrUtil.equals(entity.getSend_status(), "2")) { - agvService.deleteAgvInst(entity.getInstruction_code()); - flag = true; - - } else if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "2")) { - //NDC agv指令不当场取消指令,需要等agv上报 - if (!StrUtil.isEmpty(entity.getAgv_jobno())) { - agvService.deleteAgvInstToNDC(entity); - } else { - flag = true; - } - } else if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "3") - && !StrUtil.equals(entity.getSend_status(), "2")) { - agvService.deleteXZAgvInst(entity.getInstruction_code()); - flag = true; - } else { - flag = true; - } - } else { - flag = true; - } - - if (flag) { - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - entity.setUpdate_time(now); - entity.setUpdate_by(currentUsername); - entity.setInstruction_status("3"); - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = (JSONObject) JSONObject.toJSON(entity); - wo.update(json); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); - - // 如果是无光电的设备 指令完成变更起点、终点状态 - JSONObject jo = new JSONObject(); - jo.put("device_code", entity.getStart_device_code()); - if (StrUtil.equals(entity.getMaterial(), "1")) { - jo.put("hasGoodStatus", "1"); - } else if (!StrUtil.equals(entity.getMaterial(), "1") && !StrUtil.isEmpty(entity.getMaterial())) { - jo.put("hasGoodStatus", "2"); - } else { - jo.put("hasGoodStatus", "0"); - } - jo.put("material_type", entity.getMaterial()); - jo.put("batch", entity.getBatch()); - jo.put("islock", "false"); - deviceService.changeDeviceStatus(jo); - - JSONObject jo1 = new JSONObject(); - jo1.put("device_code", entity.getNext_device_code()); - jo.put("hasGoodStatus", "0"); - jo.put("material_type", ""); - jo.put("batch", ""); - jo1.put("islock", "false"); - deviceService.changeDeviceStatus(jo1); - - String instnextdevice = entity.getNext_device_code(); - Device device = appService.findDeviceByCode(instnextdevice); - if (device == null) { - log.debug("地址对应设备未找到"); - return; - } - LampThreecolorDeviceDriver lampThreecolorDeviceDriver; - //变更三色灯状态 - if (!ObjectUtils.isEmpty(device.getExtraValue().get("link_three_lamp"))) { - String lamd_device = device.getExtraValue().get("link_three_lamp").toString(); - Device lamddevice = appService.findDeviceByCode(lamd_device); - if (lamddevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { - lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) lamddevice.getDeviceDriver(); - lampThreecolorDeviceDriver.writing(0); - } - } - removeByCodeFromCache(entity.getInstruction_code()); - } - - } - - @Override - public void cancelNOSendAgv(String id) throws Exception { - //flag= true时取消指令 - Instruction entity = this.findById(id); - if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); - TaskDto task = taskService.findByCodeFromCache(entity.getTask_code()); - if (StrUtil.isEmpty(entity.getRoute_plan_code())) { - entity.setRoute_plan_code(task.getRoute_plan_code()); - } - - List shortPathsList = routeLineService.getShortPathLines(entity.getStart_device_code(), entity.getNext_device_code(), entity.getRoute_plan_code()); - String type = shortPathsList.get(0).getType(); - - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - entity.setUpdate_time(now); - entity.setUpdate_by(currentUsername); - entity.setInstruction_status("3"); - WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = (JSONObject) JSONObject.toJSON(entity); - wo.update(json); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); - - // 如果是无光电的设备 指令完成变更起点、终点状态 - JSONObject jo = new JSONObject(); - jo.put("device_code", entity.getStart_device_code()); - if (StrUtil.equals(entity.getMaterial(), "1")) { - jo.put("hasGoodStatus", "1"); - } else if (!StrUtil.equals(entity.getMaterial(), "1") && !StrUtil.isEmpty(entity.getMaterial())) { - jo.put("hasGoodStatus", "2"); - } else { - jo.put("hasGoodStatus", "0"); - } - jo.put("material_type", entity.getMaterial()); - jo.put("batch", entity.getBatch()); - jo.put("islock", "false"); - deviceService.changeDeviceStatus(jo); - - JSONObject jo1 = new JSONObject(); - jo1.put("device_code", entity.getNext_device_code()); - jo.put("hasGoodStatus", "0"); - jo.put("material_type", ""); - jo.put("batch", ""); - jo1.put("islock", "false"); - deviceService.changeDeviceStatus(jo1); - - String instnextdevice = entity.getNext_device_code(); - Device device = appService.findDeviceByCode(instnextdevice); - if (device == null) { - log.debug("地址对应设备未找到"); - return; - } - LampThreecolorDeviceDriver lampThreecolorDeviceDriver; - //变更三色灯状态 - if (!ObjectUtils.isEmpty(device.getExtraValue().get("link_three_lamp"))) { - String lamd_device = device.getExtraValue().get("link_three_lamp").toString(); - Device lamddevice = appService.findDeviceByCode(lamd_device); - if (lamddevice.getDeviceDriver() instanceof LampThreecolorDeviceDriver) { - lampThreecolorDeviceDriver = (LampThreecolorDeviceDriver) lamddevice.getDeviceDriver(); - lampThreecolorDeviceDriver.writing(0); - } - } - removeByCodeFromCache(entity.getInstruction_code()); - - } - - - @Override - public Instruction findByCodeFromCache(String code) { - - for (int i = 0; i < this.instructions.size(); i++) { - Instruction inst = instructions.get(i); - if (StrUtil.equals(code, inst.getInstruction_code())) { - return inst; - } - } - return null; - } - - @Override - public Instruction findByBarcodeFromCache(String barcode) { - for (int i = 0; i < this.instructions.size(); i++) { - Instruction inst = instructions.get(i); - if (StrUtil.equals(barcode, inst.getVehicle_code())) { - return inst; - } - } - return null; - } - - @Override - public Instruction findByIdFromCache(String id) { - - for (int i = 0; i < this.instructions.size(); i++) { - Instruction inst = instructions.get(i); - if (StrUtil.equals(id, inst.getInstruction_id())) { - return inst; - } - } - return null; - } - - @Override - public Instruction foramte(Instruction inst) { - String start_point_code = inst.getStart_point_code(); - String next_point_code = inst.getNext_point_code(); - String start_device_code = ""; - String next_device_code = ""; - if (StrUtil.contains(start_point_code, ".")) { - String[] point = start_point_code.split("\\."); - start_device_code = point[0]; - } else { - start_device_code = start_point_code; - } - if (StrUtil.contains(next_point_code, ".")) { - String[] point = next_point_code.split("\\."); - next_device_code = point[0]; - } else { - next_device_code = next_point_code; - } - if (StrUtil.contains(start_point_code, "-") && StrUtil.count(start_point_code, "-") == 2) { - String[] start_point = start_point_code.split("-"); - inst.setFrom_x(start_point[0]); - inst.setStart_device_code(start_point[0]); - inst.setFrom_y(start_point[1]); - inst.setFrom_z(start_point[2]); - } else { - String start_device = deviceAppService.findDeviceByCode(start_device_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(); - if (StrUtil.equals("storage", start_device)) { - String[] start_point = start_point_code.split("-"); - inst.setFrom_x(start_point[0]); - inst.setStart_device_code(start_point[0]); - inst.setFrom_y(start_point[1]); - inst.setFrom_z(start_point[2]); - } else { - inst.setStart_device_code(start_device_code); - } - } - - if (StrUtil.contains(next_point_code, "-") && StrUtil.count(next_point_code, "-") == 2) { - String[] next_point = next_point_code.split("-"); - inst.setTo_x(next_point[0]); - inst.setNext_device_code(next_point[0]); - inst.setTo_y(next_point[1]); - inst.setTo_z(next_point[2]); - } else { - - String next_device = deviceAppService.findDeviceByCode(next_device_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(); - if (StrUtil.equals("storage", next_device)) { - String[] next_point = start_point_code.split("-"); - inst.setTo_x(next_point[0]); - inst.setNext_device_code(next_point[0]); - inst.setTo_y(next_point[1]); - inst.setTo_z(next_point[2]); - } else { - inst.setNext_device_code(next_device_code); - } - } - return inst; - } - - @Override - public Instruction findByDeviceCodeFromCache(String devicecode) { - - for (int i = 0; i < this.instructions.size(); i++) { - Instruction inst = instructions.get(i); - if (StrUtil.equals(devicecode, inst.getExecute_code())) { - return inst; - } - } - return null; - } - - @Override - public List findAllInstFromCache() { - return instructions; - } - - - @Override - public Integer querySameDestinationInst(String devicecode) { - int num = 0; - for (int i = 0; i < this.instructions.size(); i++) { - Instruction inst = instructions.get(i); - //处理空盘位站点 - String next_code = inst.getNext_point_code(); - if (next_code.indexOf(".") != -1) { - next_code = next_code.substring(0, next_code.indexOf(".")); - } - if (StrUtil.equals(devicecode, next_code)) { - num = num + 1; - } - } - return num; - } - - @Override - public Integer querySameInstType(String inst_type) { - int num = 0; - for (int i = 0; i < this.instructions.size(); i++) { - Instruction inst = instructions.get(i); - if (StrUtil.equals(inst.getInstruction_type(), inst_type)) { - num = num + 1; - } - } - return num; - } - - @Override - public Integer querySameOriginInst(String devicecode) { - int num = 0; - for (int i = 0; i < this.instructions.size(); i++) { - Instruction inst = instructions.get(i); - //处理空盘位站点 - String start_code = inst.getStart_point_code(); - if (start_code.indexOf(".") != -1) { - start_code = start_code.substring(0, start_code.indexOf(".")); - } - if (StrUtil.equals(devicecode, start_code)) { - num = num + 1; - } - } - return num; - } - - @Override - public boolean removeByCodeFromCache(String code) { - - Iterator iterator = instructions.iterator(); - while (iterator.hasNext()) { - Instruction instruction = iterator.next(); - if (instruction.getInstruction_code().equals(code)) { - iterator.remove(); - return true; - } - } - return false; - } - - public Instruction findByContainer(String container_code) { - Iterator var3 = instructions.iterator(); - - while (var3.hasNext()) { - Instruction instruction = (Instruction) var3.next(); - if (StrUtil.equals(instruction.getVehicle_code(), container_code)) { - return instruction; - } - } - - return null; - } - - /* - * 判断是否为整数 - * @param str 传入的字符串 - * @return 是整数返回true,否则返回false - */ - public static boolean isInteger(String str) { - Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$"); - return pattern.matcher(str).matches(); - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/instruction/service/wql/QINST_QUERY.wql b/nladmin-system/src/main/java/org/nl/acs/instruction/service/wql/QINST_QUERY.wql deleted file mode 100644 index 170478f..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/instruction/service/wql/QINST_QUERY.wql +++ /dev/null @@ -1,126 +0,0 @@ -[交易说明] - 交易名: 手持接口查询 - 所属模块: - 功能简述: - 版权所有: - 表引用: - 版本经历: - -[数据库] - --指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 - -[IO定义] - ################################################# - ## 表字段对应输入参数 - ################################################# - 输入.flag TYPEAS s_string - 输入.code TYPEAS s_string - 输入.vehicle_code TYPEAS s_string - 输入.material_type TYPEAS s_string - 输入.status TYPEAS s_string - 输入.point_code TYPEAS s_string - 输入.point_code TYPEAS s_string - 输入.create_time TYPEAS time - 输入.end_time TYPEAS time - - -[临时表] - --这边列出来的临时表就会在运行期动态创建 - -[临时变量] - --所有中间过程变量均可在此处定义 - -[业务过程] - - ########################################## - # 1、输入输出检查 # - ########################################## - - - ########################################## - # 2、主过程前处理 # - ########################################## - - - ########################################## - # 3、业务主过程 # - ########################################## - IF 输入.flag = "1" - PAGEQUERY - SELECT - * - FROM - acs_instruction inst - WHERE - is_delete =0 - OPTION 输入.is_over = "1" - inst.instruction_status >= 2 - ENDOPTION - OPTION 输入.is_over <> "1" - inst.instruction_status < 2 - ENDOPTION - OPTION 输入.task_code <> "" - ( - inst.instruction_code = 输入.code - OR - inst.task_code = 输入.code - ) - ENDOPTION - OPTION 输入.status <> "" - inst.instruction_status = 输入.status - ENDOPTION - OPTION 输入.vehicle_code <> "" - inst.vehicle_code = 输入.vehicle_code - ENDOPTION - OPTION 输入.material_type <> "" - inst.material = 输入.material_type - ENDOPTION - OPTION 输入.point_code <> "" - ( - inst.start_point_code = 输入.point_code - OR - inst.next_point_code = 输入.point_code - ) - ENDOPTION - ENDSELECT - ENDPAGEQUERY - ENDIF - - IF 输入.flag = "2" - PAGEQUERY - SELECT - * - FROM - acs_instruction inst - WHERE - is_delete =0 - OPTION 输入.task_code <> "" - ( - inst.instruction_code = 输入.code - OR - inst.task_code = 输入.code - ) - ENDOPTION - OPTION 输入.status <> "" - inst.instruction_status = 输入.status - ENDOPTION - OPTION 输入.vehicle_code <> "" - inst.vehicle_code = 输入.vehicle_code - ENDOPTION - OPTION 输入.material_type <> "" - inst.material = 输入.material_type - ENDOPTION - OPTION 输入.point_code <> "" - ( - inst.start_point_code = 输入.point_code - OR - inst.next_point_code = 输入.point_code - ) - ENDOPTION - ENDOPTION - OPTION 输入.create_time <> "" - inst.create_time between 输入.create_time and 输入.end_time - ENDOPTION - ENDSELECT - ENDPAGEQUERY - ENDIF diff --git a/nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderService.java b/nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderService.java index 54c4ef7..e72f485 100644 --- a/nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderService.java +++ b/nladmin-system/src/main/java/org/nl/acs/order/service/ProduceshiftorderService.java @@ -3,9 +3,7 @@ package org.nl.acs.order.service; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.order.service.dto.ProduceshiftorderDto; -import org.nl.acs.order.service.dto.ProduceshiftorderdetailDto; import org.springframework.data.domain.Pageable; import javax.servlet.http.HttpServletResponse; diff --git a/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java b/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java index e27a3d4..f22e65f 100644 --- a/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java +++ b/nladmin-system/src/main/java/org/nl/acs/order/service/impl/ProduceshiftorderServiceImpl.java @@ -6,15 +6,9 @@ import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.excel.EasyExcel; -import com.alibaba.excel.ExcelWriter; -import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import com.spire.xls.CellRange; -import com.spire.xls.PageSetup; -import com.spire.xls.Workbook; -import com.spire.xls.Worksheet; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.nl.acs.config.AcsConfig; @@ -42,7 +36,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletResponse; -import java.awt.print.*; import java.io.IOException; import java.util.*; @@ -834,17 +827,6 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A dto.setLength(length); orderTab.insert(JSONObject.parseObject(JSON.toJSONString(dto))); -// Map map2 = new HashMap<>(); -// map2.put("material_id",IdUtil.simpleUUID()); -// map2.put("material_code",material_code); -// map2.put("material_name",material_name); -// map2.put("material_spec",material_spec); -// map2.put("outer_diameter",outer_diameter); -// map2.put("wall_thickness",wall_thickness); -// map2.put("length",length); -// map2.put("qty",qty); -// -// create(map2); } } @@ -1008,85 +990,6 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A @Override public Boolean print(JSONObject whereJson) { -// String order_id = whereJson.getString("order_id"); -// String template_id = whereJson.getString("template_id"); -// -// WQLObject mst = WQLObject.getWQLObject("acs_produceshiftorder"); // 主表 -// -// // 1.根据明细找主表 -// JSONObject jsonMst = mst.query("order_id = '" + order_id + "' and is_deleted ='0'").uniqueResult(0); -// -// // 2.根据明细template_id 找到对应的模板 -// JSONObject jsonStor = WQL.getWO("QPRODUCESHIFTORDER").addParam("flag", "3").addParam("storage_id", template_id).process().uniqueResult(0); -// -// // 3.创建模板工作簿 并指定储存路径 -// String path = jsonStor.getString("path"); -// String pathName = whereJson.getString("url"); -// ExcelWriter workBook = EasyExcel.write(pathName).withTemplate(path).build(); -// // 获取第一个sheet -// WriteSheet sheet = EasyExcel.writerSheet().build(); -// -// // 4.将主表当中的属性填充到excel当中 -// HashMap map = new HashMap<>(); -// map.put("alloy",whereJson.getString("alloy")); -// map.put("temper",whereJson.getString("temper")); -// map.put("material_spec",whereJson.getString("material_spec")); -// map.put("number",whereJson.getString("number")); -// map.put("outer_diameter",whereJson.getString("outer_diameter")); -// map.put("standard",whereJson.getString("standard")); -// map.put("batch",whereJson.getString("batch")); -// map.put("prod_date",whereJson.getString("prod_date")); -// map.put("present_strap_pack_number",whereJson.getString("present_strap_pack_number")); -// map.put("inspector",whereJson.getString("inspector")); -// map.put("mg_weight",whereJson.getString("mg_weight")); -// workBook.fill(map, sheet); -// workBook.finish(); -// Book book=new Book(); -// Workbook loDoc = new Workbook(); -// loDoc.loadFromFile(pathName); -// Worksheet worksheet = loDoc.getWorksheets().get(0); -// PageSetup pageSetup = worksheet.getPageSetup(); -// String printArea="A2:B8"; -// pageSetup.setPrintArea(printArea); -// pageSetup.setLeftMargin(0); -// pageSetup.setRightMargin(0); -// pageSetup.setTopMargin(0); -// pageSetup.setBottomMargin(0); -// CellRange cellRanges = worksheet.getCellRange(printArea); -// int height=0; -// for (CellRange row : cellRanges.getRows()) { -// height+= worksheet.getRowHeightPixels(row.getRow()); -// } -// -// int width=0; -// for (CellRange column : cellRanges.getColumns()) { -// width+=worksheet.getColumnWidthPixels(column.getColumn()); -// } -// -// PrinterJob loPrinterJob = PrinterJob.getPrinterJob(); -// PageFormat loPageFormat = loPrinterJob.defaultPage(); -// Paper loPaper = loPageFormat.getPaper(); -// -// loPaper.setImageableArea(0, 0, loPageFormat.getWidth(), loPageFormat.getHeight()); -// -// String page_height = whereJson.getString("page_height"); -// String page_length = whereJson.getString("page_length"); -// -// loPaper.setSize(Double.parseDouble(page_length),Double.parseDouble(page_height)); -//// loPaper.setSize(width/96.0*72,height/96.0*72); -// loPageFormat.setPaper(loPaper); -// loPrinterJob.setCopies(1); -// loPrinterJob.setPrintable(loDoc, loPageFormat); -// book.append(loDoc,loPageFormat); -// loPrinterJob.setPageable(book); -// try { -// // 执行打印 -// loPrinterJob.print(); -// } catch (PrinterException e) { -// e.printStackTrace(); -// return false; -// } - String url = acsConfigService.findConfigFromCache().get(AcsConfig.PRINTURL); String printName = acsConfigService.findConfigFromCache().get(AcsConfig.PRINTNAME); String labeling_template = whereJson.get("labeling_template").toString(); @@ -1128,4 +1031,4 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A return order; } -} \ No newline at end of file +} diff --git a/nladmin-system/src/main/java/org/nl/acs/stage/service/impl/StageActorServiceImpl.java b/nladmin-system/src/main/java/org/nl/acs/stage/service/impl/StageActorServiceImpl.java index 73be087..901caa1 100644 --- a/nladmin-system/src/main/java/org/nl/acs/stage/service/impl/StageActorServiceImpl.java +++ b/nladmin-system/src/main/java/org/nl/acs/stage/service/impl/StageActorServiceImpl.java @@ -12,7 +12,6 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device_driver.electric_fence.ElectricFenceDeviceDriver; import org.nl.acs.device_driver.hailiang.hailiang_coating.HaiLiangCoatingDeviceDriver; import org.nl.acs.device_driver.hailiang.hailiang_feeding.HaiLiangFeedingDeviceDriver; import org.nl.acs.device_driver.hailiang.hailiang_feeding_trunk.HaiLiangFeedingTrunkDeviceDriver; @@ -20,24 +19,6 @@ import org.nl.acs.device_driver.hailiang.hailiang_labeling.HaiLiangLabelingDevic import org.nl.acs.device_driver.hailiang.hailiang_lettering.HaiLiangLetteringDeviceDriver; import org.nl.acs.device_driver.hailiang.hailiang_risking.HaiLiangRiskingDeviceDriver; import org.nl.acs.device_driver.hailiang.hailiang_strapping.HaiLiangStrappingDeviceDriver; -import org.nl.acs.device_driver.machines_site.MachinesSiteDeviceDriver; -import org.nl.acs.device_driver.non_line_inspect_site.NonLineInspectSiteDeviceDriver; -import org.nl.acs.device_driver.non_line_manipulator_inspect_site.NonLineManipulatorInspectSiteDeviceDriver; -import org.nl.acs.device_driver.special_ordinary_site.SpecialOrdinarySiteDeviceDriver; -import org.nl.acs.device_driver.standard_autodoor.StandardAutodoorDeviceDriver; -import org.nl.acs.device_driver.standard_conveyor_control.StandardCoveyorControlDeviceDriver; -import org.nl.acs.device_driver.standard_conveyor_control_with_plcscanner.StandardCoveyorControlWithPlcScannerDeviceDriver; -import org.nl.acs.device_driver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver; -import org.nl.acs.device_driver.standard_conveyor_monitor.StandardCoveyorMonitorDeviceDriver; -import org.nl.acs.device_driver.standard_emptypallet_site.StandardEmptyPalletSiteDeviceDriver; -import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; -import org.nl.acs.device_driver.standard_manipulator_inspect_site.StandardManipulatorInspectSiteDeviceDriver; -import org.nl.acs.device_driver.standard_manipulator_stacking_site.StandardManipulatorStackingSiteDeviceDriver; -import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; -import org.nl.acs.device_driver.standard_photoelectric_inspect_site.StandardPhotoelectricInspectSiteDeviceDriver; -import org.nl.acs.device_driver.standard_rgv.StandardRGVDeviceDriver; -import org.nl.acs.device_driver.standard_scanner.StandardScannerDeviceDriver; -import org.nl.acs.device_driver.weighing_site.WeighingSiteDeviceDriver; import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppServiceImpl; @@ -119,7 +100,7 @@ public class StageActorServiceImpl implements StageActorService { dto.setCreate_time(now); WQLObject wo = WQLObject.getWQLObject("acs_stage_actor"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); + JSONObject json = (JSONObject) JSONObject.toJSON(dto); wo.insert(json); } @@ -136,7 +117,7 @@ public class StageActorServiceImpl implements StageActorService { dto.setUpdate_by(currentUsername); WQLObject wo = WQLObject.getWQLObject("acs_stage_actor"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); + JSONObject json = (JSONObject) JSONObject.toJSON(dto); wo.update(json); } @@ -228,7 +209,7 @@ public class StageActorServiceImpl implements StageActorService { JSONObject stageObj; //先从缓存查找 - stageObj = JSON.parseObject(redisUtils.get("stage:mst:" + stage_code).toString()); + stageObj = JSON.parseObject(redisUtils.get("stage:mst:" + stage_code).toString()); //缓存没找到去数据库查找 if (MapUtil.isEmpty(stageObj)) { stageObj = stageTab.query("is_delete ='0' and stage_code = '" + stage_code + "'").uniqueResult(0); @@ -292,44 +273,6 @@ public class StageActorServiceImpl implements StageActorService { if (ObjectUtil.isNull(device)) { continue; } - //无光电普通站点 - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - //无光电特殊站点 - SpecialOrdinarySiteDeviceDriver specialOrdinarySiteDeviceDriver; - //空盘站点 - StandardEmptyPalletSiteDeviceDriver standardEmptyPalletSiteDeviceDriver; - //检测站点 - StandardInspectSiteDeviceDriver standardInspectSiteDevicedriver; - //检测站点-无PLC - NonLineInspectSiteDeviceDriver nonLineInspectSiteDeviceDriver; - //区域管制站点(机械手) - StandardManipulatorInspectSiteDeviceDriver standardManipulatorInspectSiteDeviceDriver; - //区域管制站点-无PLC - NonLineManipulatorInspectSiteDeviceDriver nonLineManipulatorInspectSiteDeviceDriver; - //控制点 - StandardCoveyorControlDeviceDriver standardCoveyorControlDeviceDriver; - //控制点-带扫码 - StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver; - //控制点-PLC扫码 - StandardCoveyorControlWithPlcScannerDeviceDriver standardCoveyorControlWithPlcScannerDeviceDriver; - //监控点 - StandardCoveyorMonitorDeviceDriver standardCoveyorMonitorDeviceDriver; - //扫码器 - StandardScannerDeviceDriver standardScannerDeviceDriver; - //机台设备 - MachinesSiteDeviceDriver machinesSiteDeviceDriver; - //自动门 - StandardAutodoorDeviceDriver standardAutodoorDeviceDriver; - //称重设备 - WeighingSiteDeviceDriver weighingSiteDeviceDriver; - //机械手码垛驱动(区分托盘类型) - StandardManipulatorStackingSiteDeviceDriver standardManipulatorStackingSiteDeviceDriver; - //光电检测站点(优先入库) - StandardPhotoelectricInspectSiteDeviceDriver standardPhotoelectricInspectSiteDeviceDriver; - //中刚洛耐RGV - StandardRGVDeviceDriver standardRGVDeviceDriver; - //电子围栏 - ElectricFenceDeviceDriver electricFenceDeviceDriver; //海亮包装项目-上料总线体 HaiLiangFeedingTrunkDeviceDriver haiLiangFeedingTrunkDeviceDriver; //海亮包装项目-上料线体 @@ -344,599 +287,7 @@ public class StageActorServiceImpl implements StageActorService { HaiLiangCoatingDeviceDriver haiLiangCoatingDeviceDriver; //海亮包装项目-贴标线体 HaiLiangLabelingDeviceDriver haiLiangLabelingDeviceDriver; - - - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - standardCoveyorControlDeviceDriver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlDeviceDriver.getMode() == 0) { - mode = "未联机"; - } else if (standardCoveyorControlDeviceDriver.getMode() == 1) { - mode = "单机"; - } else if (standardCoveyorControlDeviceDriver.getMode() == 2) { - mode = "联机"; - } else if (standardCoveyorControlDeviceDriver.getMode() == 3) { - mode = "运行中"; - } else if (standardCoveyorControlDeviceDriver.getMode() == 4) { - mode = "申请叫料"; - } else if (standardCoveyorControlDeviceDriver.getMode() == 5) { - mode = "申请空盘"; - } else if (standardCoveyorControlDeviceDriver.getMode() == 6) { - mode = "空盘入库"; - } - if (standardCoveyorControlDeviceDriver.getMove() == 0) { - move = "无货"; - } else if (standardCoveyorControlDeviceDriver.getMove() == 1) { - move = "有货"; - } else if (standardCoveyorControlDeviceDriver.getMove() == 2) { - move = "有托盘有货"; - } - obj.put("device_name", standardCoveyorControlDeviceDriver.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("hasGoods", standardCoveyorControlDeviceDriver.getHasGoods()); - jo.put("isOnline", standardCoveyorControlDeviceDriver.getIsonline()); - jo.put("error", standardCoveyorControlDeviceDriver.getError()); - jo.put("isError", standardCoveyorControlDeviceDriver.getIserror()); - jo.put("requestSucess", standardCoveyorControlDeviceDriver.getRequireSucess()); - jo.put("applySucess", standardCoveyorControlDeviceDriver.getApplySucess()); - jo.put("message", standardCoveyorControlDeviceDriver.getMessage()); - } else if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) { - standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver(); - if (standardAutodoorDeviceDriver.getMode() == 0) { - mode = "未联机"; - } else if (standardAutodoorDeviceDriver.getMode() == 1) { - mode = "单机"; - } else if (standardAutodoorDeviceDriver.getMode() == 2) { - mode = "联机"; - } - if (standardAutodoorDeviceDriver.getAction() == 0) { - action = "未知"; - } else if (standardAutodoorDeviceDriver.getAction() == 1) { - action = "开到位"; - } else if (standardAutodoorDeviceDriver.getAction() == 2) { - action = "关到位"; - } - obj.put("device_name", standardAutodoorDeviceDriver.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("action", action); - jo.put("isOnline", true); - jo.put("error", standardAutodoorDeviceDriver.getError()); - jo.put("isError", standardAutodoorDeviceDriver.getIserror()); - } else if (device.getDeviceDriver() instanceof StandardCoveyorMonitorDeviceDriver) { - standardCoveyorMonitorDeviceDriver = (StandardCoveyorMonitorDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorMonitorDeviceDriver.getMode() == 0) { - mode = "未联机"; - } else if (standardCoveyorMonitorDeviceDriver.getMode() == 1) { - mode = "单机"; - } else if (standardCoveyorMonitorDeviceDriver.getMode() == 2) { - mode = "联机"; - } else if (standardCoveyorMonitorDeviceDriver.getMode() == 3) { - mode = "运行中"; - } else if (standardCoveyorMonitorDeviceDriver.getMode() == 4) { - mode = "申请叫料"; - } else if (standardCoveyorMonitorDeviceDriver.getMode() == 5) { - mode = "申请空盘"; - } else if (standardCoveyorMonitorDeviceDriver.getMode() == 6) { - mode = "空盘入库"; - } - if (standardCoveyorMonitorDeviceDriver.getMove() == 0) { - move = "无货"; - } else if (standardCoveyorMonitorDeviceDriver.getMove() == 1) { - move = "有货"; - } else if (standardCoveyorMonitorDeviceDriver.getMove() == 2) { - move = "有托盘有货"; - } - obj.put("device_name", standardCoveyorMonitorDeviceDriver.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("hasGoods", standardCoveyorMonitorDeviceDriver.getHasGoods()); - jo.put("isOnline", standardCoveyorMonitorDeviceDriver.getIsonline()); - jo.put("error", standardCoveyorMonitorDeviceDriver.getError()); - jo.put("isError", standardCoveyorMonitorDeviceDriver.getIserror()); - jo.put("message", standardCoveyorMonitorDeviceDriver.getMessage()); - } else if (device.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) { - standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlWithScannerDeviceDriver.getMode() == 0) { - mode = "未联机"; - } else if (standardCoveyorControlWithScannerDeviceDriver.getMode() == 1) { - mode = "单机"; - } else if (standardCoveyorControlWithScannerDeviceDriver.getMode() == 2) { - mode = "联机"; - } else if (standardCoveyorControlWithScannerDeviceDriver.getMode() == 3) { - mode = "运行中"; - } else if (standardCoveyorControlWithScannerDeviceDriver.getMode() == 4) { - mode = "申请叫料"; - } else if (standardCoveyorControlWithScannerDeviceDriver.getMode() == 5) { - mode = "申请空盘"; - } else if (standardCoveyorControlWithScannerDeviceDriver.getMode() == 6) { - mode = "空盘入库"; - } - if (standardCoveyorControlWithScannerDeviceDriver.getMove() == 0) { - move = "无货"; - } else if (standardCoveyorControlWithScannerDeviceDriver.getMove() == 1) { - move = "有货"; - } else if (standardCoveyorControlWithScannerDeviceDriver.getMove() == 2) { - move = "有托盘有货"; - } - obj.put("device_name", standardCoveyorControlWithScannerDeviceDriver.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("hasGoods", standardCoveyorControlWithScannerDeviceDriver.getHasGoods()); - jo.put("isOnline", standardCoveyorControlWithScannerDeviceDriver.getIsonline()); - jo.put("error", standardCoveyorControlWithScannerDeviceDriver.getError()); - jo.put("isError", standardCoveyorControlWithScannerDeviceDriver.getIserror()); - jo.put("height", standardCoveyorControlWithScannerDeviceDriver.getHeight()); - jo.put("operation_type", standardCoveyorControlWithScannerDeviceDriver.getOperation_type()); - jo.put("direction", standardCoveyorControlWithScannerDeviceDriver.getDirection()); - jo.put("action", standardCoveyorControlWithScannerDeviceDriver.getAction()); - jo.put("ioaction", standardCoveyorControlWithScannerDeviceDriver.getIoaction()); - jo.put("container", StrUtil.isEmpty(standardCoveyorControlWithScannerDeviceDriver.barcode()) ? "" : standardCoveyorControlWithScannerDeviceDriver.barcode()); - jo.put("message", StrUtil.equals(standardCoveyorControlWithScannerDeviceDriver.getMessage(),"null") ? "":standardCoveyorControlWithScannerDeviceDriver.getMessage()); - jo.put("requestSucess", standardCoveyorControlWithScannerDeviceDriver.getRequireSucess().toString()); - jo.put("applySucess", standardCoveyorControlWithScannerDeviceDriver.getApplySucess().toString()); - jo.put("instruction_message", standardCoveyorControlWithScannerDeviceDriver.getInst_message()); - } else if (device.getDeviceDriver() instanceof StandardCoveyorControlWithPlcScannerDeviceDriver) { - standardCoveyorControlWithPlcScannerDeviceDriver = (StandardCoveyorControlWithPlcScannerDeviceDriver) device.getDeviceDriver(); - if (standardCoveyorControlWithPlcScannerDeviceDriver.getMode() == 0) { - mode = "未联机"; - } else if (standardCoveyorControlWithPlcScannerDeviceDriver.getMode() == 1) { - mode = "单机"; - } else if (standardCoveyorControlWithPlcScannerDeviceDriver.getMode() == 2) { - mode = "联机"; - } else if (standardCoveyorControlWithPlcScannerDeviceDriver.getMode() == 3) { - mode = "运行中"; - } else if (standardCoveyorControlWithPlcScannerDeviceDriver.getMode() == 4) { - mode = "申请叫料"; - } else if (standardCoveyorControlWithPlcScannerDeviceDriver.getMode() == 5) { - mode = "申请空盘"; - } else if (standardCoveyorControlWithPlcScannerDeviceDriver.getMode() == 6) { - mode = "空盘入库"; - } - if (standardCoveyorControlWithPlcScannerDeviceDriver.getMove() == 0) { - move = "无货"; - } else if (standardCoveyorControlWithPlcScannerDeviceDriver.getMove() == 1) { - move = "有货"; - } else if (standardCoveyorControlWithPlcScannerDeviceDriver.getMove() == 2) { - move = "有托盘有货"; - } - obj.put("device_name", standardCoveyorControlWithPlcScannerDeviceDriver.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("hasGoods", standardCoveyorControlWithPlcScannerDeviceDriver.getHasGoods()); - jo.put("isOnline", standardCoveyorControlWithPlcScannerDeviceDriver.getIsonline()); - jo.put("error", standardCoveyorControlWithPlcScannerDeviceDriver.getError()); - jo.put("isError", standardCoveyorControlWithPlcScannerDeviceDriver.getIserror()); - jo.put("height", standardCoveyorControlWithPlcScannerDeviceDriver.getHeight()); - jo.put("operation_type", standardCoveyorControlWithPlcScannerDeviceDriver.getOperation_type()); - jo.put("direction", standardCoveyorControlWithPlcScannerDeviceDriver.getDirection()); - jo.put("action", standardCoveyorControlWithPlcScannerDeviceDriver.getAction()); - jo.put("ioaction", standardCoveyorControlWithPlcScannerDeviceDriver.getIoaction()); - jo.put("container", StrUtil.isEmpty(standardCoveyorControlWithPlcScannerDeviceDriver.getBarcode()) ? "" : standardCoveyorControlWithPlcScannerDeviceDriver.getBarcode()); - jo.put("message", StrUtil.isEmpty(standardCoveyorControlWithPlcScannerDeviceDriver.getMessage()) ? "":standardCoveyorControlWithPlcScannerDeviceDriver.getMessage()); - jo.put("requestSucess", standardCoveyorControlWithPlcScannerDeviceDriver.getRequireSucess().toString()); - jo.put("applySucess", standardCoveyorControlWithPlcScannerDeviceDriver.getApplySucess().toString()); - jo.put("instruction_message", standardCoveyorControlWithPlcScannerDeviceDriver.getInst_message()); - } - //检测站点 - else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDevicedriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDevicedriver.getMode() == 0) { - mode = "未联机"; - } else if (standardInspectSiteDevicedriver.getMode() == 1) { - mode = "单机"; - } else if (standardInspectSiteDevicedriver.getMode() == 2) { - mode = "联机"; - } - if (standardInspectSiteDevicedriver.getMove() == 0) { - move = "无货"; - } else if (standardInspectSiteDevicedriver.getMove() == 1) { - move = "有货"; - } else if (standardInspectSiteDevicedriver.getMove() == 2) { - move = "有托盘有货"; - } - obj.put("device_name", standardInspectSiteDevicedriver.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("hasGoods", standardInspectSiteDevicedriver.getHasGoods()); - jo.put("isOnline", standardInspectSiteDevicedriver.getIsonline()); - jo.put("error", standardInspectSiteDevicedriver.getError()); - jo.put("isError", standardInspectSiteDevicedriver.getIserror()); - jo.put("container", standardInspectSiteDevicedriver.getContainer()); - jo.put("message", standardInspectSiteDevicedriver.getMessage()); - } - //检测站点-无PLC - else if (device.getDeviceDriver() instanceof NonLineInspectSiteDeviceDriver) { - nonLineInspectSiteDeviceDriver = (NonLineInspectSiteDeviceDriver) device.getDeviceDriver(); - if (nonLineInspectSiteDeviceDriver.getMode() == 0) { - mode = "未知"; - } else if (nonLineInspectSiteDeviceDriver.getMode() == 1) { - mode = "单机"; - } else if (nonLineInspectSiteDeviceDriver.getMode() == 2) { - mode = "联机"; - } - if (nonLineInspectSiteDeviceDriver.getMove() == 0) { - move = "无货"; - } else if (nonLineInspectSiteDeviceDriver.getMove() == 1) { - move = "有货"; - } else if (nonLineInspectSiteDeviceDriver.getMove() == 2) { - move = "有托盘有货"; - } - obj.put("device_name", nonLineInspectSiteDeviceDriver.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("isOnline", nonLineInspectSiteDeviceDriver.getIs_online()); - jo.put("hasGoods", nonLineInspectSiteDeviceDriver.getHasGoods()); - jo.put("error", nonLineInspectSiteDeviceDriver.getError()); - jo.put("isError", nonLineInspectSiteDeviceDriver.getIserror()); - jo.put("container", nonLineInspectSiteDeviceDriver.getContainer()); - jo.put("message", nonLineInspectSiteDeviceDriver.getMessage()); - } - //区域管制站点(机械手) - else if (device.getDeviceDriver() instanceof StandardManipulatorInspectSiteDeviceDriver) { - standardManipulatorInspectSiteDeviceDriver = (StandardManipulatorInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardManipulatorInspectSiteDeviceDriver.getMode() == 0) { - mode = "未联机"; - } else if (standardManipulatorInspectSiteDeviceDriver.getMode() == 1) { - mode = "单机"; - } else if (standardManipulatorInspectSiteDeviceDriver.getMode() == 2) { - mode = "联机"; - } else if (standardManipulatorInspectSiteDeviceDriver.getMode() == 3) { - mode = "呼叫空盘"; - } else if (standardManipulatorInspectSiteDeviceDriver.getMode() == 4) { - mode = "申请任务"; - } - if (standardManipulatorInspectSiteDeviceDriver.getMove() == 0) { - move = "无货"; - } else if (standardManipulatorInspectSiteDeviceDriver.getMove() == 1) { - move = "有货"; - } else if (standardManipulatorInspectSiteDeviceDriver.getMove() == 2) { - move = "有托盘有货"; - } - if (standardManipulatorInspectSiteDeviceDriver.getActoin() == 0) { - action = "禁止取放"; - } else if (standardManipulatorInspectSiteDeviceDriver.getActoin() == 1) { - action = "允许取货"; - } else if (standardManipulatorInspectSiteDeviceDriver.getActoin() == 2) { - action = "允许放货"; - } else if (standardManipulatorInspectSiteDeviceDriver.getActoin() == 3) { - action = "允许取放"; - } - if (standardManipulatorInspectSiteDeviceDriver.getIo_action() == 0) { - io_action = "禁止进出"; - } else if (standardManipulatorInspectSiteDeviceDriver.getIo_action() == 1) { - io_action = "允许进入"; - } else if (standardManipulatorInspectSiteDeviceDriver.getIo_action() == 2) { - io_action = "允许离开"; - } else if (standardManipulatorInspectSiteDeviceDriver.getIo_action() == 3) { - io_action = "允许进出"; - } - obj.put("device_name", standardManipulatorInspectSiteDeviceDriver.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("action", action); - jo.put("io_action", io_action); - jo.put("hasGoods", standardManipulatorInspectSiteDeviceDriver.getHasGoods()); - jo.put("isOnline", standardManipulatorInspectSiteDeviceDriver.getIsonline()); - jo.put("error", standardManipulatorInspectSiteDeviceDriver.getError()); - jo.put("isError", standardManipulatorInspectSiteDeviceDriver.getIserror()); - jo.put("container", standardManipulatorInspectSiteDeviceDriver.getContainer()); - jo.put("message", standardManipulatorInspectSiteDeviceDriver.getMessage()); - } - //区域管制站点-无PLC(机械手) - else if (device.getDeviceDriver() instanceof NonLineManipulatorInspectSiteDeviceDriver) { - nonLineManipulatorInspectSiteDeviceDriver = (NonLineManipulatorInspectSiteDeviceDriver) device.getDeviceDriver(); - if (nonLineManipulatorInspectSiteDeviceDriver.getMode() == 0) { - mode = "未联机"; - } else if (nonLineManipulatorInspectSiteDeviceDriver.getMode() == 1) { - mode = "单机"; - } else if (nonLineManipulatorInspectSiteDeviceDriver.getMode() == 2) { - mode = "联机"; - } - if (nonLineManipulatorInspectSiteDeviceDriver.getMove() == 0) { - move = "无货"; - } else if (nonLineManipulatorInspectSiteDeviceDriver.getMove() == 1) { - move = "有货"; - } else if (nonLineManipulatorInspectSiteDeviceDriver.getMove() == 2) { - move = "有托盘有货"; - } - if (nonLineManipulatorInspectSiteDeviceDriver.getAction() == 0) { - action = "禁止取放"; - } else if (nonLineManipulatorInspectSiteDeviceDriver.getAction() == 1) { - action = "允许取货"; - } else if (nonLineManipulatorInspectSiteDeviceDriver.getAction() == 2) { - action = "允许放货"; - } else if (nonLineManipulatorInspectSiteDeviceDriver.getAction() == 3) { - action = "允许取放"; - } - if (nonLineManipulatorInspectSiteDeviceDriver.getIoaction() == 0) { - io_action = "禁止进出"; - } else if (nonLineManipulatorInspectSiteDeviceDriver.getIoaction() == 1) { - io_action = "允许进入"; - } else if (nonLineManipulatorInspectSiteDeviceDriver.getIoaction() == 2) { - io_action = "允许离开"; - } else if (nonLineManipulatorInspectSiteDeviceDriver.getIoaction() == 3) { - io_action = "允许进出"; - } - obj.put("device_name", nonLineManipulatorInspectSiteDeviceDriver.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("action", action); - jo.put("io_action", io_action); - jo.put("hasGoods", nonLineManipulatorInspectSiteDeviceDriver.getHasGoods()); - jo.put("isOnline", nonLineManipulatorInspectSiteDeviceDriver.getIs_online()); - jo.put("error", nonLineManipulatorInspectSiteDeviceDriver.getError()); - jo.put("isError", nonLineManipulatorInspectSiteDeviceDriver.getIserror()); - jo.put("container", nonLineManipulatorInspectSiteDeviceDriver.getContainer()); - jo.put("message", nonLineManipulatorInspectSiteDeviceDriver.getMessage()); - } - //空盘站点 - else if (device.getDeviceDriver() instanceof StandardEmptyPalletSiteDeviceDriver) { - standardEmptyPalletSiteDeviceDriver = (StandardEmptyPalletSiteDeviceDriver) device.getDeviceDriver(); - if (standardEmptyPalletSiteDeviceDriver.getMode() == 0) { - mode = "未联机"; - } else if (standardEmptyPalletSiteDeviceDriver.getMode() == 1) { - mode = "单机"; - } else if (standardEmptyPalletSiteDeviceDriver.getMode() == 2) { - mode = "联机"; - } - if (standardEmptyPalletSiteDeviceDriver.getMove() == 0) { - move = "无货"; - } else if (standardEmptyPalletSiteDeviceDriver.getMove() == 1) { - move = "有货"; - } else if (standardEmptyPalletSiteDeviceDriver.getMove() == 2) { - move = "有托盘有货"; - } - obj.put("device_name", standardEmptyPalletSiteDeviceDriver.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("number", standardEmptyPalletSiteDeviceDriver.getNumber()); - jo.put("hasGoods", standardEmptyPalletSiteDeviceDriver.getHasGoods()); - jo.put("isOnline", standardEmptyPalletSiteDeviceDriver.getIsonline()); - jo.put("isError", standardEmptyPalletSiteDeviceDriver.getIserror()); - jo.put("error", standardEmptyPalletSiteDeviceDriver.getError()); - jo.put("container", standardEmptyPalletSiteDeviceDriver.getContainer()); - jo.put("message", standardEmptyPalletSiteDeviceDriver.getMessage()); - } - //普通站点 - else if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (standardOrdinarySiteDeviceDriver.getHasGoods() == 0) { - move = "无货"; - } else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 1) { - move = "有货"; - } else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 2) { - move = "有托盘有货"; - } - obj.put("device_name", standardOrdinarySiteDeviceDriver.getDevice().getDevice_name()); - jo.put("move", move); - jo.put("container", standardOrdinarySiteDeviceDriver.getContainer()); - jo.put("hasGoods", standardOrdinarySiteDeviceDriver.getHasGoods()); - jo.put("isOnline", true); - //点击弹出 - jo.put("is_click", true); - jo.put("device_type", device.getDevice_type()); - jo.put("error", standardOrdinarySiteDeviceDriver.getError()); - jo.put("isError", standardOrdinarySiteDeviceDriver.getIserror()); - jo.put("container", standardOrdinarySiteDeviceDriver.getContainer()); - jo.put("message", standardOrdinarySiteDeviceDriver.getMessage()); - jo.put("material", standardOrdinarySiteDeviceDriver.getMaterial()); - jo.put("batch", standardOrdinarySiteDeviceDriver.getBatch()); - - } - //无光电特殊站点 - else if (device.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) { - specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (specialOrdinarySiteDeviceDriver.getHasGoods() == 0) { - move = "无货"; - } else if (specialOrdinarySiteDeviceDriver.getHasGoods() == 1) { - move = "有货"; - } else if (specialOrdinarySiteDeviceDriver.getHasGoods() == 2) { - move = "有托盘有货"; - } - obj.put("device_name", specialOrdinarySiteDeviceDriver.getDevice().getDevice_name()); - jo.put("move", move); - jo.put("container", specialOrdinarySiteDeviceDriver.getContainer()); - jo.put("hasGoods", specialOrdinarySiteDeviceDriver.getHasGoods()); - jo.put("isOnline", true); - //点击弹出 - jo.put("is_click", true); - jo.put("device_type", device.getDevice_type()); - jo.put("error", specialOrdinarySiteDeviceDriver.getError()); - jo.put("isError", specialOrdinarySiteDeviceDriver.getIserror()); - jo.put("container", specialOrdinarySiteDeviceDriver.getContainer()); - jo.put("message", specialOrdinarySiteDeviceDriver.getMessage()); - jo.put("material", specialOrdinarySiteDeviceDriver.getMaterial()); - jo.put("batch", specialOrdinarySiteDeviceDriver.getBatch()); - if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDevicedriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardInspectSiteDevicedriver.getMode() == 0) { - mode = "未联机"; - } else if (standardInspectSiteDevicedriver.getMode() == 1) { - mode = "单机"; - } else if (standardInspectSiteDevicedriver.getMode() == 2) { - mode = "联机"; - } - if (standardInspectSiteDevicedriver.getMove() == 0) { - move = "无货"; - } else if (standardInspectSiteDevicedriver.getMove() == 1) { - move = "有货"; - } else if (standardInspectSiteDevicedriver.getMove() == 2) { - move = "有托盘有货"; - } - obj.put("device_name", standardInspectSiteDevicedriver.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("hasGoods", standardInspectSiteDevicedriver.getHasGoods()); - jo.put("isOnline", standardInspectSiteDevicedriver.getIsonline()); - jo.put("error", standardInspectSiteDevicedriver.getError()); - jo.put("isError", standardInspectSiteDevicedriver.getIserror()); - jo.put("container", standardInspectSiteDevicedriver.getContainer()); - jo.put("message", standardInspectSiteDevicedriver.getMessage()); - } - } else if (device.getDeviceDriver() instanceof StandardScannerDeviceDriver) { - standardScannerDeviceDriver = (StandardScannerDeviceDriver) device.getDeviceDriver(); - obj.put("device_name", standardScannerDeviceDriver.getDevice().getDevice_name()); - jo.put("isOnline", true); - jo.put("device_type", device.getDevice_type()); - //点击弹出 - jo.put("is_click", true); - jo.put("ip", standardScannerDeviceDriver.getIp()); - jo.put("container", StrUtil.isEmpty(standardScannerDeviceDriver.readBarcode()) ? "" : standardScannerDeviceDriver.readBarcode()); - } else if (device.getDeviceDriver() instanceof WeighingSiteDeviceDriver) { - weighingSiteDeviceDriver = (WeighingSiteDeviceDriver) device.getDeviceDriver(); - obj.put("device_name", weighingSiteDeviceDriver.getDevice().getDevice_name()); - jo.put("isOnline", true); - jo.put("instruction_message", weighingSiteDeviceDriver.getInst_message()); - } else if (device.getDeviceDriver() instanceof MachinesSiteDeviceDriver) { - machinesSiteDeviceDriver = (MachinesSiteDeviceDriver) device.getDeviceDriver(); - if (machinesSiteDeviceDriver.getMode() == 0) { - mode = "未联机"; - } else if (machinesSiteDeviceDriver.getMode() == 1) { - mode = "单机"; - } else if (machinesSiteDeviceDriver.getMode() == 2) { - mode = "联机"; - } - if (machinesSiteDeviceDriver.getIoaction() == 0) { - io_action = "禁止进出"; - } else if (machinesSiteDeviceDriver.getIoaction() == 1) { - io_action = "允许进入"; - } else if (machinesSiteDeviceDriver.getIoaction() == 2) { - io_action = "允许离开"; - } else if (machinesSiteDeviceDriver.getIoaction() == 3) { - io_action = "允许进出"; - } - obj.put("device_name", machinesSiteDeviceDriver.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("io_action", io_action); - jo.put("isOnline", machinesSiteDeviceDriver.getIsonline()); - } - //机械手码垛驱动(区分托盘类型) - else if (device.getDeviceDriver() instanceof StandardManipulatorStackingSiteDeviceDriver) { - standardManipulatorStackingSiteDeviceDriver = (StandardManipulatorStackingSiteDeviceDriver) device.getDeviceDriver(); - if (standardManipulatorStackingSiteDeviceDriver.getMode() == 0) { - mode = "未联机"; - } else if (standardManipulatorStackingSiteDeviceDriver.getMode() == 1) { - mode = "单机"; - } else if (standardManipulatorStackingSiteDeviceDriver.getMode() == 2) { - mode = "联机"; - } else if (standardManipulatorStackingSiteDeviceDriver.getMode() == 3) { - mode = "运行中"; - } else if (standardManipulatorStackingSiteDeviceDriver.getMode() == 4) { - mode = "申请任务"; - } else if (standardManipulatorStackingSiteDeviceDriver.getMode() == 5) { - mode = "申请空盘"; - } else if (standardManipulatorStackingSiteDeviceDriver.getMode() == 6) { - mode = "申请入库"; - } else if (standardManipulatorStackingSiteDeviceDriver.getMode() == 7) { - mode = "换盘去应急位"; - } else if (standardManipulatorStackingSiteDeviceDriver.getMode() == 8) { - mode = "换盘去托盘库"; - } else if (standardManipulatorStackingSiteDeviceDriver.getMode() == 9) { - mode = "入托盘库"; - } - if (standardManipulatorStackingSiteDeviceDriver.getMove() == 0) { - move = "无货"; - } else if (standardManipulatorStackingSiteDeviceDriver.getMove() == 1) { - move = "有货"; - } else if (standardManipulatorStackingSiteDeviceDriver.getMove() == 2) { - move = "有托盘有货"; - } - if (standardManipulatorStackingSiteDeviceDriver.getAction() == 0) { - action = "禁止取放"; - } else if (standardManipulatorStackingSiteDeviceDriver.getAction() == 1) { - action = "允许取货"; - } else if (standardManipulatorStackingSiteDeviceDriver.getAction() == 2) { - action = "允许放货"; - } else if (standardManipulatorStackingSiteDeviceDriver.getAction() == 3) { - action = "允许取放"; - } - if (standardManipulatorStackingSiteDeviceDriver.getIo_action() == 0) { - io_action = "禁止进出"; - } else if (standardManipulatorStackingSiteDeviceDriver.getIo_action() == 1) { - io_action = "允许进入"; - } else if (standardManipulatorStackingSiteDeviceDriver.getIo_action() == 2) { - io_action = "允许离开"; - } else if (standardManipulatorStackingSiteDeviceDriver.getIo_action() == 3) { - io_action = "允许进出"; - } - obj.put("device_name", standardManipulatorStackingSiteDeviceDriver.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("action", action); - jo.put("io_action", io_action); - jo.put("hasGoods", standardManipulatorStackingSiteDeviceDriver.getHasGoods()); - jo.put("isOnline", standardManipulatorStackingSiteDeviceDriver.getIsonline()); - jo.put("error", standardManipulatorStackingSiteDeviceDriver.getError()); - jo.put("isError", standardManipulatorStackingSiteDeviceDriver.getIserror()); - jo.put("container", standardManipulatorStackingSiteDeviceDriver.getContainer()); - jo.put("message", standardManipulatorStackingSiteDeviceDriver.getMessage()); - } - //中钢洛耐RGV - else if (device.getDeviceDriver() instanceof StandardRGVDeviceDriver) { - standardRGVDeviceDriver = (StandardRGVDeviceDriver) device.getDeviceDriver(); - if (standardRGVDeviceDriver.getMode() == 0) { - mode = "未联机"; - } else if (standardRGVDeviceDriver.getMode() == 1) { - mode = "单机"; - } else if (standardRGVDeviceDriver.getMode() == 2) { - mode = "联机"; - } - if (standardRGVDeviceDriver.getMove() == 0) { - move = "无货"; - } else if (standardRGVDeviceDriver.getMove() == 1) { - move = "有货"; - } else if (standardRGVDeviceDriver.getMove() == 2) { - move = "有托盘有货"; - } - obj.put("devicede_name", standardRGVDeviceDriver.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("hasGoods", standardRGVDeviceDriver.getHasGoods()); - jo.put("isOnline", standardRGVDeviceDriver.getIsonline()); - jo.put("error", standardRGVDeviceDriver.getError()); - jo.put("isError", standardRGVDeviceDriver.getIserror()); - jo.put("container", standardRGVDeviceDriver.getContainer()); - jo.put("message", standardRGVDeviceDriver.getMessage()); - } - else if (device.getDeviceDriver() instanceof StandardPhotoelectricInspectSiteDeviceDriver) { - standardPhotoelectricInspectSiteDeviceDriver = (StandardPhotoelectricInspectSiteDeviceDriver) device.getDeviceDriver(); - if (standardPhotoelectricInspectSiteDeviceDriver.getMode() == 0) { - mode = "未联机"; - } else if (standardPhotoelectricInspectSiteDeviceDriver.getMode() == 1) { - mode = "单机"; - } else if (standardPhotoelectricInspectSiteDeviceDriver.getMode() == 2) { - mode = "联机"; - } else if (standardPhotoelectricInspectSiteDeviceDriver.getMode() == 4) { - mode = "待机入窑"; - } - if (standardPhotoelectricInspectSiteDeviceDriver.getMove() == 0) { - move = "无货"; - } else if (standardPhotoelectricInspectSiteDeviceDriver.getMove() == 1) { - move = "有货"; - } else if (standardPhotoelectricInspectSiteDeviceDriver.getMove() == 2) { - move = "有托盘有货"; - } - obj.put("device_name", standardPhotoelectricInspectSiteDeviceDriver.getDevice().getDevice_name()); - jo.put("mode", mode); - jo.put("move", move); - jo.put("hasGoods", standardPhotoelectricInspectSiteDeviceDriver.getHasGoods()); - jo.put("isOnline", standardPhotoelectricInspectSiteDeviceDriver.getIsonline()); - jo.put("error", standardPhotoelectricInspectSiteDeviceDriver.getError()); - jo.put("isError", standardPhotoelectricInspectSiteDeviceDriver.getIserror()); - jo.put("container", standardPhotoelectricInspectSiteDeviceDriver.getContainer()); - jo.put("message", standardPhotoelectricInspectSiteDeviceDriver.getMessage()); - } - else if (device.getDeviceDriver() instanceof ElectricFenceDeviceDriver) { - electricFenceDeviceDriver = (ElectricFenceDeviceDriver) device.getDeviceDriver(); - obj.put("device_name", electricFenceDeviceDriver.getDevice().getDevice_name()); - jo.put("isOnline", true); - //点击弹出 - jo.put("is_click", true); - jo.put("device_type", device.getDevice_type()); - jo.put("error", electricFenceDeviceDriver.getError()); - jo.put("isError", electricFenceDeviceDriver.getIserror()); - } - else if (device.getDeviceDriver() instanceof HaiLiangFeedingTrunkDeviceDriver) { + if (device.getDeviceDriver() instanceof HaiLiangFeedingTrunkDeviceDriver) { haiLiangFeedingTrunkDeviceDriver = (HaiLiangFeedingTrunkDeviceDriver) device.getDeviceDriver(); if (haiLiangFeedingTrunkDeviceDriver.getMode() == 0) { mode = "未联机"; diff --git a/nladmin-system/src/main/java/org/nl/acs/task/enums/TaskCreateEnum.java b/nladmin-system/src/main/java/org/nl/acs/task/enums/TaskCreateEnum.java deleted file mode 100644 index 78d03ea..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/task/enums/TaskCreateEnum.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.nl.acs.task.enums; - - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -/** - * 任务生成方式 - */ -public enum TaskCreateEnum { - AUTO(1, "AUTO", "自动创建"), - DEVICE_CREATE(2, "DEVICE_CREATE", "设备生成"), - HANDHELD_CREATE(3, "HANDHELD_CREATE", "手持生成"), - WMS_CREATE(3, "WMS_CREATE", "WMS生成"), - MES_CREATE(3, "MES_CREATE", "MES生成"); - - //索引 - private int index; - //编码 - private String code; - //名字 - private String name; - //描述 - private String desc; - - // 构造方法 - TaskCreateEnum(int index, String code, String name) { - this.index = index; - this.code = code; - this.name = name; - - } - - public static JSONArray getList() { - JSONArray arr = new JSONArray(); - JSONObject json = new JSONObject(); - for (TaskCreateEnum em : TaskCreateEnum.values()) { - json.put("code", em.getCode()); - json.put("name", em.getName()); - arr.add(json); - } - return arr; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDesc() { - return desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - - public static String getName(String code) { - for (TaskCreateEnum c : TaskCreateEnum.values()) { - if (c.code == code) { - return c.name; - } - } - return null; - } - - public int getIndex() { - return index; - } - - public void setIndex(int index) { - this.index = index; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/task/enums/TaskErrorEnum.java b/nladmin-system/src/main/java/org/nl/acs/task/enums/TaskErrorEnum.java deleted file mode 100644 index 4f605a4..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/task/enums/TaskErrorEnum.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.nl.acs.task.enums; - - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -/** - * 任务类型 - */ -public enum TaskErrorEnum { - NORMAL(1, "NORMAL", "正常"), - ERROR(2, "ERROR", "超时异常"); - - - //索引 - private int index; - //编码 - private String code; - //名字 - private String name; - //描述 - private String desc; - - // 构造方法 - TaskErrorEnum(int index, String code, String name) { - this.index = index; - this.code = code; - this.name = name; - - } - - public static JSONArray getList() { - JSONArray arr = new JSONArray(); - JSONObject json = new JSONObject(); - for (TaskErrorEnum em : TaskErrorEnum.values()) { - json.put("code", em.getCode()); - json.put("name", em.getName()); - arr.add(json); - } - return arr; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDesc() { - return desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - - public static String getName(String code) { - for (TaskErrorEnum c : TaskErrorEnum.values()) { - if (c.code == code) { - return c.name; - } - } - return null; - } - - public int getIndex() { - return index; - } - - public void setIndex(int index) { - this.index = index; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/task/enums/TaskFinishEnum.java b/nladmin-system/src/main/java/org/nl/acs/task/enums/TaskFinishEnum.java deleted file mode 100644 index d8174ff..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/task/enums/TaskFinishEnum.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.nl.acs.task.enums; - - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -/** - * 任务完成方式 - */ -public enum TaskFinishEnum { - AUTO_FINISH(1, "AUTO_FINISH", "自动完成"), - ACS_MANDATORY_FINISH(2, "ACS_MANDATORY_FINISH", "ACS强制完成"), - WMS_MANDATORY_FINISH(3, "WMS_MANDATORY_FINISH", "WMS强制完成"), - MES_MANDATORY_FINISH(4, "MES_MANDATORY_FINISH", "MES强制完成"), - AUTO_DELETE(5, "AUTO_DELETE", "自动删除"), - ACS_MANDATORY_DELETE(6, "ACS_MANDATORY_DELETE", "ACS强制删除"), - WMS_MANDATORY_DELETE(7, "WMS_MANDATORY_DELETE", "WMS强制删除"), - MES_MANDATORY_DELETE(8, "MES_MANDATORY_DELETE", "MES强制删除"), - DEVICE_DELETE(9, "DEVICE_DELETE", "设备删除"); - - //索引 - private int index; - //编码 - private String code; - //名字 - private String name; - //描述 - private String desc; - - // 构造方法 - TaskFinishEnum(int index, String code, String name) { - this.index = index; - this.code = code; - this.name = name; - - } - - public static JSONArray getList() { - JSONArray arr = new JSONArray(); - JSONObject json = new JSONObject(); - for (TaskFinishEnum em : TaskFinishEnum.values()) { - json.put("code", em.getCode()); - json.put("name", em.getName()); - arr.add(json); - } - return arr; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDesc() { - return desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - - public static String getName(String code) { - for (TaskFinishEnum c : TaskFinishEnum.values()) { - if (c.code == code) { - return c.name; - } - } - return null; - } - - public int getIndex() { - return index; - } - - public void setIndex(int index) { - this.index = index; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/task/enums/TaskStatusEnum.java b/nladmin-system/src/main/java/org/nl/acs/task/enums/TaskStatusEnum.java deleted file mode 100644 index 0a841b7..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/task/enums/TaskStatusEnum.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.nl.acs.task.enums; - - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -/** - * 任务状态 - */ -public enum TaskStatusEnum { - READY(1, "READY", "就绪"), - BUSY(2, "BUSY", "执行中"), - FINISHED(3, "FINISHED", "完成"); - - - //索引 - private int index; - //编码 - private String code; - //名字 - private String name; - //描述 - private String desc; - - // 构造方法 - TaskStatusEnum(int index, String code, String name) { - this.index = index; - this.code = code; - this.name = name; - - } - - public static JSONArray getList() { - JSONArray arr = new JSONArray(); - JSONObject json = new JSONObject(); - for (TaskStatusEnum em : TaskStatusEnum.values()) { - json.put("code", em.getCode()); - json.put("name", em.getName()); - arr.add(json); - } - return arr; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDesc() { - return desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - - public static String getName(String code) { - for (TaskStatusEnum c : TaskStatusEnum.values()) { - if (c.code == code) { - return c.name; - } - } - return null; - } - - public int getIndex() { - return index; - } - - public void setIndex(int index) { - this.index = index; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/task/enums/TaskTypeEnum.java b/nladmin-system/src/main/java/org/nl/acs/task/enums/TaskTypeEnum.java deleted file mode 100644 index 9340d49..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/task/enums/TaskTypeEnum.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.nl.acs.task.enums; - - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -/** - * 任务类型 - */ -public enum TaskTypeEnum { - FIXED_POINT(1, "FIXED_POINT", "定点任务"), - MOVE(2, "MOVE", "搬运"), - IN(3, "IN", "入库"), - OUT(4, "OUT", "整盘出库"), - PICK_OUT(5, "PICK_OUT", "拣选出库"), - PICK_IN(6, "PICK_IN", "拣选回库"), - APPLY_EMPTY(7, "APPLY_EMPTY", "申请空盘"); - - - //索引 - private int index; - //编码 - private String code; - //名字 - private String name; - //描述 - private String desc; - - // 构造方法 - TaskTypeEnum(int index, String code, String name) { - this.index = index; - this.code = code; - this.name = name; - - } - - public static JSONArray getList() { - JSONArray arr = new JSONArray(); - JSONObject json = new JSONObject(); - for (TaskTypeEnum em : TaskTypeEnum.values()) { - json.put("code", em.getCode()); - json.put("name", em.getName()); - arr.add(json); - } - return arr; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDesc() { - return desc; - } - - public void setDesc(String desc) { - this.desc = desc; - } - - public static String getName(String code) { - for (TaskTypeEnum c : TaskTypeEnum.values()) { - if (c.code == code) { - return c.name; - } - } - return null; - } - - public int getIndex() { - return index; - } - - public void setIndex(int index) { - this.index = index; - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/task/rest/TaskController.java b/nladmin-system/src/main/java/org/nl/acs/task/rest/TaskController.java deleted file mode 100644 index 7e9b0ca..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/task/rest/TaskController.java +++ /dev/null @@ -1,161 +0,0 @@ - -package org.nl.acs.task.rest; - - -import com.alibaba.fastjson.JSONObject; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.annotation.Log; -import org.springframework.data.domain.Pageable; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.Map; - -/** - * @author ldjun - * @date 2021-03-18 - **/ -@RestController -@RequiredArgsConstructor -@Api(tags = "任务管理") -@RequestMapping("/api/task") -@Slf4j -public class TaskController { - - private final TaskService taskService; - private final AcsToWmsService acsToWmsService; - - @GetMapping - @Log("查询任务") - @ApiOperation("查询任务") - //@PreAuthorize("@el.check('task:list')") - public ResponseEntity query(@RequestParam Map whereJson, Pageable page) { - return new ResponseEntity<>(taskService.queryAllByCache(whereJson, page), HttpStatus.OK); - } - - @GetMapping("/reload") - @Log("数据同步") - @ApiOperation("数据同步") - //@PreAuthorize("@el.check('task:list')") - public ResponseEntity reload() { - taskService.reload(); - return new ResponseEntity<>(HttpStatus.OK); - } - - @GetMapping("/getAll") - @Log("历史查询任务") - @ApiOperation("历史查询任务") - //@PreAuthorize("@el.check('task:list')") - public ResponseEntity get(@RequestParam Map whereJson, Pageable page) { - return new ResponseEntity<>(taskService.getAll(whereJson, page), HttpStatus.OK); - } - - @PostMapping - @Log("新增任务") - @ApiOperation("新增任务") - //@PreAuthorize("@el.check('task:add')") - public ResponseEntity create(@Validated @RequestBody TaskDto dto) throws Exception { - taskService.create(dto); - return new ResponseEntity<>(HttpStatus.CREATED); - } - - @PostMapping(value = "/adds") - @Log("常规任务保存") - @ApiOperation("常规任务保存") - //@PreAuthorize("@el.check('task:add')") - public ResponseEntity ordinaryTaskCreate(@RequestBody JSONObject json) throws Exception { - - taskService.ordinaryTaskCreate(json); - return new ResponseEntity<>(HttpStatus.CREATED); - } - - @PostMapping(value = "/addes") - @Log("特殊任务保存") - @ApiOperation("特殊任务保存") - public ResponseEntity specialTaskCreate(@RequestBody JSONObject json) throws Exception { - taskService.specialTaskCreate(json); - return new ResponseEntity<>(HttpStatus.CREATED); - } - - @PutMapping - @Log("修改任务") - @ApiOperation("修改任务") - //@PreAuthorize("@el.check('task:edit')") - public ResponseEntity update(@Validated @RequestBody TaskDto dto) { - taskService.update(dto); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - @Log("删除任务") - @ApiOperation("删除任务") - //@PreAuthorize("@el.check('task:del')") - @DeleteMapping - public ResponseEntity delete(@RequestBody String[] ids) throws Exception { - taskService.deleteAll(ids); - return new ResponseEntity<>(HttpStatus.OK); - } - - @Log("完成任务") - @ApiOperation("完成任务") - @PostMapping(value = "/finish/{id}") - public ResponseEntity finish(@RequestBody String id) { - taskService.finish(id); - return new ResponseEntity<>(HttpStatus.OK); - } - - @Log("取消任务") - @ApiOperation("取消任务") - @PostMapping(value = "/cancel/{id}") - public ResponseEntity cancel(@RequestBody String id) throws Exception { - taskService.cancel(id); - return new ResponseEntity<>(HttpStatus.OK); - } - - @Log("手动创建指令") - @ApiOperation("手动创建指令") - @PostMapping(value = "/createInst/{id}") - public ResponseEntity createInst(@RequestBody String id) throws Exception { - taskService.createInst(id); - return new ResponseEntity<>(HttpStatus.OK); - } - - @Log("导出任务") - @ApiOperation("导出任务") - @GetMapping(value = "/download") - //@PreAuthorize("@el.check('task:list')") - public void download(HttpServletResponse response, Map whereJson) throws IOException { - taskService.download(taskService.queryAll(whereJson), response); - } - - @Log("一体机触发任务") - @ApiOperation("一体机触发任务") - @PostMapping("/createTaskByClick") - //@PreAuthorize("@el.check('task:add')") - public ResponseEntity createTaskByClick(@RequestBody JSONObject json) { - taskService.createTaskByClick(json); - return new ResponseEntity<>(HttpStatus.CREATED); - } - - @Log("设备申请任务") - @ApiOperation("设备申请任务") - @PostMapping("/deviceAskTask") - //@PreAuthorize("@el.check('task:add')") - public ResponseEntity deviceAskTask(@RequestBody Map json) { - String device_code = (String) json.get("device_code"); - String container_code = (String) json.get("carrierno"); - int height = Integer.parseInt((String) json.get("height")); - int weight = Integer.parseInt((String) json.get("weight")); - String s = acsToWmsService.applyTaskToWms(device_code, container_code, height, weight); - return new ResponseEntity<>(s, HttpStatus.CREATED); - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/task/rest/TaskFeedbackController.java b/nladmin-system/src/main/java/org/nl/acs/task/rest/TaskFeedbackController.java deleted file mode 100644 index 37dccb6..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/task/rest/TaskFeedbackController.java +++ /dev/null @@ -1,64 +0,0 @@ - -package org.nl.acs.task.rest; - - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.task.service.TaskFeedbackService; -import org.nl.annotation.Log; -import org.springframework.data.domain.Pageable; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.Map; - -/** - * @author wangs - * @date 2022-02-17 - **/ -@RestController -@RequiredArgsConstructor -@Api(tags = "任务反馈管理") -@RequestMapping("/api/taskFeedback") -@Slf4j -public class TaskFeedbackController { - - private final TaskFeedbackService taskFeedbackService; - - @GetMapping - @Log("查询任务反馈") - @ApiOperation("查询任务反馈") - //@PreAuthorize("@el.check('taskFeedback:list')") - public ResponseEntity query(@RequestParam Map whereJson, Pageable page) { - return new ResponseEntity<>(taskFeedbackService.queryAll(whereJson, page), HttpStatus.OK); - } - - @Log("导出任务反馈") - @ApiOperation("导出任务反馈") - @GetMapping(value = "/download") - //@PreAuthorize("@el.check('taskFeedback:list')") - public void download(HttpServletResponse response, @RequestParam Map whereJson) throws IOException { - taskFeedbackService.download(taskFeedbackService.queryAll(whereJson), response); - } - - @Log("重置任务反馈") - @ApiOperation("重置任务反馈") - @PostMapping(value = "/retry/{id}") - public ResponseEntity retry(@RequestBody String id) { - taskFeedbackService.retry(id); - return new ResponseEntity<>(HttpStatus.OK); - } - - @Log("作废任务反馈") - @ApiOperation("作废任务反馈") - @PostMapping(value = "/invalid/{id}") - public ResponseEntity invalid(@RequestBody String id) { - taskFeedbackService.invalid(id); - return new ResponseEntity<>(HttpStatus.OK); - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/task/service/TaskFeedbackService.java b/nladmin-system/src/main/java/org/nl/acs/task/service/TaskFeedbackService.java deleted file mode 100644 index 30e405f..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/task/service/TaskFeedbackService.java +++ /dev/null @@ -1,96 +0,0 @@ - -package org.nl.acs.task.service; - -import org.nl.acs.task.service.dto.TaskFeedbackDto; -import org.springframework.data.domain.Pageable; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.List; -import java.util.Map; - -/** - * @author wangs - * @description 服务接口 - * @date 2022-02-17 - **/ -public interface TaskFeedbackService { - - /** - * 查询数据分页 - * - * @param whereJson 条件 - * @param page 分页参数 - * @return Map - */ - Map queryAll(Map whereJson, Pageable page); - - /** - * 查询所有数据不分页 - * - * @param whereJson 条件参数 - * @return List - */ - List queryAll(Map whereJson); - - /** - * 根据ID查询 - * - * @param taskback_id ID - * @return TaskFeedback - */ - TaskFeedbackDto findById(String taskback_id); - - /** - * 根据编码查询 - * - * @param code code - * @return TaskFeedback - */ - TaskFeedbackDto findByCode(String code); - - - /** - * 创建 - * - * @param dto / - */ - void create(TaskFeedbackDto dto); - - /** - * 编辑 - * - * @param dto / - */ - void update(TaskFeedbackDto dto); - - /** - * 多选删除 - * - * @param ids / - */ - void deleteAll(String[] ids); - - /** - * 导出数据 - * - * @param dtos 待导出的数据 - * @param response / - * @throws IOException / - */ - void download(List dtos, HttpServletResponse response) throws IOException; - - /** - * 重置 - * - * @param ids - */ - void retry(String ids); - - /** - * 作废 - * - * @param ids - */ - void invalid(String ids); -} diff --git a/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java b/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java deleted file mode 100644 index 9d84a3d..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java +++ /dev/null @@ -1,238 +0,0 @@ - -package org.nl.acs.task.service; - - -import com.alibaba.fastjson.JSONObject; -import org.nl.acs.task.service.dto.TaskDto; -import org.springframework.data.domain.Pageable; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.List; -import java.util.Map; - -/** - * @author ldjun - * @description 服务接口 - * @date 2021-03-18 - **/ -public interface TaskService { - - /** - * 查询数据分页 - * - * @param whereJson 条件 - * @param page 分页参数 - * @return Map - */ - Map queryAll(Map whereJson, Pageable page); - - /** - * 数据同步 - */ - void reload(); - - /** - * 在缓存中查询所有任务列表 - * - * @param whereJson 条件 - * @param page 分页参数 - * @return - */ - Map queryAllByCache(Map whereJson, Pageable page); - - /** - * 获取数据分页 - * - * @param whereJson 条件 - * @param page 分页参数 - * @return Map - */ - Map getAll(Map whereJson, Pageable page); - - /** - * 查询所有数据不分页 - * - * @param whereJson 条件参数 - * @return List - */ - List queryAll(String whereJson); - - - /** - * 查询所有数据不分页 - * - * @param whereJson 条件参数 - * @return List - */ - List queryAll(Map whereJson); - - /** - * 根据ID查询 - * - * @param task_id ID - * @return AcsTask - */ - TaskDto findById(String task_id); - - /** - * 查询所有未完成任务 - * - * @param whereJson 条件参数 - * @return List - */ - List queryAllUnfinished(Map whereJson); - - /** - * 根据状态查询 - * - * @param task_status task_status - * @return AcsTask - */ - List queryByStauts(String task_status); - - /** - * 根据编码查询 - * - * @param code code - * @return AcsTask - */ - TaskDto findByCode(String code); - - /** - * 根据设备号查询未执行的任务 - */ - List queryTaskByDeviceCode(String device_code); - - /** - * 创建 - * - * @param dto / - */ - void create(TaskDto dto) throws Exception; - - /** - * 常规任务保存 - * - * @param / - */ - void ordinaryTaskCreate(JSONObject json) throws Exception; - - /** - * 特殊任务保存 - * - * @param / - */ - void specialTaskCreate(JSONObject json) throws Exception; - - /** - * 编辑 - * - * @param dto / - */ - void update(TaskDto dto); - - /** - * 多选删除 - * - * @param ids / - */ - void deleteAll(String[] ids) throws Exception; - - /** - * 完成任务 - * - * @param ids - */ - void finish(String ids); - - /** - * 取消任务 - * - * @param ids - */ - void cancel(String ids) throws Exception; - - /** - * 手动创建指令 - * - * @param ids - */ - void createInst(String ids) throws Exception; - - /** - * 导出数据 - * - * @param dtos 待导出的数据 - * @param response / - * @throws IOException / - */ - void download(List dtos, HttpServletResponse response) throws IOException; - - - /** - * 根据触摸屏点击保存创建任务 - * - * @param json - */ - void createTaskByClick(JSONObject json); - - - int checkAllowCreate(String code); - - boolean removeByCodeFromCache(String code); - - TaskDto findByContainer(String container_code); - - TaskDto findByCodeFromCache(String task_code); - - /** - * 根据目的地设备编号查询当前是否有设备 - * - * @param device_code - * @return - */ - TaskDto findByNextCode(String device_code); - - /** - * 根据起点设备编号查询当前是否有设备 - * - * @param device_code - * @return - */ - TaskDto findByStartCode(String device_code); - - /** - * 查询内存任务 - * - * @return - */ - List findAllTaskFromCache(); - - TaskDto foramte(TaskDto task); - - /** - * 修改内存中任务 - * - * @param dto - */ - void updateByCodeFromCache(TaskDto dto); - - /** - * 平均分配查询设备 - * - * @param device_code - * @param task_nextdevice_code - * @return - */ - String queryAssignedByDevice(String device_code, String task_nextdevice_code); - - /** - * 查询相同任务类型的数量 - * - * @param taskType - * @return - */ - Integer querySameTaskByType(String taskType); - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java b/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java deleted file mode 100644 index 96e79e0..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java +++ /dev/null @@ -1,220 +0,0 @@ -package org.nl.acs.task.service.dto; - -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; - -/** - * @author ldjun - * @description / - * @date 2021-03-18 - **/ -@Data -public class TaskDto implements Serializable { - - /** - * 任务标识 - */ - private String task_id; - - /** - * 任务号 - */ - private String task_code; - - /** - * 载具号 - */ - private String vehicle_code; - - /** - * 载具类型 - */ - private String vehicle_type; - - /** - * 任务类型 - */ - private String task_type = "1"; - - /** - * 任务状态 - */ - private String task_status; - - /** - * 任务优先级 - */ - private String priority; - - /** - * 创建类型 - */ - private String create_type; - - /** - * 完成类型 - */ - private String finish_type; - - /** - * 执行描述编码 - */ - private String execute_code; - - /** - * 执行描述信息 - */ - private String execute_message; - - /** - * 起始点位编码 - */ - private String start_point_code; - - /** - * 起始设备编码 - */ - private String start_device_code; - - /** - * 目标点位编码 - */ - private String next_point_code; - - /** - * 目标设备编码 - */ - private String next_device_code; - - /** - * 排 - */ - private String from_x; - - /** - * 列 - */ - private String from_y; - - /** - * 层 - */ - private String from_z; - - /** - * 排 - */ - private String to_x; - - /** - * 列 - */ - private String to_y; - - /** - * 层 - */ - private String to_z; - - /** - * 路由方案名称 - */ - private String route_plan_name; - - /** - * 路由方案编码 - */ - private String route_plan_code = "normal"; - - /** - * 是否需要反馈上位系统 - */ - private String is_needfeedback; - - /** - * 备注 - */ - private String remark; - - /** - * 是否启用 - */ - private String is_active; - - /** - * 是否删除 - */ - private String is_delete; - - /** - * 创建者 - */ - private String create_by; - - /** - * 创建时间 - */ - private String create_time; - - /** - * 修改者 - */ - private String update_by; - - /** - * 修改时间 - */ - private String update_time; - - /** - * 物料类型 - */ - private String material; - - /** - * 物料数量 - */ - private BigDecimal quantity; - - /** - * 是否复合任务 - */ - private String compound_task; - - /** - * 复合任务数据 - */ - private String compound_task_data; - - /** - * 是否再次请求 - */ - private String request_again = "0"; - - /** - * 再次请求成功 - */ - private String request_again_success; - - /** - * 空盘数量 =1 则从最上方取 - */ - private String emptypallet_num = "0"; - - /** - * 起点父级编码 - */ - private String start_parent_code; - - /** - * 终点父级编码 - */ - private String next_parent_code; - - /** - * 外部系统标识 - */ - private String ext_task_uuid; -} diff --git a/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskFeedbackDto.java b/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskFeedbackDto.java deleted file mode 100644 index 83cbd16..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskFeedbackDto.java +++ /dev/null @@ -1,139 +0,0 @@ -package org.nl.acs.task.service.dto; - -import lombok.Data; - -import java.io.Serializable; - -/** - * @author wangs - * @description / - * @date 2022-02-17 - **/ -@Data -public class TaskFeedbackDto implements Serializable { - - /** - * 任务反馈标识 - */ - private String taskback_id; - - /** - * 任务标识 - */ - private String task_id; - - /** - * 任务号 - */ - private String task_code; - - /** - * 载具号 - */ - private String vehicle_code; - - /** - * 载具类型 - */ - private String vehicle_type; - - /** - * 任务类型 - */ - private String task_type; - - /** - * 任务状态 - */ - private String task_status; - - /** - * 是否完成 - */ - private String is_finished; - - /** - * 错误编码 - */ - private String error_code; - - /** - * 开始时间 - */ - private String start_time; - - /** - * 完成时间 - */ - private String finish_time; - - /** - * 创建类型 - */ - private String create_type; - - /** - * 完成类型 - */ - private String finish_type; - - /** - * 重试次数 - */ - private String retry_times; - - /** - * 起始点位编码 - */ - private String start_point_code; - - /** - * 起始设备编码 - */ - private String start_device_code; - - /** - * 目标点位编码 - */ - private String next_point_code; - - /** - * 目标设备编码 - */ - private String next_device_code; - - /** - * 备注 - */ - private String remark; - - /** - * 是否启用 - */ - private String is_active; - - /** - * 是否删除 - */ - private String is_delete; - - /** - * 创建者 - */ - private String create_by; - - /** - * 创建时间 - */ - private String create_time; - - /** - * 修改者 - */ - private String update_by; - - /** - * 修改时间 - */ - private String update_time; -} diff --git a/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskFeedbackServiceImpl.java b/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskFeedbackServiceImpl.java deleted file mode 100644 index 695f614..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskFeedbackServiceImpl.java +++ /dev/null @@ -1,206 +0,0 @@ - -package org.nl.acs.task.service.impl; - - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.task.service.TaskFeedbackService; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.acs.task.service.dto.TaskFeedbackDto; -import org.nl.exception.BadRequestException; -import org.nl.utils.FileUtil; -import org.nl.utils.SecurityUtils; -import org.nl.wql.core.bean.ResultBean; -import org.nl.wql.core.bean.WQLObject; -import org.nl.wql.util.WqlUtil; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** - * @author wangs - * @description 服务实现 - * @date 2022-02-17 - **/ -@Service -@RequiredArgsConstructor -@Slf4j -public class TaskFeedbackServiceImpl implements TaskFeedbackService { - - @Autowired - AcsToWmsService acstowmsService; - @Autowired - TaskService taskService; - - @Override - public Map queryAll(Map whereJson, Pageable page) { - WQLObject wo = WQLObject.getWQLObject("acs_task_feedback"); - ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "is_finished = '0' ", "update_time desc"); - final JSONObject json = rb.pageResult(); - return json; - } - - @Override - public List queryAll(Map whereJson) { - WQLObject wo = WQLObject.getWQLObject("acs_task_feedback"); - JSONArray arr = wo.query().getResultJSONArray(0); - List list = arr.toJavaList(TaskFeedbackDto.class); - return list; - } - - @Override - public TaskFeedbackDto findById(String taskback_id) { - WQLObject wo = WQLObject.getWQLObject("acs_task_feedback"); - JSONObject json = wo.query("taskback_id ='" + taskback_id + "'").uniqueResult(0); - final TaskFeedbackDto obj = json.toJavaObject(TaskFeedbackDto.class); - return obj; - } - - @Override - public TaskFeedbackDto findByCode(String code) { - WQLObject wo = WQLObject.getWQLObject("acs_task_feedback"); - JSONObject json = wo.query("task_code ='" + code + "' and is_finished='0' ").uniqueResult(0); - final TaskFeedbackDto obj = json.toJavaObject(TaskFeedbackDto.class); - return obj; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void create(TaskFeedbackDto dto) { - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - - dto.setTaskback_id(IdUtil.simpleUUID()); - dto.setCreate_by(currentUsername); - dto.setUpdate_by(currentUsername); - dto.setUpdate_time(now); - dto.setCreate_time(now); - - WQLObject wo = WQLObject.getWQLObject("acs_task_feedback"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(TaskFeedbackDto dto) { - TaskFeedbackDto entity = this.findById(dto.getTaskback_id()); - if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); - - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - dto.setUpdate_time(now); - dto.setUpdate_by(currentUsername); - - WQLObject wo = WQLObject.getWQLObject("acs_task_feedback"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.update(json); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteAll(String[] ids) { - WQLObject wo = WQLObject.getWQLObject("acs_task_feedback"); - for (String taskback_id : ids) { - wo.delete("taskback_id = '" + taskback_id + "'"); - } - } - - @Override - public void download(List all, HttpServletResponse response) throws IOException { - List> list = new ArrayList<>(); - for (TaskFeedbackDto taskFeedback : all) { - Map map = new LinkedHashMap<>(); - map.put("任务标识", taskFeedback.getTask_id()); - map.put("任务号", taskFeedback.getTask_code()); - map.put("载具号", taskFeedback.getVehicle_code()); - map.put("载具类型", taskFeedback.getVehicle_type()); - map.put("任务类型", taskFeedback.getTask_type()); - map.put("任务状态", taskFeedback.getTask_status()); - map.put("是否完成", taskFeedback.getIs_finished()); - map.put("错误编码", taskFeedback.getError_code()); - map.put("开始时间", taskFeedback.getStart_time()); - map.put("完成时间", taskFeedback.getFinish_time()); - map.put("创建类型", taskFeedback.getCreate_type()); - map.put("完成类型", taskFeedback.getFinish_type()); - map.put("重试次数", taskFeedback.getRetry_times()); - map.put("起始点位编码", taskFeedback.getStart_point_code()); - map.put("起始设备编码", taskFeedback.getStart_device_code()); - map.put("目标点位编码", taskFeedback.getNext_point_code()); - map.put("目标设备编码", taskFeedback.getNext_device_code()); - map.put("备注", taskFeedback.getRemark()); - map.put("是否启用", taskFeedback.getIs_active()); - map.put("是否删除", taskFeedback.getIs_delete()); - map.put("创建者", taskFeedback.getCreate_by()); - map.put("创建时间", taskFeedback.getCreate_time()); - map.put("修改者", taskFeedback.getUpdate_by()); - map.put("修改时间", taskFeedback.getUpdate_time()); - list.add(map); - } - FileUtil.downloadExcel(list, response); - } - - @Override - public void retry(String id) { - TaskFeedbackDto dto = this.findById(id); - TaskDto entity = taskService.findById(dto.getTask_id()); - JSONObject feed_jo = new JSONObject(); - feed_jo.put("task_uuid", entity.getTask_id()); - feed_jo.put("task_code", entity.getTask_code()); - feed_jo.put("task_status", entity.getTask_status()); - JSONArray ja = new JSONArray(); - - HttpResponse body = null; - String error_message = null; - try { - body = acstowmsService.feedbackTaskStatusToWms(ja); - } catch (Exception e) { - error_message = e.getMessage(); - e.printStackTrace(); - } - int status = body.getStatus(); - JSONObject jo = (JSONObject) JSONObject.toJSON(body.body()); - - dto.setTask_status(entity.getTask_status()); - if (status == 200) { - dto.setIs_finished("1"); - dto.setError_code("200"); - dto.setRemark(""); - } else { - dto.setRemark(error_message); - dto.setRetry_times(Integer.parseInt(dto.getRetry_times()) + 1 + ""); - } - this.update(dto); - - } - - @Override - public void invalid(String id) { - TaskFeedbackDto entity = this.findById(id); - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - entity.setUpdate_time(now); - entity.setUpdate_by(currentUsername); - entity.setIs_finished("1"); - WQLObject wo = WQLObject.getWQLObject("acs_task_feedback"); - JSONObject json = (JSONObject) JSONObject.toJSON(entity); - wo.update(json); - } -} diff --git a/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java deleted file mode 100644 index f1be4fd..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ /dev/null @@ -1,1277 +0,0 @@ - -package org.nl.acs.task.service.impl; - - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.config.AcsConfig; -import org.nl.acs.config.server.AcsConfigService; -import org.nl.acs.device.service.DeviceAssignedService; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device.service.StorageCellService; -import org.nl.acs.device.service.dto.DeviceAssignedDto; -import org.nl.acs.device.service.impl.DeviceServiceImpl; -import org.nl.acs.device_driver.special_ordinary_site.SpecialOrdinarySiteDeviceDriver; -import org.nl.acs.device_driver.standard_inspect_site.StandardInspectSiteDeviceDriver; -import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.instruction.service.dto.InstructionDto; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.acs.opc.DeviceType; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.route.service.dto.RouteLineDto; -import org.nl.acs.task.service.TaskFeedbackService; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.acs.task.service.dto.TaskFeedbackDto; -import org.nl.exception.BadRequestException; -import org.nl.exception.WDKException; -import org.nl.modules.system.util.CodeUtil; -import org.nl.start.auto.initial.ApplicationAutoInitial; -import org.nl.utils.FileUtil; -import org.nl.utils.SecurityUtils; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.WQL; -import org.nl.wql.core.bean.WQLObject; -import org.nl.wql.util.WqlUtil; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.math.BigDecimal; -import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * @author ldjun - * @description 服务实现 - * @date 2021-03-18 - **/ -@Service -@RequiredArgsConstructor -@Slf4j -public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { - List tasks = new ArrayList(); - - @Autowired - DeviceAppService deviceAppService; - @Autowired - RouteLineService routelineserver; - @Autowired - AcsToWmsService acstowmsService; - @Autowired - TaskFeedbackService taskFeedbackService; - @Autowired - AcsConfigService acsConfigService; - @Autowired - AgvService agvService; - @Autowired - RouteLineService routeLineService; - @Autowired - DeviceAssignedService deviceAssignedService; - @Autowired - InstructionService instructionService; - @Autowired - StorageCellService storageCellService; - - @Override - public void autoInitial() throws Exception { - this.reload(); - } - - public synchronized void reload() { - this.tasks = this.queryAll("task_status <2 and is_delete =0"); - } - - @Override - public List queryAll(String whereJson) { - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONArray arr = wo.query(whereJson).getResultJSONArray(0); - List list = arr.toJavaList(TaskDto.class); - return list; - } - - @Override - public Map queryAll(Map whereJson, Pageable page) { - - //WQLObject wo = WQLObject.getWQLObject("acs_task"); - //ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "task_status < 2 ", "update_time desc"); - HashMap map = new HashMap<>(); - map.put("flag", "1"); - String task_code = (String) whereJson.get("task_code"); - String vehicle_code = (String) whereJson.get("vehicle_code"); - String material_type = (String) whereJson.get("material_type"); - String status = (String) whereJson.get("status"); - String point_code = (String) whereJson.get("point_code"); - String is_over = (String) whereJson.get("is_over"); - if (!StrUtil.isEmpty(task_code)) { - map.put("task_code", task_code); - } - if (!StrUtil.isEmpty(vehicle_code)) { - map.put("vehicle_code", vehicle_code); - } - if (!StrUtil.isEmpty(material_type)) { - map.put("material_type", material_type); - } - if (!StrUtil.isEmpty(status)) { - map.put("status", status); - } - if (!StrUtil.isEmpty(point_code)) { - map.put("point_code", point_code); - } - if (!StrUtil.isEmpty(is_over)) { - map.put("is_over", is_over); - } - final JSONObject jo = WQL.getWO("QTASK_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), ""); - return jo; - } - - @Override - public Map queryAllByCache(Map whereJson, Pageable page) { - this.reload(); - String task_code = (String) whereJson.get("task_code"); - String vehicle_code = (String) whereJson.get("vehicle_code"); - String material_type = (String) whereJson.get("material_type"); - String status = (String) whereJson.get("status"); - String point_code = (String) whereJson.get("point_code"); - String is_over = (String) whereJson.get("is_over"); - List taskList = new ArrayList(); - for (int i = 0; i < tasks.size(); i++) { - TaskDto task = tasks.get(i); - if ("1".equals(is_over) && Integer.valueOf(task.getTask_status()) < 2) { - continue; - } - if (!"1".equals(is_over) && Integer.valueOf(task.getTask_status()) >= 2) { - continue; - } - if (!ObjectUtil.isEmpty(task_code) && !task.getTask_code().equals(task_code)) { - continue; - } - if (!ObjectUtil.isEmpty(status) && !task.getTask_status().equals(status)) { - continue; - } - if (!ObjectUtil.isEmpty(vehicle_code) && !task.getVehicle_code().equals(vehicle_code)) { - continue; - } - if (!ObjectUtil.isEmpty(material_type) && !task.getMaterial().equals(material_type)) { - continue; - } - if (!ObjectUtil.isEmpty(point_code) && !(task.getStart_point_code().equals(point_code) || task.getNext_point_code().equals(point_code))) { - continue; - } - taskList.add(task); - } - JSONObject jo = new JSONObject(); - jo.put("content", taskList); - jo.put("totalElements", taskList.size()); - return jo; - } - - @Override - public Map getAll(Map whereJson, Pageable page) { - //WQLObject wo = WQLObject.getWQLObject("acs_task"); - //ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "task_status < 2 ", "update_time desc"); - HashMap map = new HashMap<>(); - map.put("flag", "2"); - String task_code = (String) whereJson.get("task_code"); - String vehicle_code = (String) whereJson.get("vehicle_code"); - String material_type = (String) whereJson.get("material_type"); - String status = (String) whereJson.get("status"); - String point_code = (String) whereJson.get("point_code"); - String create_time = (String) whereJson.get("createTime"); - String end_time = (String) whereJson.get("end_time"); - if (!StrUtil.isEmpty(task_code)) { - map.put("task_code", task_code); - } - if (!StrUtil.isEmpty(vehicle_code)) { - map.put("vehicle_code", vehicle_code); - } - if (!StrUtil.isEmpty(material_type)) { - map.put("material_type", material_type); - } - if (!StrUtil.isEmpty(status)) { - map.put("status", status); - } - if (!StrUtil.isEmpty(point_code)) { - map.put("point_code", point_code); - } - if (!StrUtil.isEmpty(create_time) && !StrUtil.isEmpty(end_time)) { - map.put("create_time", create_time); - map.put("end_time", end_time); - } - JSONObject jsonObject1 = WQL.getWO("QTASK_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "create_time desc"); - JSONArray array = jsonObject1.getJSONArray("content"); - int totalElements = (Integer) jsonObject1.get("totalElements"); - JSONArray arr = new JSONArray(); - for (int i = 0; i < array.size(); i++) { - JSONObject jsonObject = (JSONObject) array.get(i); - jsonObject.put("hasChildren", true); - arr.add(jsonObject); - } - JSONObject jo = new JSONObject(); - jo.put("content", arr); - jo.put("totalElements", totalElements); - return jo; - } - - @Override - public List queryAll(Map whereJson) { - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONArray arr = wo.query().getResultJSONArray(0); - List list = arr.toJavaList(TaskDto.class); - return list; - } - - @Override - public TaskDto findById(String task_id) { - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = wo.query("task_id ='" + task_id + "'").uniqueResult(0); - final TaskDto obj = json.toJavaObject(TaskDto.class); - return obj; - } - - @Override - public List queryAllUnfinished(Map whereJson) { - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONArray arr = wo.query("task_status < 2 ").getResultJSONArray(0); - List list =arr.toJavaList(TaskDto.class); - return list; - } - - @Override - public TaskDto findByCode(String code) { - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = wo.query("task_code ='" + code + "'").uniqueResult(0); - final TaskDto obj = json.toJavaObject(TaskDto.class); - return obj; - } - - @Override - public List queryTaskByDeviceCode(String device_code) { - List list = new ArrayList<>(); - Iterator iterator = tasks.iterator(); - while (iterator.hasNext()) { - TaskDto task = iterator.next(); - if (task.getStart_device_code().equals(device_code) && StrUtil.equals(task.getTask_status(), "0")) { - list.add(task); - } - } - return list; - } - - @Override - public List queryByStauts(String status) { - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONArray arr = wo.query("task_status = '" + status + "'").getResultJSONArray(0); - List list = arr.toJavaList(TaskDto.class); - return list; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void create(TaskDto dto) throws Exception { - dto = foramte(dto); - if (!StrUtil.isEmpty(dto.getVehicle_code())) { - TaskDto vehicle_dto = this.findByContainer(dto.getVehicle_code()); - if (vehicle_dto != null) { - throw new WDKException("已存在该载具号的任务!"); - } - } - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - String task_uuid = dto.getTask_id(); - if (StrUtil.isEmpty(task_uuid)) { - dto.setTask_id(IdUtil.simpleUUID()); - } - String task_code = dto.getTask_code(); - if (StrUtil.isEmpty(task_code)) { - task_code = CodeUtil.getNewCode("TASK_NO"); - task_code = "-" + task_code; - } - String start_point_code = dto.getStart_point_code(); - String next_point_code = dto.getNext_point_code(); - String start_device_code = dto.getStart_device_code(); - String next_device_code = dto.getNext_device_code(); - String route_plan_code = dto.getRoute_plan_code(); - dto.setCreate_by(currentUsername); - dto.setUpdate_by(currentUsername); - dto.setUpdate_time(now); - dto.setCreate_time(now); - dto.setTask_code(task_code); - dto.setRoute_plan_code(route_plan_code); - dto.setTask_status("0"); - - if (StrUtil.isEmpty(dto.getPriority())) { - dto.setPriority("1"); - } - String plan_code = dto.getRoute_plan_code(); - //判断起点终点设备类型 - String startDeviceType = deviceAppService.findDeviceTypeByCode(dto.getStart_device_code()); - String nextDeviceType = deviceAppService.findDeviceTypeByCode(dto.getNext_device_code()); - if (routelineserver.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), plan_code).size() == 0) { - throw new Exception(dto.getStart_point_code() + "->" + dto.getNext_point_code() + "路由不通!"); - } - String createTaskCheck = acsConfigService.findConfigFromCache().get(AcsConfig.CREATETASKCHECK); - DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device nextdevice = appService.findDeviceByCode(next_device_code); - Device startdevice = appService.findDeviceByCode(start_device_code); - dto.setMaterial(startdevice.getMaterial_type()); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver; - SpecialOrdinarySiteDeviceDriver specialOrdinarySiteDeviceDriver; - if (StrUtil.equals(createTaskCheck, "1")) { - //判断起点为输送设备 - if (StrUtil.equals(DeviceType.conveyor.toString(), startDeviceType)) { - if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMode() != 2 || standardInspectSiteDeviceDriver.getMove() == 0) { - throw new Exception("任务起点需满足待机有货!"); - } - if (!StrUtil.isEmpty(standardInspectSiteDeviceDriver.getMaterial())) { - dto.setMaterial(standardInspectSiteDeviceDriver.getMaterial()); - } - } - if (startdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) startdevice.getDeviceDriver(); - if (startdevice.getHas_goods() == 0) { - throw new Exception("任务起点需满足有货!"); - } - if (!StrUtil.isEmpty(standardOrdinarySiteDeviceDriver.getMaterial())) { - dto.setMaterial(standardOrdinarySiteDeviceDriver.getMaterial()); - } - } - if (startdevice.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) { - specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) startdevice.getDeviceDriver(); - if (startdevice.getHas_goods() == 0) { - throw new Exception("任务起点需满足有货!"); - } - if (!StrUtil.isEmpty(specialOrdinarySiteDeviceDriver.getMaterial())) { - dto.setMaterial(specialOrdinarySiteDeviceDriver.getMaterial()); - } - } - } - if (StrUtil.equals(DeviceType.conveyor.toString(), nextDeviceType)) { - if (nextdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) nextdevice.getDeviceDriver(); - if (nextdevice.getHas_goods() != 0) { - throw new Exception("任务终点需满足无货!"); - } - } - if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMode() != 2 || standardInspectSiteDeviceDriver.getMove() != 0) { - throw new Exception("任务终点需满足待机无货!"); - } - } - } - } else { - //判断起点为输送设备 - if (StrUtil.equals(DeviceType.conveyor.toString(), startDeviceType)) { - if (startdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) startdevice.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMode() != 2 || standardInspectSiteDeviceDriver.getMove() == 0) { - throw new Exception("任务起点需满足待机有货!"); - } - if (!StrUtil.isEmpty(standardInspectSiteDeviceDriver.getMaterial())) { - dto.setMaterial(standardInspectSiteDeviceDriver.getMaterial()); - } - - } - - if (nextdevice.getDeviceDriver() instanceof SpecialOrdinarySiteDeviceDriver) { - specialOrdinarySiteDeviceDriver = (SpecialOrdinarySiteDeviceDriver) nextdevice.getDeviceDriver(); - if (nextdevice.getHas_goods() != 0) { - throw new Exception("任务起点需满足无货!"); - } - } - } - - if (StrUtil.equals(DeviceType.conveyor.toString(), nextDeviceType)) { -// if (nextdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { -// standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) nextdevice.getDeviceDriver(); -// if (nextdevice.getHas_goods() != 0) { -// throw new Exception("任务终点需满足无货!"); -// } -// } - - if (nextdevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { - standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) nextdevice.getDeviceDriver(); - if (standardInspectSiteDeviceDriver.getMode() != 2 || standardInspectSiteDeviceDriver.getMove() != 0) { - throw new Exception("任务终点需满足待机无货!"); - } - } - - JSONObject jo = new JSONObject(); - JSONObject jo2 = new JSONObject(); - if (!StrUtil.isEmpty(dto.getMaterial())) { - if (!StrUtil.equals(dto.getMaterial(), "1")) { - jo.put("hasGoodStatus", "2"); - jo.put("material_type", dto.getMaterial()); - } else { - jo.put("hasGoodStatus", "1"); - jo.put("material_type", "1"); - } - - } else { - jo.put("hasGoodStatus", "1"); - jo.put("material_type", "1"); - } - jo.put("device_code", dto.getStart_device_code()); - jo.put("quantity", dto.getQuantity()); - jo.put("remark", dto.getRemark()); - jo.put("batch", startdevice.getBatch()); - jo.put("islock", "true"); - deviceService.changeDeviceStatus(jo); - Device deviceByCode = deviceAppService.findDeviceByCode(dto.getNext_device_code()); - jo2.put("device_code", dto.getNext_device_code()); - jo2.put("hasGoodStatus", deviceByCode.getHas_goods()); - jo2.put("quantity", deviceByCode.getQuantity()); - jo2.put("remark", deviceByCode.getRemark()); - jo2.put("material_type", deviceByCode.getMaterial_type()); - jo2.put("batch", deviceByCode.getBatch()); - jo2.put("islock", "true"); - deviceService.changeDeviceStatus(jo2); - } - } - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.insert(json); - tasks.add(dto); - } - - /** - * 常规任务保存 - * - * @param / - * @throws Exception - */ - @Override - public void ordinaryTaskCreate(JSONObject json) throws Exception { - JSONArray array = json.getJSONArray("data"); - - if (array.size() == 0) { - throw new RuntimeException("请选择起点"); - } - for (int i = 0; i < array.size(); i++) { - JSONObject arrjo = array.getJSONObject(i); - String material_type = arrjo.getString("material_type"); - String quantity = arrjo.getString("quantity"); - String remark = arrjo.getString("remark"); - TaskDto dto = new TaskDto(); - Map whereJson = (Map) array.get(i); - - //String device_code = (String) whereJson.get("device_code"); - String device_code = MapUtil.getStr(whereJson, "device_code"); - dto.setRoute_plan_code("one"); - String next_device_code = ""; - String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + dto.getRoute_plan_code() + "'").uniqueResult(0).getString("plan_uuid"); - JSONArray ja = routelineserver.queryNextLine(device_code, plan_uuid); - for (int j = 0; j < ja.size(); j++) { - JSONObject jo = (JSONObject) ja.get(j); - next_device_code = jo.get("next_device_code").toString(); - } - if (ObjectUtil.isNotEmpty(this.findByStartCode(device_code))) { - throw new WDKException("已存在该起点的任务!"); - } - if (StrUtil.equals(material_type, "") || StrUtil.equals(quantity, "")) { - throw new RuntimeException("请填写物料信息!"); - } - dto.setStart_device_code(device_code); - dto.setStart_point_code(device_code); - dto.setNext_device_code(next_device_code); - dto.setNext_point_code(next_device_code); - dto.setQuantity(new BigDecimal(quantity)); - dto.setRemark(remark); - dto.setMaterial(material_type); - create(dto); - } - } - - /** - * 特殊任务保存 - * - * @param / - * @throws Exception - */ - @Override - public void specialTaskCreate(JSONObject json) throws Exception { - - JSONArray array = json.getJSONArray("data1"); - JSONArray array2 = json.getJSONArray("data2"); - JSONArray array3 = json.getJSONArray("data3"); - if (array.size() != 0 && array3.size() != 0) { - throw new RuntimeException("只能选择一个终点"); - } - - for (int i = 0; i < array2.size(); i++) { - JSONObject arrjo = array2.getJSONObject(i); - String material_type = arrjo.getString("material_type"); - String quantity = arrjo.getString("quantity"); - String remark = arrjo.getString("remark"); - TaskDto dto = new TaskDto(); - Map whereJson; - Map whereJson2; - Map whereJson3; - if (array.size() != 0) { - whereJson = (Map) array.get(i); - } else { - whereJson = null; - } - if (array2.size() != 0) { - whereJson2 = (Map) array2.get(i); - } else { - whereJson2 = null; - } - if (array3.size() != 0) { - whereJson3 = (Map) array3.get(i); - } else { - whereJson3 = null; - } - String start_device_code = MapUtil.getStr(whereJson2, "device_code"); - String next_device_code = ""; - if (ObjectUtil.isEmpty(whereJson)) { - next_device_code = MapUtil.getStr(whereJson3, "device_code"); - } else { - next_device_code = MapUtil.getStr(whereJson, "device_code"); - } - - if (ObjectUtil.isNotEmpty(this.findByStartCode(start_device_code)) - || ObjectUtil.isNotEmpty(this.findByNextCode(next_device_code))) { - throw new WDKException("已存在该起点或终点的任务!"); - } - if (StrUtil.equals(material_type, "") || StrUtil.equals(quantity, "")) { - throw new RuntimeException("请填写物料信息!"); - } - dto.setRoute_plan_code("two"); - dto.setStart_device_code(start_device_code); - dto.setStart_point_code(start_device_code); - dto.setNext_device_code(next_device_code); - dto.setNext_point_code(next_device_code); - dto.setQuantity(new BigDecimal(quantity)); - dto.setRemark(remark); - dto.setMaterial(material_type); - create(dto); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(TaskDto dto) { - TaskDto entity = this.findById(dto.getTask_id()); - if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); - - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - dto.setUpdate_time(now); - dto.setUpdate_by(currentUsername); - - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(dto); - - wo.update(json); - - Iterator iterator = tasks.iterator(); - while (iterator.hasNext()) { - TaskDto task = iterator.next(); - if (task.getTask_code().equals(dto.getTask_code())) { - iterator.remove(); - } - } - if (StrUtil.equals(dto.getTask_status(), "0") || StrUtil.equals(dto.getTask_status(), "1")) { - tasks.add(dto); - } - //判断是否为WMS下发的任务,如果是反馈任务状态给WMS - String hasWms = acsConfigService.findConfigFromCache().get(AcsConfig.HASWMS); - if (!StrUtil.startWith(dto.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { - TaskFeedbackDto feefbackdto = taskFeedbackService.findByCode(entity.getTask_code()); - JSONObject feed_jo = new JSONObject(); - feed_jo.put("ext_task_uuid", entity.getExt_task_uuid()); - feed_jo.put("task_code", dto.getTask_code()); - feed_jo.put("task_status", dto.getTask_status()); - JSONArray ja = new JSONArray(); - ja.add(feed_jo); - String message = null; - HttpResponse body = null; - boolean flag = false; - try { - body = acstowmsService.feedbackTaskStatusToWms(ja); - } catch (Exception e) { - flag = true; - message = e.getMessage(); - e.printStackTrace(); - } finally { - - } - if (flag) { - if (ObjectUtil.isEmpty(feefbackdto)) { - feefbackdto = new TaskFeedbackDto(); - feefbackdto.setTask_id(entity.getTask_id()); - feefbackdto.setTask_code(entity.getTask_code()); - feefbackdto.setTask_status(entity.getTask_status()); - feefbackdto.setVehicle_type(entity.getVehicle_type()); - feefbackdto.setVehicle_code(entity.getVehicle_code()); - feefbackdto.setStart_device_code(entity.getStart_device_code()); - feefbackdto.setStart_point_code(entity.getStart_point_code()); - feefbackdto.setNext_device_code(entity.getNext_device_code()); - feefbackdto.setNext_point_code(entity.getNext_point_code()); - feefbackdto.setError_code("400"); - feefbackdto.setIs_finished("0"); - feefbackdto.setRemark(message); - taskFeedbackService.create(feefbackdto); - } else { - feefbackdto.setTask_status(entity.getTask_status()); - feefbackdto.setStart_device_code(entity.getStart_device_code()); - feefbackdto.setStart_point_code(entity.getStart_point_code()); - feefbackdto.setNext_device_code(entity.getNext_device_code()); - feefbackdto.setNext_point_code(entity.getNext_point_code()); - feefbackdto.setError_code("400"); - feefbackdto.setRemark(message); - taskFeedbackService.update(feefbackdto); - } - } else { - int status = body.getStatus(); - JSONObject jo = JSONObject.parseObject(body.body()); - if (ObjectUtil.isEmpty(feefbackdto)) { - feefbackdto = new TaskFeedbackDto(); - feefbackdto.setTask_id(entity.getTask_id()); - feefbackdto.setTask_code(entity.getTask_code()); - feefbackdto.setTask_status(entity.getTask_status()); - feefbackdto.setVehicle_type(entity.getVehicle_type()); - feefbackdto.setVehicle_code(entity.getVehicle_code()); - feefbackdto.setError_code(String.valueOf(body.getStatus())); - feefbackdto.setStart_device_code(entity.getStart_device_code()); - feefbackdto.setStart_point_code(entity.getNext_point_code()); - feefbackdto.setNext_device_code(entity.getNext_device_code()); - feefbackdto.setNext_point_code(entity.getNext_point_code()); - if (status == 200) { - if (StrUtil.equals(entity.getTask_status(), "2")) { - feefbackdto.setIs_finished("1"); - } else { - feefbackdto.setIs_finished("0"); - } - } else { - feefbackdto.setIs_finished("0"); - feefbackdto.setRemark(jo.getString("message")); - } - taskFeedbackService.create(feefbackdto); - } else { - feefbackdto.setTask_status(entity.getTask_status()); - if (status == 200) { - } else { - if (StrUtil.equals(entity.getTask_status(), "2")) { - feefbackdto.setIs_finished("1"); - } else { - feefbackdto.setIs_finished("0"); - } - } - taskFeedbackService.update(feefbackdto); - } - } - - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteAll(String[] ids) throws Exception { - for (String task_id : ids) { - this.cancel(task_id); - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void finish(String id) { - TaskDto entity = this.findById(id); - if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); - InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl"); - InstructionDto instdto = instructionservice.findByTaskid(id, "instruction_status <2 "); - if (instdto != null) throw new BadRequestException("有指令未完成!"); - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - entity.setUpdate_time(now); - entity.setUpdate_by(currentUsername); - entity.setTask_status("2"); - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(entity); - wo.update(json); - removeByCodeFromCache(entity.getTask_code()); - //判断是否为WMS下发的任务,如果是反馈任务状态给WMS - String hasWms = acsConfigService.findConfigFromCache().get(AcsConfig.HASWMS); - if (!StrUtil.startWith(entity.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { - TaskFeedbackDto feefbackdto = taskFeedbackService.findByCode(entity.getTask_code()); - JSONObject feed_jo = new JSONObject(); - feed_jo.put("ext_task_uuid", entity.getExt_task_uuid()); - feed_jo.put("task_code", entity.getTask_code()); - feed_jo.put("task_status", entity.getTask_status()); - JSONArray ja = new JSONArray(); - ja.add(feed_jo); - String message = null; - HttpResponse body = null; - boolean flag = false; - try { - body = acstowmsService.feedbackTaskStatusToWms(ja); - } catch (Exception e) { - flag = true; - message = e.getMessage(); - e.printStackTrace(); - } finally { - - } - if (flag) { - if (ObjectUtil.isEmpty(feefbackdto)) { - feefbackdto = new TaskFeedbackDto(); - feefbackdto.setTask_id(entity.getTask_id()); - feefbackdto.setTask_code(entity.getTask_code()); - feefbackdto.setTask_status(entity.getTask_status()); - feefbackdto.setVehicle_type(entity.getVehicle_type()); - feefbackdto.setVehicle_code(entity.getVehicle_code()); - feefbackdto.setStart_device_code(entity.getStart_device_code()); - feefbackdto.setStart_point_code(entity.getStart_point_code()); - feefbackdto.setNext_device_code(entity.getNext_device_code()); - feefbackdto.setNext_point_code(entity.getNext_point_code()); - feefbackdto.setError_code("400"); - feefbackdto.setIs_finished("0"); - feefbackdto.setRemark(message); - taskFeedbackService.create(feefbackdto); - } else { - feefbackdto.setTask_status(entity.getTask_status()); - feefbackdto.setStart_device_code(entity.getStart_device_code()); - feefbackdto.setStart_point_code(entity.getStart_point_code()); - feefbackdto.setNext_device_code(entity.getNext_device_code()); - feefbackdto.setNext_point_code(entity.getNext_point_code()); - feefbackdto.setError_code("400"); - feefbackdto.setRemark(message); - taskFeedbackService.update(feefbackdto); - } - } else { - int status = body.getStatus(); - JSONObject jo = (JSONObject) JSONObject.toJSON(body.body()); - if (ObjectUtil.isEmpty(feefbackdto)) { - feefbackdto = new TaskFeedbackDto(); - feefbackdto.setTask_id(entity.getTask_id()); - feefbackdto.setTask_code(entity.getTask_code()); - feefbackdto.setTask_status(entity.getTask_status()); - feefbackdto.setVehicle_type(entity.getVehicle_type()); - feefbackdto.setVehicle_code(entity.getVehicle_code()); - feefbackdto.setError_code(String.valueOf(body.getStatus())); - feefbackdto.setStart_device_code(entity.getStart_device_code()); - feefbackdto.setStart_point_code(entity.getNext_point_code()); - feefbackdto.setNext_device_code(entity.getNext_device_code()); - feefbackdto.setNext_point_code(entity.getNext_point_code()); - if (status == 200) { - if (StrUtil.equals(entity.getTask_status(), "2")) { - feefbackdto.setIs_finished("1"); - } else { - feefbackdto.setIs_finished("0"); - } - } else { - feefbackdto.setIs_finished("0"); - feefbackdto.setRemark(jo.getString("message")); - } - taskFeedbackService.create(feefbackdto); - } else { - feefbackdto.setTask_status(entity.getTask_status()); - if (status == 200) { - if (StrUtil.equals(entity.getTask_status(), "2")) { - feefbackdto.setIs_finished("1"); - } else { - feefbackdto.setIs_finished("0"); - } - } else { - feefbackdto.setIs_finished("0"); - feefbackdto.setRemark(jo.getString("message")); - } - taskFeedbackService.update(feefbackdto); - } - } - - } - //如果属于先知AGV,关闭运单序列 - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "3")) { - try { - agvService.markComplete(entity.getTask_code()); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void cancel(String id) throws Exception { - TaskDto entity = this.findById(id); - if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); - InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl"); - InstructionDto instdto = instructionservice.findByTaskid(id, "instruction_status <2 "); - if (instdto != null) throw new BadRequestException("有指令未完成!"); - String currentUsername = SecurityUtils.getCurrentUsername(); - String now = DateUtil.now(); - entity.setUpdate_time(now); - entity.setUpdate_by(currentUsername); - entity.setTask_status("3"); - WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = (JSONObject) JSONObject.toJSON(entity); - wo.update(json); - //清理缓存 - for (int i = 0; i < tasks.size(); i++) { - TaskDto taskDto = tasks.get(i); - if (taskDto.getTask_id().equals(id)) { - tasks.remove(i); - } - } - //判断是否为WMS下发的任务,如果是反馈任务状态给WMS - String hasWms = acsConfigService.findConfigFromCache().get(AcsConfig.HASWMS); - if (!StrUtil.startWith(entity.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { - JSONObject feed_jo = new JSONObject(); - feed_jo.put("ext_task_uuid", entity.getExt_task_uuid()); - feed_jo.put("task_code", entity.getTask_code()); - feed_jo.put("task_status", entity.getTask_status()); - JSONArray ja = new JSONArray(); - ja.add(feed_jo); - acstowmsService.feedbackTaskStatusToWms(ja); - } - List shortPathsList = routeLineService.getShortPathLines(entity.getStart_device_code(), entity.getNext_device_code(), entity.getRoute_plan_code()); - String type = shortPathsList.get(0).getType(); - // != 0 为agv任务 - if (!StrUtil.equals(type, "0")) { - if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.AGVTYPE).toString(), "3")) { - agvService.markComplete(entity.getTask_code()); - } - } - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void createInst(String ids) throws Exception { - TaskDto acsTask = this.findById(ids); - if (acsTask == null) throw new BadRequestException("被删除或无权限,操作失败!"); - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigService.class); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl"); - InstructionDto inst = instructionservice.findByTaskid(ids, "instruction_status < 2 "); - if (inst != null) throw new BadRequestException("有指令未完成!"); - - String taskid = acsTask.getTask_id(); - String taskcode = acsTask.getTask_code(); - String vehiclecode = acsTask.getVehicle_code(); - String priority = acsTask.getPriority(); - String start_point_code = acsTask.getStart_point_code(); - String start_device_code = acsTask.getStart_device_code(); - String route_plan_code = acsTask.getRoute_plan_code(); - String vehicleType = acsTask.getVehicle_type(); - //是否复合任务 =0非复合任务 - String compound_task = acsTask.getCompound_task(); - String next_point_code = acsTask.getNext_point_code(); - String next_device_code = acsTask.getNext_device_code(); - String maxInstnumber = acsConfigService.findConfigFromCache().get(AcsConfig.MAXINSTNUMBER); - - /** - * 开始平均分解校验 - */ - String this_device_code = this.queryAssignedByDevice(acsTask.getStart_device_code(), acsTask.getNext_device_code()); - if (StrUtil.isEmpty(this_device_code)) { - List shortPathsList = routeLineService.getShortPathLines(start_device_code, acsTask.getNext_device_code(), route_plan_code); - RouteLineDto routeLineDto = shortPathsList.get(0); - String path = routeLineDto.getPath(); - String type = routeLineDto.getType(); - String[] str = path.split("->"); - List pathlist = Arrays.asList(str); - int index = 0; - for (int m = 0; m < pathlist.size(); m++) { - if (pathlist.get(m).equals(start_device_code)) { - index = m + 1; - break; - } - } - next_device_code = pathlist.get(index); - } else { - next_device_code = this_device_code; - } - - if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) { - next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z(); - } else { - next_point_code = next_device_code; - } - - Instruction instdto = new Instruction(); - instdto.setInstruction_type(acsTask.getTask_type()); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setRoute_plan_code(route_plan_code); - instdto.setRemark(acsTask.getRemark()); - instdto.setMaterial(acsTask.getMaterial()); - instdto.setQuantity(acsTask.getQuantity()); - instdto.setTask_id(taskid); - instdto.setTask_code(taskcode); - instdto.setVehicle_code(vehiclecode); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by("auto"); - instdto.setStart_device_code(start_device_code); - instdto.setNext_device_code(next_device_code); - instdto.setStart_point_code(start_point_code); - instdto.setNext_point_code(next_point_code); - instdto.setPriority(priority); - instdto.setInstruction_status("0"); - instdto.setExecute_device_code(start_point_code); - instdto.setVehicle_type(vehicleType); - - instructionservice.create(instdto); - } - - @Override - public void download(List all, HttpServletResponse response) throws IOException { - List> list = new ArrayList<>(); - for (TaskDto acsTask : all) { - Map map = new LinkedHashMap<>(); - map.put("任务号", acsTask.getTask_code()); - map.put("载具号", acsTask.getVehicle_code()); - map.put("载具类型", acsTask.getVehicle_type()); - map.put("任务类型", acsTask.getTask_type()); - map.put("任务状态", acsTask.getTask_status()); - map.put("任务优先级", acsTask.getPriority()); - map.put("创建类型", acsTask.getCreate_type()); - map.put("完成类型", acsTask.getFinish_type()); - map.put("执行描述编码", acsTask.getExecute_code()); - map.put("执行描述信息", acsTask.getExecute_message()); - map.put("起始点位编码", acsTask.getStart_point_code()); - map.put("起始设备编码", acsTask.getStart_device_code()); - map.put("目标点位编码", acsTask.getNext_point_code()); - map.put("目标设备编码", acsTask.getNext_device_code()); - map.put("排", acsTask.getFrom_x()); - map.put("列", acsTask.getFrom_y()); - map.put("层", acsTask.getFrom_z()); - map.put("排", acsTask.getTo_x()); - map.put("列", acsTask.getTo_y()); - map.put("层", acsTask.getTo_z()); - map.put("路由方案名称", acsTask.getRoute_plan_name()); - map.put("路由方案编码", acsTask.getRoute_plan_code()); - map.put("是否需要反馈上位系统", acsTask.getIs_needfeedback()); - map.put("备注", acsTask.getRemark()); - map.put("是否启用", acsTask.getIs_active()); - map.put("是否删除", acsTask.getIs_delete()); - map.put("创建者", acsTask.getCreate_by()); - map.put("创建时间", acsTask.getCreate_time()); - map.put("修改者", acsTask.getUpdate_by()); - map.put("修改时间", acsTask.getUpdate_time()); - list.add(map); - } - FileUtil.downloadExcel(list, response); - } - - @Override - public void createTaskByClick(JSONObject json) { - String device_code = json.getString("device_code"); - String type = json.getString("type"); - Device device = deviceAppService.findDeviceByCode(device_code); - if (ObjectUtil.isNull(device)) { - return; - } - StandardInspectSiteDeviceDriver deviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); - if (ObjectUtil.isNull(deviceDriver)) { - return; - } - //type=1 叫料 2 搬运任务 - if (StrUtil.equals(type, "1")) { - Boolean is_applyMaterial = deviceDriver.getApply_material(); - //未生成任务 - if (!is_applyMaterial) { - deviceDriver.setApply_material(true); - } - } else { - Boolean is_applyHandling = deviceDriver.getApply_handling(); - //未生成任务 - if (!is_applyHandling) { - deviceDriver.setApply_handling(true); - } - } - } - - @Override - public int checkAllowCreate(String devicecode) { - Map map = new HashMap(); - List taskList = this.queryAllUnfinished(map); - int num = 0; - for (int i = 0; i < taskList.size(); i++) { - TaskDto onetask = taskList.get(i); - String next_code = onetask.getNext_point_code(); - if (StrUtil.equals(devicecode, next_code)) { - num = num + 1; - } - } - return num; - } - - @Override - public boolean removeByCodeFromCache(String code) { - Iterator iterator = tasks.iterator(); - while (iterator.hasNext()) { - TaskDto task = iterator.next(); - if (task.getTask_code().equals(code)) { - iterator.remove(); - return true; - } - } - return false; - } - - @Override - public List findAllTaskFromCache() { - return tasks; - } - - - public TaskDto findByContainer(String container_code) { - Iterator var3 = tasks.iterator(); - - while (var3.hasNext()) { - TaskDto task = (TaskDto) var3.next(); - if (StrUtil.equals(task.getVehicle_code(), container_code)) { - return task; - } - } - - return null; - } - - public TaskDto findByCodeFromCache(String task_code) { - Iterator var3 = tasks.iterator(); - - while (var3.hasNext()) { - TaskDto task = (TaskDto) var3.next(); - if (StrUtil.equals(task.getTask_code(), task_code)) { - return task; - } - } - return null; - } - - @Override - public TaskDto findByNextCode(String device_code) { - Iterator var3 = tasks.iterator(); - - while (var3.hasNext()) { - TaskDto task = (TaskDto) var3.next(); - if (StrUtil.equals(task.getNext_device_code(), device_code)) { - return task; - } - } - return null; - } - - @Override - public TaskDto findByStartCode(String device_code) { - Iterator var3 = tasks.iterator(); - - while (var3.hasNext()) { - TaskDto task = (TaskDto) var3.next(); - if (StrUtil.equals(task.getStart_device_code(), device_code)) { - return task; - } - } - return null; - } - - @Override - public TaskDto foramte(TaskDto task) { - String start_point_code = task.getStart_point_code(); - String next_point_code = task.getNext_point_code(); - String from_y = null; - String from_z = null; - String to_y = null; - String to_z = null; - if (StrUtil.contains(start_point_code, "-") && StrUtil.count(start_point_code, "-") == 2) { - String[] start_point = start_point_code.split("-"); - task.setFrom_x(start_point[0]); - task.setStart_device_code(start_point[0]); - if (Integer.parseInt(start_point[1]) < 10 && start_point[1].length() == 1) { - from_y = "0" + start_point[1]; - task.setFrom_y(from_y); - } else { - from_y = start_point[1]; - task.setFrom_y(from_y); - } - if (Integer.parseInt(start_point[2]) < 10 && start_point[2].length() == 1) { - from_z = "0" + start_point[2]; - task.setFrom_z(from_z); - } else { - from_z = start_point[2]; - } - task.setStart_point_code(task.getStart_device_code() + "-" + from_y + "-" + from_z); - task.setStart_device_code(task.getStart_device_code()); - - } else { - String start_device = deviceAppService.findDeviceByCode(start_point_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(); - //如果point_device为货架,则不包含列层信息,需要重新拼接 - if (StrUtil.equals("storage", start_device)) { - if (StrUtil.isEmpty(task.getFrom_x())) { - throw new BadRequestException("货位信息起点需要包含列信息"); - } - if (StrUtil.isEmpty(task.getFrom_y())) { - throw new BadRequestException("货位信息起点需要包含层信息"); - } - if (Integer.parseInt(task.getFrom_y()) < 10 && task.getFrom_y().length() == 1) { - from_y = "0" + task.getFrom_y(); - task.setFrom_y(from_y); - } else { - from_y = task.getFrom_y(); - } - if (Integer.parseInt(task.getFrom_z()) < 10 && task.getFrom_z().length() == 1) { - from_z = "0" + task.getFrom_z(); - task.setFrom_z(from_z); - } else { - from_z = task.getFrom_z(); - } - task.setFrom_x(start_point_code); - task.setStart_point_code(start_point_code + "-" + from_y + "-" + from_z); - task.setStart_device_code(start_point_code); - } else { - task.setStart_device_code(start_point_code); - task.setStart_device_code(start_point_code); - } - } - - if (StrUtil.contains(next_point_code, "-") && StrUtil.count(next_point_code, "-") == 2) { - String[] next_point = next_point_code.split("-"); - task.setNext_device_code(next_point[0]); - task.setTo_x(next_point[0]); - if (Integer.parseInt(next_point[1]) < 10 && next_point[1].length() == 1) { - to_y = "0" + next_point[1]; - task.setTo_y(to_y); - } else { - to_y = next_point[1]; - task.setTo_y(to_y); - } - if (Integer.parseInt(next_point[2]) < 10 && next_point[2].length() == 1) { - to_z = "0" + next_point[2]; - task.setTo_z(to_z); - } else { - to_z = next_point[2]; - task.setTo_z(to_z); - } - task.setNext_point_code(task.getNext_device_code() + "-" + to_y + "-" + to_z); - task.setNext_device_code(task.getNext_device_code()); - - } else { - String next_device = deviceAppService.findDeviceByCode(next_point_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name(); - if (StrUtil.equals("storage", next_device)) { - if (StrUtil.isEmpty(task.getTo_x())) { - throw new BadRequestException("货位信息终点需要包含列信息"); - } - if (StrUtil.isEmpty(task.getTo_y())) { - throw new BadRequestException("货位信息终点需要包含层信息"); - } - if (Integer.parseInt(task.getTo_y()) < 10 && task.getTo_y().length() == 1) { - to_y = "0" + task.getTo_y(); - task.setTo_y(to_y); - } else { - to_y = task.getTo_y(); - } - if (Integer.parseInt(task.getTo_z()) < 10 && task.getTo_z().length() == 1) { - to_z = "0" + task.getTo_z(); - task.setTo_z(to_z); - } else { - to_z = task.getTo_z(); - } - task.setTo_x(next_point_code); - task.setNext_point_code(next_point_code + "-" + to_y + "-" + to_z); - task.setNext_device_code(next_point_code); - - } else { - task.setNext_device_code(next_point_code); - task.setNext_device_code(next_point_code); - - } - } - return task; - } - - @Override - public void updateByCodeFromCache(TaskDto dto) { - Iterator iterator = tasks.iterator(); - while (iterator.hasNext()) { - TaskDto task = iterator.next(); - if (task.getTask_code().equals(dto.getTask_code())) { - iterator.remove(); - } - } - tasks.add(dto); - } - - @Override - public String queryAssignedByDevice(String device_code, String task_nextdeice_code) { - List list = deviceAssignedService.queryAssignedBydevice(device_code, task_nextdeice_code); - int flag1 = 0; - String flag2 = null; - for (int i = 0; i < list.size(); i++) { - DeviceAssignedDto dto = list.get(i); - String inst_nextDevice_code = dto.getInst_nextdevice_code(); - String task_nextDevice_code = dto.getTask_nextdevice_code(); - String param = dto.getParam(); - JSONObject jo = JSON.parseObject(param); - String regEx = "[`~!@#$%^&*()+=|{}':;'\\[\\].<>/?~!@#¥%……&*()——+|{}【】':”“’。、?]"; - Pattern p = Pattern.compile(regEx); - Matcher m = p.matcher(inst_nextDevice_code); - String toSpeechText = m.replaceAll("").trim(); - - String[] str = toSpeechText.split(","); - List pathlist = Arrays.asList(str); - for (int j = 0; j < pathlist.size(); j++) { - String this_device_code = pathlist.get(j).toString(); - JSONObject data = JSON.parseObject(jo.getString(this_device_code)); - String limit = data.getString("limit"); - int num = instructionService.querySameDestinationInst(this_device_code); - if (num >= Integer.parseInt(limit)) { - continue; - } - if (j == 0) { - flag1 = num; - } - if (num <= flag1) { - flag2 = this_device_code; - } - } - - } - if (!StrUtil.isEmpty(flag2)) { - return flag2; - } - return null; - } - - @Override - public Integer querySameTaskByType(String taskType) { - int num = 0; - Iterator iterator = tasks.iterator(); - while (iterator.hasNext()) { - TaskDto task = iterator.next(); - if (task.getTask_type().equals(taskType) && task.getTask_status().equals("1")) { - num++; - } - } - - return num; - } - -} diff --git a/nladmin-system/src/main/java/org/nl/acs/task/service/wql/QTASK_QUERY.wql b/nladmin-system/src/main/java/org/nl/acs/task/service/wql/QTASK_QUERY.wql deleted file mode 100644 index dbd0efd..0000000 --- a/nladmin-system/src/main/java/org/nl/acs/task/service/wql/QTASK_QUERY.wql +++ /dev/null @@ -1,115 +0,0 @@ -[交易说明] - 交易名: 手持接口查询 - 所属模块: - 功能简述: - 版权所有: - 表引用: - 版本经历: - -[数据库] - --指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 - -[IO定义] - ################################################# - ## 表字段对应输入参数 - ################################################# - 输入.flag TYPEAS s_string - 输入.task_code TYPEAS s_string - 输入.vehicle_code TYPEAS s_string - 输入.material_type TYPEAS s_string - 输入.status TYPEAS s_string - 输入.point_code TYPEAS s_string - 输入.is_over TYPEAS s_string - 输入.create_time TYPEAS time - 输入.end_time TYPEAS time -[临时表] - --这边列出来的临时表就会在运行期动态创建 - -[临时变量] - --所有中间过程变量均可在此处定义 - -[业务过程] - - ########################################## - # 1、输入输出检查 # - ########################################## - - - ########################################## - # 2、主过程前处理 # - ########################################## - - - ########################################## - # 3、业务主过程 # - ########################################## - IF 输入.flag = "1" - PAGEQUERY - SELECT - * - FROM - acs_task task - WHERE - 1=1 - OPTION 输入.is_over = "1" - task.task_status >= 2 - ENDOPTION - OPTION 输入.is_over <> "1" - task.task_status < 2 - ENDOPTION - OPTION 输入.task_code <> "" - task.task_code = 输入.task_code - ENDOPTION - OPTION 输入.status <> "" - task.task_status = 输入.status - ENDOPTION - OPTION 输入.vehicle_code <> "" - task.vehicle_code = 输入.vehicle_code - ENDOPTION - OPTION 输入.material_type <> "" - task.material = 输入.material_type - ENDOPTION - OPTION 输入.point_code <> "" - ( - task.start_point_code = 输入.point_code - OR - task.next_point_code = 输入.point_code - ) - ENDOPTION - ENDSELECT - ENDPAGEQUERY - ENDIF - -IF 输入.flag = "2" - PAGEQUERY - SELECT - * - FROM - acs_task task - WHERE - 1=1 - OPTION 输入.task_code <> "" - task.task_code = 输入.task_code - ENDOPTION - OPTION 输入.status <> "" - task.task_status = 输入.status - ENDOPTION - OPTION 输入.vehicle_code <> "" - task.vehicle_code = 输入.vehicle_code - ENDOPTION - OPTION 输入.material_type <> "" - task.material = 输入.material_type - ENDOPTION - OPTION 输入.point_code <> "" - ( - task.start_point_code = 输入.point_code - OR - task.next_point_code = 输入.point_code - ) - ENDOPTION - OPTION 输入.create_time <> "" - task.create_time between 输入.create_time and 输入.end_time - ENDOPTION - ENDSELECT - ENDPAGEQUERY - ENDIF \ No newline at end of file diff --git a/nladmin-system/src/main/java/org/nl/hand/ndxytwo/rest/NdxyHandTwoController.java b/nladmin-system/src/main/java/org/nl/hand/ndxytwo/rest/NdxyHandTwoController.java deleted file mode 100644 index 12e5084..0000000 --- a/nladmin-system/src/main/java/org/nl/hand/ndxytwo/rest/NdxyHandTwoController.java +++ /dev/null @@ -1,157 +0,0 @@ - -package org.nl.hand.ndxytwo.rest; - - -import com.alibaba.fastjson.JSONObject; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.nl.annotation.Log; -import org.nl.annotation.rest.AnonymousPostMapping; -import org.nl.hand.ndxytwo.service.NdxyTwoHandService; -import org.nl.modules.system.service.UserService; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.Map; - -/** - * @author qxuan - * @date 2021-07-21 - **/ -@RestController -@RequiredArgsConstructor -@Api(tags = "纽迪希亚手持接口") -@RequestMapping("/api/andxy2/hand") -@Slf4j -public class NdxyHandTwoController { - private final PasswordEncoder passwordEncoder; - private final UserService userService; - private final NdxyTwoHandService HandService; - - @PostMapping("/area") - @Log("查询区域") - @ApiOperation("查询区域") - //@PreAuthorize("@el.check('sect:list')") - public ResponseEntity query(@RequestBody Map whereJson) { - return new ResponseEntity<>(HandService.queryArea(whereJson), HttpStatus.OK); - } - - @PostMapping("/point") - @Log("查询设备编号及状态") - @ApiOperation("查询设备编号及状态") - //@PreAuthorize("@el.check('sect:list')") - //@RequestBody JSONObject json - public ResponseEntity queryPoint(@RequestBody Map whereJson) { - return new ResponseEntity<>(HandService.queryPointByArea(whereJson), HttpStatus.OK); - } - - @PostMapping("/point/storage") - @Log("查询设备扩展属性") - @ApiOperation("查询设备扩展属性") - //@PreAuthorize("@el.check('sect:list')") - //@RequestBody JSONObject json - public ResponseEntity queryDeviceAugmentabilityByCode(@RequestBody Map whereJson) { - return new ResponseEntity<>(HandService.queryDeviceAugmentabilityByCode(whereJson), HttpStatus.OK); - } - - @PostMapping("/task_type") - @Log("查询任务类型") - @ApiOperation("查询任务类型") - //@PreAuthorize("@el.check('sect:list')") - //@RequestBody JSONObject json - public ResponseEntity queryTaskType() { - return new ResponseEntity<>(HandService.queryTaskType(), HttpStatus.OK); - } - - @PostMapping("/tasks") - @Log("查询任务") - @ApiOperation("查询任务") - //@PreAuthorize("@el.check('sect:list')") - public ResponseEntity queryTask(@RequestBody Map whereJson) { - - return new ResponseEntity<>(HandService.queryTask(whereJson), HttpStatus.OK); - } - - @PostMapping("/insts") - @Log("查询指令") - @ApiOperation("查询指令") - //@PreAuthorize("@el.check('sect:list')") - public ResponseEntity queryInst(@RequestBody Map whereJson) { - - return new ResponseEntity<>(HandService.queryInst(whereJson), HttpStatus.OK); - } - - @PostMapping("/routeplan_type") - @Log("查询路由类型") - @ApiOperation("查询路由类型") - //@PreAuthorize("@el.check('sect:list')") - public ResponseEntity queryRouteplanType() { - return new ResponseEntity<>(HandService.queryRouteplanType(), HttpStatus.OK); - } - - @AnonymousPostMapping("/task") - @Log("创建特殊任务") - @ApiOperation("创建特殊任务") - //@PreAuthorize("@el.check('sect:list')") - public ResponseEntity createTask(@RequestBody JSONObject whereJson) { - return new ResponseEntity<>(HandService.createTask(whereJson), HttpStatus.OK); - } - - @PostMapping("/inst") - @Log("指令操作") - @ApiOperation("指令操作") - //@PreAuthorize("@el.check('sect:list')") - public ResponseEntity Instoperation(@RequestBody Map whereJson) { - return new ResponseEntity<>(HandService.Instoperation(whereJson), HttpStatus.OK); - } - - @PostMapping("/taskoperation") - @Log("任务操作") - @ApiOperation("任务操作") - //@PreAuthorize("@el.check('sect:list')") - public ResponseEntity Taskoperation(@RequestBody Map whereJson) throws Exception { - return new ResponseEntity<>(HandService.Taskoperation(whereJson), HttpStatus.OK); - } - - @PostMapping("/deviceStatus") - @Log("修改设备状态") - @ApiOperation("修改设备状态") - //@PreAuthorize("@el.check('sect:list')") - public ResponseEntity updateDeviceStatus(@RequestBody Map whereJson) { - - return new ResponseEntity<>(HandService.updateDeviceStatus(whereJson), HttpStatus.OK); - } - - @PostMapping("/handlogin") - @Log("手持登陆验证") - @ApiOperation("手持登陆验证") - //@PreAuthorize("@el.check('sect:list')") - public ResponseEntity handlogin(@RequestBody Map whereJson) { - - return new ResponseEntity<>(HandService.handleLogin(whereJson), HttpStatus.OK); - } - - @PostMapping("/matrial") - @Log("查询物料信息") - @ApiOperation("查询物料信息") - //@PreAuthorize("@el.check('sect:list')") - public ResponseEntity queryMaterial() { - return new ResponseEntity<>(HandService.queryMaterial(), HttpStatus.OK); - } - - @AnonymousPostMapping("/task2") - @Log("创建普通任务") - @ApiOperation("创建普通任务") - //@PreAuthorize("@el.check('sect:list')") - public ResponseEntity createTask2(@RequestBody JSONObject whereJson) { - return new ResponseEntity<>(HandService.createTask2(whereJson), HttpStatus.OK); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/hand/ndxytwo/service/NdxyTwoHandService.java b/nladmin-system/src/main/java/org/nl/hand/ndxytwo/service/NdxyTwoHandService.java deleted file mode 100644 index e775387..0000000 --- a/nladmin-system/src/main/java/org/nl/hand/ndxytwo/service/NdxyTwoHandService.java +++ /dev/null @@ -1,122 +0,0 @@ - -package org.nl.hand.ndxytwo.service; - - -import com.alibaba.fastjson.JSONObject; - -import java.util.Map; - -/** - * @author qxuan - * @description 服务接口 - * @date 2021-07-21 - **/ -public interface NdxyTwoHandService { - - /** - * 查询区域 - * - * @param whereJson 条件 - * @return Map - */ - Map queryArea(Map whereJson); - - /** - * 查询设备编号及状态 - * - * @return Map - */ - Map queryPointByArea(Map whereJson); - - /** - * 查询设备扩展性 - * - * @param deviceCode - * @return - */ - Map queryDeviceAugmentabilityByCode(Map deviceCode); - - /** - * 查询任务状态 - * - * @return - */ - Map queryTaskType(); - - /** - * 查询路由类型 - * - * @return - */ - Map queryRouteplanType(); - - /** - * 查询指令 - * - * @param jsonObject 条件 - * @return Map - */ - Map queryInst(Map jsonObject); - - /** - * 创建特殊任务 - * - * @param jsonObject 条件 - * @return JSONObject - */ - Map createTask(JSONObject jsonObject); - - /** - * 查询任务 - * - * @param jsonObject 条件 - * @return Map - */ - Map queryTask(Map jsonObject); - - /** - * 修改设备状态 - * - * @param jsonObject 条件 - * @return Map - */ - Map updateDeviceStatus(Map jsonObject); - - /** - * 手持登陆 - * - * @param jsonObject 条件 - * @return Map - */ - Map handleLogin(Map jsonObject); - - /** - * 指令操作 - * - * @param jsonObject 条件 - * @return Map - */ - Map Instoperation(Map jsonObject); - - /** - * 任务操作 - * - * @param jsonObject 条件 - * @return Map - */ - Map Taskoperation(Map jsonObject) throws Exception; - - /** - * 查询物料 - * - * @return Map - */ - Map queryMaterial(); - - /** - * 创建普通任务 - * - * @return Map - */ - Map createTask2(JSONObject whereJson); -} diff --git a/nladmin-system/src/main/java/org/nl/hand/ndxytwo/service/dto/HandDto.java b/nladmin-system/src/main/java/org/nl/hand/ndxytwo/service/dto/HandDto.java deleted file mode 100644 index a66d372..0000000 --- a/nladmin-system/src/main/java/org/nl/hand/ndxytwo/service/dto/HandDto.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.nl.hand.ndxytwo.service.dto; - -import lombok.Data; - -import java.io.Serializable; -import java.math.BigDecimal; - -/** - * @author qxuan - * @description / - * @date 2021-07-21 - **/ -@Data -public class HandDto implements Serializable { - - /** - * 库区标识 - */ - private String sect_uuid; - - /** - * 库区编码 - */ - private String sect_code; - - /** - * 库区名称 - */ - private String sect_name; - - /** - * 库区简称 - */ - private String simple_name; - - /** - * 库区类型 - */ - private String sect_type; - - /** - * 顺序号 - */ - private BigDecimal order_seq; - - /** - * 仓库标识 - */ - private String store_uuid; - - /** - * 是否启用 - */ - private String is_active; - - /** - * 是否删除 - */ - private String is_delete; - - /** - * 创建者 - */ - private String create_by; - - /** - * 创建时间 - */ - private String create_time; - - /** - * 修改者 - */ - private String update_by; - - /** - * 修改时间 - */ - private String update_time; -} diff --git a/nladmin-system/src/main/java/org/nl/hand/ndxytwo/service/impl/NdxyTwoHandServiceImpl.java b/nladmin-system/src/main/java/org/nl/hand/ndxytwo/service/impl/NdxyTwoHandServiceImpl.java deleted file mode 100644 index 8b7e7fa..0000000 --- a/nladmin-system/src/main/java/org/nl/hand/ndxytwo/service/impl/NdxyTwoHandServiceImpl.java +++ /dev/null @@ -1,994 +0,0 @@ - -package org.nl.hand.ndxytwo.service.impl; - - -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -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 lombok.RequiredArgsConstructor; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.agv.server.impl.AgvServiceImpl; -import org.nl.acs.config.rest.AcsConfigController; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device.service.dto.DeviceDto; -import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.instruction.service.dto.InstructionDto; -import org.nl.acs.instruction.service.impl.InstructionServiceImpl; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.acs.route.service.RouteLineService; -import org.nl.acs.task.service.TaskService; -import org.nl.acs.task.service.dto.TaskDto; -import org.nl.acs.task.service.impl.TaskServiceImpl; -import org.nl.config.RsaProperties; -import org.nl.exception.BadRequestException; -import org.nl.hand.ndxytwo.service.NdxyTwoHandService; -import org.nl.modules.system.service.UserService; -import org.nl.modules.system.service.dto.UserDto; -import org.nl.modules.system.util.CodeUtil; -import org.nl.utils.RsaUtils; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.WQL; -import org.nl.wql.core.bean.WQLObject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.stereotype.Service; - -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - - -/** - * @author qxuan - * @description 服务实现 - * @date 2021-07-21 - **/ -@Service -@RequiredArgsConstructor -@Slf4j -public class NdxyTwoHandServiceImpl implements NdxyTwoHandService { - private final UserService userService; - private final PasswordEncoder passwordEncoder; - private final DeviceService deviceService; - private final DeviceAppService deviceAppService; - private final RouteLineService routelineserver; - private final TaskService taskService; - - @Autowired - AcsConfigController acsConfigService; - InstructionService instructionService = null; - - - @Override - public Map queryArea(Map map) { - String type = map.get("type").toString(); - JSONArray resultJSONArray; - if (StrUtil.equals(type,"1")) { - resultJSONArray = WQL.getWO("QNDXY_QUERY003").addParam("flag", "6").process().getResultJSONArray(0); - } else if (StrUtil.equals(type,"2")) { - resultJSONArray = WQL.getWO("QNDXY_QUERY003").addParam("flag", "7").process().getResultJSONArray(0); - } else { - resultJSONArray = WQL.getWO("QNDXY_QUERY003").addParam("flag", "1").process().getResultJSONArray(0); - } - JSONObject jo = new JSONObject(); - jo.put("code", "1"); - jo.put("desc", "查询成功"); - jo.put("result", resultJSONArray); - return jo; - } - - @Override - public Map queryPointByArea(Map map) { - String region = map.get("region").toString(); - JSONArray resultArr = new JSONArray(); - JSONObject resultJson = new JSONObject(); - ; - - String status = ""; - String move = ""; - String quantity = ""; - String input_material = ""; - String remark = ""; - String material = ""; - String status_name = ""; - - if (StrUtil.equals(region, "90")) { - JSONArray acs_deviceja = WQLObject.getWQLObject("acs_device").query("region = '1'", "seq_num,device_name").getResultJSONArray(0); - - for (int i = 0; i < acs_deviceja.size(); i++) { - JSONObject jo = new JSONObject(); - JSONObject devicejo = acs_deviceja.getJSONObject(i); - String device_code = devicejo.getString("device_code"); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device device = appService.findDeviceByCode(device_code); - - //普通站点 - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - - if (device == null) { - jo.put("status", status); - jo.put("device_id", devicejo.getString("device_id")); - jo.put("device_code", devicejo.getString("device_code")); - jo.put("device_name", devicejo.getString("device_code")); - jo.put("allow_update", "1"); - } else { - //检测站点 - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - - if (StrUtil.equals(device.getIslock(), "true")) { - status = "3"; - move = "有任务"; - } else { - if (standardOrdinarySiteDeviceDriver.getHasGoods() == 0) { - status = "0"; - move = "无货"; - } else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 1) { - status = "1"; - move = "空载具"; - } else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 2) { - status = "2"; - move = "有托盘有货"; - } else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 3) { - status = "3"; - move = "有任务"; - } - } - material = device.getMaterial_type(); - if (StrUtil.isNullOrUndefined(material)) { - material = ""; - } - quantity = device.getQuantity(); - if (StrUtil.isNullOrUndefined(quantity)) { - quantity = ""; - } - String input_materialflag = (String) device.getExtraValue().get("input_material"); - if (!StrUtil.isEmpty(input_materialflag) && input_materialflag.equals("false")) { - input_material = "0"; - } - if (!StrUtil.isEmpty(input_materialflag) && input_materialflag.equals("true")) { - input_material = "1"; - } - jo.put("material_type", material); - jo.put("quantity", quantity); - jo.put("remark", device.getRemark()); - jo.put("status_name", move); - jo.put("status", status); - jo.put("device_id", devicejo.getString("device_id")); - jo.put("device_code", devicejo.getString("device_code")); - jo.put("device_name", devicejo.getString("device_name")); - jo.put("allow_update", "1"); - jo.put("input_material", input_material); - jo.put("device_type", devicejo.getString("device_type")); - resultArr.add(jo); - } - } - } - } else if (StrUtil.equals(region,"91")) { - JSONArray acs_deviceja = WQLObject.getWQLObject("acs_device").query("region = '2'", "seq_num,device_name").getResultJSONArray(0); - - for (int i = 0; i < acs_deviceja.size(); i++) { - JSONObject jo = new JSONObject(); - JSONObject devicejo = acs_deviceja.getJSONObject(i); - String device_code = devicejo.getString("device_code"); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device device = appService.findDeviceByCode(device_code); - - //普通站点 - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - - if (device == null) { - jo.put("status", status); - jo.put("device_id", devicejo.getString("device_id")); - jo.put("device_code", devicejo.getString("device_code")); - jo.put("device_name", devicejo.getString("device_code")); - jo.put("allow_update", "1"); - } else { - //检测站点 - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - - if (StrUtil.equals(device.getIslock(), "true")) { - status = "3"; - move = "有任务"; - } else { - if (standardOrdinarySiteDeviceDriver.getHasGoods() == 0) { - status = "0"; - move = "无货"; - } else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 1) { - status = "1"; - move = "空载具"; - } else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 2) { - status = "2"; - move = "有托盘有货"; - } else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 3) { - status = "3"; - move = "有任务"; - } - } - material = device.getMaterial_type(); - if (StrUtil.isNullOrUndefined(material)) { - material = ""; - } - quantity = device.getQuantity(); - if (StrUtil.isNullOrUndefined(quantity)) { - quantity = ""; - } - String input_materialflag = (String) device.getExtraValue().get("input_material"); - if (!StrUtil.isEmpty(input_materialflag) && input_materialflag.equals("false")) { - input_material = "0"; - } - if (!StrUtil.isEmpty(input_materialflag) && input_materialflag.equals("true")) { - input_material = "1"; - } - jo.put("material_type", material); - jo.put("quantity", quantity); - jo.put("remark", device.getRemark()); - jo.put("status_name", move); - jo.put("status", status); - jo.put("device_id", devicejo.getString("device_id")); - jo.put("device_code", devicejo.getString("device_code")); - jo.put("device_name", devicejo.getString("device_name")); - jo.put("allow_update", "1"); - jo.put("input_material", input_material); - jo.put("device_type", devicejo.getString("device_type")); - resultArr.add(jo); - } - } - } - } else if (StrUtil.equals(region,"92")) { - JSONArray acs_deviceja = WQLObject.getWQLObject("acs_device").query("region = '3'", "seq_num,device_name").getResultJSONArray(0); - - for (int i = 0; i < acs_deviceja.size(); i++) { - JSONObject jo = new JSONObject(); - JSONObject devicejo = acs_deviceja.getJSONObject(i); - String device_code = devicejo.getString("device_code"); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device device = appService.findDeviceByCode(device_code); - - //普通站点 - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - - if (device == null) { - jo.put("status", status); - jo.put("device_id", devicejo.getString("device_id")); - jo.put("device_code", devicejo.getString("device_code")); - jo.put("device_name", devicejo.getString("device_code")); - jo.put("allow_update", "1"); - } else { - //检测站点 - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - - if (StrUtil.equals(device.getIslock(), "true")) { - status = "3"; - move = "有任务"; - } else { - if (standardOrdinarySiteDeviceDriver.getHasGoods() == 0) { - status = "0"; - move = "无货"; - } else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 1) { - status = "1"; - move = "空载具"; - } else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 2) { - status = "2"; - move = "有托盘有货"; - } else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 3) { - status = "3"; - move = "有任务"; - } - } - material = device.getMaterial_type(); - if (StrUtil.isNullOrUndefined(material)) { - material = ""; - } - quantity = device.getQuantity(); - if (StrUtil.isNullOrUndefined(quantity)) { - quantity = ""; - } - String input_materialflag = (String) device.getExtraValue().get("input_material"); - if (!StrUtil.isEmpty(input_materialflag) && input_materialflag.equals("false")) { - input_material = "0"; - } - if (!StrUtil.isEmpty(input_materialflag) && input_materialflag.equals("true")) { - input_material = "1"; - } - jo.put("material_type", material); - jo.put("quantity", quantity); - jo.put("remark", device.getRemark()); - jo.put("status_name", move); - jo.put("status", status); - jo.put("device_id", devicejo.getString("device_id")); - jo.put("device_code", devicejo.getString("device_code")); - jo.put("device_name", devicejo.getString("device_name")); - jo.put("allow_update", "1"); - jo.put("input_material", input_material); - jo.put("device_type", devicejo.getString("device_type")); - resultArr.add(jo); - } - } - } - } - else if (StrUtil.equals(region,"98")) { - JSONArray acs_deviceja = WQLObject.getWQLObject("acs_device").query("region = '4'", "seq_num,device_name").getResultJSONArray(0); - - for (int i = 0; i < acs_deviceja.size(); i++) { - JSONObject jo = new JSONObject(); - JSONObject devicejo = acs_deviceja.getJSONObject(i); - String device_code = devicejo.getString("device_code"); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device device = appService.findDeviceByCode(device_code); - - //普通站点 - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - - if (device == null) { - jo.put("status", status); - jo.put("device_id", devicejo.getString("device_id")); - jo.put("device_code", devicejo.getString("device_code")); - jo.put("device_name", devicejo.getString("device_code")); - jo.put("allow_update", "1"); - } else { - //检测站点 - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - - if (StrUtil.equals(device.getIslock(), "true")) { - status = "3"; - move = "有任务"; - } else { - if (standardOrdinarySiteDeviceDriver.getHasGoods() == 0) { - status = "0"; - move = "无货"; - } else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 1) { - status = "1"; - move = "空载具"; - } else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 2) { - status = "2"; - move = "有托盘有货"; - } else if (standardOrdinarySiteDeviceDriver.getHasGoods() == 3) { - status = "3"; - move = "有任务"; - } - } - material = device.getMaterial_type(); - if (StrUtil.isNullOrUndefined(material)) { - material = ""; - } - quantity = device.getQuantity(); - if (StrUtil.isNullOrUndefined(quantity)) { - quantity = ""; - } - String input_materialflag = (String) device.getExtraValue().get("input_material"); - if (!StrUtil.isEmpty(input_materialflag) && input_materialflag.equals("false")) { - input_material = "0"; - } - if (!StrUtil.isEmpty(input_materialflag) && input_materialflag.equals("true")) { - input_material = "1"; - } - jo.put("material_type", material); - jo.put("quantity", quantity); - jo.put("remark", device.getRemark()); - jo.put("status_name", move); - jo.put("status", status); - jo.put("device_id", devicejo.getString("device_id")); - jo.put("device_code", devicejo.getString("device_code")); - jo.put("device_name", devicejo.getString("device_name")); - jo.put("allow_update", "1"); - jo.put("input_material", input_material); - jo.put("device_type", devicejo.getString("device_type")); - resultArr.add(jo); - } - } - } - } - resultJson.put("code", "1"); - resultJson.put("desc", "查询成功"); - resultJson.put("result", resultArr); - return resultJson; - } - - @Override - public Map queryDeviceAugmentabilityByCode(Map whereMap) { - String deviceCode = whereMap.get("device_code").toString(); - JSONObject resultJson = new JSONObject(); - JSONObject jo = new JSONObject(); - JSONObject acs_device = WQLObject.getWQLObject("ACS_DEVICE").query("device_code = '" + deviceCode + "'").pageResult(); - JSONObject acsDevice = (JSONObject) acs_device.getJSONArray("content").get(0); - //判断设备类型是不是storage - if (!"storage".equals(acsDevice.getString("device_type"))) { - resultJson.put("code", "0"); - resultJson.put("desc", "该设备不是货架"); - resultJson.put("result", ""); - return resultJson; - } - JSONObject jsonObject = deviceService.queryStorageExtra(deviceCode); - jo.put("device_id", acsDevice.getString("device_id")); - jo.put("device_code", deviceCode); - jo.put("device_name", acsDevice.getString("device_name")); - jo.put("device_type", acsDevice.getString("device_type")); - jo.put("maxY", jsonObject.getString("maxY")); - jo.put("minY", jsonObject.getString("minY")); - jo.put("maxZ", jsonObject.getString("maxZ")); - jo.put("minZ", jsonObject.getString("minZ")); - - resultJson.put("code", "1"); - resultJson.put("desc", "查询成功"); - resultJson.put("result", jo); - return resultJson; - } - - @Override - public Map queryRouteplanType() { - JSONObject resultJson = new JSONObject(); - JSONObject jo = WQLObject.getWQLObject("acs_route_plan").query().pageResult(); - JSONArray arr = new JSONArray(); - JSONArray content = jo.getJSONArray("content"); - for (int i = 0; i < content.size(); i++) { - JSONObject jsonObject = (JSONObject) content.get(i); - JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("value", jsonObject.getString("plan_code")); - jsonObject1.put("label", jsonObject.getString("plan_name")); - arr.add(jsonObject1); - } - resultJson.put("code", "1"); - resultJson.put("desc", "查询成功"); - resultJson.put("result", arr); - return resultJson; - } - - @Override - public Map queryTaskType() { - JSONObject resultJson = new JSONObject(); - JSONObject jo = WQLObject.getWQLObject("sys_dict_detail").query("name = 'task_type'").pageResult(); - JSONArray arr = new JSONArray(); - JSONArray content = jo.getJSONArray("content"); - for (int i = 0; i < content.size(); i++) { - JSONObject jsonObject = (JSONObject) content.get(i); - JSONObject jsonObject1 = new JSONObject(); - jsonObject1.put("value", jsonObject.getString("value")); - jsonObject1.put("label", jsonObject.getString("label")); - arr.add(jsonObject1); - } - resultJson.put("code", "1"); - resultJson.put("desc", "查询成功"); - resultJson.put("result", arr); - return resultJson; - } - - @Override - public Map queryInst(Map jsonObject) { - //查询位完成的指令 - JSONObject resultJson = new JSONObject(); - HashMap map = new HashMap<>(); - - String key = jsonObject.get("keyword"); - String start_point = jsonObject.get("start_devicecode"); - String next_point = jsonObject.get("next_devicecode"); - map.put("flag", "4"); - if (StrUtil.isNotEmpty(key)) { - map.put("key", "%" + key + "%"); - } - if (StrUtil.isNotEmpty(start_point)) { - map.put("start_point", "%" + start_point + "%"); - } - if (StrUtil.isNotEmpty(next_point)) { - map.put("next_point", "%" + next_point + "%"); - } - JSONArray resultArr = WQL.getWO("QNDXY_QUERY003").addParamMap(map).addParamMap((HashMap) jsonObject).process().getResultJSONArray(0); - resultJson.put("code", "1"); - resultJson.put("desc", "查询成功"); - resultJson.put("result", resultArr); - return resultJson; - } - - @Override - public Map createTask(JSONObject whereJson) { - JSONArray array1 = JSONArray.parseArray(JSON.toJSONString(whereJson.get("start_devicecode"))); - JSONArray array2 = JSONArray.parseArray(JSON.toJSONString(whereJson.get("next_devicecode"))); - - JSONObject resultJson = new JSONObject(); - - boolean isPass = true; - String message = ""; - for (int i = 0; i < array1.size(); i++) { - JSONObject json = array1.getJSONObject(i); - JSONObject json2 = array2.getJSONObject(i); - String start_device_code = json.getString("device_code"); - String next_device_code = json2.getString("device_code"); - DeviceDto startDto = deviceService.findByCode(start_device_code); - DeviceDto nextDto = deviceService.findByCode(next_device_code); - - if (StrUtil.equals(startDto.getRegion(),nextDto.getRegion())) { - resultJson.put("code", "2"); - resultJson.put("desc", "起点终点不能为同一区域!"); - resultJson.put("result", ""); - return resultJson; - } - String plan_code = "two"; - if (routelineserver.getActivePathLine(start_device_code, next_device_code, plan_code).size() == 0) { - isPass = false; - message += start_device_code + "->" + next_device_code + "路由不通!"; - } - } - if (!isPass) { - resultJson.put("code", "2"); - resultJson.put("desc", message); - resultJson.put("result", ""); - return resultJson; - } - - for (int i = 0; i < array1.size(); i++) { - JSONObject arrjo1 = array1.getJSONObject(i); - JSONObject arrjo2 = array2.getJSONObject(i); - - String material_type = arrjo1.getString("material_type"); - String quantity = arrjo1.getString("quantity"); - String remark = arrjo1.getString("remark"); - String start_device_code = arrjo1.getString("device_code"); - String next_device_code = arrjo2.getString("device_code"); - Device start_device = deviceAppService.findDeviceByCode(start_device_code); - Device next_device = deviceAppService.findDeviceByCode(next_device_code); - - if (start_device.getHas_goods() == 0) { - resultJson.put("code", "2"); - resultJson.put("desc", "该起点没有货物!"); - resultJson.put("result", ""); - return resultJson; - } - if (next_device.getHas_goods() != 0) { - resultJson.put("code", "2"); - resultJson.put("desc", "该终点有货物!"); - resultJson.put("result", ""); - return resultJson; - } - TaskDto dto = new TaskDto(); - dto.setRoute_plan_code("two"); - - if (ObjectUtil.isNotEmpty(taskService.findByStartCode(start_device_code)) - || ObjectUtil.isNotEmpty(taskService.findByNextCode(next_device_code))) { - resultJson.put("code", "2"); - resultJson.put("desc", "已存在该起点或终点的任务!"); - resultJson.put("result", ""); - return resultJson; - } - if (StrUtil.equals(material_type, "") || StrUtil.equals(quantity, "")) { - resultJson.put("code", "2"); - resultJson.put("desc", "请填写物料信息!"); - resultJson.put("result", ""); - return resultJson; - } - dto.setStart_device_code(start_device_code); - dto.setStart_point_code(start_device_code); - dto.setNext_device_code(next_device_code); - dto.setNext_point_code(next_device_code); - dto.setQuantity(new BigDecimal(quantity)); - dto.setRemark(remark); - dto.setMaterial(material_type); - try { - taskService.create(dto); - } catch (Exception e) { - resultJson.put("code", "2"); - resultJson.put("desc", e.getMessage()); - resultJson.put("result", ""); - return resultJson; - } - } - resultJson.put("code", "1"); - resultJson.put("desc", "生成成功!"); - resultJson.put("result", ""); - return resultJson; - } - - @Override - public Map queryTask(Map jsonObject) { - String key = jsonObject.get("keyword"); - String start_point = jsonObject.get("start_devicecode"); - String next_point = jsonObject.get("next_devicecode"); - HashMap map = new HashMap<>(); - map.put("flag", "2"); - if (StrUtil.isNotEmpty(key)) { - map.put("key", "%" + key + "%"); - } - if (StrUtil.isNotEmpty(start_point)) { - map.put("start_point", "%" + start_point + "%"); - } - if (StrUtil.isNotEmpty(next_point)) { - map.put("next_point", "%" + next_point + "%"); - } - //查询有任务 但是没有指令的任务 - JSONArray result = WQL.getWO("QNDXY_QUERY003").addParamMap(map).process().getResultJSONArray(0); - JSONObject resultJson = new JSONObject(); - resultJson.put("code", "1"); - resultJson.put("desc", "查询成功"); - resultJson.put("result", result); - return resultJson; - } - - - @Override - public Map updateDeviceStatus(Map jsonObject) { - //修改任务的状态 - String device_code = jsonObject.get("device_code"); - String type = jsonObject.get("type"); - //需要数量 - String quantity = jsonObject.get("quantity"); - String status = jsonObject.get("status"); - //物料类型 - String material_type = jsonObject.get("material_type"); - String remark = jsonObject.get("remark"); - JSONObject resultJson = new JSONObject(); - - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - Device device = appService.findDeviceByCode(device_code); - //普通站点 - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - if (StrUtil.equals(status,"3")) { - resultJson.put("code", "2"); - resultJson.put("desc", "不可手动改为任务状态!"); - resultJson.put("result", ""); - return resultJson; - } - if (device.getHas_goods() == 3) { - resultJson.put("code", "2"); - resultJson.put("desc", "当前站点有任务,无法修改"); - resultJson.put("result", ""); - return resultJson; - } - - //修改 - if (type.equals("1")) { - //纽迪希亚专用 - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - if (Boolean.parseBoolean(device.getIslock())) { - resultJson.put("code", "0"); - resultJson.put("desc", "已有任务无法绑定!"); - resultJson.put("result", new JSONObject()); - } - standardOrdinarySiteDeviceDriver.setHasGoods(Integer.parseInt(status)); - device.setHas_goods(Integer.parseInt(status)); - standardOrdinarySiteDeviceDriver.setQty(quantity); - standardOrdinarySiteDeviceDriver.setMaterial(material_type); - standardOrdinarySiteDeviceDriver.setRemark(remark); - device.setMaterial_type(material_type); - device.setQuantity(quantity); - device.setRemark(remark); - } - } - //清空 - if (type.equals("2")) { - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - standardOrdinarySiteDeviceDriver.setHasGoods(0); - standardOrdinarySiteDeviceDriver.setQty(""); - standardOrdinarySiteDeviceDriver.setMaterial(""); - standardOrdinarySiteDeviceDriver.setRemark(""); - device.setHas_goods(0); - device.setMaterial_type(""); - device.setQuantity(""); - device.setRemark(""); - } - } - resultJson.put("code", "1"); - resultJson.put("desc", "更新成功"); - resultJson.put("result", new JSONObject()); - - return resultJson; - } - - @SneakyThrows - @Override - public Map handleLogin(Map jsonObject) { - JSONObject resultJson = new JSONObject(); - String user = jsonObject.get("user"); - String password = jsonObject.get("password"); - if (StrUtil.isEmpty("user")) { - resultJson.put("code", "1"); - resultJson.put("desc", "用户不能为空"); - return resultJson; - } - if (StrUtil.isEmpty("password")) { - resultJson.put("code", "1"); - resultJson.put("desc", "密码不能为空!"); - return resultJson; - } - boolean is_match = false; - Long account_id = 0L; - try { - String pwd = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, password); - UserDto userDto = userService.findByName(user); - account_id = userDto.getId(); - is_match = passwordEncoder.matches(pwd, userDto.getPassword()); - - } catch (Exception e) { - e.printStackTrace(); - } - - if (is_match) { - resultJson.put("code", "1"); - resultJson.put("desc", "登陆成功"); - } else { - resultJson.put("code", "2"); - resultJson.put("desc", "登陆失败!"); - } - JSONObject jo = new JSONObject(); - jo.put("user_name", user); - jo.put("account_id", account_id); - resultJson.put("result", jo); - return resultJson; - } - - @Override - public Map Instoperation(Map jsonObject) { - JSONObject jo = new JSONObject(); - String type = jsonObject.get("type"); - String inst_uuid = jsonObject.get("inst_uuid"); - JSONObject instwo = WQLObject.getWQLObject("acs_instruction").query("instruction_id='" + inst_uuid + "'").uniqueResult(0); - if (instwo == null) { - throw new BadRequestException("未找到该指令!"); - } - if (StrUtil.equals(instwo.getString("instruction_status"), "2") || - StrUtil.equals(instwo.getString("instruction_status"), "3")) { - jo.put("code", "2"); - jo.put("desc", "指令已完成或已取消,无法操作"); - jo.put("result", ""); - return jo; - } - String task_id = instwo.getString("task_id"); - Instruction instdto = instwo.toJavaObject(Instruction.class); - AgvService agvService = SpringContextHolder.getBean(AgvServiceImpl.class); - InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); - - /* 1 指令撤销 - 2 重新下发 - 3 强制完成*/ - if (type.equals("1")) { - //调用agv删除任务的接口 - - try { - agvService.deleteAgvInst(instwo.getString("instruction_code")); - } catch (Exception e) { - jo.put("code", "2"); - jo.put("desc", "下发agv失败"); - jo.put("result", ""); - return jo; - } - } - if (type.equals("2")) { - try { - agvService.sendAgvInstToMagic(instdto); - } catch (Exception e) { - - jo.put("code", "2"); - jo.put("desc", "下发agv失败"); - jo.put("result", ""); - return jo; - } - - } - if (type.equals("3")) { - //完成指令 - try { - instructionService.finish(inst_uuid); - String next_device_code = instdto.getNext_device_code(); - Device device = deviceAppService.findDeviceByCode(next_device_code); - if (ObjectUtil.isNotEmpty(taskService.findByNextCode(next_device_code))) { - device.setHas_goods(3); - } - } catch (Exception e) { - jo.put("code", "2"); - jo.put("desc", e.getMessage()); - jo.put("result", ""); - return jo; - } - } - - - jo.put("code", "1"); - jo.put("desc", "操作成功"); - jo.put("result", new JSONObject()); - return jo; - } - - @Override - public Map Taskoperation(Map jsonObject) throws Exception { - JSONObject jo = new JSONObject(); - String task_uuid = jsonObject.get("inst_uuid"); - String type = jsonObject.get("type"); - JSONObject taskjo = WQLObject.getWQLObject("acs_task").query("task_id='" + task_uuid + "'").uniqueResult(0); - String task_code = taskjo.getString("task_code"); - String start_point_code = taskjo.getString("start_point_code"); - String next_point_code = taskjo.getString("next_point_code"); - String task_id = taskjo.getString("task_id"); - - if (StrUtil.isEmpty(task_uuid)) { - throw new BadRequestException("id不能为空!"); - } - if (StrUtil.isEmpty(type)) { - throw new BadRequestException("操作类型不能为空!"); - } - if (StrUtil.equals(taskjo.getString("task_status"), "2") || - StrUtil.equals(taskjo.getString("task_status"), "3")) { - jo.put("code", "2"); - jo.put("desc", "任务已完成或已取消,无法操作"); - jo.put("result", ""); - return jo; - } - //重新生成 - if (type.equals("1")) { - //重新生产指令 - Instruction instdto = new Instruction(); - instdto.setInstruction_id(IdUtil.simpleUUID()); - instdto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO")); - instdto.setRemark(taskjo.getString("remark")); - instdto.setMaterial(taskjo.getString("material")); - instdto.setTask_id(taskjo.getString("task_id")); - instdto.setTask_code(taskjo.getString("task_code")); - instdto.setVehicle_code(taskjo.getString("vehicle_code")); - instdto.setRoute_plan_code(taskjo.getString("route_plan_code")); - String now = DateUtil.now(); - instdto.setCreate_time(now); - instdto.setCreate_by("auto"); - instdto.setStart_point_code(taskjo.getString("start_point_code")); - instdto.setNext_point_code(taskjo.getString("next_point_code")); - instdto.setStart_device_code(taskjo.getString("start_device_code")); - instdto.setNext_device_code(taskjo.getString("next_device_code")); - instdto.setInstruction_status("0"); - InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); - WQLObject instwo = WQLObject.getWQLObject("acs_instruction"); - JSONObject instcheckjson = instwo.query(" instruction_status <2 and next_point_code= '" + next_point_code + "'" + " and start_point_code = '" + start_point_code + "'" + " and task_id = '" + task_id + "'").uniqueResult(0); - if (instcheckjson != null) { - jo.put("code", "2"); - jo.put("desc", "操作失败"); - jo.put("result", task_code + ":该任务已存在待完成指令!"); - } - List instructions = instructionService.queryAll("instruction_status < 2"); - if (instructions.size() >= 1) { - jo.put("code", "2"); - jo.put("desc", "当前已有指令,无法生成!"); - jo.put("result", ""); - return jo; - } - try { - instructionService.create(instdto); - } catch (Exception e) { - jo.put("code", "2"); - jo.put("desc", e.getMessage()); - jo.put("result", ""); - return jo; - } - instdto.setExecute_device_code(taskjo.getString("start_point_code")); - //下发指令给agv -// AgvService agvserver = SpringContextHolder.getBean("agvServiceImpl"); -// try { -// agvserver.sendAgvInstToMagic(instdto); -// } catch (Exception e) { -// jo.put("code", "2"); -// jo.put("desc", e.getMessage()); -// jo.put("result", ""); -// return jo; -// } - - } - //强制完成 - if (type.equals("2")) { - //手工完成 - Device deviceByCode = deviceAppService.findDeviceByCode(start_point_code); - Device next_device = deviceAppService.findDeviceByCode(next_point_code); - next_device.setHas_goods(0); - deviceByCode.setHas_goods(2); - TaskService taskService = SpringContextHolder.getBean(TaskServiceImpl.class); - TaskDto acsTask = taskjo.toJavaObject(TaskDto.class); - InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl"); - InstructionDto instdto = instructionservice.findByTaskid(acsTask.getTask_id(), "instruction_status < 2 "); - if (instdto != null){ - jo.put("code", "2"); - jo.put("desc", "有指令未完成"); - jo.put("result", ""); - return jo; - } - taskService.finish(acsTask.getTask_id()); - if (ObjectUtil.isNotEmpty(taskService.findByNextCode(next_point_code))) { - next_device.setHas_goods(3); - } - } - - - jo.put("code", "1"); - jo.put("desc", "操作成功"); - jo.put("result", new JSONObject()); - return jo; - } - - @Override - public Map queryMaterial() { - JSONArray resultArr = WQL.getWO("QNDXY_QUERY003").addParam("flag", "5").process().getResultJSONArray(0); - JSONObject jo = new JSONObject(); - jo.put("code", "1"); - jo.put("desc", "查询成功"); - jo.put("result", resultArr); - return jo; - } - - @Override - public Map createTask2(JSONObject whereJson) { - JSONArray array = JSONArray.parseArray(JSON.toJSONString(whereJson.get("start_devicecode"))); - String next_device_code = (String) whereJson.get("next_devicecode"); - JSONObject resultJson = new JSONObject(); - - boolean isPass = true; - String message = ""; - for (int i = 0; i < array.size(); i++) { - JSONObject json = array.getJSONObject(i); - String start_device_code = json.getString("device_code"); - String plan_code = "one"; - if (routelineserver.getActivePathLine(start_device_code, next_device_code, plan_code).size() == 0) { - isPass = false; - message += start_device_code + "->" + next_device_code + "路由不通!"; - } - } - if (!isPass) { - resultJson.put("code", "2"); - resultJson.put("desc", message); - resultJson.put("result", ""); - return resultJson; - } - - for (int i = 0; i < array.size(); i++) { - JSONObject arrjo = array.getJSONObject(i); - String material_type = arrjo.getString("material_type"); - String quantity = arrjo.getString("quantity"); - String remark = arrjo.getString("remark"); - String device_code = arrjo.getString("device_code"); - TaskDto dto = new TaskDto(); - - dto.setRoute_plan_code("one"); - - if (ObjectUtil.isNotEmpty(taskService.findByStartCode(device_code))) { - resultJson.put("code", "2"); - resultJson.put("desc", "已存在该起点的任务!"); - resultJson.put("result", ""); - return resultJson; - } - if (StrUtil.equals(material_type, "") || StrUtil.equals(quantity, "")) { - resultJson.put("code", "2"); - resultJson.put("desc", "请填写物料信息!"); - resultJson.put("result", ""); - return resultJson; - } - dto.setStart_device_code(device_code); - dto.setStart_point_code(device_code); - dto.setNext_device_code(next_device_code); - dto.setNext_point_code(next_device_code); - dto.setQuantity(new BigDecimal(quantity)); - dto.setRemark(remark); - dto.setMaterial(material_type); - try { - taskService.create(dto); - } catch (Exception e) { - resultJson.put("code", "2"); - resultJson.put("desc", e.getMessage()); - resultJson.put("result", resultJson); - return resultJson; - } - } - resultJson.put("code", "1"); - resultJson.put("desc", "生成成功!"); - resultJson.put("result", ""); - return resultJson; - } - - -} diff --git a/nladmin-system/src/main/java/org/nl/hand/ndxytwo/wql/QNDXY_QUERY003.wql b/nladmin-system/src/main/java/org/nl/hand/ndxytwo/wql/QNDXY_QUERY003.wql deleted file mode 100644 index 11ad65f..0000000 --- a/nladmin-system/src/main/java/org/nl/hand/ndxytwo/wql/QNDXY_QUERY003.wql +++ /dev/null @@ -1,220 +0,0 @@ -[交易说明] - 交易名: 手持接口查询 - 所属模块: - 功能简述: - 版权所有: - 表引用: - 版本经历: - -[数据库] - --指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 - -[IO定义] - ################################################# - ## 表字段对应输入参数 - ################################################# - 输入.flag TYPEAS s_string - 输入.key TYPEAS s_string - 输入.keyword TYPEAS s_string - 输入.start_point TYPEAS s_string - 输入.next_point TYPEAS s_string - 输入.detail_id TYPEAS s_string - - - -[临时表] - --这边列出来的临时表就会在运行期动态创建 - -[临时变量] - --所有中间过程变量均可在此处定义 - -[业务过程] - - ########################################## - # 1、输入输出检查 # - ########################################## - - - ########################################## - # 2、主过程前处理 # - ########################################## - - - ########################################## - # 3、业务主过程 # - ########################################## - IF 输入.flag = "1" - QUERY - SELECT - dtl.detail_id as region_id, - dtl.label as region_name, - dtl.value as region_code - FROM - sys_dict sys - LEFT JOIN sys_dict_detail dtl ON dtl.dict_id = sys.dict_id - WHERE - sys.NAME = "region_type" - ENDSELECT - ENDQUERY - ENDIF - - IF 输入.flag = "2" - QUERY - SELECT - task.task_id AS task_uuid, - task.task_code AS task_no, - task.start_point_code AS start_devicecode, - task.next_point_code AS next_devicecode, - task.task_type AS task_type, - task.material AS material_type, - sys2.label AS material_type_name, - task.task_status AS task_status, - sys.label AS task_status_name, - task.vehicle_code AS carrier, - task.create_time, - task.priority - FROM - acs_task task - INNER JOIN sys_dict_detail AS sys ON sys. - VALUE = task.task_status - AND sys.NAME = 'task_status' - LEFT JOIN sys_dict_detail AS sys2 ON sys2. - VALUE = task.material - AND sys2.NAME = 'material_type' - where - ( task.task_status ='1' or task.task_status ='0' ) - and - ( task.task_id IN (select inst.task_id FROM acs_instruction inst where inst.is_delete<>1 and (instruction_status<>'1' and instruction_status <>'2' and instruction_status <>'0')) or task.task_id not in (select inst.task_id FROM acs_instruction inst where inst.is_delete<>1 - )) - OPTION 输入.key <> "" - (task.task_code like 输入.key - or task.task_status like 输入.key - or task.vehicle_code like 输入.key) - ENDOPTION - OPTION 输入.start_point <> "" - task.start_point_code like 输入.start_point - ENDOPTION - OPTION 输入.next_point <> "" - task.next_point_code like 输入.next_point - ENDOPTION - ORDER BY task.create_time - ENDSELECT - ENDQUERY - ENDIF - - IF 输入.flag = "3" - QUERY - SELECT - * - FROM - sys_dict_detail detl - WHERE - 1=1 - OPTION 输入.detail_id <> "" - detl.detail_id = 输入.detail_id - ENDOPTION - - ENDSELECT - ENDQUERY - ENDIF - - IF 输入.flag = "4" - QUERY - SELECT - inst.instruction_id AS inst_uuid, - inst.task_code AS task_no, - inst.instruction_code AS inst_no, - inst.task_code AS task_code, - inst.vehicle_code AS vehicle_code, - inst.start_point_code AS start_devicecode, - inst.next_point_code AS next_devicecode, - inst.instruction_status AS inst_status, - dtl.label AS inst_status_name, - inst.execute_message AS inst_step, - inst.vehicle_code AS carrier, - inst.carno, - inst.priority, - inst.send_status, - inst.create_time, - inst.material AS material_type, - dtl2.label AS material_type_name, - dtl3.label AS send_status_name - FROM - acs_instruction inst - LEFT JOIN sys_dict_detail AS dtl ON dtl. - VALUE - = inst.instruction_status - AND dtl.NAME = 'inst_status' - LEFT JOIN sys_dict_detail dtl2 ON dtl2. - VALUE - = inst.material - AND dtl2.NAME = 'material_type' - LEFT JOIN sys_dict_detail dtl3 ON dtl3. - VALUE - = inst.send_status - AND dtl3.NAME = 'send_status' - WHERE - inst.is_delete = '0' - AND inst.instruction_status <> '2' - AND inst.instruction_status <> '3' - OPTION 输入.key <> "" - (inst.instruction_code like 输入.key - or inst.task_code like 输入.key - or inst.vehicle_code like 输入.key) - ENDOPTION - OPTION 输入.start_point <> "" - inst.start_point_code like 输入.start_point - ENDOPTION - OPTION 输入.next_point <> "" - inst.next_point_code like 输入.next_point - ENDOPTION - ORDER BY - inst.create_time DESC - ENDSELECT - ENDQUERY - ENDIF - - IF 输入.flag = "5" - QUERY - SELECT - detl.label AS label, - detl.VALUE AS value - FROM - sys_dict_detail detl - WHERE - detl.name = 'material_type' - order by - dict_sort - ENDSELECT - ENDQUERY - ENDIF - IF 输入.flag = "6" - QUERY - SELECT - dtl.detail_id as region_id, - dtl.label as region_name, - dtl.value as region_code - FROM - sys_dict sys - LEFT JOIN sys_dict_detail dtl ON dtl.dict_id = sys.dict_id - WHERE - sys.NAME = "region_type" - AND dtl.VALUE IN ('2') - ENDSELECT - ENDQUERY - ENDIF - IF 输入.flag = "7" - QUERY - SELECT - dtl.detail_id as region_id, - dtl.label as region_name, - dtl.value as region_code - FROM - sys_dict sys - LEFT JOIN sys_dict_detail dtl ON dtl.dict_id = sys.dict_id - WHERE - sys.NAME = "region_type" - AND dtl.VALUE IN ('1','2','3') - ENDSELECT - ENDQUERY - ENDIF \ No newline at end of file diff --git a/nladmin-system/src/main/java/org/nl/modules/log/MongoDBAppender.java b/nladmin-system/src/main/java/org/nl/modules/log/MongoDBAppender.java deleted file mode 100644 index 551035e..0000000 --- a/nladmin-system/src/main/java/org/nl/modules/log/MongoDBAppender.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.nl.modules.log; - -import ch.qos.logback.classic.spi.ILoggingEvent; -import cn.hutool.core.date.DateUtil; -import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; -import org.bson.Document; -import org.slf4j.Marker; - -import java.net.InetAddress; -import java.net.UnknownHostException; - -/** - * https://www.cnblogs.com/lzghyh/p/14913230.html - * https://juejin.cn/post/6844903488896385037 - * https://cloud.tencent.com/developer/article/1384035 - * https://www.freesion.com/article/229560377/ - */ -public class MongoDBAppender extends MongoDBAppenderBase { - public MongoDBAppender() { - super("loggingEvents"); - } - - @Override - protected Document toMongoDocument(ILoggingEvent eventObject) { - - final Document doc = new Document(); - doc.append("_id", IdUtil.simpleUUID()); - - doc.append("date", DateUtil.now()); - doc.append("source", source); - try { - doc.append("ip", InetAddress.getLocalHost().getHostAddress()); - } catch (UnknownHostException e) { - e.printStackTrace(); - } - - Marker marker = eventObject.getMarker(); - if (!ObjectUtil.isEmpty(marker)) { - doc.append("marker", marker.getName()); - }else { - doc.append("marker", "default"); - } - - doc.append("level", eventObject.getLevel().toString()); - doc.append("logger", eventObject.getLoggerName()); - doc.append("thread", eventObject.getThreadName()); - doc.append("message", eventObject.getFormattedMessage()); - if (eventObject.getMDCPropertyMap() != null && !eventObject.getMDCPropertyMap().isEmpty()) - doc.append("mdc", eventObject.getMDCPropertyMap()); - // ... - return doc; - } - -} diff --git a/nladmin-system/src/main/java/org/nl/modules/log/MongoDBAppenderBase.java b/nladmin-system/src/main/java/org/nl/modules/log/MongoDBAppenderBase.java index ceab43b..77d28ab 100644 --- a/nladmin-system/src/main/java/org/nl/modules/log/MongoDBAppenderBase.java +++ b/nladmin-system/src/main/java/org/nl/modules/log/MongoDBAppenderBase.java @@ -3,107 +3,52 @@ package org.nl.modules.log; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.UnsynchronizedAppenderBase; import cn.hutool.core.util.ObjectUtil; -import com.mongodb.MongoClient; -import com.mongodb.MongoClientOptions; -import com.mongodb.MongoCredential; -import com.mongodb.ServerAddress; -import com.mongodb.client.MongoCollection; -import com.mongodb.client.MongoDatabase; +import com.mongodb.BasicDBObject; import lombok.Data; -import org.bson.Document; +import org.nl.utils.SpringContextHolder; import org.slf4j.Marker; +import org.springframework.data.mongodb.core.MongoTemplate; +import java.net.InetAddress; import java.net.UnknownHostException; -import java.util.Collections; /** - * MongoDBAppender适配类 + * https://www.cnblogs.com/lzghyh/p/14913230.html + * https://juejin.cn/post/6844903488896385037 + * https://cloud.tencent.com/developer/article/1384035 + * https://www.freesion.com/article/229560377/ + *

+ * https://cloud.tencent.com/developer/article/1384035 */ @Data -public abstract class MongoDBAppenderBase extends UnsynchronizedAppenderBase { - private MongoClient mongo; - MongoDatabase db; - private MongoCollection eventsCollection; - - private String host = "127.0.0.1"; // 地址 - private int port = 27017; // 端口号 - private String dbName = "db"; // 库名 - private String collectionName; // 集合名 - private String username; // 用户名 - private String password; // 密码 - protected String source; - - private int connectionsPerHost = 10; // 空闲线程池中最大链接数 - private int threadsAllowedToBlockForConnectionMultiplier = 5; //一个线程等待链接可用的最大等待毫秒数 - private int maxWaitTime = 1000 * 60 * 2; // 最长等待时间 - private int connectTimeout; - private int socketTimeout; - private int wtimeout; - - MongoDBAppenderBase(String collectionName) { - this.collectionName = collectionName; - } +public class MongoDBAppenderBase extends UnsynchronizedAppenderBase { @Override - public void start() { - try { - connectToMongoDB(); - super.start(); - } catch (UnknownHostException e) { - addError("Error connecting to MongoDB server: " + host + ":" + port, - e); + protected void append(ILoggingEvent eventObject) { + + MongoTemplate mongoTemplate = SpringContextHolder.getBean(MongoTemplate.class); + + if (mongoTemplate != null) { + final BasicDBObject doc = new BasicDBObject(); + Marker marker = eventObject.getMarker(); + if (!ObjectUtil.isEmpty(marker)) { + doc.append("marker", marker.getName()); + } else { + doc.append("marker", "default"); + } + try { + doc.append("ip", InetAddress.getLocalHost().getHostAddress()); + } catch (UnknownHostException e) { + e.printStackTrace(); + } + + doc.append("level", eventObject.getLevel().toString()); + doc.append("logger", eventObject.getLoggerName()); + doc.append("thread", eventObject.getThreadName()); + doc.append("message", eventObject.getFormattedMessage()); + mongoTemplate.insert(doc, "log"); } } - private void connectToMongoDB() throws UnknownHostException { - // 用户名 数据库 密码 - if (username != null && password != null) { - - MongoCredential credential = MongoCredential.createCredential( - username, dbName, password.toCharArray()); - ServerAddress serverAddress = new ServerAddress(host, port); - mongo = new MongoClient(serverAddress, Collections.singletonList(credential), buildOptions()); - } else { - mongo = new MongoClient(new ServerAddress(host, port), buildOptions()); - } - - db = mongo.getDatabase(dbName); - eventsCollection = db.getCollection(collectionName); - - } - - private MongoClientOptions buildOptions() { - final MongoClientOptions.Builder options = new MongoClientOptions.Builder(); - options.connectionsPerHost(connectionsPerHost); - options.threadsAllowedToBlockForConnectionMultiplier(threadsAllowedToBlockForConnectionMultiplier); - options.maxWaitTime(maxWaitTime); - options.connectTimeout(connectTimeout); - options.socketTimeout(socketTimeout); - options.maxWaitTime(wtimeout); - return options.build(); - } - - protected abstract Document toMongoDocument(E event); - - @Override - protected void append(E eventObject) { - if (eventObject instanceof ILoggingEvent) { - ILoggingEvent evt = (ILoggingEvent) eventObject; - Marker marker = evt.getMarker(); - if (ObjectUtil.isEmpty(marker)) - marker = LogMarkerTypeEnum.getMarker(LogMarkerTypeEnum.DEFAULT); - eventsCollection = db.getCollection(marker.getName()); - - } - - eventsCollection.insertOne(toMongoDocument(eventObject)); - } - - @Override - public void stop() { - if (mongo != null) - mongo.close(); - super.stop(); - } } diff --git a/nladmin-system/src/main/java/org/nl/modules/quartz/task/HomeDataQuery.java b/nladmin-system/src/main/java/org/nl/modules/quartz/task/HomeDataQuery.java deleted file mode 100644 index 9d56fb0..0000000 --- a/nladmin-system/src/main/java/org/nl/modules/quartz/task/HomeDataQuery.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.nl.modules.quartz.task; - -import cn.hutool.core.date.DateTime; -import cn.hutool.core.date.DateUtil; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.agv.server.dto.AgvDto; -import org.nl.modules.mnt.websocket.MsgType; -import org.nl.modules.mnt.websocket.SocketMsg; -import org.nl.modules.mnt.websocket.WebSocketServer; -import org.nl.start.Init; -import org.nl.wql.WQL; -import org.nl.wql.core.bean.WQLObject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.Map; - -/** - * 设备状态监控 - */ -@Slf4j -@Component -public class HomeDataQuery { - @Autowired - AgvService agvService; - - public void run() throws Exception { - if (!Init.isStart) { - return; - } - try { - JSONObject json = new JSONObject(); - Map agv_map = agvService.findAllAgvFromCache(); - AgvDto agv1 = new AgvDto(); - agv1.setName("agv1"); - agv1.setEnergyLevel("70"); - agv1.setState("IDLE"); - agv_map.put("agv1", agv1); - - AgvDto agv2 = new AgvDto(); - agv2.setName("agv2"); - agv2.setEnergyLevel("100"); - agv2.setState("EXECUTING"); - agv_map.put("agv2", agv2); - - JSONArray agv_rows = new JSONArray(); - int i = 1; - for (AgvDto agvDto : agv_map.values()) { - while (i > 5) { - break; - } - JSONObject row = new JSONObject(); - row.put("car_no", agvDto.getName()); - row.put("electricity", agvDto.getEnergyLevel()); - if (agvDto.getState().equals("UNKNOWN")) { - row.put("status_name", "有任务"); - row.put("flag", "1"); - } - if (agvDto.getState().equals("UNAVAILABLE")) { - row.put("status_name", "网络异常"); - row.put("flag", "1"); - } - if (agvDto.getState().equals("ERROR")) { - row.put("status_name", "机器错误"); - row.put("flag", "1"); - } - if (agvDto.getState().equals("IDLE")) { - row.put("status_name", "空闲"); - row.put("flag", "0"); - } - if (agvDto.getState().equals("EXECUTING")) { - row.put("status_name", "运行中"); - row.put("flag", "0"); - } - if (agvDto.getState().equals("CHARGING")) { - row.put("status_name", "充电中"); - row.put("flag", "0"); - } - agv_rows.add(row); - i++; - } - //agv状态查询 - if (agv_rows.size() < 4) { - for (int j = agv_rows.size(); j < 4; j++) { - JSONObject jo = new JSONObject(); - agv_rows.add(jo); - } - } - json.put("agv_rows", agv_rows); - - //当天任务统计 - JSONObject task_jo = WQL.getWO("QHOME_QUERY_001").addParam("flag", "1").process().uniqueResult(0); - json.put("task_jo", task_jo); - //当天指令统计 - JSONObject inst_jo = WQL.getWO("QHOME_QUERY_001").addParam("flag", "2").process().uniqueResult(0); - json.put("inst_jo", inst_jo); - - //一周任务数 - JSONObject bar_jo = new JSONObject(); - ArrayList day_list = new ArrayList<>(); - ArrayList num_list = new ArrayList<>(); - for (int j = 6; j >= 0; j--) { - String now = DateUtil.now(); - Date date = DateUtil.parse(now); - DateTime newDate2 = DateUtil.offsetDay(date, -j); - String today = DateUtil.format(newDate2, "MM/dd"); - String today_date = DateUtil.format(newDate2, "yyyy-MM-dd"); - JSONArray task_rows = WQLObject.getWQLObject("acs_task").query("create_time like '" + today_date + "%' AND is_delete = '0'").getResultJSONArray(0); - day_list.add(today); - num_list.add(task_rows.size()); - } - bar_jo.put("expectedData", day_list); - bar_jo.put("actualData", num_list); - json.put("bar_jo", bar_jo); - SocketMsg deviceInfo = new SocketMsg(json, MsgType.INFO); - - WebSocketServer.sendInfo(deviceInfo, "home_data"); - } catch (IOException e) { - e.printStackTrace(); - } - } -} diff --git a/nladmin-system/src/main/java/org/nl/modules/quartz/task/NdxyDeviceStatus.java b/nladmin-system/src/main/java/org/nl/modules/quartz/task/NdxyDeviceStatus.java deleted file mode 100644 index 2e6091e..0000000 --- a/nladmin-system/src/main/java/org/nl/modules/quartz/task/NdxyDeviceStatus.java +++ /dev/null @@ -1,103 +0,0 @@ -package org.nl.modules.quartz.task; - - -import cn.hutool.core.map.MapUtil; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.device_driver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.modules.mnt.websocket.MsgType; -import org.nl.modules.mnt.websocket.SocketMsg; -import org.nl.modules.mnt.websocket.WebSocketServer; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.Map; - -/** - * 纽迪希亚设备状态 - */ - -@Slf4j -@Component -public class NdxyDeviceStatus { - @Autowired - DeviceService deviceService; - - @Autowired - DeviceAppService deviceAppService; - - public void run() throws Exception { - - try { - log.info("run 执行成功"); - JSONObject json = new JSONObject(); - JSONArray device = new JSONArray(); - JSONArray device2 = new JSONArray(); - JSONArray device3 = new JSONArray(); - JSONObject jo = new JSONObject(); - Map whereJson1; - Map whereJson2; - Map whereJson3; - JSONArray array1 = deviceService.selectDeviceListOne(); - JSONArray array2 = deviceService.selectDeviceListTwo(); - JSONArray array3 = deviceService.selectDeviceListThree(); - for (int i = 0; i < array1.size(); i++) { - whereJson1 = (Map) array1.get(i); - String device_code = MapUtil.getStr(whereJson1, "device_code"); - Device deviceApp = deviceAppService.findDeviceByCode(device_code); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - if (deviceApp.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) deviceApp.getDeviceDriver(); - jo.put("device_code", device_code); - jo.put("quantity", standardOrdinarySiteDeviceDriver.getQty()); - jo.put("material_type", standardOrdinarySiteDeviceDriver.getMaterial()); - jo.put("hasGood", standardOrdinarySiteDeviceDriver.getHasGoods()); - jo.put("remark", standardOrdinarySiteDeviceDriver.getRemark()); - } - device.add(jo); - } - for (int i = 0; i < array2.size(); i++) { - whereJson2 = (Map) array2.get(i); - String device_code = MapUtil.getStr(whereJson2, "device_code"); - Device deviceApp = deviceAppService.findDeviceByCode(device_code); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - if (deviceApp.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) deviceApp.getDeviceDriver(); - jo.put("device_code", device_code); - jo.put("quantity", standardOrdinarySiteDeviceDriver.getQty()); - jo.put("material_type", standardOrdinarySiteDeviceDriver.getMaterial()); - jo.put("hasGood", standardOrdinarySiteDeviceDriver.getHasGoods()); - jo.put("remark", standardOrdinarySiteDeviceDriver.getRemark()); - } - device2.add(jo); - } - for (int i = 0; i < array3.size(); i++) { - whereJson3 = (Map) array3.get(i); - String device_code = MapUtil.getStr(whereJson3, "device_code"); - Device deviceApp = deviceAppService.findDeviceByCode(device_code); - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - if (deviceApp.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) deviceApp.getDeviceDriver(); - jo.put("device_code", device_code); - jo.put("quantity", standardOrdinarySiteDeviceDriver.getQty()); - jo.put("material_type", standardOrdinarySiteDeviceDriver.getMaterial()); - jo.put("hasGood", standardOrdinarySiteDeviceDriver.getHasGoods()); - jo.put("remark", standardOrdinarySiteDeviceDriver.getRemark()); - } - device3.add(jo); - } - json.put("device", device); - json.put("device2", device2); - json.put("device3", device3); - SocketMsg deviceInfo = new SocketMsg(json, MsgType.INFO); - WebSocketServer.sendInfo(deviceInfo, "ndxy_data"); - - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryMagicAgvDeviceStatus.java b/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryMagicAgvDeviceStatus.java deleted file mode 100644 index 399b35a..0000000 --- a/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryMagicAgvDeviceStatus.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.nl.modules.quartz.task; - -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.device_driver.electric_fence.ElectricFenceDeviceDriver; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.acs.opc.DeviceType; -import org.nl.utils.SpringContextHolder; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * 查询magicAGV设备状态 - */ -@Slf4j -@Component -public class QueryMagicAgvDeviceStatus { - - @Autowired - InstructionService instructionService; - - @Autowired - AgvService agvService; - - - public void run() throws Exception { - HttpResponse response = agvService.queryMagicAgvDeviceStatus(); - if (response.getStatus() == 200) { - JSONArray ja = JSONArray.parseArray(response.body()); - log.info("查询magicAGV设备状态:" + ja.toString()); - for (int i = 0; i < ja.size(); i++) { - JSONObject jo = ja.getJSONObject(i); - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - - ElectricFenceDeviceDriver electricFenceDeviceDriver; - List deviceAll = appService.findDevice(DeviceType.safetydoor); - for (int j = 0; j < deviceAll.size(); j++) { - Device device = deviceAll.get(i); - if (device.getDeviceDriver() instanceof ElectricFenceDeviceDriver) { - electricFenceDeviceDriver = (ElectricFenceDeviceDriver) device.getDeviceDriver(); - if (jo.getString("state").equals("IDLE")) { - electricFenceDeviceDriver.writing(1); - } - else if (jo.getString("state").equals("EXECUTING")) { - electricFenceDeviceDriver.writing(2); - } - } - } - } - } - } - -} diff --git a/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryMagicAgvTaskStatus.java b/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryMagicAgvTaskStatus.java deleted file mode 100644 index f6bf1ab..0000000 --- a/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryMagicAgvTaskStatus.java +++ /dev/null @@ -1,118 +0,0 @@ -package org.nl.modules.quartz.task; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * 查询AGV任务状态 - */ -@Slf4j -@Component -public class QueryMagicAgvTaskStatus { - - @Autowired - InstructionService instructionService; - - @Autowired - AgvService agvService; - - - public void run() throws Exception { - List instList = instructionService.findAllInstFromCache(); - log.info("instList:{}", instList.size()); - if (instList.size() > 0) { - for (int i = 0; i < instList.size(); i++) { - Instruction inst = instList.get(i); - String instcode = inst.getInstruction_code(); - HttpResponse response = agvService.queryAgvInstStatus(instcode); - JSONObject jo = JSONObject.parseObject(response.body()); - if (MapUtil.isEmpty(jo)) continue; - //反馈结果状态 - log.info("instcode:" + instcode + "," + jo.toString()); - //指令执行状态 - String state = jo.getString("state"); - String processingVehicle = ""; - //正在执行指令agv车号 - if (!StrUtil.isEmpty(jo.getString("processingVehicle"))) { - processingVehicle = jo.getString("processingVehicle"); - inst.setCarno(processingVehicle); - } -// RAW:初始状态 -// ACTIVE:业务订单已激活 -// DISPATCHABLE:业务订单已通过系统验证,等待被调度执行 -// BEING_PROCESSED:业务订单正在被执行 -// WITHDRAWN:业务订单已被撤销 -// FINISHED:业务订单已完成 -// FAILED:业务订单已失败 -// UNROUTABLE:无法规划该业务订单的执行路线 - - //执行中 - if ("BEING_PROCESSED".equals(state)) { - if (inst != null) { - inst.setInstruction_status("1"); - instructionService.update(inst); - } - } else if ("FINISHED".equals(state)) { - if (inst != null) { - inst.setInstruction_status("2"); - instructionService.finish(inst); - } - } else if ("WITHDRAWN".equals(state) || "FAILED".equals(state)) { - if (inst != null) { - inst.setInstruction_status("3"); - instructionService.update(inst); - instructionService.removeByCodeFromCache(instcode); - } - } else { - - } - JSONArray ja = jo.getJSONArray("properties"); - for (int j = 0; j < ja.size(); j++) { - JSONObject item = ja.getJSONObject(j); - if ("True".equals(item.get("value"))) { - String param = item.get("key").toString(); - String[] strs = param.split("-"); - //onEntry请求进入 onStation请求离开 - //onStation-库位名-动作名" - String type = null; - String device = null; - String action = null; - // =5表示为货位 - if (strs.length == 5) { - type = strs[0]; - device = strs[1] + "-" + strs[2] + "-" + strs[3]; - action = strs[4]; - } else { - type = strs[0]; - device = strs[1]; - action = strs[2]; - } - - String mes = ""; - - agvService.process(instcode, type, device, action, processingVehicle); - } - - } - } - } - } - - public static void main(String[] args) { - String str = "onEntry-0101-07-03-Unload"; - String[] strs = str.split("-"); - System.out.println(strs.length); - - } -} diff --git a/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java b/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java deleted file mode 100644 index 0452d66..0000000 --- a/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.nl.modules.quartz.task; - -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpResponse; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * 查询AGV任务状态 - */ -@Slf4j -@Component -public class QueryXZAgvTaskStatus { - - @Autowired - InstructionService instructionService; - - @Autowired - AgvService agvService; - - - public void run() throws Exception { - List instList = instructionService.findAllInstFromCache(); - if (instList.size() > 0) { - for (int i = 0; i < instList.size(); i++) { - Instruction inst = instList.get(i); - if (!StrUtil.equals(inst.getSend_status(), "1")) continue; - String instcode = inst.getInstruction_code(); - HttpResponse response = agvService.queryXZAgvInstStatus(instcode); - JSONObject jo = JSONObject.parseObject(response.body()); - if (MapUtil.isEmpty(jo)) continue; - //反馈结果状态 - log.info("instcode:" + instcode + "," + jo.toString()); - //指令执行状态 - String state = jo.getString("state"); - String processingVehicle = ""; - //正在执行指令agv车号 - if (!StrUtil.isEmpty(jo.getString("processingVehicle"))) { - processingVehicle = jo.getString("processingVehicle"); - inst.setCarno(processingVehicle); - } - -// RAW:初始状态 -// ACTIVE:业务订单已激活 -// DISPATCHABLE:业务订单已通过系统验证,等待被调度执行 -// BEING_PROCESSED:业务订单正在被执行 -// WITHDRAWN:业务订单已被撤销 -// FINISHED:业务订单已完成 -// FAILED:业务订单已失败 -// UNROUTABLE:无法规划该业务订单的执行路线 - - //执行中 - if ("BEING_PROCESSED".equals(state)) { - if (inst != null) { - inst.setInstruction_status("1"); - instructionService.update(inst); - } - } else if ("FINISHED".equals(state)) { - if (inst != null) { - inst.setInstruction_status("2"); - instructionService.finish(inst); - } - } else if ("WITHDRAWN".equals(state) || "FAILED".equals(state)) { - if (inst != null) { - inst.setInstruction_status("4"); - instructionService.update(inst); - //instructionService.removeByCodeFromCache(instcode); - } - } else { - - } - - } - } - } -} diff --git a/nladmin-system/src/main/java/org/nl/modules/quartz/task/Test.java b/nladmin-system/src/main/java/org/nl/modules/quartz/task/Test.java deleted file mode 100644 index ae7cb15..0000000 --- a/nladmin-system/src/main/java/org/nl/modules/quartz/task/Test.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright 2019-2020 Zheng Jie - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.nl.modules.quartz.task; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.nl.modules.mnt.websocket.MsgType; -import org.nl.modules.mnt.websocket.SocketMsg; -import org.nl.modules.mnt.websocket.WebSocketServer; -import org.springframework.stereotype.Component; - -/** - * 测试用 - * - * @author Zheng Jie - * @date 2019-01-08 - */ -@Slf4j -@Component -public class Test { - - public void run() { - - try { - log.info("run 执行成功"); - JSONObject json = new JSONObject(); - JSONArray device = new JSONArray(); - JSONObject jo = new JSONObject(); - jo.put("name", "A1"); - JSONObject jo2 = new JSONObject(); - jo2.put("name", "B1"); - JSONObject jo3 = new JSONObject(); - jo3.put("name", "C1"); - device.add(jo); - device.add(jo2); - device.add(jo3); - json.put("device", device); - json.put("print", "0"); - json.put("cpbh", "A111111"); - json.put("cpmc", "123456"); - SocketMsg deviceInfo = new SocketMsg(json, MsgType.INFO); - WebSocketServer.sendInfo(deviceInfo, "test_data"); - - } catch (Exception e) { - - } - - - } - -} diff --git a/nladmin-system/src/main/java/org/nl/modules/quartz/task/ToAgvDevice.java b/nladmin-system/src/main/java/org/nl/modules/quartz/task/ToAgvDevice.java deleted file mode 100644 index 3576d83..0000000 --- a/nladmin-system/src/main/java/org/nl/modules/quartz/task/ToAgvDevice.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.nl.modules.quartz.task; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.agv.server.dto.AgvDto; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.modules.mnt.websocket.MsgType; -import org.nl.modules.mnt.websocket.SocketMsg; -import org.nl.modules.mnt.websocket.WebSocketServer; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.Map; - -/** - * 查询AGV设备状态 - */ -@Slf4j -@Component -public class ToAgvDevice { - - @Autowired - AcsToWmsService acsToWmsService; - @Autowired - AgvService agvService; - - public void run() throws Exception { - JSONObject json = new JSONObject(); - Map agv_map = agvService.findAllAgvFromCache(); - - JSONArray agv_rows = new JSONArray(); - JSONObject row = new JSONObject(); - - for (AgvDto agvDto : agv_map.values()) { - row.put("device_code", agvDto.getName()); - row.put("energyLevel", agvDto.getEnergyLevel()); - if (agvDto.getState().equals("UNKNOWN")) { - row.put("status_name", "有任务"); - row.put("flag", "1"); - } - if (agvDto.getState().equals("UNAVAILABLE")) { - row.put("status_name", "网络异常"); - row.put("flag", "1"); - } - if (agvDto.getState().equals("ERROR")) { - row.put("status_name", "机器错误"); - row.put("flag", "1"); - } - if (agvDto.getState().equals("IDLE")) { - row.put("status_name", "空闲"); - row.put("flag", "0"); - } - if (agvDto.getState().equals("EXECUTING")) { - row.put("status_name", "运行中"); - row.put("flag", "0"); - } - if (agvDto.getState().equals("CHARGING")) { - row.put("status_name", "充电中"); - row.put("flag", "0"); - } - row.put("transportOrder", agvDto.getTransportOrder()); - row.put("positionX", agvDto.getPositionX()); - row.put("positionY", agvDto.getPositionY()); - row.put("positionAngle", agvDto.getPositionAngle()); - agv_rows.add(row); - } - json.put("agv_rows", agv_rows); - SocketMsg deviceInfo = new SocketMsg(json, MsgType.INFO); - WebSocketServer.sendInfo(deviceInfo, "toAgvDevice_data"); - - acsToWmsService.feedbackAgv(agv_rows); - } - -} diff --git a/nladmin-system/src/main/java/org/nl/modules/quartz/task/UpdateDeviceStatus.java b/nladmin-system/src/main/java/org/nl/modules/quartz/task/UpdateDeviceStatus.java deleted file mode 100644 index bd68237..0000000 --- a/nladmin-system/src/main/java/org/nl/modules/quartz/task/UpdateDeviceStatus.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.nl.modules.quartz.task; - -import cn.hutool.core.util.ObjectUtil; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.device_driver.non_line_inspect_site.NonLineInspectSiteDeviceDriver; -import org.nl.acs.device_driver.non_line_manipulator_inspect_site.NonLineManipulatorInspectSiteDeviceDriver; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.acs.opc.DeviceAppServiceImpl; -import org.nl.utils.SpringContextHolder; -import org.nl.wql.core.bean.WQLObject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * 查询上位系统PLC设备状态 - */ -@Slf4j -@Component -public class UpdateDeviceStatus { - - @Autowired - AcsToWmsService acsToWmsService; - - public void run() throws Exception { - DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); - JSONArray rows = acsToWmsService.getDeviceStatusToWms(); - for (int i = 0; i < rows.size(); i++) { - JSONObject row = rows.getJSONObject(i); - String device_code = ""; - JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + row.getString("device_code") + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(device_json)) { - device_code = (String) device_json.get("parent_storage_code") == null ? row.getString("device_code") : (String) device_json.get("storage_code"); - } - Device device = appService.findDeviceByCode(device_code); - if (device != null) { - NonLineInspectSiteDeviceDriver nonLineInspectSiteDeviceDriver; - if (device.getDeviceDriver() instanceof NonLineInspectSiteDeviceDriver) { - nonLineInspectSiteDeviceDriver = (NonLineInspectSiteDeviceDriver) device.getDeviceDriver(); - nonLineInspectSiteDeviceDriver.setMode(row.getInteger("mode")); - nonLineInspectSiteDeviceDriver.setMove(row.getInteger("move")); - nonLineInspectSiteDeviceDriver.setError(row.getInteger("error")); - nonLineInspectSiteDeviceDriver.setAction(row.getInteger("action")); - nonLineInspectSiteDeviceDriver.setIoaction(row.getInteger("ioaction")); - } - NonLineManipulatorInspectSiteDeviceDriver nonLineManipulatorInspectSiteDeviceDriver; - if (device.getDeviceDriver() instanceof NonLineManipulatorInspectSiteDeviceDriver) { - nonLineManipulatorInspectSiteDeviceDriver = (NonLineManipulatorInspectSiteDeviceDriver) device.getDeviceDriver(); - nonLineManipulatorInspectSiteDeviceDriver.setMode(row.getInteger("mode")); - nonLineManipulatorInspectSiteDeviceDriver.setMove(row.getInteger("move")); - nonLineManipulatorInspectSiteDeviceDriver.setError(row.getInteger("error")); - nonLineManipulatorInspectSiteDeviceDriver.setAction(row.getInteger("action")); - nonLineManipulatorInspectSiteDeviceDriver.setIoaction(row.getInteger("ioaction")); - } - } - } - } - -} diff --git a/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java b/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java deleted file mode 100644 index d1fe4c6..0000000 --- a/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java +++ /dev/null @@ -1,187 +0,0 @@ -package org.nl.start.auto.run; - -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import lombok.extern.slf4j.Slf4j; -import org.nl.acs.agv.server.AgvService; -import org.nl.acs.config.AcsConfig; -import org.nl.acs.config.server.AcsConfigService; -import org.nl.acs.config.server.impl.AcsConfigServiceImpl; -import org.nl.acs.device.service.DeviceService; -import org.nl.acs.ext.wms.service.AcsToWmsService; -import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; -import org.nl.acs.ext.xr_lk.service.AcsToXrlkService; -import org.nl.acs.instruction.service.InstructionService; -import org.nl.acs.instruction.service.dto.Instruction; -import org.nl.acs.instruction.service.impl.InstructionServiceImpl; -import org.nl.acs.opc.Device; -import org.nl.acs.opc.DeviceAppService; -import org.nl.utils.SpringContextHolder; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.net.Socket; -import java.util.Date; - -import static org.nl.acs.agv.server.impl.AgvServiceImpl.Bytes2HexString; - -@Slf4j -@Component -public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable { - - Socket s; - String ip = "127.0.0.1"; - int port = 1234; - static DataOutputStream dos; - static DataInputStream dis; - private int recordTimeOut = 10000; - private Date recordTime; - String[] ERROR = new String[]{ - "货叉尖部传感器触发", "S300传感器触发", "载货状态改变", "急停按钮触发", "触边开关出发", "需要复位", - "停在充电位", "取货失败", "放货失败", "轮子打滑", "没有动作码不能进入站点", "取货时有货", "丢失定位", - "抬叉停止"}; - boolean bConnected = true; - - boolean isReConnect = false; - - @Autowired - AcsConfigService acsConfigService; - @Autowired - AutoRunService autoRunService; - - - public NDCSocketConnectionAutoRun() { - this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut); - } - - public String getCode() { - return NDCSocketConnectionAutoRun.class.getSimpleName(); - } - - public String getName() { - return "NDC在线连接"; - } - - public void autoRun() { - - try { - AcsConfigService acsConfigService = SpringContextHolder.getBean(AcsConfigServiceImpl.class); - InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); - AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class); - AgvService AgvService = SpringContextHolder.getBean(AgvService.class); - DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class); - DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class); - AcsToXrlkService acsToXrlkService = SpringContextHolder.getBean(AcsToXrlkService.class); - ip = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL); - port = Integer.parseInt(acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT)); - byte[] b = new byte[1028]; - s = new Socket(ip, port); - dos = new DataOutputStream(s.getOutputStream()); - dis = new DataInputStream(s.getInputStream()); - - while (bConnected) { - int count = dis.read(b); - - if (count == -1) { - break; - } - - int[] arr = new int[count]; - StringBuffer bs = new StringBuffer(); - - for (int i = 0; i < count; i++) { - int temp = b[i]; - if (temp < 0) - temp += 256; - arr[i] = temp; - StringBuffer bs1 = new StringBuffer("0"); - bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp)); - } - - System.out.println("收到请求参数:" + bs); - boolean flag = false; - if (arr[8] * 256 + arr[9] == 0x73) { - byte[] data = null; - System.out.println("接收agv上报信息:" + bs); - //执行阶段 - int phase = arr[16] * 256 + arr[17]; - // agv任务号 - int index = arr[12] * 256 + arr[13]; - //任务号 - int ikey = arr[26] * 256 + arr[27]; - //站点号 - int agvaddr = arr[18] * 256 + arr[19]; - //车号 - int carno = arr[20]; - Instruction inst = null; - if (ikey != 0) { - inst = instructionService.findByCodeFromCache(String.valueOf(ikey)); - } - log.info("接收agv上报信息:" + bs); - log.info("接收agv上报信息:" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno); - Device device = null; - String device_code = null; - String old_device_code = null; - String emptyNum = null; - if (agvaddr != 0) { - old_device_code = deviceService.queryDeviceCodeByAddress(agvaddr); - if (StrUtil.contains(old_device_code, "-")) { - String[] point = old_device_code.split("-"); - device_code = point[0]; - } else if (StrUtil.contains(old_device_code, ".")) { - String[] point = old_device_code.split("\\."); - device_code = point[0]; - emptyNum = point[1]; - } else { - device_code = old_device_code; - } - device = deviceAppService.findDeviceByCode(device_code); - } - - if (!ObjectUtil.isEmpty(data)) { - write(data); - } - - } else { - System.out.println("agv上报不是0073类型动作,不处理"); - } - } - - } catch (Exception e) { - - - } finally { - - - } - - } - - - @Override - public void stop() { - super.after(); - try { - s.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - - public static void write(byte[] b) { - try { - log.info("下发agv数据:" + Bytes2HexString(b)); - System.out.println("下发agv数据:" + Bytes2HexString(b)); - dos.write(b); - dos.flush(); - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } -} diff --git a/nladmin-system/src/main/resources/log/AcsToErp.xml b/nladmin-system/src/main/resources/log/AcsToErp.xml index 46f3bc9..da17ef5 100644 --- a/nladmin-system/src/main/resources/log/AcsToErp.xml +++ b/nladmin-system/src/main/resources/log/AcsToErp.xml @@ -1,10 +1,7 @@ - - acs_log - acs_to_erp - ${CONTEXT_NAME} + info diff --git a/nladmin-system/src/main/resources/log/AcsToWms.xml b/nladmin-system/src/main/resources/log/AcsToWms.xml index 6ba12f1..c1d195c 100644 --- a/nladmin-system/src/main/resources/log/AcsToWms.xml +++ b/nladmin-system/src/main/resources/log/AcsToWms.xml @@ -1,10 +1,7 @@ - - acs_log - acs_to_wms - ${CONTEXT_NAME} + info diff --git a/nladmin-system/src/main/resources/log/AgvFeedbackServiceImpl.xml b/nladmin-system/src/main/resources/log/AgvFeedbackServiceImpl.xml index c236d0c..1edd79e 100644 --- a/nladmin-system/src/main/resources/log/AgvFeedbackServiceImpl.xml +++ b/nladmin-system/src/main/resources/log/AgvFeedbackServiceImpl.xml @@ -1,10 +1,7 @@ - - acs_log - agv_feedback_servlet - ${CONTEXT_NAME} + info diff --git a/nladmin-system/src/main/resources/log/AgvLeaveServlet.xml b/nladmin-system/src/main/resources/log/AgvLeaveServlet.xml index 3c9d096..ee95ac9 100644 --- a/nladmin-system/src/main/resources/log/AgvLeaveServlet.xml +++ b/nladmin-system/src/main/resources/log/AgvLeaveServlet.xml @@ -1,10 +1,7 @@ - - acs_log - agv_leave_servlet - ${CONTEXT_NAME} + info diff --git a/nladmin-system/src/main/resources/log/AutoCreateInst.xml b/nladmin-system/src/main/resources/log/AutoCreateInst.xml index 3117421..2706848 100644 --- a/nladmin-system/src/main/resources/log/AutoCreateInst.xml +++ b/nladmin-system/src/main/resources/log/AutoCreateInst.xml @@ -1,10 +1,7 @@ - - acs_log - auto_create_inst - ${CONTEXT_NAME} + info diff --git a/nladmin-system/src/main/resources/log/NDCSocketConnectionAutoRun.xml b/nladmin-system/src/main/resources/log/NDCSocketConnectionAutoRun.xml index e908af7..f674ced 100644 --- a/nladmin-system/src/main/resources/log/NDCSocketConnectionAutoRun.xml +++ b/nladmin-system/src/main/resources/log/NDCSocketConnectionAutoRun.xml @@ -1,10 +1,7 @@ - - acs_log - ndc_socket_connection_autorun - ${CONTEXT_NAME} + info diff --git a/nladmin-system/src/main/resources/log/QueryAgvTaskStatus.xml b/nladmin-system/src/main/resources/log/QueryAgvTaskStatus.xml index 565a189..90846b4 100644 --- a/nladmin-system/src/main/resources/log/QueryAgvTaskStatus.xml +++ b/nladmin-system/src/main/resources/log/QueryAgvTaskStatus.xml @@ -1,10 +1,7 @@ - - acs_log - agv_task_status - ${CONTEXT_NAME} + info diff --git a/nladmin-system/src/main/resources/log/QueryXZAgvTaskStatus.xml b/nladmin-system/src/main/resources/log/QueryXZAgvTaskStatus.xml index 4dd0141..3ec70a1 100644 --- a/nladmin-system/src/main/resources/log/QueryXZAgvTaskStatus.xml +++ b/nladmin-system/src/main/resources/log/QueryXZAgvTaskStatus.xml @@ -1,10 +1,7 @@ - - acs_log - xz_agv_task_status - ${CONTEXT_NAME} + info diff --git a/nladmin-system/src/main/resources/log/WmsToAcs.xml b/nladmin-system/src/main/resources/log/WmsToAcs.xml index 51e95e9..386c33c 100644 --- a/nladmin-system/src/main/resources/log/WmsToAcs.xml +++ b/nladmin-system/src/main/resources/log/WmsToAcs.xml @@ -1,10 +1,7 @@ - - acs_log - wms_to_acs - ${CONTEXT_NAME} + info diff --git a/nladmin-system/src/main/resources/logback-spring.xml b/nladmin-system/src/main/resources/logback-spring.xml index 5079f21..1bcd35c 100644 --- a/nladmin-system/src/main/resources/logback-spring.xml +++ b/nladmin-system/src/main/resources/logback-spring.xml @@ -16,7 +16,6 @@ https://juejin.cn/post/6844903775631572999 - @@ -57,14 +56,7 @@ https://juejin.cn/post/6844903775631572999 --> - - 127.0.0.1 - 27017 - - acs_log - default - ${CONTEXT_NAME} + info @@ -107,7 +99,7 @@ https://juejin.cn/post/6844903775631572999 - + @@ -125,7 +117,7 @@ https://juejin.cn/post/6844903775631572999 - + diff --git a/nladmin-test/pom.xml b/nladmin-test/pom.xml deleted file mode 100644 index 570b892..0000000 --- a/nladmin-test/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - hl_zgbz - org.nl - 1.0-SNAPSHOT - - 4.0.0 - 2.6 - - nladmin-test - - - - - org.nl - nladmin-system - 2.6 - compile - - - - - org.springframework.boot - spring-boot-autoconfigure - 2.0.0.RELEASE - - - org.springframework.boot - spring-boot-configuration-processor - 2.0.0.RELEASE - true - - - - - diff --git a/nladmin-test/src/main/java/org/nl/Cat.java b/nladmin-test/src/main/java/org/nl/Cat.java deleted file mode 100644 index 8ef8808..0000000 --- a/nladmin-test/src/main/java/org/nl/Cat.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.nl; - -public class Cat implements IShout { - @Override - public void shout() { - System.out.println("miao miao111"); - } -} diff --git a/nladmin-test/src/main/java/org/nl/Dog.java b/nladmin-test/src/main/java/org/nl/Dog.java deleted file mode 100644 index be93aba..0000000 --- a/nladmin-test/src/main/java/org/nl/Dog.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.nl; - -public class Dog implements IShout { - @Override - public void shout() { - System.out.println("wang wang"); - } -} diff --git a/nladmin-test/src/main/java/org/nl/IShout.java b/nladmin-test/src/main/java/org/nl/IShout.java deleted file mode 100644 index ba49fd4..0000000 --- a/nladmin-test/src/main/java/org/nl/IShout.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.nl; - -public interface IShout { - void shout(); -} diff --git a/nladmin-test/src/main/java/org/nl/Test111.java b/nladmin-test/src/main/java/org/nl/Test111.java deleted file mode 100644 index a2533da..0000000 --- a/nladmin-test/src/main/java/org/nl/Test111.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.nl; - -import io.swagger.annotations.Api; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.ServiceLoader; - -@RestController -@RequiredArgsConstructor -@Api(tags = "运维:应用管理") -@RequestMapping("/api/test") -public class Test111 { - public static void main(String[] args) { - ServiceLoader shouts = ServiceLoader.load(IShout.class); - for (IShout s : shouts) { - s.shout(); - } - } - @GetMapping(value = "/test") - public String getStr() { - return "hello"; - } - -} diff --git a/nladmin-test/src/main/java/org/nl/starter/TianProperties.java b/nladmin-test/src/main/java/org/nl/starter/TianProperties.java deleted file mode 100644 index 1e01819..0000000 --- a/nladmin-test/src/main/java/org/nl/starter/TianProperties.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.nl.starter; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -@ConfigurationProperties(prefix = "spring.tian") -@Data -public class TianProperties { - private String name; - private int age; - private String sex = "M"; -} diff --git a/nladmin-test/src/main/java/org/nl/starter/TianService.java b/nladmin-test/src/main/java/org/nl/starter/TianService.java deleted file mode 100644 index 19db779..0000000 --- a/nladmin-test/src/main/java/org/nl/starter/TianService.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.nl.starter; - -public class TianService { - private TianProperties properties; - public TianService() { - } - public TianService(TianProperties userProperties) { - this.properties = userProperties; - } - public void sayHello(){ - System.out.println("hi, 我叫: " + properties.getName() + - ", 今年" + properties.getAge() + "岁" - + ", 性别: " + properties.getSex()); - } -} diff --git a/nladmin-test/src/main/java/org/nl/starter/TianServiceAutoConfiguration.java b/nladmin-test/src/main/java/org/nl/starter/TianServiceAutoConfiguration.java deleted file mode 100644 index 1d84981..0000000 --- a/nladmin-test/src/main/java/org/nl/starter/TianServiceAutoConfiguration.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.nl.starter; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -@EnableConfigurationProperties(TianProperties.class) -@ConditionalOnClass(TianService.class) -@ConditionalOnProperty(prefix = "spring.tian", value = "enabled", matchIfMissing = true) -public class TianServiceAutoConfiguration { - @Autowired - private TianProperties properties; - @Bean - @ConditionalOnMissingBean(TianService.class) - public TianService tianService() { - return new TianService(properties); - } -} diff --git a/nladmin-test/src/main/resources/META-INF/services/org.nl.IShout b/nladmin-test/src/main/resources/META-INF/services/org.nl.IShout deleted file mode 100644 index 9c82046..0000000 --- a/nladmin-test/src/main/resources/META-INF/services/org.nl.IShout +++ /dev/null @@ -1,2 +0,0 @@ -org.nl.Cat -org.nl.Dog diff --git a/nladmin-test/src/main/resources/META-INF/services/spring.factories b/nladmin-test/src/main/resources/META-INF/services/spring.factories deleted file mode 100644 index 8b0aee2..0000000 --- a/nladmin-test/src/main/resources/META-INF/services/spring.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=org.nl.starter.TianServiceAutoConfiguration - diff --git a/nladmin-test/src/test/java/Test.java b/nladmin-test/src/test/java/Test.java deleted file mode 100644 index 7b8bf75..0000000 --- a/nladmin-test/src/test/java/Test.java +++ /dev/null @@ -1,19 +0,0 @@ -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; - -import java.util.HashMap; - -public class Test { - public static void main(String[] args) { - JSONObject json=new JSONObject(); - json.put("id","1493102834739187714"); - System.out.println(json.getLong("id")); - System.out.println(json.getString("id")); - - HashMap map=new HashMap(); - map.put("a","1"); - map.put("b","2"); - JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(map)); - System.out.println(jsonObject); - } -} diff --git a/pom.xml b/pom.xml index ae38742..45f1ec3 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,6 @@ nladmin-system - nladmin-test