| | |
| | | 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.controller.admin.item.vo.MdmItemSyncUpdateReqVO; |
| | | import cn.iocoder.yudao.module.mdm.dal.dataobject.brand.MdmBrandDO; |
| | | 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; |
| | |
| | | @GetMapping("/get") |
| | | @Operation(summary = "获得物料") |
| | | @Parameter(name = "id", description = "编号", required = true, example = "1") |
| | | @PreAuthorize("@ss.hasPermission('mdm:item:query')") |
| | | public CommonResult<MdmItemRespVO> getItem(@RequestParam("id") Long id) { |
| | | MdmItemDO item = itemService.getItem(id); |
| | | MdmItemRespVO resp = BeanUtils.toBean(item, MdmItemRespVO.class); |
| | |
| | | |
| | | @GetMapping("/page") |
| | | @Operation(summary = "获得物料分页") |
| | | @PreAuthorize("@ss.hasPermission('mdm:item:query')") |
| | | public CommonResult<PageResult<MdmItemRespVO>> getItemPage(@Valid MdmItemPageReqVO pageReqVO) { |
| | | PageResult<MdmItemDO> pageResult = itemService.getItemPage(pageReqVO); |
| | | // 转换并补齐关联名称 |
| | |
| | | // 关联查询计量单位名称 |
| | | Map<Long, MdmUnitMeasureDO> unitMap = unitMeasureService.getUnitMeasureMap( |
| | | convertSet(itemList, MdmItemDO::getUnitMeasureId)); |
| | | // 关联查询品牌名称(采购下单需要确认品牌) |
| | | Map<Long, MdmBrandDO> brandMap = brandService.getBrandMap( |
| | | convertSet(itemList, MdmItemDO::getBrandId)); |
| | | // 转换 |
| | | List<MdmItemRespVO> respList = BeanUtils.toBean(itemList, MdmItemRespVO.class); |
| | | // 批量查询同步状态 |
| | |
| | | if (unit != null) { |
| | | resp.setUnitMeasureName(unit.getName()); |
| | | } |
| | | // 品牌名称 |
| | | MdmBrandDO brand = brandMap.get(resp.getBrandId()); |
| | | if (brand != null) { |
| | | resp.setBrandName(brand.getName()); |
| | | } |
| | | MdmUnitMeasureDO auxUnit1 = auxUnitMap.get(resp.getUnitMeasureId2()); |
| | | if (auxUnit1 != null) { |
| | | resp.setUnitMeasureName2(auxUnit1.getName()); |
| | |
| | | @GetMapping("/list-by-ids") |
| | | @Operation(summary = "获得物料列表") |
| | | @Parameter(name = "ids", description = "编号列表", required = true, example = "1,2,3") |
| | | @PreAuthorize("@ss.hasPermission('mdm:item:query')") |
| | | public CommonResult<List<MdmItemRespVO>> getItemList(@RequestParam("ids") List<Long> ids) { |
| | | List<MdmItemDO> list = itemService.getItemList(ids); |
| | | return success(BeanUtils.toBean(list, MdmItemRespVO.class)); |
| | |
| | | // 填充单位名称等关联字段,确保下拉选择后可带出单位等信息 |
| | | Map<Long, MdmUnitMeasureDO> unitMap = unitMeasureService.getUnitMeasureMap( |
| | | convertSet(respList, MdmItemRespVO::getUnitMeasureId)); |
| | | Map<Long, MdmBrandDO> brandMap = brandService.getBrandMap( |
| | | convertSet(respList, MdmItemRespVO::getBrandId)); |
| | | respList.forEach(resp -> { |
| | | MdmUnitMeasureDO unit = unitMap.get(resp.getUnitMeasureId()); |
| | | if (unit != null) { |
| | | resp.setUnitMeasureName(unit.getName()); |
| | | } |
| | | MdmBrandDO brand = brandMap.get(resp.getBrandId()); |
| | | if (brand != null) { |
| | | resp.setBrandName(brand.getName()); |
| | | } |
| | | }); |
| | | return success(respList); |
| | |
| | | resp.setCategoryName(category.getName()); |
| | | } |
| | | } |
| | | // 品牌名称 |
| | | if (resp.getBrandId() != null) { |
| | | MdmBrandDO brand = brandService.getBrand(resp.getBrandId()); |
| | | if (brand != null) { |
| | | resp.setBrandName(brand.getName()); |
| | | } |
| | | } |
| | | // 主单位名称 |
| | | if (resp.getUnitMeasureId() != null) { |
| | | MdmUnitMeasureDO unit = unitMeasureService.getUnitMeasure(resp.getUnitMeasureId()); |