Browse Source

add:新增业务类型

master
刘先源 1 week ago
parent
commit
9a91559b7e
  1. 18
      acs2/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/RegionEnum.java
  2. 5
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/MesToWmsServiceImpl.java
  3. 146
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/PUBMOVETask.java

18
acs2/nladmin-system/src/main/java/org/nl/modules/common/utils/enums/RegionEnum.java

@ -113,6 +113,24 @@ public enum RegionEnum {
// 良品区-->钢平台接驳 // 良品区-->钢平台接驳
LPQ_GPTJB("LPQ", "GPTJB","PS20","Group-001"), LPQ_GPTJB("LPQ", "GPTJB","PS20","Group-001"),
// AB生产区-->AB生产区
AB_AB("AB", "AB","PS20","Group-001"),
// C生产区-->C生产区
C_C("C", "C","PS20","Group-001"),
// D生产区-->D生产区
D_D("D", "D","PS20","Group-001"),
// 良品区-->良品区
LPQ_LPQ("LPQ", "LPQ","PS20","Group-001"),
// 地面货架-->地面货架
DMHJ_DMHJ("DMHJ", "DMHJ","PS20","Group-001"),
// 钢平台货架-->钢平台货架
GPTHJ_GPTHJ("GPTHJ", "GPTHJ","PS10","Group-003"),
; ;
// 起点区域 // 起点区域

5
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/mes/service/impl/MesToWmsServiceImpl.java

@ -287,6 +287,11 @@ public class MesToWmsServiceImpl implements MesToWmsService {
private String ifTaskRegion(String start_region, String next_region) { private String ifTaskRegion(String start_region, String next_region) {
String task_code = ""; String task_code = "";
// 如果起点和终点是相同区域则返回移库任务类
if (start_region.equals(next_region)) {
return "PUBMOVETask";
}
// 如果是良品区的点位则返回公共任务配置类 // 如果是良品区的点位则返回公共任务配置类
if (start_region.equals("LPQ") || next_region.equals("LPQ")) { if (start_region.equals("LPQ") || next_region.equals("LPQ")) {
return "PUBLICLPQTask"; return "PUBLICLPQTask";

146
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/PUBMOVETask.java

@ -0,0 +1,146 @@
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.ext.mes.service.WmsToMesService;
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: 移库公共类
* @Date: 2024/9/24
*/
@Component(value = "PUBMOVETask")
@TaskType("PUBMOVETask")
public class PUBMOVETask extends AbstractTask {
@Autowired
private ISchBaseTaskService taskService;
@Autowired
private ISchBaseTaskconfigService taskConfigService;
@Autowired
private WmsToMesService wmsToMesService;
@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.setIs_vehicle(json.getString("IsPanCode"));
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.setIs_vehicle(taskDao.getIs_vehicle());
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("执行中");
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 backMes(String task_code) {
wmsToMesService.receiveTaskStatusMesData(taskService.getByCode(task_code));
}
@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);
// 通知mes任务完成
wmsToMesService.receiveTaskStatusMesData(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…
Cancel
Save