增加判检退货出库

This commit is contained in:
彭枝刚 2024-11-22 15:33:39 +08:00
parent 9e8c94ba5e
commit 3f424ff390
6 changed files with 705 additions and 634 deletions

View File

@ -66,6 +66,7 @@ public class PoOrderController {
@ApiOperation(value = "采购登记-获取物料", notes = "采购登记-获取物料")
@SysLog("采购登记-获取物料")
@Inner(false)
@PostMapping("/api/saveDocumentData")
public R saveDocumentData(@RequestBody List<DocumentDetailed> zwDocumentDetailList) {
return R.ok(poOrderService.saveDocumentData(zwDocumentDetailList));

View File

@ -3,12 +3,12 @@ package com.foreverwin.mom.wms.controller;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.foreverwin.iep.common.base.FrontPage;
import com.foreverwin.mom.common.core.exception.BusinessException;
import com.foreverwin.mom.common.core.util.R;
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
import com.foreverwin.mom.common.log.annotation.SysLog;
import com.foreverwin.mom.common.security.util.SecurityUtils;
import com.foreverwin.iep.common.base.FrontPage;
import com.foreverwin.mom.wms.dto.FreezeDto;
import com.foreverwin.mom.wms.dto.InventoryDto;
import com.foreverwin.mom.wms.entity.Inventory;
@ -43,343 +43,370 @@ import java.util.Map;
@Api(value = "inventory", tags = "库存(物料批次)管理")
public class ZWmsInventoryController {
private final ZWmsInventoryService inventoryService;
private final FreezeService freezeService;
private final BarCodeQueryService barCodeQueryService;
private final ZWmsInventoryService inventoryService;
private final FreezeService freezeService;
private final BarCodeQueryService barCodeQueryService;
/**
* 库存冻结导出
*
* @param freezeDto
* @return R
*/
@ResponseBody
@GetMapping("/freezeListExport")
public void inventoryCheckExport(FreezeDto freezeDto) throws Exception {
List<FreezeDto> freezeList = freezeService.getFreezeList(freezeDto);
if (freezeList.isEmpty()) {
throw BusinessException.build("没有需要导出的数据");
}
String fileName = "库存冻结导出";
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletResponse response = attributes.getResponse();
response.setCharacterEncoding("utf-8");
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
EasyExcel.write(response.getOutputStream(), FreezeDto.class).autoCloseStream(Boolean.FALSE).sheet(fileName)
.doWrite(freezeList);
}
/**
* 判检退货出库
*
* @param inventory
* @return R
*/
@ApiOperation(value = "判检退货出库-批次校验", notes = "判检退货出库-批次校验")
@SysLog("判检退货出库-批次校验")
@GetMapping("/validateInventoryId")
public R validateInventoryId(Inventory inventory) {
return R.ok(inventoryService.validateInventoryId(inventory));
}
/**
* 库存查询
*
* @param freezeDto
* @return R
*/
@ApiOperation(value = "库存查询", notes = "库存查询")
@SysLog("库存查询")
@GetMapping("/getFreezeList")
public R getFreezeList(FreezeDto freezeDto) {
return R.ok(freezeService.getFreezeList(freezeDto));
}
/**
* 判检退货出库-确认出库
*
* @param inventoryList
* @return R
*/
@ApiOperation(value = "判检退货出库-确认出库", notes = "判检退货出库-确认出库")
@SysLog("判检退货出库-确认出库")
@PostMapping("/setInventoryQtyToZero")
public R setInventoryQtyToZero(@RequestBody List<InventoryDto> inventoryList) {
inventoryService.setInventoryQtyToZero(inventoryList);
return R.ok();
}
/**
* 库存查询
*
* @param freezeDto
* @return R
*/
@ApiOperation(value = "库存查询", notes = "库存查询")
@SysLog("库存查询")
@GetMapping("/pageFreezeList")
public R pageFreezeList(FrontPage frontPage, FreezeDto freezeDto) {
return R.ok(freezeService.getFreezeList(frontPage, freezeDto));
}
/**
* 库存冻结导出
*
* @param freezeDto
* @return R
*/
@ResponseBody
@GetMapping("/freezeListExport")
public void inventoryCheckExport(FreezeDto freezeDto) throws Exception {
List<FreezeDto> freezeList = freezeService.getFreezeList(freezeDto);
if (freezeList.isEmpty()) {
throw BusinessException.build("没有需要导出的数据");
}
String fileName = "库存冻结导出";
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletResponse response = attributes.getResponse();
response.setCharacterEncoding("utf-8");
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
EasyExcel.write(response.getOutputStream(), FreezeDto.class).autoCloseStream(Boolean.FALSE).sheet(fileName)
.doWrite(freezeList);
}
/**
* 库存冻结
*
* @param inventoryList 库存(物料批次)
* @return R
*/
@ApiOperation(value = "库存冻结", notes = "库存冻结")
@SysLog("修改库存(物料批次)")
@PostMapping("/freeze")
@PreAuthorize("@pms.hasPermission('wms_inventory_save')")
public R freeze(@RequestBody List<Inventory> inventoryList) {
freezeService.freeze(inventoryList);
return R.ok();
}
/**
* 库存查询
*
* @param freezeDto
* @return R
*/
@ApiOperation(value = "库存查询", notes = "库存查询")
@SysLog("库存查询")
@GetMapping("/getFreezeList")
public R getFreezeList(FreezeDto freezeDto) {
return R.ok(freezeService.getFreezeList(freezeDto));
}
/**
* 库存解冻
*
* @param inventory 库存(物料批次)
* @return R
*/
@ApiOperation(value = "库存解冻", notes = "库存解冻")
@SysLog("修改库存(物料批次)")
@PostMapping("/unfreeze")
@PreAuthorize("@pms.hasPermission('wms_inventory_save')")
public R unfreeze(@RequestBody List<Inventory> inventory) {
freezeService.unfreeze(inventory);
return R.ok();
}
/**
* 库存查询
*
* @param freezeDto
* @return R
*/
@ApiOperation(value = "库存查询", notes = "库存查询")
@SysLog("库存查询")
@GetMapping("/pageFreezeList")
public R pageFreezeList(FrontPage frontPage, FreezeDto freezeDto) {
return R.ok(freezeService.getFreezeList(frontPage, freezeDto));
}
/**
* 分页查询
*
* @param page 分页对象
* @param inventory 库存(物料批次)
* @return
*/
@ApiOperation(value = "分页查询", notes = "分页查询")
@GetMapping("/page")
public R getInventoryPage(FrontPage page, Inventory inventory) {
inventory.setSite(TenantContextHolder.getTenantId());
QueryWrapper<Inventory> queryWrapper = new QueryWrapper<>(inventory);
if (page.getSearchText() != null && !"".equals(page.getSearchText().trim())) {
queryWrapper.lambda().and(wrapper -> wrapper
.like(Inventory::getInventoryId, page.getSearchText())
.or().like(Inventory::getStatus, page.getSearchText())
.or().like(Inventory::getItemBo, page.getSearchText())
.or().like(Inventory::getUnitOfMeasure, page.getSearchText())
.or().like(Inventory::getBatchNo, page.getSearchText())
.or().like(Inventory::getVendorBatchNo, page.getSearchText())
.or().like(Inventory::getValid, page.getSearchText())
.or().like(Inventory::getParentInventoryBo, page.getSearchText())
.or().like(Inventory::getCreator, page.getSearchText())
.or().like(Inventory::getUpdater, page.getSearchText())
);
}
return R.ok(inventoryService.page(page, queryWrapper));
}
/**
* 库存冻结
*
* @param inventoryList 库存(物料批次)
* @return R
*/
@ApiOperation(value = "库存冻结", notes = "库存冻结")
@SysLog("修改库存(物料批次)")
@PostMapping("/freeze")
@PreAuthorize("@pms.hasPermission('wms_inventory_save')")
public R freeze(@RequestBody List<Inventory> inventoryList) {
freezeService.freeze(inventoryList);
return R.ok();
}
/**
* 分页查询
*
* @param page 分页对象
* @param inventory 库存(物料批次)
* @return
*/
@ApiOperation(value = "分页查询", notes = "分页查询")
@GetMapping("/getInventoryDtoPage")
public R getInventoryDtoPage(FrontPage page, Inventory inventory) {
inventory.setSite(TenantContextHolder.getTenantId());
return R.ok(inventoryService.getInventoryDtoPage(page, inventory));
}
/**
* 库存解冻
*
* @param inventory 库存(物料批次)
* @return R
*/
@ApiOperation(value = "库存解冻", notes = "库存解冻")
@SysLog("修改库存(物料批次)")
@PostMapping("/unfreeze")
@PreAuthorize("@pms.hasPermission('wms_inventory_save')")
public R unfreeze(@RequestBody List<Inventory> inventory) {
freezeService.unfreeze(inventory);
return R.ok();
}
/**
* 根据载具分页查询
*
* @param page 分页对象
* @param dto 库存(物料批次)
* @return
*/
@ApiOperation(value = "分页查询", notes = "分页查询")
@GetMapping("/getInventoryDtoPageByCarrier")
public R getInventoryDtoPageByCarrier(FrontPage page, InventoryDto dto) {
dto.setSite(TenantContextHolder.getTenantId());
return R.ok(inventoryService.getInventoryDtoPageByCarrier(page, dto));
}
/**
* 分页查询
*
* @param page 分页对象
* @param inventory 库存(物料批次)
* @return
*/
@ApiOperation(value = "分页查询", notes = "分页查询")
@GetMapping("/page")
public R getInventoryPage(FrontPage page, Inventory inventory) {
inventory.setSite(TenantContextHolder.getTenantId());
QueryWrapper<Inventory> queryWrapper = new QueryWrapper<>(inventory);
if (page.getSearchText() != null && !"".equals(page.getSearchText().trim())) {
queryWrapper.lambda().and(wrapper -> wrapper
.like(Inventory::getInventoryId, page.getSearchText())
.or().like(Inventory::getStatus, page.getSearchText())
.or().like(Inventory::getItemBo, page.getSearchText())
.or().like(Inventory::getUnitOfMeasure, page.getSearchText())
.or().like(Inventory::getBatchNo, page.getSearchText())
.or().like(Inventory::getVendorBatchNo, page.getSearchText())
.or().like(Inventory::getValid, page.getSearchText())
.or().like(Inventory::getParentInventoryBo, page.getSearchText())
.or().like(Inventory::getCreator, page.getSearchText())
.or().like(Inventory::getUpdater, page.getSearchText())
);
}
return R.ok(inventoryService.page(page, queryWrapper));
}
/**
* 查询
*
* @param inventoryId 库存ID
* @return
*/
@ApiOperation(value = "查询id", notes = "查询id")
@GetMapping("/inventoryDto")
public R getInventoryDto(String inventoryId) {
String site = TenantContextHolder.getTenantId();
return R.ok(inventoryService.getInventoryDto(site, inventoryId));
}
/**
* 分页查询
*
* @param page 分页对象
* @param inventory 库存(物料批次)
* @return
*/
@ApiOperation(value = "分页查询", notes = "分页查询")
@GetMapping("/getInventoryDtoPage")
public R getInventoryDtoPage(FrontPage page, Inventory inventory) {
inventory.setSite(TenantContextHolder.getTenantId());
return R.ok(inventoryService.getInventoryDtoPage(page, inventory));
}
/**
* 通过id查询库存(物料批次)
*
* @param handle id
* @return R
*/
@ApiOperation(value = "通过id查询", notes = "通过id查询")
@GetMapping("/{handle}")
public R getById(@PathVariable("handle") String handle) {
return R.ok(inventoryService.getById(handle));
}
/**
* 根据载具分页查询
*
* @param page 分页对象
* @param dto 库存(物料批次)
* @return
*/
@ApiOperation(value = "分页查询", notes = "分页查询")
@GetMapping("/getInventoryDtoPageByCarrier")
public R getInventoryDtoPageByCarrier(FrontPage page, InventoryDto dto) {
dto.setSite(TenantContextHolder.getTenantId());
return R.ok(inventoryService.getInventoryDtoPageByCarrier(page, dto));
}
/**
* 通过code查询库存(物料批次)
*
* @param code code
* @return R
*/
@ApiOperation(value = "通过code查询", notes = "通过code查询")
@GetMapping("/by-code")
public R getByCode(String code) {
String site = TenantContextHolder.getTenantId();
return R.ok(inventoryService.getByCode(site, code));
}
/**
* 查询
*
* @param inventoryId 库存ID
* @return
*/
@ApiOperation(value = "查询id", notes = "查询id")
@GetMapping("/inventoryDto")
public R getInventoryDto(String inventoryId) {
String site = TenantContextHolder.getTenantId();
return R.ok(inventoryService.getInventoryDto(site, inventoryId));
}
/**
* 通过code删除库存(物料批次)
*
* @param code code
* @return R
*/
@ApiOperation(value = "通过code查询", notes = "通过code查询")
@DeleteMapping("/delete-by-code")
public R deleteByCode(String code) {
String site = TenantContextHolder.getTenantId();
return R.ok(inventoryService.deleteByCode(site, code));
}
/**
* 通过id查询库存(物料批次)
*
* @param handle id
* @return R
*/
@ApiOperation(value = "通过id查询", notes = "通过id查询")
@GetMapping("/{handle}")
public R getById(@PathVariable("handle") String handle) {
return R.ok(inventoryService.getById(handle));
}
/**
* 新增库存(物料批次)
*
* @param inventory 库存(物料批次)
* @return R
*/
@ApiOperation(value = "新增库存(物料批次)", notes = "新增库存(物料批次)")
@SysLog("新增库存(物料批次)")
@PostMapping
@PreAuthorize("@pms.hasPermission('wms_inventory_save')")
public R save(@RequestBody Inventory inventory) {
String site = TenantContextHolder.getTenantId();
String user = SecurityUtils.getUserName();
return R.ok(inventoryService.save(site, user, inventory));
}
/**
* 通过code查询库存(物料批次)
*
* @param code code
* @return R
*/
@ApiOperation(value = "通过code查询", notes = "通过code查询")
@GetMapping("/by-code")
public R getByCode(String code) {
String site = TenantContextHolder.getTenantId();
return R.ok(inventoryService.getByCode(site, code));
}
/**
* 修改库存(物料批次)
*
* @param inventory 库存(物料批次)
* @return R
*/
@ApiOperation(value = "修改库存(物料批次)", notes = "修改库存(物料批次)")
@SysLog("修改库存(物料批次)")
@PutMapping
@PreAuthorize("@pms.hasPermission('wms_inventory_save')")
public R updateById(@RequestBody Inventory inventory) {
String site = TenantContextHolder.getTenantId();
String user = SecurityUtils.getUserName();
return R.ok(freezeService.updateById(site, user, inventory));
}
/**
* 通过code删除库存(物料批次)
*
* @param code code
* @return R
*/
@ApiOperation(value = "通过code查询", notes = "通过code查询")
@DeleteMapping("/delete-by-code")
public R deleteByCode(String code) {
String site = TenantContextHolder.getTenantId();
return R.ok(inventoryService.deleteByCode(site, code));
}
/**
* 通过id删除库存(物料批次)
*
* @param handle id
* @return R
*/
@ApiOperation(value = "通过id删除库存(物料批次)", notes = "通过id删除库存(物料批次)")
@SysLog("通过id删除库存(物料批次)")
@DeleteMapping("/{handle}")
@PreAuthorize("@pms.hasPermission('wms_inventory_del')")
public R removeById(@PathVariable String handle) {
return R.ok(inventoryService.removeById(handle));
}
/**
* 新增库存(物料批次)
*
* @param inventory 库存(物料批次)
* @return R
*/
@ApiOperation(value = "新增库存(物料批次)", notes = "新增库存(物料批次)")
@SysLog("新增库存(物料批次)")
@PostMapping
@PreAuthorize("@pms.hasPermission('wms_inventory_save')")
public R save(@RequestBody Inventory inventory) {
String site = TenantContextHolder.getTenantId();
String user = SecurityUtils.getUserName();
return R.ok(inventoryService.save(site, user, inventory));
}
/**
* 修改库存(物料批次)
*
* @param inventory 库存(物料批次)
* @return R
*/
@ApiOperation(value = "修改库存(物料批次)", notes = "修改库存(物料批次)")
@SysLog("修改库存(物料批次)")
@PutMapping
@PreAuthorize("@pms.hasPermission('wms_inventory_save')")
public R updateById(@RequestBody Inventory inventory) {
String site = TenantContextHolder.getTenantId();
String user = SecurityUtils.getUserName();
return R.ok(freezeService.updateById(site, user, inventory));
}
/**
* 通过id删除库存(物料批次)
*
* @param handle id
* @return R
*/
@ApiOperation(value = "通过id删除库存(物料批次)", notes = "通过id删除库存(物料批次)")
@SysLog("通过id删除库存(物料批次)")
@DeleteMapping("/{handle}")
@PreAuthorize("@pms.hasPermission('wms_inventory_del')")
public R removeById(@PathVariable String handle) {
return R.ok(inventoryService.removeById(handle));
}
/**
* 库内冻结物料弹出框
*
* @param page
* @param item
* @return
*/
@GetMapping("/fetchItemList")
public R fetchItemList(Page page, String item) {
return R.ok(inventoryService.fetchItemList(page, item));
}
/**
* 库内冻结物料弹出框
*
* @param page
* @param item
* @return
*/
@GetMapping("/fetchItemList")
public R fetchItemList(Page page, String item) {
return R.ok(inventoryService.fetchItemList(page, item));
}
/**
* 库内冻结物料规格弹出框
*
* @param page
* @param groes
* @return
*/
@GetMapping("/fetchItemGroesList")
public R fetchItemGroesList(Page page, String groes) {
return R.ok(inventoryService.fetchItemGroesList(page, groes));
}
/**
* 库内冻结物料规格弹出框
*
* @param page
* @param groes
* @return
*/
@GetMapping("/fetchItemGroesList")
public R fetchItemGroesList(Page page, String groes) {
return R.ok(inventoryService.fetchItemGroesList(page, groes));
}
/**
* 库存拆分
*
* @param request
* @return
*/
@PostMapping("/splitInventory")
public R splitInventory(@RequestBody Map<String, String> request) {
String site = TenantContextHolder.getTenantId();
String user = SecurityUtils.getUserName();
String parentInventoryId = request.get("parentInventoryId");
BigDecimal splitQty = new BigDecimal(request.get("splitQty"));
int splitNum = Integer.parseInt(request.get("splitNum"));
// 纳琳威打印
/**
* 库存拆分
*
* @param request
* @return
*/
@PostMapping("/splitInventory")
public R splitInventory(@RequestBody Map<String, String> request) {
String site = TenantContextHolder.getTenantId();
String user = SecurityUtils.getUserName();
String parentInventoryId = request.get("parentInventoryId");
BigDecimal splitQty = new BigDecimal(request.get("splitQty"));
int splitNum = Integer.parseInt(request.get("splitNum"));
// 纳琳威打印
/*String printer = request.get("printer");
if (StringUtil.isEmpty(printer)) {
throw BusinessException.build("打印机未维护");
} else {*/
List<String> splitInventoryIdList = inventoryService.splitInventory(site, user, parentInventoryId, splitQty, splitNum, null, null, null);
splitInventoryIdList.add(parentInventoryId);
//barCodeQueryService.batchPrint(splitInventoryIdList, printer);
splitInventoryIdList.remove(splitInventoryIdList.size() - 1);
return R.ok(splitInventoryIdList);
//}
}
List<String> splitInventoryIdList = inventoryService.splitInventory(site, user, parentInventoryId, splitQty, splitNum, null, null, null);
splitInventoryIdList.add(parentInventoryId);
//barCodeQueryService.batchPrint(splitInventoryIdList, printer);
splitInventoryIdList.remove(splitInventoryIdList.size() - 1);
return R.ok(splitInventoryIdList);
//}
}
/**
* 库存合并
*
* @param request
* @return
*/
@PostMapping("/mergeInventory")
public R mergeInventory(@RequestBody Map<String, Object> request) {
String site = TenantContextHolder.getTenantId();
String user = SecurityUtils.getUserName();
List<String> inventoryIdList = (List<String>) request.get("inventoryIdList");
//打印
String printer = request.get("printer").toString();
if (StringUtil.isEmpty(printer)) {
throw BusinessException.build("打印机未维护");
} else {
String mergeInventoryId = inventoryService.mergeInventory(site, user, inventoryIdList);
barCodeQueryService.batchPrint(Collections.singletonList(mergeInventoryId), printer);
return R.ok(mergeInventoryId);
}
}
/**
* 库存合并
*
* @param request
* @return
*/
@PostMapping("/mergeInventory")
public R mergeInventory(@RequestBody Map<String, Object> request) {
String site = TenantContextHolder.getTenantId();
String user = SecurityUtils.getUserName();
List<String> inventoryIdList = (List<String>) request.get("inventoryIdList");
//打印
String printer = request.get("printer").toString();
if (StringUtil.isEmpty(printer)) {
throw BusinessException.build("打印机未维护");
} else {
String mergeInventoryId = inventoryService.mergeInventory(site, user, inventoryIdList);
barCodeQueryService.batchPrint(Collections.singletonList(mergeInventoryId), printer);
return R.ok(mergeInventoryId);
}
}
/**
* 查询无组原材/包材库存
*
* @param inventoryId 库存ID
* @return
*/
@ApiOperation(value = "查询待拆合批条码", notes = "查询待拆合批条码")
@GetMapping("/selectForSplit")
public R selectForSplit(String inventoryId) {
String site = TenantContextHolder.getTenantId();
return R.ok(inventoryService.selectForSplit(site, inventoryId));
}
/**
* 查询无组原材/包材库存
*
* @param inventoryId 库存ID
* @return
*/
@ApiOperation(value = "查询待拆合批条码", notes = "查询待拆合批条码")
@GetMapping("/selectForSplit")
public R selectForSplit(String inventoryId) {
String site = TenantContextHolder.getTenantId();
return R.ok(inventoryService.selectForSplit(site, inventoryId));
}
@ApiOperation(value = "查询待盘盈盘亏条码", notes = "查询待盘盈盘亏条码")
@GetMapping("/selectForStocktaking")
public R selectForStocktaking(String inventoryId) {
String site = TenantContextHolder.getTenantId();
return R.ok(inventoryService.selectForStocktaking(site, inventoryId));
}
@ApiOperation(value = "查询待盘盈盘亏条码", notes = "查询待盘盈盘亏条码")
@GetMapping("/selectForStocktaking")
public R selectForStocktaking(String inventoryId) {
String site = TenantContextHolder.getTenantId();
return R.ok(inventoryService.selectForStocktaking(site, inventoryId));
}
@ApiOperation(value = "库存盘盈/盘亏", notes = "库存盘盈/盘亏")
@PostMapping("/inventoryStocktaking")
public R inventoryStocktaking(@RequestBody List<Inventory> inventoryList) {
String site = TenantContextHolder.getTenantId();
String userName = SecurityUtils.getUserName();
inventoryService.inventoryStocktaking(site, userName, inventoryList);
return R.ok();
}
//------------------------------------------------------------------------------------
@ApiOperation(value = "库存盘盈/盘亏", notes = "库存盘盈/盘亏")
@PostMapping("/inventoryStocktaking")
public R inventoryStocktaking(@RequestBody List<Inventory> inventoryList) {
String site = TenantContextHolder.getTenantId();
String userName = SecurityUtils.getUserName();
inventoryService.inventoryStocktaking(site, userName, inventoryList);
return R.ok();
}
//------------------------------------------------------------------------------------
}

View File

@ -23,6 +23,12 @@ public interface ZWmsInventoryService extends IService<Inventory> {
void createInventory(Inventory wmsInventory);
// NLV 已用 Snow
InventoryDto validateInventoryId(Inventory wmsInventory);
// NLV 已用 Snow
void setInventoryQtyToZero(List<InventoryDto> wmsInventoryList);
Inventory getByCode(String site, String code);
boolean deleteByCode(String site, String code);

View File

@ -89,8 +89,8 @@ public class PoOrderServiceImpl extends ServiceImpl<PoOrderMapper, PoOrder> impl
documentDetail.setDocumentBo(zwDocument.getHandle());
documentDetail.setHandle(DocumentDetailed.genHandle(zwDocument.getSite(), zwDocument.getDocumentNo(), documentDetail.getSeq()));
documentDetail.setState("SUBMIT");
documentDetail.setSite(SecurityUtils.getUserName());
documentDetail.setDocumentType(documentType);
documentDetail.setSite(zwDocument.getSite());
documentDetail.setDocumentType(zwDocument.getDocumentType());
documentDetail.setDocumentNo(documentNo);
documentDetail.setCreateDate(LocalDateTime.now());
documentDetail.setCreateUser(SecurityUtils.getUserName());

View File

@ -2,6 +2,7 @@ package com.foreverwin.mom.wms.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -9,7 +10,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.foreverwin.iep.common.base.FrontPage;
import com.foreverwin.iep.prd.domain.GenerateNextNumberRequest;
import com.foreverwin.iep.prd.domain.GenerateNextNumberResponse;
import com.foreverwin.iep.prd.entity.Item;
import com.foreverwin.iep.prd.feign.RemoteNextNumberService;
import com.foreverwin.mom.common.core.constant.SecurityConstants;
import com.foreverwin.mom.common.core.exception.BusinessException;
import com.foreverwin.mom.common.data.tenant.TenantContextHolder;
@ -17,19 +21,13 @@ import com.foreverwin.mom.common.security.util.SecurityUtils;
import com.foreverwin.mom.wms.constant.Constant;
import com.foreverwin.mom.wms.constant.KeyWordConstant;
import com.foreverwin.mom.wms.dto.InventoryDto;
import com.foreverwin.iep.prd.domain.GenerateNextNumberRequest;
import com.foreverwin.iep.prd.domain.GenerateNextNumberResponse;
import com.foreverwin.iep.prd.feign.RemoteNextNumberService;
import com.foreverwin.mom.wms.dto.ScanCodeDTO;
import com.foreverwin.mom.wms.entity.Carrier;
import com.foreverwin.mom.wms.entity.Inventory;
import com.foreverwin.mom.wms.entity.InventoryGroup;
import com.foreverwin.mom.wms.dto.ScanCodeDTO;
import com.foreverwin.mom.wms.entity.*;
import com.foreverwin.mom.wms.entity.InventoryLog;
import com.foreverwin.mom.wms.mapper.ZWmsInventoryMapper;
import com.foreverwin.mom.wms.service.WmsCarrierMemberService;
import com.foreverwin.mom.wms.service.InventoryGroupService;
import com.foreverwin.mom.wms.service.ZWmsInventoryLogService;
import com.foreverwin.mom.wms.service.ZWmsInventoryService;
import com.foreverwin.mom.wms.service.WmsItemService;
import com.foreverwin.mom.wms.service.*;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -41,10 +39,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.sql.SQLIntegrityConstraintViolationException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -58,21 +53,22 @@ import java.util.stream.Collectors;
@Transactional(rollbackFor = Exception.class)
public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, Inventory> implements ZWmsInventoryService {
private final ZWmsInventoryLogService inventoryLogService;
private final WmsItemService itemService;
private final ZWmsInventoryLogService inventoryLogService;
private final WmsItemService itemService;
private final InventoryGroupService inventoryGroupService;
private final InventoryGroupService inventoryGroupService;
private WmsCarrierMemberService wmsCarrierMemberService;
private WmsCarrierMemberService wmsCarrierMemberService;
private final RemoteNextNumberService remoteNextNumberService;
private final RemoteNextNumberService remoteNextNumberService;
@Autowired
public void setWmsCarrierMemberService(@Lazy WmsCarrierMemberService wmsCarrierMemberService) {
this.wmsCarrierMemberService = wmsCarrierMemberService;
}
@Autowired
public void setWmsCarrierMemberService(@Lazy WmsCarrierMemberService wmsCarrierMemberService) {
this.wmsCarrierMemberService = wmsCarrierMemberService;
}
// NLV 已用 Snow
@Override
public void createInventory(Inventory wmsInventory) {
wmsInventory.setSite(TenantContextHolder.getTenantId());
@ -82,237 +78,278 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
this.baseMapper.insert(wmsInventory);
}
// NLV 已用 Snow
@Override
public Inventory getByCode(String site, String code) {
public InventoryDto validateInventoryId(Inventory wmsInventory) {
InventoryDto inventory = this.baseMapper.getInventoryDto(Inventory.genHandle(TenantContextHolder.getTenantId(), wmsInventory.getInventoryId()));
if (inventory == null) {
throw BusinessException.build("库存条码" + wmsInventory.getInventoryId() + "不存在");
} else if (!"5".equals(inventory.getQmsSpecialMarking())) {
throw BusinessException.build("库存条码" + wmsInventory.getInventoryId() + "不是退货状态");
} else if (!(inventory.getQtyOnHand().compareTo(BigDecimal.ZERO) > 0)) {
throw BusinessException.build("库存条码" + wmsInventory.getInventoryId() + "已没有数量");
} else {
return inventory;
}
}
Inventory inventory = getById(Inventory.genHandle(site, code));
if (inventory == null) {
return null;
}
return inventory;
}
// NLV 已用 Snow
@Override
public void setInventoryQtyToZero(List<InventoryDto> wmsInventoryList) {
for (Inventory inv : wmsInventoryList) {
// 重新检索一遍,防止页面缓存太久,库存条码已被更新
Inventory inventory = getById(inv.getHandle());
if (inventory == null) {
throw BusinessException.build("库存条码" + inventory.getInventoryId() + "已不存在");
} else {
inventory.setQtyOnHand(BigDecimal.ZERO);
inventory.setUpdateTime(LocalDateTime.now());
inventory.setUpdater(SecurityUtils.getUserName());
updateById(inventory);
// 写入库存日志
InventoryLog inventoryLog = new InventoryLog();
BeanUtils.copyProperties(inventory, inventoryLog);
inventoryLog.setHandle(UUID.randomUUID().toString());
inventoryLog.setInventoryBo(inventory.getHandle());
inventoryLog.setChangeType("TH");
inventoryLog.setOriginalQty(inventory.getOriginalQty());
inventoryLog.setQtyOnHand(BigDecimal.ZERO);
inventoryLog.setPreviousQty(inventory.getQtyOnHand());
inventoryLog.setCreator(SecurityUtils.getUserName());
inventoryLog.setCreateTime(LocalDateTime.now());
inventoryLogService.save(inventoryLog);
}
}
}
@Override
public boolean deleteByCode(String site, String code) {
@Override
public Inventory getByCode(String site, String code) {
String id = Inventory.genHandle(site, code);
return removeById(id);
}
Inventory inventory = getById(Inventory.genHandle(site, code));
return inventory;
}
@Override
public boolean save(String site, String creator, Inventory inventory) {
inventory.setSite(site);
String handle = Inventory.genHandle(site, inventory.getInventoryId());
inventory.setHandle(handle);
inventory.setCreator(creator);
try {
return super.save(inventory);
} catch (Exception e) {
if (e instanceof SQLIntegrityConstraintViolationException || e instanceof DuplicateKeyException) {
throw new MybatisPlusException("系统中已存在指定的值:[" + e.getCause().getLocalizedMessage() + "]");
} else {
throw e;
}
}
}
@Override
public boolean deleteByCode(String site, String code) {
@Override
public boolean updateById(String site, String updater, Inventory inventory) {
String id = Inventory.genHandle(site, code);
return removeById(id);
}
String handle = inventory.getHandle();
if (StrUtil.isBlank(handle)) {
throw BusinessException.build("handle不能为空");
}
inventory.setUpdater(updater);
return super.updateById(inventory);
}
@Override
public boolean save(String site, String creator, Inventory inventory) {
inventory.setSite(site);
String handle = Inventory.genHandle(site, inventory.getInventoryId());
inventory.setHandle(handle);
inventory.setCreator(creator);
try {
return super.save(inventory);
} catch (Exception e) {
if (e instanceof SQLIntegrityConstraintViolationException || e instanceof DuplicateKeyException) {
throw new MybatisPlusException("系统中已存在指定的值:[" + e.getCause().getLocalizedMessage() + "]");
} else {
throw e;
}
}
}
@Override
public IPage getInventoryDtoPage(FrontPage page, Inventory inventory) {
return baseMapper.getInventoryDtoPage(page, inventory);
}
@Override
public boolean updateById(String site, String updater, Inventory inventory) {
@Override
public IPage getInventoryDtoPageByCarrier(FrontPage page, InventoryDto inventoryDto) {
return baseMapper.getInventoryDtoPageByCarrier(page, inventoryDto);
}
String handle = inventory.getHandle();
if (StrUtil.isBlank(handle)) {
throw BusinessException.build("handle不能为空");
}
inventory.setUpdater(updater);
return super.updateById(inventory);
}
@Override
public InventoryDto getInventoryDto(String site, String inventoryId) {
InventoryDto inventoryDto = baseMapper.getInventoryDto(Inventory.genHandle(site, inventoryId));
if (inventoryDto == null) {
throw BusinessException.build("库存不存在");
}
return inventoryDto;
}
@Override
public IPage getInventoryDtoPage(FrontPage page, Inventory inventory) {
return baseMapper.getInventoryDtoPage(page, inventory);
}
@Transactional(rollbackFor = Exception.class)
@Override
public void updateStatus(String user, String inventoryId, String status) {
String site = TenantContextHolder.getTenantId();
UpdateWrapper updateWrapper = new UpdateWrapper();
String handle = Inventory.genHandle(site, inventoryId);
updateWrapper.eq("HANDLE", handle);
updateWrapper.set("STATUS", status);
updateWrapper.set("CREATOR", user);
updateWrapper.set("UPDATE_TIME", LocalDateTime.now());
update(updateWrapper);
//记录日志
}
@Override
public IPage getInventoryDtoPageByCarrier(FrontPage page, InventoryDto inventoryDto) {
return baseMapper.getInventoryDtoPageByCarrier(page, inventoryDto);
}
@Transactional(rollbackFor = Exception.class)
@Override
public void updateQty(String user, String inventoryId, BigDecimal currentQty) {
String site = TenantContextHolder.getTenantId();
String handle = Inventory.genHandle(site, inventoryId);
update(Wrappers.lambdaUpdate(Inventory.class)
.eq(Inventory::getHandle, handle)
.set(Inventory::getQtyOnHand, currentQty)
.set(Inventory::getUpdater, user)
.set(Inventory::getUpdateTime, LocalDateTime.now()));
}
@Override
public InventoryDto getInventoryDto(String site, String inventoryId) {
InventoryDto inventoryDto = baseMapper.getInventoryDto(Inventory.genHandle(site, inventoryId));
if (inventoryDto == null) {
throw BusinessException.build("库存不存在");
}
return inventoryDto;
}
@Override
public void createInventory(String site, String user, String inventoryId, String item, String status, BigDecimal inventoryQty, String batchNo, String vendorBatchNo, LocalDateTime productionDate, LocalDateTime expireDate, String groes, String qualityInspectionStatus, String length, String width, String bismt, String isLot) {
createInventory(site, user, inventoryId, item, status, inventoryQty, batchNo, vendorBatchNo, productionDate, expireDate, groes, qualityInspectionStatus, length, width, bismt, isLot, null);
}
@Transactional(rollbackFor = Exception.class)
@Override
public void updateStatus(String user, String inventoryId, String status) {
String site = TenantContextHolder.getTenantId();
UpdateWrapper updateWrapper = new UpdateWrapper();
String handle = Inventory.genHandle(site, inventoryId);
updateWrapper.eq("HANDLE", handle);
updateWrapper.set("STATUS", status);
updateWrapper.set("CREATOR", user);
updateWrapper.set("UPDATE_TIME", LocalDateTime.now());
update(updateWrapper);
//记录日志
}
@Override
public void createInventory(String site, String user, String inventoryId, String item, String status, BigDecimal inventoryQty, String batchNo, String vendorBatchNo, LocalDateTime productionDate, LocalDateTime expireDate, String groes, String qualityInspectionStatus, String length, String width, String bismt, String isLot, String customerDemand) {
createInventory(site, user, inventoryId, item, status, inventoryQty, batchNo, vendorBatchNo, productionDate, expireDate, groes, qualityInspectionStatus, length, width, bismt, isLot, customerDemand, null, null, null, null, null, null);
}
@Transactional(rollbackFor = Exception.class)
@Override
public void updateQty(String user, String inventoryId, BigDecimal currentQty) {
String site = TenantContextHolder.getTenantId();
String handle = Inventory.genHandle(site, inventoryId);
update(Wrappers.lambdaUpdate(Inventory.class)
.eq(Inventory::getHandle, handle)
.set(Inventory::getQtyOnHand, currentQty)
.set(Inventory::getUpdater, user)
.set(Inventory::getUpdateTime, LocalDateTime.now()));
}
@Override
public void createInventory(String site, String user, String inventoryId, String item, String status, BigDecimal inventoryQty, String batchNo, String vendorBatchNo, LocalDateTime productionDate, LocalDateTime expireDate, String groes, String qualityInspectionStatus, String length, String width, String bismt, String isLot, String customerDemand, String upgradeFlag, String standardLength, String productionBase, String demandCustomers, String qmsSpecialMarking, String delayTime) {
if (getByCode(site, inventoryId) != null) {
throw BusinessException.build("库存" + inventoryId + "已存在");
}
save(buildInventory(site, user, inventoryId, item, status, inventoryQty, batchNo, vendorBatchNo, productionDate, expireDate, groes, qualityInspectionStatus, length, width, bismt, isLot, customerDemand, upgradeFlag, standardLength, productionBase, demandCustomers, qmsSpecialMarking, delayTime));
}
@Override
public void createInventory(String site, String user, String inventoryId, String item, String status, BigDecimal inventoryQty, String batchNo, String vendorBatchNo, LocalDateTime productionDate, LocalDateTime expireDate, String groes, String qualityInspectionStatus, String length, String width, String bismt, String isLot) {
createInventory(site, user, inventoryId, item, status, inventoryQty, batchNo, vendorBatchNo, productionDate, expireDate, groes, qualityInspectionStatus, length, width, bismt, isLot, null);
}
@Override
public Inventory buildInventory(String site, String user, String inventoryId, String item, String status, BigDecimal inventoryQty, String batchNo, String vendorBatchNo, LocalDateTime productionDate, LocalDateTime expireDate, String groes, String qualityInspectionStatus, String length, String width, String bismt, String isLot) {
return buildInventory(site, user, inventoryId, item, status, inventoryQty, batchNo, vendorBatchNo, productionDate, expireDate, groes, qualityInspectionStatus, length, width, bismt, isLot, null, null, null, null, null, null, null);
}
@Override
public void createInventory(String site, String user, String inventoryId, String item, String status, BigDecimal inventoryQty, String batchNo, String vendorBatchNo, LocalDateTime productionDate, LocalDateTime expireDate, String groes, String qualityInspectionStatus, String length, String width, String bismt, String isLot, String customerDemand) {
createInventory(site, user, inventoryId, item, status, inventoryQty, batchNo, vendorBatchNo, productionDate, expireDate, groes, qualityInspectionStatus, length, width, bismt, isLot, customerDemand, null, null, null, null, null, null);
}
@Override
public Inventory buildInventory(String site, String user, String inventoryId, String item, String status, BigDecimal inventoryQty, String batchNo, String vendorBatchNo, LocalDateTime productionDate, LocalDateTime expireDate, String groes, String qualityInspectionStatus, String length, String width, String bismt, String isLot, String customerDemand, String upgradeFlag, String standardLength, String productionBase, String demandCustomers, String qmsSpecialMarking, String delayTime) {
Inventory inventory = new Inventory();
String handle = Inventory.genHandle(site, inventoryId);
inventory.setHandle(handle);
inventory.setSite(site);
inventory.setInventoryId(inventoryId);
inventory.setStatus(status);
Item selectCurrent = itemService.selectCurrent(site, item);
inventory.setItemBo(selectCurrent.getHandle());
inventory.setUnitOfMeasure(selectCurrent.getUnitOfMeasure());
inventory.setBatchNo(batchNo);
inventory.setVendorBatchNo(vendorBatchNo);
inventory.setOriginalQty(inventoryQty);
inventory.setQtyOnHand(inventoryQty);
inventory.setValid("Y");
inventory.setBismt(bismt);
inventory.setProductionDate(productionDate);
inventory.setExpireDate(expireDate);
LocalDateTime now = LocalDateTime.now();
inventory.setCreateTime(now);
inventory.setUpdateTime(now);
inventory.setCreator(user);
inventory.setUpdater(user);
inventory.setGroes(groes);
inventory.setQualityInspectionStatus(qualityInspectionStatus);
inventory.setLength(length);
inventory.setWidth(width);
inventory.setIsLot(isLot);
inventory.setCustomerDemand(customerDemand);
inventory.setUpgradeFlag(upgradeFlag);
inventory.setStandardLength(standardLength);
inventory.setProductionBase(productionBase);
inventory.setDemandCustomers(demandCustomers);
inventory.setQmsSpecialMarking(qmsSpecialMarking);
inventory.setDelayTime(delayTime);
return inventory;
}
@Override
public void createInventory(String site, String user, String inventoryId, String item, String status, BigDecimal inventoryQty, String batchNo, String vendorBatchNo, LocalDateTime productionDate, LocalDateTime expireDate, String groes, String qualityInspectionStatus, String length, String width, String bismt, String isLot, String customerDemand, String upgradeFlag, String standardLength, String productionBase, String demandCustomers, String qmsSpecialMarking, String delayTime) {
if (getByCode(site, inventoryId) != null) {
throw BusinessException.build("库存" + inventoryId + "已存在");
}
save(buildInventory(site, user, inventoryId, item, status, inventoryQty, batchNo, vendorBatchNo, productionDate, expireDate, groes, qualityInspectionStatus, length, width, bismt, isLot, customerDemand, upgradeFlag, standardLength, productionBase, demandCustomers, qmsSpecialMarking, delayTime));
}
@Override
public List<String> splitInventory(String site, String user, String parentInventoryId, BigDecimal splitQty, int splitNum, String documentNo, String documentType, String storageBinBo) {
return splitInventory(site, user, parentInventoryId, splitQty, splitNum, documentNo, documentType, storageBinBo, null);
}
@Override
public Inventory buildInventory(String site, String user, String inventoryId, String item, String status, BigDecimal inventoryQty, String batchNo, String vendorBatchNo, LocalDateTime productionDate, LocalDateTime expireDate, String groes, String qualityInspectionStatus, String length, String width, String bismt, String isLot) {
return buildInventory(site, user, inventoryId, item, status, inventoryQty, batchNo, vendorBatchNo, productionDate, expireDate, groes, qualityInspectionStatus, length, width, bismt, isLot, null, null, null, null, null, null, null);
}
@Override
public List<String> splitInventory(String site, String user, String parentInventoryId, BigDecimal splitQty, int splitNum, String documentNo, String documentType, String storageBinBo, List<String> newInventoryIdList) {
Inventory parentInventory = getByCode(site, parentInventoryId);
if (parentInventory == null) {
throw BusinessException.build("库存不存在");
} else {
//校验货格
@Override
public Inventory buildInventory(String site, String user, String inventoryId, String item, String status, BigDecimal inventoryQty, String batchNo, String vendorBatchNo, LocalDateTime productionDate, LocalDateTime expireDate, String groes, String qualityInspectionStatus, String length, String width, String bismt, String isLot, String customerDemand, String upgradeFlag, String standardLength, String productionBase, String demandCustomers, String qmsSpecialMarking, String delayTime) {
Inventory inventory = new Inventory();
String handle = Inventory.genHandle(site, inventoryId);
inventory.setHandle(handle);
inventory.setSite(site);
inventory.setInventoryId(inventoryId);
inventory.setStatus(status);
Item selectCurrent = itemService.selectCurrent(site, item);
inventory.setItemBo(selectCurrent.getHandle());
inventory.setUnitOfMeasure(selectCurrent.getUnitOfMeasure());
inventory.setBatchNo(batchNo);
inventory.setVendorBatchNo(vendorBatchNo);
inventory.setOriginalQty(inventoryQty);
inventory.setQtyOnHand(inventoryQty);
inventory.setValid("Y");
inventory.setBismt(bismt);
inventory.setProductionDate(productionDate);
inventory.setExpireDate(expireDate);
LocalDateTime now = LocalDateTime.now();
inventory.setCreateTime(now);
inventory.setUpdateTime(now);
inventory.setCreator(user);
inventory.setUpdater(user);
inventory.setGroes(groes);
inventory.setQualityInspectionStatus(qualityInspectionStatus);
inventory.setLength(length);
inventory.setWidth(width);
inventory.setIsLot(isLot);
inventory.setCustomerDemand(customerDemand);
inventory.setUpgradeFlag(upgradeFlag);
inventory.setStandardLength(standardLength);
inventory.setProductionBase(productionBase);
inventory.setDemandCustomers(demandCustomers);
inventory.setQmsSpecialMarking(qmsSpecialMarking);
inventory.setDelayTime(delayTime);
return inventory;
}
@Override
public List<String> splitInventory(String site, String user, String parentInventoryId, BigDecimal splitQty, int splitNum, String documentNo, String documentType, String storageBinBo) {
return splitInventory(site, user, parentInventoryId, splitQty, splitNum, documentNo, documentType, storageBinBo, null);
}
@Override
public List<String> splitInventory(String site, String user, String parentInventoryId, BigDecimal splitQty, int splitNum, String documentNo, String documentType, String storageBinBo, List<String> newInventoryIdList) {
Inventory parentInventory = getByCode(site, parentInventoryId);
if (parentInventory == null) {
throw BusinessException.build("库存不存在");
} else {
//校验货格
/*LambdaQueryWrapper<StorageBinBindInventory> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(StorageBinBindInventory::getInventoryBo, parentInventory.getHandle());
lambdaQueryWrapper.eq(StorageBinBindInventory::getStatus, "Y");
List<StorageBinBindInventory> bindInventoryList = storageBinBindInventoryService.list(lambdaQueryWrapper);*/
String parentStorageBinBo = parentInventory.getWmsStorageBinBo();
if (StrUtil.isBlank(parentStorageBinBo)) {
throw BusinessException.build("条码" + parentInventory.getInventoryId() + "未绑定货格");
} else {
//校验数量
BigDecimal qty = splitQty.multiply(BigDecimal.valueOf(splitNum));
if (parentInventory.getQtyOnHand().compareTo(qty) < 0) {
throw BusinessException.build("库存" + parentInventoryId + "数量" + parentInventory.getQtyOnHand().stripTrailingZeros().toPlainString() + "不满足拆批数量" + qty.stripTrailingZeros().toPlainString());
} else {
//生成新条码
if (CollectionUtil.isEmpty(newInventoryIdList)) {
newInventoryIdList = generatorDocumentNo("RAW_MATERIAL_ID", null,splitNum);
}
//创建库存
List<Inventory> newInventoryList = new ArrayList<>();
for (String inventoryId : newInventoryIdList) {
Inventory inventory = new Inventory();
BeanUtils.copyProperties(parentInventory, inventory);
inventory.setHandle(Inventory.genHandle(site, inventoryId));
inventory.setInventoryId(inventoryId);
inventory.setCreator(user);
inventory.setQtyOnHand(splitQty);
inventory.setOriginalQty(splitQty);
inventory.setIsLot(null);
//inventory.setCreateTime(LocalDateTime.now());
inventory.setParentInventoryBo(parentInventory.getHandle());
newInventoryList.add(inventory);
}
saveBatch(newInventoryList);
//货格绑定/库存日志
storageBinBo = StrUtil.blankToDefault(storageBinBo, parentStorageBinBo);
String parentStorageBinBo = parentInventory.getWmsStorageBinBo();
if (StrUtil.isBlank(parentStorageBinBo)) {
throw BusinessException.build("条码" + parentInventory.getInventoryId() + "未绑定货格");
} else {
//校验数量
BigDecimal qty = splitQty.multiply(BigDecimal.valueOf(splitNum));
if (parentInventory.getQtyOnHand().compareTo(qty) < 0) {
throw BusinessException.build("库存" + parentInventoryId + "数量" + parentInventory.getQtyOnHand().stripTrailingZeros().toPlainString() + "不满足拆批数量" + qty.stripTrailingZeros().toPlainString());
} else {
//生成新条码
if (CollectionUtil.isEmpty(newInventoryIdList)) {
newInventoryIdList = generatorDocumentNo("RAW_MATERIAL_ID", null, splitNum);
}
//创建库存
List<Inventory> newInventoryList = new ArrayList<>();
for (String inventoryId : newInventoryIdList) {
Inventory inventory = new Inventory();
BeanUtils.copyProperties(parentInventory, inventory);
inventory.setHandle(Inventory.genHandle(site, inventoryId));
inventory.setInventoryId(inventoryId);
inventory.setCreator(user);
inventory.setQtyOnHand(splitQty);
inventory.setOriginalQty(splitQty);
inventory.setIsLot(null);
//inventory.setCreateTime(LocalDateTime.now());
inventory.setParentInventoryBo(parentInventory.getHandle());
newInventoryList.add(inventory);
}
saveBatch(newInventoryList);
//货格绑定/库存日志
storageBinBo = StrUtil.blankToDefault(storageBinBo, parentStorageBinBo);
for (String inventoryId : newInventoryIdList) {
lambdaUpdate().eq(Inventory::getHandle, Inventory.genHandle(site, inventoryId))
.set(Inventory::getWmsStorageBinBo, storageBinBo)
.set(Inventory::getUpdateTime, LocalDateTime.now())
.set(Inventory::getUpdater, user).update();
for (String inventoryId : newInventoryIdList) {
lambdaUpdate().eq(Inventory::getHandle, Inventory.genHandle(site, inventoryId))
.set(Inventory::getWmsStorageBinBo, storageBinBo)
.set(Inventory::getUpdateTime, LocalDateTime.now())
.set(Inventory::getUpdater, user).update();
inventoryLogService.saveLog(user, inventoryId, documentNo, null, StrUtil.isBlank(documentType) ? Constant.CHANGE_TYPE_SPLIT : documentType,
null, null, storageBinBo);
}
//更新父库存
BigDecimal subtract = parentInventory.getQtyOnHand().subtract(qty);
updateQty(user, parentInventoryId, subtract);
//数量为0解绑父库存
boolean parentIsEmpty = BigDecimal.ZERO.compareTo(subtract) == 0;
if (parentIsEmpty) {
lambdaUpdate().eq(Inventory::getHandle, Inventory.genHandle(site, parentInventoryId))
.set(Inventory::getWmsStorageBinBo, null)
.set(Inventory::getUpdateTime, LocalDateTime.now())
.set(Inventory::getUpdater, user).update();
}
//父库存日志
inventoryLogService.saveLog(user, parentInventoryId, documentNo, parentInventory.getStatus(), Constant.CHANGE_TYPE_SPLIT,
parentStorageBinBo, parentInventory.getQtyOnHand(), parentIsEmpty ? null : parentStorageBinBo);
//返回新库存ID
return newInventoryIdList;
}
}
}
}
inventoryLogService.saveLog(user, inventoryId, documentNo, null, StrUtil.isBlank(documentType) ? Constant.CHANGE_TYPE_SPLIT : documentType,
null, null, storageBinBo);
}
//更新父库存
BigDecimal subtract = parentInventory.getQtyOnHand().subtract(qty);
updateQty(user, parentInventoryId, subtract);
//数量为0解绑父库存
boolean parentIsEmpty = BigDecimal.ZERO.compareTo(subtract) == 0;
if (parentIsEmpty) {
lambdaUpdate().eq(Inventory::getHandle, Inventory.genHandle(site, parentInventoryId))
.set(Inventory::getWmsStorageBinBo, null)
.set(Inventory::getUpdateTime, LocalDateTime.now())
.set(Inventory::getUpdater, user).update();
}
//父库存日志
inventoryLogService.saveLog(user, parentInventoryId, documentNo, parentInventory.getStatus(), Constant.CHANGE_TYPE_SPLIT,
parentStorageBinBo, parentInventory.getQtyOnHand(), parentIsEmpty ? null : parentStorageBinBo);
//返回新库存ID
return newInventoryIdList;
}
}
}
}
private List<String> generatorDocumentNo(String numberType, Map map,Integer num) {
private List<String> generatorDocumentNo(String numberType, Map map, Integer num) {
//根据编号规则生成箱号
GenerateNextNumberRequest generateNextNumberRequest = new GenerateNextNumberRequest();
generateNextNumberRequest.setSite(TenantContextHolder.getTenantId());
@ -326,91 +363,91 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
return nextNumberResponse.getIds();
}
@Override
public String mergeInventory(String site, String user, List<String> inventoryIdList) {
List<String> inventoryBoList = inventoryIdList.stream().map(o -> Inventory.genHandle(site, o)).collect(Collectors.toList());
//查询并校验库存
List<Inventory> inventoryList = listByIds(inventoryBoList);
if (CollectionUtil.isEmpty(inventoryList) || inventoryList.size() != inventoryIdList.size()) {
inventoryIdList.removeAll(inventoryList.stream().map(Inventory::getInventoryId).collect(Collectors.toList()));
throw BusinessException.build("库存[" + String.join(",", inventoryIdList) + "]不存在");
} else {
//查询并校验货格
@Override
public String mergeInventory(String site, String user, List<String> inventoryIdList) {
List<String> inventoryBoList = inventoryIdList.stream().map(o -> Inventory.genHandle(site, o)).collect(Collectors.toList());
//查询并校验库存
List<Inventory> inventoryList = listByIds(inventoryBoList);
if (CollectionUtil.isEmpty(inventoryList) || inventoryList.size() != inventoryIdList.size()) {
inventoryIdList.removeAll(inventoryList.stream().map(Inventory::getInventoryId).collect(Collectors.toList()));
throw BusinessException.build("库存[" + String.join(",", inventoryIdList) + "]不存在");
} else {
//查询并校验货格
/*LambdaQueryWrapper<StorageBinBindInventory> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(StorageBinBindInventory::getInventoryBo, inventoryBoList);
lambdaQueryWrapper.eq(StorageBinBindInventory::getStatus, "Y");
List<StorageBinBindInventory> bindInventoryList = storageBinBindInventoryService.list(lambdaQueryWrapper);*/
List<Inventory> notBindList = lambdaQuery().in(Inventory::getHandle, inventoryBoList).isNull(Inventory::getWmsStorageBinBo).select(Inventory::getInventoryId).list();
if (CollectionUtil.isNotEmpty(notBindList) ) {
throw BusinessException.build("库存[" + notBindList.stream().map(Inventory::getInventoryId).collect(Collectors.joining(","))+ "]未绑定货格");
} else {
//扣除父库存数量并解绑
BigDecimal qty = BigDecimal.ZERO;
List<Inventory> notBindList = lambdaQuery().in(Inventory::getHandle, inventoryBoList).isNull(Inventory::getWmsStorageBinBo).select(Inventory::getInventoryId).list();
if (CollectionUtil.isNotEmpty(notBindList)) {
throw BusinessException.build("库存[" + notBindList.stream().map(Inventory::getInventoryId).collect(Collectors.joining(",")) + "]未绑定货格");
} else {
//扣除父库存数量并解绑
BigDecimal qty = BigDecimal.ZERO;
update(Wrappers.lambdaUpdate(Inventory.class).in(Inventory::getHandle, inventoryBoList)
.set(Inventory::getWmsStorageBinBo, null)
.set(Inventory::getQtyOnHand, BigDecimal.ZERO)
.set(Inventory::getUpdater, user)
.set(Inventory::getUpdateTime, LocalDateTime.now()));
for (Inventory inventory : inventoryList) {
String inventoryId = inventory.getInventoryId();
BigDecimal qtyOnHand = inventory.getQtyOnHand();
qty = qty.add(qtyOnHand);
inventoryLogService.saveLog(user, inventoryId, null, inventory.getStatus(), Constant.CHANGE_TYPE_MERGE,
inventory.getWmsStorageBinBo(), qtyOnHand, null);
}
//创建新库存并绑定
String inventoryId = generatorDocumentNo("RAW_MATERIAL_ID", null,1).get(0);
Inventory inventory = new Inventory();
BeanUtils.copyProperties(inventoryList.get(0), inventory);
inventory.setHandle(Inventory.genHandle(site, inventoryId));
inventory.setInventoryId(inventoryId);
inventory.setCreator(user);
inventory.setQtyOnHand(qty);
inventory.setOriginalQty(qty);
inventory.setIsLot(null);
inventory.setCreateTime(LocalDateTime.now());
inventory.setWmsStorageBinBo(inventoryList.get(0).getWmsStorageBinBo());
save(inventory);
inventoryLogService.saveLog(user, inventoryId, null, null, Constant.CHANGE_TYPE_MERGE,
null, null, inventoryList.get(0).getWmsStorageBinBo());
return inventoryId;
}
}
}
update(Wrappers.lambdaUpdate(Inventory.class).in(Inventory::getHandle, inventoryBoList)
.set(Inventory::getWmsStorageBinBo, null)
.set(Inventory::getQtyOnHand, BigDecimal.ZERO)
.set(Inventory::getUpdater, user)
.set(Inventory::getUpdateTime, LocalDateTime.now()));
for (Inventory inventory : inventoryList) {
String inventoryId = inventory.getInventoryId();
BigDecimal qtyOnHand = inventory.getQtyOnHand();
qty = qty.add(qtyOnHand);
inventoryLogService.saveLog(user, inventoryId, null, inventory.getStatus(), Constant.CHANGE_TYPE_MERGE,
inventory.getWmsStorageBinBo(), qtyOnHand, null);
}
//创建新库存并绑定
String inventoryId = generatorDocumentNo("RAW_MATERIAL_ID", null, 1).get(0);
Inventory inventory = new Inventory();
BeanUtils.copyProperties(inventoryList.get(0), inventory);
inventory.setHandle(Inventory.genHandle(site, inventoryId));
inventory.setInventoryId(inventoryId);
inventory.setCreator(user);
inventory.setQtyOnHand(qty);
inventory.setOriginalQty(qty);
inventory.setIsLot(null);
inventory.setCreateTime(LocalDateTime.now());
inventory.setWmsStorageBinBo(inventoryList.get(0).getWmsStorageBinBo());
save(inventory);
inventoryLogService.saveLog(user, inventoryId, null, null, Constant.CHANGE_TYPE_MERGE,
null, null, inventoryList.get(0).getWmsStorageBinBo());
return inventoryId;
}
}
}
@Override
public IPage fetchItemList(Page page, String item) {
String site = TenantContextHolder.getTenantId();
return baseMapper.getItemList(page, site, item);
}
@Override
public IPage fetchItemList(Page page, String item) {
String site = TenantContextHolder.getTenantId();
return baseMapper.getItemList(page, site, item);
}
@Override
public IPage fetchItemGroesList(Page page, String groes) {
String site = TenantContextHolder.getTenantId();
return baseMapper.getItemGroesList(page, site, groes);
}
@Override
public IPage fetchItemGroesList(Page page, String groes) {
String site = TenantContextHolder.getTenantId();
return baseMapper.getItemGroesList(page, site, groes);
}
@Override
public InventoryDto selectForSplit(String site, String inventoryId) {
InventoryDto inventoryDto = baseMapper.selectWithStorageBin(Inventory.genHandle(site, inventoryId));
String itemType = Optional.ofNullable(inventoryDto).orElseThrow(() -> BusinessException.build("库存不存在或未绑定货格")).getItemType();
if (StrUtil.isBlank(itemType) || !StrUtil.equalsAny(itemType, KeyWordConstant.ITEM_MATERIAL_TYPE_ROH, KeyWordConstant.ITEM_MATERIAL_TYPE_VERP)) {
throw BusinessException.build("非原材料/包材不允许拆合批");
} else if (BigDecimal.ZERO.compareTo(inventoryDto.getQtyOnHand()) == 0) {
throw BusinessException.build("库存为0不允许拆合批");
} else {
long count = inventoryGroupService.count(Wrappers.lambdaQuery(InventoryGroup.class).eq(InventoryGroup::getInventoryBo, Inventory.genHandle(site, inventoryId)));
if (count > 0) {
throw BusinessException.build("分组库存不允许拆合批");
} else {
return inventoryDto;
}
}
}
@Override
public InventoryDto selectForSplit(String site, String inventoryId) {
InventoryDto inventoryDto = baseMapper.selectWithStorageBin(Inventory.genHandle(site, inventoryId));
String itemType = Optional.ofNullable(inventoryDto).orElseThrow(() -> BusinessException.build("库存不存在或未绑定货格")).getItemType();
if (StrUtil.isBlank(itemType) || !StrUtil.equalsAny(itemType, KeyWordConstant.ITEM_MATERIAL_TYPE_ROH, KeyWordConstant.ITEM_MATERIAL_TYPE_VERP)) {
throw BusinessException.build("非原材料/包材不允许拆合批");
} else if (BigDecimal.ZERO.compareTo(inventoryDto.getQtyOnHand()) == 0) {
throw BusinessException.build("库存为0不允许拆合批");
} else {
long count = inventoryGroupService.count(Wrappers.lambdaQuery(InventoryGroup.class).eq(InventoryGroup::getInventoryBo, Inventory.genHandle(site, inventoryId)));
if (count > 0) {
throw BusinessException.build("分组库存不允许拆合批");
} else {
return inventoryDto;
}
}
}
@Override
public InventoryDto selectForStocktaking(String site, String inventoryId) {
@Override
public InventoryDto selectForStocktaking(String site, String inventoryId) {
/*String inventoryBo = Inventory.genHandle(site, inventoryId);
InventoryDto inventory = Optional.ofNullable(getInventoryDto(site, inventoryId))
.orElseThrow(() -> BusinessException.build("库存条码不存在"));
@ -438,11 +475,11 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
case Constant.INVENTORY_STSTUS_1005:
throw BusinessException.build("冻结库存不允许调整库存");
}*/
return null;
}
return null;
}
@Override
public void inventoryStocktaking(String site, String user, List<Inventory> inventoryList) {
@Override
public void inventoryStocktaking(String site, String user, List<Inventory> inventoryList) {
// if (CollectionUtil.isEmpty(inventoryList)) {
// throw BusinessException.build("没有待盘盈盘亏数据");
// } else {
@ -521,15 +558,15 @@ public class ZWmsInventoryServiceImpl extends ServiceImpl<ZWmsInventoryMapper, I
// erpInterfanceService.wmsCallErp(InterfaceCodeConstant.MM_001, erpMm006RequestBodyDTO, null);
// }
// }
}
}
@Override
public List<ScanCodeDTO> selectInvByCode(String site, String user, String code) {
return baseMapper.selectInvByCode(Inventory.genHandle(site, code), Carrier.genHandle(site, code));
}
@Override
public List<ScanCodeDTO> selectInvByCode(String site, String user, String code) {
return baseMapper.selectInvByCode(Inventory.genHandle(site, code), Carrier.genHandle(site, code));
}
@Override
public List<ScanCodeDTO> selectTrayInvByCode(String site, String user, String code) {
return baseMapper.selectTrayInvByCode(Inventory.genHandle(site, code), Carrier.genHandle(site, code));
}
@Override
public List<ScanCodeDTO> selectTrayInvByCode(String site, String user, String code) {
return baseMapper.selectTrayInvByCode(Inventory.genHandle(site, code), Carrier.genHandle(site, code));
}
}

View File

@ -70,9 +70,9 @@
<select id="getInventoryDto" resultType="com.foreverwin.mom.wms.dto.InventoryDto">
select wi.handle,wi.`INVENTORY_ID`,wi.ORIGINAL_QTY,wi.ITEM_BO, wi.`QTY_ON_HAND`, i.`UNIT_OF_MEASURE` , i.`ITEM`, i.`DESCRIPTION`
, wi.`STATUS`
, wi.`STATUS`,wi.QMS_SPECIAL_MARKING
from wms_inventory wi
join item i on i.`HANDLE` = wi.`ITEM_BO`
left join wip.item i on i.`HANDLE` = wi.`ITEM_BO`
where wi.`HANDLE`=#{handle}
</select>