9 changed files with 414 additions and 2 deletions
@ -0,0 +1,42 @@ |
|||||
|
package org.nl.wms.pda.sch_manage.controller; |
||||
|
|
||||
|
|
||||
|
import cn.dev33.satoken.annotation.SaIgnore; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.nl.common.logging.annotation.Log; |
||||
|
import org.nl.wms.pda.sch_manage.service.PdaSchTaskService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
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; |
||||
|
|
||||
|
/** |
||||
|
* <p> |
||||
|
* 手持任务操作 控制层 |
||||
|
* </p> |
||||
|
* |
||||
|
* @author Liuxy |
||||
|
* @since 2025-06-06 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@RequiredArgsConstructor |
||||
|
@RequestMapping("/api/pda/schTask") |
||||
|
@Slf4j |
||||
|
public class PdaSchTaskController { |
||||
|
|
||||
|
@Autowired |
||||
|
private PdaSchTaskService pdaSchTaskService; |
||||
|
|
||||
|
@PostMapping("/pointTask") |
||||
|
@Log("定点作业") |
||||
|
@SaIgnore |
||||
|
public ResponseEntity<Object> pointTask(@RequestBody JSONObject whereJson) { |
||||
|
return new ResponseEntity<>(pdaSchTaskService.pointTask(whereJson), HttpStatus.OK); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,29 @@ |
|||||
|
package org.nl.wms.pda.sch_manage.service; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import org.nl.wms.pda.util.PdaResponse; |
||||
|
import org.nl.wms.sch_manage.service.dao.SchBaseTask; |
||||
|
|
||||
|
/** |
||||
|
* <p> |
||||
|
* 手持任务操作 服务类 |
||||
|
* </p> |
||||
|
* |
||||
|
* @author Liuxy |
||||
|
* @since 2025-06-06 |
||||
|
*/ |
||||
|
public interface PdaSchTaskService extends IService<SchBaseTask> { |
||||
|
|
||||
|
/** |
||||
|
* 定点任务 |
||||
|
* @param whereJson { |
||||
|
* start_point_code:起点点位 |
||||
|
* end_point_code:终点点位 |
||||
|
* storagevehicle_code:载具编码 |
||||
|
* acs_type:acs任务类型 |
||||
|
* } |
||||
|
* @return PdaResponse |
||||
|
*/ |
||||
|
PdaResponse pointTask(JSONObject whereJson); |
||||
|
} |
@ -0,0 +1,110 @@ |
|||||
|
package org.nl.wms.pda.sch_manage.service.impl; |
||||
|
|
||||
|
import cn.hutool.core.util.ObjectUtil; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import org.nl.wms.basedata_manage.service.IMdPbStoragevehicleinfoService; |
||||
|
import org.nl.wms.basedata_manage.service.IStructattrService; |
||||
|
import org.nl.wms.basedata_manage.service.dao.Structattr; |
||||
|
import org.nl.wms.pda.sch_manage.service.PdaSchTaskService; |
||||
|
import org.nl.wms.pda.util.PdaResponse; |
||||
|
import org.nl.wms.sch_manage.enums.TaskEnum; |
||||
|
import org.nl.wms.sch_manage.service.ISchBasePointService; |
||||
|
import org.nl.wms.sch_manage.service.dao.SchBasePoint; |
||||
|
import org.nl.wms.sch_manage.service.dao.SchBaseTask; |
||||
|
import org.nl.wms.sch_manage.service.dao.mapper.SchBaseTaskMapper; |
||||
|
import org.nl.wms.sch_manage.service.util.tasks.PdaPointTask; |
||||
|
import org.nl.wms.warehouse_management.enums.IOSConstant; |
||||
|
import org.nl.wms.warehouse_management.enums.IOSEnum; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
/** |
||||
|
* <p> |
||||
|
* 手持任务操作 实现类 |
||||
|
* </p> |
||||
|
* |
||||
|
* @author Liuxy |
||||
|
* @since 2025-06-06 |
||||
|
*/ |
||||
|
@Service |
||||
|
public class PdaSchTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBaseTask> implements PdaSchTaskService { |
||||
|
|
||||
|
/** |
||||
|
* 点位服务 |
||||
|
*/ |
||||
|
@Autowired |
||||
|
private ISchBasePointService iSchBasePointService; |
||||
|
|
||||
|
/** |
||||
|
* 仓位服务 |
||||
|
*/ |
||||
|
@Autowired |
||||
|
private IStructattrService iStructattrService; |
||||
|
|
||||
|
/** |
||||
|
* 载具信息服务 |
||||
|
*/ |
||||
|
@Autowired |
||||
|
private IMdPbStoragevehicleinfoService iMdPbStoragevehicleinfoService; |
||||
|
|
||||
|
/** |
||||
|
* 手持定点任务服务 |
||||
|
*/ |
||||
|
@Autowired |
||||
|
private PdaPointTask pdaPointTask; |
||||
|
|
||||
|
@Override |
||||
|
@Transactional |
||||
|
public PdaResponse pointTask(JSONObject whereJson) { |
||||
|
// 校验数据
|
||||
|
checkPoint(whereJson); |
||||
|
// 创建任务
|
||||
|
JSONObject task = new JSONObject(); |
||||
|
task.put("config_code", IOSConstant.PDA_POINT_TASK); |
||||
|
task.put("point_code1", whereJson.getString("start_point_code")); |
||||
|
task.put("point_code2", whereJson.getString("end_point_code")); |
||||
|
task.put("vehicle_code", whereJson.getString("storagevehicle_code")); |
||||
|
task.put("Priority", TaskEnum.ACS_PRIORITY.code("1")); |
||||
|
pdaPointTask.create(task); |
||||
|
return PdaResponse.requestOk(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 校验起点终点载具 |
||||
|
* @param whereJson { |
||||
|
* start_point_code:起点点位 |
||||
|
* end_point_code:终点点位 |
||||
|
* storagevehicle_code:终点点位 |
||||
|
* } |
||||
|
*/ |
||||
|
private void checkPoint(JSONObject whereJson) { |
||||
|
String start_point_code = whereJson.getString("start_point_code"); |
||||
|
String end_point_code = whereJson.getString("end_point_code"); |
||||
|
String storagevehicle_code = whereJson.getString("storagevehicle_code"); |
||||
|
// 校验起点
|
||||
|
SchBasePoint pointStartDao = iSchBasePointService.getById(start_point_code); |
||||
|
if (ObjectUtil.isEmpty(pointStartDao)) { |
||||
|
Structattr attrDao = iStructattrService.getByCode(start_point_code); |
||||
|
attrDao.setLock_type(IOSEnum.LOCK_TYPE.code("其他锁")); |
||||
|
iStructattrService.updateById(attrDao); |
||||
|
} else { |
||||
|
pointStartDao.setPoint_status(IOSEnum.POINT_STATUS.code("有货")); |
||||
|
iSchBasePointService.updateById(pointStartDao); |
||||
|
} |
||||
|
|
||||
|
// 校验终点
|
||||
|
SchBasePoint pointEndDao = iSchBasePointService.getById(end_point_code); |
||||
|
if (ObjectUtil.isEmpty(pointEndDao)) { |
||||
|
Structattr attrDao = iStructattrService.getByCode(end_point_code); |
||||
|
attrDao.setLock_type(IOSEnum.LOCK_TYPE.code("其他锁")); |
||||
|
iStructattrService.updateById(attrDao); |
||||
|
} else { |
||||
|
pointEndDao.setPoint_status(IOSEnum.POINT_STATUS.code("有货")); |
||||
|
iSchBasePointService.updateById(pointEndDao); |
||||
|
} |
||||
|
// 校验载具
|
||||
|
iMdPbStoragevehicleinfoService.getByCode(storagevehicle_code); |
||||
|
} |
||||
|
} |
@ -0,0 +1,203 @@ |
|||||
|
package org.nl.wms.sch_manage.service.util.tasks; |
||||
|
|
||||
|
import cn.hutool.core.date.DateUtil; |
||||
|
import cn.hutool.core.util.ObjectUtil; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
||||
|
import org.nl.common.exception.BadRequestException; |
||||
|
import org.nl.common.utils.SecurityUtils; |
||||
|
import org.nl.config.IdUtil; |
||||
|
import org.nl.wms.basedata_manage.service.IStructattrService; |
||||
|
import org.nl.wms.basedata_manage.service.dao.Structattr; |
||||
|
import org.nl.wms.sch_manage.enums.TaskStatus; |
||||
|
import org.nl.wms.sch_manage.service.ISchBasePointService; |
||||
|
import org.nl.wms.sch_manage.service.ISchBaseTaskService; |
||||
|
import org.nl.wms.sch_manage.service.dao.SchBasePoint; |
||||
|
import org.nl.wms.sch_manage.service.dao.SchBaseTask; |
||||
|
import org.nl.wms.sch_manage.service.util.AbstractTask; |
||||
|
import org.nl.wms.sch_manage.service.util.AcsTaskDto; |
||||
|
import org.nl.wms.sch_manage.service.util.TaskType; |
||||
|
import org.nl.wms.warehouse_management.enums.IOSEnum; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
/** |
||||
|
* @Author: Liuxy |
||||
|
* @Description: 手持定点任务 |
||||
|
* @Date: 2025/6/6 |
||||
|
*/ |
||||
|
@Component(value = "PdaPointTask") |
||||
|
@TaskType("PdaPointTask") |
||||
|
public class PdaPointTask extends AbstractTask { |
||||
|
|
||||
|
/** |
||||
|
* 任务服务类 |
||||
|
*/ |
||||
|
@Autowired |
||||
|
private ISchBaseTaskService taskService; |
||||
|
|
||||
|
/** |
||||
|
* 点位服务 |
||||
|
*/ |
||||
|
@Autowired |
||||
|
private ISchBasePointService iSchBasePointService; |
||||
|
|
||||
|
/** |
||||
|
* 仓位服务 |
||||
|
*/ |
||||
|
@Autowired |
||||
|
private IStructattrService iStructattrService; |
||||
|
|
||||
|
@Override |
||||
|
public String create(JSONObject json) { |
||||
|
SchBaseTask task = new SchBaseTask(); |
||||
|
task.setTask_id(IdUtil.getStringId()); |
||||
|
task.setTask_code(IdUtil.getStringId()); |
||||
|
task.setTask_status(TaskStatus.CREATE.getCode()); |
||||
|
task.setConfig_code(json.getString("config_code")); |
||||
|
task.setPoint_code1(json.getString("point_code1")); |
||||
|
task.setPoint_code2(json.getString("point_code2")); |
||||
|
task.setVehicle_code(json.getString("vehicle_code")); |
||||
|
task.setRequest_param(json.toString()); |
||||
|
task.setPriority(json.getString("Priority")); |
||||
|
task.setCreate_id(SecurityUtils.getCurrentUserId()); |
||||
|
task.setCreate_name(SecurityUtils.getCurrentNickName()); |
||||
|
task.setCreate_time(DateUtil.now()); |
||||
|
taskService.save(task); |
||||
|
return task.getTask_id(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public AcsTaskDto sendAcsParam(String taskId) { |
||||
|
SchBaseTask taskDao = taskService.getById(taskId); |
||||
|
|
||||
|
// 组织下发给acs的数据
|
||||
|
AcsTaskDto acsTaskDto = new AcsTaskDto(); |
||||
|
acsTaskDto.setExt_task_uuid(taskDao.getTask_id()); |
||||
|
acsTaskDto.setTask_code(taskDao.getTask_code()); |
||||
|
acsTaskDto.setStart_device_code(taskDao.getPoint_code1()); |
||||
|
acsTaskDto.setNext_device_code(taskDao.getPoint_code2()); |
||||
|
acsTaskDto.setPriority(taskDao.getPriority()); |
||||
|
acsTaskDto.setTask_type("1"); |
||||
|
return acsTaskDto; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
protected void updateStatus(String task_code, TaskStatus status) { |
||||
|
// 校验任务
|
||||
|
SchBaseTask taskObj = taskService.getByCode(task_code); |
||||
|
if (taskObj.getTask_status().equals(TaskStatus.FINISHED.getCode())) { |
||||
|
throw new BadRequestException("该任务已完成!"); |
||||
|
} |
||||
|
if (taskObj.getTask_status().equals(TaskStatus.CANCELED.getCode())) { |
||||
|
throw new BadRequestException("该任务已取消!"); |
||||
|
} |
||||
|
// 根据传来的类型去对任务进行操作
|
||||
|
if (status.equals(TaskStatus.EXECUTING)) { |
||||
|
// 更新明细状态
|
||||
|
taskObj.setTask_status(TaskStatus.EXECUTING.getCode()); |
||||
|
taskObj.setRemark("执行中"); |
||||
|
taskService.updateById(taskObj); |
||||
|
} |
||||
|
if (status.equals(TaskStatus.FINISHED)) { |
||||
|
this.finishTask(taskObj); |
||||
|
} |
||||
|
if (status.equals(TaskStatus.CANCELED)) { |
||||
|
this.cancelTask(taskObj); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void forceFinish(String task_code) { |
||||
|
SchBaseTask taskObj = taskService.getByCode(task_code); |
||||
|
if (ObjectUtil.isEmpty(taskObj)) { |
||||
|
throw new BadRequestException("该任务不存在"); |
||||
|
} |
||||
|
this.finishTask(taskObj); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void cancel(String task_code) { |
||||
|
SchBaseTask taskObj = taskService.getByCode(task_code); |
||||
|
if (ObjectUtil.isEmpty(taskObj)) { |
||||
|
throw new BadRequestException("该任务不存在"); |
||||
|
} |
||||
|
if (Integer.parseInt(taskObj.getTask_status()) > Integer.parseInt(TaskStatus.CREATE.getCode())) { |
||||
|
throw new BadRequestException("只能取消生成中的任务!"); |
||||
|
} |
||||
|
this.cancelTask(taskObj); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void backMes(String task_code) { |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public void finishTask(SchBaseTask taskObj) { |
||||
|
// 更新起点
|
||||
|
iSchBasePointService.update( |
||||
|
new UpdateWrapper<SchBasePoint>().lambda() |
||||
|
.eq(SchBasePoint::getPoint_code, taskObj.getPoint_code1()) |
||||
|
.set(SchBasePoint::getVehicle_code, null) |
||||
|
.set(SchBasePoint::getIos_id, null) |
||||
|
.set(SchBasePoint::getPoint_status, IOSEnum.POINT_STATUS.code("无货")) |
||||
|
); |
||||
|
iStructattrService.update( |
||||
|
new UpdateWrapper<Structattr>().lambda() |
||||
|
.eq(Structattr::getStruct_code, taskObj.getPoint_code1()) |
||||
|
.set(Structattr::getStoragevehicle_code, null) |
||||
|
.set(Structattr::getTaskdtl_id, null) |
||||
|
.set(Structattr::getLock_type, IOSEnum.LOCK_TYPE.code("未锁定")) |
||||
|
); |
||||
|
// 更新终点
|
||||
|
iSchBasePointService.update( |
||||
|
new UpdateWrapper<SchBasePoint>().lambda() |
||||
|
.eq(SchBasePoint::getPoint_code, taskObj.getPoint_code2()) |
||||
|
.set(SchBasePoint::getVehicle_code, taskObj.getVehicle_code()) |
||||
|
.set(SchBasePoint::getIos_id, null) |
||||
|
.set(SchBasePoint::getPoint_status, IOSEnum.POINT_STATUS.code("有货")) |
||||
|
); |
||||
|
iStructattrService.update( |
||||
|
new UpdateWrapper<Structattr>().lambda() |
||||
|
.eq(Structattr::getStruct_code, taskObj.getPoint_code2()) |
||||
|
.set(Structattr::getStoragevehicle_code, taskObj.getVehicle_code()) |
||||
|
.set(Structattr::getTaskdtl_id, null) |
||||
|
.set(Structattr::getLock_type, IOSEnum.LOCK_TYPE.code("未锁定")) |
||||
|
); |
||||
|
// 更新任务
|
||||
|
taskObj.setRemark("已完成"); |
||||
|
taskObj.setTask_status(TaskStatus.FINISHED.getCode()); |
||||
|
taskService.updateById(taskObj); |
||||
|
} |
||||
|
|
||||
|
@Transactional |
||||
|
public void cancelTask(SchBaseTask taskObj) { |
||||
|
// 更新起点
|
||||
|
iSchBasePointService.update( |
||||
|
new UpdateWrapper<SchBasePoint>().lambda() |
||||
|
.eq(SchBasePoint::getPoint_code, taskObj.getPoint_code1()) |
||||
|
.set(SchBasePoint::getPoint_status, IOSEnum.POINT_STATUS.code("无货")) |
||||
|
); |
||||
|
iStructattrService.update( |
||||
|
new UpdateWrapper<Structattr>().lambda() |
||||
|
.eq(Structattr::getStruct_code, taskObj.getPoint_code1()) |
||||
|
.set(Structattr::getLock_type, IOSEnum.LOCK_TYPE.code("未锁定")) |
||||
|
); |
||||
|
// 更新终点
|
||||
|
iSchBasePointService.update( |
||||
|
new UpdateWrapper<SchBasePoint>().lambda() |
||||
|
.eq(SchBasePoint::getPoint_code, taskObj.getPoint_code2()) |
||||
|
.set(SchBasePoint::getPoint_status, IOSEnum.POINT_STATUS.code("无货")) |
||||
|
); |
||||
|
iStructattrService.update( |
||||
|
new UpdateWrapper<Structattr>().lambda() |
||||
|
.eq(Structattr::getStruct_code, taskObj.getPoint_code2()) |
||||
|
.set(Structattr::getLock_type, IOSEnum.LOCK_TYPE.code("未锁定")) |
||||
|
); |
||||
|
// 更新任务
|
||||
|
taskObj.setRemark("已取消"); |
||||
|
taskObj.setTask_status(TaskStatus.CANCELED.getCode()); |
||||
|
taskService.updateById(taskObj); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue