no message
parent
edade7cc3c
commit
17ad836f0d
|
|
@ -47,29 +47,25 @@ public class Box extends BaseEntity implements Serializable {
|
|||
@ApiModelProperty(value = "ID")
|
||||
private Long id;
|
||||
|
||||
@Column(name = "`code`",nullable = false)
|
||||
@NotBlank
|
||||
@Column(name = "`code`")
|
||||
@ApiModelProperty(value = "按钮盒编号")
|
||||
private String code;
|
||||
|
||||
@Column(name = "`name`",nullable = false)
|
||||
@NotBlank
|
||||
@Column(name = "`name`")
|
||||
@ApiModelProperty(value = "按钮盒名称")
|
||||
private String name;
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "`item_id`",nullable = true)
|
||||
@JoinColumn(name = "`item_id`")
|
||||
@ApiModelProperty(value = "物料")
|
||||
private Item item;
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "`point_id`",nullable = false)
|
||||
@NotNull
|
||||
@JoinColumn(name = "`point_id`")
|
||||
@ApiModelProperty(value = "点位")
|
||||
private Point point;
|
||||
|
||||
@Column(name = "`enabled`",nullable = false)
|
||||
@NotNull
|
||||
@Column(name = "`enabled`")
|
||||
@ApiModelProperty(value = "状态:1启用、0禁用")
|
||||
private Boolean enabled=true;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@ package com.youchain.basicdata.repository;
|
|||
import com.youchain.basicdata.domain.PointItem;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
|
|
@ -25,4 +28,6 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|||
* @date 2025-04-11
|
||||
**/
|
||||
public interface PointItemRepository extends JpaRepository<PointItem, Long>, JpaSpecificationExecutor<PointItem> {
|
||||
@Query(value = "SELECT pi FROM PointItem pi", nativeQuery = false)
|
||||
List<PointItem> findByPoint(Long id);
|
||||
}
|
||||
|
|
@ -74,6 +74,7 @@ public class BoxController {
|
|||
@PreAuthorize("@el.check('box:add')")
|
||||
public ResponseEntity<Object> createBox(@Validated @RequestBody Box resources) {
|
||||
resources.setDept(UserUtils.getDept());
|
||||
resources.setCode(resources.getWorkType()+":"+resources.getPoint().getCode());
|
||||
boxService.create(resources);
|
||||
return new ResponseEntity<>(boxService.create(resources), HttpStatus.CREATED);
|
||||
}
|
||||
|
|
@ -83,6 +84,7 @@ public class BoxController {
|
|||
@ApiOperation("修改box")
|
||||
@PreAuthorize("@el.check('box:edit')")
|
||||
public ResponseEntity<Object> updateBox(@Validated @RequestBody Box resources) {
|
||||
resources.setCode(resources.getWorkType()+":"+resources.getPoint().getCode());
|
||||
boxService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ public class PointItemController {
|
|||
@ApiOperation("修改pointItem")
|
||||
@PreAuthorize("@el.check('pointItem:edit')")
|
||||
public ResponseEntity<Object> updatePointItem(@Validated @RequestBody PointItem resources){
|
||||
resources.setCode(resources.getPoint().getCode()+":"+resources.getItem().getCode());
|
||||
pointItemService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,4 +31,6 @@ import java.util.List;
|
|||
public interface InventoryRepository extends JpaRepository<Inventory, Long>, JpaSpecificationExecutor<Inventory> {
|
||||
@Query(value = "select inv from Inventory inv where inv.billCode=?1 ")
|
||||
List<Inventory> findByBillCode(String billCode);
|
||||
@Query(value = "select inv from Inventory inv where inv.itemKey.item.code in ?1 ")
|
||||
List<Inventory> findInvByItemCodes(List<String> itemCodes);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,4 +105,5 @@ public interface InventoryService {
|
|||
List<Inventory> getInvForPlan(String type,Long areaId,Long itemId,Long deptId);
|
||||
|
||||
List<Inventory> findInvByBillCode(Set billCode);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
package com.youchain.businessdata.service;
|
||||
|
||||
import com.youchain.annotation.Log;
|
||||
import com.youchain.basicdata.domain.Point;
|
||||
import com.youchain.businessdata.inputJson.*;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/**
|
||||
|
|
@ -47,7 +49,11 @@ public interface MlsService {
|
|||
* @return
|
||||
*/
|
||||
void getIssueInfo(IssueInfo issueInfo);
|
||||
|
||||
/**
|
||||
* 光电直接叫料
|
||||
* @return
|
||||
*/
|
||||
void getIssueInfo(List<String> itemCodes, Point endPoint);
|
||||
|
||||
/**
|
||||
* 回传MO票
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import com.youchain.basicdata.service.ItemService;
|
|||
import com.youchain.basicdata.service.PointService;
|
||||
import com.youchain.businessdata.domain.*;
|
||||
import com.youchain.businessdata.inputJson.*;
|
||||
import com.youchain.businessdata.repository.InventoryRepository;
|
||||
import com.youchain.businessdata.service.*;
|
||||
import com.youchain.config.thread.ThreadPoolExecutorUtil;
|
||||
import com.youchain.modules.system.domain.Dept;
|
||||
|
|
@ -40,6 +41,7 @@ public class MlsServiceImpl implements MlsService {
|
|||
private final PointService pointService;
|
||||
private final PointRepository pointRepository;
|
||||
private final InventoryService inventoryService;
|
||||
private final InventoryRepository inventoryRepository;
|
||||
private final RedisObjectUtils redisObjectUtils;
|
||||
private final BatchCreateOrUpdate batchCreateOrUpdate;
|
||||
|
||||
|
|
@ -531,7 +533,105 @@ public class MlsServiceImpl implements MlsService {
|
|||
throw new RuntimeException(errorMsgList.toString());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void getIssueInfo(List<String> itemCodes,Point endPoint) {
|
||||
|
||||
CompletableFuture<List<Inventory>> inventoryListFuture = CompletableFuture.supplyAsync(() -> {
|
||||
|
||||
List<Inventory> inventoryList = inventoryRepository.findInvByItemCodes(itemCodes);//物料号码查询库存信息
|
||||
|
||||
return inventoryList;
|
||||
});
|
||||
|
||||
if (inventoryListFuture.join().isEmpty()) {
|
||||
throw new RuntimeException("无库存信息!");
|
||||
}
|
||||
List<String> errorMsgList = new ArrayList<>();
|
||||
inventoryListFuture.thenAccept((result) -> {
|
||||
List<Inventory> inventoryToUpdate = new ArrayList<>();
|
||||
List<PickDetail> pickDetailToCreate = new ArrayList<>();
|
||||
List<AgvTask> agvTaskToCreate = new ArrayList<>();
|
||||
List<Task> taskToCreate = new ArrayList<>();
|
||||
for (Inventory inv : result) {
|
||||
if (inv.getBeLock()==true&&BaseCode.PICK_YH_QR.equals("1")){
|
||||
errorMsgList.add(inv.getItemKey().getPropC1() + "库存未验货!");
|
||||
continue;
|
||||
}
|
||||
if (inv.getQueuedQty()>0){
|
||||
errorMsgList.add(inv.getItemKey().getPropC1() + "库存已被占用!");
|
||||
continue;
|
||||
}
|
||||
//根据库存信息生成叫料任务
|
||||
Stock stock = inv.getStock();//容器
|
||||
Point startPoint = inv.getPoint();//起始点位
|
||||
ItemKey itemKey = inv.getItemKey();
|
||||
Item item = inv.getItemKey().getItem();
|
||||
|
||||
//更新库存信息
|
||||
inventoryToUpdate.add(updateInventory(inv));
|
||||
|
||||
//生成出库明细
|
||||
PickDetail pd = createPickDetail(item, inv.getBillCode(), itemKey.getPropC1(), inv.getQuantity(), "");
|
||||
pickDetailToCreate.add(pd);
|
||||
|
||||
//生成搬运任务
|
||||
AgvTask agvTask = new AgvTask(BizStatus.PICK, stock.getCode(), startPoint.getCode(), endPoint.getCode(), BizStatus.OPEN, "PICKER_MOVE");
|
||||
agvTaskToCreate.add(agvTask);
|
||||
|
||||
//生成Task
|
||||
Task task = createTask(item, itemKey, pd, inv.getBillCode(), stock, startPoint, endPoint, agvTask, inv);
|
||||
taskToCreate.add(task);
|
||||
|
||||
break;
|
||||
}
|
||||
if (!errorMsgList.isEmpty()) {
|
||||
throw new RuntimeException(errorMsgList.toString());
|
||||
}
|
||||
ExecutorService executor = ThreadPoolExecutorUtil.getPoll("getIssueInfo-job");
|
||||
|
||||
// 批量更新库存信息
|
||||
CompletableFuture<Void> inventoryFuture = CompletableFuture.runAsync(() -> {
|
||||
//批量更新库存信息
|
||||
if (!inventoryToUpdate.isEmpty()) {
|
||||
batchCreateOrUpdate.batchUpdate(inventoryToUpdate);
|
||||
}
|
||||
|
||||
}, executor);
|
||||
|
||||
|
||||
CompletableFuture<Void> pickDetailFuture = inventoryFuture.thenRunAsync(() -> {
|
||||
//批量生成叫料明细
|
||||
if (!pickDetailToCreate.isEmpty()) {
|
||||
batchCreateOrUpdate.batchCreate(pickDetailToCreate);
|
||||
}
|
||||
|
||||
}, executor);
|
||||
|
||||
CompletableFuture<Void> agvTaskFuture = pickDetailFuture.thenRunAsync(() -> {
|
||||
// 批量生成agv任务
|
||||
if (!agvTaskToCreate.isEmpty()) {
|
||||
batchCreateOrUpdate.batchCreate(agvTaskToCreate);
|
||||
}
|
||||
|
||||
}, executor);
|
||||
|
||||
CompletableFuture<Void> taskFuture = agvTaskFuture.thenRunAsync(() -> {
|
||||
// 批量生成任务
|
||||
if (!taskToCreate.isEmpty()) {
|
||||
batchCreateOrUpdate.batchCreate(taskToCreate);
|
||||
|
||||
}
|
||||
|
||||
}, executor);
|
||||
taskFuture.join();
|
||||
|
||||
executor.shutdown();
|
||||
});
|
||||
if (!errorMsgList.isEmpty()) {
|
||||
throw new RuntimeException(errorMsgList.toString());
|
||||
}
|
||||
}
|
||||
private void processInventory(Inventory inv, Point endPoint) {
|
||||
Stock stock = inv.getStock();
|
||||
Point startPoint = inv.getPoint();
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.youchain.basicdata.repository.ItemRepository;
|
|||
import com.youchain.basicdata.repository.PointRepository;
|
||||
import com.youchain.exception.handler.ApiResult;
|
||||
import com.youchain.jamod.domain.ModbusInfo;
|
||||
import com.youchain.jamod.repository.ModbusInfoRepository;
|
||||
import com.youchain.jamod.service.ModbusInfoService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
|
@ -29,6 +30,7 @@ import java.util.List;
|
|||
@RequestMapping("/api/dropdown")
|
||||
public class DropdownController {
|
||||
private final PointRepository pointRepository;
|
||||
private final ModbusInfoRepository modbusInfoRepository;
|
||||
private final ItemRepository itemRepository;
|
||||
@PostMapping("/pointData")
|
||||
@ApiOperation("全部点位")
|
||||
|
|
@ -46,4 +48,12 @@ public class DropdownController {
|
|||
ApiResult apiResult=ApiResult.fail(200,"成功",itemList);
|
||||
return new ResponseEntity<>(apiResult,apiResult.getStatus());
|
||||
}
|
||||
@PostMapping("/modbusInfoData")
|
||||
@ApiOperation("全部modbusInfo")
|
||||
@AnonymousAccess
|
||||
public ResponseEntity<Object> modbusInfoData(){
|
||||
List<ModbusInfo> modbusInfoList=modbusInfoRepository.findAll();
|
||||
ApiResult apiResult=ApiResult.fail(200,"成功",modbusInfoList);
|
||||
return new ResponseEntity<>(apiResult,apiResult.getStatus());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@ import javax.validation.constraints.NotBlank;
|
|||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
|
|
@ -117,6 +121,15 @@ public class ModbusInfo implements Serializable {
|
|||
@ApiModelProperty(value = "报错原因")
|
||||
private String description;
|
||||
|
||||
public List<String> getDataValueList() {
|
||||
if (dataValues == null || dataValues.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
String trimmedString = dataValues.substring(1, dataValues.length() - 1);
|
||||
String[] stringArray = trimmedString.split(",");
|
||||
return Arrays.asList(stringArray);
|
||||
}
|
||||
|
||||
public void copy(ModbusInfo source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
package com.youchain.modules.quartz.task;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.youchain.basicdata.domain.Box;
|
||||
import com.youchain.basicdata.domain.PointItem;
|
||||
import com.youchain.basicdata.repository.BoxRepository;
|
||||
import com.youchain.basicdata.repository.PointItemRepository;
|
||||
import com.youchain.businessdata.domain.AgvTask;
|
||||
import com.youchain.businessdata.domain.Inventory;
|
||||
import com.youchain.businessdata.repository.AgvTaskRepository;
|
||||
import com.youchain.businessdata.service.AgvTaskService;
|
||||
import com.youchain.businessdata.service.MlsService;
|
||||
import com.youchain.utils.BaseStatus;
|
||||
import com.youchain.utils.BizStatus;
|
||||
import com.youchain.utils.HttpPostUtil;
|
||||
|
|
@ -13,11 +17,9 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 料箱出库任务下发
|
||||
|
|
@ -28,10 +30,32 @@ public class pickTask {
|
|||
|
||||
@Autowired
|
||||
public AgvTaskService agvTaskService;
|
||||
|
||||
@Autowired
|
||||
public BoxRepository boxRepository;
|
||||
@Autowired
|
||||
public PointItemRepository pointItemRepository;
|
||||
@Autowired
|
||||
public MlsService mlsService;
|
||||
private static final int MAX_TASK_COUNT = 5;
|
||||
|
||||
private static final long TIMEOUT_MS = 2*60*1000;
|
||||
public void pickLLJTask() {
|
||||
List<Box> boxList = boxRepository.getBoxAllData();
|
||||
for (Box box : boxList){
|
||||
List<String> dataValueList = box.getModbusInfo().getDataValueList();
|
||||
if (dataValueList.get(box.getSort()-1).equals(box.getWorkCode())){
|
||||
if (box.getWorkType().equals(BizStatus.PICK)){
|
||||
List<PointItem> pointItemList=pointItemRepository.findByPoint(box.getPoint().getId());
|
||||
// 获取 PointItem.item.code 集合
|
||||
List<String> itemCodeList = pointItemList.stream()
|
||||
.map(pointItem -> pointItem.getItem().getCode())
|
||||
.collect(Collectors.toList());
|
||||
// 出库
|
||||
mlsService.getIssueInfo(itemCodeList, box.getPoint());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void pickTask() {
|
||||
// 下发出库任务
|
||||
List<AgvTask> agvTaskList = agvTaskService.queryByAgvTask(BizStatus.OPEN,BizStatus.PICK);
|
||||
|
|
|
|||
|
|
@ -95,6 +95,14 @@ public interface BizStatus {
|
|||
* 出库任务
|
||||
*/
|
||||
public static String PICK = "PICK";
|
||||
/**
|
||||
* 流利架送满
|
||||
*/
|
||||
public static String FULL_OUT = "FULL_OUT";
|
||||
/**
|
||||
* 流利架返空
|
||||
*/
|
||||
public static String EMPTY_IN = "EMPTY_IN";
|
||||
|
||||
/**
|
||||
* 验货任务
|
||||
|
|
@ -204,10 +212,6 @@ public interface BizStatus {
|
|||
* 物料类型,轴承座
|
||||
*/
|
||||
public static String ZC = "ZC";
|
||||
/**
|
||||
* 空车入库
|
||||
*/
|
||||
public static String EMPTY_IN = "EMPTY_IN";
|
||||
|
||||
/**
|
||||
* 空车出库/空箱出库
|
||||
|
|
|
|||
Loading…
Reference in New Issue