no message
parent
647442eb42
commit
646959319c
|
|
@ -5,7 +5,7 @@ import lombok.Data;
|
|||
@Data
|
||||
public class ReturnTaskVo {
|
||||
private Long taskId;//任务id
|
||||
private String orderNumber;//箱号
|
||||
private String srcOrderNumber;//箱号
|
||||
private String itemCode;//物料编码
|
||||
private String itemName;//物料名称
|
||||
private String srcPointCode;//起始点
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.youchain.appupdate.inputJson;
|
|||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 绑定容器入参
|
||||
|
|
@ -20,6 +20,6 @@ public class BindStock {
|
|||
String pointCode;
|
||||
|
||||
@ApiModelProperty(value = "箱号")
|
||||
Set boxNumbers;
|
||||
List boxNumbers;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ public class FbPick {
|
|||
@ApiModelProperty(value = "原托盘")
|
||||
String srcStockCode;
|
||||
|
||||
@ApiModelProperty(value = "箱号")
|
||||
String orderNumber;
|
||||
@ApiModelProperty(value = "实拣箱号")
|
||||
String dstOrderNumber;
|
||||
|
||||
@ApiModelProperty(value = "目标托盘")
|
||||
String dstStockCode;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import org.springframework.http.ResponseEntity;
|
|||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
|
|
@ -30,24 +31,6 @@ public class BydAppController {
|
|||
|
||||
private final StockService stockService;
|
||||
|
||||
private final TaskService taskService;
|
||||
|
||||
@PostMapping("/scanMo")
|
||||
@Log("扫描Mo票")
|
||||
@ApiOperation("扫描Mo票")
|
||||
@AnonymousAccess
|
||||
public ResponseEntity<Object> scanMo(@RequestBody BindStock bindStock) {
|
||||
try {
|
||||
//二维码格式:P:A17A;V:148795;M:DP_001/PCS;B:240512JFET;Lot:20240427;S:124051200181131;PO:5913490946/00020;Q:36/20/32;D:2024-04-27;SN:;YX:2025-04-26;DN:D12405120005031AS
|
||||
String stockCode = bindStock.getStockCode();//容器编号
|
||||
String mo = bindStock.getMo();//Mo票二维码
|
||||
String boxNumber = stockService.scanMo(stockCode, mo);
|
||||
return successResponse("扫描成功!", boxNumber);
|
||||
} catch (Exception e) {
|
||||
return badRequest("扫描失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/materialIn")
|
||||
@Log("原材料入库")
|
||||
@ApiOperation("原材料入库")
|
||||
|
|
@ -55,7 +38,7 @@ public class BydAppController {
|
|||
public ResponseEntity<Object> materialIn(@RequestBody BindStock bindStock) {
|
||||
try {
|
||||
String stockCode = bindStock.getStockCode();//容器编号
|
||||
Set<String> boxNumbers = bindStock.getBoxNumbers();//箱号集合
|
||||
List<String> boxNumbers = bindStock.getBoxNumbers();//箱号集合
|
||||
String pointCode = bindStock.getPointCode();//点位编号
|
||||
stockService.materialIn(stockCode, boxNumbers, pointCode);
|
||||
return successResponse("入库成功!");
|
||||
|
|
@ -66,8 +49,8 @@ public class BydAppController {
|
|||
}
|
||||
|
||||
@PostMapping("/scanStock")
|
||||
@Log("扫描托盘")
|
||||
@ApiOperation("扫描托盘")
|
||||
@Log("扫描原托盘")
|
||||
@ApiOperation("扫描原托盘")
|
||||
@AnonymousAccess
|
||||
public ResponseEntity<Object> scanStock(@RequestBody FbPick fbPick) {
|
||||
try {
|
||||
|
|
@ -86,7 +69,7 @@ public class BydAppController {
|
|||
public ResponseEntity<Object> fbPicking(@RequestBody FbPick fbPick) {
|
||||
try {
|
||||
Long taskId = fbPick.getTaskId();//任务id
|
||||
String orderNumber = fbPick.getOrderNumber();//箱号
|
||||
String orderNumber = fbPick.getDstOrderNumber();//箱号
|
||||
String dstStockCode = fbPick.getDstStockCode();//目标托盘
|
||||
stockService.fbPicking(taskId, orderNumber, dstStockCode);
|
||||
return successResponse("拣货成功!");
|
||||
|
|
@ -95,6 +78,19 @@ public class BydAppController {
|
|||
}
|
||||
}
|
||||
|
||||
@PostMapping("/unBindContainer")
|
||||
@Log("容器解绑")
|
||||
@ApiOperation("容器解绑")
|
||||
@AnonymousAccess
|
||||
public ResponseEntity<Object> unBindContainer(@RequestBody BindStock bindStock) {
|
||||
try {
|
||||
String stockCode = bindStock.getStockCode();//容器编号
|
||||
return successResponse("解绑成功!");
|
||||
} catch (Exception e) {
|
||||
return badRequest("解绑失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/containerIn")
|
||||
@Log("容器入场")
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public interface PointRepository extends JpaRepository<Point, Long>, JpaSpecific
|
|||
"and (:goodType IS NULL or point.description = :goodType) " +
|
||||
"and (:areaCode IS NULL or point.area.code = :areaCode) " +
|
||||
"and (:itemHeight IS NULL or point.itemHeight = :itemHeight)")
|
||||
Point findByCode(String code, String status, String type, String areaCode, String goodType, Double itemHeight);
|
||||
List<Point> findByCode(String code, String status, String type, String areaCode, String goodType, Double itemHeight);
|
||||
|
||||
@Query(" from Point p where p.code in :pointCodes")
|
||||
List<Point> findByCodes(Set pointCodes);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import com.youchain.annotation.AnonymousAccess;
|
|||
import com.youchain.annotation.Log;
|
||||
import com.youchain.basicdata.domain.Stock;
|
||||
import com.youchain.basicdata.service.StockService;
|
||||
import com.youchain.basicdata.service.StockTypeService;
|
||||
import com.youchain.basicdata.service.dto.StockQueryCriteria;
|
||||
import com.youchain.config.FileProperties;
|
||||
import com.youchain.config.thread.ThreadPoolExecutorUtil;
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ public interface StockService {
|
|||
* @param boxNumbers
|
||||
* @param pointCode
|
||||
*/
|
||||
void materialIn(String stockCode, Set boxNumbers, String pointCode);
|
||||
void materialIn(String stockCode, List boxNumbers, String pointCode);
|
||||
|
||||
/**
|
||||
* 扫描托盘
|
||||
|
|
|
|||
|
|
@ -142,7 +142,12 @@ public class PointServiceImpl implements PointService {
|
|||
|
||||
@Override
|
||||
public Point findByCode(String code, String status, String type, String areaCode, String goodType, Double itemHeight) {
|
||||
return pointRepository.findByCode(code, status, type, areaCode, goodType, itemHeight);
|
||||
List<Point> pointList=pointRepository.findByCode(code, status, type, areaCode, goodType, itemHeight);
|
||||
if(pointList.isEmpty()){
|
||||
return null;
|
||||
}else{
|
||||
return pointList.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
package com.youchain.basicdata.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.youchain.appupdate.ReturnJson.ReturnTaskVo;
|
||||
import com.youchain.basicdata.domain.Item;
|
||||
|
|
@ -23,6 +24,7 @@ import com.youchain.basicdata.domain.Point;
|
|||
import com.youchain.basicdata.domain.Stock;
|
||||
import com.youchain.basicdata.service.ItemService;
|
||||
import com.youchain.basicdata.service.PointService;
|
||||
import com.youchain.basicdata.vo.BarCodeVo;
|
||||
import com.youchain.businessdata.domain.*;
|
||||
import com.youchain.businessdata.repository.AsnDetailRepository;
|
||||
import com.youchain.businessdata.repository.InventoryRepository;
|
||||
|
|
@ -30,6 +32,7 @@ import com.youchain.businessdata.repository.PickDetailRepository;
|
|||
import com.youchain.businessdata.repository.TaskRepository;
|
||||
import com.youchain.businessdata.service.*;
|
||||
import com.youchain.businessdata.service.dto.TaskDto;
|
||||
import com.youchain.config.thread.ThreadPoolExecutorUtil;
|
||||
import com.youchain.utils.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.youchain.basicdata.repository.StockRepository;
|
||||
|
|
@ -46,6 +49,9 @@ import org.springframework.data.domain.Pageable;
|
|||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
|
|
@ -62,7 +68,6 @@ import javax.servlet.http.HttpServletResponse;
|
|||
public class StockServiceImpl implements StockService {
|
||||
|
||||
private final StockRepository stockRepository;
|
||||
private final AsnDetailRepository asnDetailRepository;
|
||||
private final PickDetailRepository pickDetailRepository;
|
||||
private final TaskRepository taskRepository;
|
||||
private final InventoryRepository inventoryRepository;
|
||||
|
|
@ -76,8 +81,10 @@ public class StockServiceImpl implements StockService {
|
|||
private final PointService pointService;
|
||||
private final TaskService taskService;
|
||||
private final StockTypeToAreaMap stockTypeToAreaMap;
|
||||
private final BatchCreateOrUpdate batchCreateOrUpdate;
|
||||
private final StockMapper stockMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(StockQueryCriteria criteria, Pageable pageable) {
|
||||
Page<Stock> page = stockRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
||||
|
|
@ -271,7 +278,7 @@ public class StockServiceImpl implements StockService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String scanMo(String stockCode, String mo) {
|
||||
Map<String, String> map = parseString(mo);//解析二维码
|
||||
/* Map<String, String> map = parseString(mo);//解析二维码
|
||||
String propC1 = map.get("Lot");//批次号
|
||||
String boxNumber = map.get("S");//箱号
|
||||
String propC3 = map.get("P");//工厂
|
||||
|
|
@ -293,47 +300,236 @@ public class StockServiceImpl implements StockService {
|
|||
createTask(item, itemKey, asnDetail, stock, null, null, null);//生成Task任务
|
||||
stock.setStatus(BaseStatus.USED);
|
||||
update(stock);
|
||||
return boxNumber;
|
||||
return boxNumber;*/
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void materialIn(String stockCode, Set boxNumbers, String pointCode) {
|
||||
Stock stock = validateStock(stockCode);//验证容器
|
||||
public void materialIn(String stockCode, List boxNumbers, String pointCode) {
|
||||
/**验证容器*/
|
||||
Stock stock = validateStock(stockCode);
|
||||
|
||||
/**验证箱条码集合*/
|
||||
validateBoxNumbers(boxNumbers);
|
||||
|
||||
/**解析箱条码集合*/
|
||||
List<BarCodeVo> barCodeVos = parseBoxNumbers(boxNumbers);
|
||||
|
||||
/**验证箱条码集合是否为同一物料,箱号是否重复*/
|
||||
validateItemCodeAndOrderNumber(barCodeVos);
|
||||
|
||||
/**验证箱号是否已入库*/
|
||||
for (BarCodeVo barCodeVo : barCodeVos) {
|
||||
if (asnDetailService.existsByboxNumber(barCodeVo.getBoxNumber())) {
|
||||
throw new RuntimeException(barCodeVo.getBoxNumber() + "箱号已入库,请勿重复操作!");
|
||||
}
|
||||
}
|
||||
|
||||
/**验证物料*/
|
||||
String firstItemCode = barCodeVos.iterator().next().getItemCode();
|
||||
Item item = validateItem(firstItemCode);
|
||||
|
||||
/**验证容器类型和物料类型是否匹配*/
|
||||
validateStockAndItem(stock, item);
|
||||
|
||||
/*容器类型:小件入库则入小件缓存区、大件入库则入大件缓存区*/
|
||||
validateStockType(stock.getStockType());
|
||||
|
||||
/**验证起点点位*/
|
||||
Point srcPoint = validateSrcPoint(pointCode);
|
||||
|
||||
/**验证起点点位状态*/
|
||||
checkPointStatus(srcPoint);
|
||||
|
||||
/**验证起点点位是否在可入库区域*/
|
||||
validateSrcPointArea(srcPoint);
|
||||
|
||||
|
||||
/**验证终点点位*/
|
||||
String areaCode = stockTypeToAreaMap.getValueByKey(stock.getStockType());
|
||||
Point endPoint = validateEndPoint(item, areaCode);
|
||||
|
||||
/**创建下发任务*/
|
||||
AgvTask agvTask = createAndSendAgvTask(stock, srcPoint, endPoint);
|
||||
|
||||
/**创建ASN明细和ItemKey和Task任务*/
|
||||
createAsnDetailsAndItemKeysAndTasks(barCodeVos, item, stock, srcPoint, endPoint, agvTask);
|
||||
|
||||
/**更新库存和点位状态*/
|
||||
updateStockAndPoints(stock, srcPoint, endPoint);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void validateBoxNumbers(List<String> boxNumbers) {
|
||||
if (boxNumbers.isEmpty()) {
|
||||
throw new RuntimeException("请扫描箱号!");
|
||||
}
|
||||
Point srcPoint = validateSrcPoint(pointCode);//验证点位
|
||||
}
|
||||
|
||||
private List<BarCodeVo> parseBoxNumbers(List<String> boxNumbers) {
|
||||
List<BarCodeVo> barCodeVos = new ArrayList<>();
|
||||
for (String mo : boxNumbers) {
|
||||
Map<String, String> map = parseString(mo);
|
||||
BarCodeVo barCodeVo = new BarCodeVo();
|
||||
try {
|
||||
barCodeVo.setMo(mo);
|
||||
barCodeVo.setItemCode(getStringCode(map.get("M")));
|
||||
barCodeVo.setPropC1(map.get("Lot"));
|
||||
barCodeVo.setBoxNumber(map.get("S"));
|
||||
barCodeVo.setPropC3(map.get("P"));
|
||||
barCodeVo.setPropD1(map.get("D"));
|
||||
barCodeVo.setOrderQty(Double.parseDouble(getStringCode(map.get("Q"))));
|
||||
barCodeVos.add(barCodeVo);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("箱号格式错误!", e);
|
||||
}
|
||||
}
|
||||
if (barCodeVos.isEmpty()) {
|
||||
throw new RuntimeException("请扫描箱号!");
|
||||
}
|
||||
return barCodeVos;
|
||||
}
|
||||
|
||||
private void validateItemCodeAndOrderNumber(List<BarCodeVo> barCodeVos) {
|
||||
String firstItemCode = barCodeVos.iterator().next().getItemCode();
|
||||
boolean allSame = barCodeVos.stream().allMatch(vo -> vo.getItemCode().equals(firstItemCode));
|
||||
if (!allSame) {
|
||||
throw new RuntimeException("一个托盘只能放同一种物料!");
|
||||
}
|
||||
|
||||
Set<String> boxNumbers = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
boolean allUnique = barCodeVos.parallelStream().anyMatch(vo -> !boxNumbers.add(vo.getBoxNumber()));
|
||||
if (allUnique) {
|
||||
throw new RuntimeException("箱号不能重复!");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateStockType(String stockType) {
|
||||
if (!stockTypeToAreaMap.getStockTypeToAreaMap().containsKey(stockType)) {
|
||||
throw new RuntimeException(stockType + "容器类型错误!");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateSrcPointArea(Point srcPoint) {
|
||||
String srcPointAreaName = srcPoint.getArea().getCode();
|
||||
if (!isValidMCArea(srcPointAreaName)) {
|
||||
throw new RuntimeException(srcPoint.getCode() + "为" + srcPointAreaName + "不能入库!");
|
||||
}
|
||||
|
||||
List<AsnDetail> asnDetailList = asnDetailRepository.findByBoxNumbers(boxNumbers);
|
||||
if (asnDetailList.isEmpty()) {
|
||||
throw new RuntimeException(boxNumbers + "箱号无入库明细记录!");
|
||||
}
|
||||
String areaCode = stockTypeToAreaMap.getValueByKey(stock.getStockType());
|
||||
Point endPoint = validateEndPoint(asnDetailList.get(0).getItem(), areaCode);//验证目标点位
|
||||
|
||||
checkPointStatus(srcPoint);//验证源点位状态
|
||||
private AgvTask createAndSendAgvTask(Stock stock, Point srcPoint, Point endPoint) {
|
||||
AgvTask agvTask = new AgvTask(BizStatus.ASN, stock.getCode(), srcPoint.getCode(), endPoint.getCode(), BizStatus.OPEN, "RACK_MOVE");
|
||||
/*String resultJson = HttpPostUtil.sendPostReq(UrlApi.submitMission(), agvTaskService.sendAgvTaskImplJson(agvTask));
|
||||
if (StringUtils.isEmpty(resultJson)) {
|
||||
throw new RuntimeException("AGV返回信息:下发任务接口调用失败!");
|
||||
}
|
||||
JSONObject resulObject = JSON.parseObject(resultJson);
|
||||
if (resulObject == null) {
|
||||
throw new RuntimeException("AGV返回信息:下发任务接口返回为空!");
|
||||
}
|
||||
|
||||
AgvTask agvTask = createAndSendAgvTask(BizStatus.ASN, stock, srcPoint, endPoint);//生成AGV任务
|
||||
for (AsnDetail asnDetail : asnDetailList) {
|
||||
String code = resulObject.getString("code");
|
||||
String message = resulObject.getString("message");*/
|
||||
String code = "0";
|
||||
String message = "";
|
||||
if (!"0".equals(code)) {
|
||||
throw new RuntimeException("AGV返回信息:" + message);
|
||||
}
|
||||
agvTaskService.create(agvTask);
|
||||
return agvTask;
|
||||
}
|
||||
|
||||
public void createAsnDetailsAndItemKeysAndTasks(List<BarCodeVo> barCodeVos, Item item, Stock stock, Point srcPoint, Point endPoint, AgvTask agvTask) {
|
||||
ExecutorService executor = ThreadPoolExecutorUtil.getPoll("materialIn-job");
|
||||
try {
|
||||
List<AsnDetail> createAsnDetails = new ArrayList<>();
|
||||
List<ItemKey> createItemKeys = new ArrayList<>();
|
||||
List<Task> createAsnTasks = new ArrayList<>();
|
||||
for (BarCodeVo barCodeVo : barCodeVos) {
|
||||
AsnDetail asnDetail = createAsnDetail(item, stock, srcPoint, barCodeVo.getPropC1(), barCodeVo.getBoxNumber(), barCodeVo.getPropC3(), Timestamp.valueOf(DateUtil.formatDateTime(DateUtil.parse(barCodeVo.getPropD1()))), barCodeVo.getOrderQty(), barCodeVo.getMo());
|
||||
createAsnDetails.add(asnDetail);
|
||||
ItemKey itemKey = createItemKey(item, barCodeVo.getPropC1(), barCodeVo.getBoxNumber());
|
||||
createItemKeys.add(itemKey);
|
||||
Task task = createAsnTask(item, itemKey, asnDetail, stock, srcPoint, endPoint, agvTask);
|
||||
createAsnTasks.add(task);
|
||||
}
|
||||
|
||||
CompletableFuture<Void> asnDetailFuture = CompletableFuture.runAsync(() -> {
|
||||
if (!createAsnDetails.isEmpty()) {
|
||||
batchCreateOrUpdate.batchCreate(createAsnDetails);
|
||||
}
|
||||
}, executor);
|
||||
|
||||
CompletableFuture<Void> itemKeyFuture = asnDetailFuture.thenRunAsync(() -> {
|
||||
if (!createItemKeys.isEmpty()) {
|
||||
batchCreateOrUpdate.batchCreate(createItemKeys);
|
||||
}
|
||||
}, executor);
|
||||
|
||||
|
||||
CompletableFuture<Void> taskFuture = itemKeyFuture.thenRunAsync(() -> {
|
||||
if (!createAsnTasks.isEmpty()) {
|
||||
batchCreateOrUpdate.batchCreate(createAsnTasks);
|
||||
}
|
||||
}, executor);
|
||||
|
||||
taskFuture.join();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("创建任务记录失败!", e);
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private AsnDetail createAsnDetail(Item item, Stock stock, Point srcPoint, String propC1, String boxNumber, String propC3, Timestamp propD1, double orderQty, String mo) {
|
||||
AsnDetail asnDetail = new AsnDetail();
|
||||
asnDetail.setItem(item);
|
||||
asnDetail.setLineNo(1l);
|
||||
asnDetail.setStatus(BizStatus.OPEN);
|
||||
asnDetail.setOrderQty(orderQty);
|
||||
asnDetail.setDept(item.getDept());
|
||||
asnDetail.setStock(stock);
|
||||
asnDetail.setPoint(srcPoint);
|
||||
asnDetailRepository.save(asnDetail);
|
||||
asnDetail.setPropC1(propC1);
|
||||
asnDetail.setOrderNumber(boxNumber);
|
||||
asnDetail.setPropC3(propC3);
|
||||
asnDetail.setPropD1(propD1);
|
||||
asnDetail.setPo(mo);
|
||||
return asnDetail;
|
||||
}
|
||||
Set asnDetailIds = asnDetailList.stream().map(AsnDetail::getId).collect(Collectors.toSet());
|
||||
List<Task> taskList = taskRepository.findByAsnDetailTask(asnDetailIds);
|
||||
for (Task task : taskList) {
|
||||
|
||||
private ItemKey createItemKey(Item item, String propC1, String orderNumber) {
|
||||
ItemKey newItemKey = new ItemKey();
|
||||
newItemKey.setItem(item);
|
||||
newItemKey.setDept(item.getDept());
|
||||
newItemKey.setPropC1(propC1);
|
||||
newItemKey.setOrderNumber(orderNumber);
|
||||
return newItemKey;
|
||||
}
|
||||
|
||||
private Task createAsnTask(Item item, ItemKey itemKey, AsnDetail asnDetail, Stock stock, Point srcPoint, Point endPoint, AgvTask agvTask) {
|
||||
|
||||
Task task = new Task();
|
||||
task.setItem(item);
|
||||
task.setItemKey(itemKey);
|
||||
task.getItemKey().setOrderNumber(asnDetail.getOrderNumber());
|
||||
task.setTaskType(BizStatus.ASN);
|
||||
task.setAsnDetail(asnDetail);
|
||||
task.setSrcStock(stock);
|
||||
task.setSrcPoint(srcPoint);
|
||||
task.setSrcPointCode(srcPoint.getCode());
|
||||
task.setSrcStockCode(stock.getCode());
|
||||
task.setSrcPoint(srcPoint);
|
||||
task.setSrcPointCode(srcPoint == null ? null : srcPoint.getCode());
|
||||
task.setDstPoint(endPoint);
|
||||
task.setDstPointCode(endPoint.getCode());
|
||||
task.setDstPointCode(endPoint == null ? null : endPoint.getCode());
|
||||
task.setTaskStatus(BizStatus.OPEN);
|
||||
task.setPlanQty(asnDetail.getOrderQty());
|
||||
task.setDept(item.getDept());
|
||||
task.setAgvTask(agvTask);
|
||||
taskService.update(task);
|
||||
}
|
||||
updateStockAndPoints(stock, srcPoint, endPoint);//更新容器和点位状态
|
||||
return task;
|
||||
}
|
||||
|
||||
private void validateStockAndItem(Stock stock, Item item) {
|
||||
|
|
@ -390,7 +586,7 @@ public class StockServiceImpl implements StockService {
|
|||
}
|
||||
ReturnTaskVo returnTaskVo = new ReturnTaskVo();
|
||||
returnTaskVo.setTaskId(task.getId());
|
||||
returnTaskVo.setOrderNumber(task.getItemKey().getOrderNumber());
|
||||
returnTaskVo.setSrcOrderNumber(task.getItemKey().getOrderNumber());
|
||||
returnTaskVo.setItemCode(task.getItem().getCode());
|
||||
returnTaskVo.setItemName(task.getItem().getName());
|
||||
returnTaskVo.setSrcPointCode(task.getSrcPointCode());
|
||||
|
|
@ -551,26 +747,6 @@ public class StockServiceImpl implements StockService {
|
|||
return stock;
|
||||
}
|
||||
|
||||
private void validateStockStatus(Stock stock, Item item) {
|
||||
//查看容器放的是否是同一种物料
|
||||
List<AsnDetail> asnDetails = asnDetailRepository.findByStockCode(stock.getCode());
|
||||
if (asnDetails.isEmpty()) {
|
||||
List<Inventory> inventoryList = inventoryService.queryInventory(stock);
|
||||
for (Inventory inventory : inventoryList) {
|
||||
if (!inventory.getItemKey().getItem().getCode().equals(item.getCode())) {
|
||||
throw new RuntimeException(stock.getCode() + "托盘已装入" + inventory.getItemKey().getItem().getCode() + "物料,扫描物料" + item.getCode() + "不一致!");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (AsnDetail asnDetail : asnDetails) {
|
||||
if (!asnDetail.getItem().getCode().equals(item.getCode())) {
|
||||
throw new RuntimeException(stock.getCode() + "托盘已装入" + asnDetail.getItem().getCode() + "物料,扫描物料" + item.getCode() + "不一致!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private Point validateSrcPoint(String pointCode) {
|
||||
Point srcPoint = pointService.findByCode(pointCode, null, null, null, null, null);
|
||||
|
|
@ -599,21 +775,13 @@ public class StockServiceImpl implements StockService {
|
|||
}
|
||||
}
|
||||
|
||||
private AgvTask createAndSendAgvTask(String bizStatus, Stock stock, Point srcPoint, Point endPoint) {
|
||||
AgvTask agvTask = new AgvTask(bizStatus, stock.getCode(), srcPoint.getCode(), endPoint.getCode(), BizStatus.OPEN, "RACK_MOVE");
|
||||
agvTaskService.create(agvTask);
|
||||
agvTaskService.sendAgvTaskImpl(agvTask);
|
||||
return agvTask;
|
||||
}
|
||||
|
||||
private void sendAgvTaskAndHandleResponse(AgvTask agvTask) {
|
||||
agvTaskService.sendAgvTaskImpl(agvTask);
|
||||
}
|
||||
|
||||
private Task createTask(Item item, ItemKey itemKey, AsnDetail asnDetail, Stock stock, Point srcPoint, Point
|
||||
endPoint, AgvTask agvTask) {
|
||||
Task task = new Task(item, itemKey, asnDetail.getOrderNumber(), BizStatus.ASN, asnDetail, null, null, null, stock, stock, srcPoint, endPoint, stock.getCode(), stock.getCode(), srcPoint == null ? null : srcPoint.getCode(), endPoint == null ? null : endPoint.getCode(), null, BizStatus.OPEN, asnDetail.getOrderQty(), null, null, item.getDept(), agvTask);
|
||||
taskService.create(task);
|
||||
private Task createTask(Item item, ItemKey itemKey, AsnDetail asnDetail, Stock stock, Point srcPoint, Point endPoint, AgvTask agvTask) {
|
||||
Task task = new Task(item, itemKey, asnDetail.getOrderNumber(), BizStatus.ASN, asnDetail, null, null, null, stock, null, srcPoint, endPoint, stock.getCode(), null, srcPoint == null ? null : srcPoint.getCode(), endPoint == null ? null : endPoint.getCode(), null, BizStatus.OPEN, asnDetail.getOrderQty(), null, null, item.getDept(), agvTask);
|
||||
taskRepository.save(task);
|
||||
return task;
|
||||
}
|
||||
|
||||
|
|
@ -688,8 +856,7 @@ public class StockServiceImpl implements StockService {
|
|||
}
|
||||
|
||||
private boolean isRestrictedArea(String areaName) {
|
||||
return areaName.equals(AreaNameDic.XJQ) || areaName.equals(AreaNameDic.DJQ) ||
|
||||
areaName.equals(AreaNameDic.CPRKQ);
|
||||
return areaName.equals(AreaNameDic.XJQ) || areaName.equals(AreaNameDic.DJQ) || areaName.equals(AreaNameDic.CPRKQ);
|
||||
}
|
||||
|
||||
private void handleFullContainer(Stock stock, Point point, String itemCode) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package com.youchain.basicdata.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class BarCodeVo {
|
||||
public String mo;//箱条码全部内容
|
||||
public String itemCode;//物料编码
|
||||
public String propC1;//批次号
|
||||
public String boxNumber;//箱号
|
||||
public String propC3 ;//工厂
|
||||
public String propD1;//生产日期
|
||||
public double orderQty ;//数量
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ public class Task extends BaseEntity implements Serializable {
|
|||
@ApiModelProperty(value = "任务类型")
|
||||
private String taskType;
|
||||
|
||||
@OneToOne(cascade = CascadeType.PERSIST)
|
||||
@OneToOne
|
||||
@JoinColumn(name = "asn_detail_id")
|
||||
@ApiModelProperty(value = "收货明细序号")
|
||||
private AsnDetail asnDetail;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,4 @@ public interface AsnDetailRepository extends JpaRepository<AsnDetail, Long>, Jpa
|
|||
|
||||
@Query(value = " FROM AsnDetail ad WHERE ad.stock.code =?1 and ad.status not in('RECEIVED') ")
|
||||
List<AsnDetail> findByStockCode(String stockCode);
|
||||
|
||||
@Query(value = " FROM AsnDetail ad WHERE ad.orderNumber in :boxNumbers ")
|
||||
List<AsnDetail> findByBoxNumbers(Set boxNumbers);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,6 +100,8 @@ public interface AgvTaskService {
|
|||
*/
|
||||
String sendAgvTaskImpl(AgvTask agvTasks);
|
||||
|
||||
String sendAgvTaskImplJson(AgvTask agvTasks);
|
||||
|
||||
/**
|
||||
* 发送料箱搬运接口任务
|
||||
*
|
||||
|
|
|
|||
|
|
@ -230,6 +230,65 @@ public class AgvTaskServiceImpl implements AgvTaskService {
|
|||
return resultJson;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sendAgvTaskImplJson(AgvTask agvTasks) {
|
||||
JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
|
||||
|
||||
Map<String, Object> objMap = new LinkedHashMap<>();
|
||||
objMap.put("orgId", agvTasks.getId());//库存组织 ID
|
||||
objMap.put("requestId", agvTasks.getId());//请求 id
|
||||
objMap.put("missionCode", agvTasks.getId());//任务编号
|
||||
|
||||
objMap.put("missionType", agvTasks.getJobType());//货 架 ( 托 盘 ) 移动 RACK_MOVE
|
||||
String viewBoardType = "";
|
||||
Point point = pointService.findByCode(agvTasks.getStartSlotCode(), null, null, null, null, null);
|
||||
//到达上视自动识别
|
||||
if (AreaNameDic.CPRKQ.equals(point.getArea().getCode())) {
|
||||
viewBoardType = "IDENTIFY_REQUIRE";
|
||||
}
|
||||
objMap.put("viewBoardType", viewBoardType);//上视识别类型;需要 IDENTIFY_REQUIRE 不需要NORMAL
|
||||
objMap.put("robotType", "LIFT");//机器人功能类型
|
||||
JSONArray robotModels = new JSONArray();
|
||||
objMap.put("robotModels", robotModels);//机器人具体型号
|
||||
JSONArray robotIds = new JSONArray();
|
||||
objMap.put("robotIds", robotIds);//机器人编号
|
||||
objMap.put("priority", "1");//数值越小,优先级越高,默认是 1
|
||||
objMap.put("containerModelCode", "");//容器模型编码
|
||||
objMap.put("containerCode", agvTasks.getStockCode() == null ? "" : agvTasks.getStockCode());//容器编号
|
||||
objMap.put("templateCode", "");//作业流程模板编号
|
||||
objMap.put("lockRobotAfterFinish", false);//是否需要流程结束后机器人保持任务锁定状态
|
||||
objMap.put("unlockRobotId", "");//解锁当前小车的在上个任务的锁定状态
|
||||
objMap.put("unlockMissionCode", "");//当前小车的上一个任务
|
||||
objMap.put("idleNode", "");//作业流程完成后,指定机器人停放区域/点
|
||||
JSONArray missionDataArray = new JSONArray();
|
||||
JSONObject missionDataObj = new JSONObject(new LinkedHashMap<>());
|
||||
Map<String, Object> missionDataMap = new LinkedHashMap<>();
|
||||
missionDataMap.put("sequence", 1);//序号
|
||||
missionDataMap.put("position", agvTasks.getStartSlotCode());//起始点
|
||||
missionDataMap.put("type", "NODE_POINT");//作业位置类型:点位:NODE_POINT
|
||||
missionDataMap.put("putDown", false);//作业点位是否需要放下货架
|
||||
missionDataMap.put("passStrategy", "AUTO");//当前任务点结束后放行策略
|
||||
missionDataMap.put("waitingMillis", "0");//自动触发离开当前任务节点的时间,默认单位:毫秒
|
||||
missionDataObj.putAll(missionDataMap);
|
||||
missionDataArray.add(missionDataObj);
|
||||
|
||||
JSONObject missionDataObj2 = new JSONObject(new LinkedHashMap<>());
|
||||
Map<String, Object> missionDataMap2 = new LinkedHashMap<>();
|
||||
missionDataMap2.put("sequence", 2);//序号
|
||||
missionDataMap2.put("position", agvTasks.getEndSlotCode());//目标点
|
||||
missionDataMap2.put("type", "NODE_POINT");//作业位置类型:点位:NODE_POINT
|
||||
missionDataMap2.put("putDown", true);//作业点位是否需要放下货架
|
||||
missionDataMap2.put("passStrategy", "AUTO");//当前任务点结束后放行策略
|
||||
missionDataMap2.put("waitingMillis", "0");//自动触发离开当前任务节点的时间,默认单位:毫秒
|
||||
missionDataObj2.putAll(missionDataMap2);
|
||||
missionDataArray.add(missionDataObj2);
|
||||
|
||||
|
||||
objMap.put("missionData", missionDataArray);
|
||||
jsonObject.putAll(objMap);
|
||||
return jsonObject.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized String sendAgvTaskLXImpl(List<AgvTask> agvTasks) {
|
||||
JSONObject jsonObject = new JSONObject(new LinkedHashMap<>());
|
||||
|
|
|
|||
|
|
@ -1,21 +1,18 @@
|
|||
package com.youchain;
|
||||
|
||||
import com.youchain.basicdata.domain.BigItem;
|
||||
import com.youchain.basicdata.vo.BarCodeVo;
|
||||
import com.youchain.businessdata.domain.AgvTask;
|
||||
import com.youchain.businessdata.domain.AsnDetail;
|
||||
import com.youchain.businessdata.domain.GdDetail;
|
||||
import com.youchain.businessdata.domain.PickDetail;
|
||||
import com.youchain.config.thread.ThreadPoolExecutorUtil;
|
||||
import com.youchain.utils.StringUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -27,13 +24,21 @@ public class EladminSystemApplicationTests {
|
|||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String name = "point-import-job";
|
||||
StringUtils.isNotBlank(name);
|
||||
if(StringUtils.isNotBlank(name)){
|
||||
System.out.println("name is not blank");
|
||||
}else{
|
||||
System.out.println("name is blank");
|
||||
}
|
||||
List<BarCodeVo> barCodeVos = new ArrayList<>();
|
||||
|
||||
BarCodeVo barCodeVo = new BarCodeVo();
|
||||
barCodeVo.setBoxNumber("123");
|
||||
barCodeVos.add(barCodeVo);
|
||||
|
||||
BarCodeVo barCodeVo2 = new BarCodeVo();
|
||||
barCodeVo2.setBoxNumber("456");
|
||||
barCodeVos.add(barCodeVo2);
|
||||
|
||||
BarCodeVo barCodeVo3 = new BarCodeVo();
|
||||
barCodeVo3.setBoxNumber("123");
|
||||
barCodeVos.add(barCodeVo3);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static final int MAX_TASK_COUNT = 4;
|
||||
|
|
@ -43,6 +48,49 @@ public class EladminSystemApplicationTests {
|
|||
|
||||
void aa() {
|
||||
|
||||
CompletableFuture<Void> asnDetailFuture = CompletableFuture.runAsync(() -> {
|
||||
System.out.println("新增asnDetail");
|
||||
});
|
||||
|
||||
CompletableFuture<Void> itemKeyFuture = asnDetailFuture.thenRunAsync(() -> {
|
||||
System.out.println("新增itemKey");
|
||||
});
|
||||
|
||||
CompletableFuture<Void> taskFuture = itemKeyFuture.thenRunAsync(() -> {
|
||||
System.out.println("新增task");
|
||||
});
|
||||
taskFuture.join();
|
||||
|
||||
Set<BarCodeVo> barCodeVos = new HashSet<>();
|
||||
|
||||
BarCodeVo barCodeVo = new BarCodeVo();
|
||||
barCodeVo.setItemCode("123");
|
||||
barCodeVo.setBoxNumber("1");
|
||||
barCodeVos.add(barCodeVo);
|
||||
|
||||
BarCodeVo barCodeVo2 = new BarCodeVo();
|
||||
barCodeVo2.setItemCode("123");
|
||||
barCodeVo2.setBoxNumber("2");
|
||||
barCodeVos.add(barCodeVo2);
|
||||
|
||||
BarCodeVo barCodeVo3 = new BarCodeVo();
|
||||
barCodeVo3.setItemCode("456");
|
||||
barCodeVo3.setBoxNumber("3");
|
||||
barCodeVos.add(barCodeVo3);
|
||||
|
||||
for (BarCodeVo vo : barCodeVos) {
|
||||
System.out.println(vo.getItemCode());
|
||||
}
|
||||
|
||||
String firstItemCode = barCodeVos.iterator().next().getItemCode();
|
||||
boolean allSame = barCodeVos.stream()
|
||||
.allMatch(vo -> vo.getItemCode().equals(firstItemCode));
|
||||
if (allSame) {
|
||||
System.out.println("全部匹配");
|
||||
} else {
|
||||
System.out.println("不匹配");
|
||||
}
|
||||
|
||||
PickDetail pickDetail1 = new PickDetail();
|
||||
pickDetail1.setId(1L);
|
||||
pickDetail1.setOrderQty(2d);
|
||||
|
|
|
|||
Loading…
Reference in New Issue