This commit is contained in:
2024-04-10 14:57:48 +08:00
34 changed files with 1071 additions and 89 deletions

View File

@@ -440,6 +440,11 @@
<artifactId>spring-retry</artifactId>
<version>1.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.22</version>
</dependency>
<!--<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>

View File

@@ -111,6 +111,9 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
int to_last = 0;
int last_to_last = 0;
int to_len = 0;
int last_to_len = 0;
Boolean isonline = true;
int hasGoods = 0;
String message = "";
@@ -177,7 +180,7 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
to_max_no = this.itemProtocol.getTo_max_no();
to_direction = this.itemProtocol.getTo_direction();
to_last = this.itemProtocol.getTo_last();
to_len = this.itemProtocol.getTo_len();
if (mode != last_mode) {
@@ -251,6 +254,7 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
last_to_onset = to_onset;
last_to_seq = to_seq;
last_to_last = to_last;
last_to_len = to_len;
last_to_direction = to_direction;
last_to_max_no = to_max_no;
}
@@ -359,8 +363,9 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
Map<String, Object> map7 = new HashMap<>();
Map<String, Object> map8 = new HashMap<>();
Map<String, Object> map9 = new HashMap<>();
Map<String, Object> map10 = new HashMap<>();
try {
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instruction.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8,map9);
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instruction.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8,map9,map10);
} catch (Exception e) {
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
@@ -437,8 +442,9 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
Map<String, Object> map7 = new HashMap<>();
Map<String, Object> map8 = new HashMap<>();
Map<String, Object> map9 = new HashMap<>();
Map<String, Object> map10 = new HashMap<>();
try {
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8,map9);
pushPLC(map1, map2, next_addr, map3, start_addr, map4, instdto.getInstruction_code(), interactionJsonDTO, map5, map6, map7, map8,map9,map10);
} catch (Exception e) {
logServer.deviceExecuteLog(device_code, "", "", "当前设备:" + device_code + ",下发指令:"
+ instdto.getInstruction_code() + ",指令起点:" + instdto.getStart_device_code()
@@ -456,7 +462,7 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
}
private void pushPLC(Map<String, Object> map1, Map<String, Object> map2, String next_addr, Map<String, Object> map3, String start_addr, Map<String, Object> map4, String task, InteractionJsonDTO interactionJsonDTO, Map<String, Object> map5, Map<String, Object> map6, Map<String, Object> map7, Map<String, Object> map8,Map<String, Object> map9) {
private void pushPLC(Map<String, Object> map1, Map<String, Object> map2, String next_addr, Map<String, Object> map3, String start_addr, Map<String, Object> map4, String task, InteractionJsonDTO interactionJsonDTO, Map<String, Object> map5, Map<String, Object> map6, Map<String, Object> map7, Map<String, Object> map8,Map<String, Object> map9,Map<String, Object> map10) {
List list = new ArrayList();
map1.put("code", "to_command");
map1.put("value", 1);
@@ -492,6 +498,12 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
map9.put("value", interactionJsonDTO.getBarcode());
list.add(map9);
}
if (ObjectUtil.isNotEmpty(interactionJsonDTO.getLen())) {
map10.put("code", "to_len");
map10.put("value", interactionJsonDTO.getLen());
list.add(map10);
}
}
this.writing(list);
}

View File

@@ -26,4 +26,9 @@ public class InteractionJsonDTO {
*子卷号
*/
private String barcode;
/**
*子卷长度
*/
private String len;
}

View File

@@ -101,6 +101,11 @@ public class ItemProtocol {
*/
public static String item_to_barcode = "to_barcode";
/**
*下发子卷长度
*/
public static String item_to_len = "to_len";
private BoxPackageManipulatorDeviceDriver driver;
@@ -174,6 +179,10 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_to_last_one);
}
public int getTo_len(){
return this.getOpcIntegerValue(item_to_len);
}
Boolean isonline;
@@ -243,8 +252,8 @@ public class ItemProtocol {
list.add(new ItemDto(item_to_direction, "子卷摆放方向", "DB2.D10"));
list.add(new ItemDto(item_to_seq, "下发木箱工位顺序", "DB2.W12"));
list.add(new ItemDto(item_to_last_one, "下发是否最后子卷", "DB2.W14"));
list.add(new ItemDto(item_to_len, "下发子卷长度", "DB2.W16"));
list.add(new ItemDto(item_to_barcode, "下发木箱条码", "DB601.STRING1.50"));
return list;
}
}

View File

@@ -359,7 +359,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
count = 0;
}
if (mode != 3 || requireSucess) {
if (mode != 3 && requireSucess) {
message = "one_message7";
} else if (error != 0) {

View File

@@ -40,22 +40,28 @@ public class ItemProtocol {
//下发命令
public static String item_to_command = "to_command";
//纸管1规格
public static String item_to_material1 = "to_material1";
//纸管2规格
public static String item_to_material2 = "to_material2";
//纸管数量
public static String item_to_qty = "to_qty";
//气涨轴类型 标箔/锂电 1/2
//气涨轴类型
public static String item_to_qzz_type = "to_qzz_type";
//是否下发纸管号1
public static String item_to_volumn1 = "to_volumn1";
//纸管1尺寸
//套管纸管1规格
public static String item_to_material1 = "to_material1";
//套管纸管2规格
public static String item_to_material2 = "to_material2";
//套管纸管数量
public static String item_to_qty1 = "to_qty1";
//套管纸管1尺寸
public static String item_to_size1 = "to_size1";
//纸管2尺寸
//套管纸管2尺寸
public static String item_to_size2 = "to_size2";
//是否下发纸管号2
public static String item_to_volumn2 = "to_volumn2";
//拔轴纸管1规格
public static String item_to_material3 = "to_material3";
//拔轴纸管2规格
public static String item_to_material4 = "to_material4";
//拔轴纸管数量
public static String item_to_qty2 = "to_qty2";
//拔轴纸管1尺寸
public static String item_to_size3 = "to_size3";
//拔轴纸管2尺寸
public static String item_to_size4 = "to_size4";
private PlugPullDeviceSiteDeviceDriver driver;
@@ -103,6 +109,10 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_to_command);
}
public int getTo_qzz_type() {
return this.getOpcIntegerValue(item_to_qzz_type);
}
public String getTo_material1() {
return this.getOpcStringValue(item_to_material1);
}
@@ -111,16 +121,8 @@ public class ItemProtocol {
return this.getOpcStringValue(item_to_material2);
}
public int getTo_qty() {
return this.getOpcIntegerValue(item_to_qty);
}
public int getTo_qzz_type() {
return this.getOpcIntegerValue(item_to_qzz_type);
}
public String getTo_volumn1() {
return this.getOpcStringValue(item_to_volumn1);
public int getTo_qty1() {
return this.getOpcIntegerValue(item_to_qty1);
}
public int getTo_size1() {
@@ -131,10 +133,27 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_to_size2);
}
public String getTo_volumn2() {
return this.getOpcStringValue(item_to_volumn1);
public String getTo_material3() {
return this.getOpcStringValue(item_to_material3);
}
public String getTo_material4() {
return this.getOpcStringValue(item_to_material4);
}
public int getTo_qty2() {
return this.getOpcIntegerValue(item_to_qty2);
}
public int getTo_size3() {
return this.getOpcIntegerValue(item_to_size3);
}
public int getTo_size4() {
return this.getOpcIntegerValue(item_to_size4);
}
Boolean isonline;
Boolean isError;
@@ -198,13 +217,16 @@ public class ItemProtocol {
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "下发命令", "DB10.W0"));
list.add(new ItemDto(item_to_material1, "纸管1规格", "DB10.String602.60"));
list.add(new ItemDto(item_to_material2, "纸管2规格", "DB10.String656.60"));
list.add(new ItemDto(item_to_qty, "纸管数量", "DB10.W6"));
list.add(new ItemDto(item_to_material1, "套管纸管1规格", "DB10.String602.60"));
list.add(new ItemDto(item_to_material2, "套管纸管2规格", "DB10.String656.60"));
list.add(new ItemDto(item_to_qty1, "套管纸管数量", "DB10.W6"));
list.add(new ItemDto(item_to_qzz_type, "气胀轴类型", "DB10.W8"));
list.add(new ItemDto(item_to_volumn1, "下发纸管号1", "DB10.String610.60"));
list.add(new ItemDto(item_to_volumn2, "下发纸管号2", "DB10.String612.60"));
list.add(new ItemDto(item_to_size1, "下发纸管1尺寸", "DB10.W10"));
list.add(new ItemDto(item_to_size1, "套管纸管1尺寸", "DB10.W10"));
list.add(new ItemDto(item_to_size2, "套管纸管2尺寸", "DB10.W12"));
list.add(new ItemDto(item_to_material1, "拔轴纸管1规格", "DB10.String602.60"));
list.add(new ItemDto(item_to_material2, "拔轴纸管2规格", "DB10.String656.60"));
list.add(new ItemDto(item_to_qty2, "拔轴纸管数量", "DB10.W6"));
list.add(new ItemDto(item_to_size1, "拔轴纸管1尺寸", "DB10.W10"));
list.add(new ItemDto(item_to_size2, "下发纸管2尺寸", "DB10.W12"));
return list;
}

View File

@@ -118,26 +118,36 @@ 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;
int toQty = 0;
int lastToQty = 0;
String toMaterial3 = null;
String lastToMaterial3 = null;
String toMaterial4 = null;
String lastToMaterial4 = null;
int toQty1 = 0;
int lastToQty1 = 0;
int toQty2 = 0;
int lastToQty2 = 0;
int toQzzType = 0;
int lastToQzzType = 0;
//子卷号1
String toVolumn1 = null;
String lastToVolumn1 = null;
//子卷号2
String toVolumn2 = null;
String lastToVolumn2 = null;
Boolean isonline = true;
@@ -183,12 +193,15 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl
toCommand = this.itemProtocol.getTo_command();
toMaterial1 = this.itemProtocol.getTo_material1();
toMaterial2 = this.itemProtocol.getTo_material2();
toQty = this.itemProtocol.getTo_qty();
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();
toVolumn1 = this.itemProtocol.getTo_volumn1();
toVolumn2 = this.itemProtocol.getTo_volumn2();
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;
@@ -268,12 +281,15 @@ public class PlugPullDeviceSiteDeviceDriver extends AbstractOpcDeviceDriver impl
lastToCommand = toCommand;
lastToMaterial1 = toMaterial1;
lastToMaterial2 = toMaterial2;
lastToQty = toQty;
lastToMaterial3 = toMaterial3;
lastToMaterial4 = toMaterial4;
lastToQty1 = toQty1;
lastToQty2 = toQty2;
lastToQzzType = toQzzType;
lastToVolumn2 = toVolumn2;
lastToVolumn1 = toVolumn1;
lastToSize2 = toSize2;
lastToSize1 = toSize1;
lastToSize3 = toSize3;
lastToSize4 = toSize4;
}
/**
@@ -289,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);
}
@@ -310,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);
@@ -399,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

@@ -332,7 +332,7 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
taskDtos = this.sortTask(taskDtos);
TaskDto taskDto = taskDtos.get(0);
truss_type = taskDto.getTruss_type();
// 9 行架任务
//查询任务是行架任务
if (!StrUtil.equals(taskDto.getTask_type(), "6")) {
taskDto = null;
continue;
@@ -661,7 +661,6 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
String action = "";
String walk_y = "";
String mode = "";
String status = "";
String is_disable = "";
@@ -704,6 +703,8 @@ public class SlitTwoManipulatorDeviceDriver extends AbstractOpcDeviceDriver impl
action = LangProcess.msg("two_action7");
} else if (this.getAction() == 8) {
action = LangProcess.msg("two_action8");
} else if (this.getAction() == 9) {
action = LangProcess.msg("two_action9");
}

View File

@@ -0,0 +1,26 @@
package org.nl.acs.ext.wms.data;
import lombok.Data;
/**
* @Author : TuQiang
* @create 2024/4/2 12:17
*/
@Data
public class CreateHandTaskRequest extends BaseRequest {
/**
* 取货点
*/
String start_device_code;
/**
* 放货点
*/
String next_device_code;
/**
* 任务类型
*/
String task_type;
}

View File

@@ -0,0 +1,9 @@
package org.nl.acs.ext.wms.data;
/**
* @Author : TuQiang
* @create 2024/4/2 12:19
*/
public class CreateHandTaskResponse extends BaseResponse {
}

View File

@@ -51,11 +51,13 @@ import org.nl.acs.route.service.dto.RouteLineDto;
import org.nl.acs.route.service.impl.RouteLineServiceImpl;
import org.nl.acs.task.TaskInstructionLock;
import org.nl.acs.task.domain.Task;
import org.nl.acs.task.enums.TaskStatusEnum;
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.dto.TaskIdAndStatusDTO;
import org.nl.acs.task.service.mapper.TaskMapper;
import org.nl.common.exception.BadRequestException;
import org.nl.acs.utils.ConvertUtil;
@@ -880,7 +882,10 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
//中转为空
if (StrUtil.isEmpty(task.getPut_device_code())) {
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
taskService.finish(task.getTask_id());
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
taskIdAndStatusDTO.setTask_id(task.getTask_id());
taskIdAndStatusDTO.setTask_status(TaskStatusEnum.FINISHED.getIndex());
taskService.finish(taskIdAndStatusDTO);
} else {
finishAndCreateNextInst(ConvertUtil.convert(entity, Instruction.class));
}
@@ -888,13 +893,19 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
finishAndCreateHXInst(ConvertUtil.convert(entity, Instruction.class));
} else if (StrUtil.equals(task.getPut_device_code(), instnextdevice)) {
taskService.finish(task.getTask_id());
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
taskIdAndStatusDTO.setTask_id(task.getTask_id());
taskIdAndStatusDTO.setTask_status(TaskStatusEnum.FINISHED.getIndex());
taskService.finish(taskIdAndStatusDTO);
}
}
} else {
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
taskService.finish(task.getTask_id());
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
taskIdAndStatusDTO.setTask_id(task.getTask_id());
taskIdAndStatusDTO.setTask_status(TaskStatusEnum.FINISHED.getIndex());
taskService.finish(taskIdAndStatusDTO);
} else {
finishAndCreateNextInst(ConvertUtil.convert(entity, Instruction.class));
}
@@ -926,7 +937,10 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
//中转为空
if (StrUtil.isEmpty(task.getPut_device_code())) {
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
taskService.finish(task.getTask_id());
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
taskIdAndStatusDTO.setTask_id(task.getTask_id());
taskIdAndStatusDTO.setTask_status(TaskStatusEnum.FINISHED.getIndex());
taskService.finish(taskIdAndStatusDTO);
} else {
finishAndCreateNextInst(ConvertUtil.convert(ins, Instruction.class));
}
@@ -934,13 +948,19 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
finishAndCreateHXInst(ConvertUtil.convert(ins, Instruction.class));
} else if (StrUtil.equals(task.getPut_device_code(), instnextdevice)) {
taskService.finish(task.getTask_id());
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
taskIdAndStatusDTO.setTask_id(task.getTask_id());
taskIdAndStatusDTO.setTask_status(TaskStatusEnum.FINISHED.getIndex());
taskService.finish(taskIdAndStatusDTO);
}
}
} else {
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
taskService.finish(task.getTask_id());
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
taskIdAndStatusDTO.setTask_id(task.getTask_id());
taskIdAndStatusDTO.setTask_status(TaskStatusEnum.FINISHED.getIndex());
taskService.finish(taskIdAndStatusDTO);
} else {
finishAndCreateNextInst(ConvertUtil.convert(ins, Instruction.class));
}

View File

@@ -18,6 +18,7 @@ public enum TaskStatusEnum {
BUSY("1", "BUSY", "执行中"),
FINISHED("2", "FINISHED", "完成"),
CANCEL("3", "CANCEL", "取消"),
FORCED_COMPLETION("4", "", "强制完成"),
ERROR("99", "ERROR", "异常");
/**

View File

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.acs.task.service.dto.TaskIdAndStatusDTO;
import org.nl.common.logging.annotation.Log;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
@@ -87,9 +88,9 @@ public class TaskController {
}
@Log("完成任务")
@PostMapping(value = "/finish/{id}")
public ResponseEntity<Object> finish(@RequestBody String id) {
taskService.finish(id);
@PostMapping(value = "/finish")
public ResponseEntity<Object> finish(@RequestBody TaskIdAndStatusDTO taskIdAndStatus) {
taskService.finish(taskIdAndStatus);
return new ResponseEntity<>(HttpStatus.OK);
}

View File

@@ -6,6 +6,7 @@ import org.nl.acs.common.base.PageInfo;
import org.nl.acs.common.base.CommonService;
import org.nl.acs.task.domain.Task;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.acs.task.service.dto.TaskIdAndStatusDTO;
import org.nl.acs.task.service.dto.TaskQueryParam;
import org.springframework.data.domain.Pageable;
@@ -291,7 +292,7 @@ public interface TaskService extends CommonService<Task> {
*
* @param ids
*/
void finish(String ids);
void finish(TaskIdAndStatusDTO ids);
/**
* 取消任务

View File

@@ -0,0 +1,10 @@
package org.nl.acs.task.service.dto;
import lombok.Data;
@Data
public class TaskIdAndStatusDTO {
private String task_id;
private String task_status;
}

View File

@@ -2,7 +2,6 @@ package org.nl.acs.task.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
@@ -12,7 +11,6 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
@@ -48,6 +46,7 @@ import org.nl.acs.task.service.TaskFeedbackService;
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.dto.TaskIdAndStatusDTO;
import org.nl.common.exception.BadRequestException;
import org.nl.acs.utils.ConvertUtil;
import org.nl.common.utils.FileUtil;
@@ -806,13 +805,13 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
@Override
@Transactional(rollbackFor = Exception.class)
public void finish(String id) {
TaskDto entity = this.findById(id);
public void finish(TaskIdAndStatusDTO taskIdAndStatus) {
TaskDto entity = this.findById(taskIdAndStatus.getTask_id());
if (entity == null) {
throw new BadRequestException(LangProcess.msg("error_sysAuth"));
}
InstructionDto instdto = instructionService.findByTaskid(id, "instruction_status <2 ");
InstructionDto instdto = instructionService.findByTaskid(taskIdAndStatus.getTask_id(), "instruction_status <2 ");
if (instdto != null) {
throw new BadRequestException(LangProcess.msg("task_insHas"));
}
@@ -821,7 +820,7 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
String now = DateUtil.now();
entity.setUpdate_time(now);
entity.setUpdate_by(currentUsername);
entity.setTask_status(TaskStatusEnum.FINISHED.getIndex());
entity.setTask_status(taskIdAndStatus.getTask_status());
Task task = ConvertUtil.convert(entity, Task.class);
taskMapper.updateById(task);

View File

@@ -0,0 +1,29 @@
package org.nl.hand.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @Author : TuQiang
* @create 2024/4/2 16:54
*/
@Data
public class HeadDto implements Serializable {
/**
* 起始设备编码
*/
private String start_device_code;
/**
* 目标设备编码
*/
private String next_device_code;
/**
* 任务类型
*/
private String task_type;
}

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

@@ -0,0 +1,17 @@
package org.nl.hand.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @Author : TuQiang
* @create 2024/4/2 16:50
*/
@Data
public class RegionDto implements Serializable {
/**
* 区域编号
*/
private String region_code;
}

View File

@@ -0,0 +1,99 @@
package org.nl.hand.rest;
import cn.dev33.satoken.annotation.SaIgnore;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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;
import org.springframework.beans.factory.annotation.Autowired;
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
*/
@RestController
@RequiredArgsConstructor
@Api(tags = "手持接口")
@RequestMapping("api/hand")
@Slf4j
public class HandController {
@Autowired
private HandService handService;
@PostMapping("/queryArea")
@Log("查询区域")
@ApiOperation("查询区域")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryArea() {
return new ResponseEntity<>(handService.queryArea(), HttpStatus.OK);
}
@PostMapping("/queryPointByArea")
@Log("根据区域编码查点位")
@ApiOperation("根据区域编码查点位")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> queryPointByArea(@RequestBody RegionDto dto) {
String region_code = dto.getRegion_code();
return new ResponseEntity<>(handService.queryPointByArea(region_code), HttpStatus.OK);
}
@PostMapping("/callTask")
@Log("手持创建任务")
@ApiOperation("手持创建任务")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
public ResponseEntity<Object> callTask(@RequestBody HeadDto dto) {
return new ResponseEntity<>(handService.callTask(dto), HttpStatus.OK);
}
@PostMapping("/insts")
@Log("查询未完成指令")
@ApiOperation("查询未完成指令")
@SaIgnore
//@PreAuthorize("@el.check('sect:list')")
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

@@ -0,0 +1,87 @@
package org.nl.hand.rest;
import cn.dev33.satoken.annotation.SaIgnore;
import cn.dev33.satoken.secure.SaSecureUtil;
import cn.dev33.satoken.stp.SaLoginModel;
import cn.dev33.satoken.stp.StpUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.RsaUtils;
import org.nl.common.utils.dto.CurrentUser;
import org.nl.config.RsaProperties;
import org.nl.system.service.role.ISysRoleService;
import org.nl.system.service.secutiry.dto.AuthUserDto;
import org.nl.system.service.user.ISysUserService;
import org.nl.system.service.user.dao.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* @Author : TuQiang
* @create 2024/4/2 16:00
*/
@Slf4j
@RestController
@RequestMapping("/mobile/auth")
public class MobileAuthorizationController {
@Autowired
private ISysUserService userService;
@Autowired
private ISysRoleService roleService;
@PostMapping(value = "/login")
@SaIgnore
public ResponseEntity<Object> login(@Validated @RequestBody AuthUserDto authUser, HttpServletRequest request) throws Exception {
// 密码解密 - 前端的加密规则: encrypt根据实际更改
String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, authUser.getPassword());
// 校验数据库
// 根据用户名查询,在比对密码
// 拿到多个已经抛出异常
SysUser userInfo = userService.getOne(new LambdaQueryWrapper<SysUser>()
.eq(SysUser::getUsername, authUser.getUsername()));
// 这里需要密码加密
if (ObjectUtil.isEmpty(userInfo) || !userInfo.getPassword().equals(SaSecureUtil.md5BySalt(password, "salt"))) {
throw new BadRequestException("账号或密码错误!");
}
// 获取权限列表 - 登录查找权限
List<String> permissionList = roleService.getPermissionList((JSONObject) JSON.toJSON(userInfo));
// 登录输入,登出删除
CurrentUser user = new CurrentUser();
user.setId(userInfo.getUser_id());
user.setUsername(userInfo.getUsername());
user.setPresonName(userInfo.getPerson_name());
user.setUser(userInfo);
user.setPermissions(permissionList);
// SaLoginModel 配置登录相关参数
StpUtil.login(userInfo.getUser_id(), new SaLoginModel()
// 此次登录的客户端设备类型, 用于[同端互斥登录]时指定此次登录的设备类型
.setDevice("PE")
// Token挂载的扩展参数 此方法只有在集成jwt插件时才会生效
.setExtra("loginInfo", user)
);
// 返回 token 与 用户信息
JSONObject jsonObject = new JSONObject();
jsonObject.put("user", userInfo);
JSONObject authInfo = new JSONObject(2) {{
put("token", "Bearer " + StpUtil.getTokenValue());
put("user", jsonObject);
}};
return ResponseEntity.ok(authInfo);
}
}

View File

@@ -0,0 +1,38 @@
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;
/**
* @Author : TuQiang
* @create 2024/4/2 10:19
*/
public interface HandService {
Map<String, Object> queryPointByArea(String region_code);
/**
* 手持创建任务
*
* @param dto
* @return
*/
Map<String, Object> callTask(HeadDto dto);
Map<String, Object> queryArea();
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

@@ -0,0 +1,439 @@
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;
import cn.hutool.core.util.ObjectUtil;
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.enums.TaskStatusEnum;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.acs.task.service.dto.TaskIdAndStatusDTO;
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;
import org.springframework.beans.factory.annotation.Autowired;
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;
/**
* @Author : TuQiang
* @create 2024/4/2 10:20
*/
@Service
@RequiredArgsConstructor
@Slf4j
public class HandServiceImpl implements HandService {
@Autowired
private DeviceService deviceService;
@Autowired
private TaskService taskserver;
@Autowired
private ISysDictService dictService;
@Autowired
private InstructionService instructionService;
@Autowired
NDCAgvService ndcAgvService;
@Override
public Map<String, Object> queryPointByArea(String region_code) {
JSONArray data = new JSONArray();
if (StrUtil.isEmpty(region_code)) {
throw new BadRequestException("区域编码不能为空!");
}
//根据区域编码查询所有设备
List<Device> list = deviceService.lambdaQuery()
.eq(Device::getRegion, region_code)
.list();
if (CollectionUtil.isEmpty(list)) {
throw new BadRequestException("未查到该区域的设备!");
}
for (int i = 0; i < list.size(); i++) {
JSONObject jo = new JSONObject();
Device device = list.get(i);
String device_id = device.getDevice_id();
String device_code = device.getDevice_code();
String device_name = device.getDevice_name();
BigDecimal seq_num = device.getSeq_num();
jo.put("device_id", device_id);
jo.put("device_code", device_code);
jo.put("device_name", device_name);
jo.put("seq_num", seq_num);
data.add(jo);
}
JSONObject resultJson = new JSONObject();
resultJson.put("message", "操作成功");
resultJson.put("data", data);
return resultJson;
}
@Override
public Map<String, Object> callTask(HeadDto dto) {
JSONArray errArr = new JSONArray();
String start_device_code = dto.getStart_device_code();
String next_device_code = dto.getNext_device_code();
String task_type = dto.getTask_type();
if (StrUtil.isEmpty(start_device_code)) {
JSONObject json = new JSONObject();
json.put("message", "起点不能为空");
errArr.add(json);
}
if (StrUtil.isEmpty(next_device_code)) {
JSONObject json = new JSONObject();
json.put("message", "终点不能为空");
errArr.add(json);
}
if (StrUtil.isEmpty(task_type)) {
JSONObject json = new JSONObject();
json.put("message", "任务类型不能为空");
errArr.add(json);
}
String start_device_code2 = "";
String next_device_code2 = "";
JSONObject jo = new JSONObject();
if (StrUtil.equals(task_type, CommonFinalParam.TYPE_ONE)) {
String s = start_device_code.substring(9);
if (StrUtil.equals("K", s)) {
start_device_code2 = next_device_code.substring(0, 10) + "M";
next_device_code2 = start_device_code.substring(0, 9) + "M";
jo.put("start_device_code2", start_device_code2);
jo.put("next_device_code2", next_device_code2);
jo.put("start_point_code2", start_device_code2);
jo.put("next_point_code2", next_device_code2);
}
} else if (StrUtil.equals(task_type, CommonFinalParam.TYPE_TWO)) {
start_device_code2 = next_device_code.substring(0, 9) + "K";
next_device_code2 = start_device_code.substring(0, 9) + "K";
jo.put("start_device_code2", start_device_code2);
jo.put("next_device_code2", next_device_code2);
jo.put("start_point_code2", start_device_code2);
jo.put("next_point_code2", next_device_code2);
}
jo.put("start_device_code", start_device_code);
jo.put("next_device_code", next_device_code);
jo.put("start_point_code", start_device_code);
jo.put("next_point_code", next_device_code);
jo.put("task_type", task_type);
jo.put("agv_system_type", "2");
jo.put("priority", "1");
TaskDto task_dto = jo.toJavaObject(TaskDto.class);
try {
taskserver.create(task_dto);
} catch (Exception e) {
// e.printStackTrace();
JSONObject json = new JSONObject();
json.put("message", e.getMessage());
errArr.add(json);
}
JSONArray data = new JSONArray();
JSONObject resultJson = new JSONObject();
if (ObjectUtil.isEmpty(errArr)) {
resultJson.put("message", "操作成功");
resultJson.put("data", data);
} else {
resultJson.put("message", "操作失败");
resultJson.put("data", data);
}
return resultJson;
}
@Override
public Map<String, Object> queryArea() {
JSONArray data = new JSONArray();
List<Dict> list = dictService.lambdaQuery()
.eq(Dict::getCode, "region_type")
.list();
if (CollectionUtil.isEmpty(list)) {
throw new BadRequestException("未查到该区域的设备!");
}
for (int i = 0; i < list.size(); i++) {
JSONObject jo = new JSONObject();
Dict dict = list.get(i);
String region_id = dict.getDict_id();
String region_code = dict.getValue();
String region_name = dict.getLabel();
jo.put("region_id", region_id);
jo.put("region_code", region_code);
jo.put("region_name", region_name);
data.add(jo);
}
JSONObject resultJson = new JSONObject();
resultJson.put("message", "操作成功");
resultJson.put("data", data);
return resultJson;
}
@Override
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;
}
TaskIdAndStatusDTO taskIdAndStatusDTO = new TaskIdAndStatusDTO();
taskIdAndStatusDTO.setTask_id(task_uuid);
taskIdAndStatusDTO.setTask_status(TaskStatusEnum.FINISHED.getIndex());
taskserver.finish(taskIdAndStatusDTO);
}
resultJson.put("message", "操作成功");
resultJson.put("data", data);
return resultJson;
}
}

View File

@@ -26,4 +26,4 @@ two_action5=\u540E\u5DE5\u4F4D\u53D6\u8D27\u4E2D
two_action6=\u540E\u5DE5\u4F4D\u53D6\u8D27\u5B8C\u6210
two_action7=\u540E\u5DE5\u4F4D\u53D6\u8D27\u4E2D
two_action8=\u540E\u5DE5\u4F4D\u653E\u8D27\u5B8C\u6210
two_action9=\u4EFB\u52A1\u5B8C\u6210

View File

@@ -26,5 +26,6 @@ two_action5=Pick-up at the post-station
two_action6=After the station pick-up is completed
two_action7=Pick-up at the post-station
two_action8=After the station is released, the goods are completed
two_action9=Mission accomplished

View File

@@ -26,3 +26,4 @@ two_action5=Penjemputan di stasiun pos
two_action6=Setelah penjemputan stasiun selesai
two_action7=Penjemputan di stasiun pos
two_action8=Setelah stasiun dilepaskan, barang selesai
two_action9=Misi tercapai

View File

@@ -26,4 +26,5 @@ two_action5=\u540E\u5DE5\u4F4D\u53D6\u8D27\u4E2D
two_action6=\u540E\u5DE5\u4F4D\u53D6\u8D27\u5B8C\u6210
two_action7=\u540E\u5DE5\u4F4D\u53D6\u8D27\u4E2D
two_action8=\u540E\u5DE5\u4F4D\u653E\u8D27\u5B8C\u6210
two_action9=\u4EFB\u52A1\u5B8C\u6210

View File

@@ -2,8 +2,13 @@ package org.nl;
import org.junit.jupiter.api.Test;
import org.nl.system.service.user.ISysUserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.scheduling.annotation.Scheduled;
import java.util.Scanner;
/**
* @Author: lyd
@@ -14,8 +19,41 @@ import org.springframework.boot.test.context.SpringBootTest;
public class ApplicationTest {
@Autowired
private ISysUserService userService;
private Logger logger = LoggerFactory.getLogger(ApplicationTest.class);
@Test
void contextLoads() {
System.out.println(userService.list());
Scanner scanner = new Scanner(System.in);
System.out.println("请输入第一个数:");
int a = scanner.nextInt();
System.out.println("请输入第一个数:");
int b = scanner.nextInt();
System.out.println("请输入第一个数:");
int c = scanner.nextInt();
//求最小值
int min = (((a < b) ? a : b) < c) ?((a < b) ? a : b):c;
//求最大值
int max = (((a > b) ? a : b) > c) ?((a > b) ? a : b):c;
//求中间值
int mid = a + b + c - max - min;
//排序
System.out.println("最小值为:" + min + "中间值为:" + mid + "最大值为:" + max);
}
@Test
@Scheduled(cron = "0/5 * * * * ?")
void testOrderTask() {
logger.info(Thread.currentThread().getName() + "===task run");
}
@org.testng.annotations.Test
void demo1() {
}
}

View File

@@ -24,11 +24,11 @@ export function edit(data) {
})
}
export function finish(task_id) {
export function finish(data) {
return request({
url: 'api/task/finish/' + task_id,
url: 'api/task/finish',
method: 'post',
data: task_id
data: data
})
}

View File

@@ -35,6 +35,7 @@ export default {
'Ready': 'Ready',
'In_progress': 'In Progress',
'Completed': 'Completed',
'Forced_Completed': 'Forced Completed',
'Pickup_point': 'Pickup Point',
'Delivery_point': 'Delivery Point',
'Remark': 'Remark',

View File

@@ -35,6 +35,7 @@ export default {
'Ready': 'Siap',
'In_progress': 'Sedang Berlangsung',
'Completed': 'Selesai',
'Forced_Completed': 'Penyelesaian wajib',
'Pickup_point': 'Titik Pengambilan',
'Delivery_point': 'Titik Pengiriman',
'Remark': 'Catatan',

View File

@@ -35,6 +35,7 @@ export default {
'Ready': '就绪',
'In_progress': '执行中',
'Completed': '完成',
'Forced_Completed': '强制完成',
'Pickup_point': '取货点',
'Delivery_point': '放货点',
'Remark': '备注',

View File

@@ -559,6 +559,15 @@
{{ $t('task.select.Create_command') }}
</el-button>
</el-dropdown-item>
<el-dropdown-item>
<el-button
type="text"
icon="el-icon-finished"
@click="handleCommand(scope.$index, scope.row,'d')"
>
{{ $t('task.select.Forced_Completed') }}
</el-button>
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
@@ -695,6 +704,10 @@ export default {
agv_system_type: '',
interactionJson: null
},
taskStatus: {
task_status: '',
task_id: null
},
extension: [{
name: '',
value: ''
@@ -790,7 +803,9 @@ export default {
return true
},
finish(index, row) {
crudTask.finish(row.task_id).then(res => {
this.taskStatus.task_id = row.task_id
this.taskStatus.task_status = index
crudTask.finish(this.taskStatus).then(res => {
this.crud.toQuery()
this.crud.notify('完成成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
}).catch(err => {
@@ -831,7 +846,7 @@ export default {
handleCommand(index, row, command) {
switch (command) {
case 'a':// 完成
this.finish(index, row)
this.finish('3', row)
break
case 'b':// 取消
this.cancel(index, row)
@@ -839,6 +854,9 @@ export default {
case 'c':// 创建指令
this.createInst(index, row)
break
case 'd':// 完成
this.finish('4', row)
break
}
},
showStartStorage(val) {