刘先源
2 months ago
17 changed files with 621 additions and 450 deletions
@ -1,9 +1,73 @@ |
|||
package org.nl.wms.ext.mes.service; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
|
|||
/** |
|||
* @Author: lyd |
|||
* @Description: mes请求wms |
|||
* @Date: 2023/8/3 |
|||
*/ |
|||
public interface MesToWmsService { |
|||
|
|||
/** |
|||
* mes下发任务(任务是数组形式下发,返回结果也要数组形式返回) |
|||
* @param jo { |
|||
* item : [ |
|||
* { |
|||
* TaskCode: 任务编码 |
|||
* PickingLocation: 取料货位 |
|||
* PlacedLocation: 放料库位 |
|||
* Priority: 优先级 |
|||
* MsgTime: 下发时间 |
|||
* } |
|||
* ] |
|||
* } |
|||
* @return { |
|||
* item : [ |
|||
* { |
|||
* TaskCode: 任务编码 |
|||
* ReturnStatus: 下发结果(0-成功,1-失败) |
|||
* ReturnInfo: 请求结果描述(1-AVG可立即执行任务,2-立库入库口占用无法执行,3-不能立即派送) |
|||
* ReturnCount: 返回空车库位剩余数量 |
|||
* MsgTime: 返回时间 |
|||
* } |
|||
* ] |
|||
* } |
|||
*/ |
|||
JSONObject taskSend(JSONObject jo); |
|||
|
|||
|
|||
/** |
|||
* mes查看任务 |
|||
* @param jo {} |
|||
* @return JSONObject : { |
|||
* ReturnStatus: 任务下发结果 |
|||
* MsgTime: 返回时间 |
|||
* TaskLists:任务列表 [ |
|||
* { |
|||
* TaskCode:任务编码 |
|||
* PickingLocation:取料货位 |
|||
* PlacedLocation:放料货位 |
|||
* TaskStatus:任务状态 |
|||
* ExecutingAGV:执行AVG名称 |
|||
* CreateTime:创建时间 |
|||
* ExecuteTime:执行时间 |
|||
* } |
|||
* ] |
|||
* } |
|||
*/ |
|||
JSONObject SearchTasks(JSONObject jo); |
|||
|
|||
/** |
|||
* mes删除任务 |
|||
* @param jo:{ |
|||
* TaskCode: 任务编码 |
|||
* } |
|||
* @return JSONObject:{ |
|||
* ReturnStatus:删除结果(0-成功,1-失败) |
|||
* ReturnInfo:结果描述 |
|||
* MsgTime:返回时间 |
|||
* } |
|||
*/ |
|||
JSONObject deleteTask(JSONObject jo); |
|||
} |
|||
|
@ -0,0 +1,52 @@ |
|||
package org.nl.wms.ext.mes.service.dto; |
|||
|
|||
import lombok.Builder; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* @Author: lxy |
|||
* @Description: 返回mes任务 |
|||
* @Date: 2024/9/24 |
|||
*/ |
|||
@Data |
|||
@Builder |
|||
public class ResultTaskMesDto { |
|||
|
|||
/** |
|||
* 任务编码 |
|||
*/ |
|||
String TaskCode; |
|||
|
|||
/** |
|||
* 取料货位 |
|||
*/ |
|||
String PickingLocation; |
|||
|
|||
/** |
|||
* 放料货位 |
|||
*/ |
|||
String PlacedLocation; |
|||
|
|||
/** |
|||
* 任务状态 |
|||
*/ |
|||
String TaskStatus; |
|||
|
|||
/** |
|||
* 执行AVG名称 |
|||
*/ |
|||
String ExecutingAGV; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
String CreateTime; |
|||
|
|||
/** |
|||
* 执行时间 |
|||
*/ |
|||
String ExecuteTime; |
|||
|
|||
} |
@ -0,0 +1,42 @@ |
|||
package org.nl.wms.sch.region.enums; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.nl.common.exception.BadRequestException; |
|||
import org.nl.config.MapOf; |
|||
|
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 区域任务类型枚举类 |
|||
* |
|||
* @author lxy |
|||
* @Date 2023/11/14 20:11 |
|||
*/ |
|||
@AllArgsConstructor |
|||
@Getter |
|||
public enum RegionEnum { |
|||
//是否
|
|||
IS_NOTANDYES(MapOf.of("否", "0", "是", "1")), |
|||
; |
|||
|
|||
private Map<String, String> code; |
|||
|
|||
public String code(String desc) { |
|||
String code = this.getCode().get(desc); |
|||
if (StringUtils.isNotEmpty(code)) { |
|||
return code; |
|||
} |
|||
throw new BadRequestException(this.name() + "对应类型" + desc + "未定义"); |
|||
} |
|||
|
|||
public String check(String code) { |
|||
for (Map.Entry<String, String> entry : this.getCode().entrySet()) { |
|||
if (entry.getValue().equals("code")) { |
|||
return entry.getValue(); |
|||
} |
|||
} |
|||
throw new BadRequestException(this.name() + "对应类型" + code + "未定义"); |
|||
} |
|||
} |
@ -1,41 +0,0 @@ |
|||
package org.nl.wms.sch.task_manage.enums; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
|
|||
/** |
|||
* @Author: lyd |
|||
* @Description: 组盘状态枚举 |
|||
* @Date: 2023/5/24 |
|||
*/ |
|||
@Getter |
|||
@AllArgsConstructor |
|||
public enum GroupStatusEnum { |
|||
/** |
|||
* 系统外 |
|||
*/ |
|||
OUT_SYSTEM("1", "系统外"), |
|||
/** |
|||
* 存储中 |
|||
*/ |
|||
IN_STORAGE("2", "存储中"), |
|||
/** |
|||
* 处理中 |
|||
*/ |
|||
IN_PROCESS("3", "处理中"), |
|||
/** |
|||
* 搬运中 |
|||
*/ |
|||
IN_CARRY("4", "搬运中"), |
|||
/** |
|||
* 可放料 |
|||
*/ |
|||
DISCHARGE_MATERIAL("5", "可放料"), |
|||
/** |
|||
* 可取料 |
|||
*/ |
|||
CABLE_RETRIEVABLE_MATERIAL("6", "可取料"); |
|||
|
|||
private final String type; |
|||
private final String name; |
|||
} |
@ -1,36 +0,0 @@ |
|||
package org.nl.wms.sch.task_manage.enums; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
|
|||
/** |
|||
* @Author: lyd |
|||
* @Description: 工单状态枚举 |
|||
* @Date: 2023/6/16 |
|||
*/ |
|||
@Getter |
|||
@AllArgsConstructor |
|||
public enum WorkOrderStatusEnum { |
|||
/** |
|||
* 未生产 |
|||
*/ |
|||
UNPRODUCED("1", "未生产"), |
|||
/** |
|||
* 已下发 |
|||
*/ |
|||
ISSUED("2", "已下发"), |
|||
/** |
|||
* 生产中 |
|||
*/ |
|||
PRODUCING("3", "生产中"), |
|||
/** |
|||
* 暂停 |
|||
*/ |
|||
STOP("4", "暂停"), |
|||
/** |
|||
* 完成 |
|||
*/ |
|||
COMPLETE("5", "完成"); |
|||
private final String code; |
|||
private final String name; |
|||
} |
@ -1 +0,0 @@ |
|||
package org.nl.wms.sch.task_manage.task; |
@ -1,34 +0,0 @@ |
|||
package org.nl.wms.sch.task_manage.task; |
|||
|
|||
import cn.hutool.core.lang.Assert; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import org.nl.common.exception.BadRequestException; |
|||
|
|||
/** |
|||
* @author ldjun |
|||
* @version 1.0 |
|||
* @date 2023年05月08日 13:59 |
|||
* @desc desc |
|||
*/ |
|||
public class TaskServiceImpl { |
|||
String create(JSONObject param) throws BadRequestException { |
|||
|
|||
|
|||
return null; |
|||
} |
|||
|
|||
public void beforeToCreate(JSONObject param) throws BadRequestException { |
|||
String point_code = param.getString("point_code"); |
|||
Assert.notEmpty(point_code, "点位编码为空!"); |
|||
//1、查找点位
|
|||
//2、校验点位是否启用
|
|||
//3、校验点位是否自动
|
|||
//4、任务类型
|
|||
|
|||
|
|||
} |
|||
|
|||
public void createAfter(JSONObject param) throws BadRequestException { |
|||
|
|||
} |
|||
} |
@ -1 +0,0 @@ |
|||
package org.nl.wms.sch.task_manage.task.core; |
@ -1,11 +0,0 @@ |
|||
package org.nl.wms.sch.task_manage.task.core; |
|||
|
|||
/** |
|||
* @author ldjun |
|||
* @version 1.0 |
|||
* @date 2023年05月08日 13:41 |
|||
* @desc desc |
|||
*/ |
|||
public class TaskDto { |
|||
private String task_code; |
|||
} |
@ -1,233 +0,0 @@ |
|||
package org.nl.wms.sch.task_manage.task.tasks.fj; |
|||
|
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import org.nl.common.exception.BadRequestException; |
|||
import org.nl.system.service.notice.ISysNoticeService; |
|||
import org.nl.wms.sch.point.service.ISchBasePointService; |
|||
import org.nl.wms.sch.point.service.dao.SchBasePoint; |
|||
import org.nl.wms.sch.task.service.ISchBaseTaskService; |
|||
import org.nl.wms.sch.task.service.ISchBaseTaskconfigService; |
|||
import org.nl.wms.sch.task.service.dao.SchBaseTask; |
|||
import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig; |
|||
import org.nl.wms.sch.task_manage.AbstractTask; |
|||
import org.nl.wms.sch.task_manage.GeneralDefinition; |
|||
import org.nl.wms.sch.task_manage.enums.GroupBindMaterialStatusEnum; |
|||
import org.nl.wms.sch.task_manage.enums.NoticeTypeEnum; |
|||
import org.nl.wms.sch.task_manage.enums.PointStatusEnum; |
|||
import org.nl.wms.sch.task_manage.enums.TaskFinishedTypeEnum; |
|||
import org.nl.wms.sch.task_manage.task.TaskType; |
|||
import org.nl.wms.sch.task_manage.task.core.TaskStatus; |
|||
import org.nl.wms.util.PointUtils; |
|||
import org.nl.wms.util.TaskUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* @Author: lyd |
|||
* @Description: 分拣回收剩料 |
|||
* @Date: 2023/7/20 |
|||
*/ |
|||
@Component(value = "FJSLHSTask") |
|||
@TaskType("FJSLHSTask") |
|||
public class FJSLTask extends AbstractTask { |
|||
private static final String TASK_CONFIG_CODE = "FJSLHSTask"; |
|||
@Autowired |
|||
private ISchBasePointService pointService; |
|||
@Autowired |
|||
private ISchBaseTaskService taskService; |
|||
@Autowired |
|||
private ISchBaseTaskconfigService taskConfigService; |
|||
|
|||
@Autowired |
|||
private ISysNoticeService noticeService; |
|||
|
|||
@Override |
|||
public void create() throws BadRequestException { |
|||
// 获取任务
|
|||
List<SchBaseTask> tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY); |
|||
// 配置信息
|
|||
SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>() |
|||
.eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE)); |
|||
for (SchBaseTask task : tasks) { |
|||
TaskUtils.setUpdateByAcs(task); |
|||
List<String> nextRegionStr = Arrays.stream(taskConfig.getNext_region_str().split(",")) |
|||
.collect(Collectors.toList()); |
|||
// 找终点
|
|||
String requestParam = task.getRequest_param(); |
|||
JSONObject jsonObject = JSONObject.parseObject(requestParam); |
|||
SchBasePoint point = findNextPoint(nextRegionStr, jsonObject); |
|||
if (ObjectUtil.isEmpty(point)) { |
|||
task.setRemark("分拣机械手[" + task.getPoint_code1() + "]未找到所需点位!"); |
|||
taskService.updateById(task); |
|||
// 消息通知
|
|||
noticeService.createNotice(task.getRemark(), TASK_CONFIG_CODE + task.getTask_code(), |
|||
NoticeTypeEnum.WARN.getCode()); |
|||
continue; |
|||
} |
|||
// 设置终点并修改创建成功状态
|
|||
task.setPoint_code2(point.getPoint_code()); |
|||
task.setTask_status(TaskStatus.CREATED.getCode()); |
|||
task.setRemark(""); |
|||
TaskUtils.setUpdateByAcs(task); |
|||
taskService.updateById(task); |
|||
|
|||
point.setIng_task_code(task.getTask_code()); |
|||
PointUtils.setUpdateByAcs(point); |
|||
pointService.updateById(point); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void createCompletion(SchBaseTask task) { |
|||
// 配置信息
|
|||
SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>() |
|||
.eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE)); |
|||
TaskUtils.setUpdateByAcs(task); |
|||
List<String> nextRegionStr = Arrays.stream(taskConfig.getNext_region_str().split(",")) |
|||
.collect(Collectors.toList()); |
|||
// 找终点
|
|||
String requestParam = task.getRequest_param(); |
|||
JSONObject jsonObject = JSONObject.parseObject(requestParam); |
|||
SchBasePoint point = findNextPoint(nextRegionStr, jsonObject); |
|||
if (ObjectUtil.isEmpty(point)) { |
|||
// 消息通知
|
|||
noticeService.createNotice("分拣机械手[" + task.getPoint_code1() + "]未找到所需点位!", TASK_CONFIG_CODE + task.getPoint_code1(), |
|||
NoticeTypeEnum.WARN.getCode()); |
|||
throw new BadRequestException("分拣机械手[" + task.getPoint_code1() + "]未找到所需点位!"); |
|||
} |
|||
// 设置组盘 - 需要的话由子类自行实现
|
|||
task.setGroup_id(setGroupPlate(jsonObject)); |
|||
// 设置终点并修改创建成功状态
|
|||
task.setPoint_code2(point.getPoint_code()); |
|||
task.setTask_status(TaskStatus.CREATED.getCode()); |
|||
task.setRemark(""); |
|||
task.setVehicle_type(GeneralDefinition.STEEL_TRAY); |
|||
TaskUtils.setUpdateByAcs(task); |
|||
taskService.save(task); |
|||
|
|||
point.setIng_task_code(task.getTask_code()); |
|||
PointUtils.setUpdateByAcs(point); |
|||
pointService.updateById(point); |
|||
} |
|||
|
|||
private SchBasePoint findNextPoint(List<String> nextRegionStr, JSONObject jsonObject) { |
|||
LambdaQueryWrapper<SchBasePoint> lam = new QueryWrapper<SchBasePoint>().lambda(); |
|||
lam.in(SchBasePoint::getRegion_code, nextRegionStr) |
|||
.eq(SchBasePoint::getPoint_status, PointStatusEnum.EMPTY_POINT.getCode()) |
|||
// 当前执行的任务为空或者NULL,有数据表示锁住
|
|||
.and(la -> la.isNull(SchBasePoint::getIng_task_code) |
|||
.or() |
|||
.eq(SchBasePoint::getIng_task_code, "")) |
|||
.eq(SchBasePoint::getIs_used, true) |
|||
.ne(SchBasePoint::getLayer_num, "3") |
|||
.orderByAsc(SchBasePoint::getIn_order_seq) |
|||
.orderByAsc(SchBasePoint::getPoint_code); |
|||
List<SchBasePoint> schBasePoints = pointService.list(lam); |
|||
return ObjectUtil.isNotEmpty(schBasePoints) ? schBasePoints.get(0) : null; |
|||
} |
|||
|
|||
@Override |
|||
public String setGroupPlate(JSONObject param) { |
|||
return null; |
|||
} |
|||
|
|||
@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("执行中"); |
|||
TaskUtils.setUpdateByAcs(taskObj); |
|||
taskService.updateById(taskObj); |
|||
} |
|||
if (status.equals(TaskStatus.FINISHED)) { |
|||
this.finishTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); |
|||
} |
|||
if (status.equals(TaskStatus.CANCELED)) { |
|||
this.cancelTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void forceFinish(String task_code) { |
|||
SchBaseTask taskObj = taskService.getByCode(task_code); |
|||
if (ObjectUtil.isEmpty(taskObj)) { |
|||
throw new BadRequestException("该任务不存在"); |
|||
} |
|||
this.finishTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); |
|||
} |
|||
|
|||
@Override |
|||
public void cancel(String task_code) { |
|||
SchBaseTask taskObj = taskService.getByCode(task_code); |
|||
if (ObjectUtil.isEmpty(taskObj)) { |
|||
throw new BadRequestException("该任务不存在"); |
|||
} |
|||
this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); |
|||
} |
|||
|
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { |
|||
String vehicleCode = taskObj.getVehicle_code(); |
|||
String vehicleType = taskObj.getVehicle_type(); |
|||
String startPoint = taskObj.getPoint_code1(); |
|||
String endPoint = taskObj.getPoint_code2(); |
|||
SchBasePoint startPointObj = pointService.getById(startPoint); |
|||
SchBasePoint endPointObj = pointService.getById(endPoint); |
|||
if (ObjectUtil.isNotEmpty(endPointObj)) { |
|||
// 记录库存并解锁
|
|||
endPointObj.setIng_task_code(""); |
|||
endPointObj.setVehicle_code(vehicleCode); |
|||
endPointObj.setVehicle_qty(1); |
|||
endPointObj.setVehicle_type(vehicleType); |
|||
endPointObj.setPoint_status(PointStatusEnum.FULL_POINT.getCode()); |
|||
PointUtils.setUpdateByType(endPointObj, taskFinishedType); |
|||
pointService.updateById(endPointObj); |
|||
} |
|||
// 起点清空
|
|||
PointUtils.setUpdateByType(startPointObj, taskFinishedType); |
|||
PointUtils.clearPoint(startPointObj); |
|||
|
|||
// 任务完成
|
|||
taskObj.setTask_status(TaskStatus.FINISHED.getCode()); |
|||
taskObj.setRemark(GeneralDefinition.TASK_FINISH); |
|||
taskObj.setFinished_type(taskFinishedType.getCode()); |
|||
TaskUtils.setUpdateByType(taskObj, taskFinishedType); |
|||
taskService.updateById(taskObj); |
|||
} |
|||
|
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { |
|||
// 获取参数
|
|||
String endPoint = taskObj.getPoint_code2(); |
|||
SchBasePoint endPointObj = pointService.getById(endPoint); |
|||
// 终点解锁
|
|||
if (ObjectUtil.isNotEmpty(endPointObj)) { |
|||
endPointObj.setIng_task_code(""); |
|||
PointUtils.setUpdateByType(endPointObj, taskFinishedType); |
|||
pointService.updateById(endPointObj); |
|||
} |
|||
taskObj.setRemark(GeneralDefinition.TASK_CANCEL); |
|||
taskObj.setTask_status(TaskStatus.CANCELED.getCode()); |
|||
taskObj.setFinished_type(taskFinishedType.getCode()); |
|||
TaskUtils.setUpdateByType(taskObj, taskFinishedType); |
|||
taskService.updateById(taskObj); |
|||
} |
|||
} |
@ -0,0 +1,132 @@ |
|||
package org.nl.wms.sch.task_manage.task.tasks.fj; |
|||
|
|||
import cn.hutool.core.date.DateUtil; |
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import org.nl.common.exception.BadRequestException; |
|||
import org.nl.common.utils.SecurityUtils; |
|||
import org.nl.config.IdUtil; |
|||
import org.nl.wms.sch.task.service.ISchBaseTaskService; |
|||
import org.nl.wms.sch.task.service.ISchBaseTaskconfigService; |
|||
import org.nl.wms.sch.task.service.dao.SchBaseTask; |
|||
import org.nl.wms.sch.task_manage.AbstractTask; |
|||
import org.nl.wms.sch.task_manage.AcsTaskDto; |
|||
import org.nl.wms.sch.task_manage.GeneralDefinition; |
|||
import org.nl.wms.sch.task_manage.enums.TaskFinishedTypeEnum; |
|||
import org.nl.wms.sch.task_manage.task.TaskType; |
|||
import org.nl.wms.sch.task_manage.task.core.TaskStatus; |
|||
import org.nl.wms.util.TaskUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
/** |
|||
* @Author: lxy |
|||
* @Description: AB区送满托盘到C区 |
|||
* @Date: 2024/9/24 |
|||
*/ |
|||
@Component(value = "MABCTask") |
|||
@TaskType("MABCTask") |
|||
public class MABCTask extends AbstractTask { |
|||
@Autowired |
|||
private ISchBaseTaskService taskService; |
|||
|
|||
@Autowired |
|||
private ISchBaseTaskconfigService taskConfigService; |
|||
|
|||
@Override |
|||
public String create(JSONObject json) { |
|||
SchBaseTask task = new SchBaseTask(); |
|||
task.setTask_id(IdUtil.getStringId()); |
|||
task.setTask_code(json.getString("TaskCode")); |
|||
task.setTask_status(TaskStatus.CREATE.getCode()); |
|||
task.setConfig_code(json.getString("task_type")); |
|||
task.setPoint_code1(json.getString("PickingLocation")); |
|||
task.setPoint_code2(json.getString("PlacedLocation")); |
|||
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(taskDao.getConfig_code()); |
|||
|
|||
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("执行中"); |
|||
TaskUtils.setUpdateByAcs(taskObj); |
|||
taskService.updateById(taskObj); |
|||
} |
|||
if (status.equals(TaskStatus.FINISHED)) { |
|||
this.finishTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); |
|||
} |
|||
if (status.equals(TaskStatus.CANCELED)) { |
|||
this.cancelTask(taskObj, TaskFinishedTypeEnum.AUTO_ACS); |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public void forceFinish(String task_code) { |
|||
SchBaseTask taskObj = taskService.getByCode(task_code); |
|||
if (ObjectUtil.isEmpty(taskObj)) { |
|||
throw new BadRequestException("该任务不存在"); |
|||
} |
|||
this.finishTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); |
|||
} |
|||
|
|||
@Override |
|||
public void cancel(String task_code) { |
|||
SchBaseTask taskObj = taskService.getByCode(task_code); |
|||
if (ObjectUtil.isEmpty(taskObj)) { |
|||
throw new BadRequestException("该任务不存在"); |
|||
} |
|||
this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_PC); |
|||
} |
|||
|
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { |
|||
// 任务完成
|
|||
taskObj.setTask_status(TaskStatus.FINISHED.getCode()); |
|||
taskObj.setRemark(GeneralDefinition.TASK_FINISH); |
|||
taskObj.setFinished_type(taskFinishedType.getCode()); |
|||
TaskUtils.setUpdateByType(taskObj, taskFinishedType); |
|||
taskService.updateById(taskObj); |
|||
} |
|||
|
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { |
|||
taskObj.setRemark(GeneralDefinition.TASK_CANCEL); |
|||
taskObj.setTask_status(TaskStatus.CANCELED.getCode()); |
|||
taskObj.setFinished_type(taskFinishedType.getCode()); |
|||
TaskUtils.setUpdateByType(taskObj, taskFinishedType); |
|||
taskService.updateById(taskObj); |
|||
} |
|||
} |
Loading…
Reference in new issue