no message
parent
62921aa99c
commit
aedc6cb9ef
|
|
@ -175,21 +175,14 @@ public class PickDetailController {
|
||||||
public synchronized ResponseEntity<Object> allocatePick(@RequestBody Long[] ids) throws Exception {
|
public synchronized ResponseEntity<Object> allocatePick(@RequestBody Long[] ids) throws Exception {
|
||||||
List<Long> picktickIds = Arrays.asList(ids);
|
List<Long> picktickIds = Arrays.asList(ids);
|
||||||
Collections.sort(picktickIds);//升序排序
|
Collections.sort(picktickIds);//升序排序
|
||||||
if (picktickIds.size() > 0) {
|
List<String> msgList = new ArrayList<>();//存放提示信息
|
||||||
try {
|
|
||||||
for (Long picktickId : picktickIds) {
|
for (Long picktickId : picktickIds) {
|
||||||
List<PickDetail> pickDetailList = pickDetailService.queryPickDetailList(picktickId);
|
List<PickDetail> pickDetailList = pickDetailService.queryPickDetailList(picktickId);
|
||||||
for (PickDetail pd : pickDetailList) {
|
for (PickDetail pd : pickDetailList) {
|
||||||
pickDetailService.allocate(pd.getId(), pd.getOrderQty() - pd.getAllocatedQty());
|
msgList.add(pickDetailService.allocateAll(pd.getId(), pd.getOrderQty() - pd.getAllocatedQty()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
return new ResponseEntity<>(ApiResult.success(msgList.toString(),null), HttpStatus.OK);
|
||||||
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<>(ApiResult.success(),HttpStatus.OK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/sbPickdetail")
|
@PostMapping("/sbPickdetail")
|
||||||
|
|
|
||||||
|
|
@ -34,15 +34,16 @@ import java.io.IOException;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @author huojin
|
||||||
* @website https://eladmin.vip
|
* @website https://eladmin.vip
|
||||||
* @description 服务接口
|
* @description 服务接口
|
||||||
* @author huojin
|
|
||||||
* @date 2023-08-16
|
* @date 2023-08-16
|
||||||
**/
|
**/
|
||||||
public interface PickDetailService {
|
public interface PickDetailService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询数据分页
|
* 查询数据分页
|
||||||
|
*
|
||||||
* @param criteria 条件
|
* @param criteria 条件
|
||||||
* @param pageable 分页参数
|
* @param pageable 分页参数
|
||||||
* @return Map<String, Object>
|
* @return Map<String, Object>
|
||||||
|
|
@ -51,6 +52,7 @@ public interface PickDetailService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有数据不分页
|
* 查询所有数据不分页
|
||||||
|
*
|
||||||
* @param criteria 条件参数
|
* @param criteria 条件参数
|
||||||
* @return List<PickDetailDto>
|
* @return List<PickDetailDto>
|
||||||
*/
|
*/
|
||||||
|
|
@ -60,6 +62,7 @@ public interface PickDetailService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据ID查询
|
* 根据ID查询
|
||||||
|
*
|
||||||
* @param id ID
|
* @param id ID
|
||||||
* @return PickDetailDto
|
* @return PickDetailDto
|
||||||
*/
|
*/
|
||||||
|
|
@ -67,6 +70,7 @@ public interface PickDetailService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建
|
* 创建
|
||||||
|
*
|
||||||
* @param resources /
|
* @param resources /
|
||||||
* @return PickDetailDto
|
* @return PickDetailDto
|
||||||
*/
|
*/
|
||||||
|
|
@ -74,23 +78,28 @@ public interface PickDetailService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑
|
* 编辑
|
||||||
|
*
|
||||||
* @param resources /
|
* @param resources /
|
||||||
*/
|
*/
|
||||||
void update(PickDetail resources);
|
void update(PickDetail resources);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多选删除
|
* 多选删除
|
||||||
|
*
|
||||||
* @param ids /
|
* @param ids /
|
||||||
*/
|
*/
|
||||||
void deleteAll(Long[] ids);
|
void deleteAll(Long[] ids);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除出库明细更新数据
|
* 删除出库明细更新数据
|
||||||
|
*
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
void deletePickDetail(Long id);
|
void deletePickDetail(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出数据
|
* 导出数据
|
||||||
|
*
|
||||||
* @param all 待导出的数据
|
* @param all 待导出的数据
|
||||||
* @param response /
|
* @param response /
|
||||||
* @throws Exception /
|
* @throws Exception /
|
||||||
|
|
@ -102,6 +111,11 @@ public interface PickDetailService {
|
||||||
*/
|
*/
|
||||||
void allocate(long id, double quantity);
|
void allocate(long id, double quantity);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分配
|
||||||
|
*/
|
||||||
|
String allocateAll(long id, double quantity);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取消分配
|
* 取消分配
|
||||||
*/
|
*/
|
||||||
|
|
@ -109,12 +123,14 @@ public interface PickDetailService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统计数量
|
* 统计数量
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
long count();
|
long count();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dto转实体
|
* Dto转实体
|
||||||
|
*
|
||||||
* @param pickDetailDto
|
* @param pickDetailDto
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -122,6 +138,7 @@ public interface PickDetailService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自动生成明细
|
* 自动生成明细
|
||||||
|
*
|
||||||
* @param pt
|
* @param pt
|
||||||
* @param item
|
* @param item
|
||||||
* @param po
|
* @param po
|
||||||
|
|
@ -133,6 +150,7 @@ public interface PickDetailService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 未分配的出库明细集合
|
* 未分配的出库明细集合
|
||||||
|
*
|
||||||
* @param picktickId
|
* @param picktickId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
@ -142,12 +160,14 @@ public interface PickDetailService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取补货需求明细
|
* 获取补货需求明细
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Object[]> getQueryBcbl(Date blDate, Long ckAreaId, String gc);
|
List<Object[]> getQueryBcbl(Date blDate, Long ckAreaId, String gc);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 得到组合最大的备货需求数
|
* 得到组合最大的备货需求数
|
||||||
|
*
|
||||||
* @param picktickId
|
* @param picktickId
|
||||||
* @param largeClass
|
* @param largeClass
|
||||||
* @return
|
* @return
|
||||||
|
|
@ -156,6 +176,7 @@ public interface PickDetailService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 得到组合所有叫料明细
|
* 得到组合所有叫料明细
|
||||||
|
*
|
||||||
* @param picktickId
|
* @param picktickId
|
||||||
* @param largeClass
|
* @param largeClass
|
||||||
* @return
|
* @return
|
||||||
|
|
|
||||||
|
|
@ -179,6 +179,7 @@ public class PickDetailServiceImpl implements PickDetailService {
|
||||||
if (pd.getOrderQty() - pd.getAllocatedQty() == 0) {
|
if (pd.getOrderQty() - pd.getAllocatedQty() == 0) {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, "已分配,请勿重复操作!");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, "已分配,请勿重复操作!");
|
||||||
}
|
}
|
||||||
|
|
||||||
Long zzkwId = null;
|
Long zzkwId = null;
|
||||||
if (pd.getPoint() != null && pickTicket.getArea().getBexb()) {
|
if (pd.getPoint() != null && pickTicket.getArea().getBexb()) {
|
||||||
zzkwId = pd.getPoint().getId();
|
zzkwId = pd.getPoint().getId();
|
||||||
|
|
@ -188,7 +189,6 @@ public class PickDetailServiceImpl implements PickDetailService {
|
||||||
throw new BadRequestException(HttpStatus.NOT_FOUND, "请维护发货暂存区");
|
throw new BadRequestException(HttpStatus.NOT_FOUND, "请维护发货暂存区");
|
||||||
}
|
}
|
||||||
List<Inventory> invs = inventoryService.queryInventoryAllocate(item.getId(), pickTicket.getArea().getId(), zzkwId);
|
List<Inventory> invs = inventoryService.queryInventoryAllocate(item.getId(), pickTicket.getArea().getId(), zzkwId);
|
||||||
if (invs.size() > 0) {
|
|
||||||
double allocateQty = 0;
|
double allocateQty = 0;
|
||||||
double unQty = quantity;//未分配数量
|
double unQty = quantity;//未分配数量
|
||||||
for (Inventory inv : invs) {
|
for (Inventory inv : invs) {
|
||||||
|
|
@ -217,9 +217,63 @@ public class PickDetailServiceImpl implements PickDetailService {
|
||||||
pickTicketRepository.save(pickTicket);
|
pickTicketRepository.save(pickTicket);
|
||||||
taskService.storeTask(null, pd, pickTicket.getArea(), inv.getItemKey(), startPoint, endPoint, allocateQty);
|
taskService.storeTask(null, pd, pickTicket.getArea(), inv.getItemKey(), startPoint, endPoint, allocateQty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public String allocateAll(long id, double quantity) {
|
||||||
|
PickDetailDto pickDetailDto = findById(id);
|
||||||
|
PickDetail pd = toEntity(pickDetailDto);//Dto转实体
|
||||||
|
PickTicket pickTicket = pd.getPickTicket();
|
||||||
|
ItemDto itemDto = pickDetailDto.getItem();
|
||||||
|
Item item = itemService.toEntity(itemDto);
|
||||||
|
if (pd.getOrderQty() - pd.getAllocatedQty() == 0) {
|
||||||
|
return pickTicket.getCode() + "出库单;" + item.getCode() + "数量已分配!";
|
||||||
|
}
|
||||||
|
Long zzkwId = null;
|
||||||
|
if (pd.getPoint() != null && pickTicket.getArea().getBexb()) {
|
||||||
|
zzkwId = pd.getPoint().getId();
|
||||||
|
}
|
||||||
|
List<Inventory> invs = inventoryService.queryInventoryAllocate(item.getId(), pickTicket.getArea().getId(), zzkwId);
|
||||||
|
if (invs.isEmpty()) {
|
||||||
|
return item.getCode() + "物料库存不足,请先补充库存!";
|
||||||
|
}
|
||||||
|
|
||||||
|
Point endPoint = pointService.getPoint("FHQ", null, null, null);//目标库位
|
||||||
|
if (endPoint == null) {
|
||||||
|
return "请维护发货暂存区!";
|
||||||
|
}
|
||||||
|
double allocateQty = 0;
|
||||||
|
double unQty = quantity;//未分配数量
|
||||||
|
for (Inventory inv : invs) {
|
||||||
|
Point startPoint = inv.getPoint();//原库位
|
||||||
|
if (unQty <= 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
allocateQty = inv.getQuantity() - inv.getQueuedQty();//库存可用数量
|
||||||
|
if (allocateQty <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (unQty < allocateQty) {
|
||||||
|
allocateQty = unQty;
|
||||||
|
}
|
||||||
|
inv.setQueuedQty(inv.getQueuedQty() + allocateQty);
|
||||||
|
inventoryRepository.save(inv);
|
||||||
|
unQty -= allocateQty;
|
||||||
|
pd.setAllocatedQty(pd.getAllocatedQty() + allocateQty);
|
||||||
|
pickDetailRepository.save(pd);
|
||||||
|
pickTicket.setAllocatedQuantity(pickTicket.getAllocatedQuantity() + allocateQty);
|
||||||
|
if (pickTicket.getAllocatedQuantity() > 0) {
|
||||||
|
pickTicket.setStatus(BizStatus.ALLOCATE);
|
||||||
|
}
|
||||||
|
//备货表上出单日期(审核写)
|
||||||
|
pickTicket.setOutOrderDate(new Timestamp(new Date().getTime()));
|
||||||
|
pickTicketRepository.save(pickTicket);
|
||||||
|
taskService.storeTask(null, pd, pickTicket.getArea(), inv.getItemKey(), startPoint, endPoint, allocateQty);
|
||||||
|
}
|
||||||
|
return item.getCode() + "物料分配成功!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue