opt:增加指令创建失败提示

This commit is contained in:
2024-12-21 13:23:37 +08:00
parent 30b6b4430c
commit 00bbc35055
19 changed files with 533 additions and 96 deletions

View File

@@ -121,7 +121,10 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
if (!ObjectUtil.isEmpty(link_inst)) { if (!ObjectUtil.isEmpty(link_inst)) {
link_flag = true; link_flag = true;
} }
if (error != 0) {
//todo 反馈立库AGV故障信息
sendAgvErrorStatus(inst, device_code, Integer.parseInt(AgvActionEnum.ACTION_STATUS.code("请求取货")));
}
Device device = null; Device device = null;
String old_device_code = null; String old_device_code = null;
String emptyNum = null; String emptyNum = null;
@@ -814,6 +817,38 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
} }
private void sendAgvErrorStatus(Instruction inst, String device_code, Integer status) {
if (inst == null) {
return;
}
JSONArray ja = new JSONArray();
JSONObject jo = new JSONObject();
jo.put("vehicle_code", inst.getVehicle_code());
jo.put("status", status);
jo.put("device_code", this.device_code);
jo.put("task_code", inst.getTask_code());
ja.add(jo);
LuceneLogDto reqlogDto = LuceneLogDto.builder()
.device_code(device_code)
.content("请求参数:" + jo)
.requestparam("请求参数:" + jo)
.method("1111111111111111111111111111111feedAgvTaskStatus")
.build();
luceneExecuteLogService.deviceExecuteLog(reqlogDto);
HttpResponse resp = acsToWmsService.feedAgvErrorStatus(ja);
LuceneLogDto resplogDto = LuceneLogDto.builder()
.device_code(device_code)
.content("返回参数:" + resp.body())
.responseparam("返回参数:" + resp.body())
.method("feedAgvTaskStatus")
.status_code(String.valueOf(resp.getStatus()))
.build();
luceneExecuteLogService.deviceExecuteLog(resplogDto);
}
private void sendAgvTaskStatus(Instruction inst, String device_code, Integer status) { private void sendAgvTaskStatus(Instruction inst, String device_code, Integer status) {
if (inst == null) { if (inst == null) {
return; return;

View File

@@ -43,6 +43,19 @@ public class WmsToAcsController {
return new ResponseEntity<>(wmstoacsService.crateTask(reqs), HttpStatus.OK); return new ResponseEntity<>(wmstoacsService.crateTask(reqs), HttpStatus.OK);
} }
@PostMapping("/getAgvInfo")
@Log("agv信息")
@ApiOperation("agv信息")
public ResponseEntity<Object> allDeviceStatus() {
return new ResponseEntity<>(wmstoacsService.allDeviceStatus(), HttpStatus.OK);
}
@PostMapping("/cancelTask") @PostMapping("/cancelTask")
@Log(value = "WMS取消任务") @Log(value = "WMS取消任务")
@ApiOperation("WMS取消任务") @ApiOperation("WMS取消任务")

View File

@@ -113,7 +113,13 @@ public interface AcsToWmsService {
*/ */
HttpResponse feedAgvTaskStatus(JSONArray from); HttpResponse feedAgvTaskStatus(JSONArray from);
/**
* 反馈AGV故障信息
*
* @param from
* @return
*/
HttpResponse feedAgvErrorStatus(JSONArray from);
/** /**

View File

@@ -19,6 +19,10 @@ public interface WmsToAcsService {
CreateTaskResponse crateTask(List<CreateTaskRequest> reqs); CreateTaskResponse crateTask(List<CreateTaskRequest> reqs);
JSONObject allDeviceStatus();
/** /**
* 取消任务 * 取消任务
* *

View File

@@ -552,6 +552,30 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
return result; return result;
} }
@Override
public HttpResponse feedAgvErrorStatus(JSONArray from) {
String wmsUrl = paramService.findByCode(AcsConfig.WMSURL).getValue();
AddressDto addressDto = addressService.findByCode("feedAgvErrorStatus");
String methods_url = addressDto.getMethods_url();
String url = wmsUrl + methods_url;
HttpResponse result = null;
log.info("feedAgvErrorStatus----请求参数{}", from);
try {
result = HttpRequest.post(url)
.body(String.valueOf(from))
.execute();
System.out.println(result);
log.info("feedAgvErrorStatus----返回参数{}", result);
} catch (Exception e) {
String msg = e.getMessage();
//网络不通
//System.out.println(msg);
}
return result;
}
@Override @Override
public String applyTask(BaseRequest requestParam) { public String applyTask(BaseRequest requestParam) {
try { try {

View File

@@ -31,11 +31,13 @@ import org.nl.acs.storage_cell.service.mapper.StorageCellMapper;
import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto; import org.nl.acs.task.service.dto.TaskDto;
import org.nl.common.exception.BadRequestException; import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.RedisUtils;
import org.nl.config.SpringContextHolder; import org.nl.config.SpringContextHolder;
import org.nl.system.service.param.ISysParamService; import org.nl.system.service.param.ISysParamService;
import org.redisson.api.RLock; import org.redisson.api.RLock;
import org.redisson.api.RedissonClient; import org.redisson.api.RedissonClient;
import org.slf4j.MDC; import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -67,6 +69,9 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
@Resource @Resource
private RedissonClient redissonClient; private RedissonClient redissonClient;
@Resource
private RedisUtils redisUtils;
@Override @Override
public CancelTaskResponse cancelFromWms(List<CancelTaskRequest> reqs) throws Exception { public CancelTaskResponse cancelFromWms(List<CancelTaskRequest> reqs) throws Exception {
ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class); ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
@@ -109,6 +114,22 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
return response; return response;
} }
/**
* agv信息查询
*/
@Override
public JSONObject allDeviceStatus() {
JSONObject jsonObject = new JSONObject();
JSONArray agv = (JSONArray) redisUtils.get("AGV");
if (ObjectUtil.isNotEmpty(agv)) {
jsonObject.put("agv", agv);
} else {
jsonObject.put("agv", new JSONArray());
}
return jsonObject;
}
@Override @Override
public Map<String, Object> updateDeviceGoodsFromWms(String param) { public Map<String, Object> updateDeviceGoodsFromWms(String param) {
JSONArray datas = JSONArray.parseArray(param); JSONArray datas = JSONArray.parseArray(param);

View File

@@ -1,23 +1,17 @@
package org.nl.acs.instruction.domain; package org.nl.acs.instruction.domain;
import org.nl.acs.common.base.CommonModel;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.IdType;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.bean.copier.CopyOptions;
import javax.validation.constraints.*; import com.baomidou.mybatisplus.annotation.*;
import java.math.BigDecimal; import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
import org.nl.acs.common.base.CommonModel;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal;
/** /**
* @author jiaolm * @author jiaolm
@@ -238,7 +232,12 @@ public class InstructionMybatis extends CommonModel<InstructionMybatis> implemen
@ApiModelProperty(value = "AGV系统类型") @ApiModelProperty(value = "AGV系统类型")
private String agv_system_type; private String agv_system_type;
public void copyFrom(Instruction source){ /**
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); * lms任务id
*/
private String ext_task_id;
public void copyFrom(Instruction source) {
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
} }
} }

View File

@@ -37,9 +37,9 @@ public class InstructionController {
@ApiOperation("查询指令") @ApiOperation("查询指令")
//@PreAuthorize("@el.check('instruction:list')") //@PreAuthorize("@el.check('instruction:list')")
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) { public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
if(ObjectUtil.isEmpty(whereJson.get("status"))) { // if(ObjectUtil.isEmpty(whereJson.get("status"))) {
whereJson.put("status", "1"); // whereJson.put("status", "1");
} // }
return new ResponseEntity<>(instructionService.queryAll(whereJson, page), HttpStatus.OK); return new ResponseEntity<>(instructionService.queryAll(whereJson, page), HttpStatus.OK);
} }

View File

@@ -348,4 +348,9 @@ public class InstructionDto implements Serializable {
*/ */
private String agv_system_type; private String agv_system_type;
/**
* lms任务id
*/
private String ext_task_id;
} }

View File

@@ -20,6 +20,9 @@ import org.nl.acs.agv.server.MagicAgvService;
import org.nl.acs.agv.server.NDCAgvService; import org.nl.acs.agv.server.NDCAgvService;
import org.nl.acs.agv.server.ZheDaAgvService; import org.nl.acs.agv.server.ZheDaAgvService;
import org.nl.acs.auto.initial.ApplicationAutoInitial; import org.nl.acs.auto.initial.ApplicationAutoInitial;
import org.nl.acs.common.base.PageInfo;
import org.nl.acs.common.base.QueryHelpMybatisPlus;
import org.nl.acs.common.base.impl.CommonServiceImpl;
import org.nl.acs.device.domain.Device; import org.nl.acs.device.domain.Device;
import org.nl.acs.device.service.DeviceService; import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device.service.impl.DeviceServiceImpl; import org.nl.acs.device.service.impl.DeviceServiceImpl;
@@ -30,9 +33,12 @@ import org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanne
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver; import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
import org.nl.acs.ext.wms.liKuData.*; import org.nl.acs.ext.wms.liKuData.*;
import org.nl.acs.ext.wms.service.AcsToLiKuService; import org.nl.acs.ext.wms.service.AcsToLiKuService;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.domain.InstructionMybatis; import org.nl.acs.instruction.domain.InstructionMybatis;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.InstructionDto; import org.nl.acs.instruction.service.dto.InstructionDto;
import org.nl.acs.instruction.service.dto.InstructionQueryParam; import org.nl.acs.instruction.service.dto.InstructionQueryParam;
import org.nl.acs.instruction.service.mapper.InstructionMapper;
import org.nl.acs.opc.DeviceAppService; 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;
@@ -42,31 +48,20 @@ import org.nl.acs.task.TaskInstructionLock;
import org.nl.acs.task.domain.Task; import org.nl.acs.task.domain.Task;
import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto; import org.nl.acs.task.service.dto.TaskDto;
import org.nl.acs.common.base.PageInfo;
import org.nl.acs.common.base.QueryHelpMybatisPlus;
import org.nl.acs.common.base.impl.CommonServiceImpl;
import org.nl.acs.task.service.mapper.TaskMapper; import org.nl.acs.task.service.mapper.TaskMapper;
import org.nl.common.exception.BadRequestException;
import org.nl.acs.utils.ConvertUtil; import org.nl.acs.utils.ConvertUtil;
import org.nl.common.utils.FileUtil;
import org.nl.acs.utils.PageUtil; import org.nl.acs.utils.PageUtil;
import org.nl.acs.instruction.domain.Instruction; import org.nl.common.exception.BadRequestException;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.mapper.InstructionMapper;
import org.nl.common.utils.SecurityUtils;
import org.nl.system.service.dict.dao.Dict;
import org.nl.system.service.param.ISysParamService;
import org.nl.common.utils.CodeUtil; import org.nl.common.utils.CodeUtil;
import org.nl.common.utils.FileUtil;
import org.nl.common.utils.SecurityUtils;
import org.nl.config.SpringContextHolder; import org.nl.config.SpringContextHolder;
import org.nl.system.service.param.ISysParamService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
// 默认不使用缓存
//import org.springframework.cache.annotation.CacheConfig;
//import org.springframework.cache.annotation.CacheEvict;
//import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
@@ -192,11 +187,10 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
IPage<InstructionMybatis> queryPage = PageUtil.toMybatisPage(page); IPage<InstructionMybatis> queryPage = PageUtil.toMybatisPage(page);
LambdaQueryWrapper<InstructionMybatis> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<InstructionMybatis> wrapper = new LambdaQueryWrapper<>();
// wrapper.eq(InstructionMybatis::getIs_delete,0); // wrapper.eq(InstructionMybatis::getIs_delete,0);
wrapper.and(StringUtils.isNotBlank(code), instructionMybatis -> instructionMybatis.like(InstructionMybatis::getInstruction_code, code).or().like(InstructionMybatis::getTask_code, code)); wrapper.and(StringUtils.isNotBlank(code), instructionMybatis -> instructionMybatis.like(InstructionMybatis::getInstruction_code, code).or().like(InstructionMybatis::getTask_code, code));
wrapper.like(StringUtils.isNotBlank(vehicle_code), InstructionMybatis::getVehicle_code, vehicle_code); wrapper.like(StringUtils.isNotBlank(vehicle_code), InstructionMybatis::getVehicle_code, vehicle_code);
wrapper.eq(StringUtils.isNotBlank(material_type), InstructionMybatis::getMaterial, material_type); wrapper.eq(StringUtils.isNotBlank(material_type), InstructionMybatis::getMaterial, material_type);
wrapper.eq(StringUtils.isNotBlank(status), InstructionMybatis::getInstruction_status, status);
wrapper.and(StringUtils.isNotBlank(point_code), instructionMybatis -> instructionMybatis.like(InstructionMybatis::getStart_point_code, point_code).or().like(InstructionMybatis::getNext_point_code, point_code)); wrapper.and(StringUtils.isNotBlank(point_code), instructionMybatis -> instructionMybatis.like(InstructionMybatis::getStart_point_code, point_code).or().like(InstructionMybatis::getNext_point_code, point_code));
wrapper.eq(StringUtils.isNotBlank(instruction_type), InstructionMybatis::getInstruction_type, instruction_type); wrapper.eq(StringUtils.isNotBlank(instruction_type), InstructionMybatis::getInstruction_type, instruction_type);
if (!StrUtil.isEmpty(is_over)) { if (!StrUtil.isEmpty(is_over)) {
@@ -206,6 +200,11 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
wrapper.lt(InstructionMybatis::getInstruction_status, 2); wrapper.lt(InstructionMybatis::getInstruction_status, 2);
} }
} }
if (!StrUtil.isEmpty(status)) {
wrapper.eq(InstructionMybatis::getInstruction_status, status);
} else {
wrapper.lt(InstructionMybatis::getInstruction_status, 2);
}
IPage<InstructionMybatis> insPage = instructionMapper.selectPage(queryPage, wrapper); IPage<InstructionMybatis> insPage = instructionMapper.selectPage(queryPage, wrapper);
final JSONObject json = (JSONObject) JSON.toJSON(ConvertUtil.convertPage(insPage, InstructionDto.class)); final JSONObject json = (JSONObject) JSON.toJSON(ConvertUtil.convertPage(insPage, InstructionDto.class));
return json; return json;
@@ -337,22 +336,12 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
@Override @Override
public Instruction findByTaskid(String id, String wherecaluse) { public Instruction findByTaskid(String id, String wherecaluse) {
// if (!StrUtil.isEmpty(wherecaluse)) {
// wherecaluse = " and " + wherecaluse;
// }
// WQLObject wo = WQLObject.getWQLObject("acs_instruction");
// JSONObject json = wo.query("task_id ='" + id + "'" + wherecaluse).uniqueResult(0);
// if (ObjectUtil.isNotEmpty(json)) {
// return json.toJavaObject(Instruction.class);
// }
// return null;
LambdaQueryWrapper<InstructionMybatis> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<InstructionMybatis> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(InstructionMybatis::getTask_id, id); wrapper.eq(InstructionMybatis::getTask_id, id);
wrapper.apply(StringUtils.isNotBlank(wherecaluse), wherecaluse); wrapper.apply(StringUtils.isNotBlank(wherecaluse), wherecaluse);
InstructionMybatis ins = instructionMapper.selectOne(wrapper); List<InstructionMybatis> insList = instructionMapper.selectList(wrapper);
if (ObjectUtil.isNotEmpty(ins)) { if (ObjectUtil.isNotEmpty(insList)) {
return ConvertUtil.convert(ins, Instruction.class); return ConvertUtil.convert(insList.get(0), Instruction.class);
} }
return null; return null;
} }
@@ -362,6 +351,128 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
dto = foramte(dto); dto = foramte(dto);
String task_code = dto.getTask_code(); String task_code = dto.getTask_code();
TaskDto task = taskService.findByCodeFromCache(task_code); TaskDto task = taskService.findByCodeFromCache(task_code);
String currentUsername = SecurityUtils.getCurrentUsername();
String now = DateUtil.now();
if (StrUtil.isEmpty(dto.getRoute_plan_code())) {
dto.setRoute_plan_code(task.getRoute_plan_code());
}
if (StrUtil.isEmpty(dto.getPriority())) {
dto.setPriority(task.getPriority());
}
if (StrUtil.isEmpty(dto.getInstruction_code())) {
dto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO"));
}
if (StrUtil.isEmpty(dto.getInstruction_id())) {
dto.setInstruction_id(IdUtil.simpleUUID());
}
if (StrUtil.isEmpty(dto.getIs_send())) {
dto.setIs_send(task.getIs_send());
}
if (StrUtil.isEmpty(dto.getLink_num())) {
dto.setIs_send(task.getLink_num());
}
// if (task.getTask_type().equals("1") || task.getTask_type().equals("2")) {
dto.setInstruction_type(task.getTask_type());
// } else if (false) {
//
// } else {
// dto.setInstruction_type("3");
// }
// 查询是否存在相同指令号
// if (!StrUtil.isEmpty(dto.getVehicle_code() )) {
// Instruction inst_dto = findByContainer(dto.getVehicle_code());
// if (inst_dto != null) {
// log.error("存在相同载具号任务,载具号"+dto.getVehicle_code());
// throw new BadRequestException("存在相同载具号任务!");
// }
// }
// 起点设备与终点设备相同则为初始指令
if (StrUtil.equals(task.getStart_device_code(), dto.getStart_device_code())) {
if (!StrUtil.equals(dto.getCompound_inst(), "0")
&& StrUtil.equals(task.getCompound_task(), "1")) {
dto.setCompound_inst("1");
dto.setCompound_inst_data(task.getCompound_task_data());
}
}
dto.setExt_task_id(task.getExt_task_id());
dto.setCreate_by(ObjectUtil.isNotEmpty(currentUsername) ? currentUsername : "admin");
dto.setUpdate_by(ObjectUtil.isNotEmpty(currentUsername) ? currentUsername : "admin");
dto.setUpdate_time(now);
dto.setCreate_time(now);
dto.setStart_parent_code(task.getStart_parent_code());
dto.setNext_parent_code(task.getNext_parent_code());
if (ObjectUtil.isNotEmpty(task.getTask_type())) {
dto.setInstruction_type(task.getTask_type());
}
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
try {
String start_device_code = dto.getStart_device_code();
String next_device_code = dto.getNext_device_code();
String route_plan_code = task.getRoute_plan_code();
List<RouteLineDto> shortPathsList =
routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
RouteLineDto route = null;
for (int i = 0; i < shortPathsList.size(); i++) {
RouteLineDto routeLineDto = shortPathsList.get(i);
String route_device = routeLineDto.getDevice_code();
String route_next_device = routeLineDto.getNext_device_code();
if (route_device.equals(dto.getStart_device_code())
&& route_next_device.equals(dto.getNext_device_code())) {
route = routeLineDto;
break;
}
}
if (ObjectUtil.isEmpty(route)) {
throw new BadRequestException("未查询到相关路由!");
}
if (StrUtil.equals(shortPathsList.get(0).getType(), "1")) {
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
} else if (StrUtil.equals(shortPathsList.get(0).getType(), "2")) {
ZheDaAgvService zheDaAgvService = SpringContextHolder.getBean(ZheDaAgvService.class);
HttpResponse result = zheDaAgvService.sendAgvInstToAgv(dto);
if (!ObjectUtils.isEmpty(result)) {
JSONObject jo = JSON.parseObject(result.body());
if (jo.getInteger("status") != 200) {
dto.setSend_status("2");
dto.setRemark("失败原因:" + jo.getString("message"));
log.error("创建指令,下发AGV/RGV任务失败任务id为:{},指令号为:{},失败原因{}", task.getTask_id(), dto.getInstruction_code(), jo.getString("message"));
if (task != null) {
task.setRemark("创建指令,下发AGV/RGV任务失败失败原因{}" + jo.getString("message"));
taskService.update(task);
}
} else {
dto.setSend_status("1");
}
} else {
dto.setSend_status("2");
dto.setRemark("失败原因:AGV/RGV未响应");
log.error("创建指令,下发AGV/RGV任务失败任务id为:{},指令号为:{},失败原因{}", task.getTask_id(), dto.getInstruction_code(), "AGV/RGV未响应");
if (task != null) {
task.setRemark("创建指令,下发AGV/RGV任务失败失败原因: AGV/RGV未响应");
taskService.update(task);
}
}
}
} catch (Exception e) {
String msg = e.getMessage()==null?"连接失败!":e.getMessage();
dto.setSend_status("2");
dto.setRemark("失败原因:" + msg);
log.error("创建指令失败任务id为" + task.getTask_id(), "失败原因:" + msg);
if (task != null) {
task.setRemark("自动创建指令失败,失败原因:"+msg);
taskService.update(task);
}
}
InstructionMybatis entity = ConvertUtil.convert(dto, InstructionMybatis.class);
instructionMapper.insert(entity);
instructions.add(dto);
}
public void create1(Instruction dto) {
dto = foramte(dto);
String task_code = dto.getTask_code();
TaskDto task = taskService.findByCodeFromCache(task_code);
String currentUsername = SecurityUtils.getCurrentUsername(); String currentUsername = SecurityUtils.getCurrentUsername();
String now = DateUtil.now(); String now = DateUtil.now();
@@ -467,9 +578,6 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
e.printStackTrace(); e.printStackTrace();
log.error(""); log.error("");
} }
// WQLObject wo = WQLObject.getWQLObject("acs_instruction");
// JSONObject json = (JSONObject) JSONObject.toJSON(dto);
// wo.insert(json);
InstructionMybatis entity = ConvertUtil.convert(dto, InstructionMybatis.class); InstructionMybatis entity = ConvertUtil.convert(dto, InstructionMybatis.class);
instructionMapper.insert(entity); instructionMapper.insert(entity);
instructions.add(dto); instructions.add(dto);
@@ -480,8 +588,6 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
dto = foramte(dto); dto = foramte(dto);
String task_code = dto.getTask_code(); String task_code = dto.getTask_code();
TaskDto task = taskService.findByCodeFromCache(task_code); TaskDto task = taskService.findByCodeFromCache(task_code);
// WQLObject instwo = WQLObject.getWQLObject("acs_instruction");
String currentUsername = SecurityUtils.getCurrentUsername(); String currentUsername = SecurityUtils.getCurrentUsername();
String now = DateUtil.now(); String now = DateUtil.now();
if (StrUtil.isEmpty(dto.getRoute_plan_code())) { if (StrUtil.isEmpty(dto.getRoute_plan_code())) {
@@ -542,6 +648,127 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
hongXiangConveyorDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code())); hongXiangConveyorDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code()));
} }
try {
String start_device_code = dto.getStart_device_code();
String next_device_code = dto.getNext_device_code();
String route_plan_code = task.getRoute_plan_code();
List<RouteLineDto> shortPathsList =
routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
RouteLineDto route = null;
for (int i = 0; i < shortPathsList.size(); i++) {
RouteLineDto routeLineDto = shortPathsList.get(i);
String route_device = routeLineDto.getDevice_code();
String route_next_device = routeLineDto.getNext_device_code();
if (route_device.equals(dto.getStart_device_code())
&& route_next_device.equals(dto.getNext_device_code())) {
route = routeLineDto;
break;
}
}
if (ObjectUtil.isEmpty(route)) {
throw new BadRequestException("未查询到相关路由!");
}
if (StrUtil.equals(shortPathsList.get(0).getType(), "1")) {
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
} else if (StrUtil.equals(shortPathsList.get(0).getType(), "2")) {
ZheDaAgvService zheDaAgvService = SpringContextHolder.getBean(ZheDaAgvService.class);
HttpResponse result = zheDaAgvService.sendAgvInstToAgv(dto);
if (!ObjectUtils.isEmpty(result)) {
JSONObject jo = JSON.parseObject(result.body());
if (jo.getInteger("status") != 200) {
dto.setSend_status("2");
dto.setRemark("失败原因:" + jo.getString("message"));
log.error("创建指令,下发AGV/RGV任务失败任务id为:{},指令号为:{},失败原因{}", task.getTask_id(), dto.getInstruction_code(), jo.getString("message"));
task.setRemark("创建指令,下发AGV/RGV任务失败失败原因{}" + jo.getString("message"));
} else {
dto.setSend_status("1");
task.setRemark("");
}
} else {
dto.setSend_status("2");
dto.setRemark("失败原因:AGV/RGV未响应");
log.error("创建指令,下发AGV/RGV任务失败任务id为:{},指令号为:{},失败原因{}", task.getTask_id(), dto.getInstruction_code(), "AGV/RGV未响应");
task.setRemark("创建指令,下发AGV/RGV任务失败失败原因: AGV/RGV未响应");
}
taskService.update(task);
}
} catch (Exception e) {
if (e.getMessage() == null) {
dto.setRemark("失败原因:连接异常!");
} else {
dto.setRemark("失败原因:" + e.getMessage());
}
dto.setSend_status("2");
log.error("创建指令失败下发AGV/RGV任务失败任务id为:{},指令号为:{},失败原因{}", task.getTask_id(), dto.getInstruction_code(), e.getMessage());
}
InstructionMybatis entity = ConvertUtil.convert(dto, InstructionMybatis.class);
instructionMapper.insert(entity);
instructions.add(dto);
}
public void create3(Instruction dto) throws Exception {
dto = foramte(dto);
String task_code = dto.getTask_code();
TaskDto task = taskService.findByCodeFromCache(task_code);
String currentUsername = SecurityUtils.getCurrentUsername();
String now = DateUtil.now();
if (StrUtil.isEmpty(dto.getRoute_plan_code())) {
dto.setRoute_plan_code(task.getRoute_plan_code());
}
if (StrUtil.isEmpty(dto.getPriority())) {
dto.setPriority(task.getPriority());
}
if (StrUtil.isEmpty(dto.getInstruction_code())) {
dto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO"));
}
if (StrUtil.isEmpty(dto.getInstruction_id())) {
dto.setInstruction_id(IdUtil.simpleUUID());
}
if (StrUtil.isEmpty(dto.getIs_send())) {
dto.setIs_send(task.getIs_send());
}
if (StrUtil.isEmpty(dto.getLink_num())) {
dto.setIs_send(task.getLink_num());
}
if (task.getTask_type().equals("1") || task.getTask_type().equals("2")) {
dto.setInstruction_type(task.getTask_type());
} else if (false) {
} else {
dto.setInstruction_type("3");
}
// 起点设备与终点设备相同则为初始指令
if (StrUtil.equals(task.getStart_device_code(), dto.getStart_device_code())) {
if (!StrUtil.equals(dto.getCompound_inst(), "0")
&& StrUtil.equals(task.getCompound_task(), "1")) {
dto.setCompound_inst("1");
dto.setCompound_inst_data(task.getCompound_task_data());
}
}
dto.setCreate_by(currentUsername);
dto.setUpdate_by(currentUsername);
dto.setUpdate_time(now);
dto.setCreate_time(now);
dto.setStart_parent_code(task.getStart_parent_code());
dto.setNext_parent_code(task.getNext_parent_code());
if (ObjectUtil.isNotEmpty(task.getTask_type())) {
dto.setInstruction_type(task.getTask_type());
}
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device startdevice = appService.findDeviceByCode(dto.getStart_device_code());
Device nextdevice = appService.findDeviceByCode(dto.getNext_device_code());
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
StandardCoveyorControlWithScannerDeviceDriver standardCoveyorControlWithScannerDeviceDriver;
if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver();
hongXiangConveyorDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code()));
}
try { try {
String start_device_code = dto.getStart_device_code(); String start_device_code = dto.getStart_device_code();
String next_device_code = dto.getNext_device_code(); String next_device_code = dto.getNext_device_code();

View File

@@ -38,10 +38,10 @@ public class TaskController {
@ApiOperation("查询任务") @ApiOperation("查询任务")
//@PreAuthorize("@el.check('task:list')") //@PreAuthorize("@el.check('task:list')")
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) { public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
// return new ResponseEntity<>(taskService.queryAllByCache(whereJson, page), HttpStatus.OK); // return new ResponseEntity<>(taskService.queryAllByCache(whereJson, page), HttpStatus.OK);
// if(ObjectUtil.isEmpty(whereJson.get("status"))) { // if(ObjectUtil.isEmpty(whereJson.get("status"))) {
// whereJson.put("status", "1"); // whereJson.put("status", "1");
// } // }
return new ResponseEntity<>(taskService.queryAll(whereJson, page), HttpStatus.OK); return new ResponseEntity<>(taskService.queryAll(whereJson, page), HttpStatus.OK);
} }

View File

@@ -993,11 +993,15 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
String resp = null; String resp = null;
try { try {
resp = acstowmsService.feedTaskStatus(request); resp = acstowmsService.feedTaskStatus(request);
log.info("任务号:{},反馈wms任务状态完成成功,响应信息:{}!", entity.getTask_code(), resp); JSONObject jo = JSON.parseObject(resp);
if ("200".equals(jo.getString("code"))) {
log.info("任务号:{},反馈wms任务状态完成成功,响应信息:{}!", entity.getTask_code(), resp);
} else {
log.error("任务号:{},反馈wms任务状态失败,原因:{}!", entity.getTask_code(), jo.getString("message"));
}
} catch (Exception e) { } catch (Exception e) {
log.error("任务号:{},反馈wms任务状态失败,原因:{}!", entity.getTask_code(), e.getMessage()); log.error("任务号:{},反馈wms任务状态失败,原因:{}!", entity.getTask_code(), e.getMessage());
} finally {
} }
} }
List<RouteLineDto> shortPathsList = List<RouteLineDto> shortPathsList =
@@ -1181,6 +1185,101 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
@Override @Override
public Instruction createInst(String ids) throws Exception { public Instruction createInst(String ids) throws Exception {
TaskDto acsTask = this.findById(ids);
if (acsTask == null) {
throw new BadRequestException("被删除或无权限,操作失败!");
}
//只有执行中的任务才能创建指令
if (!"1".equals(acsTask.getTask_status())) {
throw new BadRequestException("任务未执行,不能创建指令!");
}
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl");
InstructionDto inst = instructionservice.findByTaskid(ids, "instruction_status < 2 ");
if (inst != null) {
throw new BadRequestException("有指令未完成!");
}
String taskid = acsTask.getTask_id();
String taskcode = acsTask.getTask_code();
String vehiclecode = acsTask.getVehicle_code();
String priority = acsTask.getPriority();
String start_point_code = acsTask.getStart_point_code();
String start_device_code = acsTask.getStart_device_code();
String route_plan_code = acsTask.getRoute_plan_code();
String vehicleType = acsTask.getVehicle_type();
// 是否复合任务 =0非复合任务
String compound_task = acsTask.getCompound_task();
String next_point_code = acsTask.getNext_point_code();
String next_device_code = acsTask.getNext_device_code();
String start_point_code2 = acsTask.getStart_point_code2();
String next_point_code2 = acsTask.getNext_point_code2();
String agv_system_type = acsTask.getAgv_system_type();
String task_type = acsTask.getTask_type();
/** 开始平均分解校验 */
String this_device_code =
this.queryAssignedByDevice(acsTask.getStart_device_code(), acsTask.getNext_device_code());
if (StrUtil.isEmpty(this_device_code)) {
List<RouteLineDto> shortPathsList =
routeLineService.getShortPathLines(
start_device_code, acsTask.getNext_device_code(), route_plan_code);
RouteLineDto routeLineDto = shortPathsList.get(0);
String path = routeLineDto.getPath();
String type = routeLineDto.getType();
String[] str = path.split("->");
List<String> pathlist = Arrays.asList(str);
int index = 0;
for (int m = 0; m < pathlist.size(); m++) {
if (pathlist.get(m).equals(start_device_code)) {
index = m + 1;
break;
}
}
next_device_code = pathlist.get(index);
} else {
next_device_code = this_device_code;
}
if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) {
next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z();
} else {
next_point_code = next_device_code;
}
Instruction instdto = new Instruction();
instdto.setInstruction_type(task_type);
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setRoute_plan_code(route_plan_code);
instdto.setMaterial(acsTask.getMaterial());
instdto.setQuantity(acsTask.getQuantity());
instdto.setTask_id(taskid);
instdto.setTask_code(taskcode);
instdto.setVehicle_code(vehiclecode);
String now = DateUtil.now();
instdto.setCreate_time(now);
instdto.setCreate_by("auto");
instdto.setStart_device_code(start_device_code);
instdto.setNext_device_code(next_device_code);
instdto.setStart_point_code(start_point_code);
instdto.setNext_point_code(next_point_code);
instdto.setPriority(priority);
instdto.setInstruction_status("0");
instdto.setExecute_device_code(start_point_code);
instdto.setVehicle_type(vehicleType);
instdto.setStart_point_code2(start_point_code2);
instdto.setStart_device_code2(start_point_code2);
instdto.setNext_device_code2(next_point_code2);
instdto.setNext_point_code2(next_point_code2);
instdto.setAgv_system_type(agv_system_type);
instdto.setAgv_inst_type("1");
instdto.setExt_task_id(acsTask.getExt_task_id());
try {
instructionservice.create2(instdto);
} catch (Exception e) {
log.error("手动创建指令失败任务id为:{},指令号为:{},失败原因{}", acsTask.getTask_id(), instdto.getInstruction_code(), e.getMessage());
}
return instdto;
}
public Instruction createInst1(String ids) throws Exception {
TaskDto acsTask = this.findById(ids); TaskDto acsTask = this.findById(ids);
if (acsTask == null) { if (acsTask == null) {
throw new BadRequestException("被删除或无权限,操作失败!"); throw new BadRequestException("被删除或无权限,操作失败!");
@@ -1274,10 +1373,7 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
@Override @Override
public Instruction createInst(Instruction inst) throws Exception { public Instruction createInst(Instruction inst) throws Exception {
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl"); InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl");
instructionservice.create2(inst); instructionservice.create2(inst);
return inst; return inst;
} }

View File

@@ -199,7 +199,11 @@ public class AutoCreateInst {
try { try {
instructionService.create(instdto); instructionService.create(instdto);
} catch (Exception e) { } catch (Exception e) {
acsTask.setRemark(e.getMessage()); if (e.getMessage() == null) {
acsTask.setRemark("自动创建指令失败,失败原因:连接失败!");
} else {
acsTask.setRemark("自动创建指令失败,失败原因:" + e.getMessage());
}
taskserver.updateByCodeFromCache(acsTask); taskserver.updateByCodeFromCache(acsTask);
continue; continue;
} }

View File

@@ -59,15 +59,14 @@ public class QueryZDAgvTaskStatus {
vehicle = inst_jo.getString("vehicle"); vehicle = inst_jo.getString("vehicle");
inst.setCarno(vehicle); inst.setCarno(vehicle);
} }
// RAW初始状态 // RAW初始状态
// ACTIVE业务订单已激活 // ACTIVE业务订单已激活
// DISPATCHABLE业务订单已通过系统验证等待被调度执行 // DISPATCHABLE业务订单已通过系统验证等待被调度执行
// BEING_PROCESSED业务订单正在被执行 // BEING_PROCESSED业务订单正在被执行
// WITHDRAWN业务订单已被撤销 // WITHDRAWN业务订单已被撤销
// FINISHED业务订单已完成 // FINISHED业务订单已完成
// FAILED业务订单已失败 // FAILED业务订单已失败
// UNROUTABLE无法规划该业务订单的执行路线 // UNROUTABLE无法规划该业务订单的执行路线
//执行中 //执行中
if ("BEING_PdROCESSED".equals(status) || "ACTIVE".equals(status)) { if ("BEING_PdROCESSED".equals(status) || "ACTIVE".equals(status)) {
if (inst != null) { if (inst != null) {

View File

@@ -82,6 +82,7 @@ public class SyncDeviceStatus {
//agv状态信息反馈 //agv状态信息反馈
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
param.put("AGV", AGV); param.put("AGV", AGV);
redisUtils.set("AGV", AGV);
HttpResponse response = acsToWmsService.shipDeviceUpdate(param); HttpResponse response = acsToWmsService.shipDeviceUpdate(param);
if (response == null || response.getStatus() == 200) { if (response == null || response.getStatus() == 200) {
log.info("自动上报agv状态,接口返回:" + response.body()); log.info("自动上报agv状态,接口返回:" + response.body());

View File

@@ -7,10 +7,10 @@ spring:
db-type: com.alibaba.druid.pool.DruidDataSource db-type: com.alibaba.druid.pool.DruidDataSource
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:stand_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true # url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:stand_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:qzyf_acs_bak}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:qzyf_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
username: ${DB_USER:root} username: ${DB_USER:root}
# password: ${DB_PWD:Root.123456} # password: ${DB_PWD:Root.123456}
password: ${DB_PWD:123456789} password: ${DB_PWD:123456}
# 初始连接数 # 初始连接数
initial-size: 5 initial-size: 5
# 最小连接数 # 最小连接数

View File

@@ -104,6 +104,7 @@
<span v-if="scope.row.instruction_status=='0' ">就绪</span> <span v-if="scope.row.instruction_status=='0' ">就绪</span>
<span v-if="scope.row.instruction_status=='1' ">执行中</span> <span v-if="scope.row.instruction_status=='1' ">执行中</span>
<span v-if="scope.row.instruction_status=='2' ">完成</span> <span v-if="scope.row.instruction_status=='2' ">完成</span>
<span v-if="scope.row.instruction_status=='3' ">取消</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="start_point_code" label="起点" /> <el-table-column prop="start_point_code" label="起点" />

View File

@@ -134,10 +134,12 @@
<span v-if="scope.row.instruction_status=='0' ">就绪</span> <span v-if="scope.row.instruction_status=='0' ">就绪</span>
<span v-if="scope.row.instruction_status=='1' ">执行中</span> <span v-if="scope.row.instruction_status=='1' ">执行中</span>
<span v-if="scope.row.instruction_status=='2' ">完成</span> <span v-if="scope.row.instruction_status=='2' ">完成</span>
<span v-if="scope.row.instruction_status=='3' ">取消</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="send_status" label="下发状态"> <el-table-column prop="send_status" label="下发状态">
<template slot-scope="scope"> <template slot-scope="scope">
<span v-if="scope.row.send_status==null ">未下发</span>
<span v-if="scope.row.send_status=='0' ">未下发</span> <span v-if="scope.row.send_status=='0' ">未下发</span>
<span v-if="scope.row.send_status=='1' ">成功</span> <span v-if="scope.row.send_status=='1' ">成功</span>
<span v-if="scope.row.send_status=='2' ">失败</span> <span v-if="scope.row.send_status=='2' ">失败</span>

View File

@@ -97,22 +97,6 @@
<el-form-item v-if="false" label="任务标识" prop="task_id"> <el-form-item v-if="false" label="任务标识" prop="task_id">
<el-input v-model="form.task_id" style="width: 370px;" /> <el-input v-model="form.task_id" style="width: 370px;" />
</el-form-item> </el-form-item>
<el-form-item label="物料类型">
<el-select
v-model="form.material"
style="width: 370px;"
filterable
placeholder="请选择"
@change="isDisabled=false"
>
<el-option
v-for="item in dict.material_type"
:key="item.id"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="任务类型"> <el-form-item label="任务类型">
<el-select <el-select
v-model="form.task_type" v-model="form.task_type"
@@ -306,6 +290,22 @@
<!-- />--> <!-- />-->
<!-- </el-select>--> <!-- </el-select>-->
<!-- </el-form-item>--> <!-- </el-form-item>-->
<!-- <el-form-item label="物料类型">-->
<!-- <el-select-->
<!-- v-model="form.material"-->
<!-- style="width: 370px;"-->
<!-- filterable-->
<!-- placeholder="请选择"-->
<!-- @change="isDisabled=false"-->
<!-- >-->
<!-- <el-option-->
<!-- v-for="item in dict.material_type"-->
<!-- :key="item.id"-->
<!-- :label="item.label"-->
<!-- :value="item.value"-->
<!-- />-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item label="优先级"> <el-form-item label="优先级">
<el-input v-model="form.priority" style="width: 370px;" @change="isDisabled=false" /> <el-input v-model="form.priority" style="width: 370px;" @change="isDisabled=false" />
</el-form-item> </el-form-item>