Browse Source

rev:更新

modbus_client
gengby 10 months ago
parent
commit
fb84f8b741
  1. 26
      acs/nladmin-system/src/main/java/org/nl/acs/task/rest/TaskController.java
  2. 78
      acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java
  3. 261
      acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

26
acs/nladmin-system/src/main/java/org/nl/acs/task/rest/TaskController.java

@ -69,24 +69,6 @@ public class TaskController {
return new ResponseEntity<>(HttpStatus.CREATED); return new ResponseEntity<>(HttpStatus.CREATED);
} }
@PostMapping(value = "/adds")
@Log("常规任务保存")
@ApiOperation("常规任务保存")
//@PreAuthorize("@el.check('task:add')")
public ResponseEntity<Object> ordinaryTaskCreate(@RequestBody JSONObject json) throws Exception {
taskService.ordinaryTaskCreate(json);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@PostMapping(value = "/addes")
@Log("特殊任务保存")
@ApiOperation("特殊任务保存")
public ResponseEntity<Object> specialTaskCreate(@RequestBody JSONObject json) throws Exception {
taskService.specialTaskCreate(json);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@PutMapping @PutMapping
@Log("修改任务") @Log("修改任务")
@ApiOperation("修改任务") @ApiOperation("修改任务")
@ -137,14 +119,6 @@ public class TaskController {
taskService.download(taskService.queryAll(whereJson), response); taskService.download(taskService.queryAll(whereJson), response);
} }
@Log("一体机触发任务")
@ApiOperation("一体机触发任务")
@PostMapping("/createTaskByClick")
//@PreAuthorize("@el.check('task:add')")
public ResponseEntity<Object> createTaskByClick(@RequestBody JSONObject json) {
taskService.createTaskByClick(json);
return new ResponseEntity<>(HttpStatus.CREATED);
}
@Log("设备申请任务") @Log("设备申请任务")
@ApiOperation("设备申请任务") @ApiOperation("设备申请任务")

78
acs/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java

@ -75,21 +75,6 @@ public interface TaskService {
*/ */
TaskDto findById(String task_id); TaskDto findById(String task_id);
/**
* 查询所有未完成任务
*
* @param whereJson 条件参数
* @return List<AcsTaskDto>
*/
List<TaskDto> queryAllUnfinished(Map whereJson);
/**
* 根据状态查询
*
* @param task_status task_status
* @return AcsTask
*/
List<TaskDto> queryByStauts(String task_status);
/** /**
* 根据编码查询 * 根据编码查询
@ -99,10 +84,6 @@ public interface TaskService {
*/ */
TaskDto findByCode(String code); TaskDto findByCode(String code);
/**
* 根据设备号查询未执行的任务
*/
List<TaskDto> queryTaskByDeviceCode(String device_code);
/** /**
* 创建 * 创建
@ -111,19 +92,6 @@ public interface TaskService {
*/ */
void create(TaskDto dto) throws Exception; void create(TaskDto dto) throws Exception;
/**
* 常规任务保存
*
* @param /
*/
void ordinaryTaskCreate(JSONObject json) throws Exception;
/**
* 特殊任务保存
*
* @param /
*/
void specialTaskCreate(JSONObject json) throws Exception;
/** /**
* 编辑 * 编辑
@ -170,44 +138,12 @@ public interface TaskService {
void download(List<TaskDto> dtos, HttpServletResponse response) throws IOException; void download(List<TaskDto> dtos, HttpServletResponse response) throws IOException;
/**
* 根据触摸屏点击保存创建任务
*
* @param json
*/
void createTaskByClick(JSONObject json);
int checkAllowCreate(String code);
boolean removeByCodeFromCache(String code); boolean removeByCodeFromCache(String code);
TaskDto findByContainer(String container_code);
TaskDto findByCodeFromCache(String task_code); TaskDto findByCodeFromCache(String task_code);
/**
* 根据目的地设备编号查询当前是否有设备
*
* @param device_code
* @return
*/
TaskDto findByNextCode(String device_code);
/**
* 根据起点设备编号查询当前是否有设备
*
* @param device_code
* @return
*/
TaskDto findByStartCode(String device_code);
/**
* 查询内存任务
*
* @return
*/
List<TaskDto> findAllTaskFromCache();
TaskDto foramte(TaskDto task); TaskDto foramte(TaskDto task);
@ -227,19 +163,7 @@ public interface TaskService {
*/ */
String queryAssignedByDevice(String device_code, String task_nextdevice_code); String queryAssignedByDevice(String device_code, String task_nextdevice_code);
/**
* 查询相同任务类型的数量
*
* @param taskType
* @return
*/
Integer querySameTaskByType(String taskType);
/** TaskDto findByContainer(String vehicle_code);
* 根据设备号和任务状态查询
* @param device_code
* @return
*/
List<TaskDto> queryTaskByDeviceCodeAndStatus(String device_code);
} }

261
acs/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

@ -234,13 +234,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
return obj; return obj;
} }
@Override
public List<TaskDto> queryAllUnfinished(Map whereJson) {
WQLObject wo = WQLObject.getWQLObject("acs_task");
JSONArray arr = wo.query("task_status < 2 ").getResultJSONArray(0);
List<TaskDto> list = arr.toJavaList(TaskDto.class);
return list;
}
@Override @Override
public TaskDto findByCode(String code) { public TaskDto findByCode(String code) {
@ -250,26 +243,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
return obj; return obj;
} }
@Override
public List<TaskDto> queryTaskByDeviceCode(String device_code) {
List<TaskDto> list = new ArrayList<>();
Iterator<TaskDto> iterator = tasks.iterator();
while (iterator.hasNext()) {
TaskDto task = iterator.next();
if (task.getStart_device_code().equals(device_code) && StrUtil.equals(task.getTask_status(), "0")) {
list.add(task);
}
}
return list;
}
@Override
public List<TaskDto> queryByStauts(String status) {
WQLObject wo = WQLObject.getWQLObject("acs_task");
JSONArray arr = wo.query("task_status = '" + status + "'", "priority DESC, create_time ASC").getResultJSONArray(0);
List<TaskDto> list = arr.toJavaList(TaskDto.class);
return list;
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ -317,120 +290,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
tasks.add(dto); tasks.add(dto);
} }
/**
* 常规任务保存
*
* @param /
* @throws Exception
*/
@Override
public void ordinaryTaskCreate(JSONObject json) throws Exception {
JSONArray array = json.getJSONArray("data");
if (array.size() == 0) {
throw new RuntimeException("请选择起点");
}
for (int i = 0; i < array.size(); i++) {
JSONObject arrjo = array.getJSONObject(i);
String material_type = arrjo.getString("material_type");
String quantity = arrjo.getString("quantity");
String remark = arrjo.getString("remark");
TaskDto dto = new TaskDto();
Map whereJson = (Map) array.get(i);
//String device_code = (String) whereJson.get("device_code");
String device_code = MapUtil.getStr(whereJson, "device_code");
dto.setRoute_plan_code("one");
String next_device_code = "";
String plan_uuid = WQLObject.getWQLObject("acs_route_plan").query("plan_code= '" + dto.getRoute_plan_code() + "'").uniqueResult(0).getString("plan_uuid");
JSONArray ja = routelineserver.queryNextLine(device_code, plan_uuid);
for (int j = 0; j < ja.size(); j++) {
JSONObject jo = (JSONObject) ja.get(j);
next_device_code = jo.get("next_device_code").toString();
}
if (ObjectUtil.isNotEmpty(this.findByStartCode(device_code))) {
throw new WDKException("已存在该起点的任务!");
}
if (StrUtil.equals(material_type, "") || StrUtil.equals(quantity, "")) {
throw new RuntimeException("请填写物料信息!");
}
dto.setStart_device_code(device_code);
dto.setStart_point_code(device_code);
dto.setNext_device_code(next_device_code);
dto.setNext_point_code(next_device_code);
dto.setQuantity(new BigDecimal(quantity));
dto.setRemark(remark);
dto.setMaterial(material_type);
create(dto);
}
}
/**
* 特殊任务保存
*
* @param /
* @throws Exception
*/
@Override
public void specialTaskCreate(JSONObject json) throws Exception {
JSONArray array = json.getJSONArray("data1");
JSONArray array2 = json.getJSONArray("data2");
JSONArray array3 = json.getJSONArray("data3");
if (array.size() != 0 && array3.size() != 0) {
throw new RuntimeException("只能选择一个终点");
}
for (int i = 0; i < array2.size(); i++) {
JSONObject arrjo = array2.getJSONObject(i);
String material_type = arrjo.getString("material_type");
String quantity = arrjo.getString("quantity");
String remark = arrjo.getString("remark");
TaskDto dto = new TaskDto();
Map whereJson;
Map whereJson2;
Map whereJson3;
if (array.size() != 0) {
whereJson = (Map) array.get(i);
} else {
whereJson = null;
}
if (array2.size() != 0) {
whereJson2 = (Map) array2.get(i);
} else {
whereJson2 = null;
}
if (array3.size() != 0) {
whereJson3 = (Map) array3.get(i);
} else {
whereJson3 = null;
}
String start_device_code = MapUtil.getStr(whereJson2, "device_code");
String next_device_code = "";
if (ObjectUtil.isEmpty(whereJson)) {
next_device_code = MapUtil.getStr(whereJson3, "device_code");
} else {
next_device_code = MapUtil.getStr(whereJson, "device_code");
}
if (ObjectUtil.isNotEmpty(this.findByStartCode(start_device_code))
|| ObjectUtil.isNotEmpty(this.findByNextCode(next_device_code))) {
throw new WDKException("已存在该起点或终点的任务!");
}
if (StrUtil.equals(material_type, "") || StrUtil.equals(quantity, "")) {
throw new RuntimeException("请填写物料信息!");
}
dto.setRoute_plan_code("two");
dto.setStart_device_code(start_device_code);
dto.setStart_point_code(start_device_code);
dto.setNext_device_code(next_device_code);
dto.setNext_point_code(next_device_code);
dto.setQuantity(new BigDecimal(quantity));
dto.setRemark(remark);
dto.setMaterial(material_type);
create(dto);
}
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ -735,48 +594,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
FileUtil.downloadExcel(list, response); FileUtil.downloadExcel(list, response);
} }
@Override
public void createTaskByClick(JSONObject json) {
String device_code = json.getString("device_code");
String type = json.getString("type");
Device device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isNull(device)) {
return;
}
StandardInspectSiteDeviceDriver deviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
if (ObjectUtil.isNull(deviceDriver)) {
return;
}
//type=1 叫料 2 搬运任务
if (StrUtil.equals(type, "1")) {
Boolean is_applyMaterial = deviceDriver.getApply_material();
//未生成任务
if (!is_applyMaterial) {
deviceDriver.setApply_material(true);
}
} else {
Boolean is_applyHandling = deviceDriver.getApply_handling();
//未生成任务
if (!is_applyHandling) {
deviceDriver.setApply_handling(true);
}
}
}
@Override
public int checkAllowCreate(String devicecode) {
Map map = new HashMap();
List<TaskDto> taskList = this.queryAllUnfinished(map);
int num = 0;
for (int i = 0; i < taskList.size(); i++) {
TaskDto onetask = taskList.get(i);
String next_code = onetask.getNext_point_code();
if (StrUtil.equals(devicecode, next_code)) {
num = num + 1;
}
}
return num;
}
@Override @Override
public boolean removeByCodeFromCache(String code) { public boolean removeByCodeFromCache(String code) {
@ -791,25 +608,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
return false; return false;
} }
@Override
public List<TaskDto> findAllTaskFromCache() {
return tasks;
}
public TaskDto findByContainer(String container_code) {
Iterator var3 = tasks.iterator();
while (var3.hasNext()) {
TaskDto task = (TaskDto) var3.next();
if (StrUtil.equals(task.getVehicle_code(), container_code)) {
return task;
}
}
return null;
}
@Override
public TaskDto findByCodeFromCache(String task_code) { public TaskDto findByCodeFromCache(String task_code) {
Iterator var3 = tasks.iterator(); Iterator var3 = tasks.iterator();
@ -822,31 +622,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
return null; return null;
} }
@Override
public TaskDto findByNextCode(String device_code) {
Iterator var3 = tasks.iterator();
while (var3.hasNext()) {
TaskDto task = (TaskDto) var3.next();
if (StrUtil.equals(task.getNext_device_code(), device_code)) {
return task;
}
}
return null;
}
@Override
public TaskDto findByStartCode(String device_code) {
Iterator var3 = tasks.iterator();
while (var3.hasNext()) {
TaskDto task = (TaskDto) var3.next();
if (StrUtil.equals(task.getStart_device_code(), device_code)) {
return task;
}
}
return null;
}
@Override @Override
public TaskDto foramte(TaskDto task) { public TaskDto foramte(TaskDto task) {
@ -1016,33 +791,15 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
} }
@Override @Override
public Integer querySameTaskByType(String taskType) { public TaskDto findByContainer(String vehicle_code) {
int num = 0; return Optional
Iterator<TaskDto> iterator = tasks.iterator(); .ofNullable(this.tasks)
while (iterator.hasNext()) { .orElse(new ArrayList<>())
TaskDto task = iterator.next(); .stream()
if (task.getTask_type().equals(taskType) && task.getTask_status().equals("1")) { .filter(taskDto -> taskDto.getVehicle_code().equals(vehicle_code))
num++; .findFirst()
} .orElse(null);
}
return num;
} }
@Override
public List<TaskDto> queryTaskByDeviceCodeAndStatus(String device_code) {
List<TaskDto> list = new ArrayList<>();
Iterator<TaskDto> iterator = tasks.iterator();
while (iterator.hasNext()) {
TaskDto task = iterator.next();
if (task.getStart_device_code().equals(device_code) && StrUtil.equals(task.getTask_status(), "1")) {
Instruction instruction = instructionService.findByTaskcodeAndStatus(task.getTask_code());
if (ObjectUtil.isNotEmpty(instruction)) {
list.add(task);
}
}
}
return list;
}
} }

Loading…
Cancel
Save