fix:普通废箔任务改造调试、自动巡航费箔任务开发调试
This commit is contained in:
@@ -35,6 +35,13 @@ public class OtherPdaController {
|
||||
public ResponseEntity<Object> resumeMoveWasteFoilV2(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(otherPdaService.resumeMoveWasteFoilV2(param), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/resumeAutoMoveWasteFoil")
|
||||
@Log("继续自动巡航搬运废箔")
|
||||
public ResponseEntity<Object> resumeAutoMoveWasteFoil(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(otherPdaService.resumeAutoMoveWasteFoil(param), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/startMoveWasteFoil")
|
||||
@Log("开始搬运废箔信息")
|
||||
public ResponseEntity<Object> startMoveWasteFoil(@RequestBody JSONObject param) {
|
||||
|
||||
@@ -63,4 +63,6 @@ public interface OtherPdaService {
|
||||
* @return /
|
||||
*/
|
||||
JSONObject callAgvToSamplingVerify(JSONObject param);
|
||||
|
||||
JSONObject resumeAutoMoveWasteFoil(JSONObject param);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.nl.wms.pda.st.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
@@ -30,6 +31,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
@@ -92,26 +94,17 @@ public class OtherPdaServiceImpl implements OtherPdaService {
|
||||
String flag = param.getString("flag");
|
||||
// 判断是否能够搬运
|
||||
String pointCode = param.getString("point_code");
|
||||
// 校验是否二次创建任务
|
||||
SchBaseTask schBaseTasks = taskService.getTaskByPointCodeX(pointCode, null, null, null);
|
||||
if (ObjectUtil.isNotEmpty(schBaseTasks)) {
|
||||
throw new BadRequestException("点位[" + pointCode + "]已经存在任务!");
|
||||
}
|
||||
// 查找执行中的任务
|
||||
SchBaseTask task = taskService.getOne(new LambdaQueryWrapper<SchBaseTask>()
|
||||
.eq(SchBaseTask::getPoint_code2, pointCode)
|
||||
.lt(SchBaseTask::getTask_status, TaskStatus.FINISHED.getCode()));
|
||||
if (ObjectUtil.isEmpty(task)) {
|
||||
throw new BadRequestException("点位[" + pointCode + "]上一个任务不存在!");
|
||||
}
|
||||
SchBaseTask task = checkTask(pointCode);
|
||||
|
||||
JSONObject upTaskRequestObj = JSONObject.parseObject(task.getRequest_param());
|
||||
// 获取下一条的任务
|
||||
List<SchBaseTask> waitTask = taskService.getTaskByConfigAndStatus(task.getConfig_code(), TaskStatus.SURE_END.getCode());
|
||||
// 结束或者没有任务后回废料起点
|
||||
if (waitTask.size() == 0 || "2".equals(flag)) {
|
||||
// 最后一条任务, 创建去终点的任务
|
||||
// 获取一个废箔位置
|
||||
List<SchBasePoint> fbPoints = pointService.getAllBusinessNotTaskPoint("A1", "A1-FB",
|
||||
"2", null, null, null);
|
||||
"1", "1", null, null);
|
||||
if (CollectionUtil.isEmpty(fbPoints)) {
|
||||
throw new BadRequestException("找不到废箔点位,请稍后再试!");
|
||||
}
|
||||
@@ -140,8 +133,60 @@ public class OtherPdaServiceImpl implements OtherPdaService {
|
||||
taskService.updateById(nextTask);
|
||||
}
|
||||
// 通知ACS完成上一个任务
|
||||
// 通知ACS完成上一个任务
|
||||
JSONArray acs = new JSONArray();
|
||||
JSONObject result = new JSONObject();
|
||||
JSONObject acsParam = new JSONObject();
|
||||
noticeAcs(acsParam, task, pointCode, acs, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject resumeAutoMoveWasteFoil(JSONObject param) {
|
||||
// 判断是否能够搬运
|
||||
String pointCode = param.getString("point_code");
|
||||
// 校验是否二次创建任务
|
||||
SchBaseTask task = checkTask(pointCode);
|
||||
List<SchBasePoint> fbPoints = pointService.getAllBusinessTaskPoint("A1", "A1-FB",
|
||||
"2", "1", null, null);
|
||||
if (CollectionUtil.isEmpty(fbPoints)) {
|
||||
throw new BadRequestException("找不到废箔点位,请稍后再试!");
|
||||
}
|
||||
JSONObject upTaskRequestObj = JSONObject.parseObject(task.getRequest_param());
|
||||
|
||||
// 自动巡航过滤下一个废箔点位
|
||||
List<SchBasePoint> pointCodeCurrent = fbPoints.stream().filter(point -> point.getPoint_code().equals(pointCode)).collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(pointCodeCurrent)) {
|
||||
throw new BadRequestException("自动巡航废箔任务执行异常,当前点位不存在");
|
||||
}
|
||||
List<SchBasePoint> fbPointsFilter = fbPoints.stream()
|
||||
.filter(point -> point.getSort()!= null)
|
||||
.filter(point -> point.getSort().equals(pointCodeCurrent.get(0).getSort() + 1)).collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(fbPointsFilter)) {
|
||||
throw new BadRequestException("自动巡航废箔任务执行异常,已到达最后一个点位");
|
||||
}
|
||||
JSONObject taskParam = new JSONObject();
|
||||
taskParam.put("point_code1", pointCode);
|
||||
taskParam.put("point_code2", fbPointsFilter.get(0).getPoint_code());
|
||||
taskParam.put("config_code", "SendWasteFoilAGVTask");
|
||||
taskParam.put("create_mode", GeneralDefinition.PDA_CREATION);
|
||||
taskParam.put("remark", "自动巡航");
|
||||
taskParam.put("up_task_code", task.getTask_code());
|
||||
taskParam.put("index_task", upTaskRequestObj.getInteger("index_task") + 1);
|
||||
taskParam.put("carNo", task.getCar_no());
|
||||
taskParam.put("task_status", TaskStatus.START_AND_POINT.getCode());
|
||||
sendWasteFoilAGVTask.createTask(taskParam);
|
||||
|
||||
// 通知ACS完成上一个任务
|
||||
JSONArray acs = new JSONArray();
|
||||
JSONObject result = new JSONObject();
|
||||
JSONObject acsParam = new JSONObject();
|
||||
noticeAcs(acsParam, task, pointCode, acs, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void noticeAcs(JSONObject acsParam, SchBaseTask task, String pointCode, JSONArray acs, JSONObject result) {
|
||||
acsParam.put("task_code", task.getTask_code());
|
||||
acsParam.put("device_code", pointCode);
|
||||
acsParam.put("product_area", "A1");
|
||||
@@ -150,10 +195,23 @@ public class OtherPdaServiceImpl implements OtherPdaService {
|
||||
acs.add(acsParam);
|
||||
JSONObject jsonObject = wmsToAcsService.updateTask(acs);
|
||||
log.info("通知ACS完成上一个任务的反馈 - {}", jsonObject);
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("status", HttpStatus.OK.value());
|
||||
result.put("message", "废箔继续搬运请求成功!");
|
||||
return result;
|
||||
}
|
||||
|
||||
private SchBaseTask checkTask(String pointCode) {
|
||||
SchBaseTask schBaseTasks = taskService.getTaskByPointCodeX(pointCode, null, null, null);
|
||||
if (ObjectUtil.isNotEmpty(schBaseTasks)) {
|
||||
throw new BadRequestException("点位[" + pointCode + "]已经存在任务!");
|
||||
}
|
||||
// 查找执行中的任务
|
||||
SchBaseTask task = taskService.getOne(new LambdaQueryWrapper<SchBaseTask>()
|
||||
.eq(SchBaseTask::getPoint_code2, pointCode)
|
||||
.lt(SchBaseTask::getTask_status, TaskStatus.FINISHED.getCode()));
|
||||
if (ObjectUtil.isEmpty(task)) {
|
||||
throw new BadRequestException("点位[" + pointCode + "]上一个任务不存在!");
|
||||
}
|
||||
return task;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package org.nl.wms.quartz;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.wms.pda.st.service.OtherPdaService;
|
||||
import org.nl.wms.pda.st.service.impl.OtherPdaServiceImpl;
|
||||
import org.nl.wms.sch.point.service.ISchBasePointService;
|
||||
import org.nl.wms.sch.point.service.dao.SchBasePoint;
|
||||
import org.nl.wms.sch.point.service.dao.mapper.SchBasePointMapper;
|
||||
import org.nl.wms.sch.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch.task_manage.TaskStatus;
|
||||
import org.nl.wms.util.TaskUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 自动巡航废箔任务,起点到第一个生箔位
|
||||
* @Author: lyd
|
||||
* @Date: 2024/8/27
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AutoMoveWasteFoilAGVTask {
|
||||
|
||||
@Autowired
|
||||
private OtherPdaService otherPdaService;
|
||||
|
||||
@Autowired
|
||||
private ISchBasePointService pointService;
|
||||
public void run() {
|
||||
log.info("自动巡航废箔任务开始执行...");
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
List<SchBasePoint> fbPoints = pointService.getAllBusinessNotTaskPoint("A1", "A1-FB",
|
||||
"2", "1", null, null);
|
||||
// 筛选一号位
|
||||
List<SchBasePoint> fbPointsFilter = fbPoints.stream()
|
||||
.filter(point -> point.getSort()!= null)
|
||||
.filter(point -> point.getSort() .equals(1)).collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(fbPointsFilter)) {
|
||||
log.info("自动巡航废箔任务执行异常,无废箔位");
|
||||
return;
|
||||
}
|
||||
jsonObject.put("point_code", fbPointsFilter.get(0).getPoint_code());
|
||||
otherPdaService.startMoveWasteFoilV2(jsonObject);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -124,4 +124,7 @@ public interface ISchBasePointService extends IService<SchBasePoint> {
|
||||
* @return
|
||||
*/
|
||||
List<SchBasePoint> getGxPointNotLock();
|
||||
|
||||
List<SchBasePoint> getAllBusinessTaskPoint(String area, String region, String pointType,
|
||||
String pointStatus, String vehicleType, String vehicleCode);
|
||||
}
|
||||
|
||||
@@ -38,6 +38,9 @@ public interface SchBasePointMapper extends BaseMapper<SchBasePoint> {
|
||||
List<SchBasePoint> getAllBusinessNotTaskPoint(String area, String region, String pointType, String pointStatus,
|
||||
String vehicleType, String vehicleCode);
|
||||
|
||||
List<SchBasePoint> getAllBusinessTaskPoint(String area, String region, String pointType, String pointStatus,
|
||||
String vehicleType, String vehicleCode);
|
||||
|
||||
/**
|
||||
* 获取收卷没任务、生箔机指定的收卷的点位
|
||||
* @param code /
|
||||
|
||||
@@ -66,6 +66,31 @@
|
||||
OR t.point_code4 = p.point_code))
|
||||
ORDER BY p.update_time
|
||||
</select>
|
||||
|
||||
<select id="getAllBusinessTaskPoint" resultType="org.nl.wms.sch.point.service.dao.SchBasePoint">
|
||||
SELECT p.*
|
||||
FROM sch_base_point p
|
||||
WHERE p.is_used = TRUE
|
||||
<if test="region != null">
|
||||
AND p.region_code = #{region}
|
||||
</if>
|
||||
<if test="pointType != null">
|
||||
AND p.point_type = #{pointType}
|
||||
</if>
|
||||
<if test="area != null">
|
||||
AND p.product_area = #{area}
|
||||
</if>
|
||||
<if test="pointStatus != null">
|
||||
AND p.point_status = #{pointStatus}
|
||||
</if>
|
||||
<if test="vehicleType != null">
|
||||
AND p.vehicle_type = #{vehicleType}
|
||||
</if>
|
||||
<if test="vehicleCode != null">
|
||||
AND p.vehicle_code = #{vehicleCode}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getWindRollConformRawNotTaskPoints" resultType="org.nl.wms.sch.point.service.dao.SchBasePoint">
|
||||
SELECT
|
||||
p.*
|
||||
|
||||
@@ -239,6 +239,12 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
|
||||
return pointMapper.getAllBusinessNotTaskPoint(area, region, pointType, pointStatus, vehicleType, vehicleCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SchBasePoint> getAllBusinessTaskPoint(String area, String region, String pointType,
|
||||
String pointStatus, String vehicleType, String vehicleCode) {
|
||||
return pointMapper.getAllBusinessTaskPoint(area, region, pointType, pointStatus, vehicleType, vehicleCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SchBasePoint> getWindRollConformRawNotTaskPoints(String code) {
|
||||
return pointMapper.getWindRollConformRawNotTaskPoints(code);
|
||||
|
||||
@@ -75,11 +75,19 @@ public class SendWasteFoilAGVTask extends AbstractTask {
|
||||
checkTaskOptionStatus(taskObj);
|
||||
// 如果是废箔起点,需要吧点位置空
|
||||
String startPointCode = taskObj.getPoint_code1();
|
||||
String startPointCode2 = taskObj.getPoint_code2();
|
||||
SchBasePoint startPoint = pointService.getById(startPointCode);
|
||||
SchBasePoint startPoint2 = pointService.getById(startPointCode2);
|
||||
if ("A1-FB".equals(startPoint.getRegion_code())) {
|
||||
// 清空
|
||||
PointUtils.clearPoint(startPoint, taskFinishedType);
|
||||
}
|
||||
// 如果任务终点是废箔起点,将起点改成有载具
|
||||
if ("A1-FB".equals(startPoint.getRegion_code())) {
|
||||
// 清空
|
||||
startPoint2.setPoint_status("2");
|
||||
pointService.updateById(startPoint2);
|
||||
}
|
||||
// 任务完成
|
||||
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
|
||||
taskObj.setFinished_type(taskFinishedType.getCode());
|
||||
|
||||
Reference in New Issue
Block a user