no message
parent
9efba159b6
commit
190271455e
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.youchain.appupdate.ReturnJson;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ReturnTaskVo {
|
||||||
|
private Long taskId;//任务id
|
||||||
|
private String orderNumber;//箱号
|
||||||
|
private String itemCode;//物料编码
|
||||||
|
private String itemName;//物料名称
|
||||||
|
private String srcPointCode;//起始点
|
||||||
|
private String dstPointCode;//目标点
|
||||||
|
private Double planQty;//待拣货数量
|
||||||
|
}
|
||||||
|
|
@ -8,6 +8,11 @@ import lombok.Data;
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class FbPick {
|
public class FbPick {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "task任务id")
|
||||||
|
Long taskId;
|
||||||
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "原托盘")
|
@ApiModelProperty(value = "原托盘")
|
||||||
String srcStockCode;
|
String srcStockCode;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,10 @@ package com.youchain.appupdate.rest;
|
||||||
|
|
||||||
import com.youchain.annotation.AnonymousAccess;
|
import com.youchain.annotation.AnonymousAccess;
|
||||||
import com.youchain.annotation.Log;
|
import com.youchain.annotation.Log;
|
||||||
|
import com.youchain.appupdate.ReturnJson.ReturnTaskVo;
|
||||||
import com.youchain.appupdate.inputJson.*;
|
import com.youchain.appupdate.inputJson.*;
|
||||||
import com.youchain.basicdata.service.StockService;
|
import com.youchain.basicdata.service.StockService;
|
||||||
|
import com.youchain.businessdata.service.TaskService;
|
||||||
import com.youchain.exception.handler.ApiResult;
|
import com.youchain.exception.handler.ApiResult;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|
@ -28,6 +30,8 @@ public class BydAppController {
|
||||||
|
|
||||||
private final StockService stockService;
|
private final StockService stockService;
|
||||||
|
|
||||||
|
private final TaskService taskService;
|
||||||
|
|
||||||
@PostMapping("/scanMo")
|
@PostMapping("/scanMo")
|
||||||
@Log("扫描Mo票")
|
@Log("扫描Mo票")
|
||||||
@ApiOperation("扫描Mo票")
|
@ApiOperation("扫描Mo票")
|
||||||
|
|
@ -61,19 +65,34 @@ public class BydAppController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/scanStock")
|
||||||
|
@Log("扫描托盘")
|
||||||
|
@ApiOperation("扫描托盘")
|
||||||
|
@AnonymousAccess
|
||||||
|
public ResponseEntity<Object> scanStock(@RequestBody FbPick fbPick) {
|
||||||
|
try {
|
||||||
|
String srcStockCode = fbPick.getSrcStockCode();//原托盘
|
||||||
|
ReturnTaskVo taskVo = stockService.scanStock(srcStockCode);
|
||||||
|
return successResponse("扫描成功!", taskVo);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return badRequest("扫描失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/fbPicking")
|
@PostMapping("/fbPicking")
|
||||||
@Log("翻包拣货")
|
@Log("翻包拣货")
|
||||||
@ApiOperation("翻包拣货")
|
@ApiOperation("翻包拣货")
|
||||||
@AnonymousAccess
|
@AnonymousAccess
|
||||||
public ResponseEntity<Object> fbPicking(@RequestBody FbPick fbPick) {
|
public ResponseEntity<Object> fbPicking(@RequestBody FbPick fbPick) {
|
||||||
try {
|
try {
|
||||||
String srcStockCode = fbPick.getSrcStockCode();//原托盘
|
Long taskId = fbPick.getTaskId();//任务id
|
||||||
String orderNumber = fbPick.getOrderNumber();//箱号
|
String orderNumber = fbPick.getOrderNumber();//箱号
|
||||||
String dstStockCode = fbPick.getDstStockCode();//目标托盘
|
String dstStockCode = fbPick.getDstStockCode();//目标托盘
|
||||||
} catch (Exception e) {
|
stockService.fbPicking(taskId, orderNumber, dstStockCode);
|
||||||
return badRequest(e.getMessage());
|
|
||||||
}
|
|
||||||
return successResponse("拣货成功!");
|
return successResponse("拣货成功!");
|
||||||
|
} catch (Exception e) {
|
||||||
|
return badRequest("拣货失败:" + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package com.youchain.basicdata.service;
|
package com.youchain.basicdata.service;
|
||||||
|
|
||||||
|
import com.youchain.appupdate.ReturnJson.ReturnTaskVo;
|
||||||
import com.youchain.basicdata.domain.Item;
|
import com.youchain.basicdata.domain.Item;
|
||||||
import com.youchain.basicdata.domain.Point;
|
import com.youchain.basicdata.domain.Point;
|
||||||
import com.youchain.basicdata.domain.Stock;
|
import com.youchain.basicdata.domain.Stock;
|
||||||
|
|
@ -166,6 +167,7 @@ public interface StockService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 呼叫容器
|
* 呼叫容器
|
||||||
|
*
|
||||||
* @param itemCode
|
* @param itemCode
|
||||||
* @param pointCode
|
* @param pointCode
|
||||||
* @param scene
|
* @param scene
|
||||||
|
|
@ -174,6 +176,7 @@ public interface StockService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 扫描Mo
|
* 扫描Mo
|
||||||
|
*
|
||||||
* @param mo
|
* @param mo
|
||||||
* @param stockCode
|
* @param stockCode
|
||||||
* @return
|
* @return
|
||||||
|
|
@ -191,4 +194,20 @@ public interface StockService {
|
||||||
|
|
||||||
Map<String, Stock> findByCodes(Set stockCodes);
|
Map<String, Stock> findByCodes(Set stockCodes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 扫描托盘
|
||||||
|
*
|
||||||
|
* @param stockCode
|
||||||
|
*/
|
||||||
|
ReturnTaskVo scanStock(String stockCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 翻包拣货
|
||||||
|
*
|
||||||
|
* @param taskId
|
||||||
|
* @param orderNumber
|
||||||
|
* @param dstStockCode
|
||||||
|
*/
|
||||||
|
void fbPicking(Long taskId, String orderNumber, String dstStockCode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ package com.youchain.basicdata.service.impl;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.youchain.appupdate.ReturnJson.ReturnTaskVo;
|
||||||
import com.youchain.basicdata.domain.Item;
|
import com.youchain.basicdata.domain.Item;
|
||||||
import com.youchain.basicdata.domain.Point;
|
import com.youchain.basicdata.domain.Point;
|
||||||
import com.youchain.basicdata.domain.Stock;
|
import com.youchain.basicdata.domain.Stock;
|
||||||
|
|
@ -25,8 +26,11 @@ import com.youchain.basicdata.service.ItemService;
|
||||||
import com.youchain.basicdata.service.PointService;
|
import com.youchain.basicdata.service.PointService;
|
||||||
import com.youchain.businessdata.domain.*;
|
import com.youchain.businessdata.domain.*;
|
||||||
import com.youchain.businessdata.repository.AsnDetailRepository;
|
import com.youchain.businessdata.repository.AsnDetailRepository;
|
||||||
|
import com.youchain.businessdata.repository.InventoryRepository;
|
||||||
|
import com.youchain.businessdata.repository.PickDetailRepository;
|
||||||
import com.youchain.businessdata.repository.TaskRepository;
|
import com.youchain.businessdata.repository.TaskRepository;
|
||||||
import com.youchain.businessdata.service.*;
|
import com.youchain.businessdata.service.*;
|
||||||
|
import com.youchain.businessdata.service.dto.TaskDto;
|
||||||
import com.youchain.utils.*;
|
import com.youchain.utils.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import com.youchain.basicdata.repository.StockRepository;
|
import com.youchain.basicdata.repository.StockRepository;
|
||||||
|
|
@ -63,15 +67,20 @@ public class StockServiceImpl implements StockService {
|
||||||
|
|
||||||
private final StockRepository stockRepository;
|
private final StockRepository stockRepository;
|
||||||
private final AsnDetailRepository asnDetailRepository;
|
private final AsnDetailRepository asnDetailRepository;
|
||||||
|
private final PickDetailRepository pickDetailRepository;
|
||||||
private final TaskRepository taskRepository;
|
private final TaskRepository taskRepository;
|
||||||
|
private final InventoryRepository inventoryRepository;
|
||||||
|
|
||||||
private final AgvTaskService agvTaskService;
|
private final AgvTaskService agvTaskService;
|
||||||
private final ItemService itemService;
|
private final ItemService itemService;
|
||||||
private final InventoryService inventoryService;
|
private final InventoryService inventoryService;
|
||||||
|
private final InventoryLogService inventoryLogService;
|
||||||
private final AsnDetailService asnDetailService;
|
private final AsnDetailService asnDetailService;
|
||||||
private final PickDetailService pickDetailService;
|
private final PickDetailService pickDetailService;
|
||||||
private final ItemKeyService itemKeyService;
|
private final ItemKeyService itemKeyService;
|
||||||
private final PointService pointService;
|
private final PointService pointService;
|
||||||
private final TaskService taskService;
|
private final TaskService taskService;
|
||||||
|
|
||||||
private final StockTypeToAreaMap stockTypeToAreaMap;
|
private final StockTypeToAreaMap stockTypeToAreaMap;
|
||||||
private final StockMapper stockMapper;
|
private final StockMapper stockMapper;
|
||||||
private final EntityManager entityMapper;
|
private final EntityManager entityMapper;
|
||||||
|
|
@ -106,6 +115,11 @@ public class StockServiceImpl implements StockService {
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public StockDto create(Stock resources) {
|
public StockDto create(Stock resources) {
|
||||||
|
if (resources.getPoint() != null) {
|
||||||
|
Point point = resources.getPoint();
|
||||||
|
point.setStatus(BaseStatus.USED);
|
||||||
|
pointService.update(point);
|
||||||
|
}
|
||||||
return stockMapper.toDto(stockRepository.save(resources));
|
return stockMapper.toDto(stockRepository.save(resources));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,6 +127,16 @@ public class StockServiceImpl implements StockService {
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(Stock resources) {
|
public void update(Stock resources) {
|
||||||
Stock stock = stockRepository.findById(resources.getId()).orElseGet(Stock::new);
|
Stock stock = stockRepository.findById(resources.getId()).orElseGet(Stock::new);
|
||||||
|
if (stock.getPoint() != null) {
|
||||||
|
Point point = stock.getPoint();
|
||||||
|
point.setStatus(BaseStatus.FREE);
|
||||||
|
pointService.update(point);
|
||||||
|
}
|
||||||
|
if (resources.getPoint() != null) {
|
||||||
|
Point point = resources.getPoint();
|
||||||
|
point.setStatus(BaseStatus.USED);
|
||||||
|
pointService.update(point);
|
||||||
|
}
|
||||||
ValidationUtil.isNull(stock.getId(), "Stock", "id", resources.getId());
|
ValidationUtil.isNull(stock.getId(), "Stock", "id", resources.getId());
|
||||||
stock.copy(resources);
|
stock.copy(resources);
|
||||||
stockRepository.save(stock);
|
stockRepository.save(stock);
|
||||||
|
|
@ -393,6 +417,159 @@ public class StockServiceImpl implements StockService {
|
||||||
return stockMap;
|
return stockMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ReturnTaskVo scanStock(String stockCode) {
|
||||||
|
Task task = taskRepository.findBySrcStockCode(stockCode);
|
||||||
|
if (task == null) {
|
||||||
|
throw new RuntimeException("未找到" + stockCode + "托盘的翻包拣货任务!");
|
||||||
|
}
|
||||||
|
ReturnTaskVo returnTaskVo = new ReturnTaskVo();
|
||||||
|
returnTaskVo.setTaskId(task.getId());
|
||||||
|
returnTaskVo.setOrderNumber(task.getItemKey().getOrderNumber());
|
||||||
|
returnTaskVo.setItemCode(task.getItem().getCode());
|
||||||
|
returnTaskVo.setItemName(task.getItem().getName());
|
||||||
|
returnTaskVo.setSrcPointCode(task.getSrcPointCode());
|
||||||
|
returnTaskVo.setDstPointCode(task.getDstPointCode());
|
||||||
|
returnTaskVo.setPlanQty(task.getPlanQty());
|
||||||
|
return returnTaskVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void fbPicking(Long taskId, String orderNumber, String dstStockCode) {
|
||||||
|
/**验证任务*/
|
||||||
|
Task task = validateTask(taskId, orderNumber);
|
||||||
|
|
||||||
|
/**验证目标容器*/
|
||||||
|
Stock dstStock = validatedstStock(dstStockCode);
|
||||||
|
|
||||||
|
/**待拣货数量*/
|
||||||
|
double moveQty = task.getPlanQty();
|
||||||
|
|
||||||
|
/**库存移位*/
|
||||||
|
moveInventory(task, dstStock, moveQty);
|
||||||
|
|
||||||
|
/**刷新拣货状态*/
|
||||||
|
refreshPickStatus(task, moveQty);
|
||||||
|
|
||||||
|
/**原托盘回库内*/
|
||||||
|
returnFBAgvTask(task.getDstPoint(), task.getSrcStock(), task.getItem());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证任务
|
||||||
|
*
|
||||||
|
* @param taskId
|
||||||
|
* @param orderNumber
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Task validateTask(Long taskId, String orderNumber) {
|
||||||
|
TaskDto taskDto = taskService.findById(taskId);
|
||||||
|
if (taskDto == null) {
|
||||||
|
throw new RuntimeException("未找到相应任务记录!");
|
||||||
|
}
|
||||||
|
Task task = taskService.toEntity(taskDto);//Dto转实体
|
||||||
|
if (!orderNumber.equals(task.getItemKey().getOrderNumber())) {
|
||||||
|
throw new RuntimeException("扫描的箱号与分配的箱号不一致!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return task;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证目标容器
|
||||||
|
*
|
||||||
|
* @param dstStockCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private Stock validatedstStock(String dstStockCode) {
|
||||||
|
if (StringUtils.isEmpty(dstStockCode)) {
|
||||||
|
throw new RuntimeException("请扫描目标托盘号!");
|
||||||
|
}
|
||||||
|
Stock dstStock = stockRepository.findByCode(dstStockCode, null);
|
||||||
|
if (dstStock == null) {
|
||||||
|
throw new RuntimeException(dstStockCode + "目标托盘不存在,请扫描正确的托盘号!");
|
||||||
|
}
|
||||||
|
if (BaseStatus.USED.equals(dstStock.getStatus())) {
|
||||||
|
throw new RuntimeException(dstStockCode + "目标托盘已使用,请更换新的托盘!");
|
||||||
|
}
|
||||||
|
if (dstStock.getPoint() == null) {
|
||||||
|
throw new RuntimeException(dstStockCode + "目标托盘没有关联点位!");
|
||||||
|
}
|
||||||
|
return dstStock;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void moveInventory(Task task, Stock dstStock, double moveQty) {
|
||||||
|
//将占用数量移位,原库存回库内
|
||||||
|
Inventory inventory = task.getInventory();
|
||||||
|
inventory.setQueuedQty(inventory.getQueuedQty() - moveQty);
|
||||||
|
inventory.setQuantity(inventory.getQuantity() - moveQty);
|
||||||
|
inventoryRepository.save(inventory);
|
||||||
|
|
||||||
|
Inventory newInventory = new Inventory();
|
||||||
|
newInventory.setItemKey(inventory.getItemKey());
|
||||||
|
newInventory.setPoint(dstStock.getPoint());
|
||||||
|
newInventory.setPointCode(dstStock.getPoint().getCode());
|
||||||
|
newInventory.setStock(dstStock);
|
||||||
|
newInventory.setStockCode(dstStock.getCode());
|
||||||
|
newInventory.setQuantity(moveQty);
|
||||||
|
newInventory.setQueuedQty(0d);
|
||||||
|
newInventory.setDept(inventory.getDept());
|
||||||
|
inventoryRepository.save(newInventory);
|
||||||
|
task.setInventory(newInventory);
|
||||||
|
taskRepository.save(task);
|
||||||
|
if (inventory.getQuantity() <= 0) {
|
||||||
|
inventoryRepository.delete(inventory);
|
||||||
|
}
|
||||||
|
//库存日志
|
||||||
|
inventoryLogService.storeInventoryLog(BizStatus.MOVE, BizStatus.ADD, task.getPickDetail().getPo(), task.getItemKey(), task.getDstPoint(), dstStock.getPoint(), task.getSrcStock(), dstStock, 0d, moveQty, BizStatus.PICK, task.getId(), newInventory.getId(), "");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void refreshPickStatus(Task task, double moveQty) {
|
||||||
|
task.setTaskStatus(BizStatus.FINISH);
|
||||||
|
task.setMoveQty(moveQty);
|
||||||
|
taskRepository.save(task);
|
||||||
|
|
||||||
|
PickDetail pickDetail = task.getPickDetail();
|
||||||
|
pickDetail.setPickedQty(moveQty);
|
||||||
|
pickDetailRepository.save(pickDetail);
|
||||||
|
|
||||||
|
//查询出库单的所有明细
|
||||||
|
Pick pick = pickDetail.getPick();
|
||||||
|
List<PickDetail> allocatePickDetailList = pickDetailRepository.findByAllPickDetail(pick.getId());
|
||||||
|
//判断是否全部拣货完成
|
||||||
|
boolean allPICK_ALL = allocatePickDetailList.stream().allMatch(detail -> detail.getOrderQty().equals(detail.getPickedQty()));
|
||||||
|
//判断是否有部分拣货完成
|
||||||
|
boolean anyPICKUP = allocatePickDetailList.stream().anyMatch(detail -> detail.getOrderQty().equals(detail.getPickedQty()));
|
||||||
|
// 当前状态
|
||||||
|
String status = pick.getStatus();
|
||||||
|
|
||||||
|
//更新状态且点位占用
|
||||||
|
if (allPICK_ALL) {
|
||||||
|
status = BizStatus.PICK_ALL;
|
||||||
|
} else if (anyPICKUP) {
|
||||||
|
status = BizStatus.PICKUP;
|
||||||
|
}
|
||||||
|
pick.setStatus(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void returnFBAgvTask(Point srcPoint, Stock stock, Item item) {
|
||||||
|
String areaCode = stockTypeToAreaMap.getValueByKey(stock.getStockType());
|
||||||
|
Double itemHeight = null;
|
||||||
|
if (AreaNameDic.XJQ.equals(areaCode)) {
|
||||||
|
itemHeight = item.getExtendD2();//整托高度
|
||||||
|
}
|
||||||
|
Point endPoint = pointService.findByCode(null, BaseStatus.FREE, BaseStatus.STORAGE, areaCode, null, itemHeight);
|
||||||
|
if (endPoint == null) {
|
||||||
|
throw new RuntimeException(areaCode + "没有空闲点位!");
|
||||||
|
}
|
||||||
|
|
||||||
|
AgvTask agvTask = new AgvTask(BizStatus.FB_RETURN, stock.getCode(), srcPoint.getCode(), endPoint.getCode(), BizStatus.OPEN, "");
|
||||||
|
agvTaskService.create(agvTask);
|
||||||
|
agvTaskService.sendAgvTaskImpl(agvTask);
|
||||||
|
}
|
||||||
|
|
||||||
private Item validateItem(String itemCode) {
|
private Item validateItem(String itemCode) {
|
||||||
Item item = itemService.existItem(itemCode);
|
Item item = itemService.existItem(itemCode);
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
|
|
|
||||||
|
|
@ -146,10 +146,12 @@ public class Task extends BaseEntity implements Serializable {
|
||||||
@Column(name = "`put_code`")
|
@Column(name = "`put_code`")
|
||||||
@ApiModelProperty(value = "上架号")
|
@ApiModelProperty(value = "上架号")
|
||||||
private String putCode;
|
private String putCode;
|
||||||
|
|
||||||
@OneToOne
|
@OneToOne
|
||||||
@JoinColumn(name = "inv_id")
|
@JoinColumn(name = "inv_id")
|
||||||
@ApiModelProperty(value = "库存ID")
|
@ApiModelProperty(value = "库存ID")
|
||||||
private Inventory inventory;
|
private Inventory inventory;
|
||||||
|
|
||||||
@OneToOne
|
@OneToOne
|
||||||
@JoinColumn(name = "dept_id")
|
@JoinColumn(name = "dept_id")
|
||||||
@ApiModelProperty(value = "仓库ID")
|
@ApiModelProperty(value = "仓库ID")
|
||||||
|
|
|
||||||
|
|
@ -51,4 +51,8 @@ public interface TaskRepository extends JpaRepository<Task, Long>, JpaSpecificat
|
||||||
|
|
||||||
@Query(value = " select count(t.id) FROM Task t WHERE t.taskType='PICK' and t.taskStatus not in ('FINISH') and t.srcPoint.id=?1 ")
|
@Query(value = " select count(t.id) FROM Task t WHERE t.taskType='PICK' and t.taskStatus not in ('FINISH') and t.srcPoint.id=?1 ")
|
||||||
int existsByTask(Long srcPointId);
|
int existsByTask(Long srcPointId);
|
||||||
|
|
||||||
|
@Query(value = " from Task t WHERE t.taskType='PICK' and t.taskStatus='ARRIVED' and t.srcStock.code=:srcStockCode ")
|
||||||
|
Task findBySrcStockCode(String srcStockCode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,19 +84,7 @@ public class TaskController {
|
||||||
public ResponseEntity<Object> queryPickTask(TaskQueryCriteria criteria){
|
public ResponseEntity<Object> queryPickTask(TaskQueryCriteria criteria){
|
||||||
return new ResponseEntity<>(taskService.queryAll(criteria),HttpStatus.OK);
|
return new ResponseEntity<>(taskService.queryAll(criteria),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
@PostMapping("/jhQr")
|
|
||||||
@Log("拣货确认")
|
|
||||||
@ApiOperation("拣货确认")
|
|
||||||
@AnonymousAccess
|
|
||||||
public ResponseEntity<Object> jhQr(@RequestBody Long[] ids){
|
|
||||||
System.out.println("task:"+ids);
|
|
||||||
for (Long id:ids){
|
|
||||||
taskService.invYw(id);
|
|
||||||
/* 更新Task状态*/
|
|
||||||
}
|
|
||||||
ApiResult apiResult=ApiResult.fail(200,"操作成功",null);
|
|
||||||
return new ResponseEntity<>(apiResult, HttpStatus.valueOf(apiResult.getStatus()));
|
|
||||||
}
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@Log("新增task")
|
@Log("新增task")
|
||||||
@ApiOperation("新增task")
|
@ApiOperation("新增task")
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,7 @@ public interface TaskService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拣货
|
* 拣货
|
||||||
|
*
|
||||||
* @param taskId
|
* @param taskId
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
|
@ -128,16 +129,11 @@ public interface TaskService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退货
|
* 退货
|
||||||
|
*
|
||||||
* @param taskId
|
* @param taskId
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
void pickBarBack(long taskId, double pickedQuantity) throws Exception;
|
void pickBarBack(long taskId, double pickedQuantity) throws Exception;
|
||||||
/**
|
|
||||||
* 库存移位
|
|
||||||
* @param taskId
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
void invYw(Long taskId);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询待拣货任务
|
* 查询待拣货任务
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import com.youchain.basicdata.service.dto.ItemSmallDto;
|
||||||
import com.youchain.basicdata.service.dto.PointDto;
|
import com.youchain.basicdata.service.dto.PointDto;
|
||||||
import com.youchain.basicdata.service.dto.StockDto;
|
import com.youchain.basicdata.service.dto.StockDto;
|
||||||
import com.youchain.basicdata.service.dto.StockSmallDto;
|
import com.youchain.basicdata.service.dto.StockSmallDto;
|
||||||
|
import com.youchain.businessdata.domain.Inventory;
|
||||||
import com.youchain.modules.system.service.dto.DeptDto;
|
import com.youchain.modules.system.service.dto.DeptDto;
|
||||||
import com.youchain.modules.system.service.dto.DeptSmallDto;
|
import com.youchain.modules.system.service.dto.DeptSmallDto;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -106,8 +107,8 @@ public class TaskDto implements Serializable {
|
||||||
/** 上架号 */
|
/** 上架号 */
|
||||||
private String putCode;
|
private String putCode;
|
||||||
|
|
||||||
/** 库存ID */
|
/** 库存 */
|
||||||
private Long invId;
|
private Inventory inventory;
|
||||||
|
|
||||||
/** 仓库ID */
|
/** 仓库ID */
|
||||||
private DeptDto dept;
|
private DeptDto dept;
|
||||||
|
|
|
||||||
|
|
@ -450,7 +450,7 @@ public class AgvTaskServiceImpl implements AgvTaskService {
|
||||||
switch (endAreaName) {
|
switch (endAreaName) {
|
||||||
case AreaNameDic.XJQ:
|
case AreaNameDic.XJQ:
|
||||||
case AreaNameDic.DJQ:
|
case AreaNameDic.DJQ:
|
||||||
handleXJDJ(taskList, stock);//入库
|
handleXJDJ(agvTask, taskList, stock);//入库
|
||||||
break;
|
break;
|
||||||
case AreaNameDic.FBQ:
|
case AreaNameDic.FBQ:
|
||||||
handleFBQ(taskList, stock, endPoint);//备料完成
|
handleFBQ(taskList, stock, endPoint);//备料完成
|
||||||
|
|
@ -547,7 +547,8 @@ public class AgvTaskServiceImpl implements AgvTaskService {
|
||||||
* @param taskList
|
* @param taskList
|
||||||
* @param stock
|
* @param stock
|
||||||
*/
|
*/
|
||||||
private void handleXJDJ(List<Task> taskList, Stock stock) {
|
private void handleXJDJ(AgvTask agvTask, List<Task> taskList, Stock stock) {
|
||||||
|
if (BizStatus.ASN.equals(agvTask.getType())) {
|
||||||
//容器回存储区,新增库存、更新点位状态
|
//容器回存储区,新增库存、更新点位状态
|
||||||
for (Task task : taskList) {
|
for (Task task : taskList) {
|
||||||
AsnDetail ad = task.getAsnDetail();
|
AsnDetail ad = task.getAsnDetail();
|
||||||
|
|
@ -566,6 +567,8 @@ public class AgvTaskServiceImpl implements AgvTaskService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 备料
|
* 备料
|
||||||
*
|
*
|
||||||
|
|
@ -573,6 +576,8 @@ public class AgvTaskServiceImpl implements AgvTaskService {
|
||||||
*/
|
*/
|
||||||
private void handleFBQ(List<Task> taskList, Stock stock, Point endPoint) {
|
private void handleFBQ(List<Task> taskList, Stock stock, Point endPoint) {
|
||||||
//将托盘的物料移动到备料库位
|
//将托盘的物料移动到备料库位
|
||||||
|
stock.setPoint(endPoint);
|
||||||
|
stockRepository.save(stock);
|
||||||
List<Inventory> inventoryList = inventoryService.queryInventory(stock);
|
List<Inventory> inventoryList = inventoryService.queryInventory(stock);
|
||||||
for (Inventory inventory : inventoryList) {
|
for (Inventory inventory : inventoryList) {
|
||||||
inventory.setPoint(endPoint);
|
inventory.setPoint(endPoint);
|
||||||
|
|
@ -580,7 +585,7 @@ public class AgvTaskServiceImpl implements AgvTaskService {
|
||||||
}
|
}
|
||||||
/* 更新Task任务状态*/
|
/* 更新Task任务状态*/
|
||||||
for (Task task : taskList) {
|
for (Task task : taskList) {
|
||||||
task.setTaskStatus(BizStatus.FINISH);
|
task.setTaskStatus(BizStatus.ARRIVED);
|
||||||
taskRepository.save(task);
|
taskRepository.save(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,22 +15,19 @@
|
||||||
*/
|
*/
|
||||||
package com.youchain.businessdata.service.impl;
|
package com.youchain.businessdata.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.youchain.basicdata.domain.Item;
|
import com.youchain.basicdata.domain.Item;
|
||||||
import com.youchain.basicdata.domain.Point;
|
import com.youchain.basicdata.domain.Point;
|
||||||
import com.youchain.basicdata.domain.Stock;
|
import com.youchain.basicdata.domain.Stock;
|
||||||
import com.youchain.basicdata.repository.StockRepository;
|
import com.youchain.basicdata.repository.StockRepository;
|
||||||
import com.youchain.basicdata.service.dto.StockSmallDto;
|
import com.youchain.basicdata.service.PointService;
|
||||||
import com.youchain.businessdata.ReturnJson.RPTaskList;
|
import com.youchain.businessdata.ReturnJson.RPTaskList;
|
||||||
import com.youchain.businessdata.domain.*;
|
import com.youchain.businessdata.domain.*;
|
||||||
import com.youchain.businessdata.inputJson.IPTask;
|
import com.youchain.businessdata.inputJson.IPTask;
|
||||||
import com.youchain.businessdata.repository.*;
|
import com.youchain.businessdata.repository.*;
|
||||||
|
import com.youchain.businessdata.service.AgvTaskService;
|
||||||
import com.youchain.businessdata.service.InventoryLogService;
|
import com.youchain.businessdata.service.InventoryLogService;
|
||||||
import com.youchain.businessdata.service.InventoryService;
|
|
||||||
import com.youchain.businessdata.service.dto.InventoryDto;
|
|
||||||
import com.youchain.exception.BadRequestException;
|
|
||||||
import com.youchain.modules.system.domain.Dept;
|
import com.youchain.modules.system.domain.Dept;
|
||||||
import com.youchain.utils.*;
|
import com.youchain.utils.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
@ -41,7 +38,6 @@ import com.youchain.businessdata.service.mapstruct.TaskMapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.hibernate.SQLQuery;
|
import org.hibernate.SQLQuery;
|
||||||
import org.hibernate.transform.AliasToEntityMapResultTransformer;
|
import org.hibernate.transform.AliasToEntityMapResultTransformer;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
|
|
@ -67,12 +63,12 @@ public class TaskServiceImpl implements TaskService {
|
||||||
private final TaskRepository taskRepository;
|
private final TaskRepository taskRepository;
|
||||||
private final TaskMapper taskMapper;
|
private final TaskMapper taskMapper;
|
||||||
private final InventoryRepository inventoryRepository;
|
private final InventoryRepository inventoryRepository;
|
||||||
private final InventoryService inventoryService;
|
|
||||||
private final PickDetailRepository pickDetailRepository;
|
private final PickDetailRepository pickDetailRepository;
|
||||||
private final PickRepository pickRepository;
|
|
||||||
private final InventoryLogService inventoryLogService;
|
private final InventoryLogService inventoryLogService;
|
||||||
|
private final PointService pointService;
|
||||||
private final EntityManager entityMapper;
|
private final EntityManager entityMapper;
|
||||||
private final StockRepository stockRepository;
|
private final StockRepository stockRepository;
|
||||||
|
private final StockTypeToAreaMap stockTypeToAreaMap;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> queryAll(TaskQueryCriteria criteria, Pageable pageable) {
|
public Map<String, Object> queryAll(TaskQueryCriteria criteria, Pageable pageable) {
|
||||||
|
|
@ -256,51 +252,6 @@ public class TaskServiceImpl implements TaskService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void invYw(Long taskId) {
|
|
||||||
Task task=taskRepository.getById(taskId);
|
|
||||||
ItemKey ik=task.getItemKey();
|
|
||||||
Point endPoint = task.getDstPoint();//目标点位
|
|
||||||
Double qty=task.getPlanQty();//拣货数量
|
|
||||||
Stock stock = null;
|
|
||||||
List<Stock> stockList=stockRepository.findByPointAndFb(endPoint.getId());//查询翻包容器
|
|
||||||
if (stockList.size()<0){
|
|
||||||
throw new BadRequestException(HttpStatus.INTERNAL_SERVER_ERROR, "目标位置没有翻包容器");
|
|
||||||
}else {
|
|
||||||
stock=stockList.get(0);
|
|
||||||
}
|
|
||||||
// 扣除库存
|
|
||||||
Inventory inventory=task.getInventory();
|
|
||||||
inventory.setQueuedQty(inventory.getQueuedQty()-qty);
|
|
||||||
inventory.setQuantity(inventory.getQuantity()-qty);
|
|
||||||
inventoryRepository.save(inventory);
|
|
||||||
// 添加库存
|
|
||||||
Inventory inv = inventoryService.getInventory(ik, endPoint, stock, UserUtils.isDept, BizStatus.RECEIVING_UP);
|
|
||||||
inv.setQuantity(qty);
|
|
||||||
inventoryRepository.save(inv);
|
|
||||||
// 添加库存日志
|
|
||||||
inventoryLogService.storeInventoryLog(BizStatus.MOVE, BizStatus.ADD, task.getPickDetail().getPick().getCode(), task.getItemKey(), task.getDstPoint(), task.getSrcPoint(), task.getSrcStock(), stock, 0d, qty, BizStatus.PICK, task.getId(), inv.getId(), "");
|
|
||||||
|
|
||||||
/* 更新Task状态*/
|
|
||||||
task.setMoveQty(qty);
|
|
||||||
task.setTaskStatus(BizStatus.FINISH);
|
|
||||||
taskRepository.save(task);
|
|
||||||
/* 更新出库明细*/
|
|
||||||
PickDetail pickDetail=task.getPickDetail();
|
|
||||||
pickDetail.setPickedQty(pickDetail.getPickedQty()+qty);
|
|
||||||
if (pickDetail.getPickedQty()>=pickDetail.getAllocatedQty()){
|
|
||||||
pickDetail.setStatus(BizStatus.PICK_ALL);
|
|
||||||
}
|
|
||||||
pickDetailRepository.save(pickDetail);
|
|
||||||
/* 更新出库单*/
|
|
||||||
Pick pick=pickDetail.getPick();
|
|
||||||
List<PickDetail> pickDetailList=pickDetailRepository.findByPickNo(pick.getId());
|
|
||||||
if (pickDetailList.size()==0){
|
|
||||||
pick.setStatus(BizStatus.PICK_ALL);
|
|
||||||
pickRepository.save(pick);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional(readOnly = true)
|
@Transactional(readOnly = true)
|
||||||
public List<RPTaskList> queryTaskApp(IPTask t) {
|
public List<RPTaskList> queryTaskApp(IPTask t) {
|
||||||
String sql = "SELECT t.pick_detail_id pickDetailId, it.code itemCode,it.`name` itemName,t.plan_qty qty,ik.prop_c1 pch,t.src_point_code srcPointCode,t.src_stock_code stockCode,t.dst_point_code dstPointCode\n" +
|
String sql = "SELECT t.pick_detail_id pickDetailId, it.code itemCode,it.`name` itemName,t.plan_qty qty,ik.prop_c1 pch,t.src_point_code srcPointCode,t.src_stock_code stockCode,t.dst_point_code dstPointCode\n" +
|
||||||
|
|
|
||||||
|
|
@ -66,15 +66,20 @@ public interface BizStatus {
|
||||||
*/
|
*/
|
||||||
public static String ATWORK = "ATWORK";
|
public static String ATWORK = "ATWORK";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务状态-已到站
|
||||||
|
*/
|
||||||
|
public static String ARRIVED = "ARRIVED";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务状态-顶升
|
* 任务状态-顶升
|
||||||
*/
|
*/
|
||||||
public static String UP_CONTAINER = "UP_CONTAINER";
|
public static String UP_CONTAINER = "UP_CONTAINER";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务状态-返库中
|
* 任务状态-翻包返库
|
||||||
*/
|
*/
|
||||||
public static String RETURN = "RETURN";
|
public static String FB_RETURN = "FB_RETURN";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue