李永德
1 year ago
20 changed files with 491 additions and 442 deletions
@ -1,166 +1,166 @@ |
|||
//package org.nl.wms.sch.task_manage.task.tasks.hn;
|
|||
//
|
|||
//import cn.hutool.core.date.DateUtil;
|
|||
//import cn.hutool.core.util.ObjectUtil;
|
|||
//import com.alibaba.fastjson.JSONObject;
|
|||
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
//import org.nl.common.exception.BadRequestException;
|
|||
//import org.nl.wms.pdm.service.IPdmBdWorkorderService;
|
|||
//import org.nl.wms.pdm.service.dao.PdmBdWorkorder;
|
|||
//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.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.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/5/19
|
|||
// */
|
|||
//@Component
|
|||
//@TaskType("HLQKTask")
|
|||
//public class HNQKTask extends AbstractTask {
|
|||
// private static String TASK_CONFIG_CODE = "HLQKTask";
|
|||
// private static String EMPTY_ZHONG = "1";
|
|||
//
|
|||
// @Autowired
|
|||
// private ISchBasePointService pointService;
|
|||
// @Autowired
|
|||
// private ISchBaseTaskService taskService;
|
|||
// @Autowired
|
|||
// private ISchBaseTaskconfigService taskConfigService;
|
|||
// @Autowired
|
|||
// private IPdmBdWorkorderService workorderService;
|
|||
//
|
|||
// /**
|
|||
// * 具体业务
|
|||
// */
|
|||
// @Override
|
|||
// @Transactional(rollbackFor = Exception.class)
|
|||
// protected void create() {
|
|||
// // 获取任务
|
|||
// 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) {
|
|||
// List<String> startRegionStr = Arrays.stream(taskConfig.getStart_region_str().split(",")).collect(Collectors.toList());
|
|||
// // 找起点
|
|||
// String extGroupData = task.getExt_group_data();
|
|||
// JSONObject jsonObject = JSONObject.parseObject(extGroupData);
|
|||
// SchBasePoint point = findStartPoint(startRegionStr, jsonObject);
|
|||
// if (ObjectUtil.isEmpty(point)) {
|
|||
// task.setRemark("未找到所需点位!");
|
|||
// taskService.update(task);
|
|||
// // 消息通知
|
|||
// continue;
|
|||
// }
|
|||
// // 设置终点并修改创建成功状态
|
|||
// task.setPoint_code1(point.getPoint_code());
|
|||
// task.setRemark("");
|
|||
// task.setTask_status(TaskStatus.CREATED.getCode());
|
|||
// taskService.update(task);
|
|||
//
|
|||
// point.setIng_task_code(task.getTask_code());
|
|||
// pointService.update(point);
|
|||
//
|
|||
// //下发
|
|||
//// this.renotifyAcs(task);
|
|||
// }
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 找起点, 通过料盅睏料线区域的空盅位置找到空盅
|
|||
// *
|
|||
// * @param startRegionStr
|
|||
// * @param extGroupData
|
|||
// * @return
|
|||
// */
|
|||
// private SchBasePoint findStartPoint(List<String> startRegionStr, JSONObject extGroupData) {
|
|||
// LambdaQueryWrapper<SchBasePoint> lam = new LambdaQueryWrapper<>();
|
|||
// lam.in(SchBasePoint::getRegion_code, startRegionStr)
|
|||
// .eq(SchBasePoint::getPoint_status, PointStatusEnum.EMPTY_VEHICLE.getCode())
|
|||
// .eq(SchBasePoint::getPoint_type, EMPTY_ZHONG)
|
|||
// .and(la -> la.isNull(SchBasePoint::getIng_task_code) // 当前执行的任务为空或者NULL,有数据表示锁住
|
|||
// .or()
|
|||
// .eq(SchBasePoint::getIng_task_code, ""))
|
|||
// .orderByAsc(SchBasePoint::getIn_order_seq)
|
|||
// .orderByAsc(SchBasePoint::getPoint_code);
|
|||
// List<SchBasePoint> schBasePoints = pointService.list(lam);
|
|||
// return ObjectUtil.isNotEmpty(schBasePoints) ? schBasePoints.get(0) : null;
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// @Transactional(rollbackFor = Exception.class)
|
|||
// 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("该任务已取消!");
|
|||
// }
|
|||
// // 获取参数
|
|||
// String startPoint = taskObj.getPoint_code1(); // 获取起点
|
|||
// String endPoint = taskObj.getPoint_code2(); // 获取起点
|
|||
// SchBasePoint startPointObj = pointService.getById(startPoint);
|
|||
// SchBasePoint endPointObj = pointService.getById(endPoint);
|
|||
// // 根据传来的类型去对任务进行操作
|
|||
// if (status.equals(TaskStatus.EXECUTING)) { // 执行中
|
|||
// taskObj.setTask_status(TaskStatus.EXECUTING.getCode());
|
|||
// taskObj.setRemark("执行中");
|
|||
// }
|
|||
// if (status.equals(TaskStatus.FINISHED)) { // 完成
|
|||
// // 起点清空
|
|||
// if (ObjectUtil.isNotEmpty(startPointObj)) {
|
|||
// PointUtils.clearPoint(startPointObj);
|
|||
// taskObj.setVehicle_code(startPointObj.getVehicle_code());
|
|||
// endPointObj.setPoint_status(PointStatusEnum.EMPTY_VEHICLE.getCode());
|
|||
// endPointObj.setVehicle_type("1");
|
|||
// endPointObj.setVehicle_code(startPointObj.getVehicle_code());
|
|||
// endPointObj.setVehicle_qty(1);
|
|||
// endPointObj.setUpdate_time(DateUtil.now());
|
|||
// pointService.updateById(endPointObj);
|
|||
// }
|
|||
// // 任务完成
|
|||
// taskObj.setTask_status(TaskStatus.FINISHED.getCode());
|
|||
// taskObj.setRemark(GeneralDefinition.TASK_FINISH);
|
|||
// }
|
|||
// if (status.equals(TaskStatus.CANCELED)) { // 取消
|
|||
// // 起点解锁
|
|||
// if (ObjectUtil.isNotEmpty(startPointObj)) {
|
|||
// startPointObj.setIng_task_code("");
|
|||
// pointService.update(startPointObj);
|
|||
// }
|
|||
// taskObj.setTask_status(TaskStatus.CANCELED.getCode());
|
|||
// }
|
|||
// taskService.update(taskObj);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public void forceFinish(String task_code) {
|
|||
// this.updateStatus(task_code, TaskStatus.FINISHED);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public void cancel(String task_code) {
|
|||
// this.updateStatus(task_code, TaskStatus.CANCELED);
|
|||
// }
|
|||
//}
|
|||
//
|
|||
package org.nl.wms.sch.task_manage.task.tasks.hn; |
|||
|
|||
import cn.hutool.core.date.DateUtil; |
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import org.nl.common.exception.BadRequestException; |
|||
import org.nl.wms.pdm.workorder.service.IPdmBdWorkorderService; |
|||
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.PointStatusEnum; |
|||
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.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/5/19 |
|||
*/ |
|||
@Deprecated |
|||
@Component |
|||
@TaskType("--") |
|||
public class HNQKTask extends AbstractTask { |
|||
private static String TASK_CONFIG_CODE = "--"; |
|||
private static String EMPTY_ZHONG = "1"; |
|||
|
|||
@Autowired |
|||
private ISchBasePointService pointService; |
|||
@Autowired |
|||
private ISchBaseTaskService taskService; |
|||
@Autowired |
|||
private ISchBaseTaskconfigService taskConfigService; |
|||
@Autowired |
|||
private IPdmBdWorkorderService workorderService; |
|||
|
|||
/** |
|||
* 具体业务 |
|||
*/ |
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
protected void create() { |
|||
// 获取任务
|
|||
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) { |
|||
List<String> startRegionStr = Arrays.stream(taskConfig.getStart_region_str().split(",")).collect(Collectors.toList()); |
|||
// 找起点
|
|||
String extGroupData = task.getExt_group_data(); |
|||
JSONObject jsonObject = JSONObject.parseObject(extGroupData); |
|||
SchBasePoint point = findStartPoint(startRegionStr, jsonObject); |
|||
if (ObjectUtil.isEmpty(point)) { |
|||
task.setRemark("未找到所需点位!"); |
|||
taskService.update(task); |
|||
// 消息通知
|
|||
continue; |
|||
} |
|||
// 设置终点并修改创建成功状态
|
|||
task.setPoint_code1(point.getPoint_code()); |
|||
task.setRemark(""); |
|||
task.setTask_status(TaskStatus.CREATED.getCode()); |
|||
taskService.update(task); |
|||
|
|||
point.setIng_task_code(task.getTask_code()); |
|||
pointService.update(point); |
|||
|
|||
//下发
|
|||
// this.renotifyAcs(task);
|
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 找起点, 通过料盅睏料线区域的空盅位置找到空盅 |
|||
* |
|||
* @param startRegionStr |
|||
* @param extGroupData |
|||
* @return |
|||
*/ |
|||
private SchBasePoint findStartPoint(List<String> startRegionStr, JSONObject extGroupData) { |
|||
LambdaQueryWrapper<SchBasePoint> lam = new LambdaQueryWrapper<>(); |
|||
lam.in(SchBasePoint::getRegion_code, startRegionStr) |
|||
.eq(SchBasePoint::getPoint_status, PointStatusEnum.EMPTY_VEHICLE.getCode()) |
|||
.eq(SchBasePoint::getPoint_type, EMPTY_ZHONG) |
|||
.and(la -> la.isNull(SchBasePoint::getIng_task_code) // 当前执行的任务为空或者NULL,有数据表示锁住
|
|||
.or() |
|||
.eq(SchBasePoint::getIng_task_code, "")) |
|||
.orderByAsc(SchBasePoint::getIn_order_seq) |
|||
.orderByAsc(SchBasePoint::getPoint_code); |
|||
List<SchBasePoint> schBasePoints = pointService.list(lam); |
|||
return ObjectUtil.isNotEmpty(schBasePoints) ? schBasePoints.get(0) : null; |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
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("该任务已取消!"); |
|||
} |
|||
// 获取参数
|
|||
String startPoint = taskObj.getPoint_code1(); // 获取起点
|
|||
String endPoint = taskObj.getPoint_code2(); // 获取起点
|
|||
SchBasePoint startPointObj = pointService.getById(startPoint); |
|||
SchBasePoint endPointObj = pointService.getById(endPoint); |
|||
// 根据传来的类型去对任务进行操作
|
|||
if (status.equals(TaskStatus.EXECUTING)) { // 执行中
|
|||
taskObj.setTask_status(TaskStatus.EXECUTING.getCode()); |
|||
taskObj.setRemark("执行中"); |
|||
} |
|||
if (status.equals(TaskStatus.FINISHED)) { // 完成
|
|||
// 起点清空
|
|||
if (ObjectUtil.isNotEmpty(startPointObj)) { |
|||
PointUtils.clearPoint(startPointObj); |
|||
taskObj.setVehicle_code(startPointObj.getVehicle_code()); |
|||
endPointObj.setPoint_status(PointStatusEnum.EMPTY_VEHICLE.getCode()); |
|||
endPointObj.setVehicle_type("1"); |
|||
endPointObj.setVehicle_code(startPointObj.getVehicle_code()); |
|||
endPointObj.setVehicle_qty(1); |
|||
endPointObj.setUpdate_time(DateUtil.now()); |
|||
pointService.updateById(endPointObj); |
|||
} |
|||
// 任务完成
|
|||
taskObj.setTask_status(TaskStatus.FINISHED.getCode()); |
|||
taskObj.setRemark(GeneralDefinition.TASK_FINISH); |
|||
} |
|||
if (status.equals(TaskStatus.CANCELED)) { // 取消
|
|||
// 起点解锁
|
|||
if (ObjectUtil.isNotEmpty(startPointObj)) { |
|||
startPointObj.setIng_task_code(""); |
|||
pointService.update(startPointObj); |
|||
} |
|||
taskObj.setTask_status(TaskStatus.CANCELED.getCode()); |
|||
} |
|||
taskService.update(taskObj); |
|||
} |
|||
|
|||
@Override |
|||
public void forceFinish(String task_code) { |
|||
this.updateStatus(task_code, TaskStatus.FINISHED); |
|||
} |
|||
|
|||
@Override |
|||
public void cancel(String task_code) { |
|||
this.updateStatus(task_code, TaskStatus.CANCELED); |
|||
} |
|||
} |
|||
|
|||
|
@ -1,171 +1,171 @@ |
|||
//package org.nl.wms.sch.task_manage.task.tasks.yz;
|
|||
//
|
|||
//import cn.hutool.core.lang.Assert;
|
|||
//import cn.hutool.core.util.ObjectUtil;
|
|||
//import com.alibaba.fastjson.JSONObject;
|
|||
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
//import lombok.extern.slf4j.Slf4j;
|
|||
//import org.nl.common.exception.BadRequestException;
|
|||
//import org.nl.wms.pdm.service.IPdmBdWorkorderService;
|
|||
//import org.nl.wms.pdm.service.dao.PdmBdWorkorder;
|
|||
//import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService;
|
|||
//import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup;
|
|||
//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.enums.GroupBindMaterialStatusEnum;
|
|||
//import org.nl.wms.sch.task_manage.enums.PointStatusEnum;
|
|||
//import org.nl.wms.sch.task_manage.task.TaskType;
|
|||
//import org.nl.wms.sch.task_manage.task.core.TaskStatus;
|
|||
//import org.nl.wms.sch.task_manage.task.tasks.yz.mapper.YZMapper;
|
|||
//import org.nl.wms.util.PointUtils;
|
|||
//import org.springframework.beans.factory.annotation.Autowired;
|
|||
//import org.springframework.stereotype.Component;
|
|||
//
|
|||
//import java.util.Arrays;
|
|||
//import java.util.List;
|
|||
//import java.util.stream.Collectors;
|
|||
//
|
|||
///**
|
|||
// * @Author: lyd
|
|||
// * @Description: 压制缺料任务
|
|||
// * @Date: 2023/5/25
|
|||
// */
|
|||
//@Slf4j
|
|||
//@Component
|
|||
//@TaskType("YZQLTask")
|
|||
//public class YZQLTask extends AbstractTask {
|
|||
// private static String TASK_CONFIG_CODE = "YZQLTask";
|
|||
//
|
|||
// @Autowired
|
|||
// private ISchBasePointService pointService;
|
|||
// @Autowired
|
|||
// private ISchBaseTaskService taskService;
|
|||
// @Autowired
|
|||
// private ISchBaseTaskconfigService taskConfigService;
|
|||
// @Autowired
|
|||
// private ISchBaseVehiclematerialgroupService vehiclematerialgroupService;
|
|||
// @Autowired
|
|||
// private IPdmBdWorkorderService workorderService;
|
|||
// @Autowired
|
|||
// private YZMapper yzMapper;
|
|||
//
|
|||
// @Override
|
|||
// protected 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) {
|
|||
// List<String> startRegionStr = Arrays.stream(taskConfig.getStart_region_str().split(",")).collect(Collectors.toList());
|
|||
// // 找起点
|
|||
// String extGroupData = task.getExt_group_data();
|
|||
// JSONObject jsonObject = JSONObject.parseObject(extGroupData);
|
|||
// jsonObject.put("vehicle_type", task.getVehicle_type());
|
|||
// SchBasePoint point = findStartPoint(startRegionStr, jsonObject);
|
|||
// if (ObjectUtil.isEmpty(point)) {
|
|||
// task.setRemark("未找到所需点位!");
|
|||
// taskService.update(task);
|
|||
// // 消息通知
|
|||
// continue;
|
|||
// }
|
|||
// // 设置起点并修改创建成功状态
|
|||
// task.setPoint_code1(point.getPoint_code());
|
|||
// task.setTask_status(TaskStatus.CREATED.getCode());
|
|||
// task.setVehicle_code(point.getVehicle_code());
|
|||
// taskService.update(task);
|
|||
//
|
|||
// point.setIng_task_code(task.getTask_code());
|
|||
// pointService.update(point);
|
|||
//
|
|||
// //下发
|
|||
//// this.renotifyAcs(task);
|
|||
// }
|
|||
// }
|
|||
//
|
|||
// /**
|
|||
// * 找起点业务:混碾机工单的物料标识相同的位置
|
|||
// *
|
|||
// * @param startRegionStr : 区域列表
|
|||
// * @param extGroupData : 外部参数,包含条件所需的信息
|
|||
// * @return
|
|||
// * @description : JSONObject获取不到就是null
|
|||
// */
|
|||
// private SchBasePoint findStartPoint(List<String> startRegionStr, JSONObject extGroupData) {
|
|||
// // 获取当前工单
|
|||
// String workorderCode = extGroupData.getString("workorder_code");
|
|||
// PdmBdWorkorder workOrder = ObjectUtil.isNotEmpty(workorderCode)
|
|||
// ? workorderService.getOne(new LambdaQueryWrapper<PdmBdWorkorder>()
|
|||
// .eq(PdmBdWorkorder::getWorkorder_code, workorderCode))
|
|||
// : null;
|
|||
// Assert.notNull(workOrder, "工单不能为空!");
|
|||
// // 查找混碾机工单的物料相同的位置
|
|||
// List<SchBasePoint> points = yzMapper.findPointForYZQL(startRegionStr, workOrder.getMaterial_id());
|
|||
// return ObjectUtil.isNotEmpty(points) ? points.get(0) : 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("该任务已取消!");
|
|||
// }
|
|||
// // 获取参数
|
|||
// String startPoint = taskObj.getPoint_code1(); // 起点
|
|||
// JSONObject extGroupData = ObjectUtil.isNotEmpty(taskObj.getExt_group_data())
|
|||
// ? JSONObject.parseObject(taskObj.getExt_group_data())
|
|||
// : null;
|
|||
// SchBasePoint startPointObj = pointService.getById(startPoint);
|
|||
// // 根据传来的类型去对任务进行操作
|
|||
// if (status.equals(TaskStatus.EXECUTING)) { // 执行中
|
|||
// taskObj.setTask_status(TaskStatus.EXECUTING.getCode());
|
|||
// taskObj.setRemark("执行中");
|
|||
// }
|
|||
// if (status.equals(TaskStatus.FINISHED)) { // 完成
|
|||
// // 任务上有载具编码 -> 获取当前载具编码的组盘信息
|
|||
// SchBaseVehiclematerialgroup one = vehiclematerialgroupService.getOne(new LambdaQueryWrapper<SchBaseVehiclematerialgroup>()
|
|||
// .eq(SchBaseVehiclematerialgroup::getVehicle_code, taskObj.getVehicle_code())
|
|||
// .eq(SchBaseVehiclematerialgroup::getVehicle_type, taskObj.getVehicle_type())
|
|||
// .eq(SchBaseVehiclematerialgroup::getGroup_bind_material_status, GroupBindMaterialStatusEnum.BOUND.getValue()));
|
|||
// // 将载具设置为已解绑
|
|||
// one.setGroup_bind_material_status(GroupBindMaterialStatusEnum.UNBOUND.getValue());
|
|||
// vehiclematerialgroupService.update(one);
|
|||
// // 释放点位,将点位设置为空位,清空数据
|
|||
// if (ObjectUtil.isNotEmpty(startPointObj)) {
|
|||
// PointUtils.clearPoint(startPointObj);
|
|||
// // todo: 终点暂时无设置
|
|||
// }
|
|||
// // 任务修改成完成
|
|||
// taskObj.setTask_status(TaskStatus.FINISHED.getCode());
|
|||
// }
|
|||
// if (status.equals(TaskStatus.CANCELED)) { // 取消
|
|||
// taskObj.setTask_status(TaskStatus.CANCELED.getCode());
|
|||
// // 释放点位,起点正在执行的任务清空
|
|||
// if (ObjectUtil.isNotEmpty(startPointObj)) {
|
|||
// startPointObj.setIng_task_code("");
|
|||
// pointService.update(startPointObj);
|
|||
// }
|
|||
// }
|
|||
// taskService.update(taskObj);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public void forceFinish(String task_code) {
|
|||
// this.updateStatus(task_code, TaskStatus.FINISHED);
|
|||
// }
|
|||
//
|
|||
// @Override
|
|||
// public void cancel(String task_code) {
|
|||
// this.updateStatus(task_code, TaskStatus.CANCELED);
|
|||
// }
|
|||
//}
|
|||
package org.nl.wms.sch.task_manage.task.tasks.yz; |
|||
|
|||
import cn.hutool.core.lang.Assert; |
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.common.exception.BadRequestException; |
|||
import org.nl.wms.pdm.workorder.service.IPdmBdWorkorderService; |
|||
import org.nl.wms.pdm.workorder.service.dao.PdmBdWorkorder; |
|||
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService; |
|||
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup; |
|||
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.enums.GroupBindMaterialStatusEnum; |
|||
import org.nl.wms.sch.task_manage.task.TaskType; |
|||
import org.nl.wms.sch.task_manage.task.core.TaskStatus; |
|||
import org.nl.wms.sch.task_manage.task.tasks.yz.mapper.YZMapper; |
|||
import org.nl.wms.util.PointUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* @Author: lyd |
|||
* @Description: 压制缺料任务 |
|||
* @Date: 2023/5/25 |
|||
*/ |
|||
@Slf4j |
|||
@Deprecated |
|||
@Component |
|||
@TaskType("-") |
|||
public class YZQLTask extends AbstractTask { |
|||
private static String TASK_CONFIG_CODE = "-"; |
|||
|
|||
@Autowired |
|||
private ISchBasePointService pointService; |
|||
@Autowired |
|||
private ISchBaseTaskService taskService; |
|||
@Autowired |
|||
private ISchBaseTaskconfigService taskConfigService; |
|||
@Autowired |
|||
private ISchBaseVehiclematerialgroupService vehiclematerialgroupService; |
|||
@Autowired |
|||
private IPdmBdWorkorderService workorderService; |
|||
@Autowired |
|||
private YZMapper yzMapper; |
|||
|
|||
@Override |
|||
protected 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) { |
|||
List<String> startRegionStr = Arrays.stream(taskConfig.getStart_region_str().split(",")).collect(Collectors.toList()); |
|||
// 找起点
|
|||
String extGroupData = task.getExt_group_data(); |
|||
JSONObject jsonObject = JSONObject.parseObject(extGroupData); |
|||
jsonObject.put("vehicle_type", task.getVehicle_type()); |
|||
SchBasePoint point = findStartPoint(startRegionStr, jsonObject); |
|||
if (ObjectUtil.isEmpty(point)) { |
|||
task.setRemark("未找到所需点位!"); |
|||
taskService.update(task); |
|||
// 消息通知
|
|||
continue; |
|||
} |
|||
// 设置起点并修改创建成功状态
|
|||
task.setPoint_code1(point.getPoint_code()); |
|||
task.setTask_status(TaskStatus.CREATED.getCode()); |
|||
task.setVehicle_code(point.getVehicle_code()); |
|||
taskService.update(task); |
|||
|
|||
point.setIng_task_code(task.getTask_code()); |
|||
pointService.update(point); |
|||
|
|||
//下发
|
|||
// this.renotifyAcs(task);
|
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 找起点业务:混碾机工单的物料标识相同的位置 |
|||
* |
|||
* @param startRegionStr : 区域列表 |
|||
* @param extGroupData : 外部参数,包含条件所需的信息 |
|||
* @return |
|||
* @description : JSONObject获取不到就是null |
|||
*/ |
|||
private SchBasePoint findStartPoint(List<String> startRegionStr, JSONObject extGroupData) { |
|||
// 获取当前工单
|
|||
String workorderCode = extGroupData.getString("workorder_code"); |
|||
PdmBdWorkorder workOrder = ObjectUtil.isNotEmpty(workorderCode) |
|||
? workorderService.getOne(new LambdaQueryWrapper<PdmBdWorkorder>() |
|||
.eq(PdmBdWorkorder::getWorkorder_code, workorderCode)) |
|||
: null; |
|||
Assert.notNull(workOrder, "工单不能为空!"); |
|||
// 查找混碾机工单的物料相同的位置
|
|||
List<SchBasePoint> points = yzMapper.findPointForYZQL(startRegionStr, workOrder.getMaterial_id()); |
|||
return ObjectUtil.isNotEmpty(points) ? points.get(0) : 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("该任务已取消!"); |
|||
} |
|||
// 获取参数
|
|||
String startPoint = taskObj.getPoint_code1(); // 起点
|
|||
JSONObject extGroupData = ObjectUtil.isNotEmpty(taskObj.getExt_group_data()) |
|||
? JSONObject.parseObject(taskObj.getExt_group_data()) |
|||
: null; |
|||
SchBasePoint startPointObj = pointService.getById(startPoint); |
|||
// 根据传来的类型去对任务进行操作
|
|||
if (status.equals(TaskStatus.EXECUTING)) { // 执行中
|
|||
taskObj.setTask_status(TaskStatus.EXECUTING.getCode()); |
|||
taskObj.setRemark("执行中"); |
|||
} |
|||
if (status.equals(TaskStatus.FINISHED)) { // 完成
|
|||
// 任务上有载具编码 -> 获取当前载具编码的组盘信息
|
|||
SchBaseVehiclematerialgroup one = vehiclematerialgroupService.getOne(new LambdaQueryWrapper<SchBaseVehiclematerialgroup>() |
|||
.eq(SchBaseVehiclematerialgroup::getVehicle_code, taskObj.getVehicle_code()) |
|||
.eq(SchBaseVehiclematerialgroup::getVehicle_type, taskObj.getVehicle_type()) |
|||
.eq(SchBaseVehiclematerialgroup::getGroup_bind_material_status, GroupBindMaterialStatusEnum.BOUND.getValue())); |
|||
// 将载具设置为已解绑
|
|||
one.setGroup_bind_material_status(GroupBindMaterialStatusEnum.UNBOUND.getValue()); |
|||
vehiclematerialgroupService.update(one); |
|||
// 释放点位,将点位设置为空位,清空数据
|
|||
if (ObjectUtil.isNotEmpty(startPointObj)) { |
|||
PointUtils.clearPoint(startPointObj); |
|||
// todo: 终点暂时无设置
|
|||
} |
|||
// 任务修改成完成
|
|||
taskObj.setTask_status(TaskStatus.FINISHED.getCode()); |
|||
} |
|||
if (status.equals(TaskStatus.CANCELED)) { // 取消
|
|||
taskObj.setTask_status(TaskStatus.CANCELED.getCode()); |
|||
// 释放点位,起点正在执行的任务清空
|
|||
if (ObjectUtil.isNotEmpty(startPointObj)) { |
|||
startPointObj.setIng_task_code(""); |
|||
pointService.update(startPointObj); |
|||
} |
|||
} |
|||
taskService.update(taskObj); |
|||
} |
|||
|
|||
@Override |
|||
public void forceFinish(String task_code) { |
|||
this.updateStatus(task_code, TaskStatus.FINISHED); |
|||
} |
|||
|
|||
@Override |
|||
public void cancel(String task_code) { |
|||
this.updateStatus(task_code, TaskStatus.CANCELED); |
|||
} |
|||
} |
|||
|
Loading…
Reference in new issue