add:新增手持任务和指令的功能

This commit is contained in:
2024-04-07 15:51:14 +08:00
parent 1d6f644411
commit 7ddf8e7af5
8 changed files with 402 additions and 36 deletions

View File

@@ -53,15 +53,15 @@ public class ItemProtocol {
//套管纸管2尺寸
public static String item_to_size2 = "to_size2";
//拔轴纸管1规格
public static String item_to_material3 = "to_material1";
public static String item_to_material3 = "to_material3";
//拔轴纸管2规格
public static String item_to_material4 = "to_material2";
//拔轴纸管数量
public static String item_to_material4 = "to_material4";
//拔轴纸管数量
public static String item_to_qty2 = "to_qty2";
//拔轴纸管1尺寸
public static String item_to_size3 = "to_size1";
public static String item_to_size3 = "to_size3";
//拔轴纸管2尺寸
public static String item_to_size4 = "to_size2";
public static String item_to_size4 = "to_size4";
private PlugPullDeviceSiteDeviceDriver driver;

View File

@@ -118,12 +118,26 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl
int toSize2 = 0;
int lastToSize2 = 0;
//纸管1尺寸
int toSize3 = 0;
int lastToSize3 = 0;
//纸管2尺寸
int toSize4 = 0;
int lastToSize4 = 0;
String toMaterial1 = null;
String lastToMaterial1 = null;
String toMaterial2 = null;
String lastToMaterial2 = null;
String toMaterial3 = null;
String lastToMaterial3 = null;
String toMaterial4 = null;
String lastToMaterial4 = null;
int toQty1 = 0;
int lastToQty1 = 0;
@@ -134,14 +148,6 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl
int toQzzType = 0;
int lastToQzzType = 0;
//子卷号1
String toVolumn1 = null;
String lastToVolumn1 = null;
//子卷号2
String toVolumn2 = null;
String lastToVolumn2 = null;
Boolean isonline = true;
@@ -187,11 +193,15 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl
toCommand = this.itemProtocol.getTo_command();
toMaterial1 = this.itemProtocol.getTo_material1();
toMaterial2 = this.itemProtocol.getTo_material2();
toMaterial3 = this.itemProtocol.getTo_material3();
toMaterial4 = this.itemProtocol.getTo_material4();
toQty1 = this.itemProtocol.getTo_qty1();
toQty2 = this.itemProtocol.getTo_qty2();
toQzzType = this.itemProtocol.getTo_qzz_type();
toSize1 = this.itemProtocol.getTo_size1();
toSize2 = this.itemProtocol.getTo_size2();
toSize3 = this.itemProtocol.getTo_size3();
toSize4 = this.itemProtocol.getTo_size4();
if (mode != lastMode) {
requireSucess = false;
@@ -271,13 +281,15 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl
lastToCommand = toCommand;
lastToMaterial1 = toMaterial1;
lastToMaterial2 = toMaterial2;
lastToMaterial3 = toMaterial3;
lastToMaterial4 = toMaterial4;
lastToQty1 = toQty1;
lastToQty2 = toQty2;
lastToQzzType = toQzzType;
lastToVolumn2 = toVolumn2;
lastToVolumn1 = toVolumn1;
lastToSize2 = toSize2;
lastToSize1 = toSize1;
lastToSize3 = toSize3;
lastToSize4 = toSize4;
}
/**
@@ -293,20 +305,14 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl
applyPlugPullSitResponse = acsToWmsService.applyPlugPullSiteRequest(applyPlugPullSiteRequest);
if (applyPlugPullSitResponse.getCode() == CommonFinalParam.STATUS_OPEN) {
Map<String, String> data = applyPlugPullSitResponse.getData();
String left = data.get("left");
String right = data.get("right");
String number = data.get("number");
String leftSize = data.get("left_size");
String rightSize = data.get("right_size");
Map<String, Object> map = new LinkedHashMap<>();
//下发纸管信息
//todo:纸管规格待定
if (StrUtil.isNotEmpty(left)) {
map.put("to_volumn1", left);
}
if (StrUtil.isNotEmpty(right)) {
map.put("to_volumn2", right);
}
map.put("to_material1", material1);
map.put("to_material2", material2);
if (StrUtil.isNotEmpty(leftSize)){
map.put("to_size1", leftSize);
}
@@ -314,7 +320,7 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl
map.put("to_size2", rightSize);
}
map.put("to_command", mode);
map.put("to_qty", number);
map.put("to_qty1", number);
this.writing(map);
requireSucess = true;
logServer.deviceExecuteLog(this.deviceCode, "", "", "申请套管,返回参数:" + applyPlugPullSitResponse);
@@ -403,8 +409,9 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl
String leftSize = data.get("left_size");
String rightSzie = data.get("right_szie");
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_size1", leftSize);
map.put("to_size2", rightSzie);
map.put("to_size3", leftSize);
map.put("to_size4", rightSzie);
map.put("to_qzz_type", size);
map.put("to_command", mode);
this.writing(map);
requireSucess = true;

View File

@@ -26,8 +26,4 @@ public class HeadDto implements Serializable {
*/
private String task_type;
/**
* 关键字 可为载具号、指令号、agv车号
*/
private String keyword;
}

View File

@@ -0,0 +1,40 @@
package org.nl.hand.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @Author : TuQiang
* @create 2024/4/4 14:07
*/
@Data
public class HeadInstDto implements Serializable {
/**
* 关键字 可为载具号、指令号、agv车号
*/
private String keyword;
/**
* 起始设备编码
*/
private String start_devicecode;
/**
* 目标设备编码
*/
private String next_devicecode;
/**
* 指令uuid
*/
private String inst_uuid;
/**
* 操作类型
* 1 指令撤销
* 2 重新下发
* 3 强制完成
*/
private String type;
}

View File

@@ -0,0 +1,39 @@
package org.nl.hand.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @Author : TuQiang
* @create 2024/4/4 16:06
*/
@Data
public class HeadTaskDto implements Serializable {
/**
* 关键字 可为载具号、指令号、agv车号
*/
private String keyword;
/**
* 起始设备编码
*/
private String start_devicecode;
/**
* 目标设备编码
*/
private String next_devicecode;
/**
* 任务uuid
*/
private String task_uuid;
/**
* 操作类型
* 1 重新生成
* 2 强制完成
*/
private String type;
}

View File

@@ -7,6 +7,8 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.logging.annotation.Log;
import org.nl.hand.dto.HeadDto;
import org.nl.hand.dto.HeadInstDto;
import org.nl.hand.dto.HeadTaskDto;
import org.nl.hand.dto.RegionDto;
import org.nl.hand.service.HandService;
import org.nl.system.service.dict.dao.Dict;
@@ -15,6 +17,8 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* @Author : TuQiang
* @create 2024/4/2 10:18
@@ -57,14 +61,39 @@ public class HandController {
return new ResponseEntity<>(handService.callTask(dto), HttpStatus.OK);
}
@GetMapping("/insts")
@PostMapping("/insts")
@Log("查询未完成指令")
@ApiOperation("查询未完成指令")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryInst(@RequestBody HeadDto dto) {
public ResponseEntity<Object> queryInst(@RequestBody HeadInstDto dto) {
return new ResponseEntity<>(handService.queryInst(dto), HttpStatus.OK);
}
@PostMapping("/inst")
@Log("指令操作")
@ApiOperation("指令操作")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> instOpt(@RequestBody HeadInstDto dto) throws Exception {
return new ResponseEntity<>(handService.instOpt(dto), HttpStatus.OK);
}
@PostMapping("/tasks")
@Log("查询未完成指令")
@ApiOperation("查询未完成指令")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> querytasks(@RequestBody HeadTaskDto dto) {
return new ResponseEntity<>(handService.querytasks(dto), HttpStatus.OK);
}
@PostMapping("/taskoperation")
@Log("指令操作")
@ApiOperation("指令操作")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> taskOperation(@RequestBody HeadTaskDto dto) throws Exception {
return new ResponseEntity<>(handService.taskOperation(dto), HttpStatus.OK);
}
}

View File

@@ -4,6 +4,8 @@ package org.nl.hand.service;
import com.alibaba.fastjson.JSONArray;
import org.nl.acs.ext.wms.data.CreateHandTaskResponse;
import org.nl.hand.dto.HeadDto;
import org.nl.hand.dto.HeadInstDto;
import org.nl.hand.dto.HeadTaskDto;
import java.util.Map;
@@ -26,5 +28,11 @@ public interface HandService {
Map<String, Object> queryArea();
Map<String, Object> queryInst(HeadDto dto);
Map<String, Object> queryInst(HeadInstDto dto);
Map<String, Object> instOpt(HeadInstDto dto) throws Exception;
Map<String, Object> querytasks(HeadTaskDto dto);
Map<String, Object> taskOperation(HeadTaskDto dto);
}

View File

@@ -1,5 +1,6 @@
package org.nl.hand.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
@@ -8,19 +9,29 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.AgvService;
import org.nl.acs.agv.server.NDCAgvService;
import org.nl.acs.common.base.CommonFinalParam;
import org.nl.acs.device.domain.Device;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.ext.wms.data.CreateHandTaskRequest;
import org.nl.acs.ext.wms.data.CreateHandTaskResponse;
import org.nl.acs.ext.wms.data.JsonUtl;
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.task.domain.Task;
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.CodeUtil;
import org.nl.hand.dto.HeadDto;
import org.nl.hand.dto.HeadInstDto;
import org.nl.hand.dto.HeadTaskDto;
import org.nl.hand.service.HandService;
import org.nl.system.service.dict.ISysDictService;
import org.nl.system.service.dict.dao.Dict;
@@ -29,6 +40,8 @@ import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -39,7 +52,7 @@ import java.util.Map;
@Service
@RequiredArgsConstructor
@Slf4j
public class HandServiceImpl implements HandService {
public class HandServiceImpl implements HandService {
@Autowired
private DeviceService deviceService;
@@ -47,6 +60,12 @@ public class HandServiceImpl implements HandService {
private TaskService taskserver;
@Autowired
private ISysDictService dictService;
@Autowired
private InstructionService instructionService;
@Autowired
NDCAgvService ndcAgvService;
@Override
public Map<String, Object> queryPointByArea(String region_code) {
@@ -181,7 +200,235 @@ public class HandServiceImpl implements HandService {
}
@Override
public Map<String, Object> queryInst(HeadDto dto) {
return null;
public Map<String, Object> queryInst(HeadInstDto dto) {
//查询未完成的指令
String key = dto.getKeyword();
String start_point = dto.getStart_devicecode();
String next_point = dto.getNext_devicecode();
List<InstructionMybatis> list;
if (StrUtil.isEmpty(key)&&StrUtil.isEmpty(start_point)&&StrUtil.isEmpty(next_point)){
list = instructionService.lambdaQuery()
.orderByDesc(InstructionMybatis::getCreate_time)
.list();
}else {
list = instructionService.lambdaQuery()
.like(InstructionMybatis::getStart_device_code, start_point)
.like(InstructionMybatis::getNext_device_code, next_point)
.ne(InstructionMybatis::getInstruction_status, "2")
.eq(InstructionMybatis::getInstruction_code, key)
.or()
.eq(InstructionMybatis::getCarno, key)
.or()
.eq(InstructionMybatis::getVehicle_code, key)
.orderByDesc(InstructionMybatis::getCreate_time)
.list();
}
if (CollectionUtil.isEmpty(list)){
throw new BadRequestException("没有指令存在!");
}
JSONArray data = new JSONArray();
for (int i = 0; i < list.size(); i++) {
JSONObject inst = new JSONObject();
inst.put("inst_uuid",list.get(i).getInstruction_id());
inst.put("task_no",list.get(i).getTask_code());
inst.put("instruction_code",list.get(i).getInstruction_code());
inst.put("start_devicecode",list.get(i).getStart_device_code());
inst.put("next_devicecode",list.get(i).getNext_device_code());
inst.put("inst_status",list.get(i).getInstruction_status());
inst.put("carrier",list.get(i).getVehicle_code());
inst.put("inst_step",list.get(i).getExecute_message());
inst.put("priority",list.get(i).getPriority());
inst.put("create_time",list.get(i).getCreate_time());
inst.put("carno",list.get(i).getCarno());
data.add(inst);
}
JSONObject resultJson = new JSONObject();
resultJson.put("message", "操作成功");
resultJson.put("data", data);
return resultJson;
}
@Override
public Map<String, Object> instOpt(HeadInstDto dto) throws Exception {
JSONObject resultJson = new JSONObject();
JSONArray data = new JSONArray();
String type = dto.getType();
String inst_uuid = dto.getInst_uuid();
InstructionMybatis instruction= instructionService.lambdaQuery()
.eq(InstructionMybatis::getInstruction_id, inst_uuid)
.one();
if(instruction==null){
resultJson.put("message", "未找到该指令!");
resultJson.put("data", data);
return resultJson;
}
if (StrUtil.equals(instruction.getInstruction_status(),"2")||
StrUtil.equals(instruction.getInstruction_status(),"3")){
resultJson.put("message", "指令已完成或已取消,无法操作!");
resultJson.put("data", data);
return resultJson;
}
/* 1 指令撤销
2 重新下发
3 强制完成*/
if ("1".equals(type)){
try {
if (StrUtil.isEmpty(instruction.getAgv_jobno())){
instructionService.cancelNOSendAgv(inst_uuid);
}else {
ndcAgvService.deleteAgvInstToNDC(BeanUtil.copyProperties(instruction, Instruction.class));
}
} catch (Exception e) {
resultJson.put("message", "下发agv失败!");
resultJson.put("data", data);
return resultJson;
}
}else if ("2".equals(type)){
try {
ndcAgvService.sendAgvInstToNDC(instruction.getAgv_system_type(),BeanUtil.copyProperties(instruction, Instruction.class));
} catch (Exception e) {
resultJson.put("message", "下发agv失败!");
resultJson.put("data", data);
return resultJson;
}
}else if ("3".equals(type)){
try {
instructionService.finish(inst_uuid);
} catch (Exception e) {
resultJson.put("message", e.getMessage());
resultJson.put("data", data);
return resultJson;
}
}
resultJson.put("message", "操作成功");
resultJson.put("data", data);
return resultJson;
}
@Override
public Map<String, Object> querytasks(HeadTaskDto dto) {
String key = dto.getKeyword();
String start_point = dto.getStart_devicecode();
String next_point = dto.getNext_devicecode();
List<Task> list;
if (StrUtil.isEmpty(key)&&StrUtil.isEmpty(start_point)&&StrUtil.isEmpty(next_point)){
list = taskserver.lambdaQuery()
.orderByDesc(Task::getCreate_time)
.list();
}else {
list = taskserver.lambdaQuery()
.like(Task::getStart_device_code, start_point)
.like(Task::getNext_device_code, next_point)
.lt(Task::getTask_status, "2")
.eq(Task::getTask_code, key)
.or()
.eq(Task::getVehicle_code, key)
.or()
.eq(Task::getTask_id, key)
.orderByDesc(Task::getCreate_time)
.list();
}
if (CollectionUtil.isEmpty(list)){
throw new BadRequestException("没有指令存在!");
}
JSONArray data = new JSONArray();
for (int i = 0; i < list.size(); i++) {
JSONObject task = new JSONObject();
task.put("task_uuid",list.get(i).getTask_id());
task.put("task_no",list.get(i).getTask_code());
task.put("start_devicecode",list.get(i).getStart_device_code());
task.put("next_devicecode",list.get(i).getNext_device_code());
task.put("task_status",list.get(i).getTask_status());
task.put("priority",list.get(i).getPriority());
task.put("create_time",list.get(i).getCreate_time());
task.put("carrier",list.get(i).getVehicle_code());
data.add(task);
}
JSONObject resultJson = new JSONObject();
resultJson.put("message", "操作成功");
resultJson.put("data", data);
return resultJson;
}
@Override
public Map<String, Object> taskOperation(HeadTaskDto dto) {
JSONObject resultJson = new JSONObject();
JSONArray data = new JSONArray();
String type = dto.getType();
String task_uuid = dto.getTask_uuid();
if (StrUtil.isEmpty(type)){
throw new BadRequestException("操作类型不能为空!");
}
if (StrUtil.isEmpty(task_uuid)){
throw new BadRequestException("id不能为空");
}
TaskDto taskDto = taskserver.findById(task_uuid);
if (BeanUtil.isEmpty(taskDto)){
throw new BadRequestException("任务为空!");
}
String task_code = taskDto.getTask_code();
String start_device_code = taskDto.getStart_device_code();
String next_device_code = taskDto.getNext_device_code();
String task_id = taskDto.getTask_id();
if(StrUtil.equals(taskDto.getTask_status(),"2")||StrUtil.equals(taskDto.getTask_status(),"3")){
resultJson.put("message", "任务已完成或已取消,无法操作");
resultJson.put("data", data);
return resultJson;
}
if ("1".equals(type)){
//重新生成指令
Instruction instdto = new Instruction();
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO"));
instdto.setRemark(taskDto.getRemark());
instdto.setMaterial(taskDto.getMaterial());
instdto.setTask_id(task_id);
instdto.setTask_code(task_code);
instdto.setVehicle_code(taskDto.getVehicle_code());
String now = DateUtil.now();
instdto.setCreate_time(now);
instdto.setCreate_by("auto");
instdto.setStart_point_code(taskDto.getStart_point_code());
instdto.setNext_point_code(taskDto.getNext_point_code());
instdto.setStart_device_code(start_device_code);
instdto.setNext_device_code(next_device_code);
instdto.setInstruction_status("0");
InstructionMybatis instructionMybatis = instructionService.lambdaQuery()
.eq(InstructionMybatis::getStart_device_code, start_device_code)
.eq(InstructionMybatis::getNext_device_code, next_device_code)
.lt(InstructionMybatis::getInstruction_status, "2")
.eq(InstructionMybatis::getTask_id,task_uuid)
.one();
if (BeanUtil.isNotEmpty(instructionMybatis)){
resultJson.put("message", task_code + ":该任务已存在待完成指令!");
resultJson.put("data", data);
return resultJson;
}
try{
instructionService.create(instdto);
} catch (Exception e){
resultJson.put("message", e.getMessage());
resultJson.put("data", data);
return resultJson;
}
instdto.setExecute_code(start_device_code);
}else if ("2".equals(type)){
//强制完成
Instruction instruction = instructionService.findByTaskid(task_uuid, "instruction_status <2 ");
if (instruction!=null){
resultJson.put("message", "有指令未完成!");
resultJson.put("data", data);
return resultJson;
}
taskserver.finish(task_uuid);
}
resultJson.put("message", "操作成功");
resultJson.put("data", data);
return resultJson;
}
}