refactor(入库计划): 封装自动分配库位
This commit is contained in:
parent
5e391eca1d
commit
7a518435b4
@ -88,22 +88,7 @@ public class WmsInPlanController extends BaseController {
|
|||||||
@Log(title = "入库计划", businessType = BusinessType.INSERT)
|
@Log(title = "入库计划", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody WmsInPlan wmsInPlan) {
|
public AjaxResult add(@RequestBody WmsInPlan wmsInPlan) {
|
||||||
// 校验是否指定了库区
|
wmsInPlanService.autoCell(wmsInPlan);
|
||||||
if (wmsInPlan.getLocationCode() != null && !wmsInPlan.getLocationCode().isEmpty()) {
|
|
||||||
wmsInPlan.getWmsInPlanDetailsList().forEach(wmsInPlanDetails -> {
|
|
||||||
// 获得物料ID
|
|
||||||
MdItem mdItemById = mdItemMapper.selectMdItemById(Long.parseLong(wmsInPlanDetails.getMaterialId()));
|
|
||||||
if (mdItemById == null) throw new RuntimeException("操作失败,该物料不存在");
|
|
||||||
|
|
||||||
// 根据限定条件自动获取库位
|
|
||||||
WmStorageArea wmStorageArea = wmStorageLocationService.queryOneAreaByLocationCode(wmsInPlan.getLocationCode(), mdItemById.getAttr3() == 1);
|
|
||||||
if (wmStorageArea == null) throw new RuntimeException("操作失败,缺少空闲库位");
|
|
||||||
|
|
||||||
// 设定库位
|
|
||||||
wmsInPlanDetails.setCellId(wmStorageArea.getAreaId());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return toAjax(wmsInPlanService.insertWmsInPlan(wmsInPlan));
|
return toAjax(wmsInPlanService.insertWmsInPlan(wmsInPlan));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,4 +82,10 @@ public interface IWmsInPlanService
|
|||||||
* @param wmsInPlan 入库计划
|
* @param wmsInPlan 入库计划
|
||||||
*/
|
*/
|
||||||
public void insertAndIssueWmsInPlan(WmsInPlan wmsInPlan);
|
public void insertAndIssueWmsInPlan(WmsInPlan wmsInPlan);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分配库位
|
||||||
|
* @param wmsInPlan 入库计划
|
||||||
|
*/
|
||||||
|
public void autoCell(WmsInPlan wmsInPlan);
|
||||||
}
|
}
|
||||||
|
@ -302,10 +302,39 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService {
|
|||||||
wmsInPlanMapper.updateWmsInPlan(wmsInPlan);
|
wmsInPlanMapper.updateWmsInPlan(wmsInPlan);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建并执行入库计划
|
||||||
|
*
|
||||||
|
* @param wmsInPlan 入库计划
|
||||||
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void insertAndIssueWmsInPlan(WmsInPlan wmsInPlan) {
|
public void insertAndIssueWmsInPlan(WmsInPlan wmsInPlan) {
|
||||||
this.insertWmsInPlan(wmsInPlan);
|
this.insertWmsInPlan(wmsInPlan);
|
||||||
this.issueWmsInPlan(wmsInPlan.getPlanId());
|
this.issueWmsInPlan(wmsInPlan.getPlanId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自动分配库位
|
||||||
|
*
|
||||||
|
* @param wmsInPlan 入库计划
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void autoCell(WmsInPlan wmsInPlan) {
|
||||||
|
// 校验是否指定了库区
|
||||||
|
if (StringUtils.isNotEmpty(wmsInPlan.getLocationCode())) {
|
||||||
|
wmsInPlan.getWmsInPlanDetailsList().forEach(wmsInPlanDetails -> {
|
||||||
|
// 获得物料ID
|
||||||
|
MdItem mdItemById = mdItemService.selectMdItemById(Long.parseLong(wmsInPlanDetails.getMaterialId()));
|
||||||
|
if (mdItemById == null) throw new RuntimeException("操作失败,该物料不存在");
|
||||||
|
|
||||||
|
// 根据限定条件自动获取库位
|
||||||
|
WmStorageArea wmStorageArea = wmStorageLocationService.queryOneAreaByLocationCode(wmsInPlan.getLocationCode(), mdItemById.getAttr3() == 1);
|
||||||
|
if (wmStorageArea == null) throw new RuntimeException("操作失败,缺少空闲库位");
|
||||||
|
|
||||||
|
// 设定库位
|
||||||
|
wmsInPlanDetails.setCellId(wmStorageArea.getAreaId());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user