feat: 烘箱业务
This commit is contained in:
@@ -16,8 +16,8 @@ import org.nl.wms.sch.point.service.ISchBasePointService;
|
||||
import org.nl.wms.sch.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch.task_manage.core.constant.GeneralDefinition;
|
||||
import org.nl.wms.sch.task_manage.core.tasks.raw.RawCallRollTrussTask;
|
||||
import org.nl.wms.sch.task_manage.core.tasks.raw.RawDownAGVTask;
|
||||
import org.nl.wms.sch.task_manage.tasks.raw.RawCallRollTrussTask;
|
||||
import org.nl.wms.sch.task_manage.tasks.raw.RawDownAGVTask;
|
||||
import org.nl.wms.util.TaskUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
@@ -28,10 +28,12 @@
|
||||
FROM sch_base_point p
|
||||
WHERE p.product_area = #{area}
|
||||
AND p.region_code = #{region}
|
||||
AND p.point_type = #{pointType}
|
||||
<if test="pointType != null">
|
||||
AND p.point_type = #{pointType}
|
||||
</if>
|
||||
AND p.point_status = #{pointStatus}
|
||||
AND p.is_used = TRUE
|
||||
AND 0 = (SELECT COUNT(*) FROM sch_base_task t WHERE t.task_status <![CDATA[<]]> '07'
|
||||
AND (t.point_code2 = p.point_code OR t.point_code4 = p.point_code))
|
||||
AND (t.point_code1 = p.point_code OR t.point_code2 = p.point_code OR t.point_code4 = p.point_code))
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -41,4 +41,11 @@ public interface ISchBaseTaskconfigService extends IService<SchBaseTaskconfig> {
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Set<String> ids);
|
||||
|
||||
/**
|
||||
* 获取任务配置
|
||||
* @param code 任务配置编码
|
||||
* @return /
|
||||
*/
|
||||
SchBaseTaskconfig getByConfigCode(String code);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
@@ -99,4 +100,11 @@ public class SchBaseTaskconfigServiceImpl extends ServiceImpl<SchBaseTaskconfigM
|
||||
schBaseTaskconfigMapper.deleteBatchIds(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchBaseTaskconfig getByConfigCode(String code) {
|
||||
LambdaQueryWrapper<SchBaseTaskconfig> lam = new QueryWrapper<SchBaseTaskconfig>().lambda();
|
||||
lam.eq(SchBaseTaskconfig::getConfig_code, code);
|
||||
return getOne(lam);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -102,6 +102,7 @@ public abstract class AbstractTask {
|
||||
List<AcsTaskDto> list = new ArrayList<>();
|
||||
for (SchBaseTask task : taskList) {
|
||||
AcsTaskDto taskDto = new AcsTaskDto();
|
||||
this.setTask(task.getConfig_code(), taskDto);
|
||||
taskDto.setExt_task_id(task.getTask_id());
|
||||
taskDto.setTask_code(task.getTask_code());
|
||||
taskDto.setRoute_plan_code("normal");
|
||||
@@ -111,8 +112,9 @@ public abstract class AbstractTask {
|
||||
taskDto.setNext_device_code2(task.getPoint_code4());
|
||||
taskDto.setVehicle_code(task.getVehicle_code());
|
||||
taskDto.setVehicle_code2(task.getVehicle_code2());
|
||||
this.setTask(task.getConfig_code(), taskDto);
|
||||
// 如果各类方法对返回参数有不同,可以通过调用子类实现的deliveryBeforeProcessing方法来完成赋值,也可以是统一封装到参数值中。
|
||||
taskDto.setProduct_area(task.getProduct_area());
|
||||
// 如果各类方法对返回参数有不同,可以通过调用子类实现的deliveryBeforeProcessing方法来完成赋值,
|
||||
// 也可以是统一封装到参数值中。
|
||||
this.deliveryBeforeProcessing(task, taskDto);
|
||||
list.add(taskDto);
|
||||
}
|
||||
@@ -120,6 +122,12 @@ public abstract class AbstractTask {
|
||||
return resultForAcs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置下发任务,但是具体值以task上的为主
|
||||
* @param config_code 配置
|
||||
* @param taskDto ACS任务实体
|
||||
* @return /
|
||||
*/
|
||||
private AcsTaskDto setTask(String config_code, AcsTaskDto taskDto) {
|
||||
SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>()
|
||||
.eq(SchBaseTaskconfig::getConfig_code, config_code));
|
||||
@@ -291,7 +299,7 @@ public abstract class AbstractTask {
|
||||
? param.getString("create_mode") : GeneralDefinition.ACS_CREATION);
|
||||
task.setVehicle_code(vehicleCode);
|
||||
task.setVehicle_code2(vehicleCode2);
|
||||
task.setProduct_area(productArea);
|
||||
task.setProduct_area(ObjectUtil.isNotEmpty(productArea) ? productArea : taskConfig.getProduct_area());
|
||||
task.setVehicle_qty(param.getInteger("vehicle_qty"));
|
||||
task.setVehicle_type(vehicleType);
|
||||
task.setTask_status(TaskStatus.CREATED.getCode());
|
||||
|
||||
@@ -3,7 +3,10 @@ package org.nl.wms.sch.task_manage;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.velocity.runtime.directive.Break;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.wms.sch.task.service.ISchBaseTaskconfigService;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig;
|
||||
import org.reflections.Reflections;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -31,7 +34,7 @@ public class AutoCreateTask {
|
||||
private Map<Class<?>, Method> methodCache = new HashMap<>();
|
||||
// 类加载时候执行扫描
|
||||
static {
|
||||
Reflections reflections = new Reflections("org.nl.wms.sch.task_manage.task.tasks");
|
||||
Reflections reflections = new Reflections("org.nl.wms.sch.task_manage.tasks");
|
||||
subTypes = reflections.getSubTypesOf(AbstractTask.class);
|
||||
}
|
||||
|
||||
@@ -49,6 +52,9 @@ public class AutoCreateTask {
|
||||
subTypes.forEach(clz -> {
|
||||
// 调用AbstractAcsTask类的每个子类的schedule()方法
|
||||
try {
|
||||
if (!doCheckIsUsed(clz)) {
|
||||
return;
|
||||
}
|
||||
Object obj = SpringContextHolder.getBean(clz);
|
||||
Method m = obj.getClass().getMethod("schedule");
|
||||
m.invoke(obj);
|
||||
@@ -63,5 +69,18 @@ public class AutoCreateTask {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否启用
|
||||
* @param clz
|
||||
* @return
|
||||
*/
|
||||
public boolean doCheckIsUsed(Class<? extends AbstractTask> clz) {
|
||||
String[] split = clz.getName().split("\\.");
|
||||
String name = split[split.length - 1];
|
||||
ISchBaseTaskconfigService bean = SpringContextHolder.getBean(ISchBaseTaskconfigService.class);
|
||||
SchBaseTaskconfig config = bean.getByConfigCode(name);
|
||||
return config.getIs_used();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package org.nl.wms.sch.task_manage.core.tasks.auto;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch.task_manage.AbstractTask;
|
||||
import org.nl.wms.sch.task_manage.core.enums.TaskFinishedTypeEnum;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 自动创建入烘箱任务
|
||||
* @Date: 2024/8/9
|
||||
*/
|
||||
@Slf4j
|
||||
@Component(value = "AutoInHotTrussTask")
|
||||
public class AutoInHotTrussTask extends AbstractTask {
|
||||
@Override
|
||||
public void create() throws BadRequestException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void autoCreate() {
|
||||
// 自动创建
|
||||
log.info("自动创建。。。。");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.nl.wms.sch.task_manage.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 烘烤操作
|
||||
* @Date: 2024/8/9
|
||||
*/
|
||||
public interface BakingOperationService {
|
||||
/**
|
||||
* ACS请求出烘箱
|
||||
* @param param /
|
||||
* @return /
|
||||
*/
|
||||
public JSONObject acsRequestOutHotTask(JSONObject param);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.nl.wms.sch.task_manage.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.wms.sch.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch.task_manage.service.BakingOperationService;
|
||||
import org.nl.wms.sch.task_manage.tasks.hot.OutHotTrussTask;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description:
|
||||
* @Date: 2024/8/9
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class BakingOperationServiceImpl implements BakingOperationService {
|
||||
@Autowired
|
||||
private ISchBaseTaskService taskService;
|
||||
@Autowired
|
||||
private OutHotTrussTask outHotTrussTask;
|
||||
@Override
|
||||
public JSONObject acsRequestOutHotTask(JSONObject param) {
|
||||
log.info("acs请求出烘箱:{}", param);
|
||||
// device_code
|
||||
// 校验任务
|
||||
String deviceCode = param.getString("device_code");
|
||||
List<SchBaseTask> schBaseTasks = taskService.checkHaveTask(deviceCode);
|
||||
if (schBaseTasks.size() > 0) {
|
||||
throw new BadRequestException("点位[" + deviceCode + "]已经存在任务!");
|
||||
}
|
||||
param.put("config_code", "OutHotTrussTask");
|
||||
outHotTrussTask.apply(param);
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("status", HttpStatus.OK.value());
|
||||
result.put("message", "任务创建成功!");
|
||||
result.put("data", new JSONObject());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package org.nl.wms.sch.task_manage.tasks.auto;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.common.utils.CodeUtil;
|
||||
import org.nl.wms.pdm.bi.dao.PdmBiRawfoilworkorder;
|
||||
import org.nl.wms.pdm.bi.service.IpdmBiRawfoilworkorderService;
|
||||
import org.nl.wms.pdm.ivt.dao.StIvtHotpointivt;
|
||||
import org.nl.wms.pdm.ivt.service.IstIvtHotpointivtService;
|
||||
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.dao.SchBaseTask;
|
||||
import org.nl.wms.sch.task_manage.AbstractTask;
|
||||
import org.nl.wms.sch.task_manage.TaskStatus;
|
||||
import org.nl.wms.sch.task_manage.core.constant.GeneralDefinition;
|
||||
import org.nl.wms.sch.task_manage.core.enums.TaskFinishedTypeEnum;
|
||||
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.List;
|
||||
|
||||
import static org.nl.wms.util.PointUtils.clearPoint;
|
||||
import static org.nl.wms.util.PointUtils.setHxUpdateByType;
|
||||
import static org.nl.wms.util.TaskUtils.checkTaskOptionStatus;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 自动创建入烘箱任务
|
||||
* @Date: 2024/8/9
|
||||
*/
|
||||
@Slf4j
|
||||
@Component(value = "AutoInHotTrussTask")
|
||||
public class AutoInHotTrussTask extends AbstractTask {
|
||||
private final String THIS_CLASS = AutoInHotTrussTask.class.getName();
|
||||
private final static String HX_REGION = "A1-HXZC";
|
||||
@Autowired
|
||||
private ISchBasePointService pointService;
|
||||
@Autowired
|
||||
private IpdmBiRawfoilworkorderService rawfoilworkorderService;
|
||||
@Autowired
|
||||
private IstIvtHotpointivtService hotpointivtService;
|
||||
@Autowired
|
||||
private ISchBaseTaskService taskService;
|
||||
@Override
|
||||
public void create() throws BadRequestException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
protected void autoCreate() {
|
||||
// 自动创建
|
||||
log.info("自动创建入烘箱的任务...");
|
||||
// 获取烘箱暂存位点位状态是2:待烘烤,没任务的点位
|
||||
List<SchBasePoint> hotNotTaskPoint = pointService.getHotNotTaskPoint("A1", HX_REGION, null, "2");
|
||||
log.info("找到待烘烤的暂存位:{}", hotNotTaskPoint);
|
||||
for (SchBasePoint hotPoint : hotNotTaskPoint) {
|
||||
try {
|
||||
SchBaseTask task = new SchBaseTask();
|
||||
// 查找可用的烘箱
|
||||
String workOrderId = hotPoint.getGroup_id();
|
||||
if (ObjectUtil.isEmpty(workOrderId)) {
|
||||
log.error("点位{}的工单号为空!", hotPoint.getPoint_code());
|
||||
break;
|
||||
}
|
||||
PdmBiRawfoilworkorder order = rawfoilworkorderService.getById(workOrderId);
|
||||
String bakingTemperature = order.getBaking_temperature();
|
||||
// 如果需要烘烤, 先找对应点
|
||||
List<StIvtHotpointivt> hotList = hotpointivtService.getNotTaskHotOven(order.getRoll_type(), "1");
|
||||
if (hotList.size() == 0) {
|
||||
log.error("找不到温度为:{} 的可用烘箱位置{}", bakingTemperature);
|
||||
break;
|
||||
}
|
||||
// 查找合适温度的点位
|
||||
for (StIvtHotpointivt hxPoint : hotList) {
|
||||
String pointCode = hxPoint.getPoint_code();
|
||||
// String pointTemperature = (String) redisUtils.hget(pointCode, "temperature");
|
||||
// if (ObjectUtil.isNotEmpty(pointTemperature)) {
|
||||
// if (pointTemperature.equals(bakingTemperature)) {
|
||||
// task.setPoint_code2(hotPoint.getPoint_code());
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// 临时测试
|
||||
task.setPoint_code2(hxPoint.getPoint_code());
|
||||
break;
|
||||
}
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("workorder_id", workOrderId);
|
||||
task.setPoint_code1(hotPoint.getPoint_code());
|
||||
task.setTask_id(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
task.setTask_code(CodeUtil.getNewCode("TASK_CODE"));
|
||||
task.setConfig_code("AutoInHotTrussTask");
|
||||
task.setCreate_mode(GeneralDefinition.AUTO_CREATION);
|
||||
task.setVehicle_code(hotPoint.getVehicle_code());
|
||||
task.setRequest_param(JSONObject.toJSONString(param));
|
||||
task.setTask_status(TaskStatus.START_AND_POINT.getCode());
|
||||
TaskUtils.setCreateByPda(task);
|
||||
taskService.save(task);
|
||||
} catch (Exception e) {
|
||||
log.error("自动创建入烘箱的任务执行异常:{}", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) {
|
||||
checkTaskOptionStatus(taskObj);
|
||||
// 烘箱点位状态设置为烘烤中,起点清空。
|
||||
String startPointCode = taskObj.getPoint_code1();
|
||||
String endPointCode = taskObj.getPoint_code2();
|
||||
SchBasePoint startPoint = pointService.getById(startPointCode);
|
||||
StIvtHotpointivt endPoint = hotpointivtService.getPointByCode(endPointCode, false);
|
||||
String orderId = startPoint.getGroup_id();
|
||||
PdmBiRawfoilworkorder order = rawfoilworkorderService.getById(orderId);
|
||||
// 烘箱位,状态为02:烘烤中
|
||||
endPoint.setContainer_name(order.getContainer_name());
|
||||
endPoint.setWorkorder_id(order.getWorkorder_id());
|
||||
endPoint.setInstorage_time(DateUtil.now());
|
||||
endPoint.setPoint_status("02");
|
||||
endPoint.setFull_vehicle_code(taskObj.getVehicle_code());
|
||||
// todo: 更新温度和倒计时
|
||||
setHxUpdateByType(endPoint, taskFinishedType);
|
||||
hotpointivtService.updateById(endPoint);
|
||||
// 起点清空
|
||||
clearPoint(startPoint, taskFinishedType);
|
||||
// 完成
|
||||
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
|
||||
taskObj.setFinished_type(taskFinishedType.getCode());
|
||||
TaskUtils.setUpdateByType(taskObj, taskFinishedType);
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) {
|
||||
checkTaskOptionStatus(taskObj);
|
||||
// 取消
|
||||
taskObj.setTask_status(TaskStatus.CANCELED.getCode());
|
||||
taskObj.setRemark(GeneralDefinition.TASK_CANCEL);
|
||||
taskObj.setFinished_type(taskFinishedType.getCode());
|
||||
TaskUtils.setUpdateByType(taskObj, taskFinishedType);
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.nl.wms.sch.task_manage.core.tasks.hot;
|
||||
package org.nl.wms.sch.task_manage.tasks.hot;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
@@ -19,7 +19,6 @@ import org.nl.wms.sch.task_manage.AbstractTask;
|
||||
import org.nl.wms.sch.task_manage.TaskStatus;
|
||||
import org.nl.wms.sch.task_manage.core.constant.GeneralDefinition;
|
||||
import org.nl.wms.sch.task_manage.core.enums.TaskFinishedTypeEnum;
|
||||
import org.nl.wms.util.PointUtils;
|
||||
import org.nl.wms.util.TaskUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -127,9 +126,9 @@ public class InHotTrussTask extends AbstractTask {
|
||||
String requestParam = taskObj.getRequest_param();
|
||||
JSONObject requestObj = JSONObject.parseObject(requestParam);
|
||||
String workorderId = requestObj.getString("workorder_id");
|
||||
String pointCode2 = taskObj.getPoint_code2();
|
||||
SchBasePoint hotDjwPoint = pointService.getById(pointCode2);
|
||||
StIvtHotpointivt hotpointivt = hotpointivtService.getPointByCode(pointCode2, false);
|
||||
String endPointCode = taskObj.getPoint_code2();
|
||||
SchBasePoint hotDjwPoint = pointService.getById(endPointCode);
|
||||
StIvtHotpointivt hotpointivt = hotpointivtService.getPointByCode(endPointCode, false);
|
||||
PdmBiRawfoilworkorder order = rawfoilworkorderService.getById(workorderId);
|
||||
Assert.notNull(order, "工单不能为空!");
|
||||
if (ObjectUtil.isEmpty(hotpointivt)) {
|
||||
@@ -145,6 +144,7 @@ public class InHotTrussTask extends AbstractTask {
|
||||
hotpointivt.setContainer_name(order.getContainer_name());
|
||||
hotpointivt.setWorkorder_id(order.getWorkorder_id());
|
||||
hotpointivt.setInstorage_time(DateUtil.now());
|
||||
hotpointivt.setFull_vehicle_code(taskObj.getVehicle_code());
|
||||
hotpointivt.setPoint_status("1".equals(order.getIs_baking()) ? "02" : "03");
|
||||
// todo: 更新温度和倒计时
|
||||
setHxUpdateByType(hotpointivt, taskFinishedType);
|
||||
@@ -0,0 +1,86 @@
|
||||
package org.nl.wms.sch.task_manage.tasks.hot;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.wms.pdm.ivt.dao.StIvtHotpointivt;
|
||||
import org.nl.wms.pdm.ivt.service.IstIvtHotpointivtService;
|
||||
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.dao.SchBaseTask;
|
||||
import org.nl.wms.sch.task_manage.AbstractTask;
|
||||
import org.nl.wms.sch.task_manage.TaskStatus;
|
||||
import org.nl.wms.sch.task_manage.core.constant.GeneralDefinition;
|
||||
import org.nl.wms.sch.task_manage.core.enums.TaskFinishedTypeEnum;
|
||||
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.List;
|
||||
|
||||
import static org.nl.wms.util.TaskUtils.checkTaskOptionStatus;
|
||||
import static org.nl.wms.util.TaskUtils.setUpdateByPC;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
* @Description: 创建出烘箱任务
|
||||
* @Date: 2024/8/9
|
||||
*/
|
||||
@Slf4j
|
||||
@Component(value = "OutHotTrussTask")
|
||||
public class OutHotTrussTask extends AbstractTask {
|
||||
private final String THIS_CLASS = OutHotTrussTask.class.getName();
|
||||
@Autowired
|
||||
private ISchBasePointService pointService;
|
||||
@Autowired
|
||||
private IstIvtHotpointivtService hotpointivtService;
|
||||
@Autowired
|
||||
private ISchBaseTaskService taskService;
|
||||
@Override
|
||||
public void create() throws BadRequestException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createCompletion(SchBaseTask task) {
|
||||
// 从烘箱暂存位找一个空位
|
||||
List<SchBasePoint> hotDjwList = pointService.getHotNotTaskPoint("A1", "A1-HXZC", "4", "1");
|
||||
if (hotDjwList.size() == 0) {
|
||||
throw new BadRequestException("烘箱烘烤完毕的暂存位不够!");
|
||||
}
|
||||
String requestParam = task.getRequest_param();
|
||||
JSONObject requestObj = JSONObject.parseObject(requestParam);
|
||||
String startPoint = task.getPoint_code1();
|
||||
StIvtHotpointivt hotPoint = hotpointivtService.getPointByCode(startPoint, false);
|
||||
requestObj.put("workorder_id", hotPoint.getWorkorder_id());
|
||||
SchBasePoint point = hotDjwList.get(0);
|
||||
task.setVehicle_code(hotPoint.getFull_vehicle_code());
|
||||
task.setPoint_code2(point.getPoint_code());
|
||||
task.setRequest_param(JSONObject.toJSONString(requestObj));
|
||||
// 保存任务参数
|
||||
task.setHandle_class(THIS_CLASS);
|
||||
task.setTask_status(TaskStatus.START_AND_POINT.getCode());
|
||||
setUpdateByPC(task);
|
||||
taskService.save(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) {
|
||||
// 出烘箱后,终点状态应改成04:待分切
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) {
|
||||
checkTaskOptionStatus(taskObj);
|
||||
// 取消
|
||||
taskObj.setTask_status(TaskStatus.CANCELED.getCode());
|
||||
taskObj.setRemark(GeneralDefinition.TASK_CANCEL);
|
||||
taskObj.setFinished_type(taskFinishedType.getCode());
|
||||
TaskUtils.setUpdateByType(taskObj, taskFinishedType);
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.nl.wms.sch.task_manage.core.tasks.raw;
|
||||
package org.nl.wms.sch.task_manage.tasks.raw;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.nl.wms.sch.task_manage.core.tasks.raw;
|
||||
package org.nl.wms.sch.task_manage.tasks.raw;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -96,7 +96,7 @@ public class RawCallRollTrussTask extends AbstractTask {
|
||||
// 设置载具类型、点位状态、释放点位
|
||||
if (ObjectUtil.isNotEmpty(startPointObj)) {
|
||||
// 起点清空
|
||||
clearPoint(startPointObj);
|
||||
clearPoint(startPointObj, taskFinishedType);
|
||||
}
|
||||
log.info("点位清除完毕,清楚后的数据:{}", startPointObj);
|
||||
StIvtSbpointivt startAgvPointObj = stIvtSbpointivtService.getByPointCode(endAgvPoint, false);
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.nl.wms.sch.task_manage.core.tasks.raw;
|
||||
package org.nl.wms.sch.task_manage.tasks.raw;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -15,7 +15,7 @@ import org.nl.wms.sch.task_manage.AbstractTask;
|
||||
import org.nl.wms.sch.task_manage.TaskStatus;
|
||||
import org.nl.wms.sch.task_manage.core.constant.GeneralDefinition;
|
||||
import org.nl.wms.sch.task_manage.core.enums.TaskFinishedTypeEnum;
|
||||
import org.nl.wms.sch.task_manage.core.tasks.hot.InHotTrussTask;
|
||||
import org.nl.wms.sch.task_manage.tasks.hot.InHotTrussTask;
|
||||
import org.nl.wms.util.TaskUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -42,7 +42,7 @@ public class PointUtils {
|
||||
* 会直接更新数据,使用时候不需要在update
|
||||
* @param point
|
||||
*/
|
||||
public static void clearPoint(SchBasePoint point) {
|
||||
public static void clearPoint(SchBasePoint point, TaskFinishedTypeEnum taskFinishedType) {
|
||||
if (ObjectUtil.isEmpty(point)) {
|
||||
return; // 空直接退出
|
||||
}
|
||||
@@ -51,8 +51,10 @@ public class PointUtils {
|
||||
point.setVehicle_type("");
|
||||
point.setVehicle_code("");
|
||||
point.setIng_task_code("");
|
||||
point.setGroup_id("");
|
||||
point.setVehicle_qty(0);
|
||||
point.setUpdate_time(DateUtil.now());
|
||||
setUpdateByType(point, taskFinishedType);
|
||||
pointService.updateById(point);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user