opt:
1.任务完成,取消,指令创建,指令完成,取消,自动创建指令,各源头异常记录。 2.修改RGV下发指令失败,指令取消未对接成功处理及日志记录
This commit is contained in:
@@ -108,13 +108,12 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
|
||||
agvport = paramService.findByCode(AcsConfig.RGVPORT).getValue();
|
||||
|
||||
agvurl = agvurl + ":" + agvport + "/transportOrders/query";
|
||||
log.info("下发agv查询状态请求:{}内容为:{}", agvurl);
|
||||
//log.info("下发agv查询状态请求:{}内容为:{}", agvurl);
|
||||
HttpResponse result = HttpRequest.post(agvurl)
|
||||
.body(String.valueOf(new JSONObject()))//表单内容
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute();
|
||||
log.info("查询agv指令数据:" + result.body());
|
||||
|
||||
return result;
|
||||
} else {
|
||||
return null;
|
||||
@@ -133,7 +132,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
|
||||
agvport = paramService.findByCode(AcsConfig.RGVPORT).getValue();
|
||||
|
||||
agvurl = agvurl + ":" + agvport + "/vehicles";
|
||||
log.info("下发agv查询设备状态请求:{}内容为:{}", agvurl);
|
||||
//log.info("下发agv查询设备状态请求:{}内容为:{}", agvurl);
|
||||
HttpResponse result = HttpRequest.post(agvurl)
|
||||
.body(String.valueOf(new JSONObject()))//表单内容
|
||||
.timeout(20000)//超时,毫秒
|
||||
@@ -462,7 +461,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService {
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) {
|
||||
String agvurl = paramService.findByCode(AcsConfig.RGVURL).getValue();
|
||||
String agvport = paramService.findByCode(AcsConfig.RGVPORT).getValue();
|
||||
Instruction instruction = instructionService.findByCode(instCode);
|
||||
//Instruction instruction = instructionService.findByCode(instCode);
|
||||
agvurl = agvurl + ":" + agvport + "/transportOrders/" + instCode + "/withdrawal";
|
||||
log.info("删除agv指令请求agvurl:{}", agvurl);
|
||||
HttpResponse result = HttpRequest.post(agvurl)
|
||||
|
||||
@@ -112,7 +112,6 @@ public class GuhuashiSiteDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
public void execute() {
|
||||
String message = null;
|
||||
try {
|
||||
//todo 错误码转换
|
||||
devicecode = this.getDeviceCode();
|
||||
VW7010 = this.itemProtocol.getVW7010();
|
||||
VW7012 = this.itemProtocol.getVW7012();
|
||||
@@ -120,9 +119,6 @@ public class GuhuashiSiteDeviceDriver extends AbstractOpcDeviceDriver implements
|
||||
VW7016 = this.itemProtocol.getVW7016();
|
||||
VW7018 = this.itemProtocol.getVW7018();
|
||||
VW7020 = this.itemProtocol.getVW7020();
|
||||
if("GHS01".equals(devicecode)){
|
||||
log.info("123");
|
||||
}
|
||||
VW7022 = this.itemProtocol.getVW7022();
|
||||
VW7024 = this.itemProtocol.getVW7024();
|
||||
VW7026 = this.itemProtocol.getVW7026();
|
||||
|
||||
@@ -99,7 +99,7 @@ public class InstructionController {
|
||||
@ApiOperation("完成指令")
|
||||
@PostMapping(value = "/finish/{id}")
|
||||
public ResponseEntity<Object> finish(@RequestBody String id) throws Exception {
|
||||
instructionService.finish(id);
|
||||
instructionService.finish(id, "1");
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -181,6 +181,8 @@ public interface InstructionService extends CommonService<InstructionMybatis> {
|
||||
*/
|
||||
void finish(String id) throws Exception;
|
||||
|
||||
void finish(String id,String operationType)throws Exception;
|
||||
|
||||
/**
|
||||
* 完成指令
|
||||
*
|
||||
|
||||
@@ -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,30 +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.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;
|
||||
@@ -354,9 +350,9 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
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;
|
||||
}
|
||||
@@ -388,14 +384,13 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
if (StrUtil.isEmpty(dto.getLink_num())) {
|
||||
dto.setIs_send(task.getLink_num());
|
||||
}
|
||||
// if (task.getTask_type().equals("1") || task.getTask_type().equals("2")) {
|
||||
// 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");
|
||||
// }
|
||||
|
||||
// } else if (false) {
|
||||
//
|
||||
// } else {
|
||||
// dto.setInstruction_type("3");
|
||||
// }
|
||||
// 查询是否存在相同指令号
|
||||
// if (!StrUtil.isEmpty(dto.getVehicle_code() )) {
|
||||
// Instruction inst_dto = findByContainer(dto.getVehicle_code());
|
||||
@@ -412,7 +407,6 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
dto.setCompound_inst_data(task.getCompound_task_data());
|
||||
}
|
||||
}
|
||||
//todo 增加lms任务id
|
||||
dto.setExt_task_id(task.getExt_task_id());
|
||||
dto.setCreate_by(ObjectUtil.isNotEmpty(currentUsername) ? currentUsername : "admin");
|
||||
dto.setUpdate_by(ObjectUtil.isNotEmpty(currentUsername) ? currentUsername : "admin");
|
||||
@@ -461,21 +455,34 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
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) {
|
||||
dto.setSend_status("2");
|
||||
e.printStackTrace();
|
||||
log.error("");
|
||||
dto.setRemark("失败原因:"+ e.getMessage());
|
||||
log.error("创建指令失败,任务id为:" + task.getTask_id(), "失败原因:" + e.getMessage());
|
||||
if (task != null) {
|
||||
task.setRemark("自动创建指令失败,失败原因:"+ e.getMessage());
|
||||
taskService.update(task);
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
@@ -487,7 +494,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
String task_code = dto.getTask_code();
|
||||
TaskDto task = taskService.findByCodeFromCache(task_code);
|
||||
|
||||
// WQLObject instwo = WQLObject.getWQLObject("acs_instruction");
|
||||
// WQLObject instwo = WQLObject.getWQLObject("acs_instruction");
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
if (StrUtil.isEmpty(dto.getRoute_plan_code())) {
|
||||
@@ -578,18 +585,30 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
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) {
|
||||
dto.setRemark("失败原因:"+e.getMessage());
|
||||
dto.setSend_status("2");
|
||||
e.printStackTrace();
|
||||
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);
|
||||
@@ -599,7 +618,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
public void createAgain(Instruction dto) throws Exception {
|
||||
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())) {
|
||||
@@ -619,19 +638,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
}
|
||||
String type = shortPathsList.get(0).getType();
|
||||
if (!StrUtil.equals(type, "0")) {
|
||||
// JSONObject instcheckjson =
|
||||
// instwo
|
||||
// .query(
|
||||
// " instruction_status <3 and next_point_code= '"
|
||||
// + dto.getNext_point_code()
|
||||
// + "'"
|
||||
// + " and start_point_code = '"
|
||||
// + dto.getStart_point_code()
|
||||
// + "'"
|
||||
// + " and task_id = '"
|
||||
// + dto.getTask_id()
|
||||
// + "'")
|
||||
// .uniqueResult(0);
|
||||
|
||||
InstructionMybatis ins = new LambdaQueryChainWrapper<>(instructionMapper)
|
||||
.lt(InstructionMybatis::getInstruction_status, 3)
|
||||
.eq(InstructionMybatis::getNext_point_code, dto.getNext_point_code())
|
||||
@@ -656,11 +663,6 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
dto.setUpdate_time(now);
|
||||
dto.setCreate_time(now);
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -756,14 +758,25 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish(String id,String operationType) {
|
||||
finish(id);
|
||||
InstructionDto entity = this.findById(id);
|
||||
entity.setRemark("指令被PC端手动完成");
|
||||
InstructionMybatis ins = ConvertUtil.convert(entity, InstructionMybatis.class);
|
||||
instructionMapper.updateById(ins);
|
||||
log.error("指令被PC端手动完成,任务号:{}", entity.getTask_code());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void finish(String id) {
|
||||
InstructionDto entity = this.findById(id);
|
||||
if (ObjectUtil.isEmpty(entity)||"3".equals(entity.getInstruction_status())) {
|
||||
log.error("指令{}被删除或无权限,操作失败!",id);
|
||||
return;
|
||||
}
|
||||
if (ObjectUtil.isEmpty(entity) || "3".equals(entity.getInstruction_status())) {
|
||||
log.error("指令{}被删除或无权限,操作失败!", id);
|
||||
return;
|
||||
}
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
entity.setUpdate_time(now);
|
||||
@@ -771,7 +784,6 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
entity.setInstruction_status("2");
|
||||
String instnextdevice = entity.getNext_device_code();
|
||||
String insttaskid = entity.getTask_id();
|
||||
// WQLObject taskwo = WQLObject.getWQLObject("acs_task");
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
Device startdevice = appService.findDeviceByCode(entity.getStart_device_code());
|
||||
if (ObjectUtils.isEmpty(startdevice)) {
|
||||
@@ -823,15 +835,10 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
jo.put("islock", "0");
|
||||
deviceService.changeDeviceStatus(jo);
|
||||
|
||||
// WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
||||
// JSONObject json = (JSONObject) JSONObject.toJSON(entity);
|
||||
// wo.update(json);
|
||||
|
||||
InstructionMybatis ins = ConvertUtil.convert(entity, InstructionMybatis.class);
|
||||
instructionMapper.updateById(ins);
|
||||
|
||||
// JSONObject taskjson = taskwo.query("task_id ='" + insttaskid + "'").uniqueResult(0);
|
||||
// TaskDto obj = taskjson.toJavaObject(TaskDto.class);
|
||||
|
||||
Task task = new LambdaQueryChainWrapper<>(taskMapper)
|
||||
.eq(Task::getTask_id, insttaskid)
|
||||
@@ -839,78 +846,76 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
// =0 则不用再次请求
|
||||
if (StrUtil.equals(task.getRequest_again(), "0")) {
|
||||
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
|
||||
taskService.finish(task.getTask_id());
|
||||
taskService.finish(task.getTask_id(),"0");
|
||||
} else {
|
||||
finishAndCreateNextInst(new Instruction(entity));
|
||||
}
|
||||
}
|
||||
|
||||
removeByCodeFromCache(entity.getInstruction_code());
|
||||
// this.reload();
|
||||
// this.reload();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void finish(Instruction dto) {
|
||||
String now = DateUtil.now();
|
||||
dto.setInstruction_status("2");
|
||||
// WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
||||
// JSONObject json = (JSONObject) JSONObject.toJSON(dto);
|
||||
//
|
||||
// wo.update(json);
|
||||
|
||||
InstructionMybatis ins = ConvertUtil.convert(dto, InstructionMybatis.class);
|
||||
instructionMapper.updateById(ins);
|
||||
try {
|
||||
|
||||
String instnextdevice = dto.getNext_device_code();
|
||||
String insttaskid = dto.getTask_id();
|
||||
// WQLObject taskwo = WQLObject.getWQLObject("acs_task");
|
||||
// JSONObject taskjson = taskwo.query("task_id ='" + insttaskid + "'").uniqueResult(0);
|
||||
// TaskDto obj = taskjson.toJavaObject(TaskDto.class);
|
||||
dto.setInstruction_status("2");
|
||||
|
||||
Task task = new LambdaQueryChainWrapper<>(taskMapper)
|
||||
.eq(Task::getTask_id, insttaskid)
|
||||
.one();
|
||||
// =0 则不用再次请求
|
||||
if (StrUtil.equals(task.getRequest_again(), "0")) {
|
||||
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
|
||||
taskService.finish(task.getTask_id());
|
||||
} else {
|
||||
finishAndCreateNextInst(dto);
|
||||
InstructionMybatis ins = ConvertUtil.convert(dto, InstructionMybatis.class);
|
||||
instructionMapper.updateById(ins);
|
||||
|
||||
String instnextdevice = dto.getNext_device_code();
|
||||
String insttaskid = dto.getTask_id();
|
||||
|
||||
|
||||
Task task = new LambdaQueryChainWrapper<>(taskMapper)
|
||||
.eq(Task::getTask_id, insttaskid)
|
||||
.one();
|
||||
// =0 则不用再次请求
|
||||
if (StrUtil.equals(task.getRequest_again(), "0")) {
|
||||
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
|
||||
taskService.finish(task.getTask_id(),"1");
|
||||
} else {
|
||||
finishAndCreateNextInst(dto);
|
||||
}
|
||||
}
|
||||
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
||||
Device device = appService.findDeviceByCode(instnextdevice);
|
||||
if (device == null) {
|
||||
log.debug("地址对应设备未找到");
|
||||
return;
|
||||
}
|
||||
// 如果是无光电的设备 放货任务完成需要变更有货状态
|
||||
// StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
|
||||
// if(device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
// standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver)
|
||||
// device.getDeviceDriver();
|
||||
// standardOrdinarySiteDeviceDriver.setMove(2);
|
||||
// }
|
||||
|
||||
// 如果是无光电的设备 指令完成变更起点、终点状态
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", dto.getStart_point_code());
|
||||
jo.put("hasGoodStatus", "0");
|
||||
jo.put("material_type", "");
|
||||
jo.put("batch", "");
|
||||
deviceService.changeDeviceStatus(jo);
|
||||
|
||||
JSONObject jo1 = new JSONObject();
|
||||
jo1.put("device_code", dto.getNext_point_code());
|
||||
jo1.put("hasGoodStatus", "1");
|
||||
jo1.put("material_type", dto.getMaterial());
|
||||
jo1.put("batch", dto.getBatch());
|
||||
deviceService.changeDeviceStatus(jo1);
|
||||
removeByCodeFromCache(dto.getInstruction_code());
|
||||
log.info("RGV反馈任务完成成功!指令号:{}", ins.getInstruction_code());
|
||||
} catch (Exception e) {
|
||||
log.error("RGV反馈任务失败!任务id为:{},指令号为:{}", dto.getInstruction_code(), e.getMessage());
|
||||
}
|
||||
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
||||
Device device = appService.findDeviceByCode(instnextdevice);
|
||||
if (device == null) {
|
||||
log.debug("地址对应设备未找到");
|
||||
return;
|
||||
}
|
||||
// 如果是无光电的设备 放货任务完成需要变更有货状态
|
||||
// StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
|
||||
// if(device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
|
||||
// standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver)
|
||||
// device.getDeviceDriver();
|
||||
// standardOrdinarySiteDeviceDriver.setMove(2);
|
||||
// }
|
||||
|
||||
// 如果是无光电的设备 指令完成变更起点、终点状态
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", dto.getStart_point_code());
|
||||
jo.put("hasGoodStatus", "0");
|
||||
jo.put("material_type", "");
|
||||
jo.put("batch", "");
|
||||
deviceService.changeDeviceStatus(jo);
|
||||
|
||||
JSONObject jo1 = new JSONObject();
|
||||
jo1.put("device_code", dto.getNext_point_code());
|
||||
jo1.put("hasGoodStatus", "1");
|
||||
jo1.put("material_type", dto.getMaterial());
|
||||
jo1.put("batch", dto.getBatch());
|
||||
deviceService.changeDeviceStatus(jo1);
|
||||
|
||||
removeByCodeFromCache(dto.getInstruction_code());
|
||||
// this.reload();
|
||||
}
|
||||
|
||||
@@ -919,9 +924,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
public void finishAndCreateNextInst(Instruction dto) {
|
||||
dto = foramte(dto);
|
||||
String device_code = dto.getNext_device_code();
|
||||
// WQLObject taskwo = WQLObject.getWQLObject("acs_task");
|
||||
// JSONObject taskjson = taskwo.query("task_id ='" + dto.getTask_id() + "'").uniqueResult(0);
|
||||
// TaskDto acsTask = taskjson.toJavaObject(TaskDto.class);
|
||||
|
||||
Task acsTask = new LambdaQueryChainWrapper<>(taskMapper)
|
||||
.eq(Task::getTask_id, dto.getTask_id())
|
||||
.one();
|
||||
@@ -1010,83 +1013,88 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
if (StrUtil.isEmpty(entity.getRoute_plan_code())) {
|
||||
entity.setRoute_plan_code(task.getRoute_plan_code());
|
||||
}
|
||||
|
||||
// != 0 为agv任务 1=magic 2=NDC 3=XZ,4=ZHEDA
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "1")
|
||||
&& !StrUtil.equals(entity.getSend_status(), "2")) {
|
||||
MagicAgvService magicAgvService = SpringContextHolder.getBean(MagicAgvService.class);
|
||||
magicAgvService.deleteAgvInst(entity.getInstruction_code());
|
||||
flag = true;
|
||||
|
||||
} else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) {
|
||||
// NDC agv指令不当场取消指令,需要等agv上报
|
||||
if (!StrUtil.isEmpty(entity.getAgv_jobno())) {
|
||||
ndcAgvService.deleteAgvInstToNDC(new Instruction(entity));
|
||||
}
|
||||
// } else {
|
||||
flag = true;
|
||||
// }
|
||||
} else {
|
||||
flag = true;
|
||||
}
|
||||
if (StrUtil.equals(entity.getInstruction_type(), "4") ||
|
||||
StrUtil.equals(entity.getInstruction_type(), "3")) {
|
||||
ZheDaAgvService zheDaAgvService = SpringContextHolder.getBean(ZheDaAgvService.class);
|
||||
zheDaAgvService.deleteZDAgvInst(entity.getInstruction_code());
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
entity.setUpdate_time(now);
|
||||
entity.setUpdate_by(currentUsername);
|
||||
entity.setInstruction_status("3");
|
||||
// WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
||||
// JSONObject json = (JSONObject) JSONObject.toJSON(entity);
|
||||
// wo.update(json);
|
||||
InstructionMybatis ins = ConvertUtil.convert(entity, InstructionMybatis.class);
|
||||
instructionMapper.updateById(ins);
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
||||
|
||||
// 如果是无光电的设备 指令完成变更起点、终点状态
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", entity.getStart_device_code());
|
||||
if (StrUtil.equals(entity.getMaterial(), "1")) {
|
||||
jo.put("hasGoodStatus", "1");
|
||||
} else if (!StrUtil.equals(entity.getMaterial(), "1")
|
||||
&& !StrUtil.isEmpty(entity.getMaterial())) {
|
||||
jo.put("hasGoodStatus", "2");
|
||||
try {
|
||||
// != 0 为agv任务 1=magic 2=NDC 3=XZ,4=ZHEDA
|
||||
if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "1")
|
||||
&& !StrUtil.equals(entity.getSend_status(), "2")) {
|
||||
MagicAgvService magicAgvService = SpringContextHolder.getBean(MagicAgvService.class);
|
||||
magicAgvService.deleteAgvInst(entity.getInstruction_code());
|
||||
flag = true;
|
||||
} else if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) {
|
||||
// NDC agv指令不当场取消指令,需要等agv上报
|
||||
if (!StrUtil.isEmpty(entity.getAgv_jobno())) {
|
||||
ndcAgvService.deleteAgvInstToNDC(new Instruction(entity));
|
||||
}
|
||||
// } else {
|
||||
flag = true;
|
||||
// }
|
||||
} else {
|
||||
jo.put("hasGoodStatus", "0");
|
||||
flag = true;
|
||||
}
|
||||
jo.put("material_type", entity.getMaterial());
|
||||
jo.put("batch", entity.getBatch());
|
||||
jo.put("islock", "false");
|
||||
deviceService.changeDeviceStatus(jo);
|
||||
flag = true;
|
||||
if (StrUtil.equals(entity.getInstruction_type(), "4") ||
|
||||
StrUtil.equals(entity.getInstruction_type(), "3")) {
|
||||
ZheDaAgvService zheDaAgvService = SpringContextHolder.getBean(ZheDaAgvService.class);
|
||||
HttpResponse result = zheDaAgvService.deleteZDAgvInst(entity.getInstruction_code());
|
||||
if (result.getStatus() == 200) {
|
||||
flag = true;
|
||||
} else {
|
||||
log.error("下发rgv取消指令动作失败,下发AGV/RGV任务失败!任务id为:{},指令号为:{},失败原因{}", task.getTask_id(), entity.getInstruction_code(), "AGV/RGV未响应!");
|
||||
if (task != null) {
|
||||
task.setRemark("下发rgv取消指令动作失败!失败原因: 连接AGV/RGV未响应!");
|
||||
taskService.update(task);
|
||||
}
|
||||
flag = false;
|
||||
}
|
||||
if (flag) {
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
String now = DateUtil.now();
|
||||
entity.setUpdate_time(now);
|
||||
entity.setUpdate_by(currentUsername);
|
||||
entity.setInstruction_status("3");
|
||||
InstructionMybatis ins = ConvertUtil.convert(entity, InstructionMybatis.class);
|
||||
instructionMapper.updateById(ins);
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class);
|
||||
// 如果是无光电的设备 指令完成变更起点、终点状态
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", entity.getStart_device_code());
|
||||
if (StrUtil.equals(entity.getMaterial(), "1")) {
|
||||
jo.put("hasGoodStatus", "1");
|
||||
} else if (!StrUtil.equals(entity.getMaterial(), "1")
|
||||
&& !StrUtil.isEmpty(entity.getMaterial())) {
|
||||
jo.put("hasGoodStatus", "2");
|
||||
} else {
|
||||
jo.put("hasGoodStatus", "0");
|
||||
}
|
||||
jo.put("material_type", entity.getMaterial());
|
||||
jo.put("batch", entity.getBatch());
|
||||
jo.put("islock", "false");
|
||||
deviceService.changeDeviceStatus(jo);
|
||||
JSONObject jo1 = new JSONObject();
|
||||
jo1.put("device_code", entity.getNext_device_code());
|
||||
jo.put("hasGoodStatus", "0");
|
||||
jo.put("material_type", "");
|
||||
jo.put("batch", "");
|
||||
jo1.put("islock", "false");
|
||||
deviceService.changeDeviceStatus(jo1);
|
||||
|
||||
JSONObject jo1 = new JSONObject();
|
||||
jo1.put("device_code", entity.getNext_device_code());
|
||||
jo.put("hasGoodStatus", "0");
|
||||
jo.put("material_type", "");
|
||||
jo.put("batch", "");
|
||||
jo1.put("islock", "false");
|
||||
deviceService.changeDeviceStatus(jo1);
|
||||
|
||||
String instnextdevice = entity.getNext_device_code();
|
||||
Device device = appService.findDeviceByCode(instnextdevice);
|
||||
if (device == null) {
|
||||
log.debug("地址对应设备未找到");
|
||||
return;
|
||||
String instnextdevice = entity.getNext_device_code();
|
||||
Device device = appService.findDeviceByCode(instnextdevice);
|
||||
if (device == null) {
|
||||
log.debug("地址对应设备未找到");
|
||||
return;
|
||||
}
|
||||
removeByCodeFromCache(entity.getInstruction_code());
|
||||
}
|
||||
}
|
||||
removeByCodeFromCache(entity.getInstruction_code());
|
||||
// taskService.cancel(entity.getTask_id());
|
||||
} catch (Exception e) {
|
||||
log.error("指令取消失败!失败原因:{}", e.getMessage());
|
||||
throw new BadRequestException("指令取消失败!失败原因:" + e.getMessage());
|
||||
}
|
||||
// this.reload();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void forceCancel(String id) throws Exception {
|
||||
// flag= true时取消指令
|
||||
@@ -1104,9 +1112,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
entity.setUpdate_time(now);
|
||||
entity.setUpdate_by(currentUsername);
|
||||
entity.setInstruction_status("3");
|
||||
// WQLObject wo = WQLObject.getWQLObject("acs_instruction");
|
||||
// JSONObject json = (JSONObject) JSONObject.toJSON(entity);
|
||||
// wo.update(json);
|
||||
entity.setRemark("指令被PC端手动取消");
|
||||
InstructionMybatis ins = ConvertUtil.convert(entity, InstructionMybatis.class);
|
||||
instructionMapper.updateById(ins);
|
||||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
@@ -1142,6 +1148,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
return;
|
||||
}
|
||||
removeByCodeFromCache(entity.getInstruction_code());
|
||||
log.error("指令被PC端手动取消,指令号:{},任务号:{}", entity.getInstruction_code(),entity.getTask_code());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -112,7 +112,7 @@ public class TaskController {
|
||||
@ApiOperation("完成任务")
|
||||
@PostMapping(value = "/finish/{id}")
|
||||
public ResponseEntity<Object> finish(@RequestBody String id) {
|
||||
taskService.finish(id);
|
||||
taskService.finish(id, "2");
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -215,8 +215,9 @@ public interface TaskService extends CommonService<Task> {
|
||||
* 完成任务
|
||||
*
|
||||
* @param ids
|
||||
* @param operationType
|
||||
*/
|
||||
void finish(String ids);
|
||||
void finish(String ids,String operationType);
|
||||
|
||||
/**
|
||||
* 取消任务
|
||||
|
||||
@@ -5,7 +5,6 @@ import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
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;
|
||||
@@ -16,6 +15,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.AcsConfig;
|
||||
import org.nl.acs.agv.server.XianGongAgvService;
|
||||
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.enums.DeviceType;
|
||||
import org.nl.acs.device.service.DeviceAssignedService;
|
||||
@@ -36,35 +38,27 @@ import org.nl.acs.route.service.dto.RouteLineDto;
|
||||
import org.nl.acs.route.service.mapper.RoutePlanMapper;
|
||||
import org.nl.acs.storage_cell.service.StorageCellService;
|
||||
import org.nl.acs.task.TaskInstructionLock;
|
||||
import org.nl.acs.task.service.TaskFeedbackService;
|
||||
import org.nl.acs.task.service.dto.TaskFeedbackDto;
|
||||
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.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.task.domain.Task;
|
||||
import org.nl.acs.task.service.TaskFeedbackService;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.acs.task.service.dto.TaskFeedbackDto;
|
||||
import org.nl.acs.task.service.dto.TaskQueryParam;
|
||||
import org.nl.acs.task.service.mapper.TaskMapper;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.nl.acs.utils.ConvertUtil;
|
||||
import org.nl.acs.utils.PageUtil;
|
||||
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.context.annotation.Lazy;
|
||||
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;
|
||||
@@ -899,9 +893,12 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* operationType 1自动完成 2手动完成 3手持完成
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void finish(String id) {
|
||||
public void finish(String id, String operationType) {
|
||||
TaskDto entity = this.findById(id);
|
||||
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
|
||||
InstructionService instructionservice = SpringContextHolder.getBean("instructionServiceImpl");
|
||||
@@ -912,10 +909,15 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
entity.setUpdate_time(now);
|
||||
entity.setUpdate_by(currentUsername);
|
||||
entity.setTask_status("2");
|
||||
|
||||
if ("2".equals(operationType)) {
|
||||
log.error("任务被PC端手动完成,任务号:{}", entity.getTask_code());
|
||||
entity.setRemark("任务被PC端手动完成");
|
||||
} else if ("3".equals(operationType)) {
|
||||
log.error("任务被手持端手动完成,任务号:{}", entity.getTask_code());
|
||||
entity.setRemark("任务被手持端手动完成");
|
||||
}
|
||||
Task task = ConvertUtil.convert(entity, Task.class);
|
||||
taskMapper.updateById(task);
|
||||
|
||||
removeByCodeFromCache(entity.getTask_code());
|
||||
// 判断是否为WMS下发的任务,如果是反馈任务状态给WMS
|
||||
String hasWms = paramService.findByCode(AcsConfig.HASWMS).getValue();
|
||||
@@ -926,17 +928,17 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
request.setTask_status(entity.getTask_status());
|
||||
request.setRequest_medthod_code(RequestMethodEnum.feedback_task_status.getCode());
|
||||
request.setRequest_medthod_name(RequestMethodEnum.feedback_task_status.getName());
|
||||
boolean flag = false;
|
||||
String resp = null;
|
||||
try {
|
||||
resp = acstowmsService.feedTaskStatus(request);
|
||||
log.info("任务号:{},反馈wms任务状态完成成功,响应信息:{}!", entity.getTask_code(), resp);
|
||||
JSONObject result = JSONObject.parseObject(resp);
|
||||
if (result.getString("code").equals("200")) {
|
||||
log.info("任务号:{},反馈wms任务状态完成成功,响应信息:{}!", entity.getTask_code(), resp);
|
||||
} else {
|
||||
log.error("任务号:{},反馈wms任务状态失败,原因:{}!", entity.getTask_code(), result.getString("message"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("任务号:{},反馈wms任务状态失败,原因:{}!", entity.getTask_code(), e.getMessage());
|
||||
flag = true;
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
|
||||
}
|
||||
}
|
||||
// 如果属于先知AGV,关闭运单序列
|
||||
@@ -966,20 +968,20 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
entity.setUpdate_time(now);
|
||||
entity.setUpdate_by(currentUsername);
|
||||
entity.setTask_status("3");
|
||||
|
||||
entity.setRemark("任务被PC端手动取消");
|
||||
Task task = ConvertUtil.convert(entity, Task.class);
|
||||
taskMapper.updateById(task);
|
||||
log.error("任务被手动取消,任务号:{}", entity.getTask_code());
|
||||
|
||||
|
||||
// synchronized (TaskServiceImpl.class){
|
||||
// Iterator<TaskDto> it = tasks.iterator();
|
||||
// // 清理缓存
|
||||
// while (it.hasNext()) {
|
||||
// TaskDto taskDto = it.next();
|
||||
// if (taskDto.getTask_id().equals(id)) {
|
||||
// tasks.remove(taskDto);
|
||||
// }
|
||||
// }}
|
||||
// synchronized (TaskServiceImpl.class){
|
||||
// Iterator<TaskDto> it = tasks.iterator();
|
||||
// // 清理缓存
|
||||
// while (it.hasNext()) {
|
||||
// TaskDto taskDto = it.next();
|
||||
// if (taskDto.getTask_id().equals(id)) {
|
||||
// tasks.remove(taskDto);
|
||||
// }
|
||||
// }}
|
||||
|
||||
removeByCodeFromCache(entity.getTask_code());
|
||||
|
||||
@@ -999,8 +1001,6 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
log.info("任务号:{},反馈wms任务状态完成成功,响应信息:{}!", entity.getTask_code(), resp);
|
||||
} catch (Exception e) {
|
||||
log.error("任务号:{},反馈wms任务状态失败,原因:{}!", entity.getTask_code(), e.getMessage());
|
||||
} finally {
|
||||
|
||||
}
|
||||
}
|
||||
List<RouteLineDto> shortPathsList =
|
||||
@@ -1203,13 +1203,16 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
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();
|
||||
@@ -1255,7 +1258,6 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
} else {
|
||||
next_point_code = next_device_code;
|
||||
}
|
||||
|
||||
Instruction instdto = new Instruction();
|
||||
instdto.setInstruction_type(task_type);
|
||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||
@@ -1284,10 +1286,12 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
instdto.setAgv_system_type(agv_system_type);
|
||||
instdto.setAgv_inst_type("1");
|
||||
instdto.setExt_task_id(acsTask.getExt_task_id());
|
||||
instructionservice.create2(instdto);
|
||||
|
||||
// acsTask.setTask_status("1");
|
||||
// this.update(acsTask);
|
||||
try {
|
||||
instructionservice.create2(instdto);
|
||||
log.info("手动创建指令成功!任务id为:{},指令号为:{}", acsTask.getTask_id(), instdto.getInstruction_code());
|
||||
} catch (Exception e) {
|
||||
log.error("手动创建指令失败!任务id为:{},指令号为:{},失败原因{}", acsTask.getTask_id(), instdto.getInstruction_code(), e.getMessage());
|
||||
}
|
||||
return instdto;
|
||||
}
|
||||
|
||||
|
||||
@@ -443,7 +443,7 @@ public class HandServiceImpl implements HandService {
|
||||
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
|
||||
taskIdAndStatusDTO.setTask_id(task_uuid);
|
||||
taskIdAndStatusDTO.setTask_status(TaskStatusEnum.FINISHED.getIndex());
|
||||
taskserver.finish(task_uuid);
|
||||
taskserver.finish(task_uuid,"3");
|
||||
}
|
||||
resultJson.put("message", "操作成功");
|
||||
resultJson.put("data", data);
|
||||
|
||||
@@ -78,8 +78,6 @@ public class AutoCreateInst {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 开始平均分解校验
|
||||
*/
|
||||
@@ -202,6 +200,8 @@ public class AutoCreateInst {
|
||||
instructionService.create(instdto);
|
||||
} catch (Exception e) {
|
||||
acsTask.setRemark(e.getMessage());
|
||||
//自动创建指令失败,保存失败原因
|
||||
taskserver.update(acsTask);
|
||||
taskserver.updateByCodeFromCache(acsTask);
|
||||
continue;
|
||||
}
|
||||
@@ -209,7 +209,6 @@ public class AutoCreateInst {
|
||||
//创建指令后修改任务状态
|
||||
acsTask.setTask_status("1");
|
||||
taskserver.update(acsTask);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ public class QueryZDAgvTaskStatus {
|
||||
HttpResponse response2 = agvService.queryAgvInstStatus("1");
|
||||
//查询AGV指令列表
|
||||
JSONArray inst_rows2 = JSONArray.parseArray(response2.body());
|
||||
// JSONArray inst_rows2 = JSONArray.parseArray("");
|
||||
for (int i = 0; i < inst_rows2.size(); i++) {
|
||||
JSONObject inst_jo = inst_rows2.getJSONObject(i);
|
||||
String inst_code = inst_jo.getString("task_code");
|
||||
@@ -51,7 +50,6 @@ public class QueryZDAgvTaskStatus {
|
||||
}
|
||||
//反馈结果状态
|
||||
log.info("instcode:" + inst_code + "," + inst_jo.toString());
|
||||
|
||||
String status = inst_jo.getString("status");
|
||||
String vehicle = "";
|
||||
//正在执行指令agv车号
|
||||
@@ -59,15 +57,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) {
|
||||
@@ -88,18 +85,20 @@ public class QueryZDAgvTaskStatus {
|
||||
siteDeviceDriver.writing(10);
|
||||
siteDeviceDriver.writing(10);
|
||||
}catch(Exception e){
|
||||
log.error("写入信号失败:{}{}",e,e.getMessage());
|
||||
log.error("RGV反馈任务完成,写入检测站点驱动信号失败:{}{}",e,e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
inst.setInstruction_status("2");
|
||||
instructionService.finish(inst);
|
||||
log.info("RGV反馈任务完成成功!指令号:{}",inst_code);
|
||||
}
|
||||
} else if ("WITHDRAWN".equals(status) || "FAILED".equals(status)) {
|
||||
if (inst != null) {
|
||||
inst.setInstruction_status("3");
|
||||
instructionService.update(inst);
|
||||
instructionService.removeByCodeFromCache(inst_jo.getString("task_code"));
|
||||
log.info("RGV反馈任务撤销成功!指令号:{}",inst_code);
|
||||
}
|
||||
}
|
||||
JSONArray ja = inst_jo.getJSONArray("destinations");
|
||||
@@ -120,7 +119,7 @@ public class QueryZDAgvTaskStatus {
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
|
||||
log.error("自动线程开始查询浙大AGV任务状态失败!失败原因:{}", e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -60,12 +61,12 @@ public class SyncDeviceStatus {
|
||||
JSONArray jsonArray = JSONArray.parseArray(response.body());
|
||||
//查询RGV指令列表
|
||||
Map<String, String> taskCodeToTaskIdMap = new HashMap<>();
|
||||
List<String> task_codes = jsonArray.stream()
|
||||
List<String> taskCodes = jsonArray.stream()
|
||||
.map(r -> ((JSONObject) r).getString("task_code"))
|
||||
.filter(task_code -> task_code != null && !task_code.isEmpty())
|
||||
.filter(r -> r != null && !r.isEmpty())
|
||||
.collect(Collectors.toList());
|
||||
if (ObjectUtil.isNotEmpty(task_codes)) {
|
||||
List<InstructionMybatis> instructionList = instructionService.list(new LambdaQueryWrapper<InstructionMybatis>().in(InstructionMybatis::getInstruction_code, task_codes));
|
||||
if (ObjectUtil.isNotEmpty(taskCodes)) {
|
||||
List<InstructionMybatis> instructionList = instructionService.list(new LambdaQueryWrapper<InstructionMybatis>().in(InstructionMybatis::getInstruction_code, taskCodes));
|
||||
taskCodeToTaskIdMap = instructionList.stream()
|
||||
.filter(instruction -> StringUtils.isNotBlank(instruction.getExt_task_id()))
|
||||
.collect(Collectors.toMap(
|
||||
@@ -89,7 +90,7 @@ public class SyncDeviceStatus {
|
||||
});
|
||||
redisUtils.set("RGV", jsonArray);
|
||||
} catch (Exception e) {
|
||||
log.error("自动上报驱动状态,查询浙大RGV设备状态失败{}{}", e, e.getMessage());
|
||||
// log.error("自动上报驱动状态,查询浙大RGV设备状态失败{}{}", e, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +101,7 @@ public class SyncDeviceStatus {
|
||||
JSONArray guhuashi = new JSONArray();
|
||||
JSONArray site = new JSONArray();
|
||||
JSONArray agv = new JSONArray();
|
||||
log.info("自动线程开始查询agv设备状态");
|
||||
//log.info("自动线程开始查询agv设备状态");
|
||||
List<Device> deviceList = deviceAppService.findAllDevice();
|
||||
for (Device device : deviceList) {
|
||||
if (device.getDeviceDriver() instanceof BaoshijianSiteDeviceDriver) {
|
||||
@@ -187,8 +188,13 @@ public class SyncDeviceStatus {
|
||||
List<String> deviceCodes = agv.stream()
|
||||
.map(r -> {
|
||||
String deviceCode = ((JSONObject) r).getString("device_code");
|
||||
return deviceCode.substring(deviceCode.length() - 1);
|
||||
if (StringUtils.isNotBlank(deviceCode)) {
|
||||
return deviceCode.substring(deviceCode.length() - 1);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
if (ObjectUtil.isNotEmpty(deviceCodes)) {
|
||||
List<InstructionMybatis> instructionList = instructionService.list(new LambdaQueryWrapper<InstructionMybatis>().in(InstructionMybatis::getCarno, deviceCodes).lt(InstructionMybatis::getInstruction_status, 2).eq(InstructionMybatis::getIs_delete, 0));
|
||||
@@ -212,9 +218,9 @@ public class SyncDeviceStatus {
|
||||
|
||||
}
|
||||
redisUtils.set("agv", agv);
|
||||
log.trace("自动上报驱动状态,完毕耗时{}", System.currentTimeMillis() - startTime);
|
||||
// log.trace("自动上报驱动状态,完毕耗时{}", System.currentTimeMillis() - startTime);
|
||||
} catch (Exception e) {
|
||||
log.error("自动线程开始查询AGV设备,自动上报驱动状态失败{}{}", e, e.getMessage());
|
||||
//log.error("自动线程开始查询AGV设备,自动上报驱动状态失败{}{}", e, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,36 +71,46 @@ https://juejin.cn/post/6844903775631572999
|
||||
<!--添加loki-->
|
||||
<!--开发环境:打印控制台-->
|
||||
<springProfile name="dev">
|
||||
<root level="info">
|
||||
<root level="debug">
|
||||
<appender-ref ref="asyncLuceneAppender"/>
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</root>
|
||||
<logger name="jdbc" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
<logger name="org.springframework" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
<logger name="org.hibernate" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
<logger name="org.quartz" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
<logger name="com.google" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
<logger name="org.redisson" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
<logger name="org.nl.modules.wql" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
<logger name="org.springframework.data" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
<logger name="org.jinterop" level="ERROR" additivity="true">
|
||||
<appender-ref ref="asyncFileAppender"/>
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
</logger>
|
||||
</springProfile>
|
||||
<!--测试环境:打印控制台-->
|
||||
|
||||
Reference in New Issue
Block a user