add:新增lms业务接口

Signed-off-by: jiaoliming <dawnjiao@foxmail.com>
This commit is contained in:
jiaoliming
2023-09-01 10:10:36 +08:00
parent d7d4341684
commit ba52db4d18
5 changed files with 500 additions and 122 deletions

View File

@@ -39,6 +39,14 @@ public class WmsToAcsController {
return new ResponseEntity<>(wmstoacsService.createFromWms(tasks), HttpStatus.OK);
}
@PostMapping("/liKuTaskAgain")
@Log("接收LMS重新分配任务")
@ApiOperation("接收LMS重新分配任务")
@SaIgnore
public ResponseEntity<Object> createLiKuTask(@RequestBody List<JSONObject> tasks) {
return new ResponseEntity<>(wmstoacsService.createLiKuTaskAgain(tasks), HttpStatus.OK);
}
@PostMapping("/order")
@Log("wms下发acs工单")
@ApiOperation("wms下发acs工单")

View File

@@ -15,6 +15,14 @@ public interface WmsToAcsService {
*/
Map<String, Object> createFromWms(List<JSONObject> tasks);
/**
* lms重新分配liku任务
*
* @param tasks 条件
* @return
*/
Map<String, Object> createLiKuTaskAgain(List<JSONObject> tasks);
/**
* wms下发工单
*
@@ -162,4 +170,12 @@ public interface WmsToAcsService {
* @return Map<String, Object>
*/
Map<String, Object> cleaningIn(JSONObject param);
/**
* 下发电气信号(公用接口)
*
* @param param 条件
* @return Map<String, Object>
*/
Map<String, Object> writePlc(JSONObject param);
}

View File

@@ -109,5 +109,13 @@ public class AcsToLiKuServiceImpl implements AcsToLiKuService {
JSONObject jo = new JSONObject();
jo.put("code", 0);
jo.put("msg", "111");
UnloadContainerReqResponse unloadContainerReqResponse = new UnloadContainerReqResponse();
unloadContainerReqResponse.setAllow(false);
JSONObject result = new JSONObject();
result.put("code", "0");
result.put("msg", "success");
result.put("data", unloadContainerReqResponse);
log.info("放容器请求-----输出参数{}", JSON.toJSONString(result));
}
}

View File

@@ -2,14 +2,15 @@ package org.nl.acs.ext.wms.service.impl;
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.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.AcsConfig;
import org.nl.acs.device.address.service.AddressService;
import org.nl.acs.device_driver.basedriver.agv.liku_agv.LiKuDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_hr_ssx.HailiangHrSsxDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_hr_ssx.HailiangHrSsxDeviceDriver;
import org.nl.acs.ext.wms.RespUtil;
import org.nl.acs.ext.wms.liKuData.a.*;
import org.nl.acs.ext.wms.service.AcsToLiKuService;
@@ -19,11 +20,9 @@ import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.common.utils.StringUtils;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.modules.system.service.ParamService;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -41,19 +40,20 @@ import java.util.List;
@RequiredArgsConstructor
@Slf4j
public class LiKuToAcsServiceImpl implements LiKuToAcsService {
private final AddressService addressService;
private final TaskService taskService;
private final InstructionService instructionService;
private final DeviceAppService deviceAppService;
private final AcsToWmsService acsToWmsService;
private final AcsToLiKuService acsToLiKuService;
@Autowired
private AddressService addressService;
@Autowired
private TaskService taskService;
@Autowired
private InstructionService instructionService;
@Autowired
private DeviceAppService deviceAppService;
@Autowired
private AcsToWmsService acsToWmsService;
@Autowired
private AcsToLiKuService acsToLiKuService;
@Autowired
private ParamService paramService;
// DeviceAppService appService= SpringContextHolder.getBean(DeviceAppServiceImpl.class);
@@ -63,16 +63,14 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService {
@Override
public JSONObject queryConveyor(QueryConveyorRequest requestParam) throws Exception {
try{
log.info("查询输送线料箱状态-----输入参数{}", JSON.toJSONString(requestParam));
String conveyorCodes = requestParam.conveyorCodes;
NodeStates nodeStates=new NodeStates();
JSONObject result = new JSONObject();
try{
String conveyorCodes = requestParam.getConveyorCodes();
NodeStates nodeStates = new NodeStates();
List<NodeStates> list2 = new ArrayList<>();
Conveyors conveyors=new Conveyors();
JSONObject result = new JSONObject();
Device device=deviceAppService.findDeviceByCode(conveyorCodes);
result.put("code", "0");
result.put("msg", "success");
Conveyors conveyors = new Conveyors();
Device device = deviceAppService.findDeviceByCode(conveyorCodes);
QueryConveyorResponse queryConveyorResponse = new QueryConveyorResponse();
if (device != null && device.getDeviceDriver() instanceof HailiangHrSsxDeviceDriver) {
HailiangHrSsxDeviceDriver hailiangHrSsxDeviceDriver= (HailiangHrSsxDeviceDriver) device.getDeviceDriver();
@@ -82,23 +80,29 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService {
if (!ObjectUtil.isEmpty(device.getLocation())) {
nodeStates.setSlotCode(device.getDevice_code());
}
if (!ObjectUtil.equals(hailiangHrSsxDeviceDriver.getMove(),"1")) {
if (ObjectUtil.equals(hailiangHrSsxDeviceDriver.getMove(),"1")) {
nodeStates.setHasContainer(true);
}else { nodeStates.setHasContainer(false);}
}else {
nodeStates.setHasContainer(false);
}
}
list2.add(nodeStates);
conveyors.setNodeStates(list2);
List<Conveyors> list = new ArrayList<>();
queryConveyorResponse.setConveyors(list);
list.add(conveyors);
result.put("data", queryConveyorResponse);
log.info("查询输送线料箱状态-----输出参数{}", result);
return result;
} finally {
MDC.remove(log_file_type);
}
}
queryConveyorResponse.setConveyors(list);
result.put("code", "0");
result.put("msg", "success");
result.put("data", queryConveyorResponse);
}catch (Exception e) {
result.put("code", "1");
result.put("msg", "fail");
result.put("data", new JSONObject());
log.info("查询输送线料箱状态--------------:输出参数{}" , JSON.toJSONString(result));
}
log.info("查询输送线料箱状态,响应参数:{}", JSON.toJSONString(result));
return result;
}
@Override
public JSONObject queryNodeReader(QueryNodeReaderRequest requestParam) throws Exception {
try{
@@ -118,39 +122,60 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService {
@Override
public JSONObject loadContainerFinish(LoadContainerFinishRequest requestParam) throws Exception {
log.info("取容器完成通知-----输入参数{}", JSON.toJSONString(requestParam));
JSONObject result = new JSONObject();
try{
log.info("取容器完成通知-----输入参数{}", JSON.toJSONString(requestParam));
String slotCode = requestParam.slotCode;
String containerCode=requestParam.containerCode;
LoadContainerFinishResponse loadContainerFinishResponse = new LoadContainerFinishResponse();
JSONObject result = new JSONObject();
JSONObject json = (JSONObject) JSONObject.toJSON(loadContainerFinishResponse);
result.put("code", "0");
result.put("msg", "success");
result.put("data", json);
log.info("取容器完成通知-----输出参数{}", result);
return result;
} finally {
MDC.remove(log_file_type);
// LoadContainerFinishResponse loadContainerFinishResponse = new LoadContainerFinishResponse();
Device device = deviceAppService.findDeviceByCode(slotCode);
if (device != null && device.getDeviceDriver() instanceof HailiangHrSsxDeviceDriver) {
HailiangHrSsxDeviceDriver hailiangHrSsxDeviceDriver= (HailiangHrSsxDeviceDriver) device.getDeviceDriver();
//下发输送线电气取货完成
hailiangHrSsxDeviceDriver.writing("to_command","2");
// JSONObject json = (JSONObject) JSONObject.toJSON(loadContainerFinishResponse);
result.put("code", "0");
result.put("msg", "success");
result.put("data", new JSONObject());
}
}catch (Exception e) {
result.put("code", "1");
result.put("msg", "fail");
result.put("data", new JSONObject());
log.info("取容器完成通知--------------:输出参数{}" , JSON.toJSONString(result));
}
log.info("取容器完成通知-----输出参数{}", JSON.toJSONString(result));
return result;
}
@Override
public JSONObject unloadContainerReq(UnloadContainerReqRequest requestParam) throws Exception {
log.info("放容器请求-----输入参数{}", JSON.toJSONString(requestParam));
UnloadContainerReqResponse unloadContainerReqResponse = new UnloadContainerReqResponse();
JSONObject result = new JSONObject();
try{
log.info("放容器请求-----输入参数{}", JSON.toJSONString(requestParam));
String slotCode = requestParam.slotCode;
String containerCode=requestParam.containerCode;
UnloadContainerReqResponse unloadContainerReqResponse = new UnloadContainerReqResponse();
JSONObject result = new JSONObject();
Device device = deviceAppService.findDeviceByCode(slotCode);
if (device != null && device.getDeviceDriver() instanceof HailiangHrSsxDeviceDriver) {
HailiangHrSsxDeviceDriver hailiangHrSsxDeviceDriver= (HailiangHrSsxDeviceDriver) device.getDeviceDriver();
if (hailiangHrSsxDeviceDriver.getAction() == 2){
unloadContainerReqResponse.setAllow(true);
}else{
unloadContainerReqResponse.setAllow(false);
}
}
result.put("code", "0");
result.put("msg", "success");
result.put("data", unloadContainerReqResponse);
log.info("放容器请求-----输出参数{}", result);
return result;
} finally {
MDC.remove(log_file_type);
} catch (Exception e) {
result.put("code", "1");
result.put("msg", "fail");
result.put("data", new JSONObject());
log.info("放容器请求--------------:输出参数{}" , JSON.toJSONString(result));
}
log.info("放容器请求-----输出参数{}", JSON.toJSONString(result));
return result;
}
@Override
@@ -198,9 +223,9 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService {
try{
log.info("任务状态上报-----输入参数{}", JSON.toJSONString(requestParam));
String inst_id = requestParam.getTaskCode();
String eventType=requestParam.getEventType();
String status=requestParam.getStatus();
String carNo=requestParam.getRobotCode();
String eventType = requestParam.getEventType();
String status = requestParam.getStatus();
String carNo = requestParam.getRobotCode();
Instruction inst = instructionService.findById(inst_id);
if (ObjectUtil.isEmpty(inst)) {
TaskstatusReportingResponse taskstatusReportingResponse = new TaskstatusReportingResponse();
@@ -208,7 +233,7 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService {
result.put("result", "false");
result.put("code", "0");
result.put("comment", "未找到对应指令");
result.put("data", taskstatusReportingResponse );
result.put("data", taskstatusReportingResponse);
log.info("任务状态上报-----输出参数{}", result);
return RespUtil.getResp(result.toString(), new TaskstatusReportingResponse());
}
@@ -301,8 +326,33 @@ public class LiKuToAcsServiceImpl implements LiKuToAcsService {
try{
log.info("异常上报-----输入参数{}", JSON.toJSONString(requestParam));
String eventType=requestParam.getEventType();
if(StrUtil.equals(eventType,"location_abnormal") || StrUtil.equals(eventType,"robot_abnormal") ){
if(StrUtil.equals(eventType,"location_abnormal") || StrUtil.equals(eventType,"robot_abnormal") ){
//异常描述
String message = requestParam.getMessage();
if (StrUtil.equals(message,"TRY_ACTION_LOCATION_ALREADY_LOADING_CONTAINER")){
// 判断是否为WMS下发的任务如果是反馈任务状态给WMS
String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue();
// if (!StrUtil.startWith(dto.getTask_code(), "-") && StrUtil.equals(hasWms, "1")) {
// JSONObject feed_jo = new JSONObject();
// feed_jo.put("task_id", entity.getExt_task_id());
// feed_jo.put("status", dto.getTask_status());
// if (ObjectUtil.isNotEmpty(dto.getQuantity())) {
// feed_jo.put("quantity", dto.getQuantity());
// }
// if (ObjectUtil.isNotEmpty(dto.getVehicle_code())) {
// feed_jo.put("vehicle_code", dto.getVehicle_code());
// }
// if (ObjectUtil.isNotEmpty(dto.getWeight())) {
// feed_jo.put("weight", dto.getWeight());
// }
// feed_jo.put("ext_param", dto.getExt_param());
// JSONArray ja = new JSONArray();
// ja.add(feed_jo);
// HttpResponse httpResponse = acsToWmsService.feedbackTaskStatusToWms(ja);
// this.taskFeedbackAdd(httpResponse, dto);
// }
}
}
AbnormarReportingResponse abnormarReportingResponse = new AbnormarReportingResponse();
JSONObject result = new JSONObject();

View File

@@ -13,7 +13,6 @@ import org.nl.acs.AcsConfig;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.basedriver.hailiang_one.IssuedDeviceOrderInfo;
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_auto_cache_line.HailiangAutoCacheLineDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_feeding_line.HailiangCleaningFeedingLineDriver;
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_machine_storage_station.HailiangCleaningMachineStorageStationDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_put_line.HailiangCleaningPutLineDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_in.HailiangEngravingInDeviceDriver;
@@ -44,13 +43,11 @@ import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.system.service.ParamService;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -85,6 +82,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
String task_id = task.getString("task_id");
String task_code = task.getString("task_code");
String task_type = task.getString("task_type");
String storage_task_type = task.getString("storage_task_type");
String task_group_id = task.getString("task_group_id");
String is_send = task.getString("is_send");
String start_point_code = task.getString("start_point_code");
@@ -183,24 +181,41 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
if (hailiangEngravingInDeviceDriver.getGd_move() == 0) {
JSONObject json = new JSONObject();
json.put("task_id", task_id);
json.put("message", "上面无料框!请核实后再点击按钮!");
json.put("message", "->上面无料框!请核实后再点击按钮!");
errArr.add(json);
continue;
}
}
}
if (StrUtil.equals(put_point_code,"A1_KZ_SL")) {
Device device = deviceAppService.findDeviceByCode(put_point_code);
if (StrUtil.equals(next_point_code,"A1_KZ_SL")) {
Device device = deviceAppService.findDeviceByCode(next_point_code);
HailiangEngravingInDeviceDriver hailiangEngravingInDeviceDriver;
if (device.getDeviceDriver() instanceof HailiangEngravingInDeviceDriver) {
hailiangEngravingInDeviceDriver = (HailiangEngravingInDeviceDriver) device.getDeviceDriver();
if (hailiangEngravingInDeviceDriver.getGd_move() == 1) {
JSONObject json = new JSONObject();
json.put("task_id", task_id);
json.put("message", "上面有料框!请核实后再点击按钮!");
json.put("message", "->已有料框!请核实后再点击按钮!");
errArr.add(json);
continue;
}
if (StrUtil.equals(start_point_code,"A1_BCPRKW_SD")){
if (hailiangEngravingInDeviceDriver.getMode() == 1) {
JSONObject json = new JSONObject();
json.put("task_id", task_id);
json.put("message", "->请切换手动模式!");
errArr.add(json);
continue;
}
}else {
if (hailiangEngravingInDeviceDriver.getMode() == 0) {
JSONObject json = new JSONObject();
json.put("task_id", task_id);
json.put("message", "->请切换自动模式!");
errArr.add(json);
continue;
}
}
}
}
@@ -241,13 +256,15 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
jo.put("priority", priority);
jo.put("vehicle_code", vehicle_code);
jo.put("agv_system_type", agv_system_type);
jo.put("create_by", "mes");
jo.put("create_by", "lms");
jo.put("barcodeArr", barcodeArr);
jo.put("priority_floor", priority_floor);
jo.put("material_code", material_code);
jo.put("quantity", quantity);
jo.put("qtyArr", qtyArr);
jo.put("task_type", StrUtil.isEmpty(task_type) ? 1 : Integer.parseInt(task_type));
jo.put("storage_task_type", StrUtil.isEmpty(storage_task_type) ? 1 : Integer.parseInt(storage_task_type));
TaskDto task_dto = jo.toJavaObject(TaskDto.class);
try {
taskService.create(task_dto);
@@ -310,7 +327,14 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
Map<String, Object> package_ext = param.getJSONObject("package_ext");
EalingOrderDto ealingOrderDto = new EalingOrderDto();
// UnboxingOrderDto unboxingOrderDto = null;
String one_box_package_qty = "";
String package_qty = "";
String one_package_qty = "";
String box_num = "";
String box_type = "";
String target_roadway = "";
String is_flip = "";
String tray_full_num = "";
if (ObjectUtil.isNotEmpty(package_ext)) {
//是否启用封箱线
is_used_fxx = ObjectUtil.isEmpty(package_ext.get("is_used_fxx")) ? null : package_ext.get("is_used_fxx").toString();
@@ -319,16 +343,10 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
ealingOrderDto.setOrder_box_num(ObjectUtil.isEmpty(package_ext.get("demol_num")) ? null : package_ext.get("demol_num").toString());
//装箱模版
ealingOrderDto.setTemplate_no(ObjectUtil.isEmpty(package_ext.get("package_model")) ? null : package_ext.get("package_model").toString());
//码盘模版
lane_tray_template= ObjectUtil.isEmpty(package_ext.get("stack_model")) ? null : package_ext.get("stack_model").toString();
//是否正反转
ealingOrderDto.setIs_foreward(ObjectUtil.isEmpty(package_ext.get("is_foreward")) ? null : package_ext.get("is_foreward").toString());
//总袋数
ealingOrderDto.setOrder_bag_num(ObjectUtil.isEmpty(package_ext.get("order_bag_num")) ? null : package_ext.get("order_bag_num").toString());
//装箱机设备
ealing_device_code = ObjectUtil.isEmpty(package_ext.get("ealing_device_code")) ? null : package_ext.get("ealing_device_code").toString();
//开箱机设备
unboxing_device_code = ObjectUtil.isEmpty(package_ext.get("unboxing_device_code")) ? null : package_ext.get("unboxing_device_code").toString();
//封箱机是否自动确认(1:自动确认 2定时确认 3人工确认)
ealingOrderDto.setIs_auto_confirm(ObjectUtil.isEmpty(package_ext.get("auto_confirm")) ? null : package_ext.get("auto_confirm").toString());
//确认时间
@@ -339,17 +357,32 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
ealingOrderDto.setOne_box_weight(ObjectUtil.isEmpty(package_ext.get("demol_weight")) ? null : package_ext.get("demol_weight").toString());
//每袋重量
ealingOrderDto.setOne_bag_weight(ObjectUtil.isEmpty(package_ext.get("one_bag_weight")) ? null : package_ext.get("one_bag_weight").toString());
//后期下面参数为准
//装箱机设备
ealing_device_code = ObjectUtil.isEmpty(package_ext.get("ealing_device_code")) ? null : package_ext.get("ealing_device_code").toString();
//开箱机设备
unboxing_device_code = ObjectUtil.isEmpty(package_ext.get("unboxing_device_code")) ? null : package_ext.get("unboxing_device_code").toString();
//每箱袋数
one_box_package_qty = ObjectUtil.isEmpty(package_ext.get("one_bag_num")) ? null : package_ext.get("one_bag_num").toString();
//袋数
package_qty = ObjectUtil.isEmpty(package_ext.get("order_bag_num")) ? null : package_ext.get("order_bag_num").toString();
//每袋数量
one_package_qty = ObjectUtil.isEmpty(package_ext.get("one_bag_weight")) ? null : package_ext.get("one_bag_weight").toString();
//箱数
box_num = ObjectUtil.isEmpty(package_ext.get("demol_num")) ? null : package_ext.get("demol_num").toString();
//目标巷道
// target_roadway = ObjectUtil.isEmpty(extra_map.get("target_roadway")) ? null : extra_map.get("target_roadway").toString();
//是否翻转
is_flip = ObjectUtil.isEmpty(package_ext.get("is_foreward")) ? null : package_ext.get("is_foreward").toString();
//托盘满托数量
tray_full_num = ObjectUtil.isEmpty(package_ext.get("tray_full_num")) ? null : package_ext.get("tray_full_num").toString();
//码盘模版
lane_tray_template = ObjectUtil.isEmpty(package_ext.get("stack_model")) ? null : package_ext.get("stack_model").toString();
//码盘数量
tray_num = ObjectUtil.isEmpty(package_ext.get("tray_num")) ? null : package_ext.get("tray_num").toString();
}
ealingOrderDto.setOrder_code(workorder_code);
String one_box_package_qty = "";
String package_qty = "";
String one_package_qty = "";
String box_num = "";
String box_type = "";
String target_roadway = "";
String is_flip = "";
String tray_full_num = "";
if (ObjectUtil.isNotEmpty(extra_map)) {
//老车间包装工单信息
//每箱袋数
@@ -368,8 +401,9 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
is_flip = ObjectUtil.isEmpty(extra_map.get("is_flip")) ? null : extra_map.get("is_flip").toString();
//托盘满托数量
tray_full_num = ObjectUtil.isEmpty(extra_map.get("tray_full_num")) ? null : extra_map.get("tray_full_num").toString();
//
//码垛模板号
lane_tray_template = ObjectUtil.isEmpty(extra_map.get("lane_tray_template")) ? null : extra_map.get("lane_tray_template").toString();
//码盘数量
tray_num = ObjectUtil.isEmpty(extra_map.get("tray_num")) ? null : extra_map.get("tray_num").toString();
}
@@ -453,7 +487,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
dto.setIs_flip(is_flip);
dto.setTray_full_num(tray_full_num);
dto.setEalingOrderDto(ealingOrderDto);
dto.setCreate_by("mes");
dto.setCreate_by("lms");
dto.setTray_num(tray_num);
dto.setLane_tray_template(lane_tray_template);
try {
@@ -727,7 +761,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
//更改工单设备号
produceshiftorderDto.setDevice_code(new_device_code);
produceshiftorderDto.setUpdate_time(now);
produceshiftorderDto.setUpdate_by("mes");
produceshiftorderDto.setUpdate_by("lms");
produceshiftorderService.updateByOrderCode(produceshiftorderDto);
//将新设备中的报工数量Report_qty更改为上个设备生产的数量
@@ -1311,7 +1345,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
hailiangCleaningPutLineDeviceDriver = (HailiangCleaningPutLineDeviceDriver) device.getDeviceDriver();
resultJson.put("in_pcsn", hailiangCleaningPutLineDeviceDriver.getIn_pcsn());
resultJson.put("vechile_code", hailiangCleaningPutLineDeviceDriver.getBarcode());
resultJson.put("weight", hailiangCleaningPutLineDeviceDriver.getFull_weight());
resultJson.put("weight", hailiangCleaningPutLineDeviceDriver.getNow_weight());
}
resultJson.put("status", 200);
resultJson.put("message", "操作成功");
@@ -1319,54 +1353,119 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
return resultJson;
}
// @Override
// public Map<String, Object> engravingIn(JSONObject param) {
// log.info("接收WMS刻字上料,下发参数:{}", JSON.toJSONString(param));
// String start_device_code = param.getString("start_point_code");
// String to_sort_array = param.getString("to_sort_array");
// String to_devices_array = param.getString("to_devices_array");
// String to_weight_array = param.getString("to_weight_array");
// //上料总重量
// String all_weight = param.getString("all_weight");
// String to_task = param.getString("task_code");
// if (StrUtil.isEmpty(start_device_code)) {
// throw new BadRequestException("设备号不能为空!");
// }
// Device device = deviceAppService.findDeviceByCode(start_device_code);
// if (ObjectUtil.isEmpty(device)) {
// throw new BadRequestException("未找到对应设备:" + start_device_code);
// }
// JSONObject resultJson = new JSONObject();
// //刻字上料
// HailiangEngravingInDeviceDriver hailiangEngravingInDeviceDriver;
// if (device.getDeviceDriver() instanceof HailiangEngravingInDeviceDriver) {
// hailiangEngravingInDeviceDriver = (HailiangEngravingInDeviceDriver) device.getDeviceDriver();
// String[] sort = to_sort_array.split(",");
// for (int i=0;i< sort.length;i++){
// hailiangEngravingInDeviceDriver.writing("to_sort"+(i+1),sort[i]);
// }
// String[] devices = to_devices_array.split(",");
// for (int i=0;i< devices.length;i++){
// String[] device_i = devices[i].split("_");
// hailiangEngravingInDeviceDriver.writing("to_devices"+(i+1),device_i[device_i.length-1]);
// }
// String[] weight = to_weight_array.split(",");
// for (int i=0;i< weight.length;i++){
// hailiangEngravingInDeviceDriver.writing("to_weight"+(i+1),weight[i]);
// }
// hailiangEngravingInDeviceDriver.writing("to_all_weight", all_weight);
//// hailiangEngravingInDeviceDriver.writing("to_all_weight",String.valueOf(hailiangEngravingInDeviceDriver.getEngraving_storage_now_weight()));
// hailiangEngravingInDeviceDriver.writing("to_task",to_task);
// }
// // TODO 反馈mes
// JSONObject reqParam = new JSONObject();
// reqParam.put("task_code", to_task);
// reqParam.put("status", StatusEnum.TASK_RUNNING.getCode());
// HttpResponse httpResponse = acsToWmsService.washTask(reqParam);
//
// resultJson.put("status", 200);
// resultJson.put("message", "操作成功");
// log.info("接收WMS刻字上料成功,响应参数:{}", JSON.toJSONString(resultJson));
// return resultJson;
// }
@Override
public Map<String, Object> engravingIn(JSONObject param) {
log.info("接收WMS刻字上料,下发参数:{}", JSON.toJSONString(param));
log.info("接收WMS刻字输送线任务,下发参数:{}", JSON.toJSONString(param));
String start_device_code = param.getString("start_point_code");
String to_sort_array = param.getString("to_sort_array");
String to_devices_array = param.getString("to_devices_array");
String to_weight_array = param.getString("to_weight_array");
//上料总重量
String all_weight = param.getString("all_weight");
String to_task = param.getString("task_code");
String task_code = param.getString("task_code");
// String[] in_devices = param.getString("in_devices").split(",");
JSONArray errArr = new JSONArray();
if (StrUtil.isEmpty(start_device_code)) {
throw new BadRequestException("设备号不能为空!");
}
Device device = deviceAppService.findDeviceByCode(start_device_code);
if (ObjectUtil.isEmpty(device)) {
throw new BadRequestException("未找到对应设备:" + start_device_code);
throw new BadRequestException("未找到对应刻字上料设备:" + start_device_code);
}
JSONObject resultJson = new JSONObject();
//刻字上料
HailiangEngravingInDeviceDriver hailiangEngravingInDeviceDriver;
if (device.getDeviceDriver() instanceof HailiangEngravingInDeviceDriver) {
hailiangEngravingInDeviceDriver = (HailiangEngravingInDeviceDriver) device.getDeviceDriver();
String[] sort = to_sort_array.split(",");
for (int i=0;i< sort.length;i++){
hailiangEngravingInDeviceDriver.writing("to_sort"+(i+1),sort[i]);
}
String[] devices = to_devices_array.split(",");
for (int i=0;i< devices.length;i++){
String[] device_i = devices[i].split("_");
hailiangEngravingInDeviceDriver.writing("to_devices"+(i+1),device_i[device_i.length-1]);
}
String[] weight = to_weight_array.split(",");
for (int i=0;i< weight.length;i++){
hailiangEngravingInDeviceDriver.writing("to_weight"+(i+1),weight[i]);
}
hailiangEngravingInDeviceDriver.writing("to_all_weight", all_weight);
// hailiangEngravingInDeviceDriver.writing("to_all_weight",String.valueOf(hailiangEngravingInDeviceDriver.getEngraving_storage_now_weight()));
hailiangEngravingInDeviceDriver.writing("to_task",to_task);
}
// TODO 反馈mes
JSONObject reqParam = new JSONObject();
reqParam.put("task_code", to_task);
reqParam.put("status", StatusEnum.TASK_RUNNING.getCode());
HttpResponse httpResponse = acsToWmsService.washTask(reqParam);
resultJson.put("status", 200);
resultJson.put("message", "操作成功");
log.info("接收WMS刻字上料成功,响应参数:{}", JSON.toJSONString(resultJson));
JSONObject resultJson = new JSONObject();
ProduceshiftorderDto dto = new ProduceshiftorderDto();
dto.setExt_order_id(task_code);
dto.setOrder_code(task_code);
dto.setQty(BigDecimal.valueOf(Long.parseLong(all_weight)));
dto.setMaterial_code("KZSL");
dto.setDevice_code(start_device_code);
dto.setIs_needmove("0");
dto.setIn_devices(to_devices_array);
dto.setCreate_by("lms");
dto.setMaterial_name(to_sort_array);
dto.setMaterial_spec(to_weight_array);
try {
HailiangEngravingInDeviceDriver hailiangEngravingInDeviceDriver;
if (device.getDeviceDriver() instanceof HailiangEngravingInDeviceDriver) {
hailiangEngravingInDeviceDriver = (HailiangEngravingInDeviceDriver) device.getDeviceDriver();
if (hailiangEngravingInDeviceDriver.getMode() == 0) {
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("message", "->请切换自动模式!");
errArr.add(json);
}else if (hailiangEngravingInDeviceDriver.getMode() == 1){
produceshiftorderService.create(dto);
}
}
} catch (Exception e) {
e.printStackTrace();
JSONObject json = new JSONObject();
json.put("task_code", task_code);
json.put("message", e.getMessage());
errArr.add(json);
}
if (ObjectUtil.isEmpty(errArr)) {
resultJson.put("status", 200);
} else {
resultJson.put("status", 400);
}
resultJson.put("errArr", errArr);
resultJson.put("message", errArr.size() > 0 ? "存在下发未成功的刻字输送线任务!" : "操作成功!");
resultJson.put("data", new JSONObject());
log.info("接收wms下发刻字输送线任务,响应参数:{}", JSON.toJSONString(resultJson));
return resultJson;
}
@@ -1460,7 +1559,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
dto.setDevice_code(device_code);
dto.setIs_needmove("0");
dto.setIn_devices(in_devices);
dto.setCreate_by("mes");
dto.setCreate_by("lms");
try {
produceshiftorderService.create(dto);
} catch (Exception e) {
@@ -1481,4 +1580,201 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
log.info("接收wms下发清洗下料,响应参数:{}", JSON.toJSONString(resultJson));
return resultJson;
}
@Override
public Map<String, Object> writePlc(JSONObject param) {
log.info("接收WMS下发电气,下发参数:{}", JSON.toJSONString(param));
String device_code = param.getString("device_code");
List<JSONObject> extArray = (List<JSONObject>) param.get("extArray");
if (StrUtil.isEmpty(device_code)) {
throw new BadRequestException("设备号不能为空!");
}
Device device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device)) {
throw new BadRequestException("未找到对应设备:" + device_code);
}
for (int i = 0; i < extArray.size(); i++) {
JSONObject object = (JSONObject) extArray.get(i);
}
JSONObject resultJson = new JSONObject();
//清洗下料
HailiangCleaningPutLineDeviceDriver hailiangCleaningPutLineDeviceDriver;
if (device.getDeviceDriver() instanceof HailiangCleaningPutLineDeviceDriver) {
hailiangCleaningPutLineDeviceDriver = (HailiangCleaningPutLineDeviceDriver) device.getDeviceDriver();
hailiangCleaningPutLineDeviceDriver.writing("","");
}
resultJson.put("status", 200);
resultJson.put("message", "操作成功");
log.info("接收WMS清洗下料成功,响应参数:{}", JSON.toJSONString(resultJson));
return resultJson;
}
@Override
public Map<String, Object> createLiKuTaskAgain(List<JSONObject> tasks) {
log.info("接收lms重新分配海柔任务,下发参数:{}", JSON.toJSONString(tasks));
JSONObject resultJson = new JSONObject();
try {
JSONArray errArr = new JSONArray();
for (int i = 0; i < tasks.size(); i++) {
JSONObject task = tasks.get(i);
String task_id = task.getString("task_id");
String task_code = task.getString("task_code");
String task_type = task.getString("task_type");
String task_group_id = task.getString("task_group_id");
String is_send = task.getString("is_send");
String start_point_code = task.getString("start_point_code");
String next_point_code = task.getString("next_point_code");
String put_point_code = task.getString("put_point_code");
String priority = task.getString("priority");
String vehicle_code = task.getString("vehicle_code");
String agv_system_type = task.getString("agv_system_type");
String barcodeArr = task.getString("barcodeArr");
String priority_floor = task.getString("priority_floor");
String material_code = task.getString("material_code");
String quantity = task.getString("quantity");
String qtyArr = task.getString("qtyArr");
if (StrUtil.isEmpty(task_id)) {
JSONObject json = new JSONObject();
json.put("task_id", task_id);
json.put("message", "任务id不能为空");
errArr.add(json);
continue;
}
if (StrUtil.isEmpty(task_code)) {
JSONObject json = new JSONObject();
json.put("task_id", task_id);
json.put("message", "任务号不能为空");
errArr.add(json);
continue;
}
if (StrUtil.isEmpty(task_group_id)) {
JSONObject json = new JSONObject();
json.put("task_id", task_id);
json.put("message", "任务关联编号不能为空");
errArr.add(json);
continue;
}
if (StrUtil.isEmpty(task_type)) {
JSONObject json = new JSONObject();
json.put("task_id", task_id);
json.put("message", "任务类型不能为空");
errArr.add(json);
continue;
}
if (StrUtil.isEmpty(is_send)) {
JSONObject json = new JSONObject();
json.put("task_id", task_id);
json.put("message", "是否立刻下发AGV");
errArr.add(json);
continue;
}
if (StrUtil.isEmpty(start_point_code)) {
JSONObject json = new JSONObject();
json.put("task_id", task_id);
json.put("message", "起点不能为空");
errArr.add(json);
continue;
}
if (StrUtil.isEmpty(next_point_code)) {
JSONObject json = new JSONObject();
json.put("task_id", task_id);
json.put("message", "终点不能为空");
errArr.add(json);
continue;
}
if (taskService.findByCodeFromCache(task_code) != null) {
JSONObject json = new JSONObject();
json.put("task_id", task_id);
json.put("message", "不能存在相同的任务号:" + task_code);
errArr.add(json);
continue;
}
if (!StrUtil.isEmpty(vehicle_code)) {
TaskDto vehicle_dto = taskService.findByContainer(vehicle_code);
if (vehicle_dto != null) {
JSONObject json = new JSONObject();
json.put("task_id", task_id);
json.put("message", "已存在该载具的任务,载具号:" + vehicle_code + ",对应的任务号:" + task_code);
errArr.add(json);
continue;
}
}
String start_device_code = "";
String next_device_code = "";
JSONObject start_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + start_point_code + "'").uniqueResult(0);
if (!ObjectUtil.isEmpty(start_device_json)) {
start_point_code = (String) start_device_json.get("parent_storage_code") == null ? start_point_code : (String) start_device_json.get("storage_code");
}
JSONObject next_device_json = WQLObject.getWQLObject("acs_storage_cell").query("parent_storage_code ='" + next_point_code + "'").uniqueResult(0);
if (!ObjectUtil.isEmpty(next_device_json)) {
next_point_code = (String) next_device_json.get("parent_storage_code") == null ? next_point_code : (String) next_device_json.get("storage_code");
}
if (start_point_code.indexOf("-") > 0) {
String str[] = start_point_code.split("-");
start_device_code = str[0];
} else {
start_device_code = start_point_code;
}
if (next_point_code.indexOf("-") > 0) {
String str[] = next_point_code.split("-");
next_device_code = str[0];
} else {
next_device_code = next_point_code;
}
JSONObject jo = new JSONObject();
jo.put("task_code", task_code);
jo.put("ext_task_id", task_id);
jo.put("link_num", task_group_id);
jo.put("is_send", is_send);
jo.put("start_point_code", start_point_code);
jo.put("start_device_code", start_device_code);
jo.put("next_point_code", next_point_code);
jo.put("next_device_code", next_device_code);
jo.put("put_point_code", put_point_code);
jo.put("put_device_code", put_point_code);
jo.put("priority", priority);
jo.put("vehicle_code", vehicle_code);
jo.put("agv_system_type", agv_system_type);
jo.put("create_by", "lms");
jo.put("barcodeArr", barcodeArr);
jo.put("priority_floor", priority_floor);
jo.put("material_code", material_code);
jo.put("quantity", quantity);
jo.put("qtyArr", qtyArr);
jo.put("task_type", StrUtil.isEmpty(task_type) ? 1 : Integer.parseInt(task_type));
TaskDto task_dto = jo.toJavaObject(TaskDto.class);
try {
taskService.create(task_dto);
} catch (Exception e) {
e.printStackTrace();
JSONObject json = new JSONObject();
json.put("task_id", task_id);
json.put("message", e.getMessage());
errArr.add(json);
}
}
if (ObjectUtil.isEmpty(errArr)) {
resultJson.put("status", 200);
} else {
resultJson.put("status", 400);
}
resultJson.put("errArr", errArr);
resultJson.put("message", errArr.size() > 0 ? "存在下发未成功的任务!" + JSON.toJSONString(errArr) : "下发成功!");
resultJson.put("data", new JSONObject());
log.info("createFromWms--------------:输出参数:" + resultJson.toString());
} catch (Exception e) {
resultJson.put("status", 400);
resultJson.put("errArr", new JSONArray());
resultJson.put("message", e.getMessage());
resultJson.put("data", new JSONObject());
log.info("createFromWms--------------:输出参数:" + resultJson.toString());
}
log.info("接收wms下发任务,响应参数:{}", JSON.toJSONString(resultJson));
return resultJson;
}
}