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)) {
link_flag = true;
}
if (error != 0) {
//todo 反馈立库AGV故障信息
sendAgvErrorStatus(inst, device_code, Integer.parseInt(AgvActionEnum.ACTION_STATUS.code("请求取货")));
}
Device device = null;
String old_device_code = 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) {
if (inst == null) {
return;

View File

@@ -43,6 +43,19 @@ public class WmsToAcsController {
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")
@Log(value = "WMS取消任务")
@ApiOperation("WMS取消任务")

View File

@@ -113,7 +113,13 @@ public interface AcsToWmsService {
*/
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);
JSONObject allDeviceStatus();
/**
* 取消任务
*

View File

@@ -552,6 +552,30 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
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
public String applyTask(BaseRequest requestParam) {
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.dto.TaskDto;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.RedisUtils;
import org.nl.config.SpringContextHolder;
import org.nl.system.service.param.ISysParamService;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
@@ -67,6 +69,9 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
@Resource
private RedissonClient redissonClient;
@Resource
private RedisUtils redisUtils;
@Override
public CancelTaskResponse cancelFromWms(List<CancelTaskRequest> reqs) throws Exception {
ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
@@ -109,6 +114,22 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
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
public Map<String, Object> updateDeviceGoodsFromWms(String param) {
JSONArray datas = JSONArray.parseArray(param);

View File

@@ -1,23 +1,17 @@
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.copier.CopyOptions;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.*;
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.math.BigDecimal;
/**
* @author jiaolm
@@ -238,7 +232,12 @@ public class InstructionMybatis extends CommonModel<InstructionMybatis> implemen
@ApiModelProperty(value = "AGV系统类型")
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("查询指令")
//@PreAuthorize("@el.check('instruction:list')")
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
if(ObjectUtil.isEmpty(whereJson.get("status"))) {
whereJson.put("status", "1");
}
// if(ObjectUtil.isEmpty(whereJson.get("status"))) {
// whereJson.put("status", "1");
// }
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;
/**
* 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.ZheDaAgvService;
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.service.DeviceService;
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.ext.wms.liKuData.*;
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.service.InstructionService;
import org.nl.acs.instruction.service.dto.InstructionDto;
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.DeviceAppServiceImpl;
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.service.TaskService;
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.common.exception.BadRequestException;
import org.nl.acs.utils.ConvertUtil;
import org.nl.common.utils.FileUtil;
import org.nl.acs.utils.PageUtil;
import org.nl.acs.instruction.domain.Instruction;
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.exception.BadRequestException;
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.system.service.param.ISysParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
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 java.io.IOException;
@@ -192,11 +187,10 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
IPage<InstructionMybatis> queryPage = PageUtil.toMybatisPage(page);
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.like(StringUtils.isNotBlank(vehicle_code), InstructionMybatis::getVehicle_code, vehicle_code);
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.eq(StringUtils.isNotBlank(instruction_type), InstructionMybatis::getInstruction_type, instruction_type);
if (!StrUtil.isEmpty(is_over)) {
@@ -206,6 +200,11 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
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);
final JSONObject json = (JSONObject) JSON.toJSON(ConvertUtil.convertPage(insPage, InstructionDto.class));
return json;
@@ -337,22 +336,12 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
@Override
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<>();
wrapper.eq(InstructionMybatis::getTask_id, id);
wrapper.apply(StringUtils.isNotBlank(wherecaluse), wherecaluse);
InstructionMybatis ins = instructionMapper.selectOne(wrapper);
if (ObjectUtil.isNotEmpty(ins)) {
return ConvertUtil.convert(ins, Instruction.class);
List<InstructionMybatis> insList = instructionMapper.selectList(wrapper);
if (ObjectUtil.isNotEmpty(insList)) {
return ConvertUtil.convert(insList.get(0), Instruction.class);
}
return null;
}
@@ -362,6 +351,128 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
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.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 now = DateUtil.now();
@@ -467,9 +578,6 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
e.printStackTrace();
log.error("");
}
// WQLObject wo = WQLObject.getWQLObject("acs_instruction");
// JSONObject json = (JSONObject) JSONObject.toJSON(dto);
// wo.insert(json);
InstructionMybatis entity = ConvertUtil.convert(dto, InstructionMybatis.class);
instructionMapper.insert(entity);
instructions.add(dto);
@@ -480,8 +588,6 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
dto = foramte(dto);
String task_code = dto.getTask_code();
TaskDto task = taskService.findByCodeFromCache(task_code);
// WQLObject instwo = WQLObject.getWQLObject("acs_instruction");
String currentUsername = SecurityUtils.getCurrentUsername();
String now = DateUtil.now();
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()));
}
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 {
String start_device_code = dto.getStart_device_code();
String next_device_code = dto.getNext_device_code();

View File

@@ -38,10 +38,10 @@ public class TaskController {
@ApiOperation("查询任务")
//@PreAuthorize("@el.check('task:list')")
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
// return new ResponseEntity<>(taskService.queryAllByCache(whereJson, page), HttpStatus.OK);
// if(ObjectUtil.isEmpty(whereJson.get("status"))) {
// whereJson.put("status", "1");
// }
// return new ResponseEntity<>(taskService.queryAllByCache(whereJson, page), HttpStatus.OK);
// if(ObjectUtil.isEmpty(whereJson.get("status"))) {
// whereJson.put("status", "1");
// }
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;
try {
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) {
log.error("任务号:{},反馈wms任务状态失败,原因:{}!", entity.getTask_code(), e.getMessage());
} finally {
}
}
List<RouteLineDto> shortPathsList =
@@ -1181,6 +1185,101 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
@Override
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);
if (acsTask == null) {
throw new BadRequestException("被删除或无权限,操作失败!");
@@ -1274,10 +1373,7 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
@Override
public Instruction createInst(Instruction inst) throws Exception {
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl");
instructionservice.create2(inst);
return inst;
}

View File

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

View File

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

View File

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

View File

@@ -7,10 +7,10 @@ spring:
db-type: com.alibaba.druid.pool.DruidDataSource
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: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}
# password: ${DB_PWD:Root.123456}
password: ${DB_PWD:123456789}
password: ${DB_PWD:123456}
# 初始连接数
initial-size: 5
# 最小连接数