小件扫描确认

main
huojin\hj 2025-08-06 17:56:50 +08:00
parent 8cdfe962f6
commit ddd46bb868
21 changed files with 434 additions and 94 deletions

View File

@ -13,8 +13,8 @@ public class ApiResult {
return result(400, "操作失败!", null);
}
public static ApiResult fail(int code, String msg, Object data) {
return result(code, msg, data);
public static ApiResult fail(String msg) {
return result(400, msg, null);
}
public static ApiResult success() {

View File

@ -0,0 +1,17 @@
package com.youchain.appupdate.inputJson;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class SmallRequest {
@ApiModelProperty(value = "起点", required = true)
String pointCode;
@ApiModelProperty(value = "上线单号",required = true)
String onlineNo;
@ApiModelProperty(value = "shooter数量",required = true, example = "2")
int shooter;
}

View File

@ -0,0 +1,42 @@
package com.youchain.appupdate.rest;
import com.youchain.annotation.AnonymousAccess;
import com.youchain.annotation.Log;
import com.youchain.appupdate.inputJson.SmallRequest;
import com.youchain.appupdate.service.NioF3AppService;
import com.youchain.businessdata.inputJson.LesRequest;
import com.youchain.exception.handler.ApiResult;
import com.youchain.exception.handler.LesResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Slf4j
@RestController
@RequiredArgsConstructor
@Api(tags = "APP版本管理")
@RequestMapping("/api/app")
public class NioF3AppController {
private final NioF3AppService nioF3AppService;
@PostMapping("/smallConfirm")
@Log("小件扫描确认")
@ApiOperation("小件扫描确认")
@AnonymousAccess
public ResponseEntity<Object> smallConfirm(@RequestBody SmallRequest smallRequest) {
try {
nioF3AppService.smallConfirm(smallRequest);
return new ResponseEntity<>(ApiResult.success(), HttpStatus.OK);
} catch (Exception e) {
return new ResponseEntity<>(ApiResult.fail(e.getMessage()), HttpStatus.BAD_REQUEST);
}
}
}

View File

@ -0,0 +1,17 @@
package com.youchain.appupdate.service;
import com.youchain.appupdate.inputJson.SmallRequest;
public interface NioF3AppService {
/**
*
* @param smallRequest
*/
void smallConfirm(SmallRequest smallRequest);
/**
*
*/
void LargeConfirm();
}

View File

@ -0,0 +1,111 @@
package com.youchain.appupdate.service.impl;
import com.youchain.appupdate.inputJson.SmallRequest;
import com.youchain.appupdate.service.NioF3AppService;
import com.youchain.basicdata.domain.Point;
import com.youchain.basicdata.service.PointService;
import com.youchain.businessdata.domain.AgvTask;
import com.youchain.businessdata.domain.Les;
import com.youchain.businessdata.repository.LesRepository;
import com.youchain.businessdata.service.AgvTaskService;
import com.youchain.businessdata.service.KMReService;
import com.youchain.exception.BadRequestException;
import com.youchain.utils.BizStatus;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Service
@RequiredArgsConstructor
public class NioF3AppServiceImpl implements NioF3AppService {
private final LesRepository lesRepository;
private final PointService pointService;
private final AgvTaskService agvTaskService;
private final KMReService kmReService;
@Override
@Transactional(rollbackFor = Exception.class)
public void smallConfirm(SmallRequest smallRequest) {
//验证参数
validateParams(smallRequest);
//起点
String pointCode = smallRequest.getPointCode();
//上线单号
String onlineNo = smallRequest.getOnlineNo();
//验证起点
pointService.validatePoint(pointCode);
//验证Les任务
List<Les> lesList = validateLes(pointCode, onlineNo);
//验证起点是否有Agv任务
validateAgvTask(pointCode);
//获取目标点位
String endPointCode = getEndPointCode(lesList);
//生成Agv任务
AgvTask agvTask = agvTaskService.createAgvTask(BizStatus.OPEN, null, pointCode, endPointCode, "TUGGER");
//下发任务
kmReService.sendAgvTask(agvTask, kmReService.sendAgvTaskQYCJson(agvTask, smallRequest.getShooter(),null));
}
/**
*
*
* @param smallRequest ->
*/
private void validateParams(SmallRequest smallRequest) {
if (StringUtils.isEmpty(smallRequest.getPointCode())) {
throw new BadRequestException("pointCode必填");
}
if (StringUtils.isEmpty(smallRequest.getOnlineNo())) {
throw new BadRequestException("onlineNo必填");
}
}
/**
* Les
*
* @param pointCode ->
* @param onlineNo -> 线
*/
private List<Les> validateLes(String pointCode, String onlineNo) {
List<Les> lesList = lesRepository.findByOnlineNo(pointCode,onlineNo);
if (lesList.isEmpty()) {
throw new BadRequestException("系统未识别到任务");
}
return lesList;
}
private void validateAgvTask(String pointCode) {
Boolean bool = agvTaskService.findByStartSlotCode(pointCode, "TUGGER_MOVE", "TUGGER");
if (bool) {
throw new BadRequestException(String.format("该点位:%s有任务请勿重复下发", pointCode));
}
}
private String getEndPointCode(List<Les> lesList) {
return lesList.stream()
.map(Les::getDstPositionCode) // 提取目标字段
.distinct() // 去重
.collect(Collectors.joining(",")); // 用逗号拼接字符串
}
@Override
public void LargeConfirm() {
}
}

View File

@ -16,6 +16,7 @@
package com.youchain.basicdata.repository;
import com.youchain.basicdata.domain.Point;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

View File

@ -25,6 +25,8 @@ import com.youchain.basicdata.service.dto.PointDto;
import com.youchain.basicdata.service.dto.PointQueryCriteria;
import com.youchain.basicdata.service.mapstruct.PointMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
@ -43,6 +45,7 @@ import javax.servlet.http.HttpServletResponse;
@Service
@RequiredArgsConstructor
@Slf4j
@CacheConfig(cacheNames = "point")
public class PointServiceImpl implements PointService {
private final PointRepository pointRepository;
@ -119,6 +122,7 @@ public class PointServiceImpl implements PointService {
}
@Override
@Cacheable(key = "#position", unless = "#result == null")
public Point validatePoint(String position) {
Point point = pointRepository.findByCode(position);
if (point == null) {

View File

@ -55,8 +55,7 @@ public class AgvTask extends BaseEntity implements Serializable {
@ApiModelProperty(value = "容器号")
private String stockCode;
@Column(name = "`stock_type_code`",nullable = true)
@NotBlank
@Column(name = "`stock_type_code`")
@ApiModelProperty(value = "")
private String stockTypeCode;

View File

@ -11,6 +11,7 @@ import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
@Data
@ -35,7 +36,7 @@ public class Les extends BaseEntity implements Serializable {
private String taskType;
@Column(name = "`material_code`")
@ApiModelProperty(value = "物料代码")
@ApiModelProperty(value = "物料")
private String materialCode;
@Column(name = "`route_code`")
@ -66,6 +67,14 @@ public class Les extends BaseEntity implements Serializable {
@ApiModelProperty(value = "终点类型")
private String dstType;
@Column(name = "`agv_task_id`")
@ApiModelProperty(value = "agv任务id")
private Long agvTaskId;
@Column(name = "arrived_time")
@ApiModelProperty(value = "到达时间")
private Timestamp arrivedTime;
public void copy(Les source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}

View File

@ -0,0 +1,23 @@
package com.youchain.appupdate.inputJson;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* KMReS
* @author 92525
*/
@Data
public class MissionStateCallback {
@ApiModelProperty(value = "任务ID")
String missionCode;
@ApiModelProperty(value = "容器编号")
String containerCode;
@ApiModelProperty(value = "作业当前状态")
String missionStatus;
@ApiModelProperty(value = "容器当前位置")
String currentPosition;
}

View File

@ -31,11 +31,11 @@ import java.util.Map;
public interface AgvTaskRepository extends JpaRepository<AgvTask, Long>, JpaSpecificationExecutor<AgvTask> {
@Query(value = "select count(agv.id) from AgvTask agv where agv.stockCode=:stockCode and agv.startSlotCode=:srcPointCode and agv.endSlotCode=:endPointCode and agv.status in ('OPEN','ATCALL','UP_CONTAINER') ")
int isAGVTaskDuplicate(String stockCode, String srcPointCode, String endPointCode);
Long isAGVTaskDuplicate(String stockCode, String srcPointCode, String endPointCode);
@Query(value = "select count(agv.id) from AgvTask agv where agv.startSlotCode=:startSlotCode and agv.type=:type and agv.jobType=:jobType and agv.status in ('OPEN','ATCALL','UP_CONTAINER') ")
int findByStartSlotCode(String startSlotCode, String type, String jobType);
Long findByStartSlotCode(String startSlotCode, String type, String jobType);
@Query(value = "select count(agv.id) from AgvTask agv where agv.endSlotCode=:endSlotCode and agv.type=:type and agv.jobType=:jobType and agv.status in ('OPEN','ATCALL','UP_CONTAINER') ")
int findByEndSlotCode(String endSlotCode, String type, String jobType);
Long findByEndSlotCode(String endSlotCode, String type, String jobType);
}

View File

@ -5,8 +5,16 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface LesRepository extends JpaRepository<Les, Long>, JpaSpecificationExecutor<Les> {
@Query(value = " from Les les WHERE les.taskCode=:taskCode ")
@Query(value = " from Les les where les.taskCode=:taskCode ")
Les findByTaskCode(String taskCode);
@Query(value = " from Les les where les.agvTaskId is null and les.onlineNo=:onlineNo and les.srcPositionCode=:pointCode ")
List<Les> findByOnlineNo(String pointCode,String onlineNo);
@Query(value = " from Les les where les.agvTaskId=:agvTaskId and les.dstPositionCode=:currentPositionCode ")
List<Les> findByAgvTaskId(Long agvTaskId, String currentPositionCode);
}

View File

@ -0,0 +1,51 @@
package com.youchain.businessdata.rest;
import com.youchain.annotation.AnonymousAccess;
import com.youchain.annotation.Log;
import com.youchain.appupdate.inputJson.MissionStateCallback;
import com.youchain.businessdata.domain.AgvTask;
import com.youchain.businessdata.service.AgvTaskService;
import com.youchain.businessdata.service.KMReService;
import com.youchain.exception.handler.ApiResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.OK;
@RestController
@RequiredArgsConstructor
@Api(tags = "KMReS")
@RequestMapping("/interfaces/api/amr")
@Slf4j
public class KMReSController {
private final AgvTaskService agvTaskService;
private final KMReService kmReService;
@PostMapping("/missionStateCallback")
@Log("KMReS接口回调")
@ApiOperation("KMReS接口回调")
@AnonymousAccess
public ResponseEntity<Object> missionStateCallback(@RequestBody MissionStateCallback missionStateCallback) {
String id = missionStateCallback.getMissionCode();//作业 id
String containerCode = missionStateCallback.getContainerCode();//容器编号
String missionStatus = missionStateCallback.getMissionStatus();//作业当前状态
String currentPosition = missionStateCallback.getCurrentPosition();//容器当前位置
try {
//货架任务
AgvTask agvTask = agvTaskService.findById(Long.parseLong(id));
kmReService.missionStateCallback(agvTask, missionStatus, containerCode, currentPosition);
return new ResponseEntity<>(ApiResult.success(), HttpStatus.OK);
} catch (Exception e) {
return new ResponseEntity<>(ApiResult.fail(e.getMessage()), HttpStatus.BAD_REQUEST);
}
}
}

View File

@ -95,11 +95,11 @@ public interface AgvTaskService {
* agvTask
* @param bizStatus
* @param stock
* @param srcPoint
* @param endPoint
* @param srcPointCode
* @param endPointCode
* @param jobType
*/
AgvTask createAgvTask(String bizStatus, Stock stock, Point srcPoint, Point endPoint,String jobType);
AgvTask createAgvTask(String bizStatus, Stock stock, String srcPointCode, String endPointCode,String jobType);
/**
*

View File

@ -70,9 +70,10 @@ public interface KMReService {
* agvJSON
*
* @param agvTask
* @param tugCount
* @param tugModels
*/
String sendAgvTaskQYCJson(AgvTask agvTask, List<String> tugModels);
String sendAgvTaskQYCJson(AgvTask agvTask, int tugCount, List<String> tugModels);
/**
* agv
@ -97,4 +98,9 @@ public interface KMReService {
* @param agvTask
*/
String operationFeedbackJson(AgvTask agvTask);
/**
*
*/
String updateTuggerTrailerInfo(List<String> tugModels);
}

View File

@ -83,4 +83,10 @@ public interface LesService {
*/
String lesCallBack(String currentPositionCode,String taskCode);
/**
*
* @param agvTaskId
* @param currentPositionCode
*/
void arrivedLes(Long agvTaskId,String currentPositionCode);
}

View File

@ -1,8 +1,13 @@
package com.youchain.businessdata.service.dto;
import com.youchain.annotation.Query;
import lombok.Data;
@Data
public class LesQueryCriteria {
@Query(type = Query.Type.LEFT_LIKE)
private String taskCode;
@Query(type = Query.Type.LEFT_LIKE)
private String materialCode;
}

View File

@ -126,14 +126,15 @@ public class AgvTaskServiceImpl implements AgvTaskService {
@Override
@Transactional(rollbackFor = Exception.class)
public AgvTask createAgvTask(String bizStatus, Stock stock, Point srcPoint, Point endPoint, String jobType) {
public AgvTask createAgvTask(String bizStatus, Stock stock, String srcPointCode, String endPointCode, String jobType) {
AgvTask agvTask = AgvTask.builder()
.type(bizStatus)
.stockCode(stock.getCode())
.startSlotCode(srcPoint.getCode())
.endSlotCode(endPoint.getCode())
.type(BizStatus.MOVE)
.stockCode(stock==null?null:stock.getCode())
.startSlotCode(srcPointCode)
.endSlotCode(endPointCode)
.status(BizStatus.OPEN)
.jobType(jobType)
.jobPriority(1)
.build();
agvTaskRepository.save(agvTask);
return agvTask;

View File

@ -20,6 +20,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.sql.Array;
import java.sql.Timestamp;
import java.util.*;
@ -30,8 +31,8 @@ public class KMReServiceImpl implements KMReService {
private final DictRepository dictRepository;
private final StockService stockService;
private final PointService pointService;
private final TaskService taskService;
private final AgvTaskService agvTaskService;
private final LesService lesService;
/**
@ -316,7 +317,7 @@ public class KMReServiceImpl implements KMReService {
}
@Override
public String sendAgvTaskQYCJson(AgvTask agvTask, List<String> tugModels) {
public String sendAgvTaskQYCJson(AgvTask agvTask ,int tugCount, List<String> tugModels) {
JSONObject jsonObject = new JSONObject(true);
String requestId = TimeNumberUtils.getGTTaskCode();
Map<String, Object> objMap = new LinkedHashMap<>();
@ -336,26 +337,37 @@ public class KMReServiceImpl implements KMReService {
JSONObject missionDataObj = new JSONObject(true);
Map<String, Object> missionDataMap = new LinkedHashMap<>();
Point point = pointService.validatePoint(agvTask.getStartSlotCode());
String areaCode = point.getArea().getCode();
if("XJQ".equals(areaCode)){
tugModels=Arrays.asList("modelA", "modelB");
}else{
tugCount=tugModels.size();
}
missionDataMap.put("sequence", 1);//序号
missionDataMap.put("type", "NODE_POINT");//作业类型:点位NODE_POINT;区域NODE_AREA
missionDataMap.put("position", agvTask.getStartSlotCode());//起点
missionDataMap.put("actionType", "TUGGER_ATTACH");//动作TUGGER_ATTACH挂钩TUGGER_DETACH脱钩
missionDataMap.put("tugCount", tugModels.size());//牵引车后方的拖挂车数量
missionDataMap.put("tugCount", tugCount);//牵引车后方的拖挂车数量
missionDataMap.put("passStrategy", "MANUAL");//当前任务点结束后放行策略:自动AUTO;手动MANUAL
missionDataMap.put("tugModels", tugModels);//牵引车后方的拖挂车规格【模型名字】需要和tugCount一致
missionDataObj.putAll(missionDataMap);
missionDataArray.add(missionDataObj);
JSONObject missionDataObj2 = new JSONObject(true);
Map<String, Object> missionDataMap2 = new LinkedHashMap<>();
missionDataMap2.put("sequence", 2);//序号
missionDataMap2.put("type", "NODE_AREA");//作业类型:点位NODE_POINT;区域NODE_AREA
missionDataMap2.put("position", agvTask.getEndSlotCode());//终点
missionDataMap.put("actionType", "TUGGER_DETACH");//动作TUGGER_ATTACH挂钩TUGGER_DETACH脱钩
missionDataMap.put("passStrategy", "AUTO");//当前任务点结束后放行策略:自动AUTO;手动MANUAL
missionDataMap2.put("waitingMillis", 0);//自动触发离开当前任务节点的时间,默认单位:毫秒
missionDataObj2.putAll(missionDataMap2);
missionDataArray.add(missionDataObj2);
String [] endSlotCodes =agvTask.getEndSlotCode().split(",");
int sum=1;
for (int i = 0; i < endSlotCodes.length; i++) {
JSONObject missionDataObj2 = new JSONObject(true);
Map<String, Object> missionDataMap2 = new LinkedHashMap<>();
missionDataMap2.put("sequence", (sum + (i + 1)));//序号
missionDataMap2.put("type", "NODE_POINT");//作业类型:点位NODE_POINT;区域NODE_AREA
missionDataMap2.put("position", endSlotCodes[i]);//终点
missionDataMap2.put("actionType", "TUGGER_DETACH");//动作TUGGER_ATTACH挂钩TUGGER_DETACH脱钩
missionDataMap2.put("passStrategy", "AUTO");//当前任务点结束后放行策略:自动AUTO;手动MANUAL
missionDataMap2.put("waitingMillis", 0);//自动触发离开当前任务节点的时间,默认单位:毫秒
missionDataObj2.putAll(missionDataMap2);
missionDataArray.add(missionDataObj2);
}
objMap.put("missionData", missionDataArray);
jsonObject.putAll(objMap);
@ -395,32 +407,23 @@ public class KMReServiceImpl implements KMReService {
@Override
@Transactional(rollbackFor = Exception.class)
public void missionStateCallback(AgvTask agvTask, String status, String containerCode, String currentPosition) {
Stock stock = stockService.validateStock(containerCode);
//顶升的是起点;其它终点;
Point point;
String pointCode;
if ("UP_CONTAINER".equals(status) || "FORK_UP".equals(status)) {
pointCode = agvTask.getStartSlotCode();
} else {
pointCode = agvTask.getEndSlotCode();
}
point = pointService.queryPoint(pointCode, null, null, null);
switch (status) {
case "UP_CONTAINER":
case "FORK_UP":
handleUpContainer(agvTask, stock, point);//容器顶升
break;
case "FORK_DOWN":
//容器放下
//容器顶升
handleUpContainer(agvTask);
break;
case "ARRIVED":
//容器到达
handleArrivedContainer(agvTask,currentPosition);
break;
case "COMPLETED":
handleComContainer(agvTask, stock, point);//任务完成
//任务完成
handleComContainer(agvTask);
break;
case "CANCELED":
handleCanceledTask(agvTask, stock, point);//任务取消
//任务取消
handleCanceledTask(agvTask);
break;
case "RESEND":
handleResendTask(agvTask);//重新发送
@ -431,65 +434,99 @@ public class KMReServiceImpl implements KMReService {
@Override
public String operationFeedbackJson(AgvTask agvTask) {
JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
JSONObject jsonObject = new JSONObject(true);
//请求 id
jsonObject.put("requestId", String.valueOf(System.currentTimeMillis()));
//容器类型
//当前执行任务的容器号
jsonObject.put("containerCode", "");
//容器编号
//当前执行作业id
jsonObject.put("missionCode", agvTask.getId());
//容器当前位置
//当前执行作业的节点
jsonObject.put("position", "");
return jsonObject.toString();
}
@Override
public String updateTuggerTrailerInfo(List<String> tugModels) {
JSONObject jsonObject = new JSONObject(true);
//请求 id
String requestId = String.valueOf(System.currentTimeMillis());
jsonObject.put("requestId", requestId);
//当前执行作业id
jsonObject.put("missionCode", requestId);
//当前执行任务的小车号
jsonObject.put("robotId", "");
//拖挂车数量
jsonObject.put("tugCount", tugModels.size());
//拖挂车类型集
jsonObject.put("tugModels", tugModels);
//是否同步继续(放行)任务
jsonObject.put("resumeMission", true);
return jsonObject.toString();
}
/**
*
*
* @param agvTask
* @param stock
*/
private void handleUpContainer(AgvTask agvTask, Stock stock, Point startPoint) {
//顶升,起点释放点位
pointService.freePoint(startPoint);
agvTask.setStockCode(stock == null ? null : stock.getCode());
private void handleUpContainer(AgvTask agvTask) {
agvTask.setStatus(BizStatus.UP_CONTAINER);
agvTaskService.update(agvTask);
}
/**
*
*
* @param agvTask
*/
private void handleArrivedContainer(AgvTask agvTask, String currentPosition) {
// 验证当前点位
pointService.validatePoint(currentPosition);
// 记录当前节点
lesService.arrivedLes(agvTask.getId(), currentPosition);
agvTask.setStatus(BizStatus.ARRIVED);
// 更新点位路径
updateSlotCode(agvTask, currentPosition);
agvTaskService.update(agvTask);
}
private void updateSlotCode(AgvTask agvTask, String newPosition) {
String currentSlotCode = agvTask.getSlotCode();
// 处理空路径情况
if (StringUtils.isEmpty(currentSlotCode)) {
agvTask.setSlotCode(newPosition);
return;
}
// 使用 Set 快速检查重复点位
Set<String> existingPositions = new HashSet<>(Arrays.asList(currentSlotCode.split(",")));
if (!existingPositions.contains(newPosition)) {
agvTask.setSlotCode(currentSlotCode + "," + newPosition);
}
}
/**
*
*
* @param agvTask
* @param stock
*/
private void handleComContainer(AgvTask agvTask, Stock stock, Point endPoint) {
//任务完成根据AGV任务的目标点位走对应流程
switch (agvTask.getType()) {
case BizStatus.PICK:
break;
case BizStatus.ASN:
break;
default:
throw new BadRequestException("任务类型不存在!");
}
private void handleComContainer(AgvTask agvTask) {
//更新任务状态
this.updateAgvTaskStatus(agvTask, stock, BizStatus.FINISH);
this.updateAgvTaskStatus(agvTask, BizStatus.FINISH);
}
/**
*
*
* @param agvTask
* @param stock
*/
private void handleCanceledTask(AgvTask agvTask, Stock stock, Point endPoint) {
private void handleCanceledTask(AgvTask agvTask) {
//更新任务状态
this.updateAgvTaskStatus(agvTask, stock, BizStatus.CANCEL);
this.updateAgvTaskStatus(agvTask, BizStatus.CANCEL);
}
/**
@ -515,13 +552,6 @@ public class KMReServiceImpl implements KMReService {
.build();
agvTaskService.create(newAgvTask);
List<Task> taskList = new ArrayList<>();
for (Task task : taskList) {
task.setAgvTask(newAgvTask);
taskService.update(task);
}
// 根据任务类型发送不同的实现
switch (agvTask.getJobType()) {
@ -546,11 +576,9 @@ public class KMReServiceImpl implements KMReService {
*
*
* @param agvTask
* @param stock
* @param status
*/
private void updateAgvTaskStatus(AgvTask agvTask, Stock stock, String status) {
agvTask.setStockCode(stock == null ? null : stock.getCode());
private void updateAgvTaskStatus(AgvTask agvTask, String status) {
agvTask.setStatus(status);
agvTask.setEndTime(new Timestamp(new Date().getTime()));
agvTaskService.update(agvTask);

View File

@ -87,7 +87,7 @@ public class LesServiceImpl implements LesService {
Map<String, Object> map = new LinkedHashMap<>();
map.put("任务号", les.getTaskCode());
map.put("任务类型", les.getTaskType());
map.put("物料代码", les.getMaterialCode());
map.put("物料", les.getMaterialCode());
map.put("编组/线路", les.getRouteCode());
map.put("料箱号", les.getBoxNo());
map.put("上线单号", les.getOnlineNo());
@ -121,7 +121,7 @@ public class LesServiceImpl implements LesService {
}
@Override
public String lesCallBack(String currentPositionCode,String taskCode) {
public String lesCallBack(String currentPositionCode, String taskCode) {
JSONObject jsonObject = new JSONObject(true);
String guid = String.valueOf(System.currentTimeMillis());
//LES任务的业务单号不一定唯一
@ -146,6 +146,18 @@ public class LesServiceImpl implements LesService {
return jsonObject.toString();
}
@Override
@Transactional(rollbackFor = Exception.class)
public void arrivedLes(Long agvTaskId, String currentPositionCode) {
List<Les> lesList = lesRepository.findByAgvTaskId(agvTaskId, currentPositionCode);
for (Les les : lesList) {
les.setArrivedTime(new Timestamp(new Date().getTime()));
}
if (!lesList.isEmpty()) {
lesRepository.saveAll(lesList);
}
}
/**
*
*
@ -157,19 +169,19 @@ public class LesServiceImpl implements LesService {
}
//物料有值;说明是料箱上线场景
if (StringUtils.isNotEmpty(lesRequest.getMaterialCode())) {
if(StringUtils.isEmpty(lesRequest.getRouteCode())){
if (StringUtils.isEmpty(lesRequest.getRouteCode())) {
throw new BadRequestException("routeCode必填");
}
if(StringUtils.isEmpty(lesRequest.getBoxNo())){
if (StringUtils.isEmpty(lesRequest.getBoxNo())) {
throw new BadRequestException("boxNo必填");
}
if(StringUtils.isEmpty(lesRequest.getOnlineNo())){
if (StringUtils.isEmpty(lesRequest.getOnlineNo())) {
throw new BadRequestException("onlineNo必填");
}
if (lesRequest.getPositionCodePath()==null ||lesRequest.getPositionCodePath().isEmpty() || lesRequest.getPositionCodePath().size() < 2) {
if (lesRequest.getPositionCodePath() == null || lesRequest.getPositionCodePath().isEmpty() || lesRequest.getPositionCodePath().size() < 2) {
throw new BadRequestException("节点不能为空且长度至少为2");
}
}

View File

@ -60,9 +60,9 @@ public interface BizStatus {
public static String ATCALL = "ATCALL";
/**
* -
* -
*/
public static String ATWORK = "ATWORK";
public static String ARRIVED = "ARRIVED";
/**
* -