add: lms、acs管芯库联调
This commit is contained in:
@@ -132,6 +132,14 @@ public interface DeviceService extends CommonService<Device> {
|
||||
*/
|
||||
DeviceDto findByCode(String code);
|
||||
|
||||
/**
|
||||
* 根据电器调度号查询
|
||||
*
|
||||
* @param adress code
|
||||
* @return Device
|
||||
*/
|
||||
DeviceDto findByAdress(String adress);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
|
||||
@@ -290,6 +290,15 @@ public class DeviceServiceImpl extends CommonServiceImpl<DeviceMapper, Device> i
|
||||
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
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void create(DeviceDto dto) {
|
||||
|
||||
@@ -33,6 +33,11 @@ public class ItemProtocol {
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
public int getError2() {
|
||||
return this.getOpcIntegerValue(item_error2);
|
||||
}
|
||||
|
||||
|
||||
public int getWalk_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_action, "动作信号", "DB1.B3"));
|
||||
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_barcode, "管芯规格", "DB1.B7"));
|
||||
list.add(new ItemDto(item_target, "库位", "DB1.B7"));
|
||||
|
||||
@@ -12,7 +12,10 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.common.base.CommonFinalParam;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
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.DeviceServiceImpl;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.FeedLmsRealFailed;
|
||||
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.route.service.RouteLineService;
|
||||
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.TaskStatusEnum;
|
||||
import org.nl.acs.task.enums.TaskTypeEnum;
|
||||
@@ -74,10 +76,11 @@ public class PipeCoreRackManipulatorDeviceDriver extends AbstractOpcDeviceDriver
|
||||
DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class);
|
||||
|
||||
DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
||||
|
||||
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean("luceneExecuteLogServiceImpl");
|
||||
|
||||
private StorageCellMapper storageCellMapper;
|
||||
|
||||
int mode = 0;
|
||||
int last_mode = 0;
|
||||
int move = 0;
|
||||
@@ -86,6 +89,9 @@ public class PipeCoreRackManipulatorDeviceDriver extends AbstractOpcDeviceDriver
|
||||
int last_action = 0;
|
||||
int error = 0;
|
||||
int last_error = 0;
|
||||
|
||||
int error2 = 0;
|
||||
int last_error2 = 0;
|
||||
int task = 0;
|
||||
int last_task = 0;
|
||||
|
||||
@@ -158,8 +164,6 @@ public class PipeCoreRackManipulatorDeviceDriver extends AbstractOpcDeviceDriver
|
||||
String inst_message;
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
@@ -173,6 +177,7 @@ public class PipeCoreRackManipulatorDeviceDriver extends AbstractOpcDeviceDriver
|
||||
move = this.itemProtocol.getMove();
|
||||
action = this.itemProtocol.getAction();
|
||||
error = this.itemProtocol.getError();
|
||||
error2 = this.itemProtocol.getError2();
|
||||
heartbeat = this.itemProtocol.getHeartbeat();
|
||||
barcode = this.itemProtocol.getBarcode();
|
||||
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 {
|
||||
// logServer.deviceExecuteLog(this.device_code, "", "", "放货完成");
|
||||
// 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);
|
||||
|
||||
inFinish();
|
||||
} catch (Exception e) {
|
||||
message = "universal_message2";
|
||||
e.printStackTrace();
|
||||
@@ -246,22 +228,22 @@ public class PipeCoreRackManipulatorDeviceDriver extends AbstractOpcDeviceDriver
|
||||
message = "universal_off-line";
|
||||
|
||||
//有报警
|
||||
} else if (error != 0) {
|
||||
} else if (error2 != 0 || error != 0) {
|
||||
this.setIserror(true);
|
||||
message = "universal_message3";
|
||||
//满入空出分配新点位
|
||||
if ((error == 2 || error == 3) && !actionRequireSucess) {
|
||||
if (barcode == null || target == null) {
|
||||
if ((error2 == 2 || error2 == 3) && !actionRequireSucess) {
|
||||
if ("0".equals(barcode) || "null".equals(barcode)) {
|
||||
notCreateInstMessage = "管芯规格或库位为空";
|
||||
} else {
|
||||
if (error == 2) {
|
||||
errorDispose(PointErrorTypeEnum.IN.getCode(),null);
|
||||
if (error2 == 2) {
|
||||
errorDispose(PointErrorTypeEnum.IN.getCode(), null);
|
||||
} else {
|
||||
Instruction instruction = checkInst();
|
||||
if (instruction == null) {
|
||||
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;
|
||||
}
|
||||
|
||||
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();
|
||||
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("task_code", taskCode);
|
||||
if (inst != null) {
|
||||
param.put("task_code", inst.getTask_code());
|
||||
}
|
||||
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||
.device_code(device_code)
|
||||
.content("管芯库满入或空出请求lms,参数:" + param)
|
||||
@@ -359,29 +383,25 @@ public class PipeCoreRackManipulatorDeviceDriver extends AbstractOpcDeviceDriver
|
||||
.build();
|
||||
logDto2.setLog_level(4);
|
||||
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();
|
||||
if (error == 2) {
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
if (error2 == 2) {
|
||||
map1.put("code", "to_command");
|
||||
map1.put("value", 7);
|
||||
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) {
|
||||
Map<String, Object> map1 = new HashMap<>();
|
||||
if (error2 == 3) {
|
||||
map1.put("code", "to_command");
|
||||
map1.put("value", 8);
|
||||
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;
|
||||
} else {
|
||||
LuceneLogDto logDto2 = LuceneLogDto.builder()
|
||||
@@ -614,7 +634,7 @@ public class PipeCoreRackManipulatorDeviceDriver extends AbstractOpcDeviceDriver
|
||||
Map<String, Object> map3 = new HashMap<>();
|
||||
Map<String, Object> map4 = new HashMap<>();
|
||||
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) {
|
||||
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + 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("value", task);
|
||||
list.add(map4);
|
||||
if (interactionJsonDTO != null){
|
||||
if (interactionJsonDTO != null) {
|
||||
Map<String, Object> map5 = new HashMap<>();
|
||||
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLen())) {
|
||||
map5.put("code", "to_length");
|
||||
|
||||
@@ -727,14 +727,15 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
if (!ObjectUtil.isEmpty(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 < storageCodes.size(); i++){
|
||||
map.put("to_target" + (i + 1), storageCodes.get(i).getAddress());
|
||||
}
|
||||
map.put("to_command", 1);
|
||||
pipeCoreRackStationDeviceDriver.writing(map);
|
||||
}
|
||||
|
||||
for (int i = 0; i < targets.size(); i++) {
|
||||
Device gxDevice = deviceAppService.findDeviceByCode(targets.get(i));
|
||||
String targetAddress = gxDevice.getExtraValue().get("address").toString();
|
||||
map.put("to_target" + (i + 1), targetAddress);
|
||||
}
|
||||
map.put("to_command", 1);
|
||||
pipeCoreRackStationDeviceDriver.writing(map);
|
||||
|
||||
}
|
||||
JSONObject resultJson = new JSONObject();
|
||||
resultJson.put("status", HttpStatus.OK.value());
|
||||
|
||||
Reference in New Issue
Block a user