| | |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemRespVO; |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemSaveReqVO; |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemStatusUpdateReqVO; |
| | | import cn.iocoder.yudao.module.mdm.dal.dataobject.category.MdmItemCategoryDO; |
| | | import cn.iocoder.yudao.module.mdm.dal.dataobject.item.MdmItemBatchConfigDO; |
| | | import cn.iocoder.yudao.module.mdm.dal.dataobject.item.MdmItemDO; |
| | | import cn.iocoder.yudao.module.mdm.dal.dataobject.unit.MdmUnitMeasureDO; |
| | | import cn.iocoder.yudao.module.mdm.dal.dataobject.warehouse.MdmWarehouseDO; |
| | | import cn.iocoder.yudao.module.mdm.service.brand.MdmBrandService; |
| | | import cn.iocoder.yudao.module.mdm.service.category.MdmItemCategoryService; |
| | | import cn.iocoder.yudao.module.mdm.service.item.MdmItemBatchConfigService; |
| | | import cn.iocoder.yudao.module.mdm.service.item.MdmItemService; |
| | | import cn.iocoder.yudao.module.mdm.service.unit.MdmUnitMeasureService; |
| | | import cn.iocoder.yudao.module.mdm.service.warehouse.MdmWarehouseService; |
| | |
| | | private MdmItemService itemService; |
| | | |
| | | @Resource |
| | | private MdmItemCategoryService itemCategoryService; |
| | | @Resource |
| | | private MdmUnitMeasureService unitMeasureService; |
| | | |
| | | @Resource |
| | | private MdmWarehouseService warehouseService; |
| | | @Resource |
| | | private MdmBrandService brandService; |
| | | @Resource |
| | | private MdmItemBatchConfigService itemBatchConfigService; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "创建物料") |
| | |
| | | MdmItemRespVO resp = BeanUtils.toBean(item, MdmItemRespVO.class); |
| | | if (resp != null) { |
| | | enrichItemRespVO(resp); |
| | | // 填充批次属性配置 |
| | | enrichItemBatchConfig(resp); |
| | | } |
| | | return success(resp); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermission('mdm:item:query')") |
| | | public CommonResult<PageResult<MdmItemRespVO>> getItemPage(@Valid MdmItemPageReqVO pageReqVO) { |
| | | PageResult<MdmItemDO> pageResult = itemService.getItemPage(pageReqVO); |
| | | // 关联查询分类名称 |
| | | Map<Long, MdmItemCategoryDO> categoryMap = itemCategoryService.getItemCategoryMap( |
| | | convertSet(pageResult.getList(), MdmItemDO::getCategoryId)); |
| | | // 关联查询计量单位名称 |
| | | Map<Long, MdmUnitMeasureDO> unitMap = unitMeasureService.getUnitMeasureMap( |
| | | convertSet(pageResult.getList(), MdmItemDO::getUnitMeasureId)); |
| | |
| | | .collect(Collectors.toMap(MdmWarehouseDO::getId, w -> w)); |
| | | // 赋值 |
| | | respList.forEach(resp -> { |
| | | // 分类名称 |
| | | MdmItemCategoryDO category = categoryMap.get(resp.getCategoryId()); |
| | | if (category != null) { |
| | | resp.setCategoryName(category.getName()); |
| | | } |
| | | MdmUnitMeasureDO unit = unitMap.get(resp.getUnitMeasureId()); |
| | | if (unit != null) { |
| | | resp.setUnitMeasureName(unit.getName()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 填充物料响应 VO 的关联名称(主单位、辅单位、仓库名称) |
| | | * 填充物料响应 VO 的关联名称(分类、主单位、辅单位、仓库名称) |
| | | */ |
| | | private void enrichItemRespVO(MdmItemRespVO resp) { |
| | | // 分类名称 |
| | | if (resp.getCategoryId() != null) { |
| | | MdmItemCategoryDO category = itemCategoryService.getItemCategory(resp.getCategoryId()); |
| | | if (category != null) { |
| | | resp.setCategoryName(category.getName()); |
| | | } |
| | | } |
| | | // 主单位名称 |
| | | if (resp.getUnitMeasureId() != null) { |
| | | MdmUnitMeasureDO unit = unitMeasureService.getUnitMeasure(resp.getUnitMeasureId()); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 填充物料批次属性配置 |
| | | */ |
| | | private void enrichItemBatchConfig(MdmItemRespVO resp) { |
| | | MdmItemBatchConfigDO config = itemBatchConfigService.getItemBatchConfigByItemId(resp.getId()); |
| | | if (config != null) { |
| | | resp.setProduceDateFlag(config.getProduceDateFlag()); |
| | | resp.setExpireDateFlag(config.getExpireDateFlag()); |
| | | resp.setReceiptDateFlag(config.getReceiptDateFlag()); |
| | | resp.setVendorFlag(config.getVendorFlag()); |
| | | resp.setPurchaseOrderCodeFlag(config.getPurchaseOrderCodeFlag()); |
| | | resp.setLotNumberFlag(config.getLotNumberFlag()); |
| | | resp.setQualityStatusFlag(config.getQualityStatusFlag()); |
| | | } |
| | | } |
| | | |
| | | } |