From 7bea2bbcdf45e81c6acc03e4170df8603fdc625f Mon Sep 17 00:00:00 2001 From: tuqiang <437016993@qq.com> Date: Thu, 12 Feb 2026 16:57:40 +0800 Subject: [PATCH] =?UTF-8?q?add=EF=BC=9A=E6=96=B0=E5=A2=9E=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/nl/acs/test/rest/TestController.java | 11 ++- .../org/nl/acs/test/service/TestService.java | 2 + .../test/service/impl/TestServiceImpl.java | 70 +++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/test/rest/TestController.java b/acs/nladmin-system/src/main/java/org/nl/acs/test/rest/TestController.java index 50d710c..eb69411 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/test/rest/TestController.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/test/rest/TestController.java @@ -2,6 +2,7 @@ package org.nl.acs.test.rest; +import cn.dev33.satoken.annotation.SaIgnore; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; @@ -35,11 +36,19 @@ public class TestController { @ApiOperation("test1") @PostMapping("/test1") //@PreAuthorize("@el.check('task:add')") - public ResponseEntity test1() throws IOException { + public ResponseEntity task() throws IOException { testService.test1(); return new ResponseEntity<>(HttpStatus.CREATED); } + @PostMapping("/task") + @Log("任务操作") + @ApiOperation("任务操作") + @SaIgnore + public ResponseEntity tasks(@RequestBody Map whereJson) throws Exception { + return new ResponseEntity<>(testService.tasks(whereJson), HttpStatus.OK); + } + @Log("test2") @ApiOperation("test2") @PostMapping("/test2") diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/test/service/TestService.java b/acs/nladmin-system/src/main/java/org/nl/acs/test/service/TestService.java index ef80fe4..108c981 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/test/service/TestService.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/test/service/TestService.java @@ -69,4 +69,6 @@ public interface TestService { * @throws IOException */ JSONObject print() throws IOException; + + JSONObject tasks(Map whereJson) throws Exception; } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/test/service/impl/TestServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/test/service/impl/TestServiceImpl.java index 5d1ff4f..f7bd589 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/test/service/impl/TestServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/test/service/impl/TestServiceImpl.java @@ -2,10 +2,21 @@ package org.nl.acs.test.service.impl; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.opc.Device; +import org.nl.acs.opc.DeviceAppService; +import org.nl.acs.task.service.TaskService; +import org.nl.acs.task.service.dto.TaskDto; import org.nl.acs.test.service.TestService; +import org.nl.modules.common.utils.SecurityUtils; +import org.nl.modules.system.util.CodeUtil; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.io.IOException; @@ -22,6 +33,13 @@ import java.util.Map; public class TestServiceImpl implements TestService { + @Autowired + private TaskService taskService; + @Autowired + private InstructionService instructionService; + @Autowired + private DeviceAppService deviceAppService; + @Override public void test1() throws IOException { @@ -61,4 +79,56 @@ public class TestServiceImpl implements TestService public JSONObject print() throws IOException { return null; } + + @Override + public JSONObject tasks(Map whereJson) throws Exception { + JSONObject resultJson = new JSONObject(); + String start_device_code = whereJson.get("start_code"); + if (StrUtil.isEmpty(start_device_code)) { + resultJson.put("code", "400"); + resultJson.put("message", "起始库位不能为空!"); + return resultJson; + } + Device startDevice = deviceAppService.findDeviceByCode(start_device_code); + if (startDevice == null) { + resultJson.put("code", "0"); + resultJson.put("message", "起始库位不存在,请添加起始库位!"); + return resultJson; + } + String next_device_code = whereJson.get("end_code"); + if (StrUtil.isEmpty(next_device_code)) { + resultJson.put("code", "0"); + resultJson.put("message", "目的库位不能为空!"); + return resultJson; + } + Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); + if (nextDevice == null) { + resultJson.put("code", "0"); + resultJson.put("message", "目的库位不存在,请添加目的库位!"); + return resultJson; + } + String currentUsername = SecurityUtils.getCurrentUsername(); + String now = DateUtil.now(); + String task_uuid = IdUtil.simpleUUID(); + String task_code = CodeUtil.getNewCode("TASK_NO"); + task_code = "-" + task_code; + + JSONObject jo = new JSONObject(); + jo.put("task_id", task_uuid); + jo.put("task_code", task_code); + jo.put("start_point_code", start_device_code); + jo.put("next_point_code", next_device_code); + jo.put("start_parent_code", start_device_code); + jo.put("next_parent_code", next_device_code); + jo.put("start_device_code", start_device_code); + jo.put("next_device_code", next_device_code); + jo.put("priority", "1"); + jo.put("create_time", now); + jo.put("create_by", currentUsername); + TaskDto task_dto = (TaskDto) JSONObject.parseObject(String.valueOf(jo), TaskDto.class); + taskService.create(task_dto); + resultJson.put("code", "200"); + resultJson.put("message", "下发成功"); + return resultJson; + } }