This commit is contained in:
USER-20220102CG\noblelift
2022-12-25 12:17:36 +08:00
parent b5c3184f11
commit 397a3694ff
30 changed files with 787 additions and 367 deletions

View File

@@ -1880,6 +1880,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
String device_type = list.get(2).toString();
String is_config = list.get(3).toString();
String is_route = list.get(4).toString();
String region = list.get(5).toString();
if (StrUtil.isEmpty(device_code)) {
throw new BadRequestException("设备编号为空!");
}
@@ -1893,7 +1894,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
is_config = "FALSE";
}
if (StrUtil.isEmpty(is_route)) {
is_route = "FALSE";
is_route = "false";
}
DeviceDto dto = this.findByCode(device_code);
if (ObjectUtil.isNotEmpty(dto)) {
@@ -1910,6 +1911,7 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
param.put("create_time", now);
param.put("update_by", nickName);
param.put("update_time", now);
param.put("region", region);
wo.insert(param);
}

View File

@@ -14,6 +14,7 @@ import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingRequest;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
import org.nl.acs.instruction.service.InstructionService;
@@ -24,7 +25,9 @@ import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.system.service.ParamService;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
import org.openscada.opc.lib.da.Server;
import org.springframework.beans.factory.annotation.Autowired;
@@ -70,7 +73,9 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
public int error = 0;
public int door = 0;
public int temperature = 0;
public int countdown = 0;
public int countdown_house = 0;
public int countdown_min = 0;
public int countdown_sec = 0;
public int finish = 0;
public int task = 0;
public int error1 = 0;
@@ -90,7 +95,9 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
public int last_error = 0;
public int last_door = 0;
public int last_temperature = 0;
public int last_countdown = 0;
public int last_countdown_house = 0;
public int last_countdown_min = 0;
public int last_countdown_sec = 0;
public int last_finish = 0;
public int last_task = 0;
public int last_error1 = 0;
@@ -132,7 +139,9 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
error = this.itemProtocol.getItem_error();
door = this.itemProtocol.getItem_door();
temperature = this.itemProtocol.getItem_temperature();
countdown = this.itemProtocol.getItem_countdown();
countdown_house = this.itemProtocol.getItem_countdown_house();
countdown_min = this.itemProtocol.getItem_countdown_min();
countdown_sec = this.itemProtocol.getItem_countdown_sec();
finish = this.itemProtocol.getItem_finish();
task = this.itemProtocol.getItem_task();
error1 = this.itemProtocol.getItem_error1();
@@ -157,24 +166,21 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
}
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) {
if (error != 0) {
this.setIsonline(false);
this.setIserror(true);
message = "有报警";
//无报警
} else {
if(move ==0 && last_move ==1){
requireSucess = false;
}
if(finish == 1 && last_finish == 0 && !requireSucess ){
//烘箱完成反馈LMS
apply_finish();
}
}
last_mode = mode;
@@ -183,7 +189,9 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
last_error = error;
last_door = door;
last_temperature = temperature;
last_countdown = countdown;
last_countdown_house = countdown_house;
last_countdown_min = countdown_min;
last_countdown_sec = countdown_sec;
last_finish = finish;
last_task = task;
last_error1 = error1;
@@ -198,17 +206,6 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
}
public synchronized boolean instruction_apply(String container_code) throws Exception {
Date date = new Date();
if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return false;
} else {
this.instruction_apply_time = date;
requireSucess = true;
return true;
}
}
protected void thingToNothing() {
this.setRequireSucess(false);
@@ -320,4 +317,25 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
}
public synchronized boolean apply_finish() {
Date date = new Date();
if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return false;
} else {
this.instruction_apply_time = date;
ApplyLabelingAndBindingRequest applyLabelingAndBindingRequest = new ApplyLabelingAndBindingRequest();
JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("storage_code ='" + this.device_code + "'").uniqueResult(0);
String start_point_code = null;
if (!ObjectUtil.isEmpty(device_json)) {
start_point_code = (String) device_json.get("parent_storage_code") == null ? this.device_code : (String) device_json.get("parent_storage_code");
}
applyLabelingAndBindingRequest.setDevice_code(start_point_code);
applyLabelingAndBindingRequest.setType("3");
acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
requireSucess = true;
return true;
}
}
}

View File

@@ -19,7 +19,10 @@ public class ItemProtocol {
public static String item_door = "door";
public static String item_temperature = "temperature";
//恒温倒计时
public static String item_countdown = "countdown";
public static String item_countdown_house = "countdown_house";
public static String item_countdown_min = "countdown_min";
public static String item_countdown_sec = "countdown_sec";
public static String item_finish = "finish";
public static String item_task = "task";
public static String item_error1 = "error1";
@@ -38,7 +41,10 @@ public class ItemProtocol {
public static String item_to_close_door = "to_close_door";
public static String item_to_temperature = "to_temperature";
public static String item_to_material = "to_material";
public static String item_to_time = "to_time";
public static String item_to_time_house = "to_time_house";
public static String item_to_time_min = "to_time_min";
public static String item_to_time_sec = "to_time_sec";
public static String item_to_task = "to_task";
@@ -69,8 +75,14 @@ public class ItemProtocol {
public int getItem_temperature(){
return this.getOpcIntegerValue(item_temperature);
} ;
public int getItem_countdown(){
return this.getOpcIntegerValue(item_countdown);
public int getItem_countdown_house(){
return this.getOpcIntegerValue(item_countdown_house);
} ;
public int getItem_countdown_min(){
return this.getOpcIntegerValue(item_countdown_min);
} ;
public int getItem_countdown_sec(){
return this.getOpcIntegerValue(item_countdown_sec);
} ;
public int getItem_finish(){
return this.getOpcIntegerValue(item_finish);
@@ -127,7 +139,9 @@ public class ItemProtocol {
list.add(new ItemDto(item_move, "光电信号", "550"));
list.add(new ItemDto(item_door, "门状态", "450"));
list.add(new ItemDto(item_temperature, "工位温度", "7991"));
list.add(new ItemDto(item_countdown, "恒温倒计时", "200"));
list.add(new ItemDto(item_countdown_house, "恒温倒计时(时)", "80500"));
list.add(new ItemDto(item_countdown_min, "恒温倒计时(分)", "80502"));
list.add(new ItemDto(item_countdown_sec, "恒温倒计时(秒)", "80504"));
list.add(new ItemDto(item_finish, "烘干完成", "8025"));
list.add(new ItemDto(item_action, "取放信号", "450"));
list.add(new ItemDto(item_task, "任务号", "220"));
@@ -146,13 +160,14 @@ public class ItemProtocol {
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "下发命令", "226"));
list.add(new ItemDto(item_to_open_door, "开门", "8030"));
list.add(new ItemDto(item_to_close_door, "关门", "8031"));
list.add(new ItemDto(item_to_temperature, "生产温度", "8100"));
list.add(new ItemDto(item_to_material, "生产物料", "229"));
list.add(new ItemDto(item_to_time, "生产时间", "210"));
list.add(new ItemDto(item_to_task, "任务号", "232"));
list.add(new ItemDto(item_to_command, "下发命令", "40226"));
list.add(new ItemDto(item_to_open_door, "开门", "00111"));
list.add(new ItemDto(item_to_close_door, "关门", "00112"));
list.add(new ItemDto(item_to_temperature, "生产温度", "48100"));
list.add(new ItemDto(item_to_material, "生产物料", "40229"));
list.add(new ItemDto(item_to_time_house, "生产时间(时)", "48771"));
list.add(new ItemDto(item_to_time_min, "生产时间(分)", "48770"));
list.add(new ItemDto(item_to_task, "任务号", "40232"));
return list;
}

View File

@@ -13,6 +13,7 @@ import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.basedriver.hongxiang_conveyor.HongXiangStationDeviceDriver;
import org.nl.acs.device_driver.basedriver.hongxiang_device.HongXiangConveyorDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
@@ -231,7 +232,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver();
hongXiangConveyorDeviceDriver.writing("to_open_door", "1");
// hongXiangConveyorDeviceDriver.writing("to_open_door", "1");
if (hongXiangConveyorDeviceDriver.getMode() == 1 && hongXiangConveyorDeviceDriver.getDoor() == 1 && hongXiangConveyorDeviceDriver.getAction() == 1 && hongXiangConveyorDeviceDriver.getError1() == 0) {
this.writing("to_command", "4");
this.setNow_steps_type(5);
@@ -259,16 +260,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
e.printStackTrace();
}
TaskDto taskDto = taskserver.findByCode(inst2.getTask_code());
if (ObjectUtil.isNotEmpty(taskDto)) {
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
JSONArray array = new JSONArray();
JSONObject map = new JSONObject();
map.put("task_id", taskDto.getTask_id());
map.put("task_status", "2");
array.add(map);
acsToWmsService.feedbackTaskStatusToWms(array);
}
}
String next_device_code = taskDto.getNext_device_code();
//String start_device_code = taskDto.getStart_device_code();
//Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
@@ -281,6 +273,14 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
if (nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) nextDevice.getDeviceDriver();
hongXiangConveyorDeviceDriver.writing("to_close_door", "1");
if(StrUtil.isNotEmpty(taskDto.getOven_time())){
//下发烘箱时间
int time = Integer.parseInt(taskDto.getOven_time());
int hours = (time % (60 * 60 * 24)) / (60 * 60);
int minutes = (time % (60 * 60)) / 60;
hongXiangConveyorDeviceDriver.writing("to_time_house",String.valueOf(hours));
hongXiangConveyorDeviceDriver.writing("to_time_min",String.valueOf(minutes));
}
}
this.writing("to_command", "5");
this.setNow_steps_type(6);
@@ -412,6 +412,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
this.writing("to_target", next_addr);
this.writing("to_task", instruction.getInstruction_code());
this.writing("to_command", "1");
this.setNow_steps_type(2);
this.setRequireSucess(true);
return true;
@@ -491,6 +492,11 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
this.writing("to_target", next_addr);
this.writing("to_task", instdto.getInstruction_code());
this.writing("to_command", "1");
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
if(nextDevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver){
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver();
hongXiangConveyorDeviceDriver.writing("to_open","1");
}
this.setNow_steps_type(2);
this.setRequireSucess(true);
notCreateInstMessage = "";

View File

@@ -0,0 +1,54 @@
package org.nl.acs.device_driver.basedriver.oven_manipulator;
import java.text.DecimalFormat;
public class Test {
public static String beautifyTime(double second) {
if (second <= 0) return "0";
final String[] units = new String[]{"", "分钟", "小时"};
int digitGroups = (int) (Math.log10(second) / Math.log10(60));
String value = "0";
if(digitGroups<3) {
value = new DecimalFormat("#,##0.#").format(second / Math.pow(60, digitGroups)) + "" + units[digitGroups];
}else if(digitGroups >= 3) {
//如果超过了小时的表达范围则,则转换为天,小时,分,秒格式
value = secondToDate(second);
}
return value;
}
public static String secondToDate(double second) {
Long time = new Long(new Double(second).longValue());
String strTime = null;
Long days = time / (60 * 60 * 24);
Long hours = (time % (60 * 60 * 24)) / (60 * 60);
Long minutes = (time % (60 * 60)) / 60;
Long seconds = time % 60;
if (days > 0) {
strTime = days + "" + hours + "小时" + minutes + "分钟";
} else if (hours > 0) {
strTime = hours + "小时" + minutes + "分钟";
} else if (minutes > 0) {
strTime = minutes + "分钟" + seconds + "";
} else {
strTime = second + "";
}
return strTime;
}
public static void main(String[] args) {
Long time = new Long(new Double(7500).longValue());
Long hours = (time % (60 * 60 * 24)) / (60 * 60);
Long minutes = (time % (60 * 60)) / 60;
Long seconds = time % 60;
System.out.println(hours);
System.out.println(minutes);
System.out.println(seconds);
}
}

View File

@@ -1,9 +1,16 @@
package org.nl.acs.device_driver.basedriver.siemens_conveyor;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.nl.acs.AcsConfig;
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
@@ -19,7 +26,10 @@ 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.system.service.ParamService;
import org.nl.modules.wql.util.SpringContextHolder;
import org.openscada.opc.lib.da.Server;
import org.springframework.beans.factory.annotation.Autowired;
@@ -35,19 +45,25 @@ import java.util.*;
public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
@Autowired
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
@Autowired
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class);
@Autowired
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class);
@Autowired
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
@Autowired
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
@Autowired
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
@Autowired
ParamService paramService = SpringContextHolder.getBean(ParamService.class);
@Autowired
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class);
@Autowired
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
@Autowired
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
@Autowired
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
//当前指令
Instruction inst = null;
//工作模式
int mode = 0;
@@ -77,11 +93,14 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
private int instruction_require_time_out;
//行架机械手申请任务成功标识
boolean requireSucess = false;
//申请成功标记
Boolean applySucess = false;
private int instruction_finished_time_out;
int branchProtocol = 0;
String inst_message;
//当前指令
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
int flag;
@@ -96,7 +115,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
@Override
public void execute() {
public void execute() throws Exception {
String message = null;
try {
device_code = this.getDeviceCode();
@@ -130,12 +149,13 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
return;
}
if (!this.itemProtocol.getIsonline()) {
this.setIsonline(false);
this.setIserror(true);
message = "信号量同步异常";
//未联机
} else if (mode == 0) {
// if (!this.itemProtocol.getIsonline()) {
// this.setIsonline(false);
// this.setIserror(true);
// message = "信号量同步异常";
// //未联机
// } else
if (mode == 0) {
this.setIsonline(false);
this.setIserror(true);
message = "未联机";
@@ -152,6 +172,44 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
Instruction instruction = null;
List toInstructions;
if (mode != last_mode) {
this.setRequireSucess(false);
}
if (move != last_move) {
if (move == 0 && mode == 2) {
thingToNothing();
}
}
if (error != last_error) {
}
if (mode == 2 && move != 0 && task > 0) {
//inst_message
inst = instructionService.findByCodeFromCache(String.valueOf(task));
if (inst != null) {
inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code();
if (StrUtil.equals(inst.getInstruction_status(), "1") && StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) {
finish_instruction();
}
if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) {
inst.setInstruction_status("1");
instructionService.update(inst);
}
}
}
switch (mode) {
case 1:
log.debug("设备运转模式:等待工作");
break;
case 2:
//申请任务
if (move > 0 && !requireSucess) {
instruction_require();
}
}
}
last_mode = mode;
last_move = move;
@@ -175,11 +233,18 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
return true;
}
public synchronized boolean finish_instruction(Instruction inst) throws Exception {
public synchronized boolean finish_instruction() throws Exception {
instructionService.finish(inst);
return true;
}
protected void thingToNothing() throws Exception {
this.setRequireSucess(false);
this.setApplySucess(false);
}
public void writing(String param, String value) {
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
@@ -264,4 +329,106 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
//
// }
/**
* 请求指令
*
*/
public synchronized boolean instruction_require() throws Exception {
Date date = new Date();
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return false;
} else {
this.instruction_require_time = date;
//container_code
TaskDto task = taskserver.findByStartCodeAndReady(device_code);
if (!ObjectUtil.isEmpty(task)) {
// if (!ObjectUtils.isEmpty(instructionService.findByBarcodeFromCache(container_code))) {
// return false;
// }
String taskid = task.getTask_id();
String taskcode = task.getTask_code();
String vehiclecode = task.getVehicle_code();
String priority = task.getPriority();
String start_point_code = task.getStart_point_code();
String start_device_code = task.getStart_device_code();
String route_plan_code = task.getRoute_plan_code();
String next_device_code = "";
/**
* 开始平均分配
*/
String this_coevice_code = taskserver.queryAssignedByDevice(device_code, task.getNext_device_code());
if (StrUtil.isEmpty(this_coevice_code)) {
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, task.getNext_device_code(), route_plan_code);
RouteLineDto routeLineDto = shortPathsList.get(0);
String path = routeLineDto.getPath();
String type = routeLineDto.getType();
String[] str = path.split("->");
// if (!StrUtil.equals(type, "0")) {
// return false;
// }
List<String> pathlist = Arrays.asList(str);
int index = 0;
for (int m = 0; m < pathlist.size(); m++) {
if (pathlist.get(m).equals(start_device_code)) {
index = m + 1;
break;
}
}
next_device_code = pathlist.get(index);
} else {
next_device_code = this_coevice_code;
}
//校验路由关系
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
if (ObjectUtils.isEmpty(shortPathsList)) {
throw new RuntimeException("路由不通!");
}
Device startdevice = deviceAppservice.findDeviceByCode(start_device_code);
Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code);
String next_point_code;
if (StrUtil.equals(deviceAppservice.findDeviceTypeByCode(next_device_code), "storage")) {
next_point_code = task.getTo_x() + "-" + task.getTo_y() + "-" + task.getTo_z();
} else {
next_point_code = next_device_code;
}
Instruction instdto = new Instruction();
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setRoute_plan_code(route_plan_code);
instdto.setRemark(task.getRemark());
instdto.setMaterial(task.getMaterial());
instdto.setQuantity(task.getQuantity());
instdto.setTask_id(taskid);
instdto.setTask_code(taskcode);
instdto.setVehicle_code(vehiclecode);
String now = DateUtil.now();
instdto.setCreate_time(now);
instdto.setCreate_by("auto");
instdto.setStart_device_code(start_device_code);
instdto.setNext_device_code(next_device_code);
instdto.setStart_point_code(start_point_code);
instdto.setNext_point_code(next_point_code);
instdto.setPriority(priority);
instdto.setInstruction_status("0");
instdto.setExecute_device_code(start_point_code);
instructionService.create(instdto);
//创建指令后修改任务状态
task.setTask_status("1");
taskserver.update(task);
requireSucess = true;
applySucess = true;
String next_addr = nextdevice.getExtraValue().get("address").toString();
this.writing("to_target", next_addr);
this.writing("to_task", instdto.getInstruction_code());
this.writing("to_command", "1");
}
return true;
}
}
}

View File

@@ -4,7 +4,12 @@ import lombok.Data;
@Data
public class ApplyLabelingAndBindingRequest extends BaseRequest {
private String ext_task_id;
private String vehicle_code;
private String device_code;
/**
* 1:贴标申请
* 2:捆扎申请
* 3:烘箱
*/
private String type;
}

View File

@@ -75,6 +75,12 @@ public class CreateTaskRequest extends BaseRequest {
*/
String task_type;
/**
* 立库任务类型
*
*/
String dtl_type;
/**
* Agv系统类型
* 1:1楼叉车系统
@@ -88,6 +94,15 @@ public class CreateTaskRequest extends BaseRequest {
*/
String remark;
/**
* 烘箱时间
*/
String oven_time;
/**
* 烘箱温度
*/
String temperature;
/**
* 扩展属性

View File

@@ -0,0 +1,44 @@
package org.nl.acs.ext.wms.data;
import lombok.Data;
import java.util.Map;
@Data
public class UpdateLKTaskRequest extends BaseRequest {
/**
* 任务标识
*/
private String ext_task_id;
/**
* 任务编号
*/
private String task_code;
/**
* 载具号
*/
String vehicle_code;
/**
* 立库任务类型
*/
String dtl_type;
/**
* 类型
*/
String type;
/**
* 原库位
*/
String srcLocation;
/**
* 新库位
*/
String destLocation;
}

View File

@@ -0,0 +1,8 @@
package org.nl.acs.ext.wms.data;
import java.util.Map;
public class UpdateLKTaskResponse extends BaseResponse {
}

View File

@@ -0,0 +1,33 @@
package org.nl.acs.ext.wms.liKuData;
import lombok.Data;
@Data
public class InStoreTaskUpdateRequest extends BaseResponseData {
/**
* 任务编号
* WCS内部任务编号本次任务的唯一标识
*/
public String orderId;
/**
* 托盘条码信息
*/
public String palletCode;
/**
* 原库位号
* 托盘的存储库位编号。具体库位编号需要双方商定
*/
public String srcLocation;
/**
* 目的库位号
* 托盘的目的存储库位编号。具体库位编号需要双方商定
*/
public String destLocation;
/**
* 楼层
*/
public int floorNo;
}

View File

@@ -0,0 +1,7 @@
package org.nl.acs.ext.wms.liKuData;
public class InStoreTaskUpdateResponse extends BaseStoreRequest {
}

View File

@@ -0,0 +1,32 @@
package org.nl.acs.ext.wms.liKuData;
import lombok.Data;
@Data
public class MoveStoreTaskUpdateRequest {
/**
* 任务编号
* WCS内部任务编号本次任务的唯一标识
*/
public String orderId;
/**
* 托盘条码信息
*/
public String palletCode;
/**
* 原库位号
* 托盘的存储库位编号。具体库位编号需要双方商定
*/
public String srcLocation;
/**
* 目的库位号
* 托盘的目的存储库位编号。具体库位编号需要双方商定
*/
public String destLocation;
/**
* 楼层
*/
public int floorNo;
}

View File

@@ -0,0 +1,7 @@
package org.nl.acs.ext.wms.liKuData;
public class MoveStoreTaskUpdateResponse extends BaseStoreRequest {
}

View File

@@ -82,27 +82,6 @@ public class AcsToLiKuController {
return new ResponseEntity<>(acsToLiKuService.roadWayIsLock(requestParam), HttpStatus.OK);
}
@PostMapping("/inStoreReport")
@Log("入库任务上报")
@ApiOperation("向立库下发入库任务上报")
public ResponseEntity<Object> inStoreReport(@RequestBody InStoreReportRequest requestParam) {
return new ResponseEntity<>(acsToLiKuService.inStoreReport(requestParam), HttpStatus.OK);
}
@PostMapping("/outStoreReport")
@Log("出库任务上报")
@ApiOperation("向立库下发出库任务上报")
public ResponseEntity<Object> outStoreReport(@RequestBody OutStoreReportRequest requestParam) {
return new ResponseEntity<>(acsToLiKuService.outStoreReport(requestParam), HttpStatus.OK);
}
@PostMapping("/moveStoreReport")
@Log("移库任务上报")
@ApiOperation("向立库下发移库任务上报")
public ResponseEntity<Object> moveStoreReport(@RequestBody MoveStoreReportRequest requestParam) {
return new ResponseEntity<>(acsToLiKuService.moveStoreReport(requestParam), HttpStatus.OK);
}
@PostMapping("/cancelTask")
@Log("向立库下发任务取消")
@ApiOperation("向立库下发任务取消")

View File

@@ -48,13 +48,6 @@ public class AcsToWmsController {
return new ResponseEntity<>(acstowmsService.feedbackTaskStatusToWms(data), HttpStatus.OK);
}
@PostMapping("/pointStatusFeedback")
@Log("向WMS反馈点位状态")
@ApiOperation("向WMS反馈点位状态")
public ResponseEntity<Object> feedbackPointStatusToWms(@RequestBody Map whereJson) {
return new ResponseEntity<>(acstowmsService.feedbackPointStatusToWms(whereJson), HttpStatus.OK);
}
@PostMapping("/feedbackAgvStatus")
@Log("反馈AGV设备状态")
@ApiOperation("反馈AGV设备状态")

View File

@@ -2,8 +2,10 @@
package org.nl.acs.ext.wms.rest;
import cn.dev33.satoken.annotation.SaIgnore;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jdk.nashorn.internal.ir.annotations.Ignore;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.ext.wms.liKuData.*;
@@ -29,6 +31,7 @@ import org.springframework.web.bind.annotation.RestController;
public class LiKuToACSController {
private final LiKuToAcsService liKuToAcsService;
@SaIgnore
@PostMapping("/inStoreReport")
@Log("入库任务上报")
@ApiOperation("向立库下发入库任务上报")
@@ -36,6 +39,7 @@ public class LiKuToACSController {
return new ResponseEntity<>(liKuToAcsService.inStoreReport(requestParam), HttpStatus.OK);
}
@SaIgnore
@PostMapping("/outStoreReport")
@Log("出库任务上报")
@ApiOperation("向立库下发出库任务上报")
@@ -43,6 +47,7 @@ public class LiKuToACSController {
return new ResponseEntity<>(liKuToAcsService.outStoreReport(requestParam), HttpStatus.OK);
}
@SaIgnore
@PostMapping("/moveStoreReport")
@Log("移库任务上报")
@ApiOperation("向立库下发移库任务上报")

View File

@@ -41,6 +41,7 @@ public class WmsToAcsController {
@PostMapping("/cancelTask")
@Log("WMS取消任务")
@ApiOperation("WMS取消任务")
@SaIgnore
public ResponseEntity<Object> cancelFromWms(@RequestBody String whereJson) throws Exception {
return new ResponseEntity<>(wmstoacsService.cancelFromWms(whereJson), HttpStatus.OK);
}
@@ -62,6 +63,7 @@ public class WmsToAcsController {
@PostMapping("/action")
@Log("下发动作")
@ApiOperation("WMS修改点位状态")
@SaIgnore
public ResponseEntity<Object> putAction(@RequestBody String whereJson) throws Exception {
return new ResponseEntity<>(wmstoacsService.putAction(whereJson), HttpStatus.OK);
}
@@ -69,6 +71,7 @@ public class WmsToAcsController {
@PostMapping("/querydevice")
@Log("查询设备状态")
@ApiOperation("查询设备状态")
@SaIgnore
public ResponseEntity<Object> queryDevice(@RequestBody String whereJson) throws Exception {
return new ResponseEntity<>(wmstoacsService.queryDevice(whereJson), HttpStatus.OK);
}
@@ -76,6 +79,7 @@ public class WmsToAcsController {
@PostMapping("/queryDeviceDBValue")
@Log("查询设备DB值")
@ApiOperation("查询设备DB值")
@SaIgnore
public ResponseEntity<Object> queryDeviceDBValue(@RequestBody String whereJson){
return new ResponseEntity<>(wmstoacsService.queryDeviceDBValue(whereJson), HttpStatus.OK);
}

View File

@@ -60,27 +60,6 @@ public interface AcsToLiKuService {
public Resp<RoadWayIsLockResponse> roadWayIsLock(RoadWayIsLockRequest requestParam);
/**
* 入库任务上报
* @param requestParam
* @return
*/
public Resp<InStoreReportResponse> inStoreReport(InStoreReportRequest requestParam);
/**
* 出库任务上报
* @param requestParam
* @return
*/
public Resp<OutStoreReportResponse> outStoreReport(OutStoreReportRequest requestParam);
/**
* 移库任务上报
* @param requestParam
* @return
*/
public Resp<MoveStoreReportResponse> moveStoreReport(MoveStoreReportRequest requestParam);
/**
*取消任务
* @return

View File

@@ -3,10 +3,7 @@ package org.nl.acs.ext.wms.service;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingRequest;
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingResponse;
import org.nl.acs.ext.wms.data.LiKuApplyTakResponse;
import org.nl.acs.ext.wms.data.LiKuApplyTaskRequest;
import org.nl.acs.ext.wms.data.*;
import java.util.Map;
@@ -30,35 +27,9 @@ public interface AcsToWmsService {
*/
public HttpResponse feedbackTaskStatusToWms(JSONArray arr);
/**
* 向WMS反馈点位状态
*
* @param jsonObject 条件
* @return Map<String, Object>
*/
Map<String, Object> feedbackPointStatusToWms(Map<String, String> jsonObject);
/**
* 向WMS获取设备状态
*
* @return
*/
JSONArray getDeviceStatusToWms();
/**
* 请求信号交互
*
* @param
* @return
*/
public HttpResponse requestSignalInteraction(String device_code, String vehicle_code, String action);
public String requestTaskAgain(String address, String task_id, String vehicle_code);
public String apply_InEmpty(String device_code, String type, String quantity, String pallet);
public String apply_OutEmpty(String device_code);
/**
* 反馈AGV设备状态
*
@@ -136,4 +107,6 @@ public interface AcsToWmsService {
ApplyLabelingAndBindingResponse applyLabelingAndBindingRequest(ApplyLabelingAndBindingRequest param);
LiKuApplyTakResponse liKuApplyTaskRequest(LiKuApplyTaskRequest liKuApplyTaskRequest);
UpdateLKTaskResponse updateLKTaskRequest(UpdateLKTaskRequest updateLKTaskRequest);
}

View File

@@ -71,26 +71,6 @@ public class AcsToLiKuServiceImpl implements AcsToLiKuService {
return RespUtil.getResp(result, new RoadWayIsLockResponse());
}
@Override
public Resp<InStoreReportResponse> inStoreReport(InStoreReportRequest requestParam) {
String api = addressService.findByCode("inStoreReport").getMethods_url();
String result = AcsUtil.notifyAcs(api, requestParam);
return RespUtil.getResp(result, new InStoreReportResponse());
}
@Override
public Resp<OutStoreReportResponse> outStoreReport(OutStoreReportRequest requestParam) {
String api = addressService.findByCode("outStoreReport").getMethods_url();
String result = AcsUtil.notifyAcs(api, requestParam);
return RespUtil.getResp(result, new OutStoreReportResponse());
}
@Override
public Resp<MoveStoreReportResponse> moveStoreReport(MoveStoreReportRequest requestParam) {
String api = addressService.findByCode("moveStoreReport").getMethods_url();
String result = AcsUtil.notifyAcs(api, requestParam);
return RespUtil.getResp(result, new MoveStoreReportResponse());
}
@Override
public Resp<CancelTaskResponse> cancelTask(CancelTaskRequest requestParam) {

View File

@@ -12,10 +12,7 @@ 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.device.service.DeviceService;
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingRequest;
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingResponse;
import org.nl.acs.ext.wms.data.LiKuApplyTakResponse;
import org.nl.acs.ext.wms.data.LiKuApplyTaskRequest;
import org.nl.acs.ext.wms.data.*;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.task.service.TaskService;
@@ -118,88 +115,6 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
return result2;
}
@Override
public Map<String, Object> feedbackPointStatusToWms(Map<String, String> jsonObject) {
AddressDto addressDto = addressService.findByCode("feedbackPointStatusToWms");
String methods_url = addressDto.getMethods_url();
String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue();
String url = wmsurl + methods_url;
JSONObject json = new JSONObject();
json.put("task_uuid", jsonObject.get("device_code"));
json.put("task_code", jsonObject.get("point_status"));
json.put("task_status", jsonObject.get("point_mode"));
json.put("point_error", jsonObject.get("point_error"));
log.info("feedbackPointStatusToWms----请求参数{}", json.toString());
try {
String result2 = HttpRequest.post(url)
.body(String.valueOf(json))
.execute().body();
System.out.println(result2);
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
System.out.println(msg);
}
JSONObject resultJson = new JSONObject();
resultJson.put("status", HttpStatus.OK);
resultJson.put("message", "操作成功");
resultJson.put("data", new JSONArray());
log.info("feedbackPointStatusToWms----输出参数{}", resultJson.toString());
return resultJson;
}
@Override
public JSONArray getDeviceStatusToWms() {
String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("getDeviceStatusToWms");
String methods_url = addressDto.getMethods_url();
String url = wmsurl + methods_url;
String result = "";
try {
result = HttpRequest.get(url)
.execute().body();
System.out.println(result);
log.info("getTaskStatusToWms----返回参数{}", result);
} catch (Exception e) {
System.out.println(e.getMessage());
}
JSONArray jsonArray = JSONArray.parseArray(result);
return jsonArray;
}
@Override
public HttpResponse requestSignalInteraction(String device_code, String vehicle_code, String action) {
String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue();
JSONObject json = new JSONObject();
json.put("device_code", device_code);
json.put("vehicle_code", vehicle_code);
json.put("action", action);
AddressDto addressDto = addressService.findByCode("requestSignalInteraction");
String methods_url = addressDto.getMethods_url();
String url = wmsurl + methods_url;
HttpResponse result = null;
log.info("requestSignalInteraction----请求参数{}", json.toString());
try {
result = HttpRequest.post(url)
.body(String.valueOf(json))
.execute();
System.out.println(result);
log.info("requestSignalInteraction----返回参数{}", result);
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
System.out.println(msg);
}
return result;
}
@Override
public String requestTaskAgain(String address, String task_id, String vehicle_code) {
@@ -228,67 +143,6 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
return result2;
}
@Override
public String apply_InEmpty(String device_code, String type, String quantity, String container_code) {
if (StrUtil.isEmpty(container_code)) {
log.info("apply_InEmpty----空盘入库申请校验失败,{}{}", device_code, "设备条码为空");
throw new BadRequestException("地址对应设备未找到");
}
String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue();
JSONObject jo = new JSONObject();
jo.put("device_code", device_code);
jo.put("type", type);
jo.put("quantity", quantity);
jo.put("container_code", container_code);
String result2 = "";
AddressDto addressDto = addressService.findByCode("apply_InEmpty");
String methods_url = addressDto.getMethods_url();
String url = wmsurl + methods_url;
log.info("requestTaskAgain----请求参数{}", jo);
try {
result2 = HttpRequest.post(url)
.header("Authorization", token)
.body(String.valueOf(jo))
.execute().body();
System.out.println(result2);
log.info("requestTaskAgain----返回参数{}", result2);
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
System.out.println(msg);
}
return result2;
}
@Override
public String apply_OutEmpty(String device_code) {
String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue();
JSONObject jo = new JSONObject();
jo.put("device_code", device_code);
String result2 = "";
AddressDto addressDto = addressService.findByCode("apply_OutEmpty");
String methods_url = addressDto.getMethods_url();
String url = wmsurl + methods_url;
log.info("apply_OutEmpty----请求参数{}", jo);
try {
result2 = HttpRequest.post(url)
.header("Authorization", token)
.body(String.valueOf(jo))
.execute().body();
System.out.println(result2);
log.info("apply_OutEmpty----返回参数{}", result2);
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
System.out.println(msg);
}
return result2;
}
@Override
public HttpResponse feedbackAgvStatus(String device_code, String error, String error_message) {
String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue();
@@ -577,4 +431,32 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
return liKuApplyTakResponse;
}
@Override
public UpdateLKTaskResponse updateLKTaskRequest(UpdateLKTaskRequest param) {
UpdateLKTaskResponse updateLKTaskResponse = new UpdateLKTaskResponse();
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("liKuApplyTask");
String methods_url = addressDto.getMethods_url();
String url = wmsUrl + methods_url;
log.info("UpdateLKTaskResponse----请求参数{}", param);
try {
String result = HttpRequest.post(url)
.body(String.valueOf(param))
.execute().body();
JSONObject jsonObject = JSONObject.parseObject(result);
log.info("UpdateLKTaskResponse----返回参数{}", result);
updateLKTaskResponse = JSONObject.toJavaObject(jsonObject, UpdateLKTaskResponse.class);
} catch (Exception e) {
JSONObject map = new JSONObject();
map.put("status", 400);
map.put("message", e.getMessage());
return JSONObject.toJavaObject(map, UpdateLKTaskResponse.class);
}
}
return updateLKTaskResponse;
}
}

View File

@@ -7,12 +7,16 @@ import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.address.service.AddressService;
import org.nl.acs.ext.wms.AcsUtil;
import org.nl.acs.ext.wms.RespUtil;
import org.nl.acs.ext.wms.data.UpdateLKTaskRequest;
import org.nl.acs.ext.wms.data.UpdateLKTaskResponse;
import org.nl.acs.ext.wms.liKuData.*;
import org.nl.acs.ext.wms.service.AcsToLiKuService;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.LiKuToAcsService;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.springframework.stereotype.Service;
/**
@@ -32,20 +36,66 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService {
private final InstructionService instructionService;
private final AcsToWmsService acsToWmsService;
private final AcsToLiKuService acsToLiKuService;
//入库任务状态反馈
@Override
public Resp<InStoreReportResponse> inStoreReport(InStoreReportRequest requestParam) throws Exception {
String inst_code = requestParam.getOrderId();
String status = requestParam.getState();
Instruction inst = instructionService.findByCodeFromCache(inst_code);
TaskDto task = taskService.findByCodeFromCache(inst.getTask_code());
// 1 已接收 2 开始执行 3执行完成 4 阻挡 5 空洞
if(StrUtil.equals(status,"1") || StrUtil.equals(status,"2") ){
inst.setInstruction_status("1");
instructionService.update(inst);
} else if(StrUtil.equals(status,"3")){
inst.setInstruction_status("2");
instructionService.finish(inst.getInstruction_id());
} else {
} else if(StrUtil.equals(status,"4")) {
UpdateLKTaskRequest updateLKTaskRequest = new UpdateLKTaskRequest();
updateLKTaskRequest.setVehicle_code(inst.getVehicle_code());
updateLKTaskRequest.setExt_task_id(task.getExt_task_id());
updateLKTaskRequest.setDtl_type(task.getStorage_task_type());
updateLKTaskRequest.setSrcLocation(inst.getNext_point_code());
updateLKTaskRequest.setType("1");
//调用LMS接口申请获取新库位
UpdateLKTaskResponse updateLKTaskResponse = acsToWmsService.updateLKTaskRequest(updateLKTaskRequest);
if(updateLKTaskResponse.getstatus() == 200){
String srcLocation = updateLKTaskResponse.getParameters().get("srcLocation");
String destLocation = updateLKTaskResponse.getParameters().get("destLocation ");
InStoreResetRequest inStoreResetRequest = new InStoreResetRequest();
inStoreResetRequest.setFloorNo(Integer.parseInt(inst.getTo_z()));
inStoreResetRequest.setSrcLocation(srcLocation);
inStoreResetRequest.setDestLocation(destLocation);
inStoreResetRequest.setPalletCode(inst.getVehicle_code());
inStoreResetRequest.setOrderId(inst.getInstruction_code());
acsToLiKuService.inStoreReset(inStoreResetRequest);
}
} else if(StrUtil.equals(status,"5")) {
UpdateLKTaskRequest updateLKTaskRequest = new UpdateLKTaskRequest();
updateLKTaskRequest.setVehicle_code(inst.getVehicle_code());
updateLKTaskRequest.setExt_task_id(task.getExt_task_id());
updateLKTaskRequest.setDtl_type(task.getStorage_task_type());
updateLKTaskRequest.setSrcLocation(inst.getNext_point_code());
updateLKTaskRequest.setType("2");
//调用LMS接口申请获取新库位
UpdateLKTaskResponse updateLKTaskResponse = acsToWmsService.updateLKTaskRequest(updateLKTaskRequest);
if(updateLKTaskResponse.getstatus() == 200){
String srcLocation = updateLKTaskResponse.getParameters().get("srcLocation");
String destLocation = updateLKTaskResponse.getParameters().get("destLocation ");
InStoreResetRequest inStoreResetRequest = new InStoreResetRequest();
inStoreResetRequest.setFloorNo(Integer.parseInt(inst.getTo_z()));
inStoreResetRequest.setSrcLocation(srcLocation);
inStoreResetRequest.setDestLocation(destLocation);
inStoreResetRequest.setPalletCode(inst.getVehicle_code());
inStoreResetRequest.setOrderId(inst.getInstruction_code());
acsToLiKuService.inStoreReset(inStoreResetRequest);
}
}
InStoreReportResponse inStoreReportResponse = new InStoreReportResponse();
inStoreReportResponse.setOrderId(inst_code);
@@ -63,13 +113,33 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService {
String inst_code = requestParam.getOrderId();
String status = requestParam.getState();
Instruction inst = instructionService.findByCodeFromCache(inst_code);
TaskDto task = taskService.findByCodeFromCache(inst.getTask_code());
// 1 已接收 2 开始执行 3执行完成 4 阻挡 5 空洞
if(StrUtil.equals(status,"1") || StrUtil.equals(status,"2") ){
inst.setInstruction_status("1");
} else if(StrUtil.equals(status,"3")){
inst.setInstruction_status("2");
instructionService.finish(inst.getInstruction_id());
} else {
//出库任务起点无货
} else if(StrUtil.equals(status,"4")){
UpdateLKTaskRequest updateLKTaskRequest = new UpdateLKTaskRequest();
updateLKTaskRequest.setVehicle_code(inst.getVehicle_code());
updateLKTaskRequest.setExt_task_id(task.getExt_task_id());
updateLKTaskRequest.setDtl_type(task.getStorage_task_type());
updateLKTaskRequest.setSrcLocation(inst.getStart_point_code());
updateLKTaskRequest.setType("5");
//调用LMS接口
UpdateLKTaskResponse updateLKTaskResponse = acsToWmsService.updateLKTaskRequest(updateLKTaskRequest);
} else if(StrUtil.equals(status,"5")){
UpdateLKTaskRequest updateLKTaskRequest = new UpdateLKTaskRequest();
updateLKTaskRequest.setVehicle_code(inst.getVehicle_code());
updateLKTaskRequest.setExt_task_id(task.getExt_task_id());
updateLKTaskRequest.setDtl_type(task.getStorage_task_type());
updateLKTaskRequest.setSrcLocation(inst.getStart_point_code());
updateLKTaskRequest.setType("6");
UpdateLKTaskResponse updateLKTaskResponse = acsToWmsService.updateLKTaskRequest(updateLKTaskRequest);
}
OutStoreReportResponse outStoreReportResponse = new OutStoreReportResponse();
@@ -85,19 +155,63 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService {
}
//移库任务上报
@Override
public Resp<MoveStoreReportResponse> moveStoreReport(MoveStoreReportRequest requestParam) throws Exception {
String inst_code = requestParam.getOrderId();
String status = requestParam.getState();
Instruction inst = instructionService.findByCodeFromCache(inst_code);
TaskDto task = taskService.findByCodeFromCache(inst.getTask_code());
// 1 已接收 2 开始执行 3执行完成 4 阻挡 5 空洞
if(StrUtil.equals(status,"1") || StrUtil.equals(status,"2") ){
inst.setInstruction_status("1");
} else if(StrUtil.equals(status,"3")){
inst.setInstruction_status("2");
instructionService.finish(inst.getInstruction_id());
} else {
} else if(StrUtil.equals(status,"4")){
UpdateLKTaskRequest updateLKTaskRequest = new UpdateLKTaskRequest();
updateLKTaskRequest.setVehicle_code(inst.getVehicle_code());
updateLKTaskRequest.setExt_task_id(task.getExt_task_id());
updateLKTaskRequest.setDtl_type(task.getStorage_task_type());
updateLKTaskRequest.setSrcLocation(inst.getStart_point_code());
updateLKTaskRequest.setType("3");
//调用LMS接口
UpdateLKTaskResponse updateLKTaskResponse = acsToWmsService.updateLKTaskRequest(updateLKTaskRequest);
if(updateLKTaskResponse.getstatus() == 200){
String srcLocation = updateLKTaskResponse.getParameters().get("srcLocation");
String destLocation = updateLKTaskResponse.getParameters().get("destLocation ");
InStoreResetRequest inStoreResetRequest = new InStoreResetRequest();
inStoreResetRequest.setFloorNo(Integer.parseInt(inst.getTo_z()));
inStoreResetRequest.setSrcLocation(srcLocation);
inStoreResetRequest.setDestLocation(destLocation);
inStoreResetRequest.setPalletCode(inst.getVehicle_code());
inStoreResetRequest.setOrderId(inst.getInstruction_code());
acsToLiKuService.inStoreReset(inStoreResetRequest);
}
} else if(StrUtil.equals(status,"5")){
UpdateLKTaskRequest updateLKTaskRequest = new UpdateLKTaskRequest();
updateLKTaskRequest.setVehicle_code(inst.getVehicle_code());
updateLKTaskRequest.setExt_task_id(task.getExt_task_id());
updateLKTaskRequest.setDtl_type(task.getStorage_task_type());
updateLKTaskRequest.setSrcLocation(inst.getNext_point_code());
updateLKTaskRequest.setType("4");
UpdateLKTaskResponse updateLKTaskResponse = acsToWmsService.updateLKTaskRequest(updateLKTaskRequest);
if(updateLKTaskResponse.getstatus() == 200){
String srcLocation = updateLKTaskResponse.getParameters().get("srcLocation");
String destLocation = updateLKTaskResponse.getParameters().get("destLocation ");
InStoreResetRequest inStoreResetRequest = new InStoreResetRequest();
inStoreResetRequest.setFloorNo(Integer.parseInt(inst.getTo_z()));
inStoreResetRequest.setSrcLocation(srcLocation);
inStoreResetRequest.setDestLocation(destLocation);
inStoreResetRequest.setPalletCode(inst.getVehicle_code());
inStoreResetRequest.setOrderId(inst.getInstruction_code());
acsToLiKuService.inStoreReset(inStoreResetRequest);
}
}
MoveStoreReportResponse moveStoreReportResponse = new MoveStoreReportResponse();
moveStoreReportResponse.setOrderId(inst_code);

View File

@@ -12,6 +12,7 @@ import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.basedriver.cargo_lift_conveyor.CargoLiftConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.empty_vehicle_stacking_position.EmptyVehicleStackingPositionDeviceDriver;
import org.nl.acs.device_driver.basedriver.hongxiang_conveyor.HongXiangStationDeviceDriver;
import org.nl.acs.device_driver.basedriver.hongxiang_device.HongXiangConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver;
import org.nl.acs.ext.wms.data.*;
import org.nl.acs.ext.wms.service.WmsToAcsService;
@@ -168,10 +169,10 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
JSONArray backja = new JSONArray();
JSONArray datas = JSONArray.parseArray(jsonObject);
//空托盘叠盘
EmptyVehicleStackingPositionDeviceDriver emptyVehicleStackingPositionDeviceDriver;
//货梯对接线
CargoLiftConveyorDeviceDriver cargoLiftConveyorDeviceDriver;
//AGV烘箱对接
HongXiangStationDeviceDriver hongXiangStationDeviceDriver;
//烘箱工位
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
//货梯对接线-带扫码器
StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver;
@@ -182,30 +183,46 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
for (int i = 0; i < datas.size(); i++) {
JSONObject jo = new JSONObject();
JSONObject data = datas.getJSONObject(i);
String device_code = data.getString("device_code");
String parent_device_code = data.getString("device_code");
String device_code = "";
JSONObject device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + parent_device_code + "'").uniqueResult(0);
if (!ObjectUtil.isEmpty(device_json)) {
device_code = (String) device_json.get("parent_storage_code") == null ? parent_device_code : (String) device_json.get("storage_code");
}
Device device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device)) {
throw new Exception("未找到对应设备:" + device_code);
throw new Exception("未找到对应设备:" + parent_device_code);
}
if (device.getDeviceDriver() instanceof EmptyVehicleStackingPositionDeviceDriver) {
emptyVehicleStackingPositionDeviceDriver = (EmptyVehicleStackingPositionDeviceDriver) device.getDeviceDriver();
jo.put("device_code", device.getDevice_code());
jo.put("vehicle_num", emptyVehicleStackingPositionDeviceDriver.getNumber());
} else if (device.getDeviceDriver() instanceof CargoLiftConveyorDeviceDriver) {
cargoLiftConveyorDeviceDriver = (CargoLiftConveyorDeviceDriver) device.getDeviceDriver();
jo.put("device_code", device.getDevice_code());
jo.put("move", cargoLiftConveyorDeviceDriver.getMove());
jo.put("action", cargoLiftConveyorDeviceDriver.getAction());
jo.put("error", cargoLiftConveyorDeviceDriver.getError());
} else if (device.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) {
if (device.getDeviceDriver() instanceof HongXiangStationDeviceDriver) {
hongXiangStationDeviceDriver = (HongXiangStationDeviceDriver) device.getDeviceDriver();
jo.put("device_code", parent_device_code);
jo.put("mode", hongXiangStationDeviceDriver.getMode());
jo.put("move", hongXiangStationDeviceDriver.getMove());
}
else if(device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver){
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver();
jo.put("device_code", parent_device_code);
jo.put("mode", hongXiangConveyorDeviceDriver.getMode());
jo.put("move", hongXiangConveyorDeviceDriver.getMove());
jo.put("countdown_house", hongXiangConveyorDeviceDriver.getCountdown_house());
jo.put("countdown_min", hongXiangConveyorDeviceDriver.getCountdown_min());
jo.put("countdown_sec", hongXiangConveyorDeviceDriver.getCountdown_sec());
jo.put("temperature", hongXiangConveyorDeviceDriver.getTemperature());
jo.put("door", hongXiangConveyorDeviceDriver.getDoor());
jo.put("finish", hongXiangConveyorDeviceDriver.getFinish());
jo.put("task", hongXiangConveyorDeviceDriver.getTask());
jo.put("error", hongXiangConveyorDeviceDriver.getError());
}
else if (device.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) {
standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) device.getDeviceDriver();
jo.put("device_code", device.getDevice_code());
jo.put("device_code", parent_device_code);
jo.put("move", standardCoveyorControlWithScannerDeviceDriver.getMove());
jo.put("action", standardCoveyorControlWithScannerDeviceDriver.getAction());
jo.put("error", standardCoveyorControlWithScannerDeviceDriver.getError());
} else {
jo.put("device_code", device.getDevice_code());
jo.put("device_code", parent_device_code);
}
backja.add(jo);
}
@@ -279,8 +296,11 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
String vehicle_type = request.getVehicle_type();
String route_plan_code = request.getRoute_plan_code();
String task_type = request.getTask_type();
String storage_task_type = request.getDtl_type();
String agv_system_type = request.getAgv_system_type();
String remark = request.getRemark();
double oven_time = Double.parseDouble(request.getOven_time());
String temperature = request.getTemperature();
Map<String,String> params = request.getParams();
String start_point_code = "";
@@ -404,7 +424,9 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
jo.put("priority", priority);
jo.put("vehicle_code", vehicle_code);
jo.put("vehicle_type", vehicle_type);
jo.put("storage_task_type", storage_task_type);
jo.put("agv_system_type", agv_system_type);
jo.put("oven_time", (int) Math.ceil(oven_time));
jo.put("remark", remark);
jo.put("params", params);
jo.put("task_type", StrUtil.isEmpty(task_type) ? 1 : Integer.parseInt(task_type));
@@ -415,7 +437,12 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
TaskDto task_dto = jo.toJavaObject(TaskDto.class);
try {
taskService.create(task_dto);
// task_type=7 则是立库任务需要下刻下发
if(StrUtil.equals(task_dto.getTask_type(),"7")){
taskService.create(task_dto);
} else {
taskService.create(task_dto);
}
} catch (Exception e) {
e.printStackTrace();
JSONObject json = new JSONObject();

View File

@@ -24,6 +24,7 @@ import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspect
import org.nl.acs.device_driver.basedriver.standard_storage.StandardStorageDeviceDriver;
import org.nl.acs.ext.wms.liKuData.*;
import org.nl.acs.ext.wms.service.AcsToLiKuService;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.opc.Device;
@@ -75,7 +76,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
RouteLineService routeLineService;
@Autowired
TaskService taskService;
@Autowired
AcsToLiKuService acsToLiKuService;
@Override
public void autoInitial() {
@@ -350,6 +352,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
InStoreRequest request = new InStoreRequest();
request.setFloorNo(Integer.parseInt(dto.getTo_z()));
request.setType(1);
request.setPalletCode(dto.getVehicle_code());
request.setOrderId(dto.getInstruction_code());
request.setSrcLocation(dto.getStart_point_code());
request.setDestLocation(dto.getNext_point_code());
@@ -359,6 +362,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
InStoreRequest request = new InStoreRequest();
request.setFloorNo(Integer.parseInt(dto.getTo_z()));
request.setType(2);
request.setPalletCode(dto.getVehicle_code());
request.setOrderId(dto.getInstruction_code());
request.setSrcLocation(dto.getStart_point_code());
request.setDestLocation(dto.getNext_point_code());
@@ -397,6 +401,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
baseReq.setSrcLocation(dto.getStart_point_code());
baseReq.setDestLocation(dto.getNext_point_code());
list.add(baseReq);
moveStoreRequest.setGroupId(dto.getInstruction_code());
moveStoreRequest.setOrderInfos(list);
resp = acsToLiKuService.moveStore(moveStoreRequest);
}
@@ -806,6 +812,31 @@ 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);

View File

@@ -1,5 +1,6 @@
package org.nl.acs.opc;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -35,6 +36,11 @@ public class DeviceManageServiceImpl implements DeviceManageService {
//OPC表【acs_opc】
String opc_code = opcTab.query("is_delete= '0' AND is_active= '1' AND opc_id = '" + opc_server_id + "'").uniqueResult(0).getString("opc_code");
device.setOpc_server_code(opc_code);
if(ObjectUtil.isEmpty(plcTab.query("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").uniqueResult(0)))
{
System.out.println(device.getDevice_code());
continue;
}
String plc_code = plcTab.query("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").uniqueResult(0).getString("plc_code");
device.setOpc_plc_code(plc_code);
}

View File

@@ -239,6 +239,16 @@ public interface TaskService {
*/
TaskDto findByStartCode(String device_code);
/**
* 根据起点设备编号查询当前是否有就绪任务
*
* @param device_code
* @return
*/
TaskDto findByStartCodeAndReady(String device_code);
/**
* 查询内存任务
*

View File

@@ -279,4 +279,15 @@ public class TaskDto implements Serializable {
* AGV系统类型
*/
private String agv_system_type;
/**
* 烘箱时间s
*/
private String oven_time;
/**
* 烘箱温度
*/
private String temperature;
}

View File

@@ -1119,6 +1119,20 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
return null;
}
@Override
public TaskDto findByStartCodeAndReady(String device_code) {
Iterator var3 = tasks.iterator();
while (var3.hasNext()) {
TaskDto task = (TaskDto) var3.next();
if (StrUtil.equals(task.getStart_device_code(), device_code) && StrUtil.equals(task.getTask_status(), "0")) {
return task;
}
}
return null;
}
@Override
public TaskDto findByStartCode(String device_code) {
Iterator var3 = tasks.iterator();

View File

@@ -70,39 +70,38 @@ public class AutoCreateInst {
if (StrUtil.equals(is_send, "0")) {
continue;
}
if (StrUtil.equals(task_type, "1") || StrUtil.equals(task_type, "2")) {
//校验路由关系
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
if (ObjectUtils.isEmpty(shortPathsList)) {
acsTask.setRemark("路由不通无法生成指令");
taskserver.updateByCodeFromCache(acsTask);
continue;
}
//校验路由关系
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
if (ObjectUtils.isEmpty(shortPathsList)) {
acsTask.setRemark("路由不通无法生成指令");
taskserver.updateByCodeFromCache(acsTask);
continue;
}
if (!StrUtil.equals(shortPathsList.get(0).getType(), "1")) {
continue;
}
if (!StrUtil.equals(shortPathsList.get(0).getType(), "1")) {
continue;
}
RouteLineDto routeLineDto = shortPathsList.get(0);
String path = routeLineDto.getPath();
String type = routeLineDto.getType();
String[] str = path.split("->");
List<String> pathlist = Arrays.asList(str);
int index = 0;
for (int m = 0; m < pathlist.size(); m++) {
if (pathlist.get(m).equals(start_device_code)) {
index = m + 1;
break;
}
}
next_device_code = pathlist.get(index);
if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) {
next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z();
} else {
next_point_code = next_device_code;
RouteLineDto routeLineDto = shortPathsList.get(0);
String path = routeLineDto.getPath();
String type = routeLineDto.getType();
String[] str = path.split("->");
List<String> pathlist = Arrays.asList(str);
int index = 0;
for (int m = 0; m < pathlist.size(); m++) {
if (pathlist.get(m).equals(start_device_code)) {
index = m + 1;
break;
}
}
next_device_code = pathlist.get(index);
if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) {
next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z();
} else {
next_point_code = next_device_code;
}
Instruction instdto = new Instruction();
instdto.setInstruction_type(task_type);