|
|
|
|
@ -9,7 +9,7 @@ import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
|
|
import cn.iocoder.yudao.framework.ratelimiter.core.annotation.RateLimiter;
|
|
|
|
|
import cn.iocoder.yudao.module.common.controller.admin.mold.vo.MoldRespVO;
|
|
|
|
|
import cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldBrandDO;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProductRespVO;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutPageReqVO;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutRespVO;
|
|
|
|
|
@ -20,6 +20,7 @@ import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockInItemDO;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutDO;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutItemDO;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.service.mold.MoldBrandService;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.service.mold.MoldService;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService;
|
|
|
|
|
@ -48,6 +49,7 @@ import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMultiMap;
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
|
|
|
|
|
|
|
|
@ -66,6 +68,8 @@ public class ErpStockOutController {
|
|
|
|
|
@Resource
|
|
|
|
|
private ErpCustomerService customerService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private MoldBrandService moldBrandService;
|
|
|
|
|
@Resource
|
|
|
|
|
private MoldService moldService;
|
|
|
|
|
|
|
|
|
|
@ -98,6 +102,17 @@ public class ErpStockOutController {
|
|
|
|
|
return success(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PutMapping("/update-mold-status")
|
|
|
|
|
@Operation(summary = "更新模具出库单的状态")
|
|
|
|
|
@PreAuthorize("@ss.hasPermission('erp:stock-out:update-status')")
|
|
|
|
|
@RateLimiter(count = 1, timeUnit = TimeUnit.SECONDS)
|
|
|
|
|
public CommonResult<Boolean> updateMoldStatus(@RequestParam("id") Long id,
|
|
|
|
|
@RequestParam("status") Integer status) {
|
|
|
|
|
stockOutService.updateMoldStatus(id, status);
|
|
|
|
|
return success(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@DeleteMapping("/delete")
|
|
|
|
|
@Operation(summary = "删除其它出库单")
|
|
|
|
|
@Parameter(name = "ids", description = "编号数组", required = true)
|
|
|
|
|
@ -118,15 +133,26 @@ public class ErpStockOutController {
|
|
|
|
|
}
|
|
|
|
|
List<ErpStockOutItemDO> stockOutItemList = stockOutService.getStockOutItemListByOutId(id);
|
|
|
|
|
if (Objects.equals(stockOut.getOutType(), "模具出库")) {
|
|
|
|
|
Map<Long, MoldRespVO> moldMap = moldService.getMoldVOMap(
|
|
|
|
|
convertSet(stockOutItemList, ErpStockOutItemDO::getProductId));
|
|
|
|
|
return success(BeanUtils.toBean(stockOut, ErpStockOutRespVO.class, stockOutVO ->
|
|
|
|
|
stockOutVO.setItems(BeanUtils.toBean(stockOutItemList, ErpStockOutRespVO.Item.class, item -> {
|
|
|
|
|
ErpStockDO stock = stockService.getStock(item.getProductId(), item.getWarehouseId());
|
|
|
|
|
item.setStockCount(stock != null ? stock.getCount() : BigDecimal.ZERO);
|
|
|
|
|
MapUtils.findAndThen(moldMap, item.getProductId(), mold -> item.setProductName(mold.getName())
|
|
|
|
|
.setProductBarCode(mold.getCode()).setProductUnitName(mold.getUnitName()));
|
|
|
|
|
}))));
|
|
|
|
|
Map<Long, MoldBrandDO> moldMap = moldBrandService.getMoldVOMap(
|
|
|
|
|
convertSet(stockOutItemList, ErpStockOutItemDO::getMoldSetId));
|
|
|
|
|
Map<Long, List<cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldDO>> moldListMap = moldService.getMoldListMapByBrandIds(
|
|
|
|
|
convertSet(stockOutItemList, ErpStockOutItemDO::getMoldSetId));
|
|
|
|
|
return success(BeanUtils.toBean(stockOut, ErpStockOutRespVO.class, stockOutVO -> {
|
|
|
|
|
stockOutVO.setItems(convertList(stockOutItemList, source -> {
|
|
|
|
|
ErpStockOutRespVO.Item item = BeanUtils.toBean(source, ErpStockOutRespVO.Item.class);
|
|
|
|
|
item.setMoldSetId(source.getMoldSetId());
|
|
|
|
|
item.setMoldSetName(source.getMoldSetName());
|
|
|
|
|
ErpStockDO stock = stockService.getStock(source.getMoldSetId(), source.getWarehouseId());
|
|
|
|
|
item.setStockCount(stock != null ? stock.getCount() : BigDecimal.ZERO);
|
|
|
|
|
item.setMoldList(moldListMap.getOrDefault(source.getMoldSetId(), new ArrayList<>()));
|
|
|
|
|
MapUtils.findAndThen(moldMap, source.getMoldSetId(), mold -> item.setMoldSetName(mold.getName())
|
|
|
|
|
.setProductName(mold.getName())
|
|
|
|
|
.setProductBarCode(mold.getCode()));
|
|
|
|
|
return item;
|
|
|
|
|
}));
|
|
|
|
|
stockOutVO.setMoldSetNames(CollUtil.join(stockOutVO.getItems(), "?", ErpStockOutRespVO.Item::getMoldSetName));
|
|
|
|
|
stockOutVO.setProductNames(stockOutVO.getMoldSetNames());
|
|
|
|
|
}));
|
|
|
|
|
} else {
|
|
|
|
|
Map<Long, ErpProductRespVO> productMap = productService.getProductVOMap(
|
|
|
|
|
convertSet(stockOutItemList, ErpStockOutItemDO::getProductId));
|
|
|
|
|
@ -172,40 +198,44 @@ public class ErpStockOutController {
|
|
|
|
|
if (CollUtil.isEmpty(pageResult.getList())) {
|
|
|
|
|
return PageResult.empty(pageResult.getTotal());
|
|
|
|
|
}
|
|
|
|
|
// 1.1 出库项
|
|
|
|
|
List<ErpStockOutItemDO> stockOutItemList = stockOutService.getStockOutItemListByOutIds(
|
|
|
|
|
convertSet(pageResult.getList(), ErpStockOutDO::getId));
|
|
|
|
|
Map<Long, List<ErpStockOutItemDO>> stockOutItemMap = convertMultiMap(stockOutItemList, ErpStockOutItemDO::getOutId);
|
|
|
|
|
// 1.2 产品信息
|
|
|
|
|
Map<Long, ErpProductRespVO> productMap = productService.getProductVOMap(
|
|
|
|
|
convertSet(stockOutItemList, ErpStockOutItemDO::getProductId));
|
|
|
|
|
// 1.3 客户信息
|
|
|
|
|
Map<Long, ErpCustomerDO> customerMap = customerService.getCustomerMap(
|
|
|
|
|
convertSet(pageResult.getList(), ErpStockOutDO::getCustomerId));
|
|
|
|
|
// 1.5 管理员信息
|
|
|
|
|
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
|
|
|
|
|
convertSet(pageResult.getList(), stockOut -> Long.parseLong(stockOut.getCreator())));
|
|
|
|
|
// 1.6 领料员信息
|
|
|
|
|
Map<Long, AdminUserRespDTO> responserMap = adminUserApi.getUserMap(
|
|
|
|
|
convertSet(pageResult.getList(), ErpStockOutDO::getResponserId));
|
|
|
|
|
// 1.7 模具信息
|
|
|
|
|
Map<Long, MoldRespVO> moldMap = moldService.getMoldVOMap(
|
|
|
|
|
convertSet(stockOutItemList, ErpStockOutItemDO::getProductId));
|
|
|
|
|
Map<Long, MoldBrandDO> moldMap = moldBrandService.getMoldVOMap(
|
|
|
|
|
convertSet(stockOutItemList, ErpStockOutItemDO::getMoldSetId));
|
|
|
|
|
Map<Long, List<cn.iocoder.yudao.module.common.dal.dataobject.mold.MoldDO>> moldListMap = moldService.getMoldListMapByBrandIds(
|
|
|
|
|
convertSet(stockOutItemList, ErpStockOutItemDO::getMoldSetId));
|
|
|
|
|
|
|
|
|
|
// 2. 开始拼接
|
|
|
|
|
return BeanUtils.toBean(pageResult, ErpStockOutRespVO.class, stockOut -> {
|
|
|
|
|
if (Objects.equals(stockOut.getOutType(), "模具出库")) {
|
|
|
|
|
stockOut.setItems(BeanUtils.toBean(stockOutItemMap.get(stockOut.getId()), ErpStockOutRespVO.Item.class,
|
|
|
|
|
item -> MapUtils.findAndThen(moldMap, item.getProductId(), mold -> item.setProductName(mold.getName())
|
|
|
|
|
.setProductBarCode(mold.getCode()).setProductUnitName(mold.getUnitName()))));
|
|
|
|
|
stockOut.setProductNames(CollUtil.join(stockOut.getItems(), ",", ErpStockOutRespVO.Item::getProductName));
|
|
|
|
|
List<ErpStockOutItemDO> itemDOS = stockOutItemMap.get(stockOut.getId());
|
|
|
|
|
stockOut.setItems(convertList(itemDOS, source -> {
|
|
|
|
|
ErpStockOutRespVO.Item item = BeanUtils.toBean(source, ErpStockOutRespVO.Item.class);
|
|
|
|
|
item.setMoldSetId(source.getMoldSetId());
|
|
|
|
|
item.setMoldSetName(source.getMoldSetName());
|
|
|
|
|
item.setMoldList(moldListMap.getOrDefault(source.getMoldSetId(), new ArrayList<>()));
|
|
|
|
|
MapUtils.findAndThen(moldMap, source.getMoldSetId(), mold -> item.setMoldSetName(mold.getName())
|
|
|
|
|
.setProductName(mold.getName())
|
|
|
|
|
.setProductBarCode(mold.getCode()));
|
|
|
|
|
return item;
|
|
|
|
|
}));
|
|
|
|
|
stockOut.setMoldSetNames(CollUtil.join(stockOut.getItems(), ",", ErpStockOutRespVO.Item::getMoldSetName));
|
|
|
|
|
stockOut.setProductNames(stockOut.getMoldSetNames());
|
|
|
|
|
} else {
|
|
|
|
|
stockOut.setItems(BeanUtils.toBean(stockOutItemMap.get(stockOut.getId()), ErpStockOutRespVO.Item.class,
|
|
|
|
|
item -> MapUtils.findAndThen(productMap, item.getProductId(), product -> item.setProductName(product.getName())
|
|
|
|
|
.setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName()))));
|
|
|
|
|
stockOut.setProductNames(CollUtil.join(stockOut.getItems(), ",", ErpStockOutRespVO.Item::getProductName));
|
|
|
|
|
stockOut.setProductNames(CollUtil.join(stockOut.getItems(), ",", ErpStockOutRespVO.Item::getProductName));
|
|
|
|
|
}
|
|
|
|
|
MapUtils.findAndThen(customerMap, stockOut.getCustomerId(), supplier -> stockOut.setCustomerName(supplier.getName()));
|
|
|
|
|
MapUtils.findAndThen(customerMap, stockOut.getCustomerId(), customer -> stockOut.setCustomerName(customer.getName()));
|
|
|
|
|
MapUtils.findAndThen(userMap, Long.parseLong(stockOut.getCreator()), user -> stockOut.setCreatorName(user.getNickname()));
|
|
|
|
|
MapUtils.findAndThen(responserMap, stockOut.getResponserId(), user -> stockOut.setResponserName(user.getNickname()));
|
|
|
|
|
});
|
|
|
|
|
|