LES下发、LES回传、APP功能、AGV任务
parent
ddd46bb868
commit
c64cf86d1a
|
|
@ -19,6 +19,14 @@ import cn.hutool.core.lang.Assert;
|
|||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
|
|
@ -33,9 +41,11 @@ import org.springframework.cache.interceptor.KeyGenerator;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisOperations;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.RedisSerializationContext;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import reactor.util.annotation.Nullable;
|
||||
|
|
@ -99,6 +109,32 @@ public class RedisConfig extends CachingConfigurerSupport {
|
|||
return template;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RedisCacheManager redisCacheManager(RedisConnectionFactory connectionFactory) {
|
||||
// 序列化配置
|
||||
ObjectMapper om = new ObjectMapper();
|
||||
om.registerModule(new JavaTimeModule())
|
||||
.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false)
|
||||
.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false)
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
|
||||
Jackson2JsonRedisSerializer<Object> serializer = new Jackson2JsonRedisSerializer<>(Object.class);
|
||||
serializer.setObjectMapper(om);
|
||||
// 默认配置
|
||||
RedisCacheConfiguration defaultConfig = RedisCacheConfiguration.defaultCacheConfig()
|
||||
.entryTtl(Duration.ofDays(7)) // 默认过期时间7天
|
||||
.serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(new org.springframework.data.redis.serializer.StringRedisSerializer()))
|
||||
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(serializer))
|
||||
.disableCachingNullValues();
|
||||
|
||||
return RedisCacheManager.builder(connectionFactory)
|
||||
.cacheDefaults(defaultConfig)
|
||||
.transactionAware()
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义缓存key生成策略,默认将使用该策略
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
package com.youchain.appupdate.request;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class BindLarge {
|
||||
@ApiModelProperty(value = "起点", required = true)
|
||||
String srcPositionCode;
|
||||
|
||||
@ApiModelProperty(value = "料箱和dolly", required = true)
|
||||
List<BoxAndDolly> boxAndDolly;
|
||||
}
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
package com.youchain.appupdate.inputJson;
|
||||
package com.youchain.appupdate.request;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SmallRequest {
|
||||
public class BindSmall {
|
||||
@ApiModelProperty(value = "起点", required = true)
|
||||
String pointCode;
|
||||
String srcPositionCode;
|
||||
|
||||
@ApiModelProperty(value = "上线单号",required = true)
|
||||
String onlineNo;
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.youchain.appupdate.request;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BoxAndDolly {
|
||||
@ApiModelProperty(value = "料箱号", required = true)
|
||||
String boxNo;
|
||||
|
||||
@ApiModelProperty(value = "dolly码", required = true)
|
||||
String dolly;
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.youchain.appupdate.request;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LinePoint {
|
||||
@ApiModelProperty(value = "线边库位", required = true)
|
||||
String dstPositionCode;
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.youchain.appupdate.request;
|
||||
|
||||
import com.youchain.appupdate.response.LesTask;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class Online {
|
||||
@ApiModelProperty(value = "料箱号", required = true)
|
||||
String boxNo;
|
||||
|
||||
@ApiModelProperty(value = "库位号", required = true)
|
||||
String dstPositionCode;
|
||||
|
||||
@ApiModelProperty(value = "任务信息", required = true)
|
||||
List<LesTask> data;
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.youchain.appupdate.response;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LesTask {
|
||||
//id
|
||||
Long id;
|
||||
|
||||
//上线单号
|
||||
String onlineNo;
|
||||
|
||||
//日期
|
||||
Date createTime;
|
||||
|
||||
//编组/线路
|
||||
String routeCode;
|
||||
|
||||
//目标库位
|
||||
String dstPositionCode;
|
||||
|
||||
//料箱号
|
||||
String boxNo;
|
||||
|
||||
//物料号
|
||||
String materialCode;
|
||||
|
||||
//箱内零件数量
|
||||
Double caseNum;
|
||||
|
||||
}
|
||||
|
|
@ -2,11 +2,16 @@ 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.request.BindLarge;
|
||||
import com.youchain.appupdate.request.LinePoint;
|
||||
import com.youchain.appupdate.request.BindSmall;
|
||||
import com.youchain.appupdate.request.Online;
|
||||
import com.youchain.appupdate.service.NioF3AppService;
|
||||
import com.youchain.businessdata.inputJson.LesRequest;
|
||||
import com.youchain.appupdate.response.LesTask;
|
||||
import com.youchain.businessdata.inputJson.UpdateTuggerTrailerInfo;
|
||||
import com.youchain.businessdata.service.KMReService;
|
||||
import com.youchain.exception.handler.ApiResult;
|
||||
import com.youchain.exception.handler.LesResult;
|
||||
import com.youchain.utils.UrlApi;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
|
@ -18,6 +23,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
|
|
@ -27,13 +34,67 @@ public class NioF3AppController {
|
|||
|
||||
private final NioF3AppService nioF3AppService;
|
||||
|
||||
@PostMapping("/smallConfirm")
|
||||
@Log("小件扫描确认")
|
||||
@ApiOperation("小件扫描确认")
|
||||
private final KMReService kmReService;
|
||||
|
||||
@PostMapping("/bindSmallItemPicking")
|
||||
@Log("小件拣选绑定")
|
||||
@ApiOperation("小件拣选绑定")
|
||||
@AnonymousAccess
|
||||
public ResponseEntity<Object> smallConfirm(@RequestBody SmallRequest smallRequest) {
|
||||
public ResponseEntity<Object> bindSmallItemPicking(@RequestBody BindSmall bindSmall) {
|
||||
try {
|
||||
nioF3AppService.smallConfirm(smallRequest);
|
||||
nioF3AppService.bindSmallItemPicking(bindSmall);
|
||||
return new ResponseEntity<>(ApiResult.success(), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(ApiResult.fail(e.getMessage()), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/bindLargeItemPicking")
|
||||
@Log("大件拣选绑定")
|
||||
@ApiOperation("大件拣选绑定")
|
||||
@AnonymousAccess
|
||||
public ResponseEntity<Object> bindLargeItemPicking(@RequestBody BindLarge bindLarge) {
|
||||
try {
|
||||
nioF3AppService.bindLargeItemPicking(bindLarge);
|
||||
return new ResponseEntity<>(ApiResult.success(), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(ApiResult.fail(e.getMessage()), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/findByLinePoint")
|
||||
@Log("线边库位查询")
|
||||
@ApiOperation("线边库位查询")
|
||||
@AnonymousAccess
|
||||
public ResponseEntity<Object> findByLinePoint(@RequestBody LinePoint linePoint) {
|
||||
try {
|
||||
List<LesTask> lesList = nioF3AppService.findByLinePoint(linePoint.getDstPositionCode());
|
||||
return new ResponseEntity<>(ApiResult.success(lesList), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(ApiResult.fail(e.getMessage()), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/onlineConfirm")
|
||||
@Log("线边上线确认")
|
||||
@ApiOperation("线边上线确认")
|
||||
@AnonymousAccess
|
||||
public ResponseEntity<Object> onlineConfirm(@RequestBody Online online) {
|
||||
try {
|
||||
nioF3AppService.onlineConfirm(online);
|
||||
return new ResponseEntity<>(ApiResult.success(), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(ApiResult.fail(e.getMessage()), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/updateTuggerTrailerInfo")
|
||||
@Log("更新器具规格")
|
||||
@ApiOperation("更新器具规格")
|
||||
@AnonymousAccess
|
||||
public ResponseEntity<Object> updateTuggerTrailerInfo(@RequestBody UpdateTuggerTrailerInfo updateTuggerTrailerInfo) {
|
||||
try {
|
||||
kmReService.sendAgvTaskToContainer(UrlApi.updateTuggerTrailerInfo(),kmReService.updateTuggerTrailerInfo(updateTuggerTrailerInfo));
|
||||
return new ResponseEntity<>(ApiResult.success(), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(ApiResult.fail(e.getMessage()), HttpStatus.BAD_REQUEST);
|
||||
|
|
|
|||
|
|
@ -1,17 +1,36 @@
|
|||
package com.youchain.appupdate.service;
|
||||
|
||||
import com.youchain.appupdate.inputJson.SmallRequest;
|
||||
import com.youchain.appupdate.request.BindLarge;
|
||||
import com.youchain.appupdate.request.BindSmall;
|
||||
import com.youchain.appupdate.request.Online;
|
||||
import com.youchain.appupdate.response.LesTask;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface NioF3AppService {
|
||||
|
||||
/**
|
||||
* 小件扫码确认
|
||||
* @param smallRequest 请求参数
|
||||
* 小件拣选绑定
|
||||
* @param bindSmall 请求参数
|
||||
*/
|
||||
void smallConfirm(SmallRequest smallRequest);
|
||||
void bindSmallItemPicking(BindSmall bindSmall);
|
||||
|
||||
/**
|
||||
* 大件扫码确认
|
||||
* 大件拣选绑定
|
||||
* @param bindLarge 请求参数
|
||||
*/
|
||||
void LargeConfirm();
|
||||
void bindLargeItemPicking(BindLarge bindLarge);
|
||||
|
||||
/**
|
||||
* 线边库位查询
|
||||
* @param dstPositionCode 目标库位
|
||||
* @return List<LesTask>
|
||||
*/
|
||||
List<LesTask> findByLinePoint(String dstPositionCode);
|
||||
|
||||
/**
|
||||
* 线边上线确认
|
||||
* @param online 请求参数
|
||||
*/
|
||||
void onlineConfirm(Online online);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,18 @@
|
|||
package com.youchain.appupdate.service.impl;
|
||||
|
||||
import com.youchain.appupdate.inputJson.SmallRequest;
|
||||
import com.youchain.appupdate.request.BindLarge;
|
||||
import com.youchain.appupdate.request.BindSmall;
|
||||
import com.youchain.appupdate.request.BoxAndDolly;
|
||||
import com.youchain.appupdate.request.Online;
|
||||
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.appupdate.response.LesTask;
|
||||
import com.youchain.businessdata.service.LesService;
|
||||
import com.youchain.exception.BadRequestException;
|
||||
import com.youchain.utils.BizStatus;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
|
@ -17,7 +21,10 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
|
|
@ -25,39 +32,34 @@ import java.util.stream.Collectors;
|
|||
@RequiredArgsConstructor
|
||||
public class NioF3AppServiceImpl implements NioF3AppService {
|
||||
private final LesRepository lesRepository;
|
||||
private final LesService lesService;
|
||||
private final PointService pointService;
|
||||
private final AgvTaskService agvTaskService;
|
||||
private final KMReService kmReService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void smallConfirm(SmallRequest smallRequest) {
|
||||
public void bindSmallItemPicking(BindSmall bindSmall) {
|
||||
//验证参数
|
||||
validateParams(smallRequest);
|
||||
|
||||
//起点
|
||||
String pointCode = smallRequest.getPointCode();
|
||||
|
||||
//上线单号
|
||||
String onlineNo = smallRequest.getOnlineNo();
|
||||
|
||||
//验证起点
|
||||
pointService.validatePoint(pointCode);
|
||||
validateParams(bindSmall);
|
||||
|
||||
//验证Les任务
|
||||
List<Les> lesList = validateLes(pointCode, onlineNo);
|
||||
List<Les> lesList = validateLes(bindSmall.getSrcPositionCode(), bindSmall.getOnlineNo());
|
||||
|
||||
//验证起点是否有Agv任务
|
||||
validateAgvTask(pointCode);
|
||||
validateAgvTask(bindSmall.getSrcPositionCode());
|
||||
|
||||
//获取目标点位
|
||||
String endPointCode = getEndPointCode(lesList);
|
||||
|
||||
//生成Agv任务
|
||||
AgvTask agvTask = agvTaskService.createAgvTask(BizStatus.OPEN, null, pointCode, endPointCode, "TUGGER");
|
||||
AgvTask agvTask = agvTaskService.createAgvTask(BizStatus.OPEN, null, bindSmall.getSrcPositionCode(), endPointCode, "TUGGER");
|
||||
|
||||
//绑定任务
|
||||
bindLesTask(lesList, agvTask.getId());
|
||||
|
||||
//下发任务
|
||||
kmReService.sendAgvTask(agvTask, kmReService.sendAgvTaskQYCJson(agvTask, smallRequest.getShooter(),null));
|
||||
kmReService.sendAgvTask(agvTask, kmReService.sendAgvTaskQYCJson(agvTask, bindSmall.getShooter(), null));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -65,14 +67,17 @@ public class NioF3AppServiceImpl implements NioF3AppService {
|
|||
*
|
||||
* @param smallRequest -> 参数
|
||||
*/
|
||||
private void validateParams(SmallRequest smallRequest) {
|
||||
if (StringUtils.isEmpty(smallRequest.getPointCode())) {
|
||||
throw new BadRequestException("pointCode必填");
|
||||
private void validateParams(BindSmall smallRequest) {
|
||||
if (StringUtils.isEmpty(smallRequest.getSrcPositionCode())) {
|
||||
throw new BadRequestException("起点必填");
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(smallRequest.getOnlineNo())) {
|
||||
throw new BadRequestException("onlineNo必填");
|
||||
throw new BadRequestException("上线单号必填");
|
||||
}
|
||||
|
||||
//验证起点
|
||||
pointService.validatePoint(smallRequest.getSrcPositionCode());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -82,17 +87,17 @@ public class NioF3AppServiceImpl implements NioF3AppService {
|
|||
* @param onlineNo -> 上线单号
|
||||
*/
|
||||
private List<Les> validateLes(String pointCode, String onlineNo) {
|
||||
List<Les> lesList = lesRepository.findByOnlineNo(pointCode,onlineNo);
|
||||
List<Les> lesList = lesRepository.findByOnlineNo(pointCode, onlineNo);
|
||||
if (lesList.isEmpty()) {
|
||||
throw new BadRequestException("系统未识别到任务");
|
||||
throw new BadRequestException("PDA扫描的起点和上线单号未匹配LES任务");
|
||||
}
|
||||
return lesList;
|
||||
}
|
||||
|
||||
private void validateAgvTask(String pointCode) {
|
||||
Boolean bool = agvTaskService.findByStartSlotCode(pointCode, "TUGGER_MOVE", "TUGGER");
|
||||
Boolean bool = agvTaskService.findByStartSlotCode(pointCode, "MOVE", "TUGGER");
|
||||
if (bool) {
|
||||
throw new BadRequestException(String.format("该点位:%s有任务,请勿重复下发", pointCode));
|
||||
throw new BadRequestException(pointCode + "点位有任务,请勿重复下发");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -103,9 +108,166 @@ public class NioF3AppServiceImpl implements NioF3AppService {
|
|||
.collect(Collectors.joining(",")); // 用逗号拼接字符串
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void bindLesTask(List<Les> lesList, Long agvTaskId) {
|
||||
//获取Les
|
||||
for (Les les : lesList) {
|
||||
les.setAgvTaskId(agvTaskId);
|
||||
}
|
||||
lesRepository.saveAll(lesList);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void LargeConfirm() {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void bindLargeItemPicking(BindLarge bindLarge) {
|
||||
//验证参数
|
||||
validateParams(bindLarge);
|
||||
|
||||
//获取所有扫描的料箱号
|
||||
List<String> boxNos = bindLarge.getBoxAndDolly().stream()
|
||||
.map(BoxAndDolly::getBoxNo)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
//验证Les任务
|
||||
List<Les> lesList = validateLes(bindLarge.getSrcPositionCode(), boxNos);
|
||||
|
||||
//验证料箱号
|
||||
validateBoxNos(lesList, boxNos);
|
||||
|
||||
//验证起点是否有Agv任务
|
||||
validateAgvTask(bindLarge.getSrcPositionCode());
|
||||
|
||||
//获取目标点位
|
||||
String endPointCode = getEndPointCode(lesList);
|
||||
|
||||
//生成Agv任务
|
||||
AgvTask agvTask = agvTaskService.createAgvTask(BizStatus.OPEN, null, bindLarge.getSrcPositionCode(), endPointCode, "TUGGER");
|
||||
|
||||
//绑定任务
|
||||
bindLesTask(lesList, agvTask.getId());
|
||||
|
||||
//下发任务
|
||||
kmReService.sendAgvTask(agvTask, kmReService.sendAgvTaskQYCJson(agvTask, boxNos.size(), boxNos));
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证参数
|
||||
*
|
||||
* @param bindLarge -> 参数
|
||||
*/
|
||||
private void validateParams(BindLarge bindLarge) {
|
||||
if (StringUtils.isEmpty(bindLarge.getSrcPositionCode())) {
|
||||
throw new BadRequestException("起点必填");
|
||||
}
|
||||
|
||||
if (bindLarge.getBoxAndDolly().isEmpty()) {
|
||||
throw new BadRequestException("料箱和Dolly未扫描绑定");
|
||||
}
|
||||
|
||||
//验证起点
|
||||
pointService.validatePoint(bindLarge.getSrcPositionCode());
|
||||
}
|
||||
|
||||
public void validateBoxNos(List<Les> lesList, List<String> boxNos) {
|
||||
// 1.检查料箱是否有重复
|
||||
Set<String> seen = new HashSet<>();
|
||||
Set<String> duplicates = new HashSet<>();
|
||||
for (String boxNo : boxNos) {
|
||||
if (!seen.add(boxNo)) {
|
||||
duplicates.add(boxNo);
|
||||
}
|
||||
}
|
||||
if (!duplicates.isEmpty()) {
|
||||
throw new BadRequestException("PDA扫描的料箱号重复:明细见下列" + duplicates);
|
||||
}
|
||||
|
||||
// 2.匹配料箱任务
|
||||
Set<String> lesBoxNos = lesList.stream()
|
||||
.map(Les::getBoxNo)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 2. 找出 boxNos 中不在 lesBoxNos 的料箱号(缺失的料箱)
|
||||
Set<String> missingBoxNos = boxNos.stream()
|
||||
.filter(boxNo -> !lesBoxNos.contains(boxNo))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
if (!missingBoxNos.isEmpty()) {
|
||||
throw new BadRequestException("PDA扫描起点与料箱号未匹配LES任务:明细见下列" + missingBoxNos);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证Les任务
|
||||
*
|
||||
* @param srcPositionCode -> 起点
|
||||
* @param boxNos -> 箱号
|
||||
*/
|
||||
private List<Les> validateLes(String srcPositionCode, List<String> boxNos) {
|
||||
List<Les> lesList = lesRepository.findByBoxNoAndPoint(srcPositionCode, boxNos);
|
||||
if (lesList.isEmpty()) {
|
||||
throw new BadRequestException("PDA扫描的起点及全部料箱号均与LES任务不匹配");
|
||||
}
|
||||
return lesList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LesTask> findByLinePoint(String dstPositionCode) {
|
||||
List<LesTask> lesList = lesRepository.findByLinePoint(dstPositionCode);
|
||||
if (lesList.isEmpty()) {
|
||||
throw new BadRequestException("PDA扫描的停靠点未匹配到LES任务");
|
||||
}
|
||||
return lesList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void onlineConfirm(Online online) {
|
||||
//验证参数
|
||||
validateParams(online);
|
||||
|
||||
//根据料箱号、库位号匹配任务
|
||||
Long lesId = getLesTask(online);
|
||||
|
||||
//获取Les
|
||||
Les les = lesRepository.findById(lesId).orElseGet(Les::new);
|
||||
|
||||
//回传LES
|
||||
lesService.lesCallBack(les, lesService.lesCallBackJson(les.getDstPositionCode(), les.getTaskCode()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证参数
|
||||
*
|
||||
* @param online -> 参数
|
||||
*/
|
||||
private void validateParams(Online online) {
|
||||
if (StringUtils.isEmpty(online.getBoxNo())) {
|
||||
throw new BadRequestException("料箱号必填");
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(online.getDstPositionCode())) {
|
||||
throw new BadRequestException("库位号必填");
|
||||
}
|
||||
|
||||
if (online.getData().isEmpty()) {
|
||||
throw new BadRequestException("任务信息必填");
|
||||
}
|
||||
}
|
||||
|
||||
private Long getLesTask(Online online) {
|
||||
List<LesTask> lesTaskList = online.getData().stream()
|
||||
.filter(task ->
|
||||
Objects.equals(online.getBoxNo(), task.getBoxNo()) &&
|
||||
Objects.equals(online.getDstPositionCode(), task.getDstPositionCode())
|
||||
)
|
||||
.collect(Collectors.toList());
|
||||
if (lesTaskList.isEmpty()) {
|
||||
throw new BadRequestException("PDA扫描的料箱号和库位号未匹配LES任务");
|
||||
}
|
||||
|
||||
return lesTaskList.stream()
|
||||
.map(LesTask::getId)
|
||||
.collect(Collectors.toList()).get(0);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ public class PointServiceImpl implements PointService {
|
|||
public Point validatePoint(String position) {
|
||||
Point point = pointRepository.findByCode(position);
|
||||
if (point == null) {
|
||||
throw new BadRequestException("点位不存在或已失效");
|
||||
throw new BadRequestException(position + "点位不存在或已失效");
|
||||
}
|
||||
return point;
|
||||
}
|
||||
|
|
@ -152,9 +152,9 @@ public class PointServiceImpl implements PointService {
|
|||
|
||||
@Override
|
||||
public Point queryPoint(String code, String status, String type, String areaName) {
|
||||
List<Point> pointList= pointRepository.queryPoints(code, status, type, areaName);
|
||||
if(pointList.isEmpty()){
|
||||
throw new BadRequestException(code+"点位不存在或已失效");
|
||||
List<Point> pointList = pointRepository.queryPoints(code, status, type, areaName);
|
||||
if (pointList.isEmpty()) {
|
||||
throw new BadRequestException(code + "点位不存在或已失效");
|
||||
}
|
||||
return pointList.get(0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,14 @@ public class Les extends BaseEntity implements Serializable {
|
|||
@ApiModelProperty(value = "任务类型")
|
||||
private String taskType;
|
||||
|
||||
@Column(name = "`status`")
|
||||
@ApiModelProperty(value = "状态")
|
||||
private String status;
|
||||
|
||||
@Column(name = "`case_num`")
|
||||
@ApiModelProperty(value = "箱内零件数量")
|
||||
private Double caseNum=0D;
|
||||
|
||||
@Column(name = "`material_code`")
|
||||
@ApiModelProperty(value = "物料号")
|
||||
private String materialCode;
|
||||
|
|
@ -75,6 +83,18 @@ public class Les extends BaseEntity implements Serializable {
|
|||
@ApiModelProperty(value = "到达时间")
|
||||
private Timestamp arrivedTime;
|
||||
|
||||
@Column(name = "`req_message`")
|
||||
@ApiModelProperty(value = "请求报文")
|
||||
private String reqMessage;
|
||||
|
||||
@Column(name = "`rep_message`")
|
||||
@ApiModelProperty(value = "响应报文")
|
||||
private String repMessage;
|
||||
|
||||
@Column(name = "return_time")
|
||||
@ApiModelProperty(value = "回传时间")
|
||||
private Timestamp returnTime;
|
||||
|
||||
public void copy(Les source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
package com.youchain.businessdata.inputJson;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Dolly {
|
||||
@ApiModelProperty(value = "车码")
|
||||
String dolly;
|
||||
}
|
||||
|
|
@ -21,6 +21,9 @@ public class LesRequest {
|
|||
@ApiModelProperty(value = "任务类型",required = true, example = "bmfeed")
|
||||
String taskType;
|
||||
|
||||
@ApiModelProperty(value = "箱内零件数量", example = "0")
|
||||
String caseNum;
|
||||
|
||||
@ApiModelProperty(value = "物料代码", example = "物料代码")
|
||||
String materialCode;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package com.youchain.appupdate.inputJson;
|
||||
package com.youchain.businessdata.inputJson;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
package com.youchain.businessdata.inputJson;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class UpdateTuggerTrailerInfo {
|
||||
|
||||
@ApiModelProperty(value = "点位")
|
||||
String srcPositionCode;
|
||||
|
||||
@ApiModelProperty(value = "车码")
|
||||
List<Dolly> dollyList;
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.youchain.businessdata.repository;
|
||||
|
||||
import com.youchain.businessdata.domain.Les;
|
||||
import com.youchain.appupdate.response.LesTask;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
|
@ -12,9 +13,21 @@ public interface LesRepository extends JpaRepository<Les, Long>, JpaSpecificatio
|
|||
@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 is null and les.onlineNo=:onlineNo and les.srcPositionCode=:srcPositionCode ")
|
||||
List<Les> findByOnlineNo(String srcPositionCode, String onlineNo);
|
||||
|
||||
@Query(value = " from Les les where les.agvTaskId=:agvTaskId and les.dstPositionCode=:currentPositionCode ")
|
||||
@Query(value = " from Les les where les.agvTaskId=:agvTaskId and les.dstPositionCode=:currentPositionCode and les.status='OPEN' ")
|
||||
List<Les> findByAgvTaskId(Long agvTaskId, String currentPositionCode);
|
||||
|
||||
@Query(value = "select " +
|
||||
"new com.youchain.appupdate.response.LesTask(les.id,les.onlineNo,les.createTime," +
|
||||
"les.routeCode,les.dstPositionCode,les.boxNo,les.materialCode,les.caseNum) " +
|
||||
"from Les les " +
|
||||
"where les.agvTaskId > 0 " +
|
||||
"and les.dstPositionCode = :dstPositionCode " +
|
||||
"and les.status = 'ARRIVED'")
|
||||
List<LesTask> findByLinePoint(String dstPositionCode);
|
||||
|
||||
@Query(value = " from Les les where les.agvTaskId is null and les.srcPositionCode=:srcPositionCode and les.boxNo in (:boxNos) ")
|
||||
List<Les> findByBoxNoAndPoint(String srcPositionCode, List<String> boxNos);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ 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.inputJson.MissionStateCallback;
|
||||
import com.youchain.businessdata.service.AgvTaskService;
|
||||
import com.youchain.businessdata.service.KMReService;
|
||||
import com.youchain.exception.handler.ApiResult;
|
||||
|
|
@ -18,9 +18,6 @@ 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")
|
||||
|
|
@ -48,4 +45,6 @@ public class KMReSController {
|
|||
return new ResponseEntity<>(ApiResult.fail(e.getMessage()), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.youchain.businessdata.service;
|
||||
|
||||
import com.youchain.businessdata.domain.AgvTask;
|
||||
import com.youchain.businessdata.inputJson.UpdateTuggerTrailerInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -102,5 +103,5 @@ public interface KMReService {
|
|||
/**
|
||||
* 更新牵引车拖挂车信息
|
||||
*/
|
||||
String updateTuggerTrailerInfo(List<String> tugModels);
|
||||
String updateTuggerTrailerInfo(UpdateTuggerTrailerInfo updateTuggerTrailerInfo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,12 +76,19 @@ public interface LesService {
|
|||
void genAgvSchedulingTask( LesRequest lesRequest);
|
||||
|
||||
/**
|
||||
* LES任务回调
|
||||
* LES任务回调Json
|
||||
* @param currentPositionCode 当前点位
|
||||
* @param taskCode 任务号
|
||||
* @return json
|
||||
*/
|
||||
String lesCallBack(String currentPositionCode,String taskCode);
|
||||
String lesCallBackJson(String currentPositionCode,String taskCode);
|
||||
|
||||
/**
|
||||
* LES任务回调
|
||||
* @param les les
|
||||
* @param json 参数
|
||||
*/
|
||||
void lesCallBack(Les les,String json);
|
||||
|
||||
/**
|
||||
* 任务到达节点记录时间
|
||||
|
|
@ -89,4 +96,6 @@ public interface LesService {
|
|||
* @param currentPositionCode 当前点位
|
||||
*/
|
||||
void arrivedLes(Long agvTaskId,String currentPositionCode);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import lombok.Data;
|
|||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
|
||||
@Data
|
||||
public class LesDto {
|
||||
private Long id;
|
||||
|
|
@ -12,9 +11,15 @@ public class LesDto {
|
|||
//LES产生的任务号
|
||||
private String taskCode;
|
||||
|
||||
//任务类型"
|
||||
//任务类型
|
||||
private String taskType;
|
||||
|
||||
//状态
|
||||
private String status;
|
||||
|
||||
//箱内零件数量
|
||||
private Double caseNum;
|
||||
|
||||
//物料代码
|
||||
private String materialCode;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.youchain.basicdata.service.PointService;
|
|||
import com.youchain.basicdata.service.StockService;
|
||||
import com.youchain.businessdata.domain.AgvTask;
|
||||
import com.youchain.businessdata.domain.Task;
|
||||
import com.youchain.businessdata.inputJson.UpdateTuggerTrailerInfo;
|
||||
import com.youchain.businessdata.service.*;
|
||||
import com.youchain.exception.BadRequestException;
|
||||
import com.youchain.modules.quartz.utils.TimeNumberUtils;
|
||||
|
|
@ -17,6 +18,7 @@ import com.youchain.modules.system.repository.DictRepository;
|
|||
import com.youchain.utils.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
|
@ -317,7 +319,7 @@ public class KMReServiceImpl implements KMReService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String sendAgvTaskQYCJson(AgvTask agvTask ,int tugCount, 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<>();
|
||||
|
|
@ -339,10 +341,10 @@ public class KMReServiceImpl implements KMReService {
|
|||
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();
|
||||
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
|
||||
|
|
@ -354,8 +356,8 @@ public class KMReServiceImpl implements KMReService {
|
|||
missionDataObj.putAll(missionDataMap);
|
||||
missionDataArray.add(missionDataObj);
|
||||
|
||||
String [] endSlotCodes =agvTask.getEndSlotCode().split(",");
|
||||
int sum=1;
|
||||
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<>();
|
||||
|
|
@ -415,7 +417,7 @@ public class KMReServiceImpl implements KMReService {
|
|||
break;
|
||||
case "ARRIVED":
|
||||
//容器到达
|
||||
handleArrivedContainer(agvTask,currentPosition);
|
||||
handleArrivedContainer(agvTask, currentPosition);
|
||||
break;
|
||||
case "COMPLETED":
|
||||
//任务完成
|
||||
|
|
@ -447,7 +449,13 @@ public class KMReServiceImpl implements KMReService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String updateTuggerTrailerInfo(List<String> tugModels) {
|
||||
public String updateTuggerTrailerInfo(UpdateTuggerTrailerInfo updateTuggerTrailerInfo) {
|
||||
if (StringUtils.isEmpty(updateTuggerTrailerInfo.getSrcPositionCode())) {
|
||||
throw new BadRequestException("起点必填");
|
||||
}
|
||||
if (CollectionUtils.isEmpty(updateTuggerTrailerInfo.getDollyList())) {
|
||||
throw new BadRequestException("器具必填");
|
||||
}
|
||||
JSONObject jsonObject = new JSONObject(true);
|
||||
//请求 id
|
||||
String requestId = String.valueOf(System.currentTimeMillis());
|
||||
|
|
@ -457,9 +465,9 @@ public class KMReServiceImpl implements KMReService {
|
|||
//当前执行任务的小车号
|
||||
jsonObject.put("robotId", "");
|
||||
//拖挂车数量
|
||||
jsonObject.put("tugCount", tugModels.size());
|
||||
jsonObject.put("tugCount", updateTuggerTrailerInfo.getDollyList().size());
|
||||
//拖挂车类型集
|
||||
jsonObject.put("tugModels", tugModels);
|
||||
jsonObject.put("tugModels", updateTuggerTrailerInfo.getDollyList());
|
||||
//是否同步继续(放行)任务
|
||||
jsonObject.put("resumeMission", true);
|
||||
return jsonObject.toString();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.youchain.businessdata.service.impl;
|
|||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.youchain.basicdata.service.PointService;
|
||||
import com.youchain.businessdata.domain.AgvTask;
|
||||
import com.youchain.businessdata.domain.Les;
|
||||
import com.youchain.businessdata.inputJson.LesRequest;
|
||||
|
|
@ -38,6 +39,8 @@ public class LesServiceImpl implements LesService {
|
|||
|
||||
private final DictRepository dictRepository;
|
||||
|
||||
private final PointService pointService;
|
||||
|
||||
private final LesMapper lesMapper;
|
||||
|
||||
@Override
|
||||
|
|
@ -109,6 +112,7 @@ public class LesServiceImpl implements LesService {
|
|||
//验证任务是否存在
|
||||
validateLes(lesRequest.getTaskCode());
|
||||
|
||||
|
||||
String materialCode = lesRequest.getMaterialCode();//物料代码
|
||||
|
||||
//有物料走料箱上线场景;无物料走其余场景
|
||||
|
|
@ -121,7 +125,7 @@ public class LesServiceImpl implements LesService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String lesCallBack(String currentPositionCode, String taskCode) {
|
||||
public String lesCallBackJson(String currentPositionCode, String taskCode) {
|
||||
JSONObject jsonObject = new JSONObject(true);
|
||||
String guid = String.valueOf(System.currentTimeMillis());
|
||||
//LES任务的业务单号,不一定唯一
|
||||
|
|
@ -146,11 +150,44 @@ public class LesServiceImpl implements LesService {
|
|||
return jsonObject.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void lesCallBack(Les les, String json) {
|
||||
Dict dict = dictRepository.findDictByName("OPEN");
|
||||
String resultJson = "";
|
||||
if (dict != null) {
|
||||
resultJson = HttpPostUtil.sendPostReq(UrlApi.submitMission(), json);
|
||||
if (StringUtils.isEmpty(resultJson)) {
|
||||
throw new BadRequestException("LES返回信息:LES回传接口调用失败!");
|
||||
}
|
||||
JSONObject resulObject = JSON.parseObject(resultJson);
|
||||
if (resulObject == null) {
|
||||
throw new BadRequestException("LES返回信息:LES回传接口返回为空!");
|
||||
}
|
||||
|
||||
String resultCode = resulObject.getString("resultCode");
|
||||
String displayMsg = resulObject.getString("displayMsg");
|
||||
if (!"2000".equals(resultCode)) {
|
||||
throw new BadRequestException("LES返回消息:" + displayMsg);
|
||||
}
|
||||
}
|
||||
|
||||
les.setStatus(BizStatus.CLOSE);
|
||||
les.setRepMessage(resultJson);
|
||||
les.setReqMessage(json);
|
||||
les.setReturnTime(new Timestamp(System.currentTimeMillis()));
|
||||
lesRepository.save(les);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void arrivedLes(Long agvTaskId, String currentPositionCode) {
|
||||
List<Les> lesList = lesRepository.findByAgvTaskId(agvTaskId, currentPositionCode);
|
||||
if (lesList.isEmpty()) {
|
||||
throw new BadRequestException("系统未识别到任务");
|
||||
}
|
||||
for (Les les : lesList) {
|
||||
les.setStatus(BizStatus.ARRIVED);
|
||||
les.setArrivedTime(new Timestamp(new Date().getTime()));
|
||||
}
|
||||
if (!lesList.isEmpty()) {
|
||||
|
|
@ -165,25 +202,34 @@ public class LesServiceImpl implements LesService {
|
|||
*/
|
||||
private void validateParams(LesRequest lesRequest) {
|
||||
if (StringUtils.isEmpty(lesRequest.getTaskCode())) {
|
||||
throw new BadRequestException("taskCode必填");
|
||||
throw new BadRequestException("任务号必填");
|
||||
}
|
||||
//物料有值;说明是料箱上线场景
|
||||
if (StringUtils.isNotEmpty(lesRequest.getMaterialCode())) {
|
||||
if (StringUtils.isEmpty(lesRequest.getRouteCode())) {
|
||||
throw new BadRequestException("routeCode必填");
|
||||
throw new BadRequestException("编组/线路必填");
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(lesRequest.getBoxNo())) {
|
||||
throw new BadRequestException("boxNo必填");
|
||||
throw new BadRequestException("料箱号必填");
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(lesRequest.getOnlineNo())) {
|
||||
throw new BadRequestException("onlineNo必填");
|
||||
throw new BadRequestException("上线单号必填");
|
||||
}
|
||||
|
||||
if (lesRequest.getPositionCodePath() == null || lesRequest.getPositionCodePath().isEmpty() || lesRequest.getPositionCodePath().size() < 2) {
|
||||
throw new BadRequestException("节点不能为空且长度至少为2");
|
||||
}
|
||||
|
||||
//节点集合
|
||||
List<PositionCodeRequest> positionCodes = lesRequest.getPositionCodePath();
|
||||
//验证起点
|
||||
PositionCodeRequest srcPosition = positionCodes.get(0);
|
||||
pointService.validatePoint(srcPosition.getPositionCode());
|
||||
//验证目标库位
|
||||
PositionCodeRequest dstPosition = positionCodes.get(1);
|
||||
pointService.validatePoint(dstPosition.getPositionCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -195,7 +241,7 @@ public class LesServiceImpl implements LesService {
|
|||
private void validateLes(String taskCode) {
|
||||
Les les = lesRepository.findByTaskCode(taskCode);
|
||||
if (les != null) {
|
||||
throw new BadRequestException(taskCode + "任务号系统已接收,请勿重复请求");
|
||||
throw new BadRequestException(taskCode + "任务号系统已接收,请勿重复操作");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -211,6 +257,8 @@ public class LesServiceImpl implements LesService {
|
|||
Les les = Les.builder()
|
||||
.taskCode(lesRequest.getTaskCode())
|
||||
.taskType(lesRequest.getTaskType())
|
||||
.status(BizStatus.OPEN)
|
||||
.caseNum(Double.parseDouble(lesRequest.getCaseNum()))
|
||||
.materialCode(lesRequest.getMaterialCode())
|
||||
.routeCode(lesRequest.getRouteCode())
|
||||
.boxNo(lesRequest.getBoxNo())
|
||||
|
|
|
|||
|
|
@ -1,73 +1,66 @@
|
|||
package com.youchain.utils;
|
||||
|
||||
import com.youchain.modules.system.service.impl.ApiDictServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class UrlApi {
|
||||
private static RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class);
|
||||
private static ApiDictServiceImpl apiDictServiceImpl = SpringContextHolder.getBean(ApiDictServiceImpl.class);
|
||||
private static final String URL_SUFFIX = "_url";
|
||||
|
||||
public static String getByKey(String key){
|
||||
String re= (String)redisUtils.get(key);
|
||||
if(re==null||re.length()<=0||"".equals(re.trim())){
|
||||
private static final RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class);
|
||||
private static final ApiDictServiceImpl apiDictServiceImpl = SpringContextHolder.getBean(ApiDictServiceImpl.class);
|
||||
|
||||
public static String getByKey(String key) {
|
||||
String re = null;
|
||||
try {
|
||||
re = (String) redisUtils.get(key);
|
||||
} catch (Exception e) {
|
||||
// 记录日志或处理异常
|
||||
log.error("redisUtils.get error:", e);
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(re)) {
|
||||
synchronized (UrlApi.class) {
|
||||
try {
|
||||
re = (String) redisUtils.get(key);
|
||||
if (StringUtils.isBlank(re)) {
|
||||
apiDictServiceImpl.queryAllToSave();
|
||||
re= (String)redisUtils.get(key);
|
||||
re = (String) redisUtils.get(key);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 记录日志或处理异常
|
||||
log.error("redisUtils.get error:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return re;
|
||||
};
|
||||
|
||||
|
||||
|
||||
public static String submitMission(){
|
||||
return (String)getByKey("submitMission"+"_url");
|
||||
}
|
||||
|
||||
public static String containerIn(){
|
||||
return (String)getByKey("containerIn"+"_url");
|
||||
//任务下发
|
||||
public static String submitMission() {
|
||||
return getByKey("submitMission" + URL_SUFFIX);
|
||||
}
|
||||
|
||||
public static String containerOut(){
|
||||
return (String)getByKey("containerOut"+"_url");
|
||||
//容器入场
|
||||
public static String containerIn() {
|
||||
return getByKey("containerIn" + URL_SUFFIX);
|
||||
}
|
||||
|
||||
public static String containerQuery(){
|
||||
return (String)getByKey("containerQuery"+"_url");
|
||||
}
|
||||
public static String querypoint(){
|
||||
return (String)getByKey("querypoint"+"_url");
|
||||
}
|
||||
public static String QueryCount(){
|
||||
return (String)getByKey("QueryCount"+"_url");
|
||||
//容器出场
|
||||
public static String containerOut() {
|
||||
return getByKey("containerOut" + URL_SUFFIX);
|
||||
}
|
||||
|
||||
/* *//**
|
||||
* 料箱任务下发
|
||||
*//*
|
||||
public static String submitMission = "http://10.177.202.230:10870/interfaces/api/amr/submitMission";
|
||||
//任务放行
|
||||
public static String operationFeedback() {
|
||||
return getByKey("operationFeedback" + URL_SUFFIX);
|
||||
}
|
||||
|
||||
*//**
|
||||
* 容器入场
|
||||
*//*
|
||||
public static String containerIn = "http://10.177.202.230:10870/interfaces/api/amr/containerIn";
|
||||
//更新牵引车拖挂车信息
|
||||
public static String updateTuggerTrailerInfo() {
|
||||
return getByKey("updateTuggerTrailerInfo" + URL_SUFFIX);
|
||||
}
|
||||
|
||||
*//**
|
||||
* 容器相关操作,出场
|
||||
*//*
|
||||
public static String containerOut = "http://10.177.202.230:10870/interfaces/api/amr/containerOut";
|
||||
|
||||
*//**
|
||||
* 容器相关操作,查询容器信息
|
||||
*//*
|
||||
public static String containerQuery = "http://10.177.202.230:10870/interfaces/api/amr/containerQuery";
|
||||
|
||||
*//**
|
||||
* 输送线点位查询
|
||||
*//*
|
||||
public static String querypoint="http://10.177.188.11:4080/webapi/mes/querypoint";
|
||||
|
||||
*//**
|
||||
* 输送线点位查询
|
||||
*//*
|
||||
public static String QueryCount="http://10.177.188.11:4080/webapi/mes/QueryCount";
|
||||
*/
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue