长兴特科拉项目
This commit is contained in:
@@ -38,7 +38,7 @@ import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString;
|
||||
* @date 2023/12/06
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
//@Component
|
||||
public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
|
||||
Socket s;
|
||||
|
||||
@@ -42,7 +42,7 @@ import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
//@Component
|
||||
public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
|
||||
Socket s;
|
||||
|
||||
@@ -49,7 +49,7 @@ public class ItemProtocol {
|
||||
/**
|
||||
* 下发命令
|
||||
*/
|
||||
public static String item_to_command = "to_command";
|
||||
public static String item_to_command = "toCommand";
|
||||
/**
|
||||
* 下发托盘类型
|
||||
*/
|
||||
|
||||
@@ -39,10 +39,9 @@ import java.util.Objects;
|
||||
@Slf4j
|
||||
public class InstructionAgvServiceImpl implements InstructionAgvService {
|
||||
|
||||
@Autowired
|
||||
private TaskAgvService taskService;
|
||||
private final TaskAgvService taskService;
|
||||
|
||||
private final IInstructionServiceMapper instructionService;
|
||||
private final IInstructionServiceMapper instructionService;
|
||||
|
||||
private final IRouteLineServiceMapper routeLineServiceDao;
|
||||
|
||||
@@ -115,6 +114,10 @@ public class InstructionAgvServiceImpl implements InstructionAgvService {
|
||||
|
||||
QueryWrapper<InstructionEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("task_id", entity.getTask_id());
|
||||
List<String> statusList=new ArrayList<>();
|
||||
statusList.add(InstructionStatusEnum.READY.getIndex());
|
||||
statusList.add(InstructionStatusEnum.BUSY.getIndex());
|
||||
queryWrapper.in("instruction_status",statusList);
|
||||
List<InstructionEntity> list=instructionService.selectList(queryWrapper);
|
||||
if(!list.isEmpty()){
|
||||
throw new Exception(entity.getTask_code() + ":该任务已存在待完成指令!");
|
||||
@@ -198,9 +201,9 @@ public class InstructionAgvServiceImpl implements InstructionAgvService {
|
||||
if (resp.isSuccess()) {
|
||||
entity.setSend_status("1");
|
||||
}else{
|
||||
entity.setSend_status("2");
|
||||
entity.setRemark(resp.getMessage());
|
||||
log.error("下发指令到Agv,下发失败:{}",resp.getMessage());
|
||||
throw new BadRequestException("下发指令到Agv,下发失败!");
|
||||
|
||||
}
|
||||
//更新下发状态
|
||||
String now = DateUtil.now();
|
||||
|
||||
@@ -29,7 +29,7 @@ import java.util.Map;
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "手持接口")
|
||||
@RequestMapping("api/hand")
|
||||
@RequestMapping("api/handds")
|
||||
@Slf4j
|
||||
public class HandController {
|
||||
@Autowired
|
||||
@@ -82,8 +82,8 @@ public class HandController {
|
||||
}
|
||||
|
||||
@PostMapping("/tasks")
|
||||
@Log("查询未完成指令")
|
||||
@ApiOperation("查询未完成指令")
|
||||
@Log("查询未完成任务")
|
||||
@ApiOperation("查询未完成任务")
|
||||
@SaIgnore
|
||||
//@PreAuthorize("@el.check('sect:list')")
|
||||
public ResponseEntity<Object> querytasks(@RequestBody HeadTaskDto dto, HttpServletRequest request ) {
|
||||
@@ -92,8 +92,8 @@ public class HandController {
|
||||
}
|
||||
|
||||
@PostMapping("/taskoperation")
|
||||
@Log("指令操作")
|
||||
@ApiOperation("指令操作")
|
||||
@Log("任务操作")
|
||||
@ApiOperation("任务操作")
|
||||
@SaIgnore
|
||||
//@PreAuthorize("@el.check('sect:list')")
|
||||
public ResponseEntity<Object> taskOperation(@RequestBody HeadTaskDto dto) throws Exception {
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
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.HandPbService;
|
||||
import org.nl.hand.service.HandService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @Author: zhang
|
||||
* @Date: 2024/12/59:53
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "手持平板接口")
|
||||
@RequestMapping("api/hand")
|
||||
@Slf4j
|
||||
public class HandPbController {
|
||||
|
||||
@Autowired
|
||||
private HandPbService handService;
|
||||
|
||||
@PostMapping("/insts")
|
||||
@Log("查询未完成指令")
|
||||
@ApiOperation("查询未完成指令")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> queryInst(@RequestBody HeadInstDto dto) {
|
||||
return new ResponseEntity<>(handService.queryInst(dto), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/inst")
|
||||
@Log("指令操作")
|
||||
@ApiOperation("指令操作")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> instOpt(@RequestBody HeadInstDto dto) throws Exception {
|
||||
return new ResponseEntity<>(handService.instOpt(dto), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/tasks")
|
||||
@Log("查询未完成任务")
|
||||
@ApiOperation("查询未完成任务")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> querytasks(@RequestBody HeadTaskDto dto, HttpServletRequest request ) {
|
||||
request.getHeader("Accept-Language");
|
||||
return new ResponseEntity<>(handService.querytasks(dto), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/taskoperation")
|
||||
@Log("任务操作")
|
||||
@ApiOperation("任务操作")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> taskOperation(@RequestBody HeadTaskDto dto) throws Exception {
|
||||
return new ResponseEntity<>(handService.taskOperation(dto), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package org.nl.hand.service;
|
||||
|
||||
|
||||
import org.nl.hand.dto.HeadDto;
|
||||
import org.nl.hand.dto.HeadInstDto;
|
||||
import org.nl.hand.dto.HeadTaskDto;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface HandPbService {
|
||||
|
||||
/*
|
||||
*查询未完成指令
|
||||
*/
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
package org.nl.hand.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.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.instruction.dao.InstructionEntity;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.instruction.domain.InstructionMybatis;
|
||||
import org.nl.acs.instruction.enums.InstructionStatusEnum;
|
||||
import org.nl.acs.instruction.service.InstructionAgvService;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
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.config.language.LangProcess;
|
||||
import org.nl.hand.dto.HeadDto;
|
||||
import org.nl.hand.dto.HeadInstDto;
|
||||
import org.nl.hand.dto.HeadTaskDto;
|
||||
import org.nl.hand.service.HandPbService;
|
||||
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.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class HandPbServiceImpl implements HandPbService {
|
||||
|
||||
@Autowired
|
||||
private TaskService taskserver;
|
||||
@Autowired
|
||||
private InstructionService instructionService;
|
||||
|
||||
private final InstructionAgvService instructionAgvService;
|
||||
|
||||
@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(LangProcess.msg("error_no_ins"));
|
||||
}
|
||||
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_point_code());
|
||||
inst.put("next_devicecode", list.get(i).getNext_point_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", LangProcess.msg("universal_directives_message1"));
|
||||
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 {
|
||||
instructionAgvService.cancel(inst_uuid);
|
||||
} catch (Exception e) {
|
||||
resultJson.put("message", e.getMessage());
|
||||
resultJson.put("data", data);
|
||||
return resultJson;
|
||||
}
|
||||
}else if ("2".equals(type)){
|
||||
try {
|
||||
instructionAgvService.sendToAgv(inst_uuid);
|
||||
} catch (Exception e) {
|
||||
resultJson.put("message", e.getMessage());
|
||||
resultJson.put("data", data);
|
||||
return resultJson;
|
||||
}
|
||||
}else if ("3".equals(type)){
|
||||
try {
|
||||
instructionAgvService.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(LangProcess.msg("error_no_ins"));
|
||||
}
|
||||
JSONArray data = new JSONArray();
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
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_point_code());
|
||||
task.put("next_devicecode", list.get(i).getNext_point_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", LangProcess.msg("universal_directives_message1"));
|
||||
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)){
|
||||
//重新生成指令
|
||||
try{
|
||||
InstructionEntity instructionEntity = new InstructionEntity();
|
||||
BeanUtils.copyProperties(taskDto,instructionEntity);
|
||||
instructionEntity.setInstruction_type(taskDto.getTask_type());
|
||||
instructionEntity.setInstruction_id(IdUtil.simpleUUID());
|
||||
String now = DateUtil.now();
|
||||
instructionEntity.setCreate_time(now);
|
||||
instructionEntity.setCreate_by("auto");
|
||||
instructionEntity.setInstruction_status(InstructionStatusEnum.READY.getIndex());
|
||||
instructionEntity.setInstruction_code(CodeUtil.getNewCode("INSTRUCT_NO"));
|
||||
instructionAgvService.create(instructionEntity);
|
||||
} catch (Exception e){
|
||||
resultJson.put("message", e.getMessage());
|
||||
resultJson.put("data", data);
|
||||
return resultJson;
|
||||
}
|
||||
}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;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ spring:
|
||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||
# url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:stand_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
# url: jdbc:log4jdbc:mysql://${DB_HOST:47.111.78.178}:${DB_PORT:3306}/${DB_NAME:lzhl_two_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.251}:${DB_PORT:3306}/${DB_NAME:斗山_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.251}:${DB_PORT:3306}/${DB_NAME:tekela_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
|
||||
|
||||
username: ${DB_USER:root}
|
||||
# password: ${DB_PWD:Root.123456}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user