refactor(erp): 更新其它出库单接口和数据结构
- 移除了不必要的导入语句- 添加了 Collections 的导入,用于处理客户信息 - 修改了客户信息的获取方式,从 ErpCustomerDO 改为 AdminUserResp
This commit is contained in:
parent
7c32e1f429
commit
f477c366c4
@ -11,7 +11,6 @@ import cn.iocoder.yudao.module.erp.controller.admin.product.vo.product.ErpProduc
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutPageReqVO;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutRespVO;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.out.ErpStockOutSaveReqVO;
|
||||
import cn.iocoder.yudao.module.erp.dal.dataobject.sale.ErpCustomerDO;
|
||||
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockDO;
|
||||
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutDO;
|
||||
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockOutItemDO;
|
||||
@ -33,6 +32,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -77,7 +77,7 @@ public class ErpStockOutController {
|
||||
@Operation(summary = "更新其它出库单的状态")
|
||||
@PreAuthorize("@ss.hasPermission('erp:stock-out:update-status')")
|
||||
public CommonResult<Boolean> updateStockOutStatus(@RequestParam("id") Long id,
|
||||
@RequestParam("status") Integer status) {
|
||||
@RequestParam("status") Integer status) {
|
||||
stockOutService.updateStockOutStatus(id, status);
|
||||
return success(true);
|
||||
}
|
||||
@ -103,13 +103,16 @@ public class ErpStockOutController {
|
||||
List<ErpStockOutItemDO> stockOutItemList = stockOutService.getStockOutItemListByOutId(id);
|
||||
Map<Long, ErpProductRespVO> productMap = productService.getProductVOMap(
|
||||
convertSet(stockOutItemList, ErpStockOutItemDO::getProductId));
|
||||
|
||||
Map<Long, AdminUserRespDTO> customerMap = adminUserApi.getUserMap(Collections.singletonList(stockOut.getCustomerId()));
|
||||
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(productMap, item.getProductId(), product -> item.setProductName(product.getName())
|
||||
.setProductBarCode(product.getBarCode()).setProductUnitName(product.getUnitName()));
|
||||
}))));
|
||||
})).setCustomerName(customerMap.get(stockOut.getCustomerId()) != null ? customerMap.get(stockOut.getCustomerId()).getNickname() : null)
|
||||
));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ -125,7 +128,7 @@ public class ErpStockOutController {
|
||||
@PreAuthorize("@ss.hasPermission('erp:stock-out:export')")
|
||||
|
||||
public void exportStockOutExcel(@Valid ErpStockOutPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<ErpStockOutRespVO> list = buildStockOutVOPageResult(stockOutService.getStockOutPage(pageReqVO)).getList();
|
||||
// 导出 Excel
|
||||
@ -144,7 +147,7 @@ public class ErpStockOutController {
|
||||
Map<Long, ErpProductRespVO> productMap = productService.getProductVOMap(
|
||||
convertSet(stockOutItemList, ErpStockOutItemDO::getProductId));
|
||||
// 1.3 客户信息
|
||||
Map<Long, ErpCustomerDO> customerMap = customerService.getCustomerMap(
|
||||
Map<Long, AdminUserRespDTO> customerMap = adminUserApi.getUserMap(
|
||||
convertSet(pageResult.getList(), ErpStockOutDO::getCustomerId));
|
||||
// 1.4 管理员信息
|
||||
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
|
||||
@ -155,7 +158,7 @@ public class ErpStockOutController {
|
||||
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));
|
||||
MapUtils.findAndThen(customerMap, stockOut.getCustomerId(), supplier -> stockOut.setCustomerName(supplier.getName()));
|
||||
MapUtils.findAndThen(customerMap, stockOut.getCustomerId(), supplier -> stockOut.setCustomerName(supplier.getNickname()));
|
||||
MapUtils.findAndThen(userMap, Long.parseLong(stockOut.getCreator()), user -> stockOut.setCreatorName(user.getNickname()));
|
||||
});
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
@ -15,6 +16,7 @@ import static cn.iocoder.yudao.module.erp.enums.DictTypeConstants.AUDIT_STATUS;
|
||||
|
||||
@Schema(description = "管理后台 - ERP 其它出库单 Response VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ExcelIgnoreUnannotated
|
||||
public class ErpStockOutRespVO {
|
||||
|
||||
@ -107,4 +109,4 @@ public class ErpStockOutRespVO {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -17,11 +17,11 @@ import cn.iocoder.yudao.module.erp.enums.stock.ErpStockRecordBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
|
||||
import cn.iocoder.yudao.module.erp.service.sale.ErpCustomerService;
|
||||
import cn.iocoder.yudao.module.erp.service.stock.bo.ErpStockRecordCreateReqBO;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -66,7 +66,7 @@ public class ErpStockOutServiceImpl implements ErpStockOutService {
|
||||
// 1.1 校验出库项的有效性
|
||||
List<ErpStockOutItemDO> stockOutItems = validateStockOutItems(createReqVO.getItems());
|
||||
// 1.2 校验客户
|
||||
customerService.validateCustomer(createReqVO.getCustomerId());
|
||||
// customerService.validateCustomer(createReqVO.getCustomerId());
|
||||
// 1.3 生成出库单号,并校验唯一性
|
||||
String no = noRedisDAO.generate(ErpNoRedisDAO.STOCK_OUT_NO_PREFIX);
|
||||
if (stockOutMapper.selectByNo(no) != null) {
|
||||
@ -94,7 +94,7 @@ public class ErpStockOutServiceImpl implements ErpStockOutService {
|
||||
throw exception(STOCK_OUT_UPDATE_FAIL_APPROVE, stockOut.getNo());
|
||||
}
|
||||
// 1.2 校验客户
|
||||
customerService.validateCustomer(updateReqVO.getCustomerId());
|
||||
// customerService.validateCustomer(updateReqVO.getCustomerId());
|
||||
// 1.3 校验出库项的有效性
|
||||
List<ErpStockOutItemDO> stockOutItems = validateStockOutItems(updateReqVO.getItems());
|
||||
|
||||
@ -225,4 +225,4 @@ public class ErpStockOutServiceImpl implements ErpStockOutService {
|
||||
return stockOutItemMapper.selectListByOutIds(outIds);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user