add: lms、acs管芯库联调

This commit is contained in:
ls
2024-11-14 14:05:34 +08:00
parent b239b13cc7
commit 8ab477ff28
6 changed files with 112 additions and 66 deletions

View File

@@ -132,6 +132,14 @@ public interface DeviceService extends CommonService<Device> {
*/ */
DeviceDto findByCode(String code); DeviceDto findByCode(String code);
/**
* 根据电器调度号查询
*
* @param adress code
* @return Device
*/
DeviceDto findByAdress(String adress);
/** /**
* 创建 * 创建
* *

View File

@@ -290,6 +290,15 @@ public class DeviceServiceImpl extends CommonServiceImpl<DeviceMapper, Device> i
return ConvertUtil.convert(device, DeviceDto.class); return ConvertUtil.convert(device, DeviceDto.class);
} }
@Override
public DeviceDto findByAdress(String adress) {
Device device = new LambdaQueryChainWrapper<>(deviceMapper)
.eq(Device::getAddress, adress)
.like(Device::getDevice_code, "A1_GX"+"%")
.one();
return ConvertUtil.convert(device, DeviceDto.class);
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void create(DeviceDto dto) { public void create(DeviceDto dto) {

View File

@@ -33,6 +33,11 @@ public class ItemProtocol {
*/ */
public static String item_error = "error"; public static String item_error = "error";
/**
* 报警2
*/
public static String item_error2 = "error2";
/** /**
* 行走列 * 行走列
*/ */
@@ -141,6 +146,10 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_error); return this.getOpcIntegerValue(item_error);
} }
public int getError2() {
return this.getOpcIntegerValue(item_error2);
}
public int getWalk_y() { public int getWalk_y() {
return this.getOpcIntegerValue(item_walk_y); return this.getOpcIntegerValue(item_walk_y);
@@ -207,6 +216,7 @@ public class ItemProtocol {
list.add(new ItemDto(item_move, "光电信号", "DB1.B2")); list.add(new ItemDto(item_move, "光电信号", "DB1.B2"));
list.add(new ItemDto(item_action, "动作信号", "DB1.B3")); list.add(new ItemDto(item_action, "动作信号", "DB1.B3"));
list.add(new ItemDto(item_error, "报警信号", "DB1.B5")); list.add(new ItemDto(item_error, "报警信号", "DB1.B5"));
list.add(new ItemDto(item_error2, "报警信号2", "DB1.B11"));
list.add(new ItemDto(item_walk_y, "行走列", "DB1.B4")); list.add(new ItemDto(item_walk_y, "行走列", "DB1.B4"));
list.add(new ItemDto(item_barcode, "管芯规格", "DB1.B7")); list.add(new ItemDto(item_barcode, "管芯规格", "DB1.B7"));
list.add(new ItemDto(item_target, "库位", "DB1.B7")); list.add(new ItemDto(item_target, "库位", "DB1.B7"));

View File

@@ -12,7 +12,10 @@ import lombok.extern.slf4j.Slf4j;
import org.nl.acs.common.base.CommonFinalParam; import org.nl.acs.common.base.CommonFinalParam;
import org.nl.acs.device.domain.Device; import org.nl.acs.device.domain.Device;
import org.nl.acs.device.service.DeviceExtraService; import org.nl.acs.device.service.DeviceExtraService;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device.service.dto.DeviceDto;
import org.nl.acs.device.service.impl.DeviceExtraServiceImpl; import org.nl.acs.device.service.impl.DeviceExtraServiceImpl;
import org.nl.acs.device.service.impl.DeviceServiceImpl;
import org.nl.acs.device_driver.DeviceDriver; import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.FeedLmsRealFailed; import org.nl.acs.device_driver.FeedLmsRealFailed;
import org.nl.acs.device_driver.RouteableDeviceDriver; import org.nl.acs.device_driver.RouteableDeviceDriver;
@@ -32,7 +35,6 @@ import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl; import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.route.service.RouteLineService; import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.route.service.impl.RouteLineServiceImpl; import org.nl.acs.route.service.impl.RouteLineServiceImpl;
import org.nl.acs.storage_cell.service.mapper.StorageCellMapper;
import org.nl.acs.task.enums.ActionTypeEnum; import org.nl.acs.task.enums.ActionTypeEnum;
import org.nl.acs.task.enums.TaskStatusEnum; import org.nl.acs.task.enums.TaskStatusEnum;
import org.nl.acs.task.enums.TaskTypeEnum; import org.nl.acs.task.enums.TaskTypeEnum;
@@ -74,10 +76,11 @@ public class PipeCoreRackManipulatorDeviceDriver extends AbstractOpcDeviceDriver
DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class); DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class);
DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class); DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl");
private StorageCellMapper storageCellMapper;
int mode = 0; int mode = 0;
int last_mode = 0; int last_mode = 0;
int move = 0; int move = 0;
@@ -86,6 +89,9 @@ public class PipeCoreRackManipulatorDeviceDriver extends AbstractOpcDeviceDriver
int last_action = 0; int last_action = 0;
int error = 0; int error = 0;
int last_error = 0; int last_error = 0;
int error2 = 0;
int last_error2 = 0;
int task = 0; int task = 0;
int last_task = 0; int last_task = 0;
@@ -158,8 +164,6 @@ public class PipeCoreRackManipulatorDeviceDriver extends AbstractOpcDeviceDriver
String inst_message; String inst_message;
@Override @Override
public Device getDevice() { public Device getDevice() {
return this.device; return this.device;
@@ -173,6 +177,7 @@ public class PipeCoreRackManipulatorDeviceDriver extends AbstractOpcDeviceDriver
move = this.itemProtocol.getMove(); move = this.itemProtocol.getMove();
action = this.itemProtocol.getAction(); action = this.itemProtocol.getAction();
error = this.itemProtocol.getError(); error = this.itemProtocol.getError();
error2 = this.itemProtocol.getError2();
heartbeat = this.itemProtocol.getHeartbeat(); heartbeat = this.itemProtocol.getHeartbeat();
barcode = this.itemProtocol.getBarcode(); barcode = this.itemProtocol.getBarcode();
target = this.itemProtocol.getTarget(); target = this.itemProtocol.getTarget();
@@ -200,34 +205,11 @@ public class PipeCoreRackManipulatorDeviceDriver extends AbstractOpcDeviceDriver
} }
if (mode == 3 && !actionRequireSucess) { if (mode == 3) {
//入库任务完成 //入库任务完成
if (action == 5 && move == 0) { if (action == 5 && move == 0 && !actionRequireSucess) {
try { try {
// logServer.deviceExecuteLog(this.device_code, "", "", "放货完成"); inFinish();
// JSONObject jsonObject = new JSONObject();
// jsonObject.put("device_code", target);
// jsonObject.put("barcode", barcode);
// String response = acsToWmsService.feedbackTubeInStorageComplete(jsonObject);
// JSONObject jo = JSON.parseObject(response);
// if (jo.getInteger("status") == 200) {
// log.info("管芯入库申请放货完成成功:" + jo);
// Map<String, Object> map1 = new HashMap<>();
// List list = new ArrayList();
// map1.put("code", "to_command");
// map1.put("value", 6);
// list.add(map1);
// this.writing(list);
// message = "universal_message1";
// this.actionRequireSucess = true;
// }
Map<String, Object> map1 = new HashMap<>();
List list = new ArrayList();
map1.put("code", "to_command");
map1.put("value", 6);
list.add(map1);
this.writing(list);
} catch (Exception e) { } catch (Exception e) {
message = "universal_message2"; message = "universal_message2";
e.printStackTrace(); e.printStackTrace();
@@ -246,22 +228,22 @@ public class PipeCoreRackManipulatorDeviceDriver extends AbstractOpcDeviceDriver
message = "universal_off-line"; message = "universal_off-line";
//有报警 //有报警
} else if (error != 0) { } else if (error2 != 0 || error != 0) {
this.setIserror(true); this.setIserror(true);
message = "universal_message3"; message = "universal_message3";
//满入空出分配新点位 //满入空出分配新点位
if ((error == 2 || error == 3) && !actionRequireSucess) { if ((error2 == 2 || error2 == 3) && !actionRequireSucess) {
if (barcode == null || target == null) { if ("0".equals(barcode) || "null".equals(barcode)) {
notCreateInstMessage = "管芯规格或库位为空"; notCreateInstMessage = "管芯规格或库位为空";
} else { } else {
if (error == 2) { if (error2 == 2) {
errorDispose(PointErrorTypeEnum.IN.getCode(),null); errorDispose(PointErrorTypeEnum.IN.getCode(), null);
} else { } else {
Instruction instruction = checkInst(); Instruction instruction = checkInst();
if (instruction == null) { if (instruction == null) {
feedMessage = "universal_feedMessage4"; feedMessage = "universal_feedMessage4";
} }
errorDispose(PointErrorTypeEnum.OUT.getCode(),instruction.getTask_code()); errorDispose(PointErrorTypeEnum.OUT.getCode(), instruction);
} }
} }
@@ -337,13 +319,55 @@ public class PipeCoreRackManipulatorDeviceDriver extends AbstractOpcDeviceDriver
last_to_type = to_type; last_to_type = to_type;
} }
private void errorDispose(Integer code, String taskCode) { private void inFinish() {
JSONObject jsonObject = new JSONObject();
if (target != null) {
DeviceDto byAdress = deviceService.findByAdress(target);
jsonObject.put("device_code", byAdress.getDevice_code());
} else {
message = "目标点位为空";
}
jsonObject.put("barcode", barcode);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content("管芯入库申请放货完成,参数:" + jsonObject)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
String response = acsToWmsService.feedbackTubeInStorageComplete(jsonObject);
JSONObject jo = JSON.parseObject(response);
if (jo.getInteger("status") == 200) {
LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code(device_code)
.content("管芯入库申请放货完成,参数,接口返回:" + jo)
.build();
logDto2.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto2);
Map<String, Object> map1 = new HashMap<>();
List list = new ArrayList();
map1.put("code", "to_command");
map1.put("value", 6);
list.add(map1);
this.writing(list);
message = "universal_message1";
this.actionRequireSucess = true;
}
}
private void errorDispose(Integer code, Instruction inst) {
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
param.put("barcode", barcode); param.put("barcode", barcode);
param.put("target", target); if (target != null) {
DeviceDto byAdress = deviceService.findByAdress(target);
param.put("target", byAdress.getDevice_code());
} else {
param.put("target", inst.getNext_device_code());
}
param.put("type", code); param.put("type", code);
param.put("task_code", taskCode); if (inst != null) {
param.put("task_code", inst.getTask_code());
}
LuceneLogDto logDto = LuceneLogDto.builder() LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code) .device_code(device_code)
.content("管芯库满入或空出请求lms,参数:" + param) .content("管芯库满入或空出请求lms,参数:" + param)
@@ -359,29 +383,25 @@ public class PipeCoreRackManipulatorDeviceDriver extends AbstractOpcDeviceDriver
.build(); .build();
logDto2.setLog_level(4); logDto2.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto2); luceneExecuteLogService.deviceExecuteLog(logDto2);
Device gxDevice = deviceAppService.findDeviceByCode(jo.getString("device_code"));
String targetAddress = gxDevice.getExtraValue().get("address").toString();
Map<String, Object> map1 = new HashMap<>();
Map<String, Object> map2 = new HashMap<>();
List list = new ArrayList(); List list = new ArrayList();
if (error == 2) { if (error2 == 2) {
Map<String, Object> map1 = new HashMap<>();
map1.put("code", "to_command"); map1.put("code", "to_command");
map1.put("value", 7); map1.put("value", 7);
list.add(map1); list.add(map1);
Map<String, Object> map2 = new HashMap<>();
map2.put("code", "to_new_target");
map2.put("value", jo.getInteger("target"));
list.add(map1);
this.writing(list);
} }
if (error == 3) { if (error2 == 3) {
Map<String, Object> map1 = new HashMap<>();
map1.put("code", "to_command"); map1.put("code", "to_command");
map1.put("value", 8); map1.put("value", 8);
list.add(map1); list.add(map1);
Map<String, Object> map2 = new HashMap<>();
map2.put("code", "to_new_target");
map2.put("value", jo.getInteger("target"));
list.add(map1);
this.writing(list);
} }
map2.put("code", "to_new_target");
map2.put("value", targetAddress);
list.add(map2);
this.writing(list);
this.actionRequireSucess = true; this.actionRequireSucess = true;
} else { } else {
LuceneLogDto logDto2 = LuceneLogDto.builder() LuceneLogDto logDto2 = LuceneLogDto.builder()
@@ -614,7 +634,7 @@ public class PipeCoreRackManipulatorDeviceDriver extends AbstractOpcDeviceDriver
Map<String, Object> map3 = new HashMap<>(); Map<String, Object> map3 = new HashMap<>();
Map<String, Object> map4 = new HashMap<>(); Map<String, Object> map4 = new HashMap<>();
try { try {
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(),interactionJsonDTO); pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), interactionJsonDTO);
} catch (Exception e) { } catch (Exception e) {
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:" logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code() + instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
@@ -665,7 +685,7 @@ public class PipeCoreRackManipulatorDeviceDriver extends AbstractOpcDeviceDriver
map4.put("code", "to_task"); map4.put("code", "to_task");
map4.put("value", task); map4.put("value", task);
list.add(map4); list.add(map4);
if (interactionJsonDTO != null){ if (interactionJsonDTO != null) {
Map<String, Object> map5 = new HashMap<>(); Map<String, Object> map5 = new HashMap<>();
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLen())) { if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLen())) {
map5.put("code", "to_length"); map5.put("code", "to_length");

View File

@@ -727,14 +727,15 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
if (!ObjectUtil.isEmpty(num)) { if (!ObjectUtil.isEmpty(num)) {
map.put("to_num", num); map.put("to_num", num);
} }
List<StorageCell> storageCodes = storageCellMapper.selectList(new QueryWrapper<StorageCell>().in("storage_code", targets));
if (!storageCodes.isEmpty()) { for (int i = 0; i < targets.size(); i++) {
for (int i = 0; i < storageCodes.size(); i++){ Device gxDevice = deviceAppService.findDeviceByCode(targets.get(i));
map.put("to_target" + (i + 1), storageCodes.get(i).getAddress()); String targetAddress = gxDevice.getExtraValue().get("address").toString();
} map.put("to_target" + (i + 1), targetAddress);
map.put("to_command", 1); }
pipeCoreRackStationDeviceDriver.writing(map); map.put("to_command", 1);
} pipeCoreRackStationDeviceDriver.writing(map);
} }
JSONObject resultJson = new JSONObject(); JSONObject resultJson = new JSONObject();
resultJson.put("status", HttpStatus.OK.value()); resultJson.put("status", HttpStatus.OK.value());

View File

@@ -100,12 +100,10 @@ public class NbjOperationServiceImpl implements NbjOperationService {
} }
sysNoticeService.createNotice("点位" + deviceCode + "出现" + ("1".equals(type) ? "-满入" : "-空出") + ",请解决", sysNoticeService.createNotice("点位" + deviceCode + "出现" + ("1".equals(type) ? "-满入" : "-空出") + ",请解决",
deviceCode + ("1".equals(type) ? "-满入" : "-空出") + "点位切换", NoticeTypeEnum.NOTIFICATION.getCode()); deviceCode + ("1".equals(type) ? "-满入" : "-空出") + "点位切换", NoticeTypeEnum.NOTIFICATION.getCode());
JSONObject data = new JSONObject();
data.put("device_code", point.getPoint_code());
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
result.put("status", HttpStatus.OK.value()); result.put("status", HttpStatus.OK.value());
result.put("message", "满入空出异常处理请求成功!"); result.put("message", "满入空出异常处理请求成功!");
result.put("data", data); result.put("device_code", point.getPoint_code());
return result; return result;
} }
} }