Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -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<Object> test1() throws IOException {
|
||||
public ResponseEntity<Object> task() throws IOException {
|
||||
testService.test1();
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PostMapping("/task")
|
||||
@Log("任务操作")
|
||||
@ApiOperation("任务操作")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> tasks(@RequestBody Map<String, String> whereJson) throws Exception {
|
||||
return new ResponseEntity<>(testService.tasks(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("test2")
|
||||
@ApiOperation("test2")
|
||||
@PostMapping("/test2")
|
||||
|
||||
@@ -69,4 +69,6 @@ public interface TestService {
|
||||
* @throws IOException
|
||||
*/
|
||||
JSONObject print() throws IOException;
|
||||
|
||||
JSONObject tasks(Map<String, String> whereJson) throws Exception;
|
||||
}
|
||||
|
||||
@@ -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<String, String> 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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user