删除任务相关代码

This commit is contained in:
ldj_willow
2022-10-10 15:41:56 +08:00
parent f6de45d426
commit 3d9236b3d0
6 changed files with 18 additions and 434 deletions

View File

@@ -3,7 +3,6 @@ package org.nl.wms.ext.acs.service.impl;
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;
@@ -20,7 +19,6 @@ import org.nl.wms.sch.manage.TaskStatusEnum;
import org.nl.wms.sch.service.PointService;
import org.nl.wms.sch.service.TaskService;
import org.nl.wms.sch.service.dto.TaskDto;
import org.nl.wms.sch.tasks.*;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -138,283 +136,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
@Override
@Transactional
public JSONObject apply(JSONObject whereJson) {
String type = whereJson.getString("type");
String point_code = whereJson.getString("point_code");
String vehicle_num = whereJson.getString("vehicle_num");
String vehicle_type = whereJson.getString("vehicle_type");
String vehicle_code = whereJson.getString("vehicle_code");
String qty = whereJson.getString("qty");
if (ObjectUtil.isEmpty(type)) throw new BadRequestException("类型不能为空");
if (ObjectUtil.isEmpty(point_code)) throw new BadRequestException("点位不能为空");
WQLObject empTab = WQLObject.getWQLObject("st_ivt_EmptyVehicleRecord");// 空载具作业记录表
WQLObject taskTab = WQLObject.getWQLObject("sch_base_task");// 空载具作业记录表
WQLObject regionTab = WQLObject.getWQLObject("ST_IVT_regionIO"); // 区域出入库表
WQLObject veQtyTab = WQLObject.getWQLObject("PDM_BI_vehicleQty"); // 托盘对应数量表
/*
* 根据type判断是什么业务类型
* 1.共挤线申请空盘
* 2.共挤线满托入库
* 3.油漆线申请空盘
* 4.油漆线申请物料
* 5.油漆线空盘入库
* 6.一楼空盘入库 (有载具号)
* 7.油漆线->输送线
* 8.豪凯自动线下料入库
*/
JSONObject resuft = new JSONObject();
try {
if (StrUtil.equals(type, "1")) {
// 1.共挤线申请空盘: 调用空托盘出库处理类创建任务
if (ObjectUtil.isEmpty(vehicle_num)) throw new BadRequestException("数量不能为空");
JSONObject param = new JSONObject();
param.put("next_point_code", point_code);
param.put("qty", vehicle_num);
// 创建任务
CallEmpVehicleTask taskBean = SpringContextHolder.getBean(CallEmpVehicleTask.class);
String task_id = taskBean.createTask(param);
// 插入空载具作业记录表
JSONObject jsonEmpParam = new JSONObject();
jsonEmpParam.put("vehicle_qty", vehicle_num);
jsonEmpParam.put("task_id", task_id);
jsonEmpParam.put("io_type", "1");
this.createEmp(jsonEmpParam);
// 下发
JSONObject jsonObject = taskBean.renotifyAcs(task_id);
if (StrUtil.equals(jsonObject.getString("status"), "200")) {
// 成功返回 更新任务状态
resuft.put("status", "200");
resuft.put("message", "");
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
jsonTask.put("task_status", "05");
taskTab.update(jsonTask);
} else {
throw new BadRequestException(jsonObject.getString("message"));
}
} else if (StrUtil.equals(type, "2")) {
// 2.共挤线满托入库: 调用物料入库处理类创建任务
if (ObjectUtil.isEmpty(qty) || (StrUtil.equals(qty, "0")))
throw new BadRequestException("物料数量不能为空或者为0");
JSONObject param = new JSONObject();
param.put("start_point_code", point_code);
SendMaterialTask taskBean = SpringContextHolder.getBean(SendMaterialTask.class);
String task_id = taskBean.createTask(param);
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
// 插入区域出入库表
param.put("next_point_code", jsonTask.getString("next_point_code"));
param.put("qty", qty);
param.put("task_id", task_id);
param.put("io_type", "0");
JSONObject json = this.inCreateRegion(param);
// 回显任务载具类型
jsonTask.put("vehicle_type", json.getString("vehicle_type"));
taskTab.update(jsonTask);
// 下发
JSONObject jsonObject = taskBean.renotifyAcs(task_id);
if (StrUtil.equals(jsonObject.getString("status"), "200")) {
// 成功返回 更新任务状态
resuft.put("status", "200");
resuft.put("message", "");
jsonTask.put("task_status", "05");
taskTab.update(jsonTask);
} else {
throw new BadRequestException(jsonObject.getString("message"));
}
} else if (StrUtil.equals(type, "3")) {
// 3.油漆线申请空盘: 调用空托盘出库处理类创建任务
if (ObjectUtil.isEmpty(vehicle_num)) throw new BadRequestException("数量不能为空");
JSONObject param = new JSONObject();
param.put("next_point_code", point_code);
param.put("qty", vehicle_num);
// 创建任务
CallEmpVehicleTask taskBean = SpringContextHolder.getBean(CallEmpVehicleTask.class);
String task_id = taskBean.createTask(param);
// 插入空载具作业记录表
JSONObject jsonEmpParam = new JSONObject();
jsonEmpParam.put("vehicle_qty", vehicle_num);
jsonEmpParam.put("task_id", task_id);
jsonEmpParam.put("io_type", "1");
this.createEmp(jsonEmpParam);
// 下发
JSONObject jsonObject = taskBean.renotifyAcs(task_id);
if (StrUtil.equals(jsonObject.getString("status"), "200")) {
// 成功返回 更新任务状态
resuft.put("status", "200");
resuft.put("message", "");
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
jsonTask.put("task_status", "05");
taskTab.update(jsonTask);
} else {
throw new BadRequestException(jsonObject.getString("message"));
}
} else if (StrUtil.equals(type, "4")) {
// 4.油漆线申请物料: 调用物料出库库处理类创建任务
JSONObject param = new JSONObject();
param.put("next_point_code", point_code);
param.put("io_type", "1");
// 插入区域出库单
JSONObject json = this.outCreateRegion(param);
param.put("vehicle_type", json.getString("vehicle_type"));
param.put("material_id", json.getString("material_id"));
param.put("create_mode", json.getString("create_mode"));
param.put("iostorinv_id", json.getString("iostorinv_id"));
// 创建任务
CallMaterialTask taskBean = SpringContextHolder.getBean(CallMaterialTask.class);
String task_id = taskBean.createTask(param);
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
// 回显出库单起始点位、起始区域、任务id
JSONObject jsonRegion = regionTab.query("iostorinv_id = '" + json.getString("iostorinv_id") + "'").uniqueResult(0);
jsonRegion.put("start_point_code", jsonTask.getString("start_point_code"));
Long start_region_id = SpringContextHolder.getBean(PointService.class).findByCode(jsonTask.getString("start_point_code")).getRegion_id();
jsonRegion.put("start_region_id", String.valueOf(start_region_id));
jsonRegion.put("task_id", Long.valueOf(task_id));
regionTab.update(jsonRegion);
// 下发
JSONObject jsonObject = taskBean.renotifyAcs(task_id);
if (StrUtil.equals(jsonObject.getString("status"), "200")) {
// 成功返回 更新任务状态
resuft.put("status", "200");
resuft.put("message", "");
jsonTask.put("task_status", "05");
taskTab.update(jsonTask);
} else {
throw new BadRequestException(jsonObject.getString("message"));
}
} else if (StrUtil.equals(type, "5")) {
// 5.油漆线空盘入库: 调用空托盘入库处理类创建任务
if (ObjectUtil.isEmpty(vehicle_num)) throw new BadRequestException("数量不能为空");
JSONObject param = new JSONObject();
param.put("start_point_code", point_code);
param.put("qty", vehicle_num);
// 创建任务
SendEmpVehicleTask taskBean = SpringContextHolder.getBean(SendEmpVehicleTask.class);
String task_id = taskBean.createTask(param);
// 插入空载具作业记录表
JSONObject jsonEmpParam = new JSONObject();
jsonEmpParam.put("vehicle_qty", vehicle_num);
jsonEmpParam.put("task_id", task_id);
jsonEmpParam.put("io_type", "0");
this.createEmp(jsonEmpParam);
// 下发
JSONObject jsonObject = taskBean.renotifyAcs(task_id);
if (StrUtil.equals(jsonObject.getString("status"), "200")) {
// 成功返回 更新任务状态
resuft.put("status", "200");
resuft.put("message", "");
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
jsonTask.put("task_status", "05");
taskTab.update(jsonTask);
} else {
throw new BadRequestException(jsonObject.getString("message"));
}
} else if (StrUtil.equals(type, "6")) {
// 6.一楼空盘入库 (有载具号): 调用空托盘入库处理类创建任务
if (ObjectUtil.isEmpty(vehicle_code)) throw new BadRequestException("载具号不能为空");
JSONObject param = new JSONObject();
// 查询载具号对应的数量
JSONObject jsonVeQty = new JSONObject();
if (ObjectUtil.isEmpty(qty)) {
jsonVeQty = veQtyTab.query("vehicle_code = '" + vehicle_code + "' and is_task = '0' order by create_time DESC").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonVeQty)) throw new BadRequestException("请先手持扫码");
} else {
jsonVeQty.put("qty", qty);
}
param.put("qty", jsonVeQty.getString("qty"));
param.put("start_point_code", point_code);
param.put("vehicle_code", vehicle_code);
// 创建任务
SendEmpVehicleTask taskBean = SpringContextHolder.getBean(SendEmpVehicleTask.class);
String task_id = taskBean.createTask(param);
// 插入空载具作业记录表
JSONObject jsonEmpParam = new JSONObject();
jsonEmpParam.put("vehicle_qty", jsonVeQty.getString("qty"));
jsonEmpParam.put("task_id", task_id);
jsonEmpParam.put("io_type", "0");
this.createEmp(jsonEmpParam);
// 下发
JSONObject jsonObject = taskBean.renotifyAcs(task_id);
if (StrUtil.equals(jsonObject.getString("status"), "200")) {
// 成功返回 更新任务状态
resuft.put("status", "200");
resuft.put("message", "");
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
jsonTask.put("task_status", "05");
taskTab.update(jsonTask);
// 更新载具对应数量表
jsonVeQty.put("is_task", "1");
veQtyTab.update(jsonVeQty);
} else {
throw new BadRequestException(jsonObject.getString("message"));
}
} else if (StrUtil.equals(type, "7")) {
JSONObject param = new JSONObject();
param.put("start_point_code", point_code);
// 1.生成起点确定的任务
SpringContextHolder.getBean(PointToPointTask.class).createTask(param);
resuft.put("status", "200");
resuft.put("message", "");
} else if (StrUtil.equals(type, "8")) {
// 8.豪凯自动线下料入库
JSONObject param = new JSONObject();
param.put("start_point_code", point_code);
SendMaterialTask taskBean = SpringContextHolder.getBean(SendMaterialTask.class);
String task_id = taskBean.createTask(param);
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
// 插入区域出入库表
param.put("next_point_code", jsonTask.getString("next_point_code"));
if (ObjectUtil.isEmpty(qty)) {
param.put("qty", "1"); // 为空先写死1
} else {
param.put("qty", qty);
}
param.put("task_id", task_id);
param.put("io_type", "0");
JSONObject json = this.inCreateRegion(param);
// 回显任务载具类型
jsonTask.put("vehicle_type", json.getString("vehicle_type"));
taskTab.update(jsonTask);
// 下发
JSONObject jsonObject = taskBean.renotifyAcs(task_id);
if (StrUtil.equals(jsonObject.getString("status"), "200")) {
// 成功返回 更新任务状态
resuft.put("status", "200");
resuft.put("message", "");
jsonTask.put("task_status", "05");
taskTab.update(jsonTask);
} else {
throw new BadRequestException(jsonObject.getString("message"));
}
}
} catch (Exception e) {
resuft.put("status", ((BadRequestException) e).getStatus());
resuft.put("message", e.getMessage());
}
return resuft;
public JSONObject apply(JSONObject whereJson) {
return null;
}
@Transactional

View File

@@ -1,139 +0,0 @@
package org.nl.wms.ext.auto;
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.modules.wql.util.SpringContextHolder;
import org.nl.wms.ext.acs.service.WmsToAcsService;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@RequiredArgsConstructor
@Slf4j
public class AutoQueryTask {
private final WmsToAcsService wmsToAcsService;
@Transactional
public void run() {
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
PointToPointTask pointTaskBean = SpringContextHolder.getBean(PointToPointTask.class);
// 1.查找起点为油漆线 物料下料位的任务
JSONArray taskArr = WQL.getWO("AUTO_QUERYTASK").addParam("flag", "1").process().getResultJSONArray(0);
for (int i = 0; i < taskArr.size(); i++) {
JSONObject jsonTask = taskArr.getJSONObject(i);
/*
* 1.查找输送线有没有空位 输送线1对1关系 调用获取点位状态接口
* 2.判断有空位的输送线是否有任务:起点和终点都要判断
* 输送线点位SSX01A1 - SSX01A2 SSX02A1 - SSX02A2
*/
// 2.查找输送线空位,调用获取点位状态接口
JSONArray paramArr = new JSONArray();
JSONObject pointA1 = new JSONObject();
pointA1.put("device_code", "SSX01A1");
paramArr.add(pointA1);
JSONObject pointA2 = new JSONObject();
pointA2.put("device_code", "SSX01A2");
paramArr.add(pointA2);
JSONObject pointB1 = new JSONObject();
pointB1.put("device_code", "SSX02A1");
paramArr.add(pointB1);
JSONObject pointB2 = new JSONObject();
pointB2.put("device_code", "SSX02A2");
paramArr.add(pointB2);
JSONObject result = wmsToAcsService.getPointStatus(paramArr);
if (StrUtil.equals(result.getString("status"), "200")) {
JSONObject jsonPointAfter = new JSONObject(); // 处理后的json
JSONArray dataArr = result.getJSONArray("data");
// 3.处理返回的数据处理后为jsonkey为点位编码value为状态
for (int j = 0; j < dataArr.size(); j++) {
JSONObject jsonObject = dataArr.getJSONObject(j);
String device_code = jsonObject.getString("device_code");
switch (device_code) {
case "SSX01A1" :
jsonPointAfter.put("SSX01A1",jsonObject.getString("move"));
break;
case "SSX01A2" :
jsonPointAfter.put("SSX01A2",jsonObject.getString("move"));
break;
case "SSX02A1" :
jsonPointAfter.put("SSX02A1",jsonObject.getString("move"));
break;
case "SSX02A2" :
jsonPointAfter.put("SSX02A2",jsonObject.getString("move"));
break;
}
}
JSONObject map = new JSONObject();
// 4.1判断SSX01A1 、 SSX01A2是否是空位 无任务
if (StrUtil.equals(jsonPointAfter.getString("SSX01A1"), "0") && StrUtil.equals(jsonPointAfter.getString("SSX01A2"), "0")) {
// 4.2如果都是空位 则判断是否有正在进行的任务
map.put("flag", "2");
map.put("start_point_code", "('SSX01A1','SSX01A2')");
// 查找起点是否有任务
JSONArray is_stara = WQL.getWO("AUTO_QUERYTASK").addParamMap(map).process().getResultJSONArray(0);
// 查询终点是否有任务
map.put("flag", "3");
map.put("end_point_code", "('SSX01A1','SSX01A2')");
JSONArray is_end = WQL.getWO("AUTO_QUERYTASK").addParamMap(map).process().getResultJSONArray(0);
if (ObjectUtil.isEmpty(is_stara) && ObjectUtil.isEmpty(is_end)) {
// 4.3.更新任务终点点位
jsonTask.put("next_point_code", "SSX01A1");
taskTab.update(jsonTask);
// 4.4.下发ACS
JSONObject jsonResultAcs = pointTaskBean.renotifyAcs(jsonTask.getString("task_id"));
if (StrUtil.equals(jsonResultAcs.getString("status"), "200")) {
// 4.5.下发成功、更新任务状态
jsonTask.put("task_status", "05");
taskTab.update(jsonTask);
}
// 5.1判断SSX02A1 、 SSX02A2是否是空位 无任务
} else if (StrUtil.equals(jsonPointAfter.getString("SSX02A1"), "0") && StrUtil.equals(jsonPointAfter.getString("SSX02A2"), "0")) {
// 5.2如果都是空位 则判断是否有正在进行的任务
map.put("flag", "2");
map.put("start_point_code", "('SSX02A1','SSX02A2')");
// 查找起点是否有任务
JSONArray is_stara2 = WQL.getWO("AUTO_QUERYTASK").addParamMap(map).process().getResultJSONArray(0);
// 查询终点是否有任务
map.put("flag", "3");
map.put("end_point_code", "('SSX02A1','SSX02A2')");
JSONArray is_end2 = WQL.getWO("AUTO_QUERYTASK").addParamMap(map).process().getResultJSONArray(0);
if (ObjectUtil.isEmpty(is_stara2) && ObjectUtil.isEmpty(is_end2)) {
// 5.3.更新任务终点点位
jsonTask.put("next_point_code", "SSX02A1");
taskTab.update(jsonTask);
// 5.4.下发ACS
JSONObject jsonResultAcs = pointTaskBean.renotifyAcs(jsonTask.getString("task_id"));
if (StrUtil.equals(jsonResultAcs.getString("status"), "200")) {
// 4.5.下发成功、更新任务状态
jsonTask.put("task_status", "05");
taskTab.update(jsonTask);
}
}
}
}
}
}
}
}

View File

@@ -215,11 +215,11 @@ public class RegionioInServiceImpl implements RegionioInService {
if (ObjectUtil.isEmpty(jsonOrder)) throw new BadRequestException("此设备未在生产中或不存在");
form.put("vehicle_type", jsonOrder.getString("vehicle_type"));
SendMaterialTask sendMaterialTask = new SendMaterialTask();
String task_id = sendMaterialTask.createTask(form);
// SendMaterialTask sendMaterialTask = new SendMaterialTask();
// String task_id = sendMaterialTask.createTask(form);
JSONObject json = new JSONObject();
json.put("task_id", task_id);
// json.put("task_id", task_id);
json.put("update_optid", SecurityUtils.getCurrentUserId());
json.put("update_optname", SecurityUtils.getCurrentNickName());
json.put("update_time", DateUtil.now());

View File

@@ -197,11 +197,11 @@ public class RegionioOutServiceImpl implements RegionioOutService {
form.put("create_mode", jsonIn.getString("create_mode"));
form.put("pcsn", jsonIn.getString("pcsn"));
form.put("iostorinv_id", iostorinv_id);
CallMaterialTask callMaterialTask = new CallMaterialTask();
String task_id = callMaterialTask.createTask(form);
/* CallMaterialTask callMaterialTask = new CallMaterialTask();
String task_id = callMaterialTask.createTask(form);*/
JSONObject json = new JSONObject();
json.put("task_id", task_id);
// json.put("task_id", task_id);
json.put("update_optid", SecurityUtils.getCurrentUserId());
json.put("update_optname", SecurityUtils.getCurrentNickName());
json.put("update_time", DateUtil.now());

View File

@@ -183,15 +183,15 @@ public class InEmptyvehiclerecordServiceImpl implements InEmptyvehiclerecordServ
param.put("qty", jsonEmp.getString("vehicle_qty"));
param.put("record_uuid", jsonEmp.getString("record_uuid"));
String task_id = new SendEmpVehicleTask().createTask(param);
// String task_id = new SendEmpVehicleTask().createTask(param);
// 更新空载具表中的任务id和单据状态
PointService pointDto = SpringContextHolder.getBean(PointService.class);
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
// JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
jsonEmp.put("task_uuid", Long.valueOf(task_id));
// jsonEmp.put("task_uuid", Long.valueOf(task_id));
jsonEmp.put("bill_status","20");
jsonEmp.put("next_point_code",jsonTask.getString("next_point_code"));
jsonEmp.put("end_region_id",pointDto.findByCode(jsonTask.getString("next_point_code")).getRegion_id());
// jsonEmp.put("next_point_code",jsonTask.getString("next_point_code"));
// jsonEmp.put("end_region_id",pointDto.findByCode(jsonTask.getString("next_point_code")).getRegion_id());
jsonEmp.put("update_optid", SecurityUtils.getCurrentUserId());
jsonEmp.put("update_optname", SecurityUtils.getCurrentNickName());
jsonEmp.put("update_time", DateUtil.now());

View File

@@ -183,15 +183,15 @@ public class OutEmptyvehiclerecordServiceImpl implements OutEmptyvehiclerecordSe
param.put("qty", jsonEmp.getString("vehicle_qty"));
param.put("record_uuid", jsonEmp.getString("record_uuid"));
String task_id = new CallEmpVehicleTask().createTask(param);
// String task_id = new CallEmpVehicleTask().createTask(param);
// 更新空载具表中的任务id和单据状态
PointService pointDto = SpringContextHolder.getBean(PointService.class);
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
// JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
jsonEmp.put("task_uuid", Long.valueOf(task_id));
// jsonEmp.put("task_uuid", Long.valueOf(task_id));
jsonEmp.put("bill_status","20");
jsonEmp.put("start_point_code",jsonTask.getString("start_point_code"));
jsonEmp.put("start_region_id",pointDto.findByCode(jsonTask.getString("start_point_code")).getRegion_id());
// jsonEmp.put("start_point_code",jsonTask.getString("start_point_code"));
// jsonEmp.put("start_region_id",pointDto.findByCode(jsonTask.getString("start_point_code")).getRegion_id());
jsonEmp.put("update_optid", SecurityUtils.getCurrentUserId());
jsonEmp.put("update_optname", SecurityUtils.getCurrentNickName());
jsonEmp.put("update_time", DateUtil.now());