|
|
@ -234,13 +234,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { |
|
|
|
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 |
|
|
|
public TaskDto findByCode(String code) { |
|
|
@ -250,26 +243,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { |
|
|
|
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 |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@ -317,120 +290,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { |
|
|
|
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 |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@ -735,48 +594,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { |
|
|
|
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 |
|
|
|
public boolean removeByCodeFromCache(String code) { |
|
|
@ -791,25 +608,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { |
|
|
|
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) { |
|
|
|
Iterator var3 = tasks.iterator(); |
|
|
|
|
|
|
@ -822,31 +622,6 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { |
|
|
|
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 |
|
|
|
public TaskDto foramte(TaskDto task) { |
|
|
@ -1016,33 +791,15 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Integer querySameTaskByType(String taskType) { |
|
|
|
int num = 0; |
|
|
|
Iterator<TaskDto> iterator = tasks.iterator(); |
|
|
|
while (iterator.hasNext()) { |
|
|
|
TaskDto task = iterator.next(); |
|
|
|
if (task.getTask_type().equals(taskType) && task.getTask_status().equals("1")) { |
|
|
|
num++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return num; |
|
|
|
public TaskDto findByContainer(String vehicle_code) { |
|
|
|
return Optional |
|
|
|
.ofNullable(this.tasks) |
|
|
|
.orElse(new ArrayList<>()) |
|
|
|
.stream() |
|
|
|
.filter(taskDto -> taskDto.getVehicle_code().equals(vehicle_code)) |
|
|
|
.findFirst() |
|
|
|
.orElse(null); |
|
|
|
} |
|
|
|
|
|
|
|
@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; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|