| | |
| | | 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.controller.admin.item.vo.MdmItemSyncUpdateReqVO; |
| | | 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; |
| | | import cn.iocoder.yudao.module.mes.api.item.MesMdItemApi; |
| | | import cn.iocoder.yudao.module.mes.api.wm.warehouse.MesWmWarehouseApi; |
| | | import cn.iocoder.yudao.module.mes.api.wm.warehouse.dto.MesWmWarehouseRespDTO; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | | import io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | |
| | | private MdmItemService itemService; |
| | | |
| | | @Resource |
| | | private MesMdItemApi mesMdItemApi; |
| | | |
| | | @Resource |
| | | private MdmItemCategoryService itemCategoryService; |
| | | @Resource |
| | | private MdmUnitMeasureService unitMeasureService; |
| | | @Resource |
| | | private MdmWarehouseService warehouseService; |
| | | private MesWmWarehouseApi mesWmWarehouseApi; |
| | | @Resource |
| | | private MdmBrandService brandService; |
| | | @Resource |
| | |
| | | @PreAuthorize("@ss.hasPermission('mdm:item:update')") |
| | | public CommonResult<Boolean> updateItemStatus(@RequestBody MdmItemStatusUpdateReqVO reqVO) { |
| | | itemService.updateItemStatus(reqVO.getId(), reqVO.getStatus()); |
| | | return success(true); |
| | | } |
| | | |
| | | @PutMapping("/update-sync") |
| | | @Operation(summary = "更新物料同步状态") |
| | | @PreAuthorize("@ss.hasPermission('mdm:item:update')") |
| | | public CommonResult<Boolean> updateItemSync(@Valid @RequestBody MdmItemSyncUpdateReqVO reqVO) { |
| | | itemService.updateItemSync(reqVO.getId(), reqVO.getSync()); |
| | | return success(true); |
| | | } |
| | | |
| | |
| | | enrichItemRespVO(resp); |
| | | // 填充批次属性配置 |
| | | enrichItemBatchConfig(resp); |
| | | // 填充同步状态 |
| | | resp.setSyncedMes(mesMdItemApi.getSyncedMdmItemIds(Set.of(id)).contains(id)); |
| | | } |
| | | return success(resp); |
| | | } |
| | |
| | | convertSet(pageResult.getList(), MdmItemDO::getUnitMeasureId)); |
| | | // 转换 |
| | | List<MdmItemRespVO> respList = BeanUtils.toBean(pageResult.getList(), MdmItemRespVO.class); |
| | | // 批量查询同步状态 |
| | | Set<Long> allIds = convertSet(respList, MdmItemRespVO::getId); |
| | | Set<Long> syncedIds = mesMdItemApi.getSyncedMdmItemIds(allIds); |
| | | // 批量关联查询辅单位名称 |
| | | Set<Long> unitIds = new HashSet<>(); |
| | | respList.forEach(resp -> { |
| | |
| | | }); |
| | | Map<Long, MdmUnitMeasureDO> auxUnitMap = unitIds.isEmpty() ? |
| | | Collections.emptyMap() : unitMeasureService.getUnitMeasureMap(unitIds); |
| | | // 批量关联查询仓库名称 |
| | | // 批量关联查询仓库名称(使用 MES 仓库) |
| | | Set<Long> warehouseIds = new HashSet<>(); |
| | | respList.forEach(resp -> { |
| | | if (resp.getWarehouseId() != null) warehouseIds.add(resp.getWarehouseId()); |
| | | }); |
| | | Map<Long, MdmWarehouseDO> warehouseMap = warehouseIds.isEmpty() ? |
| | | Collections.emptyMap() : warehouseService.getWarehouseList(warehouseIds).stream() |
| | | .collect(Collectors.toMap(MdmWarehouseDO::getId, w -> w)); |
| | | Map<Long, MesWmWarehouseRespDTO> warehouseMap = warehouseIds.isEmpty() ? |
| | | Collections.emptyMap() : mesWmWarehouseApi.getWarehouseList(warehouseIds).stream() |
| | | .collect(Collectors.toMap(MesWmWarehouseRespDTO::getId, w -> w)); |
| | | // 赋值 |
| | | respList.forEach(resp -> { |
| | | // 分类名称 |
| | |
| | | if (auxUnit2 != null) { |
| | | resp.setUnitMeasureName3(auxUnit2.getName()); |
| | | } |
| | | MdmWarehouseDO warehouse = warehouseMap.get(resp.getWarehouseId()); |
| | | MesWmWarehouseRespDTO warehouse = warehouseMap.get(resp.getWarehouseId()); |
| | | if (warehouse != null) { |
| | | resp.setWarehouseName(warehouse.getName()); |
| | | } |
| | | // 同步状态 |
| | | resp.setSyncedMes(syncedIds.contains(resp.getId())); |
| | | }); |
| | | return success(new PageResult<>(respList, pageResult.getTotal())); |
| | | } |
| | |
| | | public CommonResult<List<MdmItemRespVO>> getItemList(@RequestParam("ids") List<Long> ids) { |
| | | List<MdmItemDO> list = itemService.getItemList(ids); |
| | | return success(BeanUtils.toBean(list, MdmItemRespVO.class)); |
| | | } |
| | | |
| | | @GetMapping("/simple-list") |
| | | @Operation(summary = "获取物料精简列表(启用状态,用于下拉选择)") |
| | | public CommonResult<List<MdmItemRespVO>> getItemSimpleList() { |
| | | List<MdmItemDO> list = itemService.getItemSimpleList(); |
| | | List<MdmItemRespVO> respList = BeanUtils.toBean(list, MdmItemRespVO.class); |
| | | // 填充单位名称等关联字段,确保下拉选择后可带出单位等信息 |
| | | Map<Long, MdmUnitMeasureDO> unitMap = unitMeasureService.getUnitMeasureMap( |
| | | convertSet(respList, MdmItemRespVO::getUnitMeasureId)); |
| | | respList.forEach(resp -> { |
| | | MdmUnitMeasureDO unit = unitMap.get(resp.getUnitMeasureId()); |
| | | if (unit != null) { |
| | | resp.setUnitMeasureName(unit.getName()); |
| | | } |
| | | }); |
| | | return success(respList); |
| | | } |
| | | |
| | | /** |
| | |
| | | resp.setUnitMeasureName3(unit3.getName()); |
| | | } |
| | | } |
| | | // 默认仓库名称 |
| | | // 默认仓库名称(使用 MES 仓库) |
| | | if (resp.getWarehouseId() != null) { |
| | | MdmWarehouseDO warehouse = warehouseService.getWarehouse(resp.getWarehouseId()); |
| | | if (warehouse != null) { |
| | | resp.setWarehouseName(warehouse.getName()); |
| | | List<MesWmWarehouseRespDTO> warehouses = mesWmWarehouseApi.getWarehouseList(List.of(resp.getWarehouseId())); |
| | | if (!warehouses.isEmpty()) { |
| | | resp.setWarehouseName(warehouses.get(0).getName()); |
| | | } |
| | | } |
| | | } |