|
|
@ -1,6 +1,7 @@ |
|
|
|
package org.nl.wms.ext.acs.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
@ -8,12 +9,15 @@ import cn.hutool.core.util.StrUtil; |
|
|
|
import cn.hutool.http.HttpStatus; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.nl.common.enums.GoodsEnum; |
|
|
|
import org.nl.common.exception.BadRequestException; |
|
|
|
import org.nl.system.service.notice.ISysNoticeService; |
|
|
|
import org.nl.wms.cockpit.service.dao.DasDeviceFault; |
|
|
|
import org.nl.wms.cockpit.service.mapper.CockpitMapper; |
|
|
|
import org.nl.wms.database.vehicle.service.IMdBaseVehicleService; |
|
|
|
import org.nl.wms.database.vehicle.service.dao.MdBaseVehicle; |
|
|
|
import org.nl.wms.ext.acs.service.AcsToWmsService; |
|
|
|
import org.nl.wms.ext.acs.service.dto.to.BaseResponse; |
|
|
|
import org.nl.wms.ext.acs.service.dto.to.acs.AgainApplyResponse; |
|
|
@ -23,6 +27,7 @@ import org.nl.wms.ext.connector.service.WmsToConnectorService; |
|
|
|
import org.nl.wms.ext.connector.service.dto.ConnectorDto; |
|
|
|
import org.nl.wms.ext.record.service.ISysInteractRecordService; |
|
|
|
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; |
|
|
|
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup; |
|
|
|
import org.nl.wms.sch.point.service.ISchBasePointService; |
|
|
|
import org.nl.wms.sch.point.service.dao.SchBasePoint; |
|
|
|
import org.nl.wms.sch.task.service.ISchBaseTaskService; |
|
|
@ -34,6 +39,7 @@ import org.nl.wms.sch.task_manage.GeneralDefinition; |
|
|
|
import org.nl.wms.sch.task_manage.enums.NoticeTypeEnum; |
|
|
|
import org.nl.wms.sch.task_manage.task.TaskFactory; |
|
|
|
import org.nl.wms.sch.task_manage.task.core.TaskStatus; |
|
|
|
import org.nl.wms.sch.task_manage.task.core.TaskType; |
|
|
|
import org.nl.wms.sch.task_manage.task.tasks.mapper.PointMapper; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -67,7 +73,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
@Autowired |
|
|
|
private ISchBasePointService pointService; |
|
|
|
@Autowired |
|
|
|
private ISchBaseVehiclematerialgroupService vehiclematerialgroupService; |
|
|
|
private ISchBaseVehiclematerialgroupService iSchBaseVehiclematerialgroupService; |
|
|
|
@Autowired |
|
|
|
private TaskFactory taskFactory; |
|
|
|
@Autowired |
|
|
@ -82,6 +88,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
private WmsToConnectorService connectorService; |
|
|
|
@Autowired |
|
|
|
private ISchBaseTaskconfigService taskConfigService; |
|
|
|
@Autowired |
|
|
|
private IMdBaseVehicleService iMdBaseVehicleService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 初始化反射方法 |
|
|
@ -269,7 +277,10 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
if (ObjectUtil.isNotEmpty(param)) { |
|
|
|
String status = param.getString("status"); |
|
|
|
String task_code = param.getString("task_code"); |
|
|
|
// 1.connector;2.sorting
|
|
|
|
String is_connector = param.getString("is_connector"); |
|
|
|
String task_type = param.getString("task_type"); |
|
|
|
boolean is_empty = param.getBoolean("is_empty"); |
|
|
|
if (StrUtil.isEmpty(status) || StrUtil.isEmpty(task_code)) { |
|
|
|
throw new BadRequestException("状态或任务号为空!"); |
|
|
|
} |
|
|
@ -280,15 +291,15 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
switch (status) { |
|
|
|
case "1": |
|
|
|
//申请取货
|
|
|
|
requestPickup(schBaseTask, status); |
|
|
|
requestPickup(schBaseTask, status, is_connector); |
|
|
|
break; |
|
|
|
case "2": |
|
|
|
//取货完成
|
|
|
|
pickupComplete(schBaseTask, status, is_connector); |
|
|
|
pickupComplete(schBaseTask, status, is_connector, task_type); |
|
|
|
break; |
|
|
|
case "4": |
|
|
|
//放货完成
|
|
|
|
releaseComplete(schBaseTask, status); |
|
|
|
releaseComplete(schBaseTask, status, is_connector, task_type, is_empty); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
@ -297,15 +308,56 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Object feedAgvAgain(JSONObject param) { |
|
|
|
if(ObjectUtil.isNotEmpty(param)){ |
|
|
|
String task_id = param.getString("task_id"); |
|
|
|
String device_code = param.getString("device_code"); |
|
|
|
if(StrUtil.isEmpty(task_id) || StrUtil.isEmpty(device_code)){ |
|
|
|
throw new BadRequestException("task_id或device_code为空!"); |
|
|
|
} |
|
|
|
SchBaseTask schBaseTask = taskService.getById(task_id); |
|
|
|
if(ObjectUtil.isEmpty(schBaseTask)){ |
|
|
|
throw new BadRequestException("任务不存在!task_id:" + task_id); |
|
|
|
} |
|
|
|
if(device_code.equals(schBaseTask.getPoint_code2())) throw new BadRequestException("设备号与任务设备不匹配!"); |
|
|
|
//查询点位是否存在
|
|
|
|
SchBasePoint schBasePoint = pointService.selectByPointCode(device_code); |
|
|
|
if(ObjectUtil.isEmpty(schBasePoint)) throw new BadRequestException("点位不存在!device_code:" + device_code); |
|
|
|
SchBasePoint schBasePoint1 = pointService.selectByNextWaitPoint(device_code); |
|
|
|
//
|
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 放货完成 |
|
|
|
* |
|
|
|
* @param schBaseTask |
|
|
|
* @param status |
|
|
|
*/ |
|
|
|
private void releaseComplete(SchBaseTask schBaseTask, String status) { |
|
|
|
//TODO:放货完成反馈给Connector
|
|
|
|
private void releaseComplete(SchBaseTask schBaseTask, String status, String is_connector, String taskType, boolean is_empty) { |
|
|
|
//TODO:空料容放货完成反馈给Connector
|
|
|
|
if ("1".equals(is_connector)) { |
|
|
|
if (!is_empty) { |
|
|
|
finishTask(schBaseTask.getTask_code(), schBaseTask.getPoint_code2()); |
|
|
|
} else { |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("vehicle_code", schBaseTask.getVehicle_code()); |
|
|
|
json.put("status", status); |
|
|
|
json.put("device_code", schBaseTask.getPoint_code2()); |
|
|
|
json.put("task_code", schBaseTask.getTask_code()); |
|
|
|
AcsResponse acsResponse = connectorService.feedAgvTaskStatus(json); |
|
|
|
finishTask(schBaseTask.getTask_code(), schBaseTask.getPoint_code1()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void finishTask(String task_code, String point_code) { |
|
|
|
pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class).eq(SchBasePoint::getPoint_code, point_code) |
|
|
|
.set(SchBasePoint::getIs_lock, false)); |
|
|
|
taskService.update(Wrappers.lambdaUpdate(SchBaseTask.class).eq(SchBaseTask::getTask_code, task_code) |
|
|
|
.set(SchBaseTask::getTask_status, TaskStatus.FINISHED.getCode())); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -314,20 +366,31 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
* @param schBaseTask |
|
|
|
* @param status |
|
|
|
*/ |
|
|
|
private void pickupComplete(SchBaseTask schBaseTask, String status, String is_connector) { |
|
|
|
private void pickupComplete(SchBaseTask schBaseTask, String status, String is_connector, String taskType) { |
|
|
|
//TODO:取货完成创建第二条任务:补空托盘
|
|
|
|
if("1".equals(is_connector)){ |
|
|
|
if ("1".equals(is_connector)) { |
|
|
|
List<SchBaseTask> list = taskService.list(Wrappers.lambdaQuery(SchBaseTask.class).eq(SchBaseTask::getPoint_code2, schBaseTask.getPoint_code1()) |
|
|
|
.in(SchBaseTask::getTask_status, TaskStatus.APPLY.getCode(), TaskStatus.CREATED.getCode(), TaskStatus.ISSUED.getCode(), TaskStatus.EXECUTING.getCode())); |
|
|
|
if (CollUtil.isNotEmpty(list) || list.size() > 0) { |
|
|
|
throw new BadRequestException("该点位已有任务,请等待任务完成"); |
|
|
|
} |
|
|
|
MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.getById(schBaseTask.getVehicle_code()); |
|
|
|
AbstractTask connectorTask = taskFactory.getTask("FTGTask"); |
|
|
|
// 准备参数:设备编码
|
|
|
|
JSONObject param = new JSONObject(); |
|
|
|
param.put("device_code", schBaseTask.getPoint_code2()); |
|
|
|
param.put("device_code", schBaseTask.getPoint_code1()); |
|
|
|
param.put("config_code", "FTGTask"); |
|
|
|
param.put("create_mode", GeneralDefinition.AUTO_CREATION); |
|
|
|
/*param.put("vehicle_code", vehicle_code); |
|
|
|
param.put("task_type", task_type); |
|
|
|
param.put("task_code", task_code); |
|
|
|
param.put("remark",remark);*/ |
|
|
|
param.put("vehicle_type", StrUtil.isNotEmpty(mdBaseVehicle.getVehicle_type()) ? mdBaseVehicle.getVehicle_type() : ""); |
|
|
|
connectorTask.apply(param); |
|
|
|
pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class) |
|
|
|
.eq(SchBasePoint::getPoint_code, schBaseTask.getPoint_code1()).set(SchBasePoint::getIs_lock, true)); |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
json.put("vehicle_code", schBaseTask.getVehicle_code()); |
|
|
|
json.put("status", status); |
|
|
|
json.put("device_code", schBaseTask.getPoint_code1()); |
|
|
|
json.put("task_code", schBaseTask.getTask_code()); |
|
|
|
AcsResponse acsResponse = connectorService.feedAgvTaskStatus(json); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -336,27 +399,39 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { |
|
|
|
* |
|
|
|
* @param schBaseTask |
|
|
|
*/ |
|
|
|
private void requestPickup(SchBaseTask schBaseTask, String status) { |
|
|
|
//反馈connector申请取货
|
|
|
|
SchBaseTaskconfig schBaseTaskconfig = taskConfigService.selectByConfigCode(schBaseTask.getConfig_code()); |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
if (GoodsEnum.PICK_UP.getValue().equals(schBaseTaskconfig.getTask_qf_type())) { |
|
|
|
json.put("vehicle_code", schBaseTask.getVehicle_code()); |
|
|
|
json.put("status", status); |
|
|
|
json.put("device_code", schBaseTask.getPoint_code2()); |
|
|
|
json.put("task_code", schBaseTask.getTask_code()); |
|
|
|
} else if (GoodsEnum.DELIVER_GOODS.getValue().equals(schBaseTaskconfig.getTask_qf_type())) { |
|
|
|
private void requestPickup(SchBaseTask schBaseTask, String status, String is_connector) { |
|
|
|
if ("1".equals(is_connector)) { |
|
|
|
//反馈connector申请取货
|
|
|
|
/*SchBaseTaskconfig schBaseTaskconfig = taskConfigService.selectByConfigCode(schBaseTask.getConfig_code());*/ |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
// if (GoodsEnum.PICK_UP.getValue().equals(schBaseTaskconfig.getTask_qf_type())) {
|
|
|
|
// json.put("vehicle_code", schBaseTask.getVehicle_code());
|
|
|
|
// json.put("status", status);
|
|
|
|
// json.put("device_code", schBaseTask.getPoint_code2());
|
|
|
|
// json.put("task_code", schBaseTask.getTask_code());
|
|
|
|
// } else if (GoodsEnum.DELIVER_GOODS.getValue().equals(schBaseTaskconfig.getTask_qf_type())) {
|
|
|
|
json.put("vehicle_code", schBaseTask.getVehicle_code()); |
|
|
|
json.put("status", status); |
|
|
|
json.put("device_code", schBaseTask.getPoint_code1()); |
|
|
|
json.put("task_code", schBaseTask.getTask_code()); |
|
|
|
} |
|
|
|
boolean flag = true; |
|
|
|
while (flag) { |
|
|
|
AcsResponse acsResponse = connectorService.feedAgvTaskStatus(json); |
|
|
|
if (acsResponse.getStatus() == 200 && StrUtil.isNotEmpty(acsResponse.getData())) { |
|
|
|
vehiclematerialgroupService.updateByVehicleCode(schBaseTask.getVehicle_code(), acsResponse.getData()); |
|
|
|
flag = false; |
|
|
|
boolean flag = true; |
|
|
|
while (flag) { |
|
|
|
AcsResponse acsResponse = connectorService.feedAgvTaskStatus(json); |
|
|
|
if (acsResponse.getStatus() == 200 && StrUtil.isNotEmpty(acsResponse.getData())) { |
|
|
|
JSONArray objects = JSONObject.parseArray(acsResponse.getData()); |
|
|
|
List<ConnectorDto> connectorDtos = BeanUtil.copyToList(objects, ConnectorDto.class); |
|
|
|
for (ConnectorDto connectorDto : connectorDtos) { |
|
|
|
SchBaseVehiclematerialgroup schBaseVehiclematerialgroup = new SchBaseVehiclematerialgroup(); |
|
|
|
schBaseVehiclematerialgroup.setVehicle_code(connectorDto.getVehicle_code()); |
|
|
|
schBaseVehiclematerialgroup.setJob_name(connectorDto.getJobname()); |
|
|
|
schBaseVehiclematerialgroup.setMaterial_id(connectorDto.getProductID()); |
|
|
|
schBaseVehiclematerialgroup.setMaterial_qty(connectorDto.getCurrentqty()); |
|
|
|
schBaseVehiclematerialgroup.setRegion_code(connectorDto.getProductionOrder()); |
|
|
|
iSchBaseVehiclematerialgroupService.create(schBaseVehiclematerialgroup); |
|
|
|
} |
|
|
|
// vehiclematerialgroupService.updateByVehicleCode(schBaseTask.getVehicle_code(), acsResponse.getData());
|
|
|
|
flag = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|