1 changed files with 169 additions and 0 deletions
@ -0,0 +1,169 @@ |
|||||
|
package org.nl.b_lms.sch.tasks.slitter; |
||||
|
|
||||
|
import cn.hutool.core.date.DateUtil; |
||||
|
import cn.hutool.core.util.IdUtil; |
||||
|
import cn.hutool.core.util.ObjectUtil; |
||||
|
import cn.hutool.core.util.StrUtil; |
||||
|
import com.alibaba.fastjson.JSONArray; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.nl.b_lms.bst.ivt.cutpointivt.service.IBstIvtCutpointivtService; |
||||
|
import org.nl.b_lms.bst.ivt.cutpointivt.service.dao.BstIvtCutpointivt; |
||||
|
import org.nl.b_lms.sch.point.dao.StIvtCutpointivt; |
||||
|
import org.nl.b_lms.sch.point.service.IstIvtCutpointivtService; |
||||
|
import org.nl.b_lms.sch.task.dao.SchBaseTask; |
||||
|
import org.nl.b_lms.sch.task.service.IschBaseTaskService; |
||||
|
import org.nl.common.utils.SecurityUtils; |
||||
|
import org.nl.common.utils.TaskUtils; |
||||
|
import org.nl.modules.wql.WQL; |
||||
|
import org.nl.modules.wql.core.bean.WQLObject; |
||||
|
import org.nl.wms.sch.AcsTaskDto; |
||||
|
import org.nl.wms.sch.manage.AbstractAcsTask; |
||||
|
import org.nl.wms.sch.manage.TaskStatusEnum; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Author: lyd |
||||
|
* @Description: 分切下气胀轴桁架任务(2/4点任务) |
||||
|
* @Date: 2024/2/1 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
public class DownShaftTrussTask extends AbstractAcsTask { |
||||
|
private final String THIS_CLASS = DownShaftTrussTask.class.getName(); |
||||
|
@Autowired |
||||
|
private IschBaseTaskService taskService; |
||||
|
@Autowired |
||||
|
private IBstIvtCutpointivtService bcutpointivtService; |
||||
|
@Autowired |
||||
|
private IstIvtCutpointivtService cutpointivtService; |
||||
|
|
||||
|
@Override |
||||
|
public List<AcsTaskDto> addTask() { |
||||
|
/* |
||||
|
* 下发给ACS时需要特殊处理 |
||||
|
*/ |
||||
|
List<SchBaseTask> taskList = taskService.getIssueTasks(THIS_CLASS); |
||||
|
|
||||
|
ArrayList<AcsTaskDto> resultList = new ArrayList<>(); |
||||
|
String agv_system_type = "2"; |
||||
|
for (SchBaseTask task : taskList) { |
||||
|
String requestParam = task.getRequest_param(); |
||||
|
JSONObject requestParamObj = JSONObject.parseObject(requestParam); |
||||
|
AcsTaskDto dto = AcsTaskDto.builder() |
||||
|
.ext_task_id(task.getTask_id()) |
||||
|
.task_code(task.getTask_code()) |
||||
|
.task_type(task.getAcs_task_type()) |
||||
|
.start_device_code(task.getPoint_code1()) |
||||
|
.next_device_code(task.getPoint_code2()) |
||||
|
.start_device_code2(task.getPoint_code3()) |
||||
|
.next_device_code2(task.getPoint_code4()) |
||||
|
.vehicle_code(task.getVehicle_code()) |
||||
|
.truss_type(requestParamObj.getString("truss_type")) |
||||
|
.empty_site(requestParamObj.getString("empty_site")) |
||||
|
.agv_system_type(agv_system_type) |
||||
|
.priority(task.getPriority()) |
||||
|
.remark(task.getRemark()) |
||||
|
.product_area(task.getProduct_area()) |
||||
|
.build(); |
||||
|
resultList.add(dto); |
||||
|
} |
||||
|
return resultList; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
@Transactional(rollbackFor = Exception.class) |
||||
|
public void updateTaskStatus(JSONObject taskObj, String status) { |
||||
|
SchBaseTask task = taskService.getById(taskObj.getString("task_id")); |
||||
|
if (TaskStatusEnum.EXECUTING.getCode().equals(status)) { |
||||
|
// 更新任务状态为执行中
|
||||
|
task.setTask_status(TaskStatusEnum.EXECUTING.getCode()); |
||||
|
} |
||||
|
|
||||
|
if (StrUtil.equals(status, TaskStatusEnum.FINISHED.getCode())) { |
||||
|
task.setTask_status(TaskStatusEnum.FINISHED.getCode()); |
||||
|
//起点
|
||||
|
String pointCode1 = task.getPoint_code1(); |
||||
|
//终点
|
||||
|
String pointCode2 = task.getPoint_code2(); |
||||
|
StIvtCutpointivt point1 = cutpointivtService.getPintByUpOrDownCode(pointCode1, false); |
||||
|
BstIvtCutpointivt point2 = bcutpointivtService.getPintByTrussCode(pointCode2, false); |
||||
|
// 点位数据更新
|
||||
|
|
||||
|
point2.setQzz_no1(point1.getUp_qzzno()); |
||||
|
point1.setUp_qzzno(""); |
||||
|
//下双
|
||||
|
if(ObjectUtil.isNotEmpty(task.getPoint_code3())){ |
||||
|
|
||||
|
point2.setQzz_no2(point1.getDown_qzzno()); |
||||
|
point1.setDown_qzzno(""); |
||||
|
} |
||||
|
//更新分切机点位
|
||||
|
point1.setRemark(""); |
||||
|
point1.setUpdate_optid(3L); |
||||
|
point1.setUpdate_optname("ACS"); |
||||
|
point1.setUpdate_time(DateUtil.now()); |
||||
|
cutpointivtService.updateById(point1); |
||||
|
|
||||
|
//更新分切暂存点
|
||||
|
point2.setPoint_status("3"); |
||||
|
TaskUtils.updateOptMessageByBCutPoint(point2); |
||||
|
bcutpointivtService.updateById(point2); |
||||
|
} |
||||
|
task.setUpdate_time(DateUtil.now()); |
||||
|
taskService.updateById(task); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public String createTask(JSONObject form) { |
||||
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
||||
|
String currentUsername = SecurityUtils.getCurrentUsername(); |
||||
|
|
||||
|
SchBaseTask task = new SchBaseTask(); |
||||
|
task.setTask_id(IdUtil.getSnowflake(1, 1).nextIdStr()); |
||||
|
task.setTask_code(IdUtil.getSnowflake(1, 1).nextIdStr()); |
||||
|
task.setTask_status(TaskStatusEnum.START_AND_POINT.getCode()); |
||||
|
task.setPoint_code1(form.getString("point_code1")); |
||||
|
task.setPoint_code2(form.getString("point_code2")); |
||||
|
task.setPoint_code3(form.getString("point_code3")); |
||||
|
task.setPoint_code4(form.getString("point_code4")); |
||||
|
task.setVehicle_code(form.getString("vehicle_code1")); |
||||
|
task.setVehicle_code2(form.getString("vehicle_code2")); |
||||
|
task.setAcs_task_type("6"); |
||||
|
task.setIs_delete("0"); |
||||
|
task.setRequest_param(form.toJSONString()); |
||||
|
task.setTask_type(form.getString("task_type")); |
||||
|
task.setProduct_area(form.getString("product_area")); |
||||
|
task.setCreate_id(currentUserId); |
||||
|
task.setCreate_name(currentUsername); |
||||
|
task.setCreate_time(DateUtil.now()); |
||||
|
task.setHandle_class(THIS_CLASS); |
||||
|
//根据类型获取对应的任务优先级
|
||||
|
JSONObject priority_jo = WQL.getWO("PDA_COOLIN").addParam("flag", "3").addParam("task_type", task.getTask_type()).process().uniqueResult(0); |
||||
|
if (ObjectUtil.isEmpty(priority_jo)) { |
||||
|
task.setPriority("1"); |
||||
|
} else { |
||||
|
task.setPriority(priority_jo.getString("value")); |
||||
|
} |
||||
|
taskService.save(task); |
||||
|
this.immediateNotifyAcs(null); |
||||
|
return task.getTask_id(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void forceFinish(String task_id) { |
||||
|
JSONObject taskObj = WQLObject.getWQLObject("SCH_BASE_Task").query("task_id = '" + task_id + "'").uniqueResult(0); |
||||
|
this.updateTaskStatus(taskObj, TaskStatusEnum.FINISHED.getCode()); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@Override |
||||
|
public void cancel(String task_id) { |
||||
|
JSONObject taskObj = WQLObject.getWQLObject("SCH_BASE_Task").query("task_id = '" + task_id + "'").uniqueResult(0); |
||||
|
this.updateTaskStatus(taskObj, "0"); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue