rev:手持功能代码优化

This commit is contained in:
2024-04-19 17:03:43 +08:00
parent 6766c47ced
commit fdb12b9760
7 changed files with 50 additions and 58 deletions

View File

@@ -57,6 +57,6 @@ public interface DeviceExtraMapper extends CommonMapper<DeviceExtra> {
* @param extra_code * @param extra_code
* @return * @return
*/ */
@Select("select * from lzhl_two_acs.acs_device_extra where device_id=#{device_id} and extra_code=#{extra_code} order by create_time desc") @Select("select * from acs_device_extra where device_id=#{device_id} and extra_code=#{extra_code} order by create_time desc")
DeviceExtra findByDeviceId(@Param("device_id") String device_id, @Param("extra_code") String extra_code); DeviceExtra findByDeviceId(@Param("device_id") String device_id, @Param("extra_code") String extra_code);
} }

View File

@@ -88,6 +88,11 @@ public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implem
public int lastMove = 0; public int lastMove = 0;
public int lastAction = 0; public int lastAction = 0;
public int lastError = 0; public int lastError = 0;
int to_command = 0;
int last_to_command = 0;
int to_error = 0;
int last_to_error = 0;
Boolean isonline = true; Boolean isonline = true;
@@ -117,6 +122,8 @@ public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implem
action = this.itemProtocol.getItem_action(); action = this.itemProtocol.getItem_action();
error = this.itemProtocol.getItem_error(); error = this.itemProtocol.getItem_error();
iserror = this.itemProtocol.isError; iserror = this.itemProtocol.isError;
to_command = this.itemProtocol.getItem_to_command();
to_error = this.itemProtocol.getItem_error();
if (mode != lastMode) { if (mode != lastMode) {
requireSucess = false; requireSucess = false;
@@ -134,7 +141,7 @@ public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implem
} else if (error != 0) { } else if (error != 0) {
this.setIserror(true); this.setIserror(true);
message = "universal_message3"; message = "universal_message3";
}else { } else {
this.setIsonline(true); this.setIsonline(true);
this.setIserror(false); this.setIserror(false);
message = ""; message = "";
@@ -175,11 +182,12 @@ public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implem
} }
lastMode = mode; lastMode = mode;
lastMove = move; lastMove = move;
lastAction = action; lastAction = action;
lastError = error; lastError = error;
last_to_error = to_error;
last_to_command = to_command;
} }
@@ -203,20 +211,20 @@ public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implem
if (ObjectUtil.isEmpty(response)) { if (ObjectUtil.isEmpty(response)) {
message = "two_message18"; message = "two_message18";
} else { } else {
if (response.getCode()== CommonFinalParam.STATUS_OPEN) { if (response.getCode() == CommonFinalParam.STATUS_OPEN) {
if (mode==4){ if (mode == 4) {
this.writing("to_command","4"); this.writing("to_command", "4");
}else if (mode==5){ } else if (mode == 5) {
this.writing("to_command","5"); this.writing("to_command", "5");
}else if (mode==9){ } else if (mode == 9) {
this.writing("to_command","9"); this.writing("to_command", "9");
} }
message = "two_message19"; message = "two_message19";
requireSucess = true; requireSucess = true;
} else { } else {
requireSucess = false; requireSucess = false;
message = "two_message20" + response.getMessage(); message = "two_message20" + response.getMessage();
this.writing("to_command","99"); this.writing("to_command", "99");
} }
} }
} }
@@ -224,8 +232,6 @@ public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implem
} }
public void writing(String param, String value) { public void writing(String param, String value) {
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
@@ -277,14 +283,12 @@ public class GreenFoilMachineButtonDriver extends AbstractOpcDeviceDriver implem
requireSucess = "1"; requireSucess = "1";
} }
jo.put("requireSucess", requireSucess); jo.put("requireSucess", requireSucess);
if (this.getAction() == 1) { if (this.getAction() == 0) {
action = "取货中"; action = "不允许取放";
} else if (this.getAction() == 1) {
action = "允许取放";
} else if (this.getAction() == 2) { } else if (this.getAction() == 2) {
action = "取货完成"; action = "允许离开";
} else if (this.getAction() == 3) {
action = "放货中";
} else if (this.getAction() == 4) {
action = "放货完成";
} }
jo.put("device_name", this.getDevice().getDevice_name()); jo.put("device_name", this.getDevice().getDevice_name());

View File

@@ -20,6 +20,7 @@ public class ItemProtocol {
public static String item_to_command = "to_command"; public static String item_to_command = "to_command";
public static String item_to_error = "to_error";
private GreenFoilMachineButtonDriver driver; private GreenFoilMachineButtonDriver driver;
@@ -42,6 +43,9 @@ public class ItemProtocol {
}; };
public int getItem_error(){ public int getItem_error(){
return this.getOpcIntegerValue(item_error); return this.getOpcIntegerValue(item_error);
}
public int getItem_to_command(){
return this.getOpcIntegerValue(item_to_error);
} ; } ;
Boolean isonline; Boolean isonline;
@@ -89,6 +93,7 @@ public class ItemProtocol {
public static List<ItemDto> getWriteableItemDtos() { public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "下发命令", "DB6.W0")); list.add(new ItemDto(item_to_command, "下发命令", "DB6.W0"));
list.add(new ItemDto(item_to_error, "下发故障代码", "DB6.W1"));
return list; return list;
} }

View File

@@ -81,6 +81,9 @@ public class TaskScreenServiceImpl extends CommonServiceImpl<TaskScreenMapper, D
DeviceDto deviceDto = deviceService.findByCode(deviceCode); DeviceDto deviceDto = deviceService.findByCode(deviceCode);
String deviceId = deviceDto.getDevice_id(); String deviceId = deviceDto.getDevice_id();
DeviceExtra deviceExtra = deviceExtraMapper.findByDeviceId(deviceId, "link_device_code"); DeviceExtra deviceExtra = deviceExtraMapper.findByDeviceId(deviceId, "link_device_code");
if (ObjectUtil.isEmpty(deviceExtra)){
throw new BadRequestException("未配置关联设备!");
}
String extraValue = deviceExtra.getExtra_value(); String extraValue = deviceExtra.getExtra_value();
List<String> extraDeviceCodes = getExtraDeviceCodes(extraValue); List<String> extraDeviceCodes = getExtraDeviceCodes(extraValue);
if (CollUtil.isEmpty(extraDeviceCodes) || extraDeviceCodes.size() < 0) { if (CollUtil.isEmpty(extraDeviceCodes) || extraDeviceCodes.size() < 0) {

View File

@@ -54,19 +54,13 @@ public class B2HandServiceImpl implements B2HandService {
String task_type = dto.getTask_type(); String task_type = dto.getTask_type();
if (StrUtil.isEmpty(start_device_code)) { if (StrUtil.isEmpty(start_device_code)) {
JSONObject json = new JSONObject(); throw new BadRequestException("起点1不能为空");
json.put("message", "起点1不能为空");
errArr.add(json);
} }
if (StrUtil.isEmpty(next_device_code)) { if (StrUtil.isEmpty(next_device_code)) {
JSONObject json = new JSONObject(); throw new BadRequestException("终点1不能为空");
json.put("message", "终点1不能为空");
errArr.add(json);
} }
if (StrUtil.isEmpty(task_type)) { if (StrUtil.isEmpty(task_type)) {
JSONObject json = new JSONObject(); throw new BadRequestException("任务类型不能为空");
json.put("message", "任务类型不能为空");
errArr.add(json);
} }
JSONObject jo = new JSONObject(); JSONObject jo = new JSONObject();
@@ -85,11 +79,8 @@ public class B2HandServiceImpl implements B2HandService {
jo.put("next_device_code", next_device_code); jo.put("next_device_code", next_device_code);
jo.put("start_point_code", start_device_code); jo.put("start_point_code", start_device_code);
jo.put("next_point_code", next_device_code); jo.put("next_point_code", next_device_code);
jo.put("start_device_code2", start_device_code2);
jo.put("next_device_code2", next_device_code2);
jo.put("start_point_code2", start_device_code2);
jo.put("next_point_code2", next_device_code2);
jo.put("task_type", task_type); jo.put("task_type", task_type);
jo.put("route_plan_code","normal");
jo.put("agv_system_type", "2"); jo.put("agv_system_type", "2");
jo.put("priority", "1"); jo.put("priority", "1");
@@ -101,6 +92,7 @@ public class B2HandServiceImpl implements B2HandService {
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
json.put("message", e.getMessage()); json.put("message", e.getMessage());
errArr.add(json); errArr.add(json);
throw new RuntimeException(e.getMessage());
} }
JSONArray data = new JSONArray(); JSONArray data = new JSONArray();
JSONObject resultJson = new JSONObject(); JSONObject resultJson = new JSONObject();
@@ -119,7 +111,7 @@ public class B2HandServiceImpl implements B2HandService {
JSONArray data = new JSONArray(); JSONArray data = new JSONArray();
//查询所有生箔区的设备 //查询所有生箔区的设备
List<Device> list = deviceService.lambdaQuery() List<Device> list = deviceService.lambdaQuery()
.eq(Device::getRegion, "2") .eq(Device::getRegion, "1")
.list(); .list();
if (CollectionUtil.isEmpty(list)) { if (CollectionUtil.isEmpty(list)) {
throw new BadRequestException("未查到该区域的设备!"); throw new BadRequestException("未查到该区域的设备!");
@@ -158,15 +150,12 @@ public class B2HandServiceImpl implements B2HandService {
String device_code = dto.getDevice_code(); String device_code = dto.getDevice_code();
String option = dto.getOption(); String option = dto.getOption();
if (StrUtil.isEmpty(device_code)) { if (StrUtil.isEmpty(device_code)) {
JSONObject json = new JSONObject(); throw new BadRequestException("设备号不能为空");
json.put("message", "设备号不能为空");
errArr.add(json);
} }
if (StrUtil.isEmpty(option)) { if (StrUtil.isEmpty(option)) {
JSONObject json = new JSONObject(); throw new BadRequestException("操作不能为空");
json.put("message", "操作不能为空");
errArr.add(json);
} }
//满轴位允许进入,空轴位允许离开
if (device_code.contains("M")&&(!"1".equals(option))){ if (device_code.contains("M")&&(!"1".equals(option))){
throw new BadRequestException("该设备为满轴位,不能进行该操作"); throw new BadRequestException("该设备为满轴位,不能进行该操作");
} }
@@ -175,6 +164,11 @@ public class B2HandServiceImpl implements B2HandService {
} }
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
Device device = deviceAppService.findDeviceByCode(device_code); Device device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device)){
JSONObject json = new JSONObject();
json.put("message", "设备不存在!");
errArr.add(json);
}
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
standardOrdinarySiteDeviceDriver.setOption(Integer.parseInt(option)); standardOrdinarySiteDeviceDriver.setOption(Integer.parseInt(option));
JSONArray data = new JSONArray(); JSONArray data = new JSONArray();

View File

@@ -115,19 +115,13 @@ public class HandServiceImpl implements HandService {
String task_type = dto.getTask_type(); String task_type = dto.getTask_type();
if (StrUtil.isEmpty(start_device_code)) { if (StrUtil.isEmpty(start_device_code)) {
JSONObject json = new JSONObject(); throw new BadRequestException("起点不能为空");
json.put("message", "起点不能为空");
errArr.add(json);
} }
if (StrUtil.isEmpty(next_device_code)) { if (StrUtil.isEmpty(next_device_code)) {
JSONObject json = new JSONObject(); throw new BadRequestException("终点不能为空");
json.put("message", "终点不能为空");
errArr.add(json);
} }
if (StrUtil.isEmpty(task_type)) { if (StrUtil.isEmpty(task_type)) {
JSONObject json = new JSONObject(); throw new BadRequestException("任务类型不能为空");
json.put("message", "任务类型不能为空");
errArr.add(json);
} }
String start_device_code2 = ""; String start_device_code2 = "";

View File

@@ -153,7 +153,7 @@ export default {
const timer = setInterval(() => { const timer = setInterval(() => {
this.settime()// 你所加载数据的方法 this.settime()// 你所加载数据的方法
this.getMessage() this.getMessage()
}, 10000) }, 1000)
// 销毁定时器 // 销毁定时器
this.$once('hook:beforeDestroy', () => { this.$once('hook:beforeDestroy', () => {
clearInterval(timer) clearInterval(timer)
@@ -175,14 +175,6 @@ export default {
methods: { methods: {
changeDevice(val) { changeDevice(val) {
this.device = val this.device = val
deviceCrud.getLedMessage(this.device).then(data => {
this.form = data
})
// todo: 定时器
this.timer = setInterval(() => { // 定时刷新设备的状态信息
console.log('定时器启动')
this.initStatus()
}, 10000)
}, },
getMessage() { getMessage() {
deviceCrud.getLedMessage(this.device).then(data => { deviceCrud.getLedMessage(this.device).then(data => {