diff --git a/acs/nladmin-system/pom.xml b/acs/nladmin-system/pom.xml index 9d3187d..4ce11ae 100644 --- a/acs/nladmin-system/pom.xml +++ b/acs/nladmin-system/pom.xml @@ -35,11 +35,11 @@ - - org.bouncycastle - bcprov-jdk15on - 1.50 - + + + + + org.apache.commons @@ -70,21 +70,45 @@ org.openscada.jinterop org.openscada.jinterop.core 2.1.8 + + + org.bouncycastle + bcprov-jdk15on + + org.openscada.jinterop org.openscada.jinterop.deps 1.5.0 + + + org.bouncycastle + bcprov-jdk15on + + org.openscada.utgard org.openscada.opc.dcom 1.5.0 + + + org.bouncycastle + bcprov-jdk15on + + org.openscada.utgard org.openscada.opc.lib 1.5.0 + + + org.bouncycastle + bcprov-jdk15on + + com.squareup.okhttp3 @@ -447,45 +471,27 @@ ${lucene.version} - - - - - - nexus - - nexus - http://121.40.234.130:8081/repository/maven-releases/ - - - - - + ${project.artifactId} org.springframework.boot spring-boot-maven-plugin - + 2.2.10.RELEASE org.nl.AppRun + true + - - - - org.apache.maven.plugins - maven-surefire-plugin - - true - + + + + repackage + + + - @@ -504,7 +510,5 @@ - - diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/AcsConfig.java b/acs/nladmin-system/src/main/java/org/nl/acs/AcsConfig.java index 77cbff7..4719225 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/AcsConfig.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/AcsConfig.java @@ -30,6 +30,10 @@ public interface AcsConfig { String AGVTYPE = "agvType"; //WMS系统接口地址 String WMSURL = "wmsurl"; + //MES系统接口地址 + String MESURL = "mesurl"; + //MES系统接口地址 +// String MESURL = "mesurl"; //WCS系统接口地址 String WCSURL = "wcsurl"; @@ -38,6 +42,8 @@ public interface AcsConfig { String ERPURL = "erpurl"; //是否存在wms系统 String HASWMS = "hasWms"; + //是否存在mes系统 + String HASMES = "hasMes"; //路由选择 String ROUTE = "route"; //忽略取放货校验 diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java index abc3185..b94840b 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/NDCAgvService.java @@ -31,6 +31,8 @@ public interface NDCAgvService { public byte[] sendAgvOneModeInst(int phase, int index,int result); + public byte[] sendAgvOneModeInst(int phase, int index,int result,Instruction inst); + public byte[] sendAgvTwoModeInst(int phase, int index,int result); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java index 28be8fc..bfef3a3 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java @@ -1,5 +1,6 @@ package org.nl.acs.agv.server.impl; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -14,6 +15,7 @@ import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.log.LokiLog; import org.nl.acs.log.LokiLogType; import org.nl.acs.log.service.DeviceExecuteLogService; +import org.nl.acs.opc.Device; import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppServiceImpl; import org.nl.modules.system.service.ParamService; @@ -30,13 +32,13 @@ import java.util.Map; @RequiredArgsConstructor public class NDCAgvServiceImpl implements NDCAgvService { @Autowired - private DeviceAppService deviceAppService; + private DeviceAppService deviceAppService; @Autowired - private ParamService paramService; + private ParamService paramService; @Autowired - private AcsToWmsService acsToWmsService; + private AcsToWmsService acsToWmsService; @Autowired - private DeviceExecuteLogService logServer; + private DeviceExecuteLogService logServer; Map AGVDeviceStatus = new HashMap(); @@ -76,6 +78,9 @@ public class NDCAgvServiceImpl implements NDCAgvService { @LokiLog(type = LokiLogType.AGV) @Override public void sendAgvInstToNDC(String agv_system_type, Instruction inst) { + log.info("sendAgvInstToNDC 指令下发NDC:" + "inst_code:" + inst.getInstruction_code() + ",agv_system_type:" + agv_system_type + ",agv_inst_type:" + inst.getAgv_inst_type() + + ",priority:" + inst.getPriority() + ",startAddress:" + inst.getStart_point_code() + + ",nextAddress:" + inst.getNext_point_code()); if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) { String instcode = inst.getInstruction_code(); int type = Integer.parseInt(inst.getAgv_inst_type()); @@ -83,7 +88,7 @@ public class NDCAgvServiceImpl implements NDCAgvService { 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()); + int nextAddress = deviceService.queryAddressBynextdeviceCode(inst.getNext_point_code()); byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode)); byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode)); byte typehigh = (byte) IntToHexHigh(type); @@ -93,37 +98,71 @@ public class NDCAgvServiceImpl implements NDCAgvService { 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); + if (ObjectUtil.isNotEmpty(inst.getCarno())) { + int carNo = Integer.parseInt(inst.getCarno()); + byte agvnohigh = (byte) IntToHexHigh(carNo); + byte agvnolow = (byte) IntToHexLow(carNo); + str += "agv车号 /carNo:" + (carNo); + str1 += "agv车号 /carNo:" + hexToString(agvnolow & 0xFF); + } + 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); + + byte[] b = new byte[]{}; + if (ObjectUtil.isNotEmpty(inst.getCarno())){ + int carNo = Integer.parseInt(inst.getCarno()); + byte agvnohigh = (byte) IntToHexHigh(carNo); + byte agvnolow = (byte) IntToHexLow(carNo); + b = new byte[]{(byte) 0X87, (byte) 0XCD, + (byte) 0X00, (byte) 0X08, + (byte) 0X00, (byte) 0X14, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X71, + (byte) 0X00, (byte) 0X10, + (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, + (byte) agvnohigh, (byte) agvnolow + }; + }else { + 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); + log.info("下发AGV作业指令--{}", str); + log.info("下发agv指令数据--{}", Bytes2HexString(b)); OneNDCSocketConnectionAutoRun.write(b); - System.out.println("下发agv指令数据:" + Bytes2HexString(b)); } } @@ -155,6 +194,111 @@ public class NDCAgvServiceImpl implements NDCAgvService { } + @Override + public byte[] sendAgvOneModeInst(int phase, int index, int result,Instruction inst) { + if (inst.getAgv_inst_type().equals("1")){ + return sendAgvOneModeInst(phase, index, result); + } + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); + Device startDevice = appService.findDeviceByCode(inst.getStart_point_code()); + Device nextDevice = appService.findDeviceByCode(inst.getNext_point_code()); + String startLinkDeviceCode = ""; + String nextLinkDeviceCode = ""; + int start2Address = 0; + int next2Address = 0; + int startLinkAddress = 0; + int nextLinkAddress = 0; + if (inst.getAgv_inst_type().equals("3")) { + startLinkDeviceCode = String.valueOf(startDevice.getExtraValue().get("link_device_code")); + nextLinkDeviceCode = String.valueOf(nextDevice.getExtraValue().get("link_device_code")); + startLinkAddress = deviceService.queryAddressBydeviceCode(startLinkDeviceCode); + nextLinkAddress = deviceService.queryAddressBynextdeviceCode(nextLinkDeviceCode); + } + int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code()); + int nextAddress = deviceService.queryAddressBynextdeviceCode(inst.getNext_point_code()); + if (!inst.getAgv_inst_type().equals("1")){ + start2Address = deviceService.queryAddressBydeviceCode(inst.getStart_point_code2()); + next2Address = deviceService.queryAddressBynextdeviceCode(inst.getNext_point_code2()); + } + + byte qhdhigh = 0; + byte qhdlow = 0; + byte fhdhigh = 0; + byte fhdlow = 0; + byte addrHigh = 0; + byte addrLow = 0; + 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); + if (inst.getAgv_inst_type().equals("2")){ + if (phase == 0x09) { + qhdhigh = (byte) IntToHexHigh(start2Address); + qhdlow = (byte) IntToHexLow(start2Address); + addrHigh = qhdhigh; + addrLow = qhdlow; + }else if (phase == 0x0D) { + fhdhigh = (byte) IntToHexHigh(next2Address); + fhdlow = (byte) IntToHexLow(next2Address); + addrHigh = fhdhigh; + addrLow = fhdlow; + } + }else if (inst.getAgv_inst_type().equals("3")) { + if (phase == 0x09) { + qhdhigh = (byte) IntToHexHigh(nextAddress); + qhdlow = (byte) IntToHexLow(nextAddress); + addrHigh = qhdhigh; + addrLow = qhdlow; + }else if (phase == 0x11) { + qhdhigh = (byte) IntToHexHigh(startLinkAddress); + qhdlow = (byte) IntToHexLow(startLinkAddress); + addrHigh = qhdhigh; + addrLow = qhdlow; + }else if (phase == 0x19){ + qhdhigh = (byte) IntToHexHigh(nextLinkAddress); + qhdlow = (byte) IntToHexLow(nextLinkAddress); + addrHigh = qhdhigh; + addrLow = qhdlow; + }else if (phase == 0x0D){ + fhdhigh = (byte) IntToHexHigh(nextLinkAddress); + fhdlow = (byte) IntToHexLow(nextLinkAddress); + addrHigh = fhdhigh; + addrLow = fhdlow; + }else if (phase == 0x15){ + fhdhigh = (byte) IntToHexHigh(start2Address); + fhdlow = (byte) IntToHexLow(start2Address); + addrHigh = fhdhigh; + addrLow = fhdlow; + }else if (phase == 0x1D){ + fhdhigh = (byte) IntToHexHigh(next2Address); + fhdlow = (byte) IntToHexLow(next2Address); + addrHigh = fhdhigh; + addrLow = fhdlow; + } + } + byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, + (byte) 0X00, (byte) 0X08, + (byte) 0X00, (byte) 0X0C, + (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) addrHigh, (byte) addrLow, + }; + + + 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 byte[] sendAgvTwoModeInst(int phase, int index, int result) { @@ -217,9 +361,9 @@ public class NDCAgvServiceImpl implements NDCAgvService { }; log.info("下发AGV充电任务--{}", str1); - try{ + try { OneNDCSocketConnectionAutoRun.write(b); - } catch (Exception e){ + } catch (Exception e) { e.getMessage(); return false; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java b/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java index e8672f2..ed8a01b 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/auto/run/OneNDCSocketConnectionAutoRun.java @@ -159,7 +159,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { } //任务完毕 //(无车id及状态) - else if (phase == 0x0A) { + else if (phase == 0x22) { if (!ObjectUtil.isEmpty(inst)) { if (!ObjectUtil.isEmpty(inst)) { diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device.xls b/acs/nladmin-system/src/main/java/org/nl/acs/device.xls index 1c3db51..1664120 100644 Binary files a/acs/nladmin-system/src/main/java/org/nl/acs/device.xls and b/acs/nladmin-system/src/main/java/org/nl/acs/device.xls differ diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/address/wql/sys_config.xls b/acs/nladmin-system/src/main/java/org/nl/acs/device/address/wql/sys_config.xls index b0b5f2a..bac9ea7 100644 Binary files a/acs/nladmin-system/src/main/java/org/nl/acs/device/address/wql/sys_config.xls and b/acs/nladmin-system/src/main/java/org/nl/acs/device/address/wql/sys_config.xls differ diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/rest/TaskConfigController.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/rest/TaskConfigController.java new file mode 100644 index 0000000..98458fc --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/rest/TaskConfigController.java @@ -0,0 +1,61 @@ +package org.nl.acs.device.rest; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.service.TaskConfigService; +import org.nl.acs.device.service.dto.TaskConfigDto; +import org.nl.modules.logging.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 java.util.Map; + +@RestController +@RequiredArgsConstructor +@Api(tags = "任务配置管理") +@RequestMapping("/api/TaskConfig") +@Slf4j +public class TaskConfigController { + private final TaskConfigService taskConfigService; + + + @GetMapping + @Log("查询任务配置") + @ApiOperation("查询任务配置") + //@PreAuthorize("@el.check('Address:list')") + public ResponseEntity query(@RequestParam Map whereJson, Pageable page) { + return new ResponseEntity<>(taskConfigService.queryAll(whereJson, page), HttpStatus.OK); + } + + @PostMapping + @Log("新增任务配置") + @ApiOperation("新增任务配置") + //@PreAuthorize("@el.check('Address:add')") + public ResponseEntity create(@Validated @RequestBody TaskConfigDto dto) { + taskConfigService.create(dto); + return new ResponseEntity<>(HttpStatus.CREATED); + } + + @PutMapping + @Log("修改任务配置") + @ApiOperation("修改任务配置") + //@PreAuthorize("@el.check('Address:edit')") + public ResponseEntity update(@Validated @RequestBody TaskConfigDto dto) { + taskConfigService.update(dto); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @Log("删除任务配置") + @ApiOperation("删除任务配置") + //@PreAuthorize("@el.check('Address:del')") + @DeleteMapping + public ResponseEntity delete(@RequestBody String[] ids) { + taskConfigService.deleteAll(ids); + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java index 80ca668..9e8c664 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/DeviceService.java @@ -266,6 +266,8 @@ public interface DeviceService { int queryAddressBydeviceCode(String code); + int queryAddressBynextdeviceCode(String code); + String queryDeviceCodeByAddress(int address); List findCacheDevice(); diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/TaskConfigService.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/TaskConfigService.java new file mode 100644 index 0000000..9ee0c98 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/TaskConfigService.java @@ -0,0 +1,60 @@ +package org.nl.acs.device.service; + +import org.nl.acs.device.service.dto.TaskConfigDto; +import org.springframework.data.domain.Pageable; + +import java.util.List; +import java.util.Map; + +public interface TaskConfigService { + + /** + * 查询数据分页 + * + * @param whereJson 条件 + * @param page 分页参数 + * @return Map + */ + Map queryAll(Map whereJson, Pageable page); + + /** + * 查询所有数据不分页 + * + * @param whereJson 条件参数 + * @return List + */ + List queryAll(Map whereJson); + + /** + * 根据ID查询 + * + * @param task_config_id ID + * @return Address + */ + TaskConfigDto findById(String task_config_id); + + + + /** + * 创建 + * + * @param dto / + */ + void create(TaskConfigDto dto); + + /** + * 编辑 + * + * @param dto / + */ + void update(TaskConfigDto dto); + + /** + * 多选删除 + * + * @param ids / + */ + void deleteAll(String[] ids); + + TaskConfigDto selectTaskConfigByStartPointAndTaskType(String point_code1, String task_type); +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/dto/StorageCellDto.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/dto/StorageCellDto.java index 0ce97e4..ff81d85 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/dto/StorageCellDto.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/dto/StorageCellDto.java @@ -43,10 +43,15 @@ public class StorageCellDto implements Serializable { private String z; /** - * 地址 + * 取货地址 */ private int address; + /** + * 卸货地址 + */ + private int address1; + /** * 备注 */ diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/dto/TaskConfigDto.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/dto/TaskConfigDto.java new file mode 100644 index 0000000..e5cd270 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/dto/TaskConfigDto.java @@ -0,0 +1,92 @@ +package org.nl.acs.device.service.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class TaskConfigDto implements Serializable { + /** 方法标识 */ + /** + * 防止精度丢失 + */ + @JsonSerialize(using = ToStringSerializer.class) + private String task_config_id; + + /** + * 任务类型 + */ + private String task_type; + + /** + * 起点1 + */ + private String point_code1; + + /** + * 终点1 + */ + private String point_code2; + + /** + * 起点2 + */ + private String point_code3; + + /** + * 终点2 + */ + private String point_code4; + + /** + * 备注 + */ + private String remark; + + /** + * 创建人 + */ + private Long create_by; + + /** + * 创建人id + */ + private Long create_id; + + /** + * 创建人id + */ + private String create_name; + + /** + * 创建时间 + */ + private String create_time; + + /** + * 修改人 + */ + private Long update_by; + + /** + * 修改人 + */ + private Long update_optid; + + /** + * 修改人 + */ + private String update_optname; + + /** + * 修改时间 + */ + private String update_time; + + /** + * 是否删除 + */ + private String is_delete; +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java index a50e0ed..c635b85 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/DeviceServiceImpl.java @@ -260,15 +260,12 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial log.info("设备删除成功!"); if (deviceByCode != null) { - if (StrUtil.equals("storage", deviceByCode.getDeviceDriverDefination().getFitDeviceTypes().get(0).name())) { - storageTab.delete("substring_index( storage_code,'-',1)= '" + device_code + "'"); - } else { - JSONObject data = storageTab.query("storage_code ='" + device_code + "'").uniqueResult(0); - if (!ObjectUtil.isEmpty(data)) { - storageTab.delete("storage_code = '" + device_code + "'"); - } + JSONObject data = storageTab.query("storage_code ='" + device_code + "'").uniqueResult(0); + if (!ObjectUtil.isEmpty(data)) { + storageTab.delete("storage_code = '" + device_code + "'"); } + } wo.delete("device_id = '" + device_id + "'"); } @@ -854,10 +851,6 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial @Override public void changeDeviceStatus(JSONObject form) { String device_code = form.getString("device_code"); - if (StrUtil.contains(device_code, "-") && StrUtil.count(device_code, "-") == 2) { - String[] point = device_code.split("-"); - device_code = point[0]; - } //需要数量 String hasGoodStatus = form.getString("hasGoodStatus"); if (StrUtil.isEmpty(hasGoodStatus)) { @@ -953,7 +946,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial } else if (device.getDeviceDriver() instanceof SiemensConveyorCkkDeviceDriver) { SiemensConveyorCkkDeviceDriver siemensConveyorCkkDeviceDriver = (SiemensConveyorCkkDeviceDriver) device.getDeviceDriver(); siemensConveyorCkkDeviceDriver.setDeviceStatus(form); - } else if (device.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver){ + } else if (device.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) { StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) device.getDeviceDriver(); standardCoveyorControlWithScannerDeviceDriver.setDeviceStatus(form); @@ -1556,12 +1549,24 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial return 0; } + @Override + public int queryAddressBynextdeviceCode(String code) { + Iterator iterator = storageCells.iterator(); + while (iterator.hasNext()) { + StorageCellDto storageCellDto = (StorageCellDto) iterator.next(); + if (storageCellDto.getStorage_code().equals(code)) { + return storageCellDto.getAddress1(); + } + } + return 0; + } + @Override public String queryDeviceCodeByAddress(int code) { Iterator iterator = storageCells.iterator(); while (iterator.hasNext()) { StorageCellDto storageCellDto = (StorageCellDto) iterator.next(); - if (storageCellDto.getAddress() == code) { + if (storageCellDto.getAddress() == code ||storageCellDto.getAddress1() == code) { return storageCellDto.getStorage_code(); } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/TaskConfigServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/TaskConfigServiceImpl.java new file mode 100644 index 0000000..9a4b4ad --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/service/impl/TaskConfigServiceImpl.java @@ -0,0 +1,119 @@ +package org.nl.acs.device.service.impl; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.address.service.dto.AddressDto; +import org.nl.acs.device.service.TaskConfigService; +import org.nl.acs.device.service.dto.TaskConfigDto; +import org.nl.modules.common.exception.BadRequestException; +import org.nl.modules.common.utils.SecurityUtils; +import org.nl.modules.wql.WQL; +import org.nl.modules.wql.core.bean.WQLObject; +import org.nl.modules.wql.util.WqlUtil; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +@Service +@RequiredArgsConstructor +@Slf4j +public class TaskConfigServiceImpl implements TaskConfigService { + @Override + public Map queryAll(Map whereJson, Pageable page) { + String blurry = ""; + if (whereJson.get("blurry") != null) { + blurry = (String) whereJson.get("blurry"); + } + JSONObject jo = WQL.getWO("taskConfig").addParam("flag", "3").addParam("blurry", blurry).pageQuery(WqlUtil.getHttpContext(page), "update_time desc"); + return jo; + } + + @Override + public List queryAll(Map whereJson) { + WQLObject wo = WQLObject.getWQLObject("task_config"); + JSONArray arr = wo.query().getResultJSONArray(0); + List list = arr.toJavaList(TaskConfigDto.class); + return list; + } + + @Override + public TaskConfigDto findById(String task_config_id) { + WQLObject wo = WQLObject.getWQLObject("task_config"); + JSONObject json = wo.query("task_config_id ='" + task_config_id + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(json)) { + return null; + } + final TaskConfigDto obj = json.toJavaObject(TaskConfigDto.class); + return obj; + } + + + @Override + public void create(TaskConfigDto dto) { + String task_config_id = dto.getTask_config_id(); + TaskConfigDto taskConfigDto = this.findById(task_config_id); + if (taskConfigDto != null) { + throw new BadRequestException("存在相同的任务配置"); + } + Long userId = SecurityUtils.getCurrentUserId(); + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + + dto.setTask_config_id(IdUtil.simpleUUID()); + dto.setCreate_id(userId); + dto.setCreate_name(currentUsername); + dto.setCreate_by(userId); + dto.setUpdate_by(userId); + dto.setUpdate_time(now); + dto.setCreate_time(now); + + WQLObject wo = WQLObject.getWQLObject("task_config"); + JSONObject json = (JSONObject) JSONObject.toJSON(dto); + + wo.insert(json); + } + + @Override + public void update(TaskConfigDto dto) { + TaskConfigDto entity = this.findById(dto.getTask_config_id()); + if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); + + Long userId = SecurityUtils.getCurrentUserId(); + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + dto.setUpdate_optid(userId); + dto.setUpdate_optname(currentUsername); + dto.setUpdate_time(now); + dto.setUpdate_by(userId); + + WQLObject wo = WQLObject.getWQLObject("task_config"); + JSONObject json = (JSONObject) JSONObject.toJSON(dto); + wo.update(json); + } + + @Override + public void deleteAll(String[] ids) { + WQLObject wo = WQLObject.getWQLObject("task_config"); + for (String task_config_id : ids) { + wo.delete("task_config_id = '" + task_config_id + "'"); + } + } + + @Override + public TaskConfigDto selectTaskConfigByStartPointAndTaskType(String point_code1, String task_type) { + WQLObject wo = WQLObject.getWQLObject("task_config"); + JSONObject json = wo.query("point_code1 = '" + point_code1 + "' and task_type = '" + task_type + "'").uniqueResult(0); + if (ObjectUtil.isEmpty(json)) { + return null; + } + final TaskConfigDto obj = json.toJavaObject(TaskConfigDto.class); + return obj; + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/wql/taskConfig.wql b/acs/nladmin-system/src/main/java/org/nl/acs/device/wql/taskConfig.wql new file mode 100644 index 0000000..e75aa99 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device/wql/taskConfig.wql @@ -0,0 +1,137 @@ +[交易说明] + 交易名: 设备基础信息查询 + 所属模块: + 功能简述: + 版权所有: + 表引用: + 版本经历: + +[数据库] + --指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 + +[IO定义] + ################################################# + ## 表字段对应输入参数 + ################################################# + 输入.flag TYPEAS s_string + //模糊查询 + 输入.blurry TYPEAS s_string + //设备类型 + 输入.device_type TYPEAS s_string + //opc_server + 输入.opc_id TYPEAS s_string + 输入.task_type TYPEAS s_string + 输入.task_config_id TYPEAS s_string + 输入.blurry TYPEAS s_string +[临时表] + --这边列出来的临时表就会在运行期动态创建 + +[临时变量] + --所有中间过程变量均可在此处定义 + +[业务过程] + + ########################################## + # 1、输入输出检查 # + ########################################## + + + ########################################## + # 2、主过程前处理 # + ########################################## + + + ########################################## + # 3、业务主过程 # + ########################################## + IF 输入.flag = "1" + PAGEQUERY + SELECT + d.*, dict.label AS device_type_name, + dict2.label AS region_name + FROM + ACS_DEVICE d + LEFT JOIN sys_dict_detail dict ON dict.value = d.device_type + AND dict.`name` = 'device_type' + LEFT JOIN sys_dict_detail dict2 ON dict2.value = d.region + AND dict2.`name` = 'region_type' + WHERE + is_delete = '0' + OPTION 输入.blurry <> "" + ( d.device_code LIKE 输入.blurry or d.device_name LIKE 输入.blurry) + ENDOPTION + OPTION 输入.device_type <> "" + d.device_type = 输入.device_type + ENDOPTION + ENDSELECT + ENDPAGEQUERY + ENDIF + IF 输入.flag = "2" + QUERY + SELECT + d.device_id,d.device_code,d.driver_code,d.device_type, + e.extra_code,e.extra_name, + opc.opc_code,plc.plc_code + FROM + acs_device_extra e + LEFT JOIN acs_device d ON e.device_id = d.device_id + LEFT JOIN acs_opc opc ON d.opc_server_id = opc.opc_id + LEFT JOIN acs_opc_plc plc ON d.opc_plc_id = plc.plc_id + WHERE + d.is_delete = '0' + and e.filed_type != '01' + OPTION 输入.blurry <> "" + ( d.device_code LIKE 输入.blurry or d.device_name LIKE 输入.blurry) + ENDOPTION + OPTION 输入.device_type <> "" + d.device_type = 输入.device_type + ENDOPTION + OPTION 输入.opc_id <> "" + d.opc_server_id = 输入.opc_id + ENDOPTION + ORDER BY d.device_code,e.extra_name + ENDSELECT + ENDQUERY + ENDIF + + IF 输入.flag = "3" + PAGEQUERY + SELECT + * + FROM + task_config as config + WHERE + 1=1 + OPTION 输入.blurry <> "" + config.task_type like "%" 输入.blurry "%" + ENDOPTION + ENDSELECT + ENDPAGEQUERY + ENDIF + + IF 输入.flag = "4" + SELECT + * + FROM + sys_interface_methods_address as address + WHERE + 1=1 + OPTION 输入.methods_code <> "" + address.methods_code = 输入.methods_code + ENDOPTION + + ENDSELECT + ENDIF + + IF 输入.flag = "5" + SELECT + * + FROM + sys_interface_methods_address as address + WHERE + 1=1 + OPTION 输入.methods_id <> "" + address.methods_id = 输入.methods_id + ENDOPTION + ENDSELECT + ENDIF diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device/wql/task_inst.xls b/acs/nladmin-system/src/main/java/org/nl/acs/device/wql/task_inst.xls index 665ebb7..c0f6de1 100644 Binary files a/acs/nladmin-system/src/main/java/org/nl/acs/device/wql/task_inst.xls and b/acs/nladmin-system/src/main/java/org/nl/acs/device/wql/task_inst.xls differ diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java index 9eb6590..f5ef64f 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java @@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject; import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import net.dreamlu.mica.core.utils.StringUtil; import org.nl.acs.AcsConfig; import org.nl.acs.agv.server.NDCAgvService; import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun; @@ -14,9 +15,11 @@ import org.nl.acs.device.service.DeviceService; import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.basedriver.lubei_conveyor.LubeiConveyorDeviceDriver; import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver; +import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_storage.StandardStorageDeviceDriver; import org.nl.acs.device_driver.driver.AbstractDeviceDriver; +import org.nl.acs.ext.wms.service.AcsToMesService; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.AcsToWmsZDService; import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; @@ -34,6 +37,8 @@ import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceManageDto; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; +import org.nl.modules.common.utils.DateUtil; +import org.nl.modules.common.utils.StringUtils; import org.nl.modules.lucene.service.dto.LuceneLogDto; import org.nl.modules.system.service.ParamService; import org.nl.modules.system.service.impl.ParamServiceImpl; @@ -88,7 +93,6 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic int mode = 2; - // @LokiLog(type = LokiLogType.AGV) public synchronized void processSocket(int[] arr) throws Exception { device_code = this.getDeviceCode(); byte[] data = null; @@ -104,30 +108,16 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic Instruction inst = null; AcsToWmsZDService acsToWmsZDService = SpringContextHolder.getBean("acsToWmsZDServiceImpl"); + AcsToMesService acsToMesService = SpringContextHolder.getBean("acsToMesServiceImpl"); logServer.deviceExecuteLog(this.device_code, "", "", "接收agv上报信息:" + "phase--" + phase + " index--" + index + " 指令号--" + ikey + " 站点号--" + agvaddr + " 车号--" + carno); Instruction link_inst = null; - List insts = null; - boolean link_flag = false; - Device agv_device = null; - if (carno != 0) { - agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno)); - } if (ikey != 0) { if (phase != 0x67 && phase != 0x71 && phase != 0x72 && phase != 0x73 && phase != 0x74 && phase != 0x75) { inst = instructionService.findByCodeFromCache(String.valueOf(ikey)); this.instruction = inst; } -// if (ObjectUtil.isEmpty(inst)){ -// inst = instructionService.findByCode(String.valueOf(ikey)); -// } } - if (!ObjectUtil.isEmpty(link_inst)) { - link_flag = true; - } - Device device = null; - String old_device_code = null; - String emptyNum = null; String device_code = null; // if (phase == 0x67) { @@ -138,30 +128,401 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic // data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); // } - //普通站点 - StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; - //货架 - StandardStorageDeviceDriver standardStorageDeviceDriver; - // - SiemensConveyorDeviceDriver siemensConveyorDeviceDriver; //将车号写入DeviceManageDto DeviceManageDto deviceManageDto = new DeviceManageDto(); deviceManageDto.setCarno(carno); - LubeiConveyorDeviceDriver lubeiConveyorDeviceDriver; - boolean is_feedback = false; - String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue(); + String hasMes = paramService.findByCode(AcsConfig.HASMES).getValue(); //分配 车id //(不需要WCS反馈) if (phase == 0x02) { inst.setCarno(String.valueOf(carno)); instructionService.update(inst); logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈车号:" + carno + ",指令号:" + ikey); - //到达取货点 - //(需要WCS反馈) + //(Itype=1/2/3,需要WCS反馈Phase) } else if (phase == 0x03) { + log.info("==================AGV请求取货=================="); + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到指令:" + device_code + ikey); + return; + } + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + log.info("{},{}", device_code, "agv地址参数有误,phase:" + phase); + return; + } + device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + if (ObjectUtil.isEmpty(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + return; + } + device = deviceAppService.findDeviceByCode(device_code); + TaskService taskService = SpringContextHolder.getBean("taskServiceImpl"); + TaskDto task = taskService.findByCode(inst.getTask_code()); + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv允许取货信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + Object ext_system = device.getExtraValue().get("ext_system"); + //检测站点,安全交互类型为中鼎的 + if (!StringUtil.isEmpty(ext_system)) { + if (ext_system.equals("1")) { + JSONObject jo = new JSONObject(); + jo.put("taskCode", task.getTask_code()); + jo.put("carId", carno); + jo.put("taskType ", task.getTask_type()); + jo.put("feedbackStatus", "applyTake"); + log.info("请求wms取货完成参数:{}", jo); + HttpResponse result = acsToWmsZDService.taskFeedback(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int responseCode = response.getInteger("responseCode"); + if (responseCode == 0) { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.error("请求wms取货失败参数:{}", response); + } + //焊接线 + } else if (ext_system.equals("3")) { + JSONObject jo1 = new JSONObject(); + jo1.put("point", device_code); + jo1.put("type", "1"); + jo1.put("containerCode", task.getVehicle_code()); + Object url = device.getExtraValue().get("address"); + if (StringUtil.isEmpty(ext_system)) { + log.error("请求安全交互失败,未配置焊接线IP" + device_code); + } + jo1.put("url", url); + HttpResponse result = acsToMesService.actionRequest(jo1); + JSONObject response = JSONObject.parseObject(result.body()); + int code = response.getInteger("code"); + if (code == 200) { + log.info("请求Mes成功,申请取货 请求结果{}", code); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.error("请求Mes失败,申请区货 错误信息{}", response); + } + }else if (ext_system.equals("2")){ + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + } else { + log.error("检测站点未配置检测系统"); + return; + } + } + } + //取货完毕 + //(Itype=1/2/3,需要WCS反馈Phase) + } else if (phase == 0x05) { + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); + return; + } + device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + device = deviceAppService.findDeviceByCode(device_code); + + if (ObjectUtil.isEmpty(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + logServer.deviceExecuteLog(this.device_code, "", "", "对应设备号为空" + device_code); + return; + } + //校验agv上报站点编号与指令起始点相同 + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到关联编号{}对应的指令", ikey); + logServer.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey); + return; + } + TaskService taskService = SpringContextHolder.getBean("taskServiceImpl"); + TaskDto task = taskService.findByCode(inst.getTask_code()); + + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv允许取货信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else + { + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + Object ext_system = device.getExtraValue().get("ext_system"); + //检测站点,安全交互类型为中鼎的 + if (!StringUtil.isEmpty(ext_system)) { + if (ext_system.equals("1")) { + JSONObject jo = new JSONObject(); + jo.put("taskCode", task.getTask_code()); + jo.put("carId", carno); + jo.put("taskType ", task.getTask_type()); + jo.put("feedbackStatus", "takeFinish"); + log.info("请求wms取货完成参数:{}", jo); + HttpResponse result = acsToWmsZDService.taskFeedback(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int responseCode = response.getInteger("responseCode"); + if (responseCode == 0) { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.error("请求wms取货失败参数:{}", response); + } + //焊接线 + } else if (ext_system.equals("3")) { + JSONObject jo = new JSONObject(); + jo.put("taskCode", task.getTask_code()); + jo.put("carId", carno); + jo.put("taskType ", task.getTask_type()); + jo.put("feedbackStatus", "takeFinish"); + log.info("请求wms取货完成参数:{}", jo); + HttpResponse result = acsToWmsZDService.taskFeedback(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int responseCode = response.getInteger("responseCode"); + if (responseCode == 0) { + log.info("请求ZDwcs成功,取货完成 请求结果{}", responseCode); + JSONObject jo1 = new JSONObject(); + jo1.put("point", device_code); + jo1.put("type", "3"); + jo1.put("containerCode", task.getVehicle_code()); + Object url = device.getExtraValue().get("address"); + if (StringUtil.isEmpty(ext_system)) { + log.error("请求安全交互失败,未配置焊接线IP" + device_code); + } + jo1.put("url", url); + HttpResponse result2 = acsToMesService.actionFinish(jo1); + JSONObject response2 = JSONObject.parseObject(result2.body()); + int code = response2.getInteger("code"); + if (code == 200) { + log.info("请求Mes成功,申请取货完成 请求结果{}", code); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.info("请求Mes失败,申请取货完成 错误信息{}", response2); + } + } else { + log.info("请求ZDwcs失败,取货完成 错误码{}", responseCode); + } + //只跟MES交互的点 + } else if (ext_system.equals("2")) { + JSONObject jo = new JSONObject(); + jo.put("taskCode", task.getTask_code()); + jo.put("carId", carno); + jo.put("taskType ", task.getTask_type()); + jo.put("feedbackStatus", "takeFinish"); + log.info("请求wms取货完成参数:{}", jo); + HttpResponse result = acsToWmsZDService.taskFeedback(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int responseCode = response.getInteger("responseCode"); + if (responseCode == 0) { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + } + } + } else { + log.error("检测站点未配置检测系统"); + return; + } + } + + if (ObjectUtil.isNotEmpty(data)) { + logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + Bytes2HexString(data)); + } + //到达放货点 + //(Itype=1/2/3,需要WCS反馈Phase) + } else if (phase == 0x07) { + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); + return; + } + device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + + device = deviceAppService.findDeviceByCode(device_code); + if (ObjectUtil.isEmpty(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + return; + } + TaskService taskService = SpringContextHolder.getBean("taskServiceImpl"); + TaskDto task = taskService.findByCode(inst.getTask_code()); + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv允许取货信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + Object ext_system = device.getExtraValue().get("ext_system"); + //检测站点,安全交互类型为中鼎的 + if (!StringUtil.isEmpty(ext_system)) { + if (ext_system.equals("1")) { + JSONObject jo = new JSONObject(); + jo.put("taskCode", task.getTask_code()); + jo.put("carId", carno); + jo.put("taskType ", task.getTask_type()); + jo.put("feedbackStatus", "applyPut"); + log.info("请求wms取货完成参数:{}", jo); + HttpResponse result = acsToWmsZDService.taskFeedback(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int responseCode = response.getInteger("responseCode"); + if (responseCode == 0) { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.error("请求wms取货失败参数:{}", response); + } + //焊接线 + } else if (ext_system.equals("3")) { + JSONObject jo1 = new JSONObject(); + jo1.put("point", device_code); + jo1.put("type", "2"); + jo1.put("containerCode", task.getVehicle_code()); + Object url = device.getExtraValue().get("address"); + if (StringUtil.isEmpty(ext_system)) { + log.error("请求安全交互失败,未配置焊接线IP" + device_code); + } + jo1.put("url", url); + HttpResponse result = acsToMesService.actionRequest(jo1); + JSONObject response = JSONObject.parseObject(result.body()); + int code = response.getInteger("code"); + if (code == 200) { + log.info("请求Mes成功,申请取货 请求结果{}", code); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.error("请求Mes失败,申请区货 错误信息{}", response); + } + } else if (ext_system.equals("2")) { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + } else { + log.error("检测站点未配置检测系统"); + return; + } + } + } + + //校验agv上报站点编号与指令起始点相同 + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到关联编号{}对应的指令", ikey); + return; + } + + if (flag) { + log.info("==================允许AGV放货=================="); + log.info("{},{}", device_code, "允许AGV放货。"); + } + + + //放货完毕 + //(Itype=1/2/3,需要WCS反馈Phase) + } else if (phase == 0x09) { + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); + return; + } + device_code = deviceService.queryDeviceCodeByAddress(agvaddr); + + device = deviceAppService.findDeviceByCode(device_code); + if (ObjectUtil.isEmpty(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + return; + } + //校验agv上报站点编号与指令起始点相同 + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到编号{}对应的指令", ikey); + return; + } + TaskService taskService = SpringContextHolder.getBean("taskServiceImpl"); + TaskDto task = taskService.findByCode(inst.getTask_code()); + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv允许取货信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + Object ext_system = device.getExtraValue().get("ext_system"); + //检测站点,安全交互类型为中鼎的 + if (!StringUtil.isEmpty(ext_system)) { + if (ext_system.equals("1")) { + JSONObject jo = new JSONObject(); + jo.put("taskCode", task.getTask_code()); + jo.put("carId", carno); + jo.put("taskType ", task.getTask_type()); + jo.put("feedbackStatus", "putFinish"); + log.info("请求wms取货完成参数:{}", jo); + HttpResponse result = acsToWmsZDService.taskFeedback(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int responseCode = response.getInteger("responseCode"); + if (responseCode == 0) { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.error("请求wms取货失败参数:{}", response); + } + //焊接线 + } else if (ext_system.equals("3")) { + JSONObject jo = new JSONObject(); + jo.put("taskCode", task.getTask_code()); + jo.put("carId", carno); + jo.put("taskType ", task.getTask_type()); + jo.put("feedbackStatus", "putFinish"); + log.info("请求wms取货完成参数:{}", jo); + HttpResponse result = acsToWmsZDService.taskFeedback(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int responseCode = response.getInteger("responseCode"); + if (responseCode == 0) { + JSONObject jo1 = new JSONObject(); + jo1.put("point", device_code); + jo1.put("type", "4"); + jo1.put("containerCode", task.getVehicle_code()); + Object url = device.getExtraValue().get("address"); + if (StringUtil.isEmpty(ext_system)) { + log.error("请求安全交互失败,未配置焊接线IP" + device_code); + } + jo1.put("url", url); + HttpResponse result2 = acsToMesService.actionFinish(jo1); + JSONObject response2 = JSONObject.parseObject(result2.body()); + int code = response2.getInteger("code"); + if (code == 200) { + log.info("请求Mes成功,申请取货完成 请求结果{}", code); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.info("请求Mes失败,申请取货完成 错误信息{}", response2); + } + } else { + log.info("请求ZDwcs失败,取货完成 错误码{}", responseCode); + } + //只跟MES交互的点 + } else if (ext_system.equals("2")) { + JSONObject jo = new JSONObject(); + jo.put("taskCode", task.getTask_code()); + jo.put("carId", carno); + jo.put("taskType ", task.getTask_type()); + jo.put("feedbackStatus", "putFinish"); + log.info("请求wms取货完成参数:{}", jo); + HttpResponse result = acsToWmsZDService.taskFeedback(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int responseCode = response.getInteger("responseCode"); + if (responseCode == 0) { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + } + } + } else { + log.error("检测站点未配置检测系统"); + return; + } + } + + } + //到达取货点 + //(Itype=2/3,需要WCS反馈Phase) + else if (phase == 0x0B) { log.info("==================AGV请求取货=================="); if (ObjectUtil.isEmpty(inst)) { log.info("未找到指令:" + ikey); @@ -203,30 +564,57 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic } TaskService taskService = SpringContextHolder.getBean("taskServiceImpl"); TaskDto task = taskService.findByCode(inst.getTask_code()); + + //mes的站点用检测站点 wms的站点用普通站点驱动 if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - if((StrUtil.startWith(task.getTask_code(), "-"))){ + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv允许取货信号"); data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); } - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { JSONObject jo = new JSONObject(); jo.put("taskCode", task.getTask_code()); jo.put("carId", carno); jo.put("taskType ", task.getTask_type()); - jo.put("feedbackStatus","applyTake"); - log.info("请求参数:{}", jo); + jo.put("feedbackStatus", "applyTake"); + log.info("请求wms申请取货参数:{}", jo); HttpResponse result = acsToWmsZDService.taskFeedback(jo); JSONObject response = JSONObject.parseObject(result.body()); int responseCode = response.getInteger("responseCode"); if (responseCode == 0) { - is_feedback = true; log.info("请求ZDwcs成功,申请取货 请求结果{}", responseCode); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.info("请求ZDwcs失败,申请取货 错误码{}", responseCode); } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv允许取货信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasMes, "1")) { + JSONObject jo = new JSONObject(); + jo.put("point", device_code); + jo.put("type", "1"); + log.info("请求mes申请取货参数:{}", jo); + HttpResponse result = acsToMesService.actionRequest(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int code = response.getInteger("code"); + if (code == 200) { + log.info("请求Mes成功,申请取货 请求结果{}", code); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.info("请求Mes失败,申请取货 错误信息{}", response); + } + } else { data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); } } + // // if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { // siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver(); @@ -250,8 +638,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic // } //取货完毕 - //(需要WCS反馈) - } else if (phase == 0x05) { + //(Itype=2/3,需要WCS反馈Phase) + } else if (phase == 0x0D) { if (agvaddr == 0) { agvaddr = agvaddr_copy; } @@ -288,30 +676,55 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic } TaskService taskService = SpringContextHolder.getBean("taskServiceImpl"); TaskDto task = taskService.findByCode(inst.getTask_code()); + + //mes的站点用检测站点 wms的站点用普通站点驱动 if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - if((StrUtil.startWith(task.getTask_code(), "-"))){ - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv取货完成信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); } - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { JSONObject jo = new JSONObject(); jo.put("taskCode", task.getTask_code()); jo.put("carId", carno); jo.put("taskType ", task.getTask_type()); jo.put("feedbackStatus", "takeFinish"); - log.info("请求参数:{}", jo); + log.info("请求wms取货完成参数:{}", jo); HttpResponse result = acsToWmsZDService.taskFeedback(jo); JSONObject response = JSONObject.parseObject(result.body()); int responseCode = response.getInteger("responseCode"); if (responseCode == 0) { - is_feedback = true; log.info("请求ZDwcs成功,取货完成 请求结果{}", responseCode); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } else { + log.info("请求ZDwcs失败,取货完成 错误码{}", responseCode); } - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv取货完成信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } + if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasMes, "1")) { + JSONObject jo = new JSONObject(); + jo.put("point", device_code); + jo.put("type", "3"); + log.info("请求mes取货完成参数:{}", jo); + HttpResponse result = acsToMesService.actionRequest(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int code = response.getInteger("code"); + if (code == 200) { + log.info("请求Mes成功,申请取货完成 请求结果{}", code); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } else { + log.info("请求Mes失败,申请取货完成 错误信息{}", response); + } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); } } -// // if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { // siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver(); // if (siemensConveyorDeviceDriver.getTo_command() == 2) { @@ -333,8 +746,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + Bytes2HexString(data)); } //到达放货点 - //(需要WCS反馈) - } else if (phase == 0x07) { + //(Itype=2/3,需要WCS反馈Phase) + } else if (phase == 0x0F) { if (agvaddr == 0) { agvaddr = agvaddr_copy; } @@ -363,45 +776,71 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic } TaskService taskService = SpringContextHolder.getBean("taskServiceImpl"); TaskDto task = taskService.findByCode(inst.getTask_code()); + + //mes的站点用检测站点 wms的站点用普通站点驱动 if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - if((StrUtil.startWith(task.getTask_code(), "-"))){ + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv允许放货信号"); data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); } - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { JSONObject jo = new JSONObject(); jo.put("taskCode", task.getTask_code()); jo.put("carId", carno); jo.put("taskType ", task.getTask_type()); jo.put("feedbackStatus", "applyPut"); - log.info("请求参数:{}", jo); + log.info("请求wms申请放货参数:{}", jo); HttpResponse result = acsToWmsZDService.taskFeedback(jo); JSONObject response = JSONObject.parseObject(result.body()); int responseCode = response.getInteger("responseCode"); if (responseCode == 0) { - is_feedback = true; log.info("请求ZDwcs成功,申请放货 请求结果{}", responseCode); data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.info("请求ZDwcs失败,申请放货 错误码{}", responseCode); } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv允许放货信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasMes, "1")) { + JSONObject jo = new JSONObject(); + jo.put("point", device_code); + jo.put("type", "2"); + log.info("请求mes申请放货参数:{}", jo); + HttpResponse result = acsToMesService.actionRequest(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int code = response.getInteger("code"); + if (code == 200) { + log.info("请求Mes成功,申请放货 请求结果{}", code); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.info("请求Mes失败,申请放货 错误信息{}", response); + } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); } } + //校验agv上报站点编号与指令起始点相同 if (ObjectUtil.isEmpty(inst)) { log.info("未找到关联编号{}对应的指令", ikey); return; } - if (flag) { - log.info("==================允许AGV放货=================="); - log.info("{},{}", device_code,"允许AGV放货。"); - } - + if (flag) { + log.info("==================允许AGV放货=================="); + log.info("{},{}", device_code, "允许AGV放货。"); + } //放货完毕 - //(需要WCS反馈) - } else if (phase == 0x09) { + //(Itype=2/3,需要WCS反馈Phase) + } else if (phase == 0x11) { if (agvaddr == 0) { agvaddr = agvaddr_copy; } @@ -436,30 +875,867 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic } TaskService taskService = SpringContextHolder.getBean("taskServiceImpl"); TaskDto task = taskService.findByCode(inst.getTask_code()); + + //mes的站点用检测站点 wms的站点用普通站点驱动 if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { - if((StrUtil.startWith(task.getTask_code(), "-"))){ - data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv放货完成信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); } - } - if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { JSONObject jo = new JSONObject(); jo.put("taskCode", task.getTask_code()); jo.put("carId", carno); jo.put("taskType ", task.getTask_type()); jo.put("feedbackStatus", "putFinish"); - log.info("请求参数:{}", jo); + log.info("请求wms放货完成参数:{}", jo); HttpResponse result = acsToWmsZDService.taskFeedback(jo); JSONObject response = JSONObject.parseObject(result.body()); int responseCode = response.getInteger("responseCode"); if (responseCode == 0) { - is_feedback = true; log.info("请求ZDwcs成功,放货完成 请求结果{}", responseCode); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } else { + log.info("请求ZDwcs失败,放货完成 错误码{}", responseCode); } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv放货完成信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } + if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasMes, "1")) { + JSONObject jo = new JSONObject(); + jo.put("point", device_code); + jo.put("type", "4"); + log.info("请求mes放货完成参数:{}", jo); + HttpResponse result = acsToMesService.actionFinish(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int code = response.getInteger("code"); + if (code == 200) { + log.info("请求Mes成功,放货完成 请求结果{}", code); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } else { + log.info("请求Mes失败,放货完成 错误信息{}", response); + } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } + } + } + + //到达取货点 + //(Itype=2/3,需要WCS反馈Phase) + else if (phase == 0x13) { + log.info("==================AGV请求取货=================="); + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到指令:" + ikey); + log.info("{},{}", device_code, "未找到指令 [" + ikey + "]"); + return; + } + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + log.info("{},{}", device_code, "agv地址参数有误,phase:" + phase); + return; + } + device_code = deviceService.queryDeviceCodeByAddress(agvaddr); +// 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(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + return; + } + //校验agv上报站点编号与指令起始点相同 + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到编号{}对应的指令", ikey); + log.info("{},{}", device_code, "未找到关联编号对应的指令" + ikey); + return; + } + TaskService taskService = SpringContextHolder.getBean("taskServiceImpl"); + TaskDto task = taskService.findByCode(inst.getTask_code()); + + //mes的站点用检测站点 wms的站点用普通站点驱动 + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv允许取货信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { + JSONObject jo = new JSONObject(); + jo.put("taskCode", task.getTask_code()); + jo.put("carId", carno); + jo.put("taskType ", task.getTask_type()); + jo.put("feedbackStatus", "applyTake"); + log.info("请求wms申请取货参数:{}", jo); + HttpResponse result = acsToWmsZDService.taskFeedback(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int responseCode = response.getInteger("responseCode"); + if (responseCode == 0) { + log.info("请求ZDwcs成功,申请取货 请求结果{}", responseCode); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.info("请求ZDwcs失败,申请取货 错误码{}", responseCode); + } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv允许取货信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasMes, "1")) { + JSONObject jo = new JSONObject(); + jo.put("point", device_code); + jo.put("type", "1"); + log.info("请求mes申请取货参数:{}", jo); + HttpResponse result = acsToMesService.actionRequest(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int code = response.getInteger("code"); + if (code == 200) { + log.info("请求Mes成功,申请取货 请求结果{}", code); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.info("请求Mes失败,申请取货 错误信息{}", response); + } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + } + +// +// if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { +// siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver(); +// if (siemensConveyorDeviceDriver.getMove() == 1) { +// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); +// } else { +// log.info("请求取货条件不满足待机有货"); +// } +// } +// +// if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { +// siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver(); +// if (siemensConveyorDeviceDriver.getMove() == 1) { +// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); +// } else { +// log.info("请求取货条件不满足待机有货"); +// } +// } +// if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { +// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); +// } + + //取货完毕 + //(Itype=2/3,需要WCS反馈Phase) + } else if (phase == 0x15) { + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); + return; + } + device_code = deviceService.queryDeviceCodeByAddress(agvaddr); +// 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(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + logServer.deviceExecuteLog(this.device_code, "", "", "对应设备号为空" + device_code); + return; + } + //校验agv上报站点编号与指令起始点相同 + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到关联编号{}对应的指令", ikey); + logServer.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey); + return; + } + TaskService taskService = SpringContextHolder.getBean("taskServiceImpl"); + TaskDto task = taskService.findByCode(inst.getTask_code()); + + //mes的站点用检测站点 wms的站点用普通站点驱动 + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv取货完成信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } + if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { + JSONObject jo = new JSONObject(); + jo.put("taskCode", task.getTask_code()); + jo.put("carId", carno); + jo.put("taskType ", task.getTask_type()); + jo.put("feedbackStatus", "takeFinish"); + log.info("请求wms取货完成参数:{}", jo); + HttpResponse result = acsToWmsZDService.taskFeedback(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int responseCode = response.getInteger("responseCode"); + if (responseCode == 0) { + log.info("请求ZDwcs成功,取货完成 请求结果{}", responseCode); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } else { + log.info("请求ZDwcs失败,取货完成 错误码{}", responseCode); + } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv取货完成信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } + if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasMes, "1")) { + JSONObject jo = new JSONObject(); + jo.put("point", device_code); + jo.put("type", "3"); + log.info("请求mes取货完成参数:{}", jo); + HttpResponse result = acsToMesService.actionRequest(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int code = response.getInteger("code"); + if (code == 200) { + log.info("请求Mes成功,申请取货完成 请求结果{}", code); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } else { + log.info("请求Mes失败,申请取货完成 错误信息{}", response); + } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } + } +// +// if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { +// siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver(); +// if (siemensConveyorDeviceDriver.getTo_command() == 2) { +// log.info("取货完成请求离开,当前输送to_command:" + siemensConveyorDeviceDriver.getTo_command()); +// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); +// } else { +// log.info("取货完成请求离开下发输送信号,当前输送to_command:" + siemensConveyorDeviceDriver.getTo_command()); +// List list = new ArrayList(); +// Map map = new HashMap(); +// map.put("code", "to_command"); +// map.put("value", "2"); +// list.add(map); +// siemensConveyorDeviceDriver.writing(list); +// siemensConveyorDeviceDriver.writing(list); +// } +// } + + if (ObjectUtil.isNotEmpty(data)) { + logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + Bytes2HexString(data)); + } + //到达放货点 + //(Itype=2/3,需要WCS反馈Phase) + } else if (phase == 0x17) { + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); + return; + } + device_code = deviceService.queryDeviceCodeByAddress(agvaddr); +// 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(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + return; + } + TaskService taskService = SpringContextHolder.getBean("taskServiceImpl"); + TaskDto task = taskService.findByCode(inst.getTask_code()); + + //mes的站点用检测站点 wms的站点用普通站点驱动 + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv允许放货信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { + JSONObject jo = new JSONObject(); + jo.put("taskCode", task.getTask_code()); + jo.put("carId", carno); + jo.put("taskType ", task.getTask_type()); + jo.put("feedbackStatus", "applyPut"); + log.info("请求wms申请放货参数:{}", jo); + HttpResponse result = acsToWmsZDService.taskFeedback(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int responseCode = response.getInteger("responseCode"); + if (responseCode == 0) { + log.info("请求ZDwcs成功,申请放货 请求结果{}", responseCode); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.info("请求ZDwcs失败,申请放货 错误码{}", responseCode); + } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv允许放货信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasMes, "1")) { + JSONObject jo = new JSONObject(); + jo.put("point", device_code); + jo.put("type", "2"); + log.info("请求mes申请放货参数:{}", jo); + HttpResponse result = acsToMesService.actionRequest(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int code = response.getInteger("code"); + if (code == 200) { + log.info("请求Mes成功,申请放货 请求结果{}", code); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.info("请求Mes失败,申请放货 错误信息{}", response); + } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + } + //校验agv上报站点编号与指令起始点相同 + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到关联编号{}对应的指令", ikey); + return; + } + + if (flag) { + log.info("==================允许AGV放货=================="); + log.info("{},{}", device_code, "允许AGV放货。"); + } + + + //放货完毕 + //(Itype=2/3,需要WCS反馈Phase) + } else if (phase == 0x19) { + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); + return; + } + device_code = deviceService.queryDeviceCodeByAddress(agvaddr); +// 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(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + return; + } + //校验agv上报站点编号与指令起始点相同 + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到编号{}对应的指令", ikey); + return; + } + TaskService taskService = SpringContextHolder.getBean("taskServiceImpl"); + TaskDto task = taskService.findByCode(inst.getTask_code()); + + //mes的站点用检测站点 wms的站点用普通站点驱动 + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv放货完成信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } + if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { + JSONObject jo = new JSONObject(); + jo.put("taskCode", task.getTask_code()); + jo.put("carId", carno); + jo.put("taskType ", task.getTask_type()); + jo.put("feedbackStatus", "putFinish"); + log.info("请求wms放货完成参数:{}", jo); + HttpResponse result = acsToWmsZDService.taskFeedback(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int responseCode = response.getInteger("responseCode"); + if (responseCode == 0) { + log.info("请求ZDwcs成功,放货完成 请求结果{}", responseCode); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } else { + log.info("请求ZDwcs失败,放货完成 错误码{}", responseCode); + } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv放货完成信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } + if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasMes, "1")) { + JSONObject jo = new JSONObject(); + jo.put("point", device_code); + jo.put("type", "4"); + log.info("请求mes放货完成参数:{}", jo); + HttpResponse result = acsToMesService.actionFinish(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int code = response.getInteger("code"); + if (code == 200) { + log.info("请求Mes成功,放货完成 请求结果{}", code); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } else { + log.info("请求Mes失败,放货完成 错误信息{}", response); + } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } + } + } + + //到达取货点 + //(Itype=2/3,需要WCS反馈Phase) + else if (phase == 0x1B) { + log.info("==================AGV请求取货=================="); + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到指令:" + ikey); + log.info("{},{}", device_code, "未找到指令 [" + ikey + "]"); + return; + } + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + log.info("{},{}", device_code, "agv地址参数有误,phase:" + phase); + return; + } + device_code = deviceService.queryDeviceCodeByAddress(agvaddr); +// 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(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + return; + } + //校验agv上报站点编号与指令起始点相同 + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到编号{}对应的指令", ikey); + log.info("{},{}", device_code, "未找到关联编号对应的指令" + ikey); + return; + } + TaskService taskService = SpringContextHolder.getBean("taskServiceImpl"); + TaskDto task = taskService.findByCode(inst.getTask_code()); + + //mes的站点用检测站点 wms的站点用普通站点驱动 + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv允许取货信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { + JSONObject jo = new JSONObject(); + jo.put("taskCode", task.getTask_code()); + jo.put("carId", carno); + jo.put("taskType ", task.getTask_type()); + jo.put("feedbackStatus", "applyTake"); + log.info("请求wms申请取货参数:{}", jo); + HttpResponse result = acsToWmsZDService.taskFeedback(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int responseCode = response.getInteger("responseCode"); + if (responseCode == 0) { + log.info("请求ZDwcs成功,申请取货 请求结果{}", responseCode); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.info("请求ZDwcs失败,申请取货 错误码{}", responseCode); + } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv允许取货信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasMes, "1")) { + JSONObject jo = new JSONObject(); + jo.put("point", device_code); + jo.put("type", "1"); + log.info("请求mes申请取货参数:{}", jo); + HttpResponse result = acsToMesService.actionRequest(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int code = response.getInteger("code"); + if (code == 200) { + log.info("请求Mes成功,申请取货 请求结果{}", code); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.info("请求Mes失败,申请取货 错误信息{}", response); + } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + } + +// +// if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { +// siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver(); +// if (siemensConveyorDeviceDriver.getMove() == 1) { +// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); +// } else { +// log.info("请求取货条件不满足待机有货"); +// } +// } +// +// if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { +// siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver(); +// if (siemensConveyorDeviceDriver.getMove() == 1) { +// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); +// } else { +// log.info("请求取货条件不满足待机有货"); +// } +// } +// if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) { +// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); +// } + + //取货完毕 + //(Itype=2/3,需要WCS反馈Phase) + } else if (phase == 0x1D) { + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); + return; + } + device_code = deviceService.queryDeviceCodeByAddress(agvaddr); +// 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(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + logServer.deviceExecuteLog(this.device_code, "", "", "对应设备号为空" + device_code); + return; + } + //校验agv上报站点编号与指令起始点相同 + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到关联编号{}对应的指令", ikey); + logServer.deviceExecuteLog(this.device_code, "", "", "未找到关联编号对应的指令" + ikey); + return; + } + TaskService taskService = SpringContextHolder.getBean("taskServiceImpl"); + TaskDto task = taskService.findByCode(inst.getTask_code()); + + //mes的站点用检测站点 wms的站点用普通站点驱动 + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv取货完成信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } + if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { + JSONObject jo = new JSONObject(); + jo.put("taskCode", task.getTask_code()); + jo.put("carId", carno); + jo.put("taskType ", task.getTask_type()); + jo.put("feedbackStatus", "takeFinish"); + log.info("请求wms取货完成参数:{}", jo); + HttpResponse result = acsToWmsZDService.taskFeedback(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int responseCode = response.getInteger("responseCode"); + if (responseCode == 0) { + log.info("请求ZDwcs成功,取货完成 请求结果{}", responseCode); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } else { + log.info("请求ZDwcs失败,取货完成 错误码{}", responseCode); + } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv取货完成信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } + if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasMes, "1")) { + JSONObject jo = new JSONObject(); + jo.put("point", device_code); + jo.put("type", "3"); + log.info("请求mes取货完成参数:{}", jo); + HttpResponse result = acsToMesService.actionRequest(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int code = response.getInteger("code"); + if (code == 200) { + log.info("请求Mes成功,申请取货完成 请求结果{}", code); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } else { + log.info("请求Mes失败,申请取货完成 错误信息{}", response); + } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, inst); + } + } +// +// if (device.getDeviceDriver() instanceof SiemensConveyorDeviceDriver) { +// siemensConveyorDeviceDriver = (SiemensConveyorDeviceDriver) device.getDeviceDriver(); +// if (siemensConveyorDeviceDriver.getTo_command() == 2) { +// log.info("取货完成请求离开,当前输送to_command:" + siemensConveyorDeviceDriver.getTo_command()); +// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); +// } else { +// log.info("取货完成请求离开下发输送信号,当前输送to_command:" + siemensConveyorDeviceDriver.getTo_command()); +// List list = new ArrayList(); +// Map map = new HashMap(); +// map.put("code", "to_command"); +// map.put("value", "2"); +// list.add(map); +// siemensConveyorDeviceDriver.writing(list); +// siemensConveyorDeviceDriver.writing(list); +// } +// } + + if (ObjectUtil.isNotEmpty(data)) { + logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + Bytes2HexString(data)); + } + //到达放货点 + //(Itype=2/3,需要WCS反馈Phase) + } else if (phase == 0x1F) { + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); + return; + } + device_code = deviceService.queryDeviceCodeByAddress(agvaddr); +// 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(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + return; + } + TaskService taskService = SpringContextHolder.getBean("taskServiceImpl"); + TaskDto task = taskService.findByCode(inst.getTask_code()); + + //mes的站点用检测站点 wms的站点用普通站点驱动 + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv允许放货信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { + JSONObject jo = new JSONObject(); + jo.put("taskCode", task.getTask_code()); + jo.put("carId", carno); + jo.put("taskType ", task.getTask_type()); + jo.put("feedbackStatus", "applyPut"); + log.info("请求wms申请放货参数:{}", jo); + HttpResponse result = acsToWmsZDService.taskFeedback(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int responseCode = response.getInteger("responseCode"); + if (responseCode == 0) { + log.info("请求ZDwcs成功,申请放货 请求结果{}", responseCode); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.info("请求ZDwcs失败,申请放货 错误码{}", responseCode); + } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv允许放货信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasMes, "1")) { + JSONObject jo = new JSONObject(); + jo.put("point", device_code); + jo.put("type", "2"); + log.info("请求mes申请放货参数:{}", jo); + HttpResponse result = acsToMesService.actionRequest(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int code = response.getInteger("code"); + if (code == 200) { + log.info("请求Mes成功,申请放货 请求结果{}", code); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.info("请求Mes失败,申请放货 错误信息{}", response); + } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + } + //校验agv上报站点编号与指令起始点相同 + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到关联编号{}对应的指令", ikey); + return; + } + + if (flag) { + log.info("==================允许AGV放货=================="); + log.info("{},{}", device_code, "允许AGV放货。"); + } + + + //放货完毕 + //(Itype=2/3,需要WCS反馈Phase) + } else if (phase == 0x21) { + if (agvaddr == 0) { + agvaddr = agvaddr_copy; + } + if (agvaddr < 1) { + logServer.deviceExecuteLog(this.device_code, "", "", "agv地址参数有误,phase:" + phase); + return; + } + device_code = deviceService.queryDeviceCodeByAddress(agvaddr); +// 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(device_code)) { + log.info(agvaddr + "对应设备号为空!"); + return; + } + //校验agv上报站点编号与指令起始点相同 + if (ObjectUtil.isEmpty(inst)) { + log.info("未找到编号{}对应的指令", ikey); + return; + } + TaskService taskService = SpringContextHolder.getBean("taskServiceImpl"); + TaskDto task = taskService.findByCode(inst.getTask_code()); + + //mes的站点用检测站点 wms的站点用普通站点驱动 + if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv放货完成信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { + JSONObject jo = new JSONObject(); + jo.put("taskCode", task.getTask_code()); + jo.put("carId", carno); + jo.put("taskType ", task.getTask_type()); + jo.put("feedbackStatus", "putFinish"); + log.info("请求wms放货完成参数:{}", jo); + HttpResponse result = acsToWmsZDService.taskFeedback(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int responseCode = response.getInteger("responseCode"); + if (responseCode == 0) { + log.info("请求ZDwcs成功,放货完成 请求结果{}", responseCode); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.info("请求ZDwcs失败,放货完成 错误码{}", responseCode); + } + } else { + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + if ((StrUtil.startWith(task.getTask_code(), "-"))) { + log.info("定点任务下发agv放货完成信号"); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } + if (!StrUtil.startWith(task.getTask_code(), "-") && StrUtil.equals(hasMes, "1")) { + JSONObject jo = new JSONObject(); + jo.put("point", device_code); + jo.put("type", "4"); + log.info("请求mes放货完成参数:{}", jo); + HttpResponse result = acsToMesService.actionFinish(jo); + JSONObject response = JSONObject.parseObject(result.body()); + int code = response.getInteger("code"); + if (code == 200) { + log.info("请求Mes成功,放货完成 请求结果{}", code); + data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); + } else { + log.info("请求Mes失败,放货完成 错误信息{}", response); + } + } else { data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); } } } + //到达位置点 //(需要WCS反馈) else if (phase == 0x64) {//param,agv货位id待定 diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/StandardInspectSiteDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/StandardInspectSiteDeviceDriver.java index fcdd34c..8cc151b 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/StandardInspectSiteDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/standard_inspect_site/StandardInspectSiteDeviceDriver.java @@ -30,10 +30,7 @@ import org.nl.modules.wql.util.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; +import java.util.*; /** * 检测站点驱动 @@ -128,100 +125,100 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp @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(); +// 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 (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); +// } - 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: +// } 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(); @@ -271,28 +268,28 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp // 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; +// 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; } @@ -475,6 +472,21 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp return jo; } + public List getExtraDeviceCodes(String extraName) { + String extraValue = (String) this.getDevice().getExtraValue().get(extraName); + if (StrUtil.isEmpty(extraValue)) { + return new ArrayList<>(); + } + String devicesString = extraValue.substring(1, extraValue.length() - 1); + List devicesList = new ArrayList<>(); + String[] devices = devicesString.split(","); + for (int i = 0; i < devices.length; i++) { + String s = devices[i].replace("\"", "").replace("\"", ""); + devicesList.add(s); + } + return devicesList; + } + @Override public void setDeviceStatus(JSONObject data) { diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToMesController.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToMesController.java new file mode 100644 index 0000000..f49bd05 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/AcsToMesController.java @@ -0,0 +1,19 @@ +package org.nl.acs.ext.wms.rest; + +import cn.dev33.satoken.annotation.SaIgnore; +import io.swagger.annotations.Api; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Lazy; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequiredArgsConstructor +@Api(tags = "mes接口") +@RequestMapping("/mes") +@Slf4j +@Lazy +@SaIgnore +public class AcsToMesController { +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/MesToAcsController.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/MesToAcsController.java new file mode 100644 index 0000000..8bd98c7 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/MesToAcsController.java @@ -0,0 +1,53 @@ +package org.nl.acs.ext.wms.rest; + +import cn.dev33.satoken.annotation.SaIgnore; +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.MesToAcsService; +import org.nl.modules.logging.annotation.Log; +import org.springframework.context.annotation.Lazy; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +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; + +@RestController +@RequiredArgsConstructor +@Api(tags = "mes接口") +@RequestMapping("/api/acs") +@Slf4j +@Service +@Lazy +@SaIgnore +public class MesToAcsController { + private final MesToAcsService mesToAcsService; + @PostMapping("/task") + @Log("任务接收") + @ApiOperation("任务接收") + @SaIgnore + public ResponseEntity taskCreate(@RequestBody JSONObject whereJson) { + return new ResponseEntity<>(mesToAcsService.taskCreate(whereJson), HttpStatus.OK); + } + + @PostMapping("/taskOperation") + @Log("任务操作") + @ApiOperation("任务操作") + @SaIgnore + public ResponseEntity taskOperation(@RequestBody JSONObject whereJson) { + return new ResponseEntity<>(mesToAcsService.taskOperation(whereJson), HttpStatus.OK); + } + + @PostMapping("/taskStatus") + @Log("任务状态查询") + @ApiOperation("任务状态查询") + @SaIgnore + public ResponseEntity taskStatus(@RequestBody JSONObject whereJson) { + return new ResponseEntity<>(mesToAcsService.taskStatus(whereJson), HttpStatus.OK); + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsZDToAcsController.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsZDToAcsController.java index 69d339a..6791c5d 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsZDToAcsController.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/rest/WmsZDToAcsController.java @@ -20,18 +20,34 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequiredArgsConstructor @Api(tags = "wms接口") -@RequestMapping("/restful/API/V3") +@RequestMapping("/api/wms/acs") @Slf4j @Service @Lazy @SaIgnore public class WmsZDToAcsController { private final WmsZDToAcsService wmsZDToAcsService; - @PostMapping("/createTask") + @PostMapping("/task") @Log("任务接收") @ApiOperation("任务接收") @SaIgnore public ResponseEntity taskCreate(@RequestBody JSONObject whereJson) { return new ResponseEntity<>(wmsZDToAcsService.taskCreate(whereJson), HttpStatus.OK); } + + @PostMapping("/taskOperation") + @Log("任务操作") + @ApiOperation("任务操作") + @SaIgnore + public ResponseEntity taskOperation(@RequestBody JSONObject whereJson) { + return new ResponseEntity<>(wmsZDToAcsService.taskOperation(whereJson), HttpStatus.OK); + } + + @PostMapping("/taskStatus") + @Log("任务状态查询") + @ApiOperation("任务状态查询") + @SaIgnore + public ResponseEntity taskStatus(@RequestBody JSONObject whereJson) { + return new ResponseEntity<>(wmsZDToAcsService.taskStatus(whereJson), HttpStatus.OK); + } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToMesService.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToMesService.java new file mode 100644 index 0000000..9852f9b --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToMesService.java @@ -0,0 +1,36 @@ +package org.nl.acs.ext.wms.service; + +import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSONObject; + +import java.io.IOException; + +public interface AcsToMesService { + + /** + * 动作请求反馈 + * @param jsonObject + */ + HttpResponse actionRequest(JSONObject jsonObject) throws IOException; + /** + * 动作完成反馈 + * @param jsonObject + */ + HttpResponse actionFinish(JSONObject jsonObject) throws IOException; + + /** + * 任务反馈 + * + * + * + */ + HttpResponse taskFeedback(JSONObject whereJson); + + /** + * 任务取消 + * + * + * + */ + HttpResponse taskDeprecate(JSONObject whereJson); +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/MesToAcsService.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/MesToAcsService.java new file mode 100644 index 0000000..e17e82d --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/MesToAcsService.java @@ -0,0 +1,28 @@ +package org.nl.acs.ext.wms.service; + +import com.alibaba.fastjson.JSONObject; + +import java.util.Map; + +public interface MesToAcsService { + /** + * 任务接收 + * + * @return Map + */ + Map taskCreate(JSONObject whereJson); + + /** + * 任务处理 + * + * @return Map + */ + Map taskOperation(JSONObject whereJson); + + /** + * 任务状态 + * + * @return Map + */ + Map taskStatus(JSONObject whereJson); +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsZDToAcsService.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsZDToAcsService.java index 23f13ad..165f6a6 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsZDToAcsService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/WmsZDToAcsService.java @@ -15,4 +15,18 @@ public interface WmsZDToAcsService { * @return Map */ Map taskCreate(JSONObject whereJson); + + /** + * 任务处理 + * + * @return Map + */ + Map taskOperation(JSONObject whereJson); + + /** + * 任务状态 + * + * @return Map + */ + Map taskStatus(JSONObject whereJson); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToMesServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToMesServiceImpl.java new file mode 100644 index 0000000..5b2952e --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToMesServiceImpl.java @@ -0,0 +1,138 @@ +package org.nl.acs.ext.wms.service.impl; + +import cn.hutool.http.Header; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.AcsConfig; +import org.nl.acs.device.address.service.AddressService; +import org.nl.acs.device.address.service.dto.AddressDto; +import org.nl.acs.ext.wms.service.AcsToMesService; +import org.nl.modules.lucene.service.LuceneExecuteLogService; +import org.nl.modules.lucene.service.dto.LuceneLogDto; +import org.nl.modules.system.service.ParamService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.io.IOException; + +@Service +@RequiredArgsConstructor +@Slf4j +public class AcsToMesServiceImpl implements AcsToMesService { + + @Autowired + ParamService paramService; + + @Autowired + AddressService addressService; + + @Autowired + private LuceneExecuteLogService luceneLogService; + + public String token; + @Override + public HttpResponse actionRequest(JSONObject jsonObject) throws IOException { + HttpResponse execute = null; + try { + String wmsurl = jsonObject.getString("url"); + AddressDto addressDto = addressService.findByCode("actionRequest"); + String url = wmsurl + addressDto.getMethods_url(); + try { + execute = HttpRequest.post(url) + .header(Header.USER_AGENT, "Hutool http") + .header("Authorization", token) + .body(String.valueOf(jsonObject)) + .execute(); + } catch (Exception e) { + String msg = e.getMessage(); + log.info("actionRequest-----输出参数{}", msg); + //网络不通 + LuceneLogDto luceneLogDto1 = new LuceneLogDto(4, "actionRequest", String.valueOf(execute.getStatus()), + String.valueOf(jsonObject), + String.valueOf(execute.body()), jsonObject.getString("task_code") + "设备工位取货完成反馈失败"); + luceneLogService.interfaceExecuteLog(luceneLogDto1); + } + log.info("actionRequest - 动作请求反馈{}", jsonObject); + LuceneLogDto luceneLogDto = new LuceneLogDto(4, "actionRequest", "", + String.valueOf(jsonObject), + "", jsonObject.getString("task_code") + "动作请求反馈"); + luceneLogService.interfaceExecuteLog(luceneLogDto); + } catch (Exception e) { + LuceneLogDto luceneLogDto = new LuceneLogDto(4, "actionRequest", String.valueOf(execute.getStatus()), + JSON.toJSONString(execute.body()), + String.valueOf(execute.body()), jsonObject.getString("task_code") + "设备工位动作请求反馈失败"); + luceneLogService.interfaceExecuteLog(luceneLogDto); + } + return execute; + } + + @Override + public HttpResponse taskFeedback(JSONObject whereJson) { + String mesUrl = paramService.findByCode(AcsConfig.MESURL).getValue(); + AddressDto addressDto = addressService.findByCode("feedAgvTaskStatus"); + String methods_url = addressDto.getMethods_url(); + String url = mesUrl + methods_url; + HttpResponse result = null; + log.info("feedAgvTaskStatus----请求参数{}", whereJson); + try { + result = HttpRequest.post(url) + .body(String.valueOf(whereJson)) + .execute(); + System.out.println(result); + log.info("feedAgvTaskStatus----返回参数{}", result); + } catch (Exception e) { + String msg = e.getMessage(); + //网络不通 + log.info("错误原因{}",msg); + } + return result; + } + + @Override + public HttpResponse taskDeprecate(JSONObject whereJson) { + String mesUrl = paramService.findByCode(AcsConfig.MESURL).getValue(); + AddressDto addressDto = addressService.findByCode("acsCancelBack"); + String methods_url = addressDto.getMethods_url(); + String url = mesUrl + methods_url; + HttpResponse result = null; + log.info("deprecateMesTask----请求参数{}", whereJson); + try { + result = HttpRequest.post(url) + .body(String.valueOf(whereJson)) + .execute(); + System.out.println(result); + log.info("deprecateMesTask----返回参数{}", result); + } catch (Exception e) { + String msg = e.getMessage(); + //网络不通 + //System.out.println(msg); + } + return result; + } + + @Override + public HttpResponse actionFinish(JSONObject whereJson) throws IOException { + String wmsUrl = whereJson.getString("url"); + AddressDto addressDto = addressService.findByCode("actionFinish"); + String methods_url = addressDto.getMethods_url(); + String url = wmsUrl + methods_url; + HttpResponse result = null; + log.info("actionFinish----请求参数{}", whereJson); + try { + result = HttpRequest.post(url) + .body(String.valueOf(whereJson)) + .execute(); + System.out.println(result); + log.info("actionFinish----返回参数{}", result); + } catch (Exception e) { + String msg = e.getMessage(); + //网络不通 + log.info("错误原因{}",msg); + } + return result; + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsZDServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsZDServiceImpl.java index c798875..5d4eb5a 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsZDServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsZDServiceImpl.java @@ -57,7 +57,8 @@ public class AcsToWmsZDServiceImpl implements AcsToWmsZDService { @Override public HttpResponse taskFeedback(JSONObject whereJson) { - String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); + //TODO:改成中鼎 + String wmsUrl = "10.10.188.151:8098"; AddressDto addressDto = addressService.findByCode("feedAgvTaskStatus"); String methods_url = addressDto.getMethods_url(); String url = wmsUrl + methods_url; @@ -79,18 +80,18 @@ public class AcsToWmsZDServiceImpl implements AcsToWmsZDService { @Override public HttpResponse taskDeprecate(JSONObject whereJson) { - String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); - AddressDto addressDto = addressService.findByCode("deprecateTask"); + String wmsUrl = "10.10.188.151:8098"; + AddressDto addressDto = addressService.findByCode("acsCancelBack"); String methods_url = addressDto.getMethods_url(); String url = wmsUrl + methods_url; HttpResponse result = null; - log.info("deprecateTask----请求参数{}", whereJson); + log.info("deprecateWmsTask----请求参数{}", whereJson); try { result = HttpRequest.post(url) .body(String.valueOf(whereJson)) .execute(); System.out.println(result); - log.info("deprecateTask----返回参数{}", result); + log.info("deprecateWmsTask----返回参数{}", result); } catch (Exception e) { String msg = e.getMessage(); //网络不通 @@ -101,7 +102,7 @@ public class AcsToWmsZDServiceImpl implements AcsToWmsZDService { @Override public HttpResponse deviceStatusUpdate(JSONObject whereJson) { - String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue(); + String wmsUrl = "10.10.188.151:8098"; AddressDto addressDto = addressService.findByCode("deviceStatusUpdate"); String methods_url = addressDto.getMethods_url(); String url = wmsUrl + methods_url; diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/MesToAcsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/MesToAcsServiceImpl.java new file mode 100644 index 0000000..bf30320 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/MesToAcsServiceImpl.java @@ -0,0 +1,303 @@ +package org.nl.acs.ext.wms.service.impl; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.ext.wms.service.MesToAcsService; +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.logging.service.LogService; +import org.nl.modules.system.util.CodeUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.Map; + +@Service +@RequiredArgsConstructor +@Slf4j +public class MesToAcsServiceImpl implements MesToAcsService { + + @Autowired + RouteLineService routeLineService; + + @Autowired + TaskService taskService; + + + @Autowired + LogService logServer; + + @Override + public Map taskCreate(JSONObject whereJson) { + Map map = new HashMap<>(); + log.info("taskCreate--------------:输入参数:" + whereJson.toString()); + //获取甲方wcs传过来的参数 + JSONObject params = whereJson.getJSONObject("params"); + String locationFrom = whereJson.getString("locationFrom"); + String locationTo = whereJson.getString("locationTo"); + String locationFrom2 = whereJson.getString("locationFrom2"); + String locationTo2 = whereJson.getString("locationTo2"); + String priority = whereJson.getString("priority"); + String actionType = whereJson.getString("actionType"); + String systemType = whereJson.getString("systemType"); + String vehicleCode = whereJson.getString("containerCode"); + String remark = whereJson.getString("remark"); + if (ObjectUtil.isEmpty(params)) { + map.put("status", "400"); + map.put("message", "扩展参数不能为空"); + map.put("data", null); + return map; + } + + if (ObjectUtil.isEmpty(actionType)) { + map.put("status", "400"); + map.put("message", "任务动作类型不能为空"); + map.put("data", null); + return map; + } + + if (ObjectUtil.isEmpty(locationFrom)) { + map.put("status", "400"); + map.put("message", "起点1不能为空"); + map.put("data", null); + return map; + } + + if (ObjectUtil.isEmpty(locationTo)) { + map.put("status", "400"); + map.put("message", "终点1不能为空"); + map.put("data", null); + return map; + } + if (actionType.equals("2")) { + if (ObjectUtil.isEmpty(locationFrom2)) { + map.put("status", "400"); + map.put("message", "起点2不能为空"); + map.put("data", null); + return map; + } + + if (ObjectUtil.isEmpty(locationTo2)) { + map.put("status", "400"); + map.put("message", "起点2不能为空"); + map.put("data", null); + return map; + } + } + if (ObjectUtil.isEmpty(priority)) { + map.put("status", "400"); + map.put("message", "优先级不能为空"); + map.put("data", null); + return map; + } + String taskCode = params.getString("taskCode"); + String taskCreateDateTime = params.getString("taskCreateDateTime"); + String taskType = params.getString("taskType"); + String containerCode = params.getString("containerCode"); + String containerType = params.getString("containerType"); + if (ObjectUtil.isEmpty(taskCode)) { + taskCode = CodeUtil.getNewCode("TASK_NO"); + } +// if (ObjectUtil.isEmpty(taskCreateDateTime)) { +// map.put("status", "400"); +// map.put("message", "任务创建时间不能为空"); +// map.put("data", null); +// return map; +// } +// if (ObjectUtil.isEmpty(taskType)) { +// map.put("status", "400"); +// map.put("message", "任务类型不能为空"); +// map.put("data", null); +// return map; +// } +// if (ObjectUtil.isEmpty(containerCode)) { +// map.put("status", "400"); +// map.put("message", "载具编码不能为空"); +// map.put("data", null); +// return map; +// } +// if (ObjectUtil.isEmpty(containerType)) { +// map.put("status", "400"); +// map.put("message", "载具类型不能为空"); +// map.put("data", null); +// return map; +// } + + + String start_device_code = ""; + String next_device_code = ""; + String start_device_code2 = ""; + String next_device_code2 = ""; + + +// if (start_point_code.indexOf("-") > 0) { +// String str[] = start_point_code.split("-"); +// start_device_code = str[0]; +// } else { + start_device_code = locationFrom; +// } + +// if (next_point_code.indexOf("-") > 0) { +// String str[] = next_point_code.split("-"); +// next_device_code = str[0]; +// } else { + next_device_code = locationTo; +// } + + if (actionType.equals("2")) { + start_device_code2 = locationFrom2; + next_device_code2 = locationTo2; + } + +// //查询wcs传过来的起点终点路由 +// List list = routeLineService.getShortPathLines(start_device_code, next_device_code, "normal"); +// if (ObjectUtil.isEmpty(list)) { +// map.put("responseCode", 1); +// map.put("responseMessage", "路由不通!"); +// return map; +// } + //查询任务编码是否重复 +// TaskDto taskDto = taskService.findByCodeFromCache(taskCode); +// if (taskDto != null) { +// map.put("status", "400"); +// map.put("message", "不能存在相同的任务号"); +// map.put("data", null); +// return map; +// } + //判断载具编码是否相同 + if (!StrUtil.isEmpty(containerCode)) { + TaskDto vehicle_dto = taskService.findByContainer(containerCode); + if (vehicle_dto != null) { + map.put("status", "400"); + map.put("message", "已存在该容器号的任务"); + map.put("data", null); + return map; + } + } + + //判断设备是否还有未完成的任务 + int count1 = taskService.queryDeviceUnfinishTask(locationFrom); + if (count1 > 0) { + map.put("status", "400"); + map.put("message", "设备"+locationFrom+"有未完成任务"); + map.put("data", null); + return map; + } + int count2 = taskService.queryDeviceUnfinishTask(locationTo); + if (count2 > 0) { + map.put("status", "400"); + map.put("message", "设备"+locationTo+"有未完成任务"); + map.put("data", null); + return map; + } + + JSONObject jo = new JSONObject(); + jo.put("task_code", taskCode); + jo.put("start_point_code", locationFrom); + jo.put("next_point_code", locationTo); + jo.put("start_parent_code", locationFrom); + jo.put("next_parent_code", locationTo); + jo.put("start_device_code", start_device_code); + jo.put("next_device_code", next_device_code); + jo.put("start_point_code2", locationFrom2); + jo.put("next_point_code2", locationTo2); + jo.put("start_device_code2", start_device_code2); + jo.put("next_device_code2", next_device_code2); + jo.put("priority", priority); + jo.put("vehicle_code", vehicleCode); + jo.put("vehicle_type", containerType); + jo.put("create_time", DateUtil.now()); + jo.put("task_type", actionType); + jo.put("create_type",systemType); + jo.put("create_by", systemType); + TaskDto task_dto = (TaskDto) JSONObject.parseObject(String.valueOf(jo), TaskDto.class); + try { + taskService.create(task_dto); + logServer.log(taskCode, "taskCreate", "success", whereJson.toString(), "创建成功", String.valueOf(200), "/createTask", ""); + } catch (Exception e) { + logServer.log(taskCode, "taskCreate", "error", whereJson.toString(), e.getMessage(), String.valueOf(400), "/createTask", ""); + e.printStackTrace(); + map.put("status", "400"); + map.put("message", e.getMessage()); + map.put("data", null); + return map; + } + map.put("status", "200"); + map.put("message", "创建任务成功"); + JSONObject ja = new JSONObject(); + ja.put("taskCode", taskCode); + map.put("data", ja); + log.info("taskCreate--------------:输出参数:" + map.toString()); + return map; + } + + @Override + public Map taskOperation(JSONObject whereJson) { + Map map = new HashMap<>(); + log.info("taskOperation--------------:输入参数:" + whereJson.toString()); + String wmsTaskCode = whereJson.getString("wmsTaskCode"); + String operation = whereJson.getString("operation"); + if (ObjectUtil.isEmpty(wmsTaskCode)) { + map.put("status", "400"); + map.put("message", "任务编码不能为空"); + map.put("data", null); + return map; + } + if (ObjectUtil.isEmpty(operation)) { + map.put("status", "400"); + map.put("message", "操作不能为空"); + map.put("data", null); + return map; + } + if (operation.equals("1")) { + taskService.finishByWmsOrMes(whereJson); + } else if (operation.equals("2")) { + taskService.cancelByWmsOrMes(whereJson); + } else { + map.put("status", "400"); + map.put("message", "操作类型错误"); + map.put("data", null); + return map; + } + map.put("status", "200"); + map.put("message", "操作成功"); + map.put("data", null); + log.info("taskOperation--------------:输出参数:" + map.toString()); + return map; + } + + @Override + public Map taskStatus(JSONObject whereJson) { + Map map = new HashMap<>(); + log.info("taskStatus--------------:输入参数:" + whereJson.toString()); + String taskCode = whereJson.getString("taskCode"); + if (ObjectUtil.isEmpty(taskCode)) { + map.put("status", "400"); + map.put("message", "任务编码不能为空"); + map.put("data", null); + log.info("taskStatus--------------:输出参数:" + map.toString()); + return map; + } + TaskDto taskDto = taskService.findByCodeFromCache(taskCode); + if (taskDto == null) { + map.put("status", "400"); + map.put("message", "任务不存在"); + map.put("data", null); + log.info("taskStatus--------------:输出参数:" + map.toString()); + return map; + } + map.put("status", "200"); + map.put("message", "查询成功"); + JSONObject jo = new JSONObject(); + jo.put("status", taskDto.getTask_status()); + map.put("data", jo); + log.info("taskStatus--------------:输出参数:" + map.toString()); + return map; + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsZDToAcsServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsZDToAcsServiceImpl.java index 1b0c443..18914b4 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsZDToAcsServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/WmsZDToAcsServiceImpl.java @@ -15,6 +15,7 @@ import org.nl.modules.logging.service.LogService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; +import oshi.driver.mac.net.NetStat; import java.util.HashMap; import java.util.List; @@ -39,55 +40,126 @@ public class WmsZDToAcsServiceImpl implements WmsZDToAcsService { Map map = new HashMap<>(); log.info("taskCreate--------------:输入参数:" + whereJson.toString()); //获取甲方wcs传过来的参数 - String houseCode = whereJson.getString("houseCode"); - String systemCode = whereJson.getString("systemCode"); - JSONObject parameters = whereJson.getJSONObject("parameters"); - String taskCode = whereJson.getString("taskCode"); - String taskType = whereJson.getString("taskType"); - String taskCreateDatetime = whereJson.getString("taskCreateDatetime"); - String containerCode = whereJson.getString("containerCode"); - String containerType = whereJson.getString("containerType"); - String start_point_code = whereJson.getString("locationFrom"); - String next_point_code = whereJson.getString("locationTo"); + JSONObject params = whereJson.getJSONObject("params"); + String locationFrom = whereJson.getString("locationFrom"); + String locationTo = whereJson.getString("locationTo"); + String locationFrom2 = whereJson.getString("locationFrom2"); + String locationTo2 = whereJson.getString("locationTo2"); String priority = whereJson.getString("priority"); + String actionType = whereJson.getString("actionType"); + String systemType = whereJson.getString("systemType"); + String vehicleCode = whereJson.getString("containerCode"); + String remark = whereJson.getString("remark"); + if (ObjectUtil.isEmpty(params)){ + map.put("status", "400"); + map.put("message", "扩展参数不能为空"); + map.put("data", null); + return map; + } + + if (ObjectUtil.isEmpty(actionType)){ + map.put("status", "400"); + map.put("message", "任务动作类型不能为空"); + map.put("data", null); + return map; + } + + if (ObjectUtil.isEmpty(locationFrom)){ + map.put("status", "400"); + map.put("message", "起点1不能为空"); + map.put("data", null); + return map; + } + + if (ObjectUtil.isEmpty(locationTo)){ + map.put("status", "400"); + map.put("message", "终点1不能为空"); + map.put("data", null); + return map; + } + if (actionType.equals("2")) { + if (ObjectUtil.isEmpty(locationFrom2)) { + map.put("status", "400"); + map.put("message", "起点2不能为空"); + map.put("data", null); + return map; + } + + if (ObjectUtil.isEmpty(locationTo2)) { + map.put("status", "400"); + map.put("message", "起点2不能为空"); + map.put("data", null); + return map; + } + } + if (ObjectUtil.isEmpty(priority)){ + map.put("status", "400"); + map.put("message", "优先级不能为空"); + map.put("data", null); + return map; + } + String taskCode = params.getString("taskCode"); + String taskCreateDateTime = params.getString("taskCreateDateTime"); + String taskType = params.getString("taskType"); + String containerCode = params.getString("containerCode"); + String containerType = params.getString("containerType"); + if (ObjectUtil.isEmpty(taskCode)){ + map.put("status", "400"); + map.put("message", "任务编码不能为空"); + map.put("data", null); + return map; + } +// if (ObjectUtil.isEmpty(taskCreateDateTime)){ +// map.put("status", "400"); +// map.put("message", "任务创建时间不能为空"); +// map.put("data", null); +// return map; +// } +// if (ObjectUtil.isEmpty(taskType)){ +// map.put("status", "400"); +// map.put("message", "任务类型不能为空"); +// map.put("data", null); +// return map; +// } +// if (ObjectUtil.isEmpty(containerCode)){ +// map.put("status", "400"); +// map.put("message", "载具编码不能为空"); +// map.put("data", null); +// return map; +// } +// if (ObjectUtil.isEmpty(containerType)){ +// map.put("status", "400"); +// map.put("message", "载具类型不能为空"); +// map.put("data", null); +// return map; +// } + + String start_device_code = ""; String next_device_code = ""; - //判断必填项是否为空 - if (StrUtil.isEmpty(taskCode)) { - map.put("responseCode", 1); - map.put("responseMessage", "任务号不能为空"); - return map; - } - if (StrUtil.isEmpty(start_point_code)) { - map.put("responseCode", 1); - map.put("responseMessage", "起点不能为空"); - return map; - } - if (StrUtil.isEmpty(next_point_code)) { - map.put("responseCode", 1); - map.put("responseMessage", "终点不能为空"); - return map; - } - if (StrUtil.isEmpty(containerCode)) { - map.put("responseCode", 1); - map.put("responseMessage", "容器编号不能为空"); - return map; - } + String start_device_code2 = ""; + String next_device_code2 = ""; + // if (start_point_code.indexOf("-") > 0) { // String str[] = start_point_code.split("-"); // start_device_code = str[0]; // } else { - start_device_code = start_point_code; + start_device_code = locationFrom; // } // if (next_point_code.indexOf("-") > 0) { // String str[] = next_point_code.split("-"); // next_device_code = str[0]; // } else { - next_device_code = next_point_code; + next_device_code = locationTo; // } + if (actionType.equals("2")) { + start_device_code2 = locationFrom2; + next_device_code2 = locationTo2; + } + // //查询wcs传过来的起点终点路由 // List list = routeLineService.getShortPathLines(start_device_code, next_device_code, "normal"); // if (ObjectUtil.isEmpty(list)) { @@ -98,33 +170,56 @@ public class WmsZDToAcsServiceImpl implements WmsZDToAcsService { //查询任务编码是否重复 TaskDto taskDto = taskService.findByCodeFromCache(taskCode); if (taskDto != null) { - map.put("responseCode", 1); - map.put("responseMessage", "不能存在相同的任务号!"); + map.put("status", "400"); + map.put("message", "不能存在相同的任务号"); + map.put("data", null); return map; } //判断载具编码是否相同 if (!StrUtil.isEmpty(containerCode)) { TaskDto vehicle_dto = taskService.findByContainer(containerCode); if (vehicle_dto != null) { - map.put("responseCode", 1); - map.put("responseMessage", "已存在该容器号的任务!"); + map.put("status", "400"); + map.put("message", "已存在该载具号的任务"); + map.put("data", null); return map; } } + //判断设备是否还有未完成的任务 + int count1 = taskService.queryDeviceUnfinishTask(locationFrom); + if (count1 > 0) { + map.put("status", "400"); + map.put("message", "设备"+locationFrom+"有未完成任务"); + map.put("data", null); + return map; + } + int count2 = taskService.queryDeviceUnfinishTask(locationTo); + if (count2 > 0) { + map.put("status", "400"); + map.put("message", "设备"+locationTo+"有未完成任务"); + map.put("data", null); + return map; + } JSONObject jo = new JSONObject(); jo.put("task_code", taskCode); - 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_point_code", locationFrom); + jo.put("next_point_code", locationTo); + jo.put("start_parent_code", locationFrom); + jo.put("next_parent_code", locationTo); jo.put("start_device_code", start_device_code); jo.put("next_device_code", next_device_code); + jo.put("start_point_code2", locationFrom2); + jo.put("next_point_code2", locationTo2); + jo.put("start_device_code2", start_device_code2); + jo.put("next_device_code2", next_device_code2); jo.put("priority", priority); jo.put("vehicle_code", containerCode); jo.put("vehicle_type", containerType); - jo.put("create_time", taskCreateDatetime); - jo.put("task_type", taskType); + jo.put("create_time", taskCreateDateTime); + jo.put("task_type", actionType); + jo.put("create_type", systemType); + jo.put("create_by", systemType); TaskDto task_dto = (TaskDto) JSONObject.parseObject(String.valueOf(jo), TaskDto.class); try { taskService.create(task_dto); @@ -132,13 +227,79 @@ public class WmsZDToAcsServiceImpl implements WmsZDToAcsService { } catch (Exception e) { logServer.log(taskCode, "taskCreate", "error", whereJson.toString(), e.getMessage(), String.valueOf(400), "/createTask", ""); e.printStackTrace(); - map.put("responseCode", 1); - map.put("responseMessage", e.getMessage()); + map.put("status", "400"); + map.put("message", e.getMessage()); + map.put("data", null); return map; } - map.put("responseCode", 0); - map.put("responseMessage", "创建任务成功!"); - map.put("parameters", new HashMap<>()); + map.put("status", "200"); + map.put("message", "创建任务成功"); + JSONObject ja = new JSONObject(); + jo.put("taskCode", taskCode); + map.put("data", ja); + log.info("taskCreate--------------:输出参数:" + map.toString()); + return map; + } + + @Override + public Map taskOperation(JSONObject whereJson) { + Map map = new HashMap<>(); + log.info("taskOperation--------------:输入参数:" + whereJson.toString()); + String wmsTaskCode = whereJson.getString("wmsTaskCode"); + String operation = whereJson.getString("operation"); + if (ObjectUtil.isEmpty(wmsTaskCode)) { + map.put("status", "400"); + map.put("message", "任务编码不能为空"); + map.put("data", null); + return map; + } + if (ObjectUtil.isEmpty(operation)) { + map.put("status", "400"); + map.put("message", "操作不能为空"); + map.put("data", null); + return map; + } + if (operation.equals("1")){ + taskService.finishByWmsOrMes(whereJson); + }else if (operation.equals("2")){ + taskService.cancelByWmsOrMes(whereJson); + }else { + map.put("status", "400"); + map.put("message", "操作类型错误"); + map.put("data", null); + return map; + } + map.put("status", "200"); + map.put("message", "操作成功"); + map.put("data", null); + log.info("taskOperation--------------:输出参数:" + map.toString()); + return map; + } + + @Override + public Map taskStatus(JSONObject whereJson) { + Map map = new HashMap<>(); + log.info("taskStatus--------------:输入参数:" + whereJson.toString()); + String taskCode = whereJson.getString("taskCode"); + if (ObjectUtil.isEmpty(taskCode)) { + map.put("status", "400"); + map.put("message", "任务编码不能为空"); + map.put("data", null); + return map; + } + TaskDto taskDto = taskService.findByCodeFromCache(taskCode); + if (taskDto == null) { + map.put("status", "400"); + map.put("message", "任务不存在"); + map.put("data", null); + return map; + } + map.put("status", "200"); + map.put("message", "查询成功"); + JSONObject jo = new JSONObject(); + jo.put("status", taskDto.getTask_status()); + map.put("data", jo); + log.info("taskStatus--------------:输出参数:" + map.toString()); return map; } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java index 203e45e..fc42549 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/InstructionService.java @@ -276,4 +276,6 @@ public interface InstructionService { void init(String id); + + Instruction findBylinkCode(String linkDeviceCode); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/InstructionDto.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/InstructionDto.java index 5a6f574..214cd9b 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/InstructionDto.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/dto/InstructionDto.java @@ -348,4 +348,15 @@ public class InstructionDto implements Serializable { */ private String agv_system_type; + /** + * agv取货高度 + */ + private String start_height = "0"; + + + /** + * agv放货高度 + */ + private String next_height = "0"; + } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index f7f9e46..cbf27fc 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -245,7 +245,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu @Override public Instruction findByCode(String code) { WQLObject wo = WQLObject.getWQLObject("acs_instruction"); - JSONObject json = wo.query("instruction_code ='" + code + "'").uniqueResult(0); + JSONObject json = wo.query("instruction_code ='" + code + "'","create_time desc").uniqueResult(0); if (ObjectUtil.isEmpty(json)) { return null; } @@ -313,13 +313,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu if (StrUtil.isEmpty(dto.getLink_num())) { dto.setIs_send(task.getLink_num()); } - if (task.getTask_type().equals("1") || task.getTask_type().equals("2")) { - dto.setInstruction_type(task.getTask_type()); - } else if (false) { - - } else { - dto.setInstruction_type("3"); - } + dto.setInstruction_type(task.getTask_type()); // 查询是否存在相同指令号 // if (!StrUtil.isEmpty(dto.getVehicle_code() )) { @@ -361,6 +355,24 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu dto.setSend_status("1"); } } else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue().toString(), String.valueOf(AgvSystemEnum.NDC.getIndex()))) { + if(StrUtil.isBlank(dto.getAgv_inst_type())){ +// String agv_system_type = task.getAgv_system_type(); + String task_type = task.getTask_type(); + // task_type + //1、普通任务; Itype=1: + //2、四点任务 Itype=2; + //3、八点任务 Itype=3; + if (StrUtil.equals(task_type, "1")) { + dto.setAgv_inst_type("1"); + } else if (StrUtil.equals(task_type, "2")||task_type.equals("4")) { + dto.setAgv_inst_type("2"); + } else if (StrUtil.equals(task_type, "3")) { + dto.setAgv_inst_type("3"); + } else { + log.info("未找到对应的AGV指令类型,任务号:" + task.getTask_code() + ",task_type:" + task.getTask_type()) ; + } +// dto.setAgv_system_type(task.getAgv_system_type()); + } ndcAgvService.sendAgvInstToNDC("1", dto); dto.setSend_status("1"); @@ -912,30 +924,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu } if (flag) { - - if (StrUtil.equals(entity.getInstruction_type(), "7")) { - CancelTaskRequest cancelTaskRequest = new CancelTaskRequest(); - cancelTaskRequest.setOrderId(entity.getInstruction_code()); - cancelTaskRequest.setPalletCode(entity.getVehicle_code()); - cancelTaskRequest.setSrcLocation(entity.getStart_point_code()); - cancelTaskRequest.setDestLocation(entity.getNext_point_code()); - // 1 入库,2 出库,3 移库,4 空托盘入库,5 空托盘出库 - int type = 0; - if (StrUtil.equals(task.getStorage_task_type(), "1")) { - type = 1; - } else if (StrUtil.equals(task.getStorage_task_type(), "2")) { - type = 4; - } else if (StrUtil.equals(task.getStorage_task_type(), "3")) { - type = 2; - } else if (StrUtil.equals(task.getStorage_task_type(), "4")) { - type = 5; - } else if (StrUtil.equals(task.getStorage_task_type(), "5")) { - type = 3; - } - cancelTaskRequest.setTaskType(type); - acsToLiKuService.cancelTask(cancelTaskRequest); - } - String currentUsername = SecurityUtils.getCurrentUsername(); String now = DateUtil.now(); entity.setUpdate_time(now); @@ -944,39 +932,6 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu 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; - } removeByCodeFromCache(entity.getInstruction_code()); } // this.reload(); @@ -985,15 +940,15 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu @Override public void forceCancel(String id) throws Exception { // flag= true时取消指令 - boolean flag = false; +// 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()); - } +// TaskDto task = taskService.findByCodeFromCache(entity.getTask_code()); +// if (StrUtil.isEmpty(entity.getRoute_plan_code())) { +// entity.setRoute_plan_code(task.getRoute_plan_code()); +// } String currentUsername = SecurityUtils.getCurrentUsername(); String now = DateUtil.now(); entity.setUpdate_time(now); @@ -1002,38 +957,38 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu 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; - } +// 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; +// } removeByCodeFromCache(entity.getInstruction_code()); } @@ -1457,4 +1412,27 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu ((SiemensConveyorDeviceDriver) startDeviceDriver).writing(list); } } + + @Override + public Instruction findBylinkCode(String linkDeviceCode) { + List instructionList = instructions; + ListUtil.sort( + instructionList, + new Comparator() { + @Override + public int compare(Instruction o1, Instruction o2) { + return o1.getCreate_time().compareTo(o2.getCreate_time()); + } + }); + Iterator it = instructions.iterator(); + while (it.hasNext()) { + Instruction inst = it.next(); + if (StrUtil.equals(linkDeviceCode, inst.getNext_device_code()) + && inst.getInstruction_status().equals("1")) { + return inst; + } + } + + return null; + } } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java index 55a0ce1..5fcb735 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java @@ -180,6 +180,13 @@ public interface TaskService { */ void finish(String ids); + /** + * 完成任务 + * + * @param json + */ + void finishByWmsOrMes(JSONObject json); + /** * 取消任务 * @@ -187,6 +194,13 @@ public interface TaskService { */ void cancel(String ids) throws Exception; + /** + * 取消任务 + * + * @param json + */ + void cancelByWmsOrMes(JSONObject json); + /** * 取消任务 @@ -322,5 +336,12 @@ public interface TaskService { */ Integer querySameDeviceReadyTask(String start_device,String next_device,String status); + /** + * 查询设备未完成任务的数量 + * + * @param + * @return + */ + Integer queryDeviceUnfinishTask(String device_code); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java index c80a62d..c12440d 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/dto/TaskDto.java @@ -85,7 +85,7 @@ public class TaskDto implements Serializable { private String priority; /** - * 创建类型 + * 创建类型 1-wms 2-mes */ private String create_type; @@ -274,6 +274,11 @@ public class TaskDto implements Serializable { */ private String next_parent_code; + /** + * 车号 + */ + private String car_no; + /** * AGV系统类型 diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java index e268c7e..2ace820 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java @@ -21,6 +21,7 @@ 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.ext.wms.service.AcsToMesService; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.AcsToWmsZDService; import org.nl.acs.instruction.service.InstructionService; @@ -81,6 +82,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { @Autowired AcsToWmsZDService acsToWmsZDService; @Autowired + private AcsToMesService acsToMesService; + @Autowired TaskFeedbackService taskFeedbackService; @Autowired ParamService paramService; @@ -305,7 +308,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { @Override public TaskDto findByCode(String code) { WQLObject wo = WQLObject.getWQLObject("acs_task"); - JSONObject json = wo.query("task_code ='" + code + "'").uniqueResult(0); + JSONObject json = wo.query("task_code ='" + code + "'","create_time desc").uniqueResult(0); final TaskDto obj = json.toJavaObject(TaskDto.class); return obj; } @@ -454,7 +457,9 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { 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); + if (StrUtil.isEmpty(dto.getCreate_by())) { + dto.setCreate_by(currentUsername); + } dto.setUpdate_by(currentUsername); dto.setUpdate_time(now); dto.setCreate_time(now); @@ -732,6 +737,21 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { // 判断是否为WMS下发的任务,如果是反馈任务状态给WMS String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue(); // if (!StrUtil.startWith(entity.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { +// JSONObject jo = new JSONObject(); +// jo.put("taskCode", task.getTask_code()); +// jo.put("carId", carno); +// jo.put("taskType ", task.getTask_type()); +// jo.put("feedbackStatus","applyTake"); +// log.info("请求参数:{}", jo); +// HttpResponse result = acsToWmsZDService.taskFeedback(jo); +// JSONObject response = JSONObject.parseObject(result.body()); +// int responseCode = response.getInteger("responseCode"); +// if (responseCode == 0) { +// log.info("请求ZDwcs成功,申请取货 请求结果{}", responseCode); +// } +// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); +// } +// if (!StrUtil.startWith(entity.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { // TaskFeedbackDto feefbackdto = taskFeedbackService.findByCode(entity.getTask_code()); // System.out.println(feefbackdto == null); // JSONObject feed_jo = new JSONObject(); @@ -823,13 +843,69 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { // } // } // 如果属于先知AGV,关闭运单序列 - if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) { - try { - agvService.markComplete(entity.getTask_code()); - } catch (Exception e) { - e.printStackTrace(); - } +// if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) { +// try { +// agvService.markComplete(entity.getTask_code()); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } + } + + + @Override + @Transactional(rollbackFor = Exception.class) + public void finishByWmsOrMes(JSONObject whereJson) { + TaskDto entity = this.findByCode(whereJson.getString("wmsTaskCode")); + if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!"); + InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl"); + InstructionDto instdto = instructionservice.findByTaskid(entity.getTask_id(), "instruction_status <2 "); + if (instdto != null) throw new BadRequestException("任务号为【"+entity.getTask_code()+"】有指令未完成!"); + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + entity.setUpdate_time(now); + entity.setUpdate_by("外部系统"); + entity.setTask_status("2"); + entity.setRemark("外部系统完成"); + WQLObject wo = WQLObject.getWQLObject("acs_task"); + JSONObject json = (JSONObject) JSONObject.toJSON(entity); + wo.update(json); + removeByCodeFromCache(entity.getTask_code()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void cancelByWmsOrMes(JSONObject whereJson) { + TaskDto entity = this.findByCode(whereJson.getString("wmsTaskCode")); + if (entity == null) { + throw new BadRequestException("被删除或无权限,操作失败!"); } + InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl"); + InstructionDto instdto = instructionservice.findByTaskid(entity.getTask_id(), "instruction_status <2 "); + if (instdto != null) { + throw new BadRequestException("任务号为【"+entity.getTask_code()+"】有指令未完成!"); + } + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + entity.setUpdate_time(now); + entity.setUpdate_by("外部系统"); + entity.setTask_status("3"); + entity.setRemark("外部系统取消"); + WQLObject wo = WQLObject.getWQLObject("acs_task"); + JSONObject json = (JSONObject) JSONObject.toJSON(entity); + wo.update(json); + +// synchronized (TaskServiceImpl.class){ +// Iterator it = tasks.iterator(); +// // 清理缓存 +// while (it.hasNext()) { +// TaskDto taskDto = it.next(); +// if (taskDto.getTask_id().equals(id)) { +// tasks.remove(taskDto); +// } +// }} + + removeByCodeFromCache(entity.getTask_code()); } @Override @@ -867,22 +943,22 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { // 判断是否为WMS下发的任务,如果是反馈任务状态给WMS String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue(); + String hasMes = paramService.findByCode(AcsConfig.HASMES).getCode(); String Type1=entity.getTask_type(); - if(StrUtil.equals(Type1,"定点任务")){ - JSONObject jo = new JSONObject(); - jo.put("taskCode",entity.getTask_code()); - jo.put("carId",""); - jo.put("taskType ",entity.getTask_type()); - jo.put("feedbackStatus","taking"); - log.info("请求参数:{}",jo); - HttpResponse result= acsToWmsZDService.taskFeedback(jo); + if(!StrUtil.startWith(entity.getTask_code(), "-") &&entity.getCreate_type().equals("2")&& StrUtil.equals(hasMes, "1")){ + JSONObject feed_jo = new JSONObject(); + feed_jo.put("task_code", entity.getTask_code()); +// JSONArray ja = new JSONArray(); +// ja.add(feed_jo); +// acstowmsService.feedbackTaskStatusToWms(ja); + HttpResponse result=acsToMesService.taskDeprecate(feed_jo); JSONObject response=JSONObject.parseObject(result.body()); int responseCode= response.getInteger("responseCode"); if(responseCode == 0) { - log.info("请求ZDwcs成功,申请取货 请求结果{}",responseCode); + log.info("请求Mes成功,任务取消 请求结果{}",responseCode); } } - if (!StrUtil.startWith(entity.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) { + if (!StrUtil.startWith(entity.getTask_code(), "-") &&entity.getCreate_type().equals("1")&& StrUtil.equals(hasWms, "1")) { JSONObject feed_jo = new JSONObject(); feed_jo.put("task_code", entity.getTask_code()); // JSONArray ja = new JSONArray(); @@ -895,18 +971,18 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { log.info("请求ZDwcs成功,任务取消 请求结果{}",responseCode); } } - 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(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) { - agvService.markComplete(entity.getTask_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任务 +// if (!StrUtil.equals(type, "0")) { +// if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) { +// agvService.markComplete(entity.getTask_code()); +// } +// } } @Override @@ -1629,6 +1705,23 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { } + @Override + public Integer queryDeviceUnfinishTask(String device_code) { + int num = 0; + Iterator iterator = tasks.iterator(); + while (iterator.hasNext()) { + TaskDto task = iterator.next(); + if ((StrUtil.equals(task.getStart_device_code(), device_code) + || StrUtil.equals(task.getNext_device_code(), device_code)) + && Integer.parseInt(task.getTask_status()) < 2) { + num++; + } + } + + return num; + } + + @Override public Integer querySameTaskByType(String taskType) { int num = 0; diff --git a/acs/nladmin-system/src/main/java/org/nl/hand/rest/PadController.java b/acs/nladmin-system/src/main/java/org/nl/hand/rest/PadController.java new file mode 100644 index 0000000..0a9fd63 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/hand/rest/PadController.java @@ -0,0 +1,50 @@ +package org.nl.hand.rest; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.hand.service.PadService; +import org.nl.modules.logging.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; + +@RestController +@RequiredArgsConstructor +@Api(tags = "手持接口") +@RequestMapping("/api/hand") +@Slf4j +public class PadController { + + private final PadService HandService; + + @PostMapping("/sendPointTask") + @Log("任务操作") + @ApiOperation("任务操作") + //@PreAuthorize("@el.check('sect:list')") + public ResponseEntity Taskoperation(@RequestBody Map whereJson) { + return new ResponseEntity<>(HandService.sendPointTask(whereJson), HttpStatus.OK); + } + + @PostMapping("/getTaskInfoByStartPoint") + @Log("根据起点查询任务信息") + @ApiOperation("根据起点查询任务信息") + //@PreAuthorize("@el.check('sect:list')") + public ResponseEntity getTaskInfoByStartPoint(@RequestBody Map whereJson) { + return new ResponseEntity<>(HandService.getTaskInfoByStartPoint(whereJson), HttpStatus.OK); + } + + @PostMapping("/getAllTaskType") + @Log("根据起点查询任务信息") + @ApiOperation("根据起点查询任务信息") + //@PreAuthorize("@el.check('sect:list')") + public ResponseEntity getAllTaskType() { + return new ResponseEntity<>(HandService.getAllTaskType(), HttpStatus.OK); + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/hand/service/PadService.java b/acs/nladmin-system/src/main/java/org/nl/hand/service/PadService.java new file mode 100644 index 0000000..ea75279 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/hand/service/PadService.java @@ -0,0 +1,25 @@ +package org.nl.hand.service; + +import java.util.Map; + +public interface PadService { + /** + * 发送点位任务 + * @param whereJson + * @return + */ + Map sendPointTask(Map whereJson); + + /** + * 获取任务信息 + * @param whereJson + * @return + */ + Map getTaskInfoByStartPoint(Map whereJson); + + /** + * 获取所有任务类型 + * @return + */ + Map getAllTaskType(); +} diff --git a/acs/nladmin-system/src/main/java/org/nl/hand/service/dto/PadDto.java b/acs/nladmin-system/src/main/java/org/nl/hand/service/dto/PadDto.java new file mode 100644 index 0000000..a661c89 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/hand/service/dto/PadDto.java @@ -0,0 +1,40 @@ +package org.nl.hand.service.dto; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class PadDto implements Serializable { + + /** + * 任务类型 + */ + private String task_type; + + /** + * 起点1 + */ + private String point_code1; + + /** + * 终点1 + */ + private String point_code2; + + /** + * 起点2 + */ + private String point_code3; + + /** + * 终点2 + */ + private String point_code4; + + /** + * 是否超限 + */ + private String is_overrun; + +} diff --git a/acs/nladmin-system/src/main/java/org/nl/hand/service/impl/PadServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/hand/service/impl/PadServiceImpl.java new file mode 100644 index 0000000..4001b71 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/hand/service/impl/PadServiceImpl.java @@ -0,0 +1,164 @@ +package org.nl.hand.service.impl; + +import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONObject; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.service.dto.TaskConfigDto; +import org.nl.acs.device.service.impl.TaskConfigServiceImpl; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.opc.DeviceAppServiceImpl; +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.hand.service.PadService; +import org.nl.modules.common.exception.BadRequestException; +import org.nl.modules.wql.WQL; +import org.nl.modules.wql.util.SpringContextHolder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Map; + +@Service +@RequiredArgsConstructor +@Slf4j +public class PadServiceImpl implements PadService { + + @Autowired + TaskService taskService; + @Override + public Map sendPointTask(Map whereJson) { + JSONObject resultJson = new JSONObject(); + String task_type = whereJson.get("task_type"); + String point_code1 = whereJson.get("point_code1"); + String point_code2 = whereJson.get("point_code2"); + String point_code3 = whereJson.get("point_code3"); + String point_code4 = whereJson.get("point_code4"); + String is_overrun = whereJson.get("is_overrun"); + if (StrUtil.isEmpty(point_code1)) { + throw new BadRequestException("起点1不能为空"); + } + if (StrUtil.isEmpty(point_code2)) { + throw new BadRequestException("终点1不能为空"); + } + DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); + Device startDevice = appService.findDeviceByCode(point_code1); + Device nextDevice = appService.findDeviceByCode(point_code2); + if (startDevice == null) { + throw new BadRequestException("起点1不存在"); + } + if (nextDevice == null) { + throw new BadRequestException("终点1不存在"); + } + Device startDevice2 = null; + Device nextDevice2 = null; + if (!"1".equals(task_type)){ + if (StrUtil.isEmpty(point_code3)) { + throw new BadRequestException("起点2不能为空"); + } + if (StrUtil.isEmpty(point_code4)){ + throw new BadRequestException("终点2不能为空"); + } + startDevice2 = appService.findDeviceByCode(point_code3); + nextDevice2 = appService.findDeviceByCode(point_code4); + if (startDevice2 == null) { + throw new BadRequestException("起点2不存在"); + } + if (nextDevice2 == null) { + throw new BadRequestException("终点2不存在"); + } + //判断设备是否还有未完成的任务 + int count1 = taskService.queryDeviceUnfinishTask(point_code3); + if (count1 > 0) { + throw new BadRequestException("设备"+point_code3+"有未完成任务"); + } + int count2 = taskService.queryDeviceUnfinishTask(point_code4); + if (count2 > 0) { + throw new BadRequestException("设备"+point_code4+"有未完成任务"); + } + } + + //判断设备是否还有未完成的任务 + int count1 = taskService.queryDeviceUnfinishTask(point_code1); + if (count1 > 0) { + throw new BadRequestException("设备"+point_code1+"有未完成任务"); + } + int count2 = taskService.queryDeviceUnfinishTask(point_code2); + if (count2 > 0) { + throw new BadRequestException("设备"+point_code2+"有未完成任务"); + } + TaskService taskService = SpringContextHolder.getBean(TaskServiceImpl.class); + TaskDto dto = new TaskDto(); + dto.setIs_active("1"); + dto.setIs_delete("0"); + dto.setStart_point_code(point_code1); + dto.setStart_device_code(point_code1); + dto.setNext_point_code(point_code2); + dto.setNext_device_code(point_code2); + dto.setNext_point_code2(point_code4); + dto.setNext_device_code2(point_code4); + dto.setStart_point_code2(point_code3); + dto.setStart_device_code2(point_code3); + dto.setTask_type(task_type); + dto.setPriority("1"); + try { + taskService.create(dto); + } catch (Exception e) { + resultJson.put("code", "400"); + resultJson.put("message", e.getMessage()); + return resultJson; + } + resultJson.put("code", "200"); + resultJson.put("message", "生成成功!"); + return resultJson; + } + + @Override + public Map getTaskInfoByStartPoint(Map whereJson) { + String task_type = whereJson.get("task_type"); + String point_code1 = whereJson.get("point_code1"); + if (StrUtil.isEmpty(point_code1)){ + throw new BadRequestException("起点1不能为空"); + } + if (StrUtil.isEmpty(task_type)){ + throw new BadRequestException("任务类型不能为空"); + } + TaskConfigServiceImpl taskConfigService = SpringContextHolder.getBean(TaskConfigServiceImpl.class); + TaskConfigDto taskConfigDto = taskConfigService.selectTaskConfigByStartPointAndTaskType(point_code1, task_type); + JSONObject ja = new JSONObject(); + JSONObject resultJson = new JSONObject(); + if (taskConfigDto == null){ + resultJson.put("point_code2", ""); + resultJson.put("point_code3", ""); + resultJson.put("point_code4", ""); + ja.put("data", resultJson); + return ja; + } + resultJson.put("point_code2", taskConfigDto.getPoint_code2()); + resultJson.put("point_code3", taskConfigDto.getPoint_code3()); + resultJson.put("point_code4", taskConfigDto.getPoint_code4()); + ja.put("data", resultJson); + return ja; + } + + @Override + public Map getAllTaskType() { + // 返回值 + JSONObject resultJSON = new JSONObject(); + + // 查询任务类型 + resultJSON.put("data", + WQL + .getWO("PAD") + .addParam("flag", "1") + .process() + .getResultJSONArray(0)); + + // 返回 + resultJSON.put("code", "200"); + resultJSON.put("message", "查询成功"); + return resultJSON; + } +} diff --git a/acs/nladmin-system/src/main/java/org/nl/hand/wql/PAD.wql b/acs/nladmin-system/src/main/java/org/nl/hand/wql/PAD.wql new file mode 100644 index 0000000..48e67bf --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/hand/wql/PAD.wql @@ -0,0 +1,55 @@ +[交易说明] + 交易名: 包装工单查询 + 所属模块: + 功能简述: + 版权所有: + 表引用: + 版本经历: + +[数据库] + --指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 + +[IO定义] + ################################################# + ## 表字段对应输入参数 + ################################################# + 输入.flag TYPEAS s_string + 输入.region_id TYPEAS s_string + 输入.point_id TYPEAS s_string + 输入.lock_type TYPEAS s_string + 输入.col TYPEAS s_string + +[临时表] + --这边列出来的临时表就会在运行期动态创建 + +[临时变量] + --所有中间过程变量均可在此处定义 + +[业务过程] + + ########################################## + # 1、输入输出检查 # + ########################################## + + + ########################################## + # 2、主过程前处理 # + ########################################## + + + ########################################## + # 3、业务主过程 # + ########################################## + + IF 输入.flag = "1" + QUERY + SELECT + dd.label as text, + dd.`value` as value + FROM + sys_dict_detail dd + WHERE + dd.`name` = 'task_type' + ENDSELECT + ENDQUERY + ENDIF diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/lucene/service/dto/LuceneLogDto.java b/acs/nladmin-system/src/main/java/org/nl/modules/lucene/service/dto/LuceneLogDto.java index bdd6e6c..1b40289 100644 --- a/acs/nladmin-system/src/main/java/org/nl/modules/lucene/service/dto/LuceneLogDto.java +++ b/acs/nladmin-system/src/main/java/org/nl/modules/lucene/service/dto/LuceneLogDto.java @@ -38,6 +38,11 @@ public class LuceneLogDto { /* 日志类型 */ private String log_type; + /** + * 日志级别 + */ + private Integer log_level; + /* 方法 */ private String method; @@ -83,6 +88,13 @@ public class LuceneLogDto { + home; } + public LuceneLogDto(final Integer log_level, final String requestparam, final String content) { + super(); + this.log_level = log_level; + this.requestparam = requestparam; + this.content = content; + } + public LuceneLogDto(final String device_code, final String remark) { super(); this.device_code = device_code; @@ -92,4 +104,14 @@ public class LuceneLogDto { + remark; } + public LuceneLogDto(final Integer log_level,final String method, final String status, + final String requestparam, final String responseparam, final String content) { + super(); + this.log_level = log_level; + this.method =method; + this.requestparam = requestparam; + this.responseparam = responseparam; + this.content = content; + } + } diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/CommonFinalParam.java b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/CommonFinalParam.java new file mode 100644 index 0000000..faf14be --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/CommonFinalParam.java @@ -0,0 +1,79 @@ +package org.nl.modules.quartz; + +import lombok.Data; + +@Data +public class CommonFinalParam { + public static final String DELETE = "0"; + /** + * 分隔符 + */ + private final String BARRE = "-"; + private final String POINT = "."; + + public static final String ZERO = "0"; + public static final String ONE = "1"; + + public static final String TWO = "2"; + + public static final String THREE = "3"; + public static final String FOUR = "4"; + public static final String FIVE = "5"; + public static final String SIX = "6"; + public static final String SEVEN = "7"; + public static final String EIGHT = "8"; + public static final String NINE = "9"; + public static final String TEN = "10"; + public static final String ELEVEN = "11"; + + + /** + * 无货 + */ + public static final int DEVICE_MOVE_ZERO = 0; + /** + * 设备联机等待 + */ + public static final int DEVICE_MODE_TWO = 2; + /** + * 成功状态 + */ + public static final int STATUS_OPEN = 200; + + /** + * 动作信号 + */ + public static final int ACTION_ONE = 1; + public static final int ACTION_TWO = 2; + public static final int ACTION_THREE = 3; + + /** + * 申请任务type类型 + */ + public static final String TYPE_ONE = "1"; + public static final String TYPE_TWO = "2"; + public static final String TYPE_THREE = "3"; + public static final String TYPE_FOUR = "4"; + public static final String TYPE_FIVE = "5"; + public static final String TYPE_SIX = "6"; + public static final String TYPE_SEVEN = "7"; + + + + + /** + * 切割点符号 + */ + public static final String DOT = "."; + /** + * 切割横杠符号 + */ + public static final String HYPHEN_ = "-"; + + + + /** + * 自动门 + */ + public static final String DOORS = "doors"; +} diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java index 9e3aaf7..4f0e6b3 100644 --- a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java +++ b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/AutoCreateInst.java @@ -2,17 +2,21 @@ package org.nl.modules.quartz.task; 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.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; +import org.nl.acs.device_driver.basedriver.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.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.quartz.CommonFinalParam; import org.nl.modules.wql.util.SpringContextHolder; import org.springframework.stereotype.Component; @@ -39,7 +43,7 @@ public class AutoCreateInst { List list = taskserver.queryAll("task_status = '0'"); for (int i = 0; i < list.size(); i++) { TaskDto acsTask = list.get(i); - if(StrUtil.equals(acsTask.getTask_type(),"7") && !StrUtil.startWith(acsTask.getTask_code(), "-") ){ + if (StrUtil.equals(acsTask.getTask_type(), "7") && !StrUtil.startWith(acsTask.getTask_code(), "-")) { continue; } String taskid = acsTask.getTask_id(); @@ -69,12 +73,30 @@ public class AutoCreateInst { String route_plan_code = acsTask.getRoute_plan_code(); String vehicleType = acsTask.getVehicle_type(); String agv_system_type = acsTask.getAgv_system_type(); + String create_type = acsTask.getCreate_type(); if (StrUtil.equals(is_send, "0")) { continue; } - + String start_point = acsTask.getStart_device_code(); + Device device = appService.findDeviceByCode(start_point); + if (StrUtil.equals(acsTask.getTask_type(), "1") && device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { + List deviceCodes = ((StandardInspectSiteDeviceDriver) device.getDeviceDriver()).getExtraDeviceCodes("link_device_code"); + if (ObjectUtil.isNotEmpty(deviceCodes)) { + String linkDeviceCode = deviceCodes.get(0); + Instruction instruction = instructionService.findBylinkCode(linkDeviceCode); + if (ObjectUtil.isNotEmpty(instruction)) { + String carno = instruction.getCarno(); + if (StrUtil.isNotEmpty(carno)) { + acsTask.setCar_no(carno); + acsTask.setPriority("2"); + }else { + continue; + } + } + } + } // //校验路由关系 // List shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); // if (ObjectUtils.isEmpty(shortPathsList)) { @@ -140,7 +162,25 @@ public class AutoCreateInst { instdto.setVehicle_type(vehicleType); instdto.setAgv_system_type(agv_system_type); instdto.setAgv_inst_type("1"); + instdto.setCreate_type(create_type); + instdto.setCarno(acsTask.getCar_no()); + // task_type + //1、普通任务; Itype=1: + //2、四点任务 Itype=2; + //3、八点任务 Itype=3; + if (StrUtil.equals(task_type, CommonFinalParam.ONE)) { + instdto.setAgv_inst_type(CommonFinalParam.ONE); + } else if (StrUtil.equals(task_type, "1")) { + instdto.setAgv_inst_type("1"); + } else if (StrUtil.equals(task_type, "2") || StrUtil.equals(task_type, "4")) { + instdto.setAgv_inst_type("2"); + } else if (StrUtil.equals(task_type, "3")) { + instdto.setAgv_inst_type("3"); + } else { + log.info("未找到对应的AGV指令类型,任务号:" + acsTask.getTask_code() + ",task_type:" + acsTask.getTask_type()); + continue; + } try { instructionService.create(instdto); diff --git a/acs/nladmin-system/src/main/resources/log/AcsToMesServiceImpl.xml b/acs/nladmin-system/src/main/resources/log/AcsToMesServiceImpl.xml new file mode 100644 index 0000000..d6a8a03 --- /dev/null +++ b/acs/nladmin-system/src/main/resources/log/AcsToMesServiceImpl.xml @@ -0,0 +1,33 @@ + + + + + + + + + ${LOG_HOME}/ACS请求MES/%d{yyyy-MM-dd}.%i.log + + 15 + + 200MB + + 2GB + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + ${log.charset} + + + + + + + + + + + diff --git a/acs/nladmin-system/src/main/resources/log/MesToAcsServiceImpl.xml b/acs/nladmin-system/src/main/resources/log/MesToAcsServiceImpl.xml new file mode 100644 index 0000000..768cdf3 --- /dev/null +++ b/acs/nladmin-system/src/main/resources/log/MesToAcsServiceImpl.xml @@ -0,0 +1,33 @@ + + + + + + + + + ${LOG_HOME}/MES请求ACS/%d{yyyy-MM-dd}.%i.log + + 15 + + 200MB + + 2GB + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + ${log.charset} + + + + + + + + + + + diff --git a/acs/nladmin-system/src/main/resources/logback-spring.xml b/acs/nladmin-system/src/main/resources/logback-spring.xml index 9665a43..29a0f6b 100644 --- a/acs/nladmin-system/src/main/resources/logback-spring.xml +++ b/acs/nladmin-system/src/main/resources/logback-spring.xml @@ -64,42 +64,21 @@ https://juejin.cn/post/6844903775631572999 - - - 1000 - - ${LOKI_URL}/push - - - - - ${log.pattern} - - true - - - - - - - @@ -125,13 +104,8 @@ https://juejin.cn/post/6844903775631572999 - - - - - @@ -139,44 +113,34 @@ https://juejin.cn/post/6844903775631572999 - - - - - - - - - - diff --git a/acs/nladmin-ui/src/api/acs/TaskConfig.js b/acs/nladmin-ui/src/api/acs/TaskConfig.js new file mode 100644 index 0000000..e670725 --- /dev/null +++ b/acs/nladmin-ui/src/api/acs/TaskConfig.js @@ -0,0 +1,27 @@ +import request from '@/utils/request' + +export function add(data) { + return request({ + url: 'api/TaskConfig', + method: 'post', + data + }) +} + +export function del(ids) { + return request({ + url: 'api/TaskConfig/', + method: 'delete', + data: ids + }) +} + +export function edit(data) { + return request({ + url: 'api/TaskConfig', + method: 'put', + data + }) +} + +export default { add, edit, del } diff --git a/acs/nladmin-ui/src/views/acs/device/driver/siemens_conveyor.vue b/acs/nladmin-ui/src/views/acs/device/driver/siemens_conveyor.vue index 7ecfb7d..bc4b365 100644 --- a/acs/nladmin-ui/src/views/acs/device/driver/siemens_conveyor.vue +++ b/acs/nladmin-ui/src/views/acs/device/driver/siemens_conveyor.vue @@ -46,12 +46,12 @@
- 输送系统: + 安全交互:
- + diff --git a/acs/nladmin-ui/src/views/acs/device/driver/standard_inspect_site.vue b/acs/nladmin-ui/src/views/acs/device/driver/standard_inspect_site.vue index 2a71c31..eff99bb 100644 --- a/acs/nladmin-ui/src/views/acs/device/driver/standard_inspect_site.vue +++ b/acs/nladmin-ui/src/views/acs/device/driver/standard_inspect_site.vue @@ -46,15 +46,32 @@
- 输送系统: + 安全交互:
- + + + + + + + +
@@ -286,6 +303,7 @@ export default { dataOpcservers: [], dataOpcPlcs: [], deviceList: [], + extSystemList: [{'label': 'WMS交互', 'value': '1' }, { 'label': 'MES点', 'value': '2' }, { 'label': '焊接线交互', 'value': '3' }], data1: [], data2: [], form: { @@ -298,7 +316,8 @@ export default { is_pickup: true, is_release: true, link_device_code: [], - address: '' + address: '', + ext_system: '' }, rules: {} } diff --git a/acs/nladmin-ui/src/views/acs/device/storageCell/index.vue b/acs/nladmin-ui/src/views/acs/device/storageCell/index.vue index bf0d0ad..9186de0 100644 --- a/acs/nladmin-ui/src/views/acs/device/storageCell/index.vue +++ b/acs/nladmin-ui/src/views/acs/device/storageCell/index.vue @@ -34,9 +34,12 @@ - + + + + @@ -56,7 +59,8 @@ - + + @@ -83,7 +87,7 @@ import udOperation from '@crud/UD.operation' import pagination from '@crud/Pagination' import rrOperation from '@crud/RR.operation' -const defaultForm = { storage_id: null, storage_code: null, x: null, y: null, z: null, address: null, remark: null, is_active: null, is_delete: null, create_by: null, create_time: null, update_by: null, update_time: null, parent_storage_code: null } +const defaultForm = { storage_id: null, storage_code: null, x: null, y: null, z: null, address: null, address1: null, remark: null, is_active: null, is_delete: null, create_by: null, create_time: null, update_by: null, update_time: null, parent_storage_code: null } export default { name: 'StorageCell', components: { pagination, crudOperation, udOperation, rrOperation }, diff --git a/acs/nladmin-ui/src/views/acs/device/taskConfig/index.vue b/acs/nladmin-ui/src/views/acs/device/taskConfig/index.vue new file mode 100644 index 0000000..e3c066a --- /dev/null +++ b/acs/nladmin-ui/src/views/acs/device/taskConfig/index.vue @@ -0,0 +1,198 @@ + + + + +