Merge remote-tracking branch 'origin/master'

This commit is contained in:
zhangzhiqiang
2023-02-04 09:08:02 +08:00
32 changed files with 3299 additions and 1710 deletions

View File

@@ -41,8 +41,9 @@ public enum DriverTypeEnum {
PLUG_PULL_DEVICE_SITE(15, "plug_pull_device_site", "插拔轴站点", "conveyor"),
SIEMENS_CONVEYOR_LABELING(16, "siemens_conveyor_labeling", "西门子-输送机驱动-贴标", "conveyor");
SIEMENS_CONVEYOR_LABELING(16, "siemens_conveyor_labeling", "西门子-输送机驱动-贴标", "conveyor"),
SIEMENS_CONVEYOR_CKK(17, "siemens_conveyor_ckk", "西门子-输送机驱动-出库口", "conveyor");
//驱动索引

View File

@@ -21,93 +21,10 @@ import org.openscada.opc.lib.list.ServerList;
import java.net.UnknownHostException;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class ReadUtil {
public static void main(String[] args) throws AlreadyConnectedException, JIException, UnknownHostException, NotConnectedException, DuplicateGroupException, AddFailedException, InterruptedException {
// 启动服务
/* ItemProtocol ipl = new ItemProtocol();
List<ItemDto> list = ipl.getReadableItemDtos();
List<String> ls = new ArrayList<>();
for (ItemDto dto : list) {
//ls.add("RD3.RD3.2265."+ dto.getCode());
}
ls.add("DDJ1.DDJ1.DDJ1.heartbeat");
ls.add("DDJ1.DDJ1.DDJ1.action");
final Server server = getServer();
Map<String, Object> map = read(ls, server);
*//*Map<String, Object> params=new HashMap<>();
params.put("RD3.RD3.2265."+"mode","0");
write(params, server);*//*
System.out.println(111);*/
/* try {
test();
} catch (InterruptedException e) {
e.printStackTrace();
}*/
//List<Map<String, String>> maps = showAllOpcServer("192.168.81.207", "administrator", "123", "");
Server server = getServer();
List<String> itemString = new ArrayList<String>();
itemString.add("RD1.RD1.1005.test");
Map map = read(itemString, server);
System.out.println(map.get("RD1.RD1.1005.test"));
// int[] a = (int[]) map.get("RD1.RD1.1005.test");
// for(int i=0; i<a.length; i++){
// System.out.println(a[i]);
// }
// Server server = ReadUtil.getServer();
// Map<String, Object> itemMap = new HashMap<String, Object>();
// itemMap.put("RD1.RD1.1005.test", "1.2");
}
/**
* 发布订阅测试
*/
private static final int PERIOD = 100;
private static final int SLEEP = 2000;
public static void test() throws AlreadyConnectedException, JIException, UnknownHostException, AddFailedException, NotConnectedException, DuplicateGroupException, InterruptedException {
/*ConnectionInformation ci = new ConnectionInformation();
ci.setHost("10.1.5.123");
ci.setDomain("");
ci.setUser("freud");
ci.setPassword("password");
ci.setClsid("F8582CF2-88FB-11D0-B850-00C0F0104305");
Server server = new Server(ci,
Executors.newSingleThreadScheduledExecutor());*/
Server server = getServer();
// server.connect();
AccessBase access = new Async20Access(server, PERIOD, false);
access.addItem("RD1.RD1.B21.mode", new DataCallback() {
private int count;
@SneakyThrows
public void changed(Item item, ItemState itemstate) {
System.out.println("[" + (++count) + "],ItemName:["
+ item.getId() + "],value:" + itemstate.getValue());
System.out.println(itemstate.getValue().isArray());
List<String> listB = Arrays.asList(itemstate.getValue().toString());
System.out.println(listB.get(0));
}
});
access.bind();
Thread.sleep(SLEEP);
access.unbind();
server.dispose();
}
public static Server getServer(String opc_id) {
//OPC表【acs_opc】
@@ -134,28 +51,6 @@ public class ReadUtil {
return server;
}
public static Server getServer() {
//RD1.RD1.1028
// 连接信息
ConnectionInformation ci = new ConnectionInformation();
ci.setHost("192.168.81.251");
ci.setDomain("");
ci.setUser("administrator");
ci.setPassword("Huawei@123");
ci.setClsid("7BC0CC8E-482C-47CA-ABDC-0FE7F9C6E729");
final Server server = new Server(ci, Executors.newSingleThreadScheduledExecutor());
try {
server.connect();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (JIException e) {
e.printStackTrace();
} catch (AlreadyConnectedException e) {
e.printStackTrace();
}
return server;
}
public static void write(Map<String, Object> strings, Server server) {
try {
//Group group = this.opcServerService.getServer(opcServiceCode);
@@ -198,7 +93,6 @@ public class ReadUtil {
public static Map<String, Object> read(List<String> itemString, Server server) {
HashMap map = new HashMap();
try {
//Group group = this.opcServerService.getServer(opcServiceCode);
Group group = server.addGroup();
Map<String, Item> items = new LinkedHashMap();
Iterator is = itemString.iterator();
@@ -226,6 +120,7 @@ public class ReadUtil {
} catch (Exception e) {
e.printStackTrace();
}
return map;
}

View File

@@ -1,58 +0,0 @@
package org.nl.acs.device.service.impl;
import lombok.Data;
import lombok.SneakyThrows;
import org.nl.acs.instruction.service.dto.InstructionDto;
import org.nl.acs.opc.OpcUtl;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.acs.task.service.impl.TaskServiceImpl;
@Data
public class ConveyorDevice {
String id;
int jobNo = -1;
int lastjobNo = -1;
String palletNo;
InstructionDto inst;
RecvThread rt;
public ConveyorDevice(String id) {
if (id == null) {
throw new NullPointerException("ID is null");
} else {
this.id = id;
}
System.out.println("id:" + id);
rt = new RecvThread();
rt.run();
}
public void adviseData() {
System.out.println("test");
}
private class RecvThread implements Runnable {
@SneakyThrows
@Override
public void run() {
System.out.println("test");
String MODE = "RD1.RD1." + id + ".mode";
String code = OpcUtl.read(MODE);
if ("2".equals(code)) {
TaskService taskserver = new TaskServiceImpl();
TaskDto dto = new TaskDto();
dto.setStart_point_code(id);
dto.setNext_point_code("1002");
taskserver.create(dto);
}
}
}
}

View File

@@ -24,6 +24,7 @@ import org.nl.acs.device_driver.DeviceDriverDefination;
import org.nl.acs.device_driver.ScannerDeviceDriver;
import org.nl.acs.device_driver.basedriver.oven_manipulator.OvenGantryManipulatorDeviceDriver;
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
import org.nl.acs.device_driver.basedriver.siemens_conveyor_ckk.SiemensConveyorCkkDeviceDriver;
import org.nl.acs.device_driver.basedriver.siemens_conveyor_labeling.SiemensConveyorLabelingDeviceDriver;
import org.nl.acs.device_driver.basedriver.slit_two_manipulator.SlitTwoManipulatorDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.StandardCoveyorControlWithScannerDeviceDriver;
@@ -949,6 +950,13 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
} else if (device.getDeviceDriver() instanceof OvenGantryManipulatorDeviceDriver) {
OvenGantryManipulatorDeviceDriver ovenGantryManipulatorDeviceDriver = (OvenGantryManipulatorDeviceDriver) device.getDeviceDriver();
ovenGantryManipulatorDeviceDriver.setDeviceStatus(form);
} else if (device.getDeviceDriver() instanceof SiemensConveyorCkkDeviceDriver) {
SiemensConveyorCkkDeviceDriver siemensConveyorCkkDeviceDriver = (SiemensConveyorCkkDeviceDriver) device.getDeviceDriver();
siemensConveyorCkkDeviceDriver.setDeviceStatus(form);
} else if (device.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver){
StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver
= (StandardCoveyorControlWithScannerDeviceDriver) device.getDeviceDriver();
standardCoveyorControlWithScannerDeviceDriver.setDeviceStatus(form);
}
}

View File

@@ -1,18 +0,0 @@
package org.nl.acs.device.service.impl;
import java.util.ArrayList;
import java.util.List;
public class Test {
public static void main(String[] args) {
String device = "1001,1002";
List list = new ArrayList<>();
list.add("1001");
list.add("1002");
for (int i = 0; i < list.size(); i++) {
ConveyorDevice condev = new ConveyorDevice(list.get(i).toString());
}
}
}

View File

@@ -297,7 +297,7 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
break;
case 6:
//空托盘满垛入库申请
if (move > 0 && !requireEmptyInSuccess) {
if (move > 0 && !requireSucess) {
emptyIn();
}
if (move > 0 && !requireSucess) {
@@ -867,13 +867,13 @@ public class SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver impleme
JSONObject jo = JSON.parseObject(str);
if (ObjectUtil.isEmpty(jo)) {
message = "申请空盘入库接口不通";
requireEmptyInSuccess = true;
requireSucess = true;
} else {
if (jo.getInteger("status") == 200) {
message = "申请空盘入库成功";
requireEmptyInSuccess = true;
requireSucess = true;
} else {
requireEmptyInSuccess = true;
requireSucess = true;
message = "申请空盘入库失败," + jo.get("message").toString();
}
}

View File

@@ -0,0 +1,132 @@
package org.nl.acs.device_driver.basedriver.siemens_conveyor_ckk;
import cn.hutool.core.util.StrUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import java.util.ArrayList;
import java.util.List;
@Slf4j
@Data
public class ItemProtocol {
//心跳
public static String item_heartbeat = "heartbeat";
//工作模式
public static String item_mode = "mode";
//光电信号
public static String item_move = "move";
//托盘方向
public static String item_carrier_direction = "carrier_direction";
//报警
public static String item_error = "error";
//任务号
public static String item_task = "task";
//下发命令
public static String item_to_command = "to_command";
//下发目标站
public static String item_to_target = "to_target";
//下发托盘类型
public static String item_to_container_type = "to_container_type";
//下发任务号
public static String item_to_task = "to_task";
//困扎次数
public static String item_to_strap_times = "to_strap_times";
//木箱长度
public static String item_to_length = "to_length";
//木箱宽度
public static String item_to_weight = "to_weight";
//木箱高度
public static String item_to_height = "to_height";
private SiemensConveyorCkkDeviceDriver driver;
public ItemProtocol(SiemensConveyorCkkDeviceDriver driver) {
this.driver = driver;
}
public int getHeartbeat() {
return this.getOpcIntegerValue(item_heartbeat);
}
public int getMode() {
return this.getOpcIntegerValue(item_mode);
}
public int getMove() {
return this.getOpcIntegerValue(item_move);
}
public int getCarrier_direction() {
return this.getOpcIntegerValue(item_carrier_direction);
}
public int getError() {
return this.getOpcIntegerValue(item_error);
}
public int getTask() {
return this.getOpcIntegerValue(item_task);
}
Boolean isonline;
public int getOpcIntegerValue(String protocol) {
Integer value = this.driver.getIntegeregerValue(protocol);
if (value == null) {
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
setIsonline(false);
} else {
setIsonline(true);
return value;
}
return 0;
}
public String getOpcStringValue(String protocol) {
String value = this.driver.getStringValue(protocol);
if (StrUtil.isEmpty(value)) {
} else {
return value;
}
return "0";
}
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_heartbeat, "心跳", "DB600.B0"));
list.add(new ItemDto(item_mode, "工作模式", "DB600.B2"));
list.add(new ItemDto(item_move, "光电信号", "DB600.B3"));
list.add(new ItemDto(item_carrier_direction, "托盘方向", "DB600.B4"));
list.add(new ItemDto(item_error, "报警信号", "DB600.B6"));
list.add(new ItemDto(item_task, "任务号", "DB600.D10"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "下发命令", "DB601.W2"));
list.add(new ItemDto(item_to_target, "下发目标站", "DB601.W4"));
list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB601.W6"));
list.add(new ItemDto(item_to_task, "下发任务号", "DB601.D8"));
list.add(new ItemDto(item_to_strap_times, "困扎次数", "DB601.W12"));
list.add(new ItemDto(item_to_length, "木箱长度", "DB601.W14"));
list.add(new ItemDto(item_to_weight, "木箱宽度", "DB601.W16"));
list.add(new ItemDto(item_to_height, "木箱高度", "DB601.W18"));
return list;
}
@Override
public String toString() {
return "";
}
}

View File

@@ -0,0 +1,64 @@
package org.nl.acs.device_driver.basedriver.siemens_conveyor_ckk;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceType;
import org.springframework.stereotype.Service;
import java.util.LinkedList;
import java.util.List;
/**
* 西门子-输送机驱动
*
*/
@Service
public class SiemensConveyorCkkDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "siemens_conveyor_ckk";
}
@Override
public String getDriverName() {
return "西门子-输送机驱动-出库口";
}
@Override
public String getDriverDescription() {
return "西门子-输送机驱动-出库口";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new SiemensConveyorCkkDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return SiemensConveyorCkkDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.station);
return types;
}
@Override
public List<ItemDto> getReadableItemDtos() {
return ItemProtocol.getReadableItemDtos();
}
@Override
public List<ItemDto> getWriteableItemDtos() {
return ItemProtocol.getWriteableItemDtos();
}
}

View File

@@ -0,0 +1,912 @@
package org.nl.acs.device_driver.basedriver.siemens_conveyor_ckk;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.nl.acs.AcsConfig;
import org.nl.acs.agv.server.NDCAgvService;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingRequest;
import org.nl.acs.ext.wms.data.ApplyLabelingAndBindingResponse;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.route.service.dto.RouteLineDto;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.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;
import java.util.*;
/**
* 西门子-输送机驱动-出库口
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class SiemensConveyorCkkDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
@Autowired
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
@Autowired
DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class);
@Autowired
RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class);
@Autowired
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
@Autowired
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
@Autowired
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
@Autowired
ParamService paramService = SpringContextHolder.getBean(ParamService.class);
@Autowired
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class);
@Autowired
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
@Autowired
NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class);
//当前指令
Instruction inst = null;
//工作模式
int mode = 0;
int last_mode = 0;
//光电信号
int move = 0;
int last_move = 0;
//托盘方向
int carrier_direction = 0;
int last_carrier_direction = 0;
//报警信号
int error = 0;
int last_error = 0;
//任务号
int task = 0;
int last_task = 0;
int agvphase = 0;
String task_code = null;
int phase = 0;
int index = 0;
Boolean isonline = true;
int hasGoods = 0;
String message = null;
Boolean iserror = false;
Integer heartbeat_tag;
private Date instruction_require_time = new Date();
private Date require_apply_labeling_time = new Date();
private Date require_apply_strangulation_time = new Date();
private Date require_empty_in_time = new Date();
private Date require_empty_out_time = new Date();
private int instruction_require_time_out = 3000;
//行架机械手申请任务成功标识
boolean requireSucess = false;
boolean requireApplyLabelingSuccess = false;
boolean requireApplyLaStrangulationSuccess = false;
boolean requireEmptyInSuccess = false;
boolean requireEmptyOutSuccess = false;
boolean requiresShipDeviceUpdate = true;
private int instruction_finished_time_out;
int branchProtocol = 0;
String inst_message;
String last_inst_message;
//当前指令
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
int flag;
String device_code;
String vehicle_code;
String last_vehicle_code;
@Override
public Device getDevice() {
return this.device;
}
@Override
public void execute() {
try {
device_code = this.getDeviceCode();
mode = this.itemProtocol.getMode();
move = this.itemProtocol.getMove();
carrier_direction = this.itemProtocol.getCarrier_direction();
error = this.itemProtocol.getError();
task = this.itemProtocol.getTask();
if (mode != last_mode) {
if (mode == 2) {
requireSucess = false;
requireApplyLabelingSuccess = false;
requireApplyLaStrangulationSuccess = false;
requireEmptyInSuccess = false;
requireEmptyOutSuccess = false;
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode + "复位请求标记");
}
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode);
}
if (move != last_move) {
message = null;
if (move == 0 ) {
inst_message = null;
requireSucess = false;
this.clearWrite();
}
logServer.deviceItemValue(this.device_code, "move", String.valueOf(move));
logServer.deviceExecuteLog(this.device_code, "", "", "信号move" + last_move + "->" + move);
}
if (carrier_direction != last_carrier_direction) {
logServer.deviceItemValue(this.device_code, "carrier_direction", String.valueOf(carrier_direction));
logServer.deviceExecuteLog(this.device_code, "", "", "信号carrier_direction" + last_carrier_direction + "->" + carrier_direction);
}
if (error != last_error) {
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
logServer.deviceExecuteLog(this.device_code, "", "", "信号error" + last_error + "->" + error);
}
if (task != last_task) {
logServer.deviceItemValue(this.device_code, "task", String.valueOf(task));
logServer.deviceExecuteLog(this.device_code, "", "", "信号task" + last_task + "->" + task);
}
if (move != 0 && task > 0) {
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();
vehicle_code = inst.getVehicle_code();
task_code = inst.getTask_code();
if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) {
inst.setInstruction_status("1");
inst.setExecute_device_code(this.device_code);
instructionService.update(inst);
logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task);
}
if (StrUtil.equals(inst.getInstruction_status(), "1")) {
if (!StrUtil.equals(inst.getExecute_code(), this.device_code)) {
inst.setExecute_device_code(this.device_code);
instructionService.update(inst);
}
}
} else {
// logServer.deviceExecuteLog(device_code, "", "", "输送线任务开始反馈任务状态,反馈失败,查询不到指令号:" + task);
message = "输送线任务反馈状态,查询不到指令号:" + task +"指令已完成";
inst_message = null;
}
}
} catch (Exception var17) {
inst_message = var17.getMessage();
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "读取信号值时出现异常:" + var17.getMessage());
}
// 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);
Instruction instruction = null;
List toInstructions;
switch (mode) {
case 1:
log.debug("设备运转模式:等待工作");
break;
case 2:
//申请任务
if (move > 0 && !requireSucess) {
try {
instruction_require();
} catch (Exception e) {
e.printStackTrace();
}
}
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
break;
}
}
last_mode = mode;
last_move = move;
last_carrier_direction = carrier_direction;
last_error = error;
last_task = task;
}
private void shipDeviceUpdate() {
JSONObject param = new JSONObject() {{
put("device_code", device_code);
}};
HttpResponse response = acsToWmsService.shipDeviceUpdate(param);
if (response == null || response.getStatus() == 200) {
this.requiresShipDeviceUpdate = true;
}
}
public boolean exe_error() {
if (this.error == 0) {
return true;
} else {
log.debug("设备报警");
return false;
}
}
public void clearWrite() {
List list = new ArrayList();
Map map = new HashMap();
map.put("code", "to_target");
map.put("value", "0");
list.add(map);
Map map2 = new HashMap();
map2.put("code", "to_task");
map2.put("value", "0");
list.add(map2);
Map map3 = new HashMap();
map3.put("code", "to_command");
map3.put("value", "0");
list.add(map3);
Map map4 = new HashMap();
map4.put("code", "to_strap_times");
map4.put("value", "0");
list.add(map4);
Map map5 = new HashMap();
map5.put("code", "to_length");
map5.put("value", "0");
list.add(map5);
Map map6 = new HashMap();
map6.put("code", "to_weight");
map6.put("value", "0");
list.add(map6);
Map map7 = new HashMap();
map7.put("code", "to_height");
map7.put("value", "0");
list.add(map7);
this.writing(list);
message = null;
vehicle_code = null;
}
public boolean exe_business() {
return true;
}
public synchronized boolean finish_instruction() throws Exception {
instructionService.finish(inst);
// requireSucess = false;
return true;
}
protected void thingToNothing() throws Exception {
requireSucess = 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()
+ "." + param;
//String opcservcerid = this.getDevice().getOpc_server_id();
//Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_param, Integer.parseInt(value));
// itemMap.put(to_param, Integer.parseInt(value));
this.control(itemMap);
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value);
}
public void executing(Server server, Map<String, Object> itemMap) {
this.control(itemMap);
}
public void writing(int command) {
//String opcservcerid = this.getDevice().getOpc_server_id();
//Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
this.control(itemMap);
}
@Override
public JSONObject getDeviceStatusName() {
JSONObject jo = new JSONObject();
String mode = "";
String move = "";
String carrier_direction = "";
if (this.getMode() == 0) {
mode = "脱机";
} else if (this.getMode() == 1) {
mode = "单机";
} else if (this.getMode() == 2) {
mode = "待机";
} else if (this.getMode() == 3) {
mode = "运行中";
} else if (this.getMode() == 4) {
mode = "申请捆扎中";
} else if (this.getMode() == 5) {
mode = "申请贴标中";
} else if (this.getMode() == 6) {
mode = "申请空盘入库中";
} else if (this.getMode() == 7) {
mode = "申请空盘出库中";
} else if (this.getMode() == 8) {
mode = "申请AGV任务中";
}
if (this.getMove() == 0) {
move = "无货";
jo.put("hasGoods", false);
} else if (this.getMove() == 1) {
move = "有货";
jo.put("hasGoods", true);
} else if (this.getMove() == 2) {
move = "有托盘有货";
jo.put("hasGoods", true);
}
if (this.carrier_direction == 1) {
carrier_direction = "正转";
} else if (this.carrier_direction == 2) {
carrier_direction = "反转";
}
String requireSucess = "0";
if (this.requireSucess) {
requireSucess = "1";
}
jo.put("device_name", this.getDevice().getDevice_name());
jo.put("mode", mode);
jo.put("move", move);
jo.put("carrier_direction", carrier_direction);
jo.put("task", task);
jo.put("last_task", last_task);
jo.put("task_code", task_code);
// jo.put("barcode", barcode);
// jo.put("last_task", last_task);
jo.put("inst_message", this.inst_message);
jo.put("last_inst_message", this.last_inst_message);
jo.put("isOnline", this.getIsonline());
jo.put("error", this.getError());
jo.put("isError", this.getIserror());
jo.put("message", this.getMessage());
jo.put("is_click", true);
jo.put("requireSucess", requireSucess);
jo.put("driver_type", "siemens_conveyor");
return jo;
}
@Override
public void setDeviceStatus(JSONObject data) {
String requestSucess = data.getString("requireSucess");
if (StrUtil.equals(requestSucess, "0")) {
this.requireSucess = false;
} else if (StrUtil.equals(requestSucess, "1")) {
this.requireSucess = true;
}
}
public void writing(List list) {
// String opcservcerid = this.getDevice().getOpc_server_id();
// Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
for (int i = 0; i < list.size(); i++) {
Object ob = list.get(i);
JSONObject json = (JSONObject) JSONObject.toJSON(ob);
if (!StrUtil.isEmpty(json.getString("value"))) {
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + json.getString("code");
itemMap.put(to_param, json.getString("value"));
}
}
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号:" + itemMap);
this.control(itemMap);
}
/**
* 请求指令
*/
public synchronized boolean instruction_require() {
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;
if (task > 0) {
Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task));
if (ObjectUtil.isEmpty(instruction)) {
instruction = instructionService.findByCode(String.valueOf(task));
}
if(StrUtil.equals(instruction.getInstruction_status(),"1")){
if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) {
vehicle_code = inst.getVehicle_code();
inst.setExecute_device_code(this.device_code);
try {
finish_instruction();
} catch (Exception e) {
e.printStackTrace();
}
logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task);
}
}
} else {
logServer.deviceExecuteLog(device_code, "", "", "申请输送任务电气设备任务号:" + task + "异常");
message = "申请输送任务电气设备任务号:" + task + "异常";
return false;
}
//判断是否存在起点相同 任务状态就绪的任务
TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code);
if (!ObjectUtil.isEmpty(taskdto)) {
// if (!ObjectUtils.isEmpty(instructionService.findByBarcodeFromCache(container_code))) {
// return false;
// }
//需要判断当前设备是否已经存在就绪的指令 如果存在就直接下发 不存在则创建
Instruction inst = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code());
if (ObjectUtil.isNotEmpty(inst)) {
List list = new ArrayList();
Map map = new HashMap();
if (StrUtil.isNotEmpty(taskdto.getTo_z())) {
if (StrUtil.equals(taskdto.getTo_z(), "01")) {
map.put("code", "to_target");
map.put("value", "102");
} else if (StrUtil.equals(taskdto.getTo_z(), "02")) {
map.put("code", "to_target");
map.put("value", "201");
} else if (StrUtil.equals(taskdto.getTo_z(), "03")) {
map.put("code", "to_target");
map.put("value", "301");
}
}
list.add(map);
Map map2 = new HashMap();
map2.put("code", "to_task");
map2.put("value", inst.getInstruction_code());
list.add(map2);
Map map3 = new HashMap();
map3.put("code", "to_command");
map3.put("value", "1");
list.add(map3);
this.writing(list);
if (task != Integer.parseInt(inst.getInstruction_code())) {
this.writing(list);
message = "重新下发电气信号";
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
}
message = "下发电气任务号成功";
requireSucess = true;
return true;
}
// type 5 输送任务
if (!StrUtil.equals(taskdto.getTask_type(), "5")) {
return false;
}
String taskid = taskdto.getTask_id();
String taskcode = taskdto.getTask_code();
String vehiclecode = taskdto.getVehicle_code();
String priority = taskdto.getPriority();
String start_point_code = taskdto.getStart_point_code();
String start_device_code = taskdto.getStart_device_code();
String route_plan_code = taskdto.getRoute_plan_code();
String next_device_code = "";
/**
* 开始平均分配
*/
String this_coevice_code = taskserver.queryAssignedByDevice(device_code, taskdto.getNext_device_code());
if (StrUtil.isEmpty(this_coevice_code)) {
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, taskdto.getNext_device_code(), route_plan_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);
} 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 = taskdto.getTo_x() + "-" + taskdto.getTo_y() + "-" + taskdto.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(taskdto.getRemark());
instdto.setMaterial(taskdto.getMaterial());
instdto.setQuantity(taskdto.getQuantity());
instdto.setTask_id(taskid);
instdto.setTask_code(taskcode);
instdto.setVehicle_code(vehiclecode);
String now = DateUtil.now();
instdto.setCreate_time(now);
instdto.setCreate_by("auto");
instdto.setStart_device_code(start_device_code);
instdto.setNext_device_code(next_device_code);
instdto.setStart_point_code(start_point_code);
instdto.setNext_point_code(next_point_code);
instdto.setPriority(priority);
instdto.setInstruction_status("0");
instdto.setExecute_device_code(start_point_code);
try {
instructionService.create(instdto);
} catch (Exception e) {
e.printStackTrace();
log.error("指令创建失败!",e.getMessage());
return false;
}
//创建指令后修改任务状态
taskdto.setTask_status("1");
taskserver.update(taskdto);
requireSucess = true;
String next_addr = nextdevice.getExtraValue().get("address").toString();
List list = new ArrayList();
Map map = new HashMap();
map.put("code", "to_target");
map.put("value", next_addr);
list.add(map);
Map map2 = new HashMap();
map2.put("code", "to_task");
map2.put("value", instdto.getInstruction_code());
list.add(map2);
Map map3 = new HashMap();
map3.put("code", "to_command");
map3.put("value", "1");
list.add(map3);
this.writing(list);
if (task != Integer.parseInt(inst.getInstruction_code())) {
this.writing(list);
message = "重新下发电气信号";
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
}
} else {
//如果不存在则直接找对应指令
Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code);
if (ObjectUtil.isEmpty(inst)) {
return false;
}
Device nextdevice = deviceAppservice.findDeviceByCode(inst.getNext_device_code());
String next_addr = nextdevice.getExtraValue().get("address").toString();
List list = new ArrayList();
Map map = new HashMap();
map.put("code", "to_target");
map.put("value", next_addr);
list.add(map);
Map map2 = new HashMap();
map2.put("code", "to_task");
map2.put("value", inst.getInstruction_code());
list.add(map2);
Map map3 = new HashMap();
map3.put("code", "to_command");
map3.put("value", "1");
list.add(map3);
this.writing(list);
if (task != Integer.parseInt(inst.getInstruction_code())) {
this.writing(list);
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
}
requireSucess = true;
}
return true;
}
}
//申请贴标
public synchronized void applyLabeling() {
Date date = new Date();
if (date.getTime() - this.require_apply_labeling_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return;
} else {
this.require_apply_labeling_time = date;
String vehicle_code = "";
if (task > 0) {
Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task));
vehicle_code = instruction.getVehicle_code();
} else {
logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备任务号:" + task + "异常");
message = "申请贴标电气设备任务号:" + task + "异常";
throw new RuntimeException("任务号为空!");
}
if (StrUtil.isEmpty(vehicle_code)) {
logServer.deviceExecuteLog(device_code, "", "", "申请贴标电气设备任务号:" + task + "未找到载具号");
message = "申请贴标电气设备任务号:" + task + "未找到载具号";
throw new RuntimeException("载具号为空!");
}
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("1");
applyLabelingAndBindingRequest.setVehicle_code(vehicle_code);
ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
if (applyLabelingAndBindingResponse.getstatus() == 200) {
message = "申请贴标成功";
List list = new ArrayList();
Map map = new HashMap();
map.put("code", "to_command");
map.put("value", "5");
list.add(map);
this.writing(list);
this.writing(list);
message = "申请贴标下发电气信号成功";
requireApplyLabelingSuccess = true;
} else {
message = "申请贴标失败," + applyLabelingAndBindingResponse.getMessage();
}
}
}
//申请捆扎
@SneakyThrows
public synchronized void applyLaStrangulation() {
Date date = new Date();
if (date.getTime() - this.require_apply_strangulation_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return;
} else {
this.require_apply_strangulation_time = date;
String vehicle_code = "";
if (task > 0) {
Instruction instruction = instructionService.findByCodeFromCache(String.valueOf(task));
if(ObjectUtil.isEmpty(instruction)){
message = "申请捆扎电气设备任务号:" + task + "未找到对应指令";
throw new RuntimeException("该电气任务号未找到对应指令!");
}
vehicle_code = instruction.getVehicle_code();
} else {
logServer.deviceExecuteLog(device_code, "", "", "申请捆扎电气设备任务号:" + task + "异常");
message = "申请捆扎电气设备任务号:" + task + "异常";
throw new RuntimeException("任务号为空!");
}
if (StrUtil.isEmpty(vehicle_code)) {
logServer.deviceExecuteLog(device_code, "", "", "申请捆扎电气设备任务号:" + task + "未找到载具号");
message = "申请捆扎电气设备任务号:" + task + "未找到载具号";
throw new RuntimeException("载具号为空!");
}
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("2");
applyLabelingAndBindingRequest.setVehicle_code(vehicle_code);
ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
if (applyLabelingAndBindingResponse.getstatus() == 200) {
if (ObjectUtil.isNotEmpty(applyLabelingAndBindingResponse.getData())) {
Map datas = applyLabelingAndBindingResponse.getData();
String length = datas.get("box_length").toString();
String width = datas.get("box_width").toString();
String box_high = datas.get("box_high").toString();
String bundle_times = datas.get("bundle_times").toString();
List list = new ArrayList();
Map map = new HashMap();
map.put("code", "to_length");
map.put("value", length);
list.add(map);
Map map2 = new HashMap();
map2.put("code", "to_weight");
map2.put("value", width);
list.add(map2);
Map map3 = new HashMap();
map3.put("code", "to_height");
map3.put("value", box_high);
list.add(map3);
Map map4 = new HashMap();
map4.put("code", "to_strap_times");
map4.put("value", bundle_times);
list.add(map4);
Map map5 = new HashMap();
map5.put("code", "to_command");
map5.put("value", "4");
list.add(map5);
this.writing(list);
// this.writing(list);
message = "申请捆扎成功";
requireSucess = true;
} else {
message = "未返回尺寸信息";
}
} else {
message = applyLabelingAndBindingResponse.getMessage();
}
}
}
public synchronized void emptyIn() {
Date date = new Date();
if (date.getTime() - this.require_empty_in_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return;
} else {
this.require_empty_in_time = date;
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
message = "申请空盘入库任务中...";
JSONObject apply = new JSONObject();
apply.put("device_code", device_code);
apply.put("type", "2");
String str = acsToWmsService.applyTaskToWms(apply);
JSONObject jo = JSON.parseObject(str);
if (ObjectUtil.isEmpty(jo)) {
message = "申请空盘入库接口不通";
requireEmptyInSuccess = true;
} else {
if (jo.getInteger("status") == 200) {
message = "申请空盘入库成功";
requireEmptyInSuccess = true;
} else {
requireEmptyInSuccess = true;
message = "申请空盘入库失败," + jo.get("message").toString();
}
}
}
}
}
public synchronized void applyAgvTask() {
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;
} else {
this.instruction_require_time = date;
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
Instruction instruction = instructionService.findByCode(String.valueOf(task));
if(ObjectUtil.isEmpty(instruction)){
message = "指令号"+task+"未找到对应指令";
return;
}
message = "申请AGV搬运任务中...";
JSONObject apply = new JSONObject();
apply.put("device_code", device_code);
apply.put("type", "4");
apply.put("vehicle_code", instruction.getVehicle_code());
String str = acsToWmsService.applyTaskToWms(apply);
JSONObject jo = JSON.parseObject(str);
if (ObjectUtil.isEmpty(jo)) {
message = "申请AGV搬运任务接口不通";
requireSucess = true;
} else {
if (jo.getInteger("status") == 200) {
message = "申请AGV搬运任务成功";
requireSucess = true;
} else {
requireSucess = true;
message = "申请AGV搬运任务失败," + jo.get("message").toString();
}
}
}
}
}
public synchronized void emptyOut() {
Date date = new Date();
if (date.getTime() - this.require_empty_out_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return;
} else {
this.require_empty_out_time = date;
if (StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), "1")) {
message = "申请空盘出库任务中...";
JSONObject apply = new JSONObject();
apply.put("device_code", device_code);
apply.put("type", "3");
String str = acsToWmsService.applyTaskToWms(apply);
JSONObject jo = JSON.parseObject(str);
if (ObjectUtil.isEmpty(jo)) {
message = "申请空盘出库接口不通";
requireSucess = true;
} else {
if (jo.getInteger("status") == 200) {
message = "申请空盘出库成功";
requireSucess = true;
} else {
requireSucess = true;
message = "申请空盘出库失败," + jo.get("message").toString();
}
}
}
}
}
}

View File

@@ -1470,6 +1470,12 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
is_disable = "禁用";
}
String requireSucess = "0";
if (this.requireSucess) {
requireSucess = "1";
}
jo.put("requireSucess", requireSucess);
jo.put("device_name", this.getDevice().getDevice_name());
jo.put("mode", mode);
jo.put("status", status);
@@ -1540,5 +1546,11 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
if (StrUtil.isNotEmpty(is_disable)) {
this.setIs_disable(Integer.parseInt(is_disable));
}
String requestSucess = data.getString("requireSucess");
if (StrUtil.equals(requestSucess, "0")) {
this.requireSucess = false;
} else if (StrUtil.equals(requestSucess, "1")) {
this.requireSucess = true;
}
}
}

View File

@@ -828,6 +828,7 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
jo.put("mode", mode);
jo.put("move", move);
jo.put("action", action);
jo.put("is_click", true);
jo.put("isOnline", this.getIsonline());
jo.put("error", this.getError());
jo.put("isError", this.getIserror());
@@ -852,7 +853,19 @@ public class StandardCoveyorControlWithScannerDeviceDriver extends AbstractOpcDe
@Override
public void setDeviceStatus(JSONObject data) {
String requestSucess = data.getString("requireSucess");
System.out.println(requestSucess);
if (StrUtil.equals(requestSucess, "0")) {
this.requireSucess = false;
} else if (StrUtil.equals(requestSucess, "1")) {
this.requireSucess = true;
}
String applySucess = data.getString("applySucess");
if (StrUtil.equals(applySucess, "0")) {
this.applySucess = false;
} else if (StrUtil.equals(applySucess, "1")) {
this.applySucess = true;
}
}
}

View File

@@ -118,8 +118,8 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService {
inst.setCarno(carNo);
instructionService.update(inst);
} else if(StrUtil.equals(status,"3")){
inst.setInstruction_status("2");
instructionService.finish(inst.getInstruction_id());
// inst.setInstruction_status("1");
// instructionService.finish(inst.getInstruction_id());
} else if(StrUtil.equals(status,"4")){
//5 取消指令

View File

@@ -1,4 +1,6 @@
package org.nl.acs.instruction.common;
public class InstructStatusEnum {
}

View File

@@ -789,7 +789,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
deviceService.changeDeviceStatus(jo1);
removeByCodeFromCache(dto.getInstruction_code());
this.reload();
// this.reload();
}
}
@@ -1089,12 +1089,14 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override
public Instruction findByLinkNumSend(String code) {
for (int i = 0; i < this.instructions.size(); i++) {
Instruction inst = instructions.get(i);
Iterator<Instruction> it = instructions.iterator();
while (it.hasNext()){
Instruction inst = it.next();
if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "1")) {
return inst;
}
}
return null;
}
@@ -1102,8 +1104,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override
public List<Instruction> findByLinkNum(String code) {
List<Instruction> list = new ArrayList<>();
for (int i = 0; i < this.instructions.size(); i++) {
Instruction inst = instructions.get(i);
Iterator<Instruction> it = instructions.iterator();
while (it.hasNext()){
Instruction inst = it.next();
if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "0")) {
list.add(inst);
}
@@ -1113,19 +1116,22 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override
public Instruction findByLinkNumNoSend(String code) {
for (int i = 0; i < this.instructions.size(); i++) {
Instruction inst = instructions.get(i);
Iterator<Instruction> it = instructions.iterator();
while (it.hasNext()){
Instruction inst = it.next();
if (StrUtil.equals(code, inst.getLink_num()) && StrUtil.equals(inst.getIs_send(), "0")) {
return inst;
}
}
return null;
}
@Override
public Instruction findByCodeFromCache(String code) {
for (int i = 0; i < this.instructions.size(); i++) {
Instruction inst = instructions.get(i);
Iterator<Instruction> it = instructions.iterator();
while (it.hasNext()){
Instruction inst = it.next();
if (StrUtil.equals(code, inst.getInstruction_code())) {
return inst;
}
@@ -1136,8 +1142,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override
public Instruction findByBarcodeFromCache(String barcode) {
for (int i = 0; i < this.instructions.size(); i++) {
Instruction inst = instructions.get(i);
Iterator<Instruction> it = instructions.iterator();
while (it.hasNext()){
Instruction inst = it.next();
if (StrUtil.equals(barcode, inst.getVehicle_code())) {
return inst;
}
@@ -1147,9 +1154,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override
public Instruction findByIdFromCache(String id) {
for (int i = 0; i < this.instructions.size(); i++) {
Instruction inst = instructions.get(i);
Iterator<Instruction> it = instructions.iterator();
while (it.hasNext()){
Instruction inst = it.next();
if (StrUtil.equals(id, inst.getInstruction_id())) {
return inst;
}
@@ -1220,18 +1227,28 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
public Instruction findByDeviceCodeFromCache(String devicecode) {
List<Instruction> instructionList = instructions;
ListUtil.sort(instructionList, new Comparator<Instruction>() {
try {
ListUtil.sort(
instructionList,
new Comparator<Instruction>() {
@Override
public int compare(Instruction o1, Instruction o2) {
return o1.getCreate_time().compareTo(o2.getCreate_time());
}
});
for (int i = 0; i < instructionList.size(); i++) {
Instruction inst = instructionList.get(i);
if (StrUtil.equals(devicecode, inst.getStart_device_code()) && inst.getInstruction_status().equals("0")) {
Iterator<Instruction> it = instructions.iterator();
while (it.hasNext()) {
Instruction inst = it.next();
if (StrUtil.equals(devicecode, inst.getStart_device_code())
&& inst.getInstruction_status().equals("0")) {
return inst;
}
}
} catch (Exception e) {
log.warn("指令排序按照创建时间执执行失败!重新执行");
//失败之后重新查找指令
return findByDeviceCodeFromCache(devicecode);
}
return null;
}
@@ -1244,8 +1261,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override
public Integer querySameDestinationInst(String devicecode) {
int num = 0;
for (int i = 0; i < this.instructions.size(); i++) {
Instruction inst = instructions.get(i);
Iterator<Instruction> it = instructions.iterator();
while (it.hasNext()){
Instruction inst = it.next();
//处理空盘位站点
String next_code = inst.getNext_point_code();
if (next_code.indexOf(".") != -1) {
@@ -1255,14 +1273,16 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
num = num + 1;
}
}
return num;
}
@Override
public Integer querySameInstType(String inst_type) {
int num = 0;
for (int i = 0; i < this.instructions.size(); i++) {
Instruction inst = instructions.get(i);
Iterator<Instruction> it = instructions.iterator();
while (it.hasNext()){
Instruction inst = it.next();
if (StrUtil.equals(inst.getInstruction_type(), inst_type)) {
num = num + 1;
}
@@ -1273,8 +1293,9 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override
public Integer querySameOriginInst(String devicecode) {
int num = 0;
for (int i = 0; i < this.instructions.size(); i++) {
Instruction inst = instructions.get(i);
Iterator<Instruction> it = instructions.iterator();
while (it.hasNext()){
Instruction inst = it.next();
//处理空盘位站点
String start_code = inst.getStart_point_code();
if (start_code.indexOf(".") != -1) {

View File

@@ -21,6 +21,8 @@ public class DeviceOpcProtocolRunable implements Runnable {
String message;
private Server server;
Group group;
public DeviceOpcProtocolRunable() {
this.error_num = 0;
this.message = null;
@@ -62,13 +64,15 @@ public class DeviceOpcProtocolRunable implements Runnable {
public void run() {
while (true) {
try {
server = OpcServerUtl.getServerWithOutException(
server =
OpcServerUtl.getServerWithOutException(
this.OpcServer.getOpc_host(),
this.OpcServer.getCls_id(),
this.OpcServer.getUser(),
this.OpcServer.getPassword(),
this.OpcServer.getDomain());
Group group = server.addGroup();
group = server.addGroup();
List<String> itemsString = new ArrayList();
Iterator it = this.protocols.iterator();
@@ -121,6 +125,8 @@ public class DeviceOpcProtocolRunable implements Runnable {
long begin = System.currentTimeMillis();
Map<Item, ItemState> itemStatus =
group.read(true, (Item[]) itemsMap.values().toArray(new Item[0]));
//TODO 读完释放server可行否?
long end = System.currentTimeMillis();
log.trace("{} 开始记时{}", tag, DateUtil.now());
long duration = end - begin;
@@ -135,12 +141,13 @@ public class DeviceOpcProtocolRunable implements Runnable {
time_out = false;
}
// A1_HK_04.A1_HK_04.A1_HK_04_3.door 列表
Set<Item> items = itemStatus.keySet();
Iterator var18 = items.iterator();
while (true) {
// System.out.println("label98");
Item item;
// A1_HK_04.A1_HK_04.A1_HK_04_3.door
// 当前值
Object value;
// 旧的值
@@ -155,6 +162,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
this.error_num = 0;
this.message = null;
}
// 所有信号读完并且没有变化的值
continue label97;
}
@@ -183,7 +191,6 @@ public class DeviceOpcProtocolRunable implements Runnable {
log.info("信号{}变更从{}->{};信号快照:{}", new Object[] {item.getId(), his, value, sb});
}
System.out.println("设置值:【"+item.getId()+"】-->"+value);
// 设置值
accessor_value.setValue(item.getId(), value);
}
@@ -197,6 +204,15 @@ public class DeviceOpcProtocolRunable implements Runnable {
this.server = null;
}
if (group != null) {
try {
group.clear();
group.remove();
} catch (Exception var6) {
}
this.group = null;
}
String error_message = "设备信息同步异常";
if (!StrUtil.equals(this.message, error_message)) {
log.warn("", var30);
@@ -215,5 +231,4 @@ public class DeviceOpcProtocolRunable implements Runnable {
}
}
}
}

View File

@@ -268,31 +268,6 @@ public class OpcUtl {
return value;
}
public static String read(String item) throws Exception {
System.out.println(item);
Server server = getServer("192.168.81.251", "7bc0cc8e-482c-47ca-abdc-0fe7f9c6e729", "administrator", "Huawei@123", "");
// String byteItemString = "RD1.RD1.1001.mode";
Group group = server.addGroup();
Item byteItem = group.addItem(item);
ItemState itemState = null;
JIVariant value = null;
itemState = byteItem.read(true);
value = itemState.getValue();
String data = OpcUtl.getValue(byteItem, itemState) + "";
return data;
}
public static void main(String[] args) throws Exception {
Server server = getServer("192.168.81.251", "7bc0cc8e-482c-47ca-abdc-0fe7f9c6e729", "administrator", "Huawei@123", "");
String byteItemString = "RD1.RD1.1001.mode";
Group group = server.addGroup();
Item byteItem = group.addItem(byteItemString);
ItemState itemState = null;
JIVariant value = null;
System.out.println(byteItem.getId());
itemState = byteItem.read(true);
System.out.println(itemState.getQuality());
System.out.println(getValue(byteItem, itemState));
}
}

View File

@@ -1,7 +1,5 @@
package org.nl.acs.task.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
@@ -61,33 +59,23 @@ import java.util.stream.Collectors;
* @author ldjun
* @description 服务实现
* @date 2021-03-18
**/
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
List<TaskDto> tasks = new ArrayList();
@Autowired
DeviceAppService deviceAppService;
@Autowired
RouteLineService routelineserver;
@Autowired
AcsToWmsService acstowmsService;
@Autowired
TaskFeedbackService taskFeedbackService;
@Autowired
ParamService paramService;
@Autowired
XianGongAgvService agvService;
@Autowired
RouteLineService routeLineService;
@Autowired
DeviceAssignedService deviceAssignedService;
@Autowired
InstructionService instructionService;
@Autowired
StorageCellService storageCellService;
@Autowired DeviceAppService deviceAppService;
@Autowired RouteLineService routelineserver;
@Autowired AcsToWmsService acstowmsService;
@Autowired TaskFeedbackService taskFeedbackService;
@Autowired ParamService paramService;
@Autowired XianGongAgvService agvService;
@Autowired RouteLineService routeLineService;
@Autowired DeviceAssignedService deviceAssignedService;
@Autowired InstructionService instructionService;
@Autowired StorageCellService storageCellService;
@Override
public void autoInitial() throws Exception {
@@ -110,7 +98,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
// WQLObject wo = WQLObject.getWQLObject("acs_task");
//ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "task_status < 2 ", "update_time desc");
// ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "task_status < 2 ", "update_time
// desc");
HashMap<String, String> map = new HashMap<>();
map.put("flag", "1");
String task_code = (String) whereJson.get("task_code");
@@ -137,7 +126,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
if (!StrUtil.isEmpty(is_over)) {
map.put("is_over", is_over);
}
final JSONObject jo = WQL.getWO("QTASK_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "");
final JSONObject jo =
WQL.getWO("QTASK_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "");
return jo;
}
@@ -152,8 +142,10 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
String is_over = (String) whereJson.get("is_over");
String task_type = (String) whereJson.get("task_type");
List<TaskDto> taskList = new ArrayList();
for (int i = 0; i < tasks.size(); i++) {
TaskDto task = tasks.get(i);
Iterator<TaskDto> it = tasks.iterator();
while (it.hasNext()) {
TaskDto task = it.next();
if ("1".equals(is_over) && Integer.valueOf(task.getTask_status()) < 2) {
continue;
}
@@ -172,7 +164,9 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
if (!ObjectUtil.isEmpty(material_type) && !task.getMaterial().equals(material_type)) {
continue;
}
if (!ObjectUtil.isEmpty(point_code) && !(task.getStart_point_code().contains(point_code) || task.getNext_point_code().contains(point_code))) {
if (!ObjectUtil.isEmpty(point_code)
&& !(task.getStart_point_code().contains(point_code)
|| task.getNext_point_code().contains(point_code))) {
continue;
}
if (!ObjectUtil.isEmpty(task_type) && !task.getTask_type().equals(task_type)) {
@@ -182,14 +176,22 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
}
// 按照创建时间排序
taskList = taskList
.stream()
.sorted((task1, task2) -> DateUtil.compare(DateUtil.parseDate(task1.getCreate_time()), DateUtil.parse(task2.getCreate_time())))
taskList =
taskList.stream()
.sorted(
(task1, task2) ->
DateUtil.compare(
DateUtil.parseDate(task1.getCreate_time()),
DateUtil.parse(task2.getCreate_time())))
.collect(Collectors.toList());
Integer currentPageNumber = page.getPageNumber() + 1;
Integer pageMaxSize = page.getPageSize();
List<TaskDto> taskDtoList = taskList.stream().skip((currentPageNumber - 1) * pageMaxSize).limit(pageMaxSize).collect(Collectors.toList());
List<TaskDto> taskDtoList =
taskList.stream()
.skip((currentPageNumber - 1) * pageMaxSize)
.limit(pageMaxSize)
.collect(Collectors.toList());
JSONObject jo = new JSONObject();
jo.put("content", taskDtoList);
jo.put("totalElements", taskList.size());
@@ -199,7 +201,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
@Override
public Map<String, Object> getAll(Map whereJson, Pageable page) {
// WQLObject wo = WQLObject.getWQLObject("acs_task");
//ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "task_status < 2 ", "update_time desc");
// ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "task_status < 2 ", "update_time
// desc");
HashMap<String, String> map = new HashMap<>();
map.put("flag", "2");
String task_code = (String) whereJson.get("task_code");
@@ -228,7 +231,10 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
map.put("create_time", create_time);
map.put("end_time", end_time);
}
JSONObject jsonObject1 = WQL.getWO("QTASK_QUERY").addParamMap(map).pageQuery(WqlUtil.getHttpContext(page), "create_time desc");
JSONObject jsonObject1 =
WQL.getWO("QTASK_QUERY")
.addParamMap(map)
.pageQuery(WqlUtil.getHttpContext(page), "create_time desc");
JSONArray array = jsonObject1.getJSONArray("content");
int totalElements = (Integer) jsonObject1.get("totalElements");
JSONArray arr = new JSONArray();
@@ -281,7 +287,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
Iterator<TaskDto> iterator = tasks.iterator();
while (iterator.hasNext()) {
TaskDto task = iterator.next();
if (task.getStart_device_code().equals(device_code) && StrUtil.equals(task.getTask_status(), "0")) {
if (task.getStart_device_code().equals(device_code)
&& StrUtil.equals(task.getTask_status(), "0")) {
list.add(task);
}
}
@@ -297,7 +304,9 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
if (!StrUtil.equals(task.getTask_type(), "6")) {
continue;
}
if ((task.getStart_device_code().equals(start_device_code) || task.getStart_device_code2().equals(start_device_code)) && StrUtil.equals(task.getTask_status(), "0")) {
if ((task.getStart_device_code().equals(start_device_code)
|| task.getStart_device_code2().equals(start_device_code))
&& StrUtil.equals(task.getTask_status(), "0")) {
list.add(task);
}
}
@@ -313,7 +322,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
if (!StrUtil.equals(task.getTask_type(), "6")) {
continue;
}
if (task.getStart_device_code().equals(back_start_device_code) && StrUtil.equals(task.getTask_status(), "0")) {
if (task.getStart_device_code().equals(back_start_device_code)
&& StrUtil.equals(task.getTask_status(), "0")) {
list.add(task);
}
}
@@ -326,7 +336,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
Iterator<TaskDto> iterator = tasks.iterator();
while (iterator.hasNext()) {
TaskDto task = iterator.next();
if (task.getStart_device_code().equals(device_code) && StrUtil.equals(task.getTask_status(), "1")) {
if (task.getStart_device_code().equals(device_code)
&& StrUtil.equals(task.getTask_status(), "1")) {
Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code());
if (ObjectUtil.isNotEmpty(instruction)) {
list.add(task);
@@ -336,7 +347,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
return list;
}
public List<TaskDto> queryTaskByStartAndIntStatus(String head_start_device_code) {
List<TaskDto> list = new ArrayList<>();
Iterator<TaskDto> iterator = tasks.iterator();
@@ -345,7 +355,9 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
if (!StrUtil.equals(task.getTask_type(), "6")) {
continue;
}
if ((task.getStart_device_code().equals(head_start_device_code) || task.getStart_device_code2().equals(head_start_device_code)) && StrUtil.equals(task.getTask_status(), "1")) {
if ((task.getStart_device_code().equals(head_start_device_code)
|| task.getStart_device_code2().equals(head_start_device_code))
&& StrUtil.equals(task.getTask_status(), "1")) {
Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code());
if (ObjectUtil.isNotEmpty(instruction)) {
list.add(task);
@@ -363,7 +375,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
if (!StrUtil.equals(task.getTask_type(), "6")) {
continue;
}
if ((task.getStart_device_code().equals(back_start_device_code)) && StrUtil.equals(task.getTask_status(), "1")) {
if ((task.getStart_device_code().equals(back_start_device_code))
&& StrUtil.equals(task.getTask_status(), "1")) {
Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code());
if (ObjectUtil.isNotEmpty(instruction)) {
list.add(task);
@@ -429,7 +442,10 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
// 判断起点终点设备类型
String startDeviceType = deviceAppService.findDeviceTypeByCode(dto.getStart_device_code());
String nextDeviceType = deviceAppService.findDeviceTypeByCode(dto.getNext_device_code());
if (routelineserver.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), plan_code).size() == 0) {
if (routelineserver
.getShortPathLines(dto.getStart_device_code(), dto.getNext_device_code(), plan_code)
.size()
== 0) {
throw new Exception(dto.getStart_point_code() + "->" + dto.getNext_point_code() + "路由不通!");
}
String createTaskCheck = paramService.findByCode(AcsConfig.CREATETASKCHECK).getValue();
@@ -440,20 +456,18 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
dto.setMaterial(startdevice.getMaterial_type());
if (StrUtil.equals(createTaskCheck, "1")) {
// 判断起点为输送设备
if (StrUtil.equals(DeviceType.conveyor.toString(), startDeviceType)) {
if (StrUtil.equals(DeviceType.conveyor.toString(), startDeviceType)) {}
}
if (StrUtil.equals(DeviceType.conveyor.toString(), nextDeviceType)) {
}
if (StrUtil.equals(DeviceType.conveyor.toString(), nextDeviceType)) {}
} else {
// 判断起点为输送设备
if (StrUtil.equals(DeviceType.conveyor.toString(), startDeviceType)) {
}
if (StrUtil.equals(DeviceType.conveyor.toString(), startDeviceType)) {}
if (StrUtil.equals(DeviceType.conveyor.toString(), nextDeviceType)) {
// if (nextdevice.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
// standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) nextdevice.getDeviceDriver();
// if (nextdevice.getDeviceDriver() instanceof
// StandardOrdinarySiteDeviceDriver) {
// standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver)
// nextdevice.getDeviceDriver();
// if (nextdevice.getHas_goods() != 0) {
// throw new Exception("任务终点需满足无货!");
// }
@@ -523,7 +537,11 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
String device_code = MapUtil.getStr(whereJson, "device_code");
dto.setRoute_plan_code("one");
String next_device_code = "";
String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + dto.getRoute_plan_code() + "'").uniqueResult(0).getString("plan_uuid");
String plan_uuid =
WQLObject.getWQLObject("acs_route_plan")
.query("plan_code= '" + dto.getRoute_plan_code() + "'")
.uniqueResult(0)
.getString("plan_uuid");
JSONArray ja = routelineserver.queryNextLine(device_code, plan_uuid);
for (int j = 0; j < ja.size(); j++) {
JSONObject jo = (JSONObject) ja.get(j);
@@ -726,7 +744,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
taskFeedbackService.update(feefbackdto);
}
}
}
}
@@ -844,7 +861,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
taskFeedbackService.update(feefbackdto);
}
}
}
// 如果属于先知AGV关闭运单序列
if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) {
@@ -876,11 +892,13 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
WQLObject wo = WQLObject.getWQLObject("acs_task");
JSONObject json = (JSONObject) JSONObject.toJSON(entity);
wo.update(json);
Iterator<TaskDto> it = tasks.iterator();
// 清理缓存
for (int i = 0; i < tasks.size(); i++) {
TaskDto taskDto = tasks.get(i);
while (it.hasNext()){
TaskDto taskDto = it.next();
if (taskDto.getTask_id().equals(id)) {
tasks.remove(i);
tasks.remove(taskDto);
}
}
// 判断是否为WMS下发的任务如果是反馈任务状态给WMS
@@ -894,7 +912,11 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
ja.add(feed_jo);
acstowmsService.feedbackTaskStatusToWms(ja);
}
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(entity.getStart_device_code(), entity.getNext_device_code(), entity.getRoute_plan_code());
List<RouteLineDto> 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")) {
@@ -913,7 +935,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
ParamService paramService = SpringContextHolder.getBean(ParamService.class);
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl");
// InstructionDto inst = instructionservice.findByTaskid(acsTask, "instruction_status < 2 ");
// InstructionDto inst = instructionservice.findByTaskid(acsTask, "instruction_status < 2
// ");
// if (inst != null) {
// throw new BadRequestException("有指令未完成!");
// }
@@ -941,13 +964,13 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
String to_y = acsTask.getTo_y();
String to_z = acsTask.getTo_z();
/**
* 开始平均分解校验
*/
String this_device_code = this.queryAssignedByDevice(acsTask.getStart_device_code(), acsTask.getNext_device_code());
/** 开始平均分解校验 */
String this_device_code =
this.queryAssignedByDevice(acsTask.getStart_device_code(), acsTask.getNext_device_code());
if (StrUtil.isEmpty(this_device_code)) {
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, acsTask.getNext_device_code(), route_plan_code);
List<RouteLineDto> shortPathsList =
routeLineService.getShortPathLines(
start_device_code, acsTask.getNext_device_code(), route_plan_code);
RouteLineDto routeLineDto = shortPathsList.get(0);
String path = routeLineDto.getPath();
String type = routeLineDto.getType();
@@ -1033,8 +1056,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
return instdto;
}
@Override
public Instruction createInst(String ids) throws Exception {
TaskDto acsTask = this.findById(ids);
@@ -1065,12 +1086,13 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
String next_point_code2 = acsTask.getNext_point_code2();
String agv_system_type = acsTask.getAgv_system_type();
String task_type = acsTask.getTask_type();
/**
* 开始平均分解校验
*/
String this_device_code = this.queryAssignedByDevice(acsTask.getStart_device_code(), acsTask.getNext_device_code());
/** 开始平均分解校验 */
String this_device_code =
this.queryAssignedByDevice(acsTask.getStart_device_code(), acsTask.getNext_device_code());
if (StrUtil.isEmpty(this_device_code)) {
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, acsTask.getNext_device_code(), route_plan_code);
List<RouteLineDto> shortPathsList =
routeLineService.getShortPathLines(
start_device_code, acsTask.getNext_device_code(), route_plan_code);
RouteLineDto routeLineDto = shortPathsList.get(0);
String path = routeLineDto.getPath();
String type = routeLineDto.getType();
@@ -1160,7 +1182,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
return inst;
}
@Override
public void download(List<TaskDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
@@ -1202,9 +1223,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
}
@Override
public void createTaskByClick(JSONObject json) {
}
public void createTaskByClick(JSONObject json) {}
@Override
public int checkAllowCreate(String devicecode) {
@@ -1239,7 +1258,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
return tasks;
}
public TaskDto findByContainer(String container_code) {
Iterator var3 = tasks.iterator();
@@ -1288,7 +1306,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
return null;
}
@Override
public TaskDto findByStartCodeAndReady(String device_code) {
Iterator var3 = tasks.iterator();
@@ -1298,7 +1315,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
// if (!StrUtil.equals(task.getTask_type(), "5")) {
// continue;
// }
if (StrUtil.equals(task.getStart_device_code(), device_code) && StrUtil.equals(task.getTask_status(), "0")) {
if (StrUtil.equals(task.getStart_device_code(), device_code)
&& StrUtil.equals(task.getTask_status(), "0")) {
return task;
}
}
@@ -1350,7 +1368,13 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
task.setStart_device_code(task.getStart_device_code());
} else {
String start_device = deviceAppService.findDeviceByCode(start_point_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name();
String start_device =
deviceAppService
.findDeviceByCode(start_point_code)
.getDeviceDriverDefination()
.getFitDeviceTypes()
.get(0)
.name();
// 如果point_device为货架则不包含列层信息需要重新拼接
if (StrUtil.equals("storage", start_device)) {
if (StrUtil.isEmpty(task.getFrom_x())) {
@@ -1408,7 +1432,13 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
task.setNext_device_code(task.getNext_device_code());
} else {
String next_device = deviceAppService.findDeviceByCode(next_point_code).getDeviceDriverDefination().getFitDeviceTypes().get(0).name();
String next_device =
deviceAppService
.findDeviceByCode(next_point_code)
.getDeviceDriverDefination()
.getFitDeviceTypes()
.get(0)
.name();
if (StrUtil.equals("storage", next_device)) {
if (StrUtil.isEmpty(task.getTo_x())) {
throw new BadRequestException("货位信息终点需要包含列信息");
@@ -1438,7 +1468,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
} else {
task.setNext_device_code(next_point_code);
task.setNext_device_code(next_point_code);
}
}
return task;
@@ -1458,7 +1487,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
@Override
public String queryAssignedByDevice(String device_code, String task_nextdeice_code) {
List<DeviceAssignedDto> list = deviceAssignedService.queryAssignedBydevice(device_code, task_nextdeice_code);
List<DeviceAssignedDto> list =
deviceAssignedService.queryAssignedBydevice(device_code, task_nextdeice_code);
int flag1 = 0;
String flag2 = null;
for (int i = 0; i < list.size(); i++) {
@@ -1489,7 +1519,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
flag2 = this_device_code;
}
}
}
if (!StrUtil.isEmpty(flag2)) {
return flag2;
@@ -1497,14 +1526,14 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
return null;
}
@Override
public Integer querySameDeviceReadyTask(String start_device, String next_device, String status) {
int num = 0;
Iterator<TaskDto> iterator = tasks.iterator();
while (iterator.hasNext()) {
TaskDto task = iterator.next();
if (StrUtil.equals(task.getStart_device_code(),start_device) && StrUtil.equals(task.getNext_device_code(),next_device)
if (StrUtil.equals(task.getStart_device_code(), start_device)
&& StrUtil.equals(task.getNext_device_code(), next_device)
&& StrUtil.equals(task.getTask_status(), status)) {
num++;
}
@@ -1513,7 +1542,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
return num;
}
@Override
public Integer querySameTaskByType(String taskType) {
int num = 0;
@@ -1537,6 +1565,4 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
public Integer querySameDestinationTask(String code) {
return null;
}
}

View File

@@ -8,11 +8,11 @@ spring:
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
# url: jdbc:log4jdbc:mysql://${DB_HOST:10.1.3.91}:${DB_PORT:3306}/${DB_NAME:acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:lzhl_one_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:lzhl_one_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:lzhl_one_wcs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
username: ${DB_USER:root}
# password: ${DB_PWD:P@ssw0rd}
# password: ${DB_PWD:Root.123456}
password: ${DB_PWD:123456}
password: ${DB_PWD:password}
# 初始连接数
initial-size: 5

View File

@@ -2,7 +2,7 @@ spring:
freemarker:
check-template-location: false
profiles:
active: prod
active: dev
jackson:
time-zone: GMT+8
data:

View File

@@ -94,6 +94,7 @@ import hongxiang_device from '@/views/acs/device/driver/hongxiang_device'
import hongxiang_conveyor from '@/views/acs/device/driver/hongxiang_conveyor'
import plug_pull_device_site from '@/views/acs/device/driver/plug_pull_device_site'
import siemens_conveyor_labeling from '@/views/acs/device/driver/siemens_conveyor_labeling'
import siemens_conveyor_ckk from '@/views/acs/device/driver/siemens_conveyor_ckk'
export default {
name: 'DeviceConfig',
@@ -118,7 +119,8 @@ export default {
siemens_conveyor,
slit_two_manipulator,
plug_pull_device_site,
siemens_conveyor_labeling
siemens_conveyor_labeling,
siemens_conveyor_ckk
},
dicts: ['device_type'],
mixins: [crud],

View File

@@ -0,0 +1,513 @@
<template>
<!--标准版-输送机-出库口-->
<div>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">设备协议</span>
</div>
<el-row>
<el-col :span="12">
OpcServer:
<el-select
v-model="opc_id"
placeholder="无"
clearable
filterable
@change="changeOpc"
>
<el-option
v-for="item in dataOpcservers"
:key="item.opc_id"
:label="item.opc_name"
:value="item.opc_id"
/>
</el-select>
</el-col>
<el-col :span="12">
PLC:
<el-select
v-model="plc_id"
placeholder="无"
clearable
@change="changePlc"
>
<el-option
v-for="item in dataOpcPlcs"
:key="item.plc_id"
:label="item.plc_name"
:value="item.plc_id"
/>
</el-select>
</el-col>
</el-row>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">输送系统</span>
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-row>
<el-col :span="8">
<el-form-item label="电气调度号" label-width="150px">
<el-input v-model="form.address" />
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">指令相关</span>
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-row>
<el-col :span="8">
<el-form-item label="检验有货">
<el-switch v-model="form.inspect_in_stocck" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="忽视取货校验" label-width="150px">
<el-switch v-model="form.ignore_pickup_check" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="忽视放货校验" label-width="150px">
<el-switch v-model="form.ignore_release_check" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="呼叫">
<el-switch v-model="form.apply_task" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="响应" label-width="150px">
<el-switch v-model="form.manual_create_task" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="关联设备" prop="device_code">
<el-select
v-model="form.link_device_code"
filterable
multiple
placeholder="请选择"
>
<el-option
v-for="item in deviceList"
:key="item.device_code"
:label="item.device_name"
:value="item.device_code"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="关联三色灯" prop="device_code" label-width="100px">
<el-select
v-model="form.link_three_lamp"
filterable
clearable
placeholder="请选择"
>
<el-option
v-for="item in deviceList"
:key="item.device_code"
:label="item.device_name"
:value="item.device_code"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="是否输入物料" label-width="150px">
<el-switch v-model="form.input_material" />
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">AGV相关</span>
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-row>
<el-col :span="8">
<el-form-item label="取货">
<el-switch v-model="form.is_pickup" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="放货">
<el-switch v-model="form.is_release" />
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">PLC读取字段</span>
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-table
v-loading="false"
:data="data1"
:max-height="550"
size="small"
style="width: 100%;margin-bottom: 15px"
>
<el-table-column prop="name" label="用途" />
<el-table-column prop="code" label="别名要求" />
<el-table-column prop="db" label="DB块">
<template slot-scope="scope">
<el-input
v-model="data1[scope.$index].db"
size="mini"
class="edit-input"
@input="finishReadEdit(data1[scope.$index])"
/>
</template>
</el-table-column>
<el-table-column prop="dbr_value">
<template slot="header">
<el-link type="primary" :underline="false" @click.native="test_read1()">测试读</el-link>
</template>
<template slot-scope="scope">
<el-input v-model="data1[scope.$index].dbr_value" size="mini" class="edit-input" />
</template>
</el-table-column>
</el-table>
</el-form>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span">PLC写入字段</span>
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-table
v-loading="false"
:data="data2"
:max-height="550"
size="small"
style="width: 100%;margin-bottom: 15px"
>
<el-table-column prop="name" label="用途" />
<el-table-column prop="code" label="别名要求" />
<el-table-column prop="db" label="DB块">
<template slot-scope="scope">
<el-input
v-model="data2[scope.$index].db"
size="mini"
class="edit-input"
@input="finishWriteEdit(data2[scope.$index])"
/>
</template>
</el-table-column>
<el-table-column prop="dbw_value">
<template slot="header">
<el-link type="primary" :underline="false" @click.native="test_write1()">测试写</el-link>
</template>
<template slot-scope="scope">
<el-input v-model="data2[scope.$index].dbw_value" size="mini" class="edit-input" />
</template>
</el-table-column>
</el-table>
</el-form>
</el-card>
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<span class="role-span" />
<el-button
:loading="false"
icon="el-icon-check"
size="mini"
style="float: right; padding: 6px 9px"
type="primary"
@click="doSubmit"
>保存
</el-button>
</div>
</el-card>
</div>
</template>
<script>
import {
queryDriverConfig,
updateConfig,
testRead,
testwrite
} from '@/api/acs/device/driverConfig'
import { selectOpcList } from '@/api/acs/device/opc'
import { selectPlcList } from '@/api/acs/device/opcPlc'
import { selectListByOpcID } from '@/api/acs/device/opcPlc'
import crud from '@/mixins/crud'
import deviceCrud from '@/api/acs/device/device'
export default {
name: 'StandardConveyorControl',
mixins: [crud],
props: {
parentForm: {
type: Object,
require: true
}
},
data() {
return {
device_code: '',
device_id: '',
plc_id: '',
plc_code: '',
address: '',
opc_id: '',
opc_code: '',
configLoading: false,
dataOpcservers: [],
dataOpcPlcs: [],
deviceList: [],
data1: [],
data2: [],
form: {
inspect_in_stocck: true,
ignore_pickup_check: true,
ignore_release_check: true,
apply_task: true,
link_three_lamp: '',
manual_create_task: true,
is_pickup: true,
is_release: true,
link_device_code: []
},
rules: {}
}
},
created() {
this.$nextTick(() => {
// 从父表单获取设备编码
this.device_id = this.$props.parentForm.device_id
this.device_code = this.$props.parentForm.device_code
queryDriverConfig(this.device_id, this.$props.parentForm.driver_code).then(data => {
// 给表单赋值,并且属性不能为空
if (data.form) {
const arr = Object.keys(data.form)
// 不为空
if (arr.length > 0) {
this.form = data.form
}
}
// 给表单赋值,并且属性不能为空
if (data.parentForm) {
const arr = Object.keys(data.parentForm)
// 不为空
if (arr.length > 0) {
this.opc_code = data.parentForm.opc_code
this.plc_code = data.parentForm.plc_code
}
}
this.data1 = data.rs
this.data2 = data.ws
this.sliceItem()
})
selectPlcList().then(data => {
this.dataOpcPlcs = data
this.plc_id = this.$props.parentForm.opc_plc_id
})
selectOpcList().then(data => {
this.dataOpcservers = data
this.opc_id = this.$props.parentForm.opc_server_id
})
deviceCrud.selectDeviceList().then(data => {
this.deviceList = data
})
})
},
methods: {
finishReadEdit(data) {
// 编辑的是code列,并且值包含mode
if (data.code.indexOf('mode') !== -1) {
const dbValue = data.db
// .之前的字符串
const beforeStr = dbValue.match(/(\S*)\./)[1]
// .之后的字符串
const afterStr = dbValue.match(/\.(\S*)/)[1]
// 取最后数字
const endNumber = afterStr.substring(1)
// 最后为非数字
if (isNaN(parseInt(endNumber))) {
return
}
for (const val in this.data1) {
if (this.data1[val].code.indexOf('mode') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 0)
}
if (this.data1[val].code.indexOf('move') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 1)
}
if (this.data1[val].code.indexOf('carrier_direction') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
}
if (this.data1[val].code.indexOf('error') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 4)
}
if (this.data1[val].code.indexOf('task') !== -1) {
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 8)
}
}
}
},
finishWriteEdit(data) {
// 编辑的是code列,并且值包含mode
if (data.code.indexOf('to_command') !== -1) {
const dbValue = data.db
// .之前的字符串
const beforeStr = dbValue.match(/(\S*)\./)[1]
// .之后的字符串
const afterStr = dbValue.match(/\.(\S*)/)[1]
// 取最后数字
const endNumber = afterStr.substring(1)
// 最后为非数字
if (isNaN(parseInt(endNumber))) {
return
}
console.log(endNumber)
for (const val in this.data2) {
if (this.data2[val].code.indexOf('to_command') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 0)
}
if (this.data2[val].code.indexOf('to_target') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
}
if (this.data2[val].code.indexOf('to_container_type') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 4)
}
if (this.data2[val].code.indexOf('to_task') !== -1) {
this.data2[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 6)
}
if (this.data2[val].code.indexOf('to_strap_times') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 10)
}
if (this.data2[val].code.indexOf('to_length') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 12)
}
if (this.data2[val].code.indexOf('to_weight') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 14)
}
if (this.data2[val].code.indexOf('to_height') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 16)
}
}
}
},
changeOpc(val) {
this.dataOpcservers.forEach(item => {
if (item.opc_id === val) {
this.opc_code = item.opc_code
}
})
selectListByOpcID(val).then(data => {
this.dataOpcPlcs = data
this.plc_id = ''
this.plc_code = ''
if (this.dataOpcPlcs && this.dataOpcPlcs.length > 0) {
this.plc_id = this.dataOpcPlcs[0].plc_id
this.plc_code = this.dataOpcPlcs[0].plc_code
}
this.sliceItem()
})
},
changePlc(val) {
this.dataOpcPlcs.forEach(item => {
if (item.plc_id === val) {
this.plc_code = item.plc_code
this.sliceItem()
return
}
})
},
test_read1() {
testRead(this.data1, this.opc_id).then(data => {
this.data1 = data
this.notify('操作成功!', 'success')
}).catch(err => {
console.log(err.response.data.message)
})
},
test_write1() {
testwrite(this.data2, this.opc_id).then(data => {
this.notify('操作成功!', 'success')
}).catch(err => {
console.log(err.response.data.message)
})
},
doSubmit() {
this.$refs['form'].validate((valid) => {
if (valid) {
this.configLoading = true
// 根据驱动类型判断是否为路由设备
const parentForm = this.parentForm
parentForm.is_route = true
parentForm.plc_id = this.plc_id
parentForm.opc_id = this.opc_id
updateConfig(parentForm, this.form, this.data1, this.data2).then(res => {
this.notify('保存成功', 'success')
this.configLoading = false
}).catch(err => {
this.configLoading = false
console.log(err.response.data.message)
})
}
})
},
sliceItem() { // 拼接DB的Item值
this.data1.forEach(item => {
const str = item.code
// 是否包含.
if (str.search('.') !== -1) {
// 截取最后一位
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
} else {
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
}
})
this.data2.forEach(item => {
const str = item.code
// 是否包含.
if (str.search('.') !== -1) {
// 截取最后一位
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
} else {
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
}
})
}
}
}
</script>
<style scoped>
</style>

View File

@@ -85,6 +85,12 @@
<el-radio-button :label="1">禁用</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item label="请求标记" prop="requireSucess" label-width="120px">
<el-radio-group v-model="form.requireSucess">
<el-radio-button :label="0"></el-radio-button>
<el-radio-button :label="1"></el-radio-button>
</el-radio-group>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible4 = false"> </el-button>
@@ -97,13 +103,31 @@
<el-form-item label="设备编号" prop="device_code" label-width="120px">
<el-input v-model="form.device_code" :disabled="true" />
</el-form-item>
<el-form-item label="请求标记" prop="is_disable" label-width="120px">
<el-form-item label="请求标记" prop="requireSucess" label-width="120px">
<el-radio-group v-model="form.requireSucess">
<el-radio-button :label="0"></el-radio-button>
<el-radio-button :label="1"></el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item label="请求标记" prop="is_disable" label-width="120px">
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible5 = false"> </el-button>
<el-button type="primary" @click="dialogSave"> </el-button>
</div>
</el-dialog>
<el-dialog title="设备设置" :visible.sync="dialogFormVisible6" width="35%">
<el-form :model="form" size="small">
<el-form-item label="设备编号" prop="device_code" label-width="120px">
<el-input v-model="form.device_code" :disabled="true" />
</el-form-item>
<el-form-item label="申请指令标记" prop="requireSucess" label-width="120px">
<el-radio-group v-model="form.requireSucess">
<el-radio-button :label="0"></el-radio-button>
<el-radio-button :label="1"></el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item label="请求任务标记" prop="applySucess" label-width="120px">
<el-radio-group v-model="form.applySucess">
<el-radio-button :label="0"></el-radio-button>
<el-radio-button :label="1"></el-radio-button>
@@ -165,6 +189,7 @@ export default {
dialogFormVisible3: false,
dialogFormVisible4: false,
dialogFormVisible5: false,
dialogFormVisible6: false,
form: {
device_code: '',
hasGoodStatus: null,
@@ -308,8 +333,7 @@ export default {
} else if (clickObj.data.driver_type === 'siemens_conveyor') {
this.dialogFormVisible5 = true
} else if (clickObj.data.driver_type === 'standard_conveyor_control_with_scanner') {
this.dialogFormVisible5 = true
console.log('11111111111')
this.dialogFormVisible6 = true
} else {
this.dialogFormVisible = true
}
@@ -322,6 +346,7 @@ export default {
this.form.requireSucess = clickObj.data.requireSucess
this.form.fullrequireSucess = clickObj.data.fullrequireSucess
this.form.is_disable = clickObj.data.is_disable1
this.form.applySucess = clickObj.data.applySucess
},
moveShow(nodeData) { // 点击之后显示出来的数据----只需要设备信息
let item = ''
@@ -538,6 +563,7 @@ export default {
this.dialogFormVisible3 = false
this.dialogFormVisible4 = false
this.dialogFormVisible5 = false
this.dialogFormVisible6 = false
this.initStageData()
}).catch(err => {
this.dialogFormVisible = false

View File

@@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.*;
import java.util.HashMap;
/**
* @author liuxy
@@ -83,6 +84,7 @@ public class PrintServiceImpl implements PrintService {
String date_of_FG_inbound = jsonInbound.getString("date_of_fg_inbound");
//毛重
String box_weight = NumberUtil.round(box_jo.getString("box_weight"),2).toString();
// String box_weight = NumberUtil.round(box_jo.getString("real_weight"),2).toString();
//生产日期:取此箱子中最晚的生产日期
JSONObject jsonProduction = subTab.query("package_box_sn = '" + box_no + "' order by date_of_production DESC").uniqueResult(0);
String date_of_production = jsonProduction.getString("date_of_production");
@@ -211,7 +213,13 @@ public class PrintServiceImpl implements PrintService {
//入库日期:取此箱子中最晚的入库日期
JSONObject jsonInbound= subTab.query("package_box_sn = '" + box_no + "' order by date_of_fg_inbound DESC").uniqueResult(0);
String date_of_FG_inbound = jsonInbound.getString("date_of_fg_inbound");
//毛重
//更新实际重量
double real_weight = whereJson.getDoubleValue("box_weight");
HashMap<String, Object> map = new HashMap<>();
map.put("real_weight",real_weight);
subTab.update(map,"package_box_sn = '"+package_box_sn+"'");
String box_weight = NumberUtil.round(whereJson.getString("box_weight"),2).toString();
//生产日期:取此箱子中最晚的生产日期
JSONObject jsonProduction = subTab.query("package_box_sn = '" + box_no + "' order by date_of_production DESC").uniqueResult(0);

View File

@@ -857,17 +857,57 @@ public class RawAssistIStorServiceImpl implements RawAssistIStorService {
if (ObjectUtil.isNotEmpty(jsonDescStruct)) {
struct_jo = jsonDescStruct;
} else {
// 没有就正序找到第一个物料、判断上一个是否有货位
JSONObject jsonAscBox = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') <> '' order by out_order_seq ASC").uniqueResult(0);
String out_order_seq2 = jsonAscBox.getString("out_order_seq");
// 上一个货位顺序号
String out_order_seq_asc = String.valueOf(NumberUtil.sub(out_order_seq2, "1"));
JSONObject jsonAscStruct = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num + "'AND placement_type = '" + placement_type + "' AND row_num = '" + row_num + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' and out_order_seq = '"+out_order_seq_asc+"'").uniqueResult(0);
// 说明这排有任务在执行,新开一排
//根据分切计划查询该订单物料大概还有多少未入
row_map.put("flag", "12");
JSONArray plan_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0);
if (ObjectUtil.isEmpty(plan_rows)) {
plan_rows = new JSONArray();
}
//查询该销售订单及行号有多少个生成状态的箱子
row_map.put("flag", "27");
JSONArray box_rows = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParamMap(row_map).process().getResultJSONArray(0);
if (ObjectUtil.isEmpty(box_rows)) {
box_rows = new JSONArray();
}
int box_num = (int) Math.ceil(plan_rows.size() / 2) + box_rows.size();
if (ObjectUtil.isNotEmpty(jsonAscStruct)) struct_jo = jsonAscStruct;
//查询数量与订单物料箱子数量相近的一排
JSONObject empty_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("sect_id", sect_id).addParam("flag", "13").addParam("sql_str", " ORDER BY abs(" + box_num + "-a.struct_num),block_num,row_num").process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(empty_row)) {
String block_num2 = empty_row.getString("block_num");
String row_num2 = empty_row.getString("row_num");
String placement_type2 = empty_row.getString("placement_type");
if (placement_type.equals("02")) {
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num2 + "' AND row_num = '" + row_num2 + "' AND placement_type = '" + placement_type2 + "' AND is_delete = '0' AND is_used = '1' AND lock_type = '1' order by out_order_seq ASC").uniqueResult(0);
} else {
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num2 + "' AND row_num = '" + row_num2 + "' AND placement_type = '" + placement_type2 + "'AND is_delete = '0' AND is_used = '1' AND lock_type = '1' order by out_order_seq DESC").uniqueResult(0);
}
} else {
//如果查询不到空的一排,则查询有空位双通的一排
JSONObject have_row = WQL.getWO("QST_IVT_RAWASSISTISTOR").addParam("sect_id", sect_id).addParam("flag", "14").addParam("sql_str", " ORDER BY abs(" + box_num + "-a.struct_num)").process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(have_row)) {
String block_num3 = have_row.getString("block_num");
String row_num3 = have_row.getString("row_num");
//判断该排是左边为空,还是右边为空
JSONObject right_str = WQLObject.getWQLObject("st_ivt_structattr").query("block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' order by out_order_seq").uniqueResult(0);
JSONObject left_str = WQLObject.getWQLObject("st_ivt_structattr").query("block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' order by out_order_seq desc").uniqueResult(0);
if (StrUtil.isNotEmpty(right_str.getString("storagevehicle_code")) || !right_str.getString("lock_type").equals("1")) {
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq").uniqueResult(0);
}
if (StrUtil.isNotEmpty(left_str.getString("storagevehicle_code")) || !left_str.getString("lock_type").equals("1")) {
struct_jo = WQLObject.getWQLObject("st_ivt_structattr").query("lock_type = '1' AND block_num = '" + block_num3 + "' AND row_num = '" + row_num3 + "' AND is_delete = '0' AND is_used = '1' AND IFNULL(storagevehicle_code,'') = '' order by out_order_seq desc").uniqueResult(0);
}
}
}
}
}
} else {
//如果不存在相同订单物料的巷道
/*//查询是否存在未完成的相同订单物流的入库单,如果存在则查询该排是否存在可用的仓位