开发出库分配,取消分配
parent
12803c1095
commit
75b38e7a54
|
|
@ -137,24 +137,10 @@ public class PickDetailController {
|
|||
|
||||
@PostMapping("/cancelAllocate")
|
||||
@Log("取消分配")
|
||||
@ApiOperation("取消分配")
|
||||
@AnonymousAccess
|
||||
public synchronized ResponseEntity<Object> cancelAllocate(@RequestBody Long[] ids) throws Exception {
|
||||
List<Long> pickDetailIds = Arrays.asList(ids);
|
||||
if (pickDetailIds.size() > 0) {
|
||||
try {
|
||||
for (Long id : pickDetailIds) {
|
||||
PickDetailDto pickDetailDto = pickDetailService.findById(id);
|
||||
pickDetailService.cancelAllocate(id, pickDetailDto.getAllocatedQty());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity(ApiResult.fail(BAD_REQUEST.value(), e.getMessage(), ""), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
} else {
|
||||
return new ResponseEntity(ApiResult.fail(BAD_REQUEST.value(), "参数错误或者为null", ""), HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
ApiResult apiResult = pickDetailService.cancelAllocate(ids);
|
||||
return new ResponseEntity<>(apiResult, HttpStatus.valueOf(apiResult.getStatus()));
|
||||
}
|
||||
|
||||
@PostMapping("/queryTaskApp")
|
||||
|
|
|
|||
|
|
@ -16,10 +16,8 @@
|
|||
package com.youchain.businessdata.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.youchain.basicdata.domain.Box;
|
||||
import com.youchain.basicdata.domain.Item;
|
||||
import com.youchain.basicdata.domain.Point;
|
||||
import com.youchain.basicdata.service.dto.BoxDto;
|
||||
import com.youchain.businessdata.domain.PickDetail;
|
||||
import com.youchain.businessdata.service.dto.PickDetailDto;
|
||||
import com.youchain.businessdata.service.dto.PickDetailQueryCriteria;
|
||||
|
|
@ -105,7 +103,8 @@ public interface PickDetailService {
|
|||
/**
|
||||
* 取消分配
|
||||
*/
|
||||
void cancelAllocate(long id,double quantity) throws Exception;
|
||||
void cancelAllocate(long id,double quantity) ;
|
||||
ApiResult cancelAllocate(Long[] ids);
|
||||
|
||||
/**
|
||||
* 统计数量
|
||||
|
|
|
|||
|
|
@ -18,10 +18,7 @@ package com.youchain.businessdata.service.impl;
|
|||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.youchain.basicdata.domain.*;
|
||||
import com.youchain.basicdata.repository.BillTypeRepository;
|
||||
import com.youchain.basicdata.repository.BoxRepository;
|
||||
import com.youchain.basicdata.repository.ItemRepository;
|
||||
import com.youchain.basicdata.repository.StockRepository;
|
||||
import com.youchain.basicdata.repository.*;
|
||||
import com.youchain.basicdata.service.ItemService;
|
||||
import com.youchain.basicdata.service.PointService;
|
||||
import com.youchain.basicdata.service.dto.ItemDto;
|
||||
|
|
@ -35,8 +32,6 @@ import com.youchain.businessdata.service.PickDetailService;
|
|||
import com.youchain.businessdata.service.dto.PickDetailDto;
|
||||
import com.youchain.businessdata.service.dto.PickDetailQueryCriteria;
|
||||
import com.youchain.businessdata.service.mapstruct.PickDetailMapper;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
|
@ -50,8 +45,6 @@ import javax.persistence.EntityManager;
|
|||
import javax.persistence.Query;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
|
||||
/**
|
||||
* @author huojin
|
||||
* @website https://eladmin.vip
|
||||
|
|
@ -64,6 +57,7 @@ import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
|||
public class PickDetailServiceImpl implements PickDetailService {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH");
|
||||
private final PickDetailRepository pickDetailRepository;
|
||||
private final PointRepository pointRepository;
|
||||
private final PickRepository pickRepository;
|
||||
private final PickDetailMapper pickDetailMapper;
|
||||
private final BillTypeRepository billTypeRepository;
|
||||
|
|
@ -146,72 +140,58 @@ public class PickDetailServiceImpl implements PickDetailService {
|
|||
for (int i = 0; i < ids.length; i++) {
|
||||
Long id=ids[i];
|
||||
PickDetail pickDetail=pickDetailRepository.getById(id);
|
||||
if (pickDetail.getPropC4().equals(BizStatus.AGV_PT)){
|
||||
//AGV出库
|
||||
}
|
||||
|
||||
Double quantity=pickDetail.getOrderQty();
|
||||
PickDetail pd = pickDetailRepository.getById(id);//Dto转实体
|
||||
Item item = pd.getItem();
|
||||
Item item = pickDetail.getItem();
|
||||
Dept dept = item.getDept();//仓库
|
||||
|
||||
Box box = boxRepository.getBoxByItem(item.getId());
|
||||
|
||||
Point endPoint = box.getPoint();//目标点位
|
||||
if (pd.getOrderQty() > pd.getAllocatedQty()) {
|
||||
List<Inventory> Inventorys = inventoryRepository.queryInventory(item.getId());
|
||||
if (Inventorys.size() > 0) {
|
||||
double allocateQty = 0;
|
||||
double unQty = quantity;//未分配数量
|
||||
for (Inventory inv : Inventorys) {
|
||||
Stock stock = inv.getStock();//容器
|
||||
Point startPoint = inv.getPoint();//起始点位
|
||||
Double quantity=pickDetail.getOrderQty()-pickDetail.getAllocatedQty();//未分配数量
|
||||
Point endPoint;//目标点位
|
||||
if (pickDetail.getPropC4().equals(BizStatus.AGV_PT)){
|
||||
/**AGV出库分配*/
|
||||
//获取目标点位
|
||||
endPoint = pointRepository.findByCode(pickDetail.getPropC5());
|
||||
if (pickDetail.getOrderQty() > pickDetail.getAllocatedQty()) {
|
||||
List<Inventory> inventoryList = inventoryRepository.queryInventory(item.getId());
|
||||
if (inventoryList.size() > 0) {
|
||||
double allocateQty = 0;//分配数量
|
||||
double unQty = quantity;//订单数量
|
||||
for (Inventory inv : inventoryList) {
|
||||
Point startPoint = inv.getPoint();//原库位
|
||||
if (unQty == 0) {
|
||||
break;
|
||||
}
|
||||
allocateQty = inv.getQuantity() - inv.getQueuedQty();//库存可用数量
|
||||
if (allocateQty <= 0) {
|
||||
continue;
|
||||
}
|
||||
//整托分配
|
||||
allocateQty = inv.getQuantity();
|
||||
if (unQty < allocateQty) {
|
||||
allocateQty = unQty;
|
||||
return ApiResult.fail(201,"剩余订单数量不足一托","");
|
||||
}
|
||||
inv.setQueuedQty(inv.getQueuedQty() + allocateQty);
|
||||
//更新库存
|
||||
inv.setQueuedQty(allocateQty);
|
||||
inventoryRepository.save(inv);
|
||||
unQty -= allocateQty;
|
||||
pd.setAllocatedQty(pd.getAllocatedQty() + allocateQty);
|
||||
if (pd.getOrderQty().equals(pd.getAllocatedQty())) {
|
||||
pd.setStatus(BizStatus.ALLOCATE);
|
||||
}
|
||||
pickDetailRepository.save(pd);
|
||||
|
||||
//生成搬运任务
|
||||
AgvTask agvTask = new AgvTask(BizStatus.PICK, stock.getCode(), startPoint.getCode(), endPoint.getCode(), BizStatus.OPEN, "01");
|
||||
agvTaskRepository.save(agvTask);
|
||||
//生成Task
|
||||
unQty = unQty-allocateQty;
|
||||
//更新出库单
|
||||
pickDetail.setAllocatedQty(pickDetail.getAllocatedQty() + allocateQty);
|
||||
pickDetail.setStatus(BizStatus.ALLOCATE);
|
||||
pickDetailRepository.save(pickDetail);
|
||||
//生成Task任务
|
||||
Task task = new Task();
|
||||
task.setItem(item);
|
||||
task.setItemKey(inv.getItemKey());
|
||||
task.setPickDetail(pd);
|
||||
task.setBillCode(pd.getPo());
|
||||
task.setSrcStock(inv.getStock());
|
||||
task.setDstStock(inv.getStock());
|
||||
task.setPickDetail(pickDetail);
|
||||
task.setBillCode(pickDetail.getPick().getRelatedBill1());
|
||||
task.setSrcPoint(startPoint);
|
||||
task.setDstPoint(endPoint);
|
||||
task.setSrcStockCode(inv.getStock().getCode());
|
||||
task.setSrcPointCode(startPoint.getCode());
|
||||
task.setDstPointCode(endPoint.getCode());
|
||||
task.setInvStatus(inv.getStatus());
|
||||
task.setTaskStatus(BizStatus.OPEN);
|
||||
task.setTaskType(BizStatus.PICK);
|
||||
task.setTaskStatus(BizStatus.ALLOCATE);
|
||||
task.setBeSkip(1);//是否AGV出库
|
||||
task.setPlanQty(allocateQty);
|
||||
task.setDept(dept);
|
||||
task.setAgvTask(agvTask);
|
||||
task.setInventory(inv);
|
||||
taskRepository.save(task);
|
||||
}
|
||||
}else {
|
||||
return ApiResult.fail(500, item.getCode()+"料号,无库存", "");
|
||||
}
|
||||
}else {
|
||||
return ApiResult.fail(500, "已分配", "");
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new RuntimeException("已分配,请勿重复操作!");
|
||||
}
|
||||
}
|
||||
return ApiResult.fail(200,"操作成功",null);
|
||||
|
|
@ -352,7 +332,7 @@ public class PickDetailServiceImpl implements PickDetailService {
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public synchronized void cancelAllocate(long id, double quantity) throws Exception {
|
||||
public void cancelAllocate(long id, double quantity){
|
||||
|
||||
PickDetailDto pickDetailDto = findById(id);
|
||||
PickDetail pd = toEntity(pickDetailDto);
|
||||
|
|
@ -360,13 +340,13 @@ public class PickDetailServiceImpl implements PickDetailService {
|
|||
for (Task task : Tasks) {
|
||||
//根据Taskz找到对应的库存
|
||||
Inventory inv = inventoryRepository.findById(task.getInventory().getId()).get();
|
||||
inv.setQueuedQty(inv.getQueuedQty() - pd.getAllocatedQty());
|
||||
inv.setQueuedQty(inv.getQueuedQty() - task.getPlanQty());
|
||||
inventoryRepository.save(inv);
|
||||
|
||||
//删除Task
|
||||
taskRepository.delete(task);
|
||||
|
||||
pd.setAllocatedQty(pd.getAllocatedQty() - quantity);
|
||||
pd.setAllocatedQty(pd.getAllocatedQty() - task.getPlanQty());
|
||||
if (pd.getAllocatedQty() == 0) {
|
||||
pd.setStatus(BizStatus.OPEN);
|
||||
}
|
||||
|
|
@ -376,6 +356,15 @@ public class PickDetailServiceImpl implements PickDetailService {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult cancelAllocate(Long[] ids) {
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
PickDetail pickDetail=pickDetailRepository.getById(ids[i]);
|
||||
cancelAllocate(pickDetail.getId(), pickDetail.getOrderQty());
|
||||
}
|
||||
return ApiResult.fail(200, "操作成功", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long count() {
|
||||
return pickDetailRepository.count();
|
||||
|
|
|
|||
Loading…
Reference in New Issue