张江玮
2 years ago
17 changed files with 1557 additions and 66 deletions
@ -0,0 +1,20 @@ |
|||
package org.nl.wms.md.pb; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
|
|||
/** |
|||
* @author 张江玮 |
|||
* @date 2022/11/04 20:12 |
|||
*/ |
|||
@AllArgsConstructor |
|||
@Getter |
|||
public enum VehicleStatus { |
|||
|
|||
EMPTY("1", "空载具"), |
|||
HAS_MATERIAL("2", "有物料"); |
|||
|
|||
private final String code; |
|||
|
|||
private final String name; |
|||
} |
@ -0,0 +1,91 @@ |
|||
package org.nl.wms.pda.rest; |
|||
|
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.modules.logging.annotation.Log; |
|||
import org.nl.wms.pda.service.PdaService; |
|||
import org.springframework.http.HttpStatus; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
/** |
|||
* @author 张江玮 |
|||
* @date 2022/11/04 18:16 |
|||
*/ |
|||
@RestController |
|||
@RequiredArgsConstructor |
|||
@Api(tags = "手持接口") |
|||
@RequestMapping("/api/pda") |
|||
@Slf4j |
|||
public class PdaController { |
|||
|
|||
private final PdaService pdaService; |
|||
|
|||
@PostMapping("/region") |
|||
@Log("查询所有区域") |
|||
@ApiOperation("查询所有区域") |
|||
public ResponseEntity<JSONArray> region() { |
|||
return new ResponseEntity<>(pdaService.region(), HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping("/point") |
|||
@Log("根据区域查询点位") |
|||
@ApiOperation("根据区域查询点位") |
|||
public ResponseEntity<JSONArray> point(@RequestBody JSONObject param) { |
|||
return new ResponseEntity<>(pdaService.point(param.getString("region_id")), HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping("/vmByPoint") |
|||
@Log("查询点位上的载具及组盘信息") |
|||
@ApiOperation("查询点位上的载具及组盘信息") |
|||
public ResponseEntity<JSONObject> vmByPoint(@RequestBody JSONObject param) { |
|||
return new ResponseEntity<>(pdaService.vmByPoint(param.getString("point_id")), HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping("/bindPoint") |
|||
@Log("点位载具绑定") |
|||
@ApiOperation("点位载具绑定") |
|||
public ResponseEntity<JSONObject> bindPoint(@RequestBody JSONObject param) { |
|||
pdaService.bindPoint(param.getString("point_id"), param.getString("vehicle_code")); |
|||
|
|||
return this.success(); |
|||
} |
|||
|
|||
@PostMapping("/vm") |
|||
@Log("组盘") |
|||
@ApiOperation("组盘") |
|||
public ResponseEntity<JSONObject> vm(@RequestBody JSONObject param) { |
|||
pdaService.vm(param.getString("vehicle_code"), param.getJSONArray("material")); |
|||
|
|||
return this.success(); |
|||
} |
|||
|
|||
@PostMapping("/vmByVehicle") |
|||
@Log("查询载具及组盘信息") |
|||
@ApiOperation("查询载具及组盘信息") |
|||
public ResponseEntity<JSONObject> vmByVehicle(@RequestBody JSONObject param) { |
|||
return new ResponseEntity<>(pdaService.vmByVehicle(param.getString("vehicle_code")), HttpStatus.OK); |
|||
} |
|||
|
|||
@PostMapping("/outbound") |
|||
@Log("确认出库") |
|||
@ApiOperation("确认出库") |
|||
public ResponseEntity<JSONObject> outbound(@RequestBody JSONObject param) { |
|||
pdaService.outbound(param.getString("vehicle_code"), param.getJSONArray("vm")); |
|||
|
|||
return this.success(); |
|||
} |
|||
|
|||
private ResponseEntity<JSONObject> success() { |
|||
JSONObject result = new JSONObject(); |
|||
result.put("message", "操作成功"); |
|||
return new ResponseEntity<>(result, HttpStatus.OK); |
|||
} |
|||
} |
@ -0,0 +1,25 @@ |
|||
package org.nl.wms.pda.service; |
|||
|
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
|
|||
/** |
|||
* @author 张江玮 |
|||
* @date 2022/11/04 18:25 |
|||
*/ |
|||
public interface PdaService { |
|||
|
|||
JSONArray region(); |
|||
|
|||
JSONArray point(String regionId); |
|||
|
|||
JSONObject vmByPoint(String pointId); |
|||
|
|||
void bindPoint(String pointId, String vehicleCode); |
|||
|
|||
void vm(String vehicleCode, JSONArray materials); |
|||
|
|||
JSONObject vmByVehicle(String vehicleCode); |
|||
|
|||
void outbound(String vehicleCode, JSONArray materials); |
|||
} |
@ -0,0 +1,237 @@ |
|||
package org.nl.wms.pda.service.impl; |
|||
|
|||
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; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.modules.common.exception.BadRequestException; |
|||
import org.nl.modules.wql.WQL; |
|||
import org.nl.modules.wql.core.bean.WQLObject; |
|||
import org.nl.wms.md.pb.VehicleStatus; |
|||
import org.nl.wms.pda.service.PdaService; |
|||
import org.nl.wms.sch.base.point.LockType; |
|||
import org.nl.wms.sch.base.point.PointStatus; |
|||
import org.nl.wms.sch.base.point.PointType; |
|||
import org.nl.wms.util.CommonUtils; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
/** |
|||
* @author 张江玮 |
|||
* @date 2022/11/04 18:25 |
|||
*/ |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
@Slf4j |
|||
public class PdaServiceImpl implements PdaService { |
|||
|
|||
|
|||
@Override |
|||
public JSONArray region() { |
|||
return WQL.getWO("PDA").addParam("flag", "1").process().getResultJSONArray(0); |
|||
} |
|||
|
|||
@Override |
|||
public JSONArray point(String regionId) { |
|||
JSONArray points = WQL |
|||
.getWO("PDA") |
|||
.addParam("flag", "2") |
|||
.addParam("region_id", regionId) |
|||
.process() |
|||
.getResultJSONArray(0); |
|||
for (Object o : points) { |
|||
JSONObject point = (JSONObject) o; |
|||
if (StrUtil.equals(point.getString("lock_type"), LockType.TASK_LOCKED.getCode())) { |
|||
point.put("status", "3"); |
|||
} |
|||
} |
|||
|
|||
return points; |
|||
} |
|||
|
|||
@Override |
|||
public JSONObject vmByPoint(String pointId) { |
|||
JSONObject result = new JSONObject(); |
|||
|
|||
JSONObject point = WQLObject |
|||
.getWQLObject("sch_base_point") |
|||
.query("point_id = " + pointId) |
|||
.uniqueResult(0); |
|||
|
|||
if (StrUtil.equals(point.getString("point_status"), PointStatus.HAS_VEHICLE.getCode())) { |
|||
String vehicleCode = point.getString("vehicle_code"); |
|||
result.put("vehicle_code", vehicleCode); |
|||
|
|||
JSONArray detail = WQL |
|||
.getWO("PDA") |
|||
.addParam("flag", "3") |
|||
.addParam("vehicle_code", vehicleCode) |
|||
.process() |
|||
.getResultJSONArray(0); |
|||
result.put("detail", detail); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public void bindPoint(String pointId, String vehicleCode) { |
|||
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point"); |
|||
JSONObject point = pointTable |
|||
.query("point_id = " + pointId) |
|||
.uniqueResult(0); |
|||
if (StrUtil.equals(point.getString("lock_type"), LockType.TASK_LOCKED.getCode())) { |
|||
throw new BadRequestException("该点位存在任务"); |
|||
} |
|||
|
|||
WQLObject ivtTable = WQLObject.getWQLObject("st_ivt_structivt"); |
|||
if (StrUtil.isNotEmpty(vehicleCode)) { |
|||
JSONObject vehicle = WQLObject.getWQLObject("md_pb_vehicle").query("vehicle_code = " + vehicleCode).uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(vehicle)) { |
|||
throw new BadRequestException("该载具号不存在,请从组盘功能添加"); |
|||
} |
|||
|
|||
JSONObject existPoint = pointTable.query("vehicle_code = " + vehicleCode).uniqueResult(0); |
|||
if (ObjectUtil.isNotEmpty(existPoint) && !StrUtil.equals(pointId, existPoint.getString("point_id"))) { |
|||
throw new BadRequestException("该载具号存放于" + existPoint.getString("point_name")); |
|||
} |
|||
|
|||
if (StrUtil.equals(vehicle.getString("vehicle_status"), VehicleStatus.HAS_MATERIAL.getCode()) |
|||
&& StrUtil.equals(point.getString("point_type"), PointType.STORAGE_LOCATION.getCode())) { |
|||
JSONObject vm = WQLObject |
|||
.getWQLObject("st_ivt_vehicle_material") |
|||
.query("vehicle_id = " + vehicle.getString("vehicle_id"), "create_time ASC") |
|||
.uniqueResult(0); |
|||
|
|||
JSONObject ivt = new JSONObject(); |
|||
ivt.put("stockrecord_id", IdUtil.getSnowflake(1L, 1L).nextId()); |
|||
ivt.put("point_id", pointId); |
|||
ivt.put("instorage_time", vm.getString("create_time")); |
|||
|
|||
ivtTable.insert(ivt); |
|||
} |
|||
|
|||
point.put("point_status", PointStatus.HAS_VEHICLE.getCode()); |
|||
point.put("vehicle_code", vehicleCode); |
|||
} else { |
|||
ivtTable.delete("point_id = " + pointId); |
|||
|
|||
point.put("point_status", PointStatus.EMPTY.getCode()); |
|||
point.put("vehicle_code", ""); |
|||
} |
|||
|
|||
|
|||
CommonUtils.addUpdateColum(point); |
|||
pointTable.update(point); |
|||
} |
|||
|
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public void vm(String vehicleCode, JSONArray materials) { |
|||
WQLObject vehicleTable = WQLObject.getWQLObject("md_pb_vehicle"); |
|||
JSONObject vehicle = vehicleTable.query("vehicle_code = " + vehicleCode).uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(vehicle)) { |
|||
vehicle = new JSONObject(); |
|||
vehicle.put("vehicle_id", IdUtil.getSnowflake(1L, 1L).nextId()); |
|||
vehicle.put("vehicle_code", vehicleCode); |
|||
vehicle.put("vehicle_status", VehicleStatus.EMPTY.getCode()); |
|||
CommonUtils.addCommonColum(vehicle); |
|||
vehicleTable.insert(vehicle); |
|||
} |
|||
String vehicleId = vehicle.getString("vehicle_id"); |
|||
|
|||
if (ObjectUtil.isNotEmpty(materials)) { |
|||
WQLObject materialTable = WQLObject.getWQLObject("md_me_materialbase"); |
|||
WQLObject vmTable = WQLObject.getWQLObject("st_ivt_vehicle_material"); |
|||
for (Object o : materials) { |
|||
String code = ((JSONObject) o).getString("code"); |
|||
Double qty = ((JSONObject) o).getDouble("qty"); |
|||
|
|||
String materialCode = code.substring(0, 8); |
|||
String materialBatch = code.substring(8, 18); |
|||
|
|||
JSONObject material = materialTable |
|||
.query("material_code = " + materialCode) |
|||
.uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(material)) { |
|||
throw new BadRequestException("条码为" + code + "的物料信息不存在,请从后台管理界面添加"); |
|||
} |
|||
|
|||
JSONObject vm = new JSONObject(); |
|||
vm.put("vm_id", IdUtil.getSnowflake(1L, 1L).nextId()); |
|||
vm.put("vehicle_id", vehicleId); |
|||
vm.put("material_id", material.getString("material_id")); |
|||
vm.put("material_qty", qty); |
|||
vm.put("material_batch", materialBatch); |
|||
CommonUtils.addCreateColum(vm); |
|||
vmTable.insert(vm); |
|||
} |
|||
|
|||
vehicle.put("vehicle_status", VehicleStatus.HAS_MATERIAL.getCode()); |
|||
CommonUtils.addUpdateColum(vehicle); |
|||
vehicleTable.update(vehicle); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public JSONObject vmByVehicle(String vehicleCode) { |
|||
JSONObject result = new JSONObject(); |
|||
JSONArray detail = WQL |
|||
.getWO("PDA") |
|||
.addParam("flag", "3") |
|||
.addParam("vehicle_code", vehicleCode) |
|||
.process() |
|||
.getResultJSONArray(0); |
|||
result.put("detail", detail); |
|||
|
|||
return result; |
|||
} |
|||
|
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public void outbound(String vehicleCode, JSONArray materials) { |
|||
WQLObject vehicleTable = WQLObject.getWQLObject("md_pb_vehicle"); |
|||
JSONObject vehicle = vehicleTable.query("vehicle_code = " + vehicleCode).uniqueResult(0); |
|||
String vehicleId = vehicle.getString("vehicle_id"); |
|||
|
|||
WQLObject vmTable = WQLObject.getWQLObject("st_ivt_vehicle_material"); |
|||
JSONObject oldVm = vmTable.query("vehicle_id = " + vehicleId, "create_time ASC").uniqueResult(0); |
|||
vmTable.delete("vehicle_id = " + vehicleId); |
|||
|
|||
if (ObjectUtil.isNotEmpty(materials)) { |
|||
WQLObject materialTable = WQLObject.getWQLObject("md_me_materialbase"); |
|||
for (Object o : materials) { |
|||
JSONObject material = (JSONObject) o; |
|||
String materialCode = material.getString("material_code"); |
|||
String materialQty = material.getString("material_qty"); |
|||
String materialBatch = material.getString("batch"); |
|||
|
|||
String materialId = materialTable |
|||
.query("material_code = " + materialCode) |
|||
.uniqueResult(0) |
|||
.getString("material_id"); |
|||
|
|||
JSONObject vm = new JSONObject(); |
|||
vm.put("vm_id", IdUtil.getSnowflake(1L, 1L).nextId()); |
|||
vm.put("vehicle_id", vehicleId); |
|||
vm.put("material_id", materialId); |
|||
vm.put("material_qty", materialQty); |
|||
vm.put("material_batch", materialBatch); |
|||
CommonUtils.addCreateColum(vm); |
|||
vm.put("create_time", oldVm.getString("create_time")); |
|||
vmTable.insert(vm); |
|||
} |
|||
|
|||
vehicle.put("vehicle_status", VehicleStatus.HAS_MATERIAL.getCode()); |
|||
} else { |
|||
vehicle.put("vehicle_status", VehicleStatus.EMPTY.getCode()); |
|||
} |
|||
|
|||
CommonUtils.addUpdateColum(vehicle); |
|||
vehicleTable.update(vehicle); |
|||
} |
|||
} |
@ -0,0 +1,82 @@ |
|||
[交易说明] |
|||
交易名: 任务分页查询 |
|||
所属模块: |
|||
功能简述: |
|||
版权所有: |
|||
表引用: |
|||
版本经历: |
|||
|
|||
[数据库] |
|||
--指定数据库,为空采用默认值,默认为db.properties中列出的第一个库 |
|||
|
|||
[IO定义] |
|||
################################################# |
|||
## 表字段对应输入参数 |
|||
################################################# |
|||
输入.flag TYPEAS s_string |
|||
输入.region_id TYPEAS s_string |
|||
输入.vehicle_code TYPEAS s_string |
|||
|
|||
[临时表] |
|||
--这边列出来的临时表就会在运行期动态创建 |
|||
|
|||
[临时变量] |
|||
--所有中间过程变量均可在此处定义 |
|||
|
|||
[业务过程] |
|||
|
|||
########################################## |
|||
# 1、输入输出检查 # |
|||
########################################## |
|||
|
|||
|
|||
########################################## |
|||
# 2、主过程前处理 # |
|||
########################################## |
|||
|
|||
|
|||
########################################## |
|||
# 3、业务主过程 # |
|||
########################################## |
|||
|
|||
IF 输入.flag = "1" |
|||
QUERY |
|||
SELECT |
|||
region_id, |
|||
region_name |
|||
FROM |
|||
sch_base_region |
|||
ENDSELECT |
|||
ENDQUERY |
|||
ENDIF |
|||
|
|||
IF 输入.flag = "2" |
|||
QUERY |
|||
SELECT |
|||
point_id, |
|||
point_name, |
|||
point_status AS `status`, |
|||
lock_type |
|||
FROM |
|||
sch_base_point |
|||
WHERE |
|||
region_id = 输入.region_id |
|||
ENDQUERY |
|||
ENDIF |
|||
|
|||
IF 输入.flag = "3" |
|||
QUERY |
|||
SELECT |
|||
material.material_code, |
|||
material.material_name, |
|||
vm.material_qty, |
|||
vm.material_batch AS batch |
|||
FROM |
|||
st_ivt_vehicle_material vm |
|||
LEFT JOIN md_pb_vehicle vehicle ON vm.vehicle_id = vehicle.vehicle_id |
|||
LEFT JOIN md_me_materialbase material ON vm.material_id = material.material_id |
|||
WHERE |
|||
vehicle.vehicle_code = 输入.vehicle_code |
|||
ENDSELECT |
|||
ENDQUERY |
|||
ENDIF |
@ -0,0 +1,20 @@ |
|||
package org.nl.wms.sch.base.point; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
|
|||
/** |
|||
* @author 张江玮 |
|||
* @date 2022/11/07 8:49 |
|||
*/ |
|||
@AllArgsConstructor |
|||
@Getter |
|||
public enum PointType { |
|||
|
|||
POINT("1", "点位"), |
|||
STORAGE_LOCATION("2", "库位"); |
|||
|
|||
private final String code; |
|||
|
|||
private final String name; |
|||
} |
@ -0,0 +1,208 @@ |
|||
package org.nl.wms.sch.task; |
|||
|
|||
import cn.hutool.core.util.IdUtil; |
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import cn.hutool.core.util.StrUtil; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.modules.common.exception.BadRequestException; |
|||
import org.nl.modules.system.util.CodeUtil; |
|||
import org.nl.modules.wql.core.bean.WQLObject; |
|||
import org.nl.wms.sch.base.point.LockType; |
|||
import org.nl.wms.sch.base.point.PointStatus; |
|||
import org.nl.wms.sch.base.point.PointType; |
|||
import org.nl.wms.sch.manage.AbstractAcsTask; |
|||
import org.nl.wms.sch.task.dto.AcsTaskDTO; |
|||
import org.nl.wms.sch.task.util.TaskUtils; |
|||
import org.nl.wms.util.CommonUtils; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 纽迪希亚3呼叫原料出库任务 |
|||
* |
|||
* @author 张江玮 |
|||
* @date 2022/11/07 20:03 |
|||
*/ |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
@Slf4j |
|||
public class CallMaterialTask extends AbstractAcsTask { |
|||
|
|||
private static final String THIS_CLASS_NAME = CallMaterialTask.class.getName(); |
|||
|
|||
/** |
|||
* 添加任务进行下发 |
|||
* |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public List<AcsTaskDTO> addTask() { |
|||
return TaskUtils.addTask(THIS_CLASS_NAME); |
|||
} |
|||
|
|||
/** |
|||
* @param taskJSON 代表一条任务对象 |
|||
* @param status 代表wcs任务完成状态: //0:acs,取消,:执行中,2:完成
|
|||
* @return |
|||
* @discription wcs请求wms任务完成状态反馈接口, 比如agv从a点往b点走。生成任务的时候绑定b的物料信息,任务完成的时候,清除a的物料信息 |
|||
* @author ldjun |
|||
* @created 2019年4月17日 下午8:51:50 |
|||
*/ |
|||
@Override |
|||
public void updateTaskStatus(JSONObject taskJSON, String status) { |
|||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task"); |
|||
String taskCode = taskJSON.getString("task_code"); |
|||
JSONObject task = taskTable |
|||
.query("task_code = " + taskCode) |
|||
.uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(task)) { |
|||
throw new BadRequestException("未找到任务号为" + taskCode + "的任务"); |
|||
} |
|||
|
|||
if (StrUtil.equals(status, "0")) { |
|||
this.cancel(task.getString("task_id")); |
|||
} |
|||
|
|||
if (StrUtil.equals(status, TaskStatus.EXECUTING.getCode())) { |
|||
task.put("task", TaskStatus.EXECUTING.getCode()); |
|||
CommonUtils.addAdminUpdateColum(task); |
|||
taskTable.update(task); |
|||
} |
|||
|
|||
if (StrUtil.equals(status, TaskStatus.FINISHED.getCode())) { |
|||
this.finishTask(task, TaskFinishedType.AUTO); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @param param 创建任务需要的参数 |
|||
* @return 返回任务标识 |
|||
*/ |
|||
@Override |
|||
public String createTask(JSONObject param) { |
|||
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point"); |
|||
JSONObject nextPoint = pointTable |
|||
.query("point_id = " + param.getString("point_id")) |
|||
.uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(nextPoint)) { |
|||
throw new BadRequestException("终点不存在"); |
|||
} |
|||
|
|||
JSONObject startPoint = pointTable |
|||
.query("vehicle_code = " + param.getString("vehicle_code")) |
|||
.uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(startPoint)) { |
|||
throw new BadRequestException("指定的料车点位不存在"); |
|||
} |
|||
|
|||
JSONObject task = new JSONObject(); |
|||
String taskId = IdUtil.getSnowflake(1L, 1L).nextIdStr(); |
|||
task.put("task_id", taskId); |
|||
task.put("task_code", CodeUtil.getNewCode("TASK_CODE")); |
|||
task.put("task_type", TaskType.CALL_MATERIAL.getCode()); |
|||
task.put("task_status", TaskStatus.START_AND_END.getCode()); |
|||
task.put("point_code1", startPoint.getString("point_code")); |
|||
task.put("point_code2", nextPoint.getString("point_code")); |
|||
task.put("vehicle_code", startPoint.getString("vehicle_code")); |
|||
task.put("handle_class", THIS_CLASS_NAME); |
|||
task.put("create_mode", CreateMode.SCCJ.getCode()); |
|||
CommonUtils.addCommonColum(task); |
|||
WQLObject.getWQLObject("sch_base_task").insert(task); |
|||
|
|||
startPoint.put("lock_type", LockType.TASK_LOCKED.getCode()); |
|||
CommonUtils.addUpdateColum(startPoint); |
|||
pointTable.update(startPoint); |
|||
|
|||
nextPoint.put("lock_type", LockType.TASK_LOCKED.getCode()); |
|||
CommonUtils.addUpdateColum(nextPoint); |
|||
pointTable.update(nextPoint); |
|||
|
|||
return taskId; |
|||
} |
|||
|
|||
/** |
|||
* @param taskId 任务标识 |
|||
* @return |
|||
* @discription 强制结束完成任务 |
|||
* @author ldjun |
|||
* @created 2020年6月19日 上午10:34:58 |
|||
*/ |
|||
@Override |
|||
public void forceFinish(String taskId) { |
|||
JSONObject task = WQLObject |
|||
.getWQLObject("sch_base_task") |
|||
.query("task_id = " + taskId) |
|||
.uniqueResult(0); |
|||
this.finishTask(task, TaskFinishedType.MANUAL); |
|||
} |
|||
|
|||
/** |
|||
* 取消任务,货物搬回原点 |
|||
* |
|||
* @param taskId |
|||
*/ |
|||
@Override |
|||
public void cancel(String taskId) { |
|||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task"); |
|||
JSONObject task = taskTable |
|||
.query("task_id = " + taskId) |
|||
.uniqueResult(0); |
|||
taskTable.delete(task); |
|||
|
|||
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point"); |
|||
JSONObject startPoint = pointTable |
|||
.query("task_code = " + task.getString("point_code1")) |
|||
.uniqueResult(0); |
|||
JSONObject nextPoint = pointTable |
|||
.query("task_code = " + task.getString("point_code2")) |
|||
.uniqueResult(0); |
|||
|
|||
startPoint.put("lock_type", LockType.UNLOCKED.getCode()); |
|||
CommonUtils.addAdminUpdateColum(startPoint); |
|||
pointTable.update(startPoint); |
|||
nextPoint.put("lock_type", LockType.UNLOCKED.getCode()); |
|||
CommonUtils.addAdminUpdateColum(nextPoint); |
|||
pointTable.update(nextPoint); |
|||
} |
|||
|
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void finishTask(JSONObject task, TaskFinishedType taskFinishedType) { |
|||
task.put("finished_type", taskFinishedType.getCode()); |
|||
task.put("task_status", TaskStatus.FINISHED.getCode()); |
|||
CommonUtils.addAdminUpdateColum(task); |
|||
WQLObject.getWQLObject("sch_base_task").update(task); |
|||
|
|||
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point"); |
|||
JSONObject startPoint = pointTable |
|||
.query("task_code = " + task.getString("point_code1")) |
|||
.uniqueResult(0); |
|||
JSONObject nextPoint = pointTable |
|||
.query("task_code = " + task.getString("point_code2")) |
|||
.uniqueResult(0); |
|||
|
|||
if (StrUtil.equals(startPoint.getString("point_type"), PointType.STORAGE_LOCATION.getCode())) { |
|||
JSONObject vehicle = WQLObject |
|||
.getWQLObject("md_pb_vehicle") |
|||
.query("vehicle_code = " + startPoint.getString("vehicle_code")) |
|||
.uniqueResult(0); |
|||
|
|||
WQLObject.getWQLObject("st_ivt_structivt").delete("vehicle_id = " + vehicle.getString("vehicle_id")); |
|||
} |
|||
|
|||
nextPoint.put("point_status", PointStatus.HAS_VEHICLE.getCode()); |
|||
nextPoint.put("lock_type", LockType.UNLOCKED.getCode()); |
|||
nextPoint.put("vehicle_code", startPoint.getString("vehicle_code")); |
|||
CommonUtils.addAdminUpdateColum(nextPoint); |
|||
pointTable.update(nextPoint); |
|||
|
|||
startPoint.put("point_status", PointStatus.EMPTY.getCode()); |
|||
startPoint.put("lock_type", LockType.UNLOCKED.getCode()); |
|||
startPoint.put("vehicle_code", ""); |
|||
CommonUtils.addAdminUpdateColum(startPoint); |
|||
pointTable.update(startPoint); |
|||
} |
|||
} |
@ -0,0 +1,248 @@ |
|||
package org.nl.wms.sch.task; |
|||
|
|||
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; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.modules.common.exception.BadRequestException; |
|||
import org.nl.modules.system.util.CodeUtil; |
|||
import org.nl.modules.wql.WQL; |
|||
import org.nl.modules.wql.core.bean.WQLObject; |
|||
import org.nl.wms.sch.base.point.LockType; |
|||
import org.nl.wms.sch.base.point.PointStatus; |
|||
import org.nl.wms.sch.base.point.PointType; |
|||
import org.nl.wms.sch.manage.AbstractAcsTask; |
|||
import org.nl.wms.sch.task.dto.AcsTaskDTO; |
|||
import org.nl.wms.sch.task.util.TaskUtils; |
|||
import org.nl.wms.util.CommonUtils; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 纽迪希亚3送满料车任务 |
|||
* |
|||
* @author 张江玮 |
|||
* @date 2022/11/07 8:59 |
|||
*/ |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
@Slf4j |
|||
public class SendFullVehicleTask extends AbstractAcsTask { |
|||
|
|||
private static final String THIS_CLASS_NAME = SendFullVehicleTask.class.getName(); |
|||
|
|||
/** |
|||
* 添加任务进行下发 |
|||
* |
|||
* @return 所有这个类处理的已确认起点和终点任务 |
|||
*/ |
|||
@Override |
|||
public List<AcsTaskDTO> addTask() { |
|||
return TaskUtils.addTask(THIS_CLASS_NAME); |
|||
} |
|||
|
|||
/** |
|||
* @param taskJSON 代表一条任务对象 |
|||
* @param status 代表wcs任务完成状态: //0:acs,取消,:执行中,2:完成
|
|||
* @discription wcs请求wms任务完成状态反馈接口, 比如agv从a点往b点走。生成任务的时候绑定b的物料信息,任务完成的时候,清除a的物料信息 |
|||
* @author ldjun |
|||
* @created 2019年4月17日 下午8:51:50 |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public void updateTaskStatus(JSONObject taskJSON, String status) { |
|||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task"); |
|||
String taskCode = taskJSON.getString("task_code"); |
|||
JSONObject task = taskTable |
|||
.query("task_code = " + taskCode) |
|||
.uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(task)) { |
|||
throw new BadRequestException("未找到任务号为" + taskCode + "的任务"); |
|||
} |
|||
|
|||
if (StrUtil.equals(status, "0")) { |
|||
this.cancel(task.getString("task_id")); |
|||
} |
|||
|
|||
if (StrUtil.equals(status, TaskStatus.EXECUTING.getCode())) { |
|||
task.put("task", TaskStatus.EXECUTING.getCode()); |
|||
CommonUtils.addAdminUpdateColum(task); |
|||
taskTable.update(task); |
|||
} |
|||
|
|||
if (StrUtil.equals(status, TaskStatus.FINISHED.getCode())) { |
|||
this.finishTask(task, TaskFinishedType.AUTO); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @param param 创建任务需要的参数 |
|||
* |
|||
* @return 返回任务标识 |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public String createTask(JSONObject param) { |
|||
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point"); |
|||
JSONObject point = pointTable |
|||
.query("point_id = " + param.getString("point_id")) |
|||
.uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(point)) { |
|||
throw new BadRequestException("点位不存在"); |
|||
} |
|||
|
|||
JSONObject task = new JSONObject(); |
|||
String taskId = IdUtil.getSnowflake(1L, 1L).nextIdStr(); |
|||
task.put("task_id", taskId); |
|||
task.put("task_code", CodeUtil.getNewCode("TASK_CODE")); |
|||
task.put("task_type", TaskType.SEND_FULL_VEHICLE.getCode()); |
|||
task.put("task_status", TaskStatus.SURE_START.getCode()); |
|||
task.put("point_code1", point.getString("point_code")); |
|||
task.put("vehicle_code", point.getString("vehicle_code")); |
|||
task.put("handle_class", THIS_CLASS_NAME); |
|||
task.put("create_mode", CreateMode.SCCJ.getCode()); |
|||
CommonUtils.addCommonColum(task); |
|||
WQLObject.getWQLObject("sch_base_task").insert(task); |
|||
|
|||
point.put("lock_type", LockType.TASK_LOCKED.getCode()); |
|||
CommonUtils.addUpdateColum(point); |
|||
pointTable.update(point); |
|||
|
|||
return taskId; |
|||
} |
|||
|
|||
/** |
|||
* @param taskId 任务标识 |
|||
* @discription 强制结束完成任务 |
|||
* @author ldjun |
|||
* @created 2020年6月19日 上午10:34:58 |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public void forceFinish(String taskId) { |
|||
JSONObject task = WQLObject |
|||
.getWQLObject("sch_base_task") |
|||
.query("task_id = " + taskId) |
|||
.uniqueResult(0); |
|||
this.finishTask(task, TaskFinishedType.MANUAL); |
|||
} |
|||
|
|||
/** |
|||
* 取消任务,货物搬回原点 |
|||
* |
|||
* @param taskId 任务标识 |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public void cancel(String taskId) { |
|||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task"); |
|||
JSONObject task = taskTable |
|||
.query("task_id = " + taskId) |
|||
.uniqueResult(0); |
|||
taskTable.delete(task); |
|||
|
|||
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point"); |
|||
JSONObject startPoint = pointTable |
|||
.query("task_code = " + task.getString("point_code1")) |
|||
.uniqueResult(0); |
|||
JSONObject nextPoint = pointTable |
|||
.query("task_code = " + task.getString("point_code2")) |
|||
.uniqueResult(0); |
|||
|
|||
startPoint.put("lock_type", LockType.UNLOCKED.getCode()); |
|||
CommonUtils.addAdminUpdateColum(startPoint); |
|||
pointTable.update(startPoint); |
|||
nextPoint.put("lock_type", LockType.UNLOCKED.getCode()); |
|||
CommonUtils.addAdminUpdateColum(nextPoint); |
|||
pointTable.update(nextPoint); |
|||
} |
|||
|
|||
/** |
|||
* @return |
|||
* @discription 确定下一点位 |
|||
* @author ldjun |
|||
* @created 2020年6月12日 下午6:01:06 |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public void findNextPoint() { |
|||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task"); |
|||
JSONArray tasks = taskTable |
|||
.query("task_status = " + TaskStatus.SURE_START.getCode() + " AND handle_class = " + THIS_CLASS_NAME) |
|||
.getResultJSONArray(0); |
|||
|
|||
for (Object o : tasks) { |
|||
JSONObject point = WQL.getWO("TASK") |
|||
.addParam("flag", "2") |
|||
.process() |
|||
.uniqueResult(0); |
|||
|
|||
if (ObjectUtil.isNotEmpty(point)) { |
|||
JSONObject task = (JSONObject) o; |
|||
|
|||
task.put("task_status", TaskStatus.START_AND_END.getCode()); |
|||
task.put("point_code2", point.getString("point_code")); |
|||
CommonUtils.addAdminUpdateColum(task); |
|||
taskTable.update(task); |
|||
|
|||
JSONObject lockPoint = new JSONObject(); |
|||
lockPoint.put("lock_type", LockType.TASK_LOCKED.getCode()); |
|||
CommonUtils.addAdminUpdateColum(lockPoint); |
|||
WQLObject.getWQLObject("sch_base_point").update(lockPoint, "point_id = " + point.getString("point_id")); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void finishTask(JSONObject task, TaskFinishedType taskFinishedType) { |
|||
task.put("finished_type", taskFinishedType.getCode()); |
|||
task.put("task_status", TaskStatus.FINISHED.getCode()); |
|||
CommonUtils.addAdminUpdateColum(task); |
|||
WQLObject.getWQLObject("sch_base_task").update(task); |
|||
|
|||
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point"); |
|||
JSONObject startPoint = pointTable |
|||
.query("task_code = " + task.getString("point_code1")) |
|||
.uniqueResult(0); |
|||
JSONObject nextPoint = pointTable |
|||
.query("task_code = " + task.getString("point_code2")) |
|||
.uniqueResult(0); |
|||
|
|||
|
|||
if (StrUtil.equals(nextPoint.getString("point_type"), PointType.STORAGE_LOCATION.getCode())) { |
|||
JSONObject vehicle = WQLObject |
|||
.getWQLObject("md_pb_vehicle") |
|||
.query("vehicle_code = " + startPoint.getString("vehicle_code")) |
|||
.uniqueResult(0); |
|||
|
|||
JSONObject vm = WQLObject |
|||
.getWQLObject("st_ivt_vehicle_material") |
|||
.query("vehicle_id = " + vehicle.getString("vehicle_id"), "create_time ASC") |
|||
.uniqueResult(0); |
|||
|
|||
JSONObject ivt = new JSONObject(); |
|||
ivt.put("stockrecord_id", IdUtil.getSnowflake(1L, 1L).nextId()); |
|||
ivt.put("point_id", nextPoint.getString("point_id")); |
|||
ivt.put("instorage_time", vm.getString("create_time")); |
|||
|
|||
WQLObject.getWQLObject("st_ivt_structivt").insert(ivt); |
|||
} |
|||
|
|||
nextPoint.put("point_status", PointStatus.HAS_VEHICLE.getCode()); |
|||
nextPoint.put("lock_type", LockType.UNLOCKED.getCode()); |
|||
nextPoint.put("vehicle_code", startPoint.getString("vehicle_code")); |
|||
CommonUtils.addAdminUpdateColum(nextPoint); |
|||
pointTable.update(nextPoint); |
|||
|
|||
startPoint.put("point_status", PointStatus.EMPTY.getCode()); |
|||
startPoint.put("lock_type", LockType.UNLOCKED.getCode()); |
|||
startPoint.put("vehicle_code", ""); |
|||
CommonUtils.addAdminUpdateColum(startPoint); |
|||
pointTable.update(startPoint); |
|||
} |
|||
} |
@ -0,0 +1,248 @@ |
|||
package org.nl.wms.sch.task; |
|||
|
|||
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; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.modules.common.exception.BadRequestException; |
|||
import org.nl.modules.system.util.CodeUtil; |
|||
import org.nl.modules.wql.WQL; |
|||
import org.nl.modules.wql.core.bean.WQLObject; |
|||
import org.nl.wms.sch.base.point.LockType; |
|||
import org.nl.wms.sch.base.point.PointStatus; |
|||
import org.nl.wms.sch.base.point.PointType; |
|||
import org.nl.wms.sch.manage.AbstractAcsTask; |
|||
import org.nl.wms.sch.task.dto.AcsTaskDTO; |
|||
import org.nl.wms.sch.task.util.TaskUtils; |
|||
import org.nl.wms.util.CommonUtils; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 纽迪西亚3呼叫余料入库任务 |
|||
* |
|||
* @author 张江玮 |
|||
* @date 2022/11/07 20:19 |
|||
*/ |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
@Slf4j |
|||
public class SendResiduesMaterialTask extends AbstractAcsTask { |
|||
|
|||
private static final String THIS_CLASS_NAME = SendResiduesMaterialTask.class.getName(); |
|||
|
|||
/** |
|||
* 添加任务进行下发 |
|||
* |
|||
* @return 所有这个类处理的已确认起点和终点任务 |
|||
*/ |
|||
@Override |
|||
public List<AcsTaskDTO> addTask() { |
|||
return TaskUtils.addTask(THIS_CLASS_NAME); |
|||
} |
|||
|
|||
/** |
|||
* @param taskJSON 代表一条任务对象 |
|||
* @param status 代表wcs任务完成状态: //0:acs,取消,:执行中,2:完成
|
|||
* @discription wcs请求wms任务完成状态反馈接口, 比如agv从a点往b点走。生成任务的时候绑定b的物料信息,任务完成的时候,清除a的物料信息 |
|||
* @author ldjun |
|||
* @created 2019年4月17日 下午8:51:50 |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public void updateTaskStatus(JSONObject taskJSON, String status) { |
|||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task"); |
|||
String taskCode = taskJSON.getString("task_code"); |
|||
JSONObject task = taskTable |
|||
.query("task_code = " + taskCode) |
|||
.uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(task)) { |
|||
throw new BadRequestException("未找到任务号为" + taskCode + "的任务"); |
|||
} |
|||
|
|||
if (StrUtil.equals(status, "0")) { |
|||
this.cancel(task.getString("task_id")); |
|||
} |
|||
|
|||
if (StrUtil.equals(status, TaskStatus.EXECUTING.getCode())) { |
|||
task.put("task", TaskStatus.EXECUTING.getCode()); |
|||
CommonUtils.addAdminUpdateColum(task); |
|||
taskTable.update(task); |
|||
} |
|||
|
|||
if (StrUtil.equals(status, TaskStatus.FINISHED.getCode())) { |
|||
this.finishTask(task, TaskFinishedType.AUTO); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @param param 创建任务需要的参数 |
|||
* |
|||
* @return 返回任务标识 |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public String createTask(JSONObject param) { |
|||
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point"); |
|||
JSONObject point = pointTable |
|||
.query("point_id = " + param.getString("point_id")) |
|||
.uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(point)) { |
|||
throw new BadRequestException("点位不存在"); |
|||
} |
|||
|
|||
JSONObject task = new JSONObject(); |
|||
String taskId = IdUtil.getSnowflake(1L, 1L).nextIdStr(); |
|||
task.put("task_id", taskId); |
|||
task.put("task_code", CodeUtil.getNewCode("TASK_CODE")); |
|||
task.put("task_type", TaskType.SEND_RESIDUES_MATERIAL.getCode()); |
|||
task.put("task_status", TaskStatus.SURE_START.getCode()); |
|||
task.put("point_code1", point.getString("point_code")); |
|||
task.put("vehicle_code", point.getString("vehicle_code")); |
|||
task.put("handle_class", THIS_CLASS_NAME); |
|||
task.put("create_mode", CreateMode.SCCJ.getCode()); |
|||
CommonUtils.addCommonColum(task); |
|||
WQLObject.getWQLObject("sch_base_task").insert(task); |
|||
|
|||
point.put("lock_type", LockType.TASK_LOCKED.getCode()); |
|||
CommonUtils.addUpdateColum(point); |
|||
pointTable.update(point); |
|||
|
|||
return taskId; |
|||
} |
|||
|
|||
/** |
|||
* @param taskId 任务标识 |
|||
* @discription 强制结束完成任务 |
|||
* @author ldjun |
|||
* @created 2020年6月19日 上午10:34:58 |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public void forceFinish(String taskId) { |
|||
JSONObject task = WQLObject |
|||
.getWQLObject("sch_base_task") |
|||
.query("task_id = " + taskId) |
|||
.uniqueResult(0); |
|||
this.finishTask(task, TaskFinishedType.MANUAL); |
|||
} |
|||
|
|||
/** |
|||
* 取消任务,货物搬回原点 |
|||
* |
|||
* @param taskId 任务标识 |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public void cancel(String taskId) { |
|||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task"); |
|||
JSONObject task = taskTable |
|||
.query("task_id = " + taskId) |
|||
.uniqueResult(0); |
|||
taskTable.delete(task); |
|||
|
|||
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point"); |
|||
JSONObject startPoint = pointTable |
|||
.query("task_code = " + task.getString("point_code1")) |
|||
.uniqueResult(0); |
|||
JSONObject nextPoint = pointTable |
|||
.query("task_code = " + task.getString("point_code2")) |
|||
.uniqueResult(0); |
|||
|
|||
startPoint.put("lock_type", LockType.UNLOCKED.getCode()); |
|||
CommonUtils.addAdminUpdateColum(startPoint); |
|||
pointTable.update(startPoint); |
|||
nextPoint.put("lock_type", LockType.UNLOCKED.getCode()); |
|||
CommonUtils.addAdminUpdateColum(nextPoint); |
|||
pointTable.update(nextPoint); |
|||
} |
|||
|
|||
/** |
|||
* @return |
|||
* @discription 确定下一点位 |
|||
* @author ldjun |
|||
* @created 2020年6月12日 下午6:01:06 |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public void findNextPoint() { |
|||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task"); |
|||
JSONArray tasks = taskTable |
|||
.query("task_status = " + TaskStatus.SURE_START.getCode() + " AND handle_class = " + THIS_CLASS_NAME) |
|||
.getResultJSONArray(0); |
|||
|
|||
for (Object o : tasks) { |
|||
JSONObject point = WQL.getWO("TASK") |
|||
.addParam("flag", "2") |
|||
.process() |
|||
.uniqueResult(0); |
|||
|
|||
if (ObjectUtil.isNotEmpty(point)) { |
|||
JSONObject task = (JSONObject) o; |
|||
|
|||
task.put("task_status", TaskStatus.START_AND_END.getCode()); |
|||
task.put("point_code2", point.getString("point_code")); |
|||
CommonUtils.addAdminUpdateColum(task); |
|||
taskTable.update(task); |
|||
|
|||
JSONObject lockPoint = new JSONObject(); |
|||
lockPoint.put("lock_type", LockType.TASK_LOCKED.getCode()); |
|||
CommonUtils.addAdminUpdateColum(lockPoint); |
|||
WQLObject.getWQLObject("sch_base_point").update(lockPoint, "point_id = " + point.getString("point_id")); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void finishTask(JSONObject task, TaskFinishedType taskFinishedType) { |
|||
task.put("finished_type", taskFinishedType.getCode()); |
|||
task.put("task_status", TaskStatus.FINISHED.getCode()); |
|||
CommonUtils.addAdminUpdateColum(task); |
|||
WQLObject.getWQLObject("sch_base_task").update(task); |
|||
|
|||
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point"); |
|||
JSONObject startPoint = pointTable |
|||
.query("task_code = " + task.getString("point_code1")) |
|||
.uniqueResult(0); |
|||
JSONObject nextPoint = pointTable |
|||
.query("task_code = " + task.getString("point_code2")) |
|||
.uniqueResult(0); |
|||
|
|||
|
|||
if (StrUtil.equals(nextPoint.getString("point_type"), PointType.STORAGE_LOCATION.getCode())) { |
|||
JSONObject vehicle = WQLObject |
|||
.getWQLObject("md_pb_vehicle") |
|||
.query("vehicle_code = " + startPoint.getString("vehicle_code")) |
|||
.uniqueResult(0); |
|||
|
|||
JSONObject vm = WQLObject |
|||
.getWQLObject("st_ivt_vehicle_material") |
|||
.query("vehicle_id = " + vehicle.getString("vehicle_id"), "create_time ASC") |
|||
.uniqueResult(0); |
|||
|
|||
JSONObject ivt = new JSONObject(); |
|||
ivt.put("stockrecord_id", IdUtil.getSnowflake(1L, 1L).nextId()); |
|||
ivt.put("point_id", nextPoint.getString("point_id")); |
|||
ivt.put("instorage_time", vm.getString("create_time")); |
|||
|
|||
WQLObject.getWQLObject("st_ivt_structivt").insert(ivt); |
|||
} |
|||
|
|||
nextPoint.put("point_status", PointStatus.HAS_VEHICLE.getCode()); |
|||
nextPoint.put("lock_type", LockType.UNLOCKED.getCode()); |
|||
nextPoint.put("vehicle_code", startPoint.getString("vehicle_code")); |
|||
CommonUtils.addAdminUpdateColum(nextPoint); |
|||
pointTable.update(nextPoint); |
|||
|
|||
startPoint.put("point_status", PointStatus.EMPTY.getCode()); |
|||
startPoint.put("lock_type", LockType.UNLOCKED.getCode()); |
|||
startPoint.put("vehicle_code", ""); |
|||
CommonUtils.addAdminUpdateColum(startPoint); |
|||
pointTable.update(startPoint); |
|||
} |
|||
} |
@ -0,0 +1,229 @@ |
|||
package org.nl.wms.sch.task.wql; |
|||
|
|||
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; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.modules.common.exception.BadRequestException; |
|||
import org.nl.modules.system.util.CodeUtil; |
|||
import org.nl.modules.wql.WQL; |
|||
import org.nl.modules.wql.core.bean.WQLObject; |
|||
import org.nl.wms.sch.base.point.LockType; |
|||
import org.nl.wms.sch.base.point.PointStatus; |
|||
import org.nl.wms.sch.base.point.PointType; |
|||
import org.nl.wms.sch.manage.AbstractAcsTask; |
|||
import org.nl.wms.sch.task.*; |
|||
import org.nl.wms.sch.task.dto.AcsTaskDTO; |
|||
import org.nl.wms.sch.task.util.TaskUtils; |
|||
import org.nl.wms.util.CommonUtils; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 纽迪希亚3呼叫空车入库 |
|||
* |
|||
* @author 张江玮 |
|||
* @date 2022/11/07 20:14 |
|||
*/ |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
@Slf4j |
|||
public class SendEmptyVehicleTask extends AbstractAcsTask { |
|||
|
|||
private static final String THIS_CLASS_NAME = SendEmptyVehicleTask.class.getName(); |
|||
|
|||
/** |
|||
* 添加任务进行下发 |
|||
* |
|||
* @return 所有这个类处理的已确认起点和终点任务 |
|||
*/ |
|||
@Override |
|||
public List<AcsTaskDTO> addTask() { |
|||
return TaskUtils.addTask(THIS_CLASS_NAME); |
|||
} |
|||
|
|||
/** |
|||
* @param taskJSON 代表一条任务对象 |
|||
* @param status 代表wcs任务完成状态: //0:acs,取消,:执行中,2:完成
|
|||
* @discription wcs请求wms任务完成状态反馈接口, 比如agv从a点往b点走。生成任务的时候绑定b的物料信息,任务完成的时候,清除a的物料信息 |
|||
* @author ldjun |
|||
* @created 2019年4月17日 下午8:51:50 |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public void updateTaskStatus(JSONObject taskJSON, String status) { |
|||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task"); |
|||
String taskCode = taskJSON.getString("task_code"); |
|||
JSONObject task = taskTable |
|||
.query("task_code = " + taskCode) |
|||
.uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(task)) { |
|||
throw new BadRequestException("未找到任务号为" + taskCode + "的任务"); |
|||
} |
|||
|
|||
if (StrUtil.equals(status, "0")) { |
|||
this.cancel(task.getString("task_id")); |
|||
} |
|||
|
|||
if (StrUtil.equals(status, TaskStatus.EXECUTING.getCode())) { |
|||
task.put("task", TaskStatus.EXECUTING.getCode()); |
|||
CommonUtils.addAdminUpdateColum(task); |
|||
taskTable.update(task); |
|||
} |
|||
|
|||
if (StrUtil.equals(status, TaskStatus.FINISHED.getCode())) { |
|||
this.finishTask(task, TaskFinishedType.AUTO); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @param param 创建任务需要的参数 |
|||
* |
|||
* @return 返回任务标识 |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public String createTask(JSONObject param) { |
|||
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point"); |
|||
JSONObject point = pointTable |
|||
.query("point_id = " + param.getString("point_id")) |
|||
.uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(point)) { |
|||
throw new BadRequestException("点位不存在"); |
|||
} |
|||
|
|||
JSONObject task = new JSONObject(); |
|||
String taskId = IdUtil.getSnowflake(1L, 1L).nextIdStr(); |
|||
task.put("task_id", taskId); |
|||
task.put("task_code", CodeUtil.getNewCode("TASK_CODE")); |
|||
task.put("task_type", TaskType.SEND_EMPTY_VEHICLE.getCode()); |
|||
task.put("task_status", TaskStatus.SURE_START.getCode()); |
|||
task.put("point_code1", point.getString("point_code")); |
|||
task.put("vehicle_code", point.getString("vehicle_code")); |
|||
task.put("handle_class", THIS_CLASS_NAME); |
|||
task.put("create_mode", CreateMode.SCCJ.getCode()); |
|||
CommonUtils.addCommonColum(task); |
|||
WQLObject.getWQLObject("sch_base_task").insert(task); |
|||
|
|||
point.put("lock_type", LockType.TASK_LOCKED.getCode()); |
|||
CommonUtils.addUpdateColum(point); |
|||
pointTable.update(point); |
|||
|
|||
return taskId; |
|||
} |
|||
|
|||
/** |
|||
* @param taskId 任务标识 |
|||
* @discription 强制结束完成任务 |
|||
* @author ldjun |
|||
* @created 2020年6月19日 上午10:34:58 |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public void forceFinish(String taskId) { |
|||
JSONObject task = WQLObject |
|||
.getWQLObject("sch_base_task") |
|||
.query("task_id = " + taskId) |
|||
.uniqueResult(0); |
|||
this.finishTask(task, TaskFinishedType.MANUAL); |
|||
} |
|||
|
|||
/** |
|||
* 取消任务,货物搬回原点 |
|||
* |
|||
* @param taskId 任务标识 |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public void cancel(String taskId) { |
|||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task"); |
|||
JSONObject task = taskTable |
|||
.query("task_id = " + taskId) |
|||
.uniqueResult(0); |
|||
taskTable.delete(task); |
|||
|
|||
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point"); |
|||
JSONObject startPoint = pointTable |
|||
.query("task_code = " + task.getString("point_code1")) |
|||
.uniqueResult(0); |
|||
JSONObject nextPoint = pointTable |
|||
.query("task_code = " + task.getString("point_code2")) |
|||
.uniqueResult(0); |
|||
|
|||
startPoint.put("lock_type", LockType.UNLOCKED.getCode()); |
|||
CommonUtils.addAdminUpdateColum(startPoint); |
|||
pointTable.update(startPoint); |
|||
nextPoint.put("lock_type", LockType.UNLOCKED.getCode()); |
|||
CommonUtils.addAdminUpdateColum(nextPoint); |
|||
pointTable.update(nextPoint); |
|||
} |
|||
|
|||
/** |
|||
* @return |
|||
* @discription 确定下一点位 |
|||
* @author ldjun |
|||
* @created 2020年6月12日 下午6:01:06 |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public void findNextPoint() { |
|||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task"); |
|||
JSONArray tasks = taskTable |
|||
.query("task_status = " + TaskStatus.SURE_START.getCode() + " AND handle_class = " + THIS_CLASS_NAME) |
|||
.getResultJSONArray(0); |
|||
|
|||
for (Object o : tasks) { |
|||
JSONObject point = WQL.getWO("TASK") |
|||
.addParam("flag", "2") |
|||
.process() |
|||
.uniqueResult(0); |
|||
|
|||
if (ObjectUtil.isNotEmpty(point)) { |
|||
JSONObject task = (JSONObject) o; |
|||
|
|||
task.put("task_status", TaskStatus.START_AND_END.getCode()); |
|||
task.put("point_code2", point.getString("point_code")); |
|||
CommonUtils.addAdminUpdateColum(task); |
|||
taskTable.update(task); |
|||
|
|||
JSONObject lockPoint = new JSONObject(); |
|||
lockPoint.put("lock_type", LockType.TASK_LOCKED.getCode()); |
|||
CommonUtils.addAdminUpdateColum(lockPoint); |
|||
WQLObject.getWQLObject("sch_base_point").update(lockPoint, "point_id = " + point.getString("point_id")); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void finishTask(JSONObject task, TaskFinishedType taskFinishedType) { |
|||
task.put("finished_type", taskFinishedType.getCode()); |
|||
task.put("task_status", TaskStatus.FINISHED.getCode()); |
|||
CommonUtils.addAdminUpdateColum(task); |
|||
WQLObject.getWQLObject("sch_base_task").update(task); |
|||
|
|||
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point"); |
|||
JSONObject startPoint = pointTable |
|||
.query("task_code = " + task.getString("point_code1")) |
|||
.uniqueResult(0); |
|||
JSONObject nextPoint = pointTable |
|||
.query("task_code = " + task.getString("point_code2")) |
|||
.uniqueResult(0); |
|||
|
|||
nextPoint.put("point_status", PointStatus.HAS_VEHICLE.getCode()); |
|||
nextPoint.put("lock_type", LockType.UNLOCKED.getCode()); |
|||
nextPoint.put("vehicle_code", startPoint.getString("vehicle_code")); |
|||
CommonUtils.addAdminUpdateColum(nextPoint); |
|||
pointTable.update(nextPoint); |
|||
|
|||
startPoint.put("point_status", PointStatus.EMPTY.getCode()); |
|||
startPoint.put("lock_type", LockType.UNLOCKED.getCode()); |
|||
startPoint.put("vehicle_code", ""); |
|||
CommonUtils.addAdminUpdateColum(startPoint); |
|||
pointTable.update(startPoint); |
|||
} |
|||
} |
Loading…
Reference in new issue