Les接口 任务下发
parent
64a7c008ea
commit
4673e9fa42
|
|
@ -0,0 +1,35 @@
|
|||
package com.youchain.exception.handler;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class LesResult {
|
||||
private Object data;//数据
|
||||
private String debugMsg;//调试信息
|
||||
private String displayMsg;//描述信息,失败原因
|
||||
private String requestId;//请求id
|
||||
private int resultCode;//返回码
|
||||
private String serverTime;//请求时间,服务器时间戳
|
||||
|
||||
public static LesResult fail(String requestId, String displayMsg) {
|
||||
return result(requestId,400, displayMsg, null);
|
||||
}
|
||||
|
||||
public static LesResult success(String requestId) {
|
||||
return result(requestId, 2000, "", null);
|
||||
}
|
||||
|
||||
public static LesResult result(String requestId, int resultCode, String displayMsg, Object data) {
|
||||
LesResult lesResult = new LesResult();
|
||||
lesResult.setRequestId(requestId);
|
||||
lesResult.setServerTime(LocalDateTime.now().toString());
|
||||
lesResult.setResultCode(resultCode);
|
||||
lesResult.setDisplayMsg(displayMsg);
|
||||
lesResult.setDebugMsg("");
|
||||
lesResult.setData(data);
|
||||
return lesResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -78,18 +78,6 @@ public class Point extends BaseEntity implements Serializable {
|
|||
@ApiModelProperty(value = "仓库")
|
||||
private Dept dept;
|
||||
|
||||
@Column(name = "`pos_x`")
|
||||
@ApiModelProperty(value = "坐标X")
|
||||
private Double posX=0d;
|
||||
|
||||
@Column(name = "`pos_y`")
|
||||
@ApiModelProperty(value = "坐标Y")
|
||||
private Double posY=0d;
|
||||
|
||||
@Column(name = "`pos_z`")
|
||||
@ApiModelProperty(value = "坐标Z")
|
||||
private Double posZ=0d;
|
||||
|
||||
@Column(name = "`type`")
|
||||
@ApiModelProperty(value = "类型")
|
||||
private String type;
|
||||
|
|
@ -98,17 +86,17 @@ public class Point extends BaseEntity implements Serializable {
|
|||
@ApiModelProperty(value = "热度")
|
||||
private Double heat;
|
||||
|
||||
@Column(name = "`rows`")
|
||||
@ApiModelProperty(value = "层")
|
||||
private int rows=0;
|
||||
@Column(name = "`line`")
|
||||
@ApiModelProperty(value = "排")
|
||||
private int line=0;
|
||||
|
||||
@Column(name = "`col`")
|
||||
@ApiModelProperty(value = "列")
|
||||
private int col=0;
|
||||
|
||||
@Column(name = "`line`")
|
||||
@ApiModelProperty(value = "排")
|
||||
private int line=0;
|
||||
@Column(name = "`rows`")
|
||||
@ApiModelProperty(value = "层")
|
||||
private int rows=0;
|
||||
|
||||
public void copy(Point source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
|
|
|
|||
|
|
@ -54,14 +54,6 @@ public class PointController {
|
|||
|
||||
private final PointService pointService;
|
||||
|
||||
private final AreaService areaService;
|
||||
|
||||
private final FileProperties properties;
|
||||
|
||||
private final BatchCreateOrUpdate batchCreateOrUpdate;
|
||||
|
||||
private final RedisObjectUtils redisObjectUtils;
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
|
|
@ -116,15 +108,4 @@ public class PointController {
|
|||
pointService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private ResponseEntity<Object> badRequest(String message) {
|
||||
return new ResponseEntity<>(ApiResult.fail(BAD_REQUEST.value(), message, ""), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
private ResponseEntity<Object> successRequest(String message, Object object) {
|
||||
return new ResponseEntity<>(ApiResult.fail(OK.value(), message, object), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,15 +58,6 @@ public class PointDto implements Serializable {
|
|||
/** 仓库ID */
|
||||
private DeptDto dept;
|
||||
|
||||
/** 坐标X */
|
||||
private Double posX;
|
||||
|
||||
/** 坐标Y */
|
||||
private Double posY;
|
||||
|
||||
/** 坐标Z */
|
||||
private Double posZ;
|
||||
|
||||
/** 类型 */
|
||||
private String type;
|
||||
|
||||
|
|
|
|||
|
|
@ -104,9 +104,6 @@ public class PointServiceImpl implements PointService {
|
|||
map.put("库区名称", point.getArea().getName());
|
||||
map.put("是否启用", point.getEnabled());
|
||||
map.put("仓库名称", point.getDept().getName());
|
||||
map.put("坐标X", point.getPosX());
|
||||
map.put("坐标Y", point.getPosY());
|
||||
map.put("坐标Z", point.getPosZ());
|
||||
map.put("层", point.getRows());
|
||||
map.put("列", point.getCol());
|
||||
map.put("排", point.getLine());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,72 @@
|
|||
package com.youchain.businessdata.domain;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import com.youchain.base.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@Table(name="data_les")
|
||||
public class Les extends BaseEntity implements Serializable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "`id`")
|
||||
@ApiModelProperty(value = "ID")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "`task_code`")
|
||||
@ApiModelProperty(value = "LES产生的任务号")
|
||||
private String taskCode;
|
||||
|
||||
@Column(name = "`task_type`")
|
||||
@ApiModelProperty(value = "任务类型")
|
||||
private String taskType;
|
||||
|
||||
@Column(name = "`material_code`")
|
||||
@ApiModelProperty(value = "物料代码")
|
||||
private String materialCode;
|
||||
|
||||
@Column(name = "`route_code`")
|
||||
@ApiModelProperty(value = "编组/线路")
|
||||
private String routeCode;
|
||||
|
||||
@Column(name = "`box_no`")
|
||||
@ApiModelProperty(value = "料箱号")
|
||||
private String boxNo;
|
||||
|
||||
@Column(name = "`online_no`")
|
||||
@ApiModelProperty(value = "上线单号")
|
||||
private String onlineNo;
|
||||
|
||||
@Column(name = "`src_position_code`")
|
||||
@ApiModelProperty(value = "起点库位")
|
||||
private String srcPositionCode;
|
||||
|
||||
@Column(name = "`src_type`")
|
||||
@ApiModelProperty(value = "起点类型")
|
||||
private String srcType;
|
||||
|
||||
@Column(name = "`dst_position_code`")
|
||||
@ApiModelProperty(value = "终点库位")
|
||||
private String dstPositionCode;
|
||||
|
||||
@Column(name = "`dst_type`")
|
||||
@ApiModelProperty(value = "终点类型")
|
||||
private String dstType;
|
||||
|
||||
public void copy(Les source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.youchain.businessdata.inputJson;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* @description:LES入参
|
||||
* @author: Zhong Zhichao
|
||||
* @date: 2020/4/16 14:05
|
||||
*/
|
||||
@Data
|
||||
public class LesRequest {
|
||||
@ApiModelProperty(value = "请求id", required = true, example = "bcc413ca30504015a8676059d08d474b")
|
||||
String guId;
|
||||
|
||||
@ApiModelProperty(value = "LES产生的任务号",required = true, example = "LES产生的任务号,唯一,必填")
|
||||
String taskCode;
|
||||
|
||||
@ApiModelProperty(value = "任务类型",required = true, example = "bmfeed")
|
||||
String taskType;
|
||||
|
||||
@ApiModelProperty(value = "物料代码", example = "物料代码")
|
||||
String materialCode;
|
||||
|
||||
@ApiModelProperty(value = "编组/线路")
|
||||
String routeCode;
|
||||
|
||||
@ApiModelProperty(value = "料箱号")
|
||||
String boxNo;
|
||||
|
||||
@ApiModelProperty(value = "上线单号")
|
||||
String onlineNo;
|
||||
|
||||
@ApiModelProperty(value = "节点", required = true)
|
||||
List<PositionCodeRequest> positionCodes;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.youchain.businessdata.inputJson;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @description:节点
|
||||
* @author: guo_zhao_bo
|
||||
* @create: 2020/05/07 09:05
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class PositionCodeRequest {
|
||||
@ApiModelProperty(value = "库位", required = true, example = "库位")
|
||||
String positionCode;
|
||||
|
||||
@ApiModelProperty(value = "类型", required = true, example = "类型")
|
||||
String type;
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.youchain.businessdata.repository;
|
||||
|
||||
import com.youchain.businessdata.domain.AgvTask;
|
||||
import com.youchain.businessdata.domain.Les;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
public interface LesRepository extends JpaRepository<Les, Long>, JpaSpecificationExecutor<Les> {
|
||||
|
||||
@Query(value = " from Les les WHERE les.taskCode=:taskCode ")
|
||||
Les findByTaskCode(String taskCode);
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
package com.youchain.businessdata.rest;
|
||||
|
||||
|
||||
import com.youchain.annotation.AnonymousAccess;
|
||||
import com.youchain.annotation.Log;
|
||||
import com.youchain.businessdata.domain.Les;
|
||||
import com.youchain.businessdata.inputJson.LesRequest;
|
||||
import com.youchain.businessdata.service.LesService;
|
||||
import com.youchain.businessdata.service.dto.LesQueryCriteria;
|
||||
import com.youchain.exception.handler.LesResult;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "les管理")
|
||||
@RequestMapping("/api/les")
|
||||
public class LesController {
|
||||
private final LesService lesService;
|
||||
|
||||
@Log("导出数据")
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('les:list')")
|
||||
public void exportLes(HttpServletResponse response, LesQueryCriteria criteria) throws IOException {
|
||||
lesService.download(lesService.queryAll(criteria), response);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation("查询les")
|
||||
public ResponseEntity<Object> queryLes(LesQueryCriteria criteria, Pageable pageable) {
|
||||
return new ResponseEntity<>(lesService.queryAll(criteria, pageable), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增les")
|
||||
@ApiOperation("新增les")
|
||||
@PreAuthorize("@el.check('les:add')")
|
||||
public ResponseEntity<Object> createLes(@Validated @RequestBody Les resources) {
|
||||
return new ResponseEntity<>(lesService.create(resources), HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@Log("修改les")
|
||||
@ApiOperation("修改les")
|
||||
@PreAuthorize("@el.check('les:edit')")
|
||||
public ResponseEntity<Object> updateLes(@Validated @RequestBody Les resources) {
|
||||
lesService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@Log("删除les")
|
||||
@ApiOperation("删除les")
|
||||
@PreAuthorize("@el.check('les:del')")
|
||||
public ResponseEntity<Object> deleteLes(@RequestBody Long[] ids) {
|
||||
lesService.deleteAll(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/genAgvSchedulingTask")
|
||||
@Log("Les任务下发")
|
||||
@ApiOperation("Les任务下发")
|
||||
@AnonymousAccess
|
||||
public ResponseEntity<Object> genAgvSchedulingTask(@RequestBody LesRequest lesRequest) {
|
||||
String id = lesRequest.getGuId();//请求id
|
||||
try {
|
||||
return new ResponseEntity<>(LesResult.success(id), HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(LesResult.fail(id, e.getMessage()), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
package com.youchain.businessdata.service;
|
||||
|
||||
import com.youchain.basicdata.domain.Point;
|
||||
import com.youchain.basicdata.domain.Stock;
|
||||
import com.youchain.businessdata.domain.AgvTask;
|
||||
import com.youchain.businessdata.domain.Les;
|
||||
import com.youchain.businessdata.inputJson.LesRequest;
|
||||
import com.youchain.businessdata.service.dto.*;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface LesService {
|
||||
/**
|
||||
* 查询数据分页
|
||||
*
|
||||
* @param criteria 条件
|
||||
* @param pageable 分页参数
|
||||
* @return Map<String, Object>
|
||||
*/
|
||||
Map<String, Object> queryAll(LesQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria 条件参数
|
||||
* @return List<AsnDetailDto>
|
||||
*/
|
||||
List<LesDto> queryAll(LesQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
* @param id ID
|
||||
* @return AgvTaskDto
|
||||
*/
|
||||
Les findById(Long id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param resources /
|
||||
* @return AgvTaskDto
|
||||
*/
|
||||
Les create(Les resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param resources /
|
||||
*/
|
||||
void update(Les resources);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Long[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
*
|
||||
* @param all 待导出的数据
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
void download(List<LesDto> all, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* LES任务下发
|
||||
* @param lesRequest 请求参数
|
||||
*/
|
||||
void genAgvSchedulingTask( LesRequest lesRequest);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.youchain.businessdata.service.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
|
||||
@Data
|
||||
public class LesDto {
|
||||
private Long id;
|
||||
|
||||
//LES产生的任务号
|
||||
private String taskCode;
|
||||
|
||||
//任务类型"
|
||||
private String taskType;
|
||||
|
||||
//物料代码
|
||||
private String materialCode;
|
||||
|
||||
//编组/线路
|
||||
private String routeCode;
|
||||
|
||||
//料箱号
|
||||
private String boxNo;
|
||||
|
||||
//上线单号
|
||||
private String onlineNo;
|
||||
|
||||
//起点库位
|
||||
private String srcPositionCode;
|
||||
|
||||
//起点类型
|
||||
private String srcType;
|
||||
|
||||
//终点库位
|
||||
private String dstPositionCode;
|
||||
|
||||
//终点类型
|
||||
private String dstType;
|
||||
|
||||
/** 创建时间 */
|
||||
private Timestamp createTime;
|
||||
|
||||
/** 创建人 */
|
||||
private String createBy;
|
||||
|
||||
/** 修改人 */
|
||||
private String updateBy;
|
||||
|
||||
/** 修改时间 */
|
||||
private Timestamp updateTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.youchain.businessdata.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LesQueryCriteria {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,165 @@
|
|||
package com.youchain.businessdata.service.impl;
|
||||
|
||||
import com.youchain.businessdata.domain.Les;
|
||||
import com.youchain.businessdata.inputJson.LesRequest;
|
||||
import com.youchain.businessdata.inputJson.PositionCodeRequest;
|
||||
import com.youchain.businessdata.repository.LesRepository;
|
||||
import com.youchain.businessdata.service.LesService;
|
||||
import com.youchain.businessdata.service.dto.LesDto;
|
||||
import com.youchain.businessdata.service.dto.LesQueryCriteria;
|
||||
import com.youchain.businessdata.service.mapstruct.LesMapper;
|
||||
import com.youchain.exception.BadRequestException;
|
||||
import com.youchain.utils.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class LesServiceImpl implements LesService {
|
||||
|
||||
private final LesRepository lesRepository;
|
||||
|
||||
private final LesMapper lesMapper;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(LesQueryCriteria criteria, Pageable pageable) {
|
||||
Page<Les> page = lesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
||||
return PageUtil.toPage(page.map(lesMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LesDto> queryAll(LesQueryCriteria criteria) {
|
||||
return lesMapper.toDto(lesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Les findById(Long id) {
|
||||
Les les = lesRepository.findById(id).orElseGet(Les::new);
|
||||
ValidationUtil.isNull(les.getId(), "Les", "id", id);
|
||||
return les;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Les create(Les resources) {
|
||||
return lesRepository.save(resources);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(Les resources) {
|
||||
Les les = lesRepository.findById(resources.getId()).orElseGet(Les::new);
|
||||
ValidationUtil.isNull(les.getId(), "Les", "id", resources.getId());
|
||||
les.copy(resources);
|
||||
lesRepository.save(les);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(Long[] ids) {
|
||||
for (Long id : ids) {
|
||||
lesRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void download(List<LesDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (LesDto les : all) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("任务号", les.getTaskCode());
|
||||
map.put("任务类型", les.getTaskType());
|
||||
map.put("物料代码", les.getMaterialCode());
|
||||
map.put("编组/线路", les.getRouteCode());
|
||||
map.put("料箱号", les.getBoxNo());
|
||||
map.put("上线单号", les.getOnlineNo());
|
||||
map.put("起点库位", les.getSrcPositionCode());
|
||||
map.put("终点库位", les.getDstPositionCode());
|
||||
map.put("创建时间", les.getCreateTime());
|
||||
map.put("创建人", les.getCreateBy());
|
||||
list.add(map);
|
||||
}
|
||||
FileUtil.downloadExcel(list, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void genAgvSchedulingTask(LesRequest lesRequest) {
|
||||
//验证参数有效性
|
||||
validateParams(lesRequest);
|
||||
|
||||
//验证任务是否存在
|
||||
String taskCode = lesRequest.getTaskCode();
|
||||
validateLes(taskCode);
|
||||
|
||||
String materialCode = lesRequest.getMaterialCode();//物料代码
|
||||
|
||||
//有物料走料箱上线场景;无物料走其余场景
|
||||
if (StringUtils.isNotEmpty(materialCode)) {
|
||||
createLes(lesRequest);
|
||||
} else {
|
||||
//直接转发给AGV
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证参数有效性
|
||||
*
|
||||
* @param lesRequest 请求参数
|
||||
*/
|
||||
private void validateParams(LesRequest lesRequest) {
|
||||
if (StringUtils.isEmpty(lesRequest.getTaskCode())) {
|
||||
throw new BadRequestException("任务号必填!");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(lesRequest.getMaterialCode())) {
|
||||
if (lesRequest.getPositionCodes().isEmpty() || lesRequest.getPositionCodes().size() < 2) {
|
||||
throw new BadRequestException("节点不能为空且长度至少为2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证任务号是否存在
|
||||
*
|
||||
* @param taskCode -> 任务号
|
||||
*/
|
||||
private void validateLes(String taskCode) {
|
||||
Les les = lesRepository.findByTaskCode(taskCode);
|
||||
if (les != null) {
|
||||
throw new BadRequestException(taskCode + "任务号已存在!");
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createLes(LesRequest lesRequest) {
|
||||
//节点集合
|
||||
List<PositionCodeRequest> positionCodes = lesRequest.getPositionCodes();
|
||||
//起点对象
|
||||
PositionCodeRequest srcPosition = positionCodes.get(0);
|
||||
//终点对象
|
||||
PositionCodeRequest dstPosition = positionCodes.get(1);
|
||||
|
||||
Les les = Les.builder()
|
||||
.taskCode(lesRequest.getTaskCode())
|
||||
.taskType(lesRequest.getTaskType())
|
||||
.materialCode(lesRequest.getMaterialCode())
|
||||
.routeCode(lesRequest.getRouteCode())
|
||||
.boxNo(lesRequest.getBoxNo())
|
||||
.onlineNo(lesRequest.getOnlineNo())
|
||||
.srcPositionCode(srcPosition.getPositionCode())
|
||||
.srcType(srcPosition.getType())
|
||||
.dstPositionCode(dstPosition.getPositionCode())
|
||||
.dstType(dstPosition.getType())
|
||||
.build();
|
||||
lesRepository.save(les);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -52,12 +52,8 @@ import javax.servlet.http.HttpServletResponse;
|
|||
public class TaskServiceImpl implements TaskService {
|
||||
|
||||
private final TaskRepository taskRepository;
|
||||
private final PickDetailRepository pickDetailRepository;
|
||||
private final TaskMapper taskMapper;
|
||||
private final StockService stockService;
|
||||
private final AgvTaskService agvTaskService;
|
||||
private final InventoryService inventoryService;
|
||||
private final InventoryLogService inventoryLogService;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(TaskQueryCriteria criteria, Pageable pageable) {
|
||||
Page<Task> page = taskRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package com.youchain.businessdata.service.mapstruct;
|
||||
|
||||
import com.youchain.base.BaseMapper;
|
||||
import com.youchain.businessdata.domain.AgvTask;
|
||||
import com.youchain.businessdata.domain.Les;
|
||||
import com.youchain.businessdata.service.dto.AgvTaskDto;
|
||||
import com.youchain.businessdata.service.dto.LesDto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface LesMapper extends BaseMapper<LesDto, Les> {
|
||||
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ spring:
|
|||
enabled: true
|
||||
# 记录慢SQL
|
||||
log-slow-sql: true
|
||||
slow-sql-millis: 1000
|
||||
slow-sql-millis: 10000
|
||||
merge-sql: true
|
||||
wall:
|
||||
config:
|
||||
|
|
|
|||
Loading…
Reference in New Issue