diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/office/supplier/dal/mapper/SupplierMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/office/supplier/dal/mapper/SupplierMapper.java index dc2a547..567ad8b 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/office/supplier/dal/mapper/SupplierMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/office/supplier/dal/mapper/SupplierMapper.java @@ -40,12 +40,21 @@ public interface SupplierMapper extends BaseMapperX { default SupplierExtendRespVO selectOneWithCertifications(Long id) { return selectJoinOne(SupplierExtendRespVO.class, +// new MPJLambdaWrapperX() +// .selectAll(SupplierDO.class) +// .selectCollection(SupplierPropertiesDO.class, SupplierExtendRespVO::getSupplierPropertiesList) +// .leftJoin(SupplierPropertiesDO.class, SupplierPropertiesDO::getSupplierId, SupplierDO::getId) +// .eq(SupplierDO::getId, id) +//// .eq(SupplierPropertiesDO::getBusinessType, QmsSupplierConstant.CERTIFICATION_KEY) new MPJLambdaWrapperX() .selectAll(SupplierDO.class) .selectCollection(SupplierPropertiesDO.class, SupplierExtendRespVO::getSupplierPropertiesList) - .leftJoin(SupplierPropertiesDO.class, SupplierPropertiesDO::getSupplierId, SupplierDO::getId) + // 将关联条件写在一个 on() 方法内 + .leftJoin(SupplierPropertiesDO.class, on -> on + .eq(SupplierPropertiesDO::getSupplierId, SupplierDO::getId) + .eq(SupplierPropertiesDO::getBusinessType, QmsSupplierConstant.CERTIFICATION_KEY) + ) // 注意这里移除了之前的 .eq 条件 .eq(SupplierDO::getId, id) - .eq(SupplierPropertiesDO::getBusinessType, QmsSupplierConstant.CERTIFICATION_KEY) ); } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/controller/admin/DeviceConfigBusinessItemController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/controller/admin/DeviceConfigBusinessItemController.java index 76bb751..d7032f3 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/controller/admin/DeviceConfigBusinessItemController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/device/controller/admin/DeviceConfigBusinessItemController.java @@ -57,14 +57,14 @@ public class DeviceConfigBusinessItemController extends AbstractFileUploadContro @PostMapping("/create") @Operation(summary = "创建设备-检查项目配置") - @PreAuthorize("@ss.hasPermission('qms:device-config-business-item:create')") +// @PreAuthorize("@ss.hasPermission('qms:device-config-business-item:create')") public CommonResult createDeviceConfigBusinessItem(@Valid @RequestBody DeviceConfigBusinessItemSaveReqVO createReqVO) { return success(deviceConfigBusinessItemService.createDeviceConfigBusinessItem(createReqVO)); } @PutMapping("/update") @Operation(summary = "更新设备-检查项目配置") - @PreAuthorize("@ss.hasPermission('qms:device-config-business-item:update')") +// @PreAuthorize("@ss.hasPermission('qms:device-config-business-item:update')") public CommonResult updateDeviceConfigBusinessItem(@Valid @RequestBody DeviceConfigBusinessItemSaveReqVO updateReqVO) { deviceConfigBusinessItemService.updateDeviceConfigBusinessItem(updateReqVO); return success(true); @@ -73,7 +73,7 @@ public class DeviceConfigBusinessItemController extends AbstractFileUploadContro @DeleteMapping("/delete") @Operation(summary = "删除设备-检查项目配置") @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('qms:device-config-business-item:delete')") +// @PreAuthorize("@ss.hasPermission('qms:device-config-business-item:delete')") public CommonResult deleteDeviceConfigBusinessItem(@RequestParam("id") Long id) { deviceConfigBusinessItemService.deleteDeviceConfigBusinessItem(id); return success(true); @@ -82,7 +82,7 @@ public class DeviceConfigBusinessItemController extends AbstractFileUploadContro @DeleteMapping("/delete-list") @Parameter(name = "ids", description = "编号", required = true) @Operation(summary = "批量删除设备-检查项目配置") - @PreAuthorize("@ss.hasPermission('qms:device-config-business-item:delete')") +// @PreAuthorize("@ss.hasPermission('qms:device-config-business-item:delete')") public CommonResult deleteDeviceConfigBusinessItemList(@RequestBody BatchDeleteReqVO req) { deviceConfigBusinessItemService.deleteDeviceConfigBusinessItemListByIds(req.getIds()); return success(true); @@ -91,7 +91,7 @@ public class DeviceConfigBusinessItemController extends AbstractFileUploadContro @GetMapping("/get") @Operation(summary = "获得设备-检查项目配置") @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('qms:device-config-business-item:query')") +// @PreAuthorize("@ss.hasPermission('qms:device-config-business-item:query')") public CommonResult getDeviceConfigBusinessItem(@RequestParam("id") Long id) { DeviceConfigBusinessItemDO deviceConfigBusinessItem = deviceConfigBusinessItemService.getDeviceConfigBusinessItem(id); return success(BeanUtils.toBean(deviceConfigBusinessItem, DeviceConfigBusinessItemRespVO.class)); @@ -99,7 +99,7 @@ public class DeviceConfigBusinessItemController extends AbstractFileUploadContro @GetMapping("/page") @Operation(summary = "获得设备-检查项目配置分页") - @PreAuthorize("@ss.hasPermission('qms:device-config-business-item:query')") +// @PreAuthorize("@ss.hasPermission('qms:device-config-business-item:query')") public CommonResult> getDeviceConfigBusinessItemPage(@Valid DeviceConfigBusinessItemPageReqVO pageReqVO) { PageResult pageResult = deviceConfigBusinessItemService.getDeviceConfigBusinessItemPage(pageReqVO); return success(BeanUtils.toBean(pageResult, DeviceConfigBusinessItemRespVO.class)); @@ -107,7 +107,7 @@ public class DeviceConfigBusinessItemController extends AbstractFileUploadContro @GetMapping("/export-excel") @Operation(summary = "导出设备-检查项目配置 Excel") - @PreAuthorize("@ss.hasPermission('qms:device-config-business-item:export')") +// @PreAuthorize("@ss.hasPermission('qms:device-config-business-item:export')") @ApiAccessLog(operateType = EXPORT) public void exportDeviceConfigBusinessItemExcel(@Valid DeviceConfigBusinessItemPageReqVO pageReqVO, HttpServletResponse response) throws IOException { diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialBatchController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialBatchController.java index 87fbdd7..64dc814 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialBatchController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialBatchController.java @@ -1,5 +1,6 @@ package com.zt.plat.module.qms.resource.material.controller.admin; +import com.zt.plat.framework.datapermission.core.annotation.DeptDataPermissionIgnore; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchSaveReqVO; @@ -39,6 +40,7 @@ import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*; @RestController @RequestMapping("/qms/resource/material-batch") @Validated +@DeptDataPermissionIgnore(enable = "true") public class MaterialBatchController implements BusinessControllerMarker { @@ -47,14 +49,14 @@ public class MaterialBatchController implements BusinessControllerMarker { @PostMapping("/create") @Operation(summary = "创建物料批次") - @PreAuthorize("@ss.hasPermission('qms:material-batch:create')") +// @PreAuthorize("@ss.hasPermission('qms:material-batch:create')") public CommonResult createMaterialBatch(@Validated(AddGroup.class) @RequestBody MaterialBatchSaveReqVO createReqVO) { return success(materialBatchService.createMaterialBatch(createReqVO)); } @PutMapping("/update") @Operation(summary = "更新物料批次") - @PreAuthorize("@ss.hasPermission('qms:material-batch:update')") +// @PreAuthorize("@ss.hasPermission('qms:material-batch:update')") public CommonResult updateMaterialBatch(@Validated(UpdateGroup.class) @RequestBody MaterialBatchSaveReqVO updateReqVO) { materialBatchService.updateMaterialBatch(updateReqVO); return success(true); @@ -63,7 +65,7 @@ public class MaterialBatchController implements BusinessControllerMarker { @DeleteMapping("/delete") @Operation(summary = "删除物料批次") @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('qms:material-batch:delete')") +// @PreAuthorize("@ss.hasPermission('qms:material-batch:delete')") public CommonResult deleteMaterialBatch(@RequestParam("id") Long id) { materialBatchService.deleteMaterialBatch(id); return success(true); @@ -110,7 +112,7 @@ public class MaterialBatchController implements BusinessControllerMarker { @PostMapping("/assign-gongduan") @Operation(summary = "批次工段拆分") - @PreAuthorize("@ss.hasPermission('qms:material-batch:create')") +// @PreAuthorize("@ss.hasPermission('qms:material-batch:create')") public CommonResult> assignMaterialBatchGongduan(@Valid @RequestBody List createReqVOs) { return success(materialBatchService.assignMaterialBatchGongduan(createReqVOs)); } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInventoryController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInventoryController.java new file mode 100644 index 0000000..281b368 --- /dev/null +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialInventoryController.java @@ -0,0 +1,38 @@ +package com.zt.plat.module.qms.resource.material.controller.admin; + +import com.zt.plat.framework.business.interceptor.BusinessControllerMarker; +import com.zt.plat.framework.common.pojo.CommonResult; +import com.zt.plat.framework.common.pojo.PageResult; +import com.zt.plat.framework.datapermission.core.annotation.DeptDataPermissionIgnore; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductPageReqVO; +import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductRespVO; +import com.zt.plat.module.qms.resource.material.service.MaterialProductService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import static com.zt.plat.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - 物料库存") +@RestController +@RequestMapping("/qms/resource/material-inventory") +@Validated +@DeptDataPermissionIgnore(enable = "true") +public class MaterialInventoryController implements BusinessControllerMarker { + + @Autowired + private MaterialProductService materialProductService; + + @GetMapping("/page") + @Operation(summary = "获得物料大类分页") + public CommonResult> getMaterialInventoryPage(@Valid MaterialProductPageReqVO pageReqVO) { + // 需要库存数量和预警信息 + PageResult pageResult = materialProductService.getMaterialInventoryPage(pageReqVO); + return success(pageResult); + } +} diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialProductController.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialProductController.java index 14f5748..baea25d 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialProductController.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/admin/MaterialProductController.java @@ -9,6 +9,7 @@ import com.zt.plat.framework.common.pojo.PageParam; import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO; import com.zt.plat.framework.common.util.object.BeanUtils; +import com.zt.plat.framework.datapermission.core.annotation.DeptDataPermissionIgnore; import com.zt.plat.framework.excel.core.util.ExcelUtils; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductRespVO; @@ -36,6 +37,7 @@ import static com.zt.plat.framework.common.pojo.CommonResult.success; @RequestMapping("/qms/resource/material-product") @Validated @FileUploadController(source = "resource.materialproduct") +@DeptDataPermissionIgnore(enable = "true") public class MaterialProductController extends AbstractFileUploadController implements BusinessControllerMarker{ static { @@ -51,7 +53,7 @@ public class MaterialProductController extends AbstractFileUploadController impl @PostMapping("/save-category") @Operation(summary = "保存分类") - @PreAuthorize("@ss.hasPermission('qms:material-product:create-category')") +// @PreAuthorize("@ss.hasPermission('qms:material-product:create-category')") public CommonResult saveMaterialCategory(@Valid @RequestBody MaterialProductSaveReqVO createReqVO) { return success(materialProductService.saveMaterialCategory(createReqVO)); } @@ -72,7 +74,7 @@ public class MaterialProductController extends AbstractFileUploadController impl @PostMapping("/save-material") @Operation(summary = "保存物料大类") - @PreAuthorize("@ss.hasPermission('qms:material-product:create')") +// @PreAuthorize("@ss.hasPermission('qms:material-product:create')") public CommonResult saveMaterialProduct(@Valid @RequestBody MaterialProductSaveReqVO createReqVO) { return success(materialProductService.saveMaterialProduct(createReqVO)); } @@ -85,6 +87,13 @@ public class MaterialProductController extends AbstractFileUploadController impl return success(BeanUtils.toBean(pageResult, MaterialProductRespVO.class)); } + @GetMapping("category-data") + @Operation(summary = "获得物料分类和大类") + @Parameter(name = "type", description = "category-分类,data-全部") + public CommonResult> getCategoryAndData(@RequestParam("type") String type) { + return success(materialProductService.getCategoryAndData(type)); + } + // @PutMapping("/update") // @Operation(summary = "更新物料") @@ -97,7 +106,7 @@ public class MaterialProductController extends AbstractFileUploadController impl @DeleteMapping("/delete") @Operation(summary = "删除物料分类或大类") @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('qms:material-product:delete')") +// @PreAuthorize("@ss.hasPermission('qms:material-product:delete')") public CommonResult deleteMaterialProduct(@RequestParam("id") Long id) { materialProductService.deleteMaterialProduct(id); return success(true); @@ -117,7 +126,7 @@ public class MaterialProductController extends AbstractFileUploadController impl @Parameter(name = "id", description = "编号", required = true, example = "1024") // @PreAuthorize("@ss.hasPermission('qms:material-product:query')") public CommonResult getMaterialProduct(@RequestParam("id") Long id) { - MaterialProductDO materialProduct = materialProductService.getMaterialProduct(id); + MaterialProductDO materialProduct = materialProductService.getMaterialProductInfo(id); return success(BeanUtils.toBean(materialProduct, MaterialProductRespVO.class)); } diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialBatchRespVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialBatchRespVO.java index 25a1ef3..6c63e9e 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialBatchRespVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialBatchRespVO.java @@ -58,6 +58,10 @@ public class MaterialBatchRespVO { @ExcelProperty("分配部门名称") private String assignDepartmentName; + @Schema(description = "提交状态,0-未提交,1-已提交", example = "1") + @ExcelProperty("提交状态,0-未提交,1-已提交") + private Integer submitStatus; + @Schema(description = "验收状态", example = "1") @ExcelProperty("验收状态") private String acceptanceStatus; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialProductRespVO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialProductRespVO.java index d609997..24eedd7 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialProductRespVO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/controller/vo/MaterialProductRespVO.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.List; @@ -82,6 +83,10 @@ public class MaterialProductRespVO { @ExcelProperty("单位") private String unit; + @Schema(description = "库存数量") + @ExcelProperty("库存数量") + private BigDecimal inventoryQuantity; + @Schema(description = "允许按量领取,1-领用时输入量,按量领取;0-领用时不能输入量,整个领走") @ExcelProperty("允许按量领取,1-领用时输入量,按量领取;0-领用时不能输入量,整个领走") private Integer enablePartial; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialBatchDO.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialBatchDO.java index 2fed0b7..15fcdd7 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialBatchDO.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/dataobject/MaterialBatchDO.java @@ -82,6 +82,11 @@ public class MaterialBatchDO extends BusinessBaseDO { */ @TableField("ASN_DEPT_NAME") private String assignDepartmentName; + /** + * 提交状态,0-未提交,1-已提交 + */ + @TableField("SBM_STS") + private Integer submitStatus; /** * 验收状态 */ diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialBatchMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialBatchMapper.java index be6576a..8e2eafd 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialBatchMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialBatchMapper.java @@ -1,12 +1,21 @@ package com.zt.plat.module.qms.resource.material.dal.mapper; +import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.github.yulichang.base.MPJBaseMapper; +import com.github.yulichang.wrapper.MPJLambdaWrapper; import com.zt.plat.framework.common.pojo.PageResult; -import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX; +import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialBatchPageReqVO; import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialBatchDO; +import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO; import org.apache.ibatis.annotations.Mapper; +import java.util.Arrays; +import java.util.List; + /** * 物料批次 Mapper * @@ -16,6 +25,7 @@ import org.apache.ibatis.annotations.Mapper; public interface MaterialBatchMapper extends BaseMapperX { default PageResult selectPage(MaterialBatchPageReqVO reqVO) { + // TODO 需要层级穿透 分类-物料sku-批次 return selectPage(reqVO, new LambdaQueryWrapperX() .eqIfPresent(MaterialBatchDO::getProductId, reqVO.getProductId()) .likeIfPresent(MaterialBatchDO::getBatchNo, reqVO.getBatchNo()) diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialProductMapper.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialProductMapper.java index 3135749..a2f67bd 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialProductMapper.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/dal/mapper/MaterialProductMapper.java @@ -1,6 +1,5 @@ package com.zt.plat.module.qms.resource.material.dal.mapper; -import cn.hutool.core.collection.CollUtil; import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX; import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; @@ -9,11 +8,6 @@ import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductPag import com.zt.plat.module.qms.resource.material.dal.dataobject.MaterialProductDO; import org.apache.ibatis.annotations.Mapper; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - /** * 物料大类 Mapper * @@ -22,12 +16,14 @@ import java.util.stream.Collectors; @Mapper public interface MaterialProductMapper extends BaseMapperX { +// @QmsPermission(deptDataRoleCodes = "ytjyDeptAndSub", moduleDataRoleCodes = "qms_material_manager") default PageResult selectPage(MaterialProductPageReqVO reqVO) { - PageResult pageResult = selectPage(reqVO, new LambdaQueryWrapperX() + return selectPage(reqVO, new LambdaQueryWrapperX() .eq(MaterialProductDO::getNodeType, DataTypeConstant.DATA_TYPE_DATA) .eqIfPresent(MaterialProductDO::getParentId, reqVO.getParentId()) .likeIfPresent(MaterialProductDO::getIdPath, reqVO.getIdPath()) .likeIfPresent(MaterialProductDO::getName, reqVO.getName()) + .likeIfPresent(MaterialProductDO::getCode, reqVO.getCode()) .likeIfPresent(MaterialProductDO::getCustomConfig, reqVO.getCustomConfig()) .likeIfPresent(MaterialProductDO::getCustomForm, reqVO.getCustomForm()) .likeIfPresent(MaterialProductDO::getCustomData, reqVO.getCustomData()) @@ -54,17 +50,6 @@ public interface MaterialProductMapper extends BaseMapperX { .orderByAsc(MaterialProductDO::getSortNo) .orderByAsc(MaterialProductDO::getIdPath) .orderByDesc(MaterialProductDO::getId)); - List mtrlDos = pageResult.getList(); - if (CollUtil.isEmpty(mtrlDos)) return pageResult; - Set prnIds = mtrlDos.stream().map(MaterialProductDO::getParentId).collect(Collectors.toSet()); - List prnDos = this.selectByIds(prnIds); - if (CollUtil.isEmpty(prnDos)) return pageResult; - Map prnIdNameMap = prnDos.stream().collect(Collectors.toMap(MaterialProductDO::getId, MaterialProductDO::getName)); - for (MaterialProductDO mtrlDo : mtrlDos) { - mtrlDo.setCategoryName(prnIdNameMap.get(mtrlDo.getParentId())); - } - pageResult.setList(mtrlDos); - return pageResult; } } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialBatchServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialBatchServiceImpl.java index e54f4eb..5d25a2a 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialBatchServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialBatchServiceImpl.java @@ -43,8 +43,6 @@ public class MaterialBatchServiceImpl implements MaterialBatchService { private MaterialBatchMapper materialBatchMapper; @Autowired private SequenceUtil sequenceUtil; - @Autowired - private MaterialProductService materialProductService; private final String sequenceKey = "QMS_MATERIAL_BATCH_NO"; diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationService.java index 07388f9..7239403 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationService.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationService.java @@ -61,4 +61,11 @@ public interface MaterialInfomationService { */ PageResult getMaterialInfomationPage(MaterialInfomationPageReqVO pageReqVO); + /** + * 根据物料大类 id 获取库存数量 + * + * @param mtrlIds ids + * @return 大类id-库存数量 + */ + Map getStockQuantityByPdtIds(List mtrlIds); } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationServiceImpl.java index 0254e34..a0f5238 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialInfomationServiceImpl.java @@ -1,6 +1,8 @@ package com.zt.plat.module.qms.resource.material.service; import cn.hutool.core.collection.CollUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.common.util.object.BeanUtils; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialInfomationPageReqVO; @@ -12,7 +14,10 @@ import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.zt.plat.module.qms.enums.ErrorCodeConstants.MATERIAL_INFOMATION_NOT_EXISTS; @@ -86,4 +91,20 @@ public class MaterialInfomationServiceImpl implements MaterialInfomationService return materialInfomationMapper.selectPage(pageReqVO); } + @Override + public Map getStockQuantityByPdtIds(List pdtIds) { + QueryWrapper queryWrapper = Wrappers.query(MaterialInfomationDO.class) + .select("PDT_ID ,count(*) as quantity") + .in("PDT_ID", pdtIds) + .eq("USG_STS", 0) + .groupBy("PDT_ID"); + List> maps = materialInfomationMapper.selectMaps(queryWrapper); + if (CollUtil.isEmpty(maps)) return new HashMap<>(); + + return maps.stream().collect(Collectors.toMap( + map -> (Long) map.get("PDT_ID"), + map -> ((Long) map.get("quantity")) + )); + } + } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductService.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductService.java index bf59481..a5b8bdf 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductService.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductService.java @@ -75,4 +75,28 @@ public interface MaterialProductService { * @return 物料大类分页 */ PageResult getMaterialProductPage(MaterialProductPageReqVO pageReqVO); + + /** + * 获得物料大类详情 + * + * @param id 编号 + * @return 物料大类 + */ + MaterialProductDO getMaterialProductInfo(Long id); + + /** + * 获得物料分类和大类 + * + * @param type 节点类型 + * @return 列表 + */ + List getCategoryAndData(String type); + + /** + * 获得物料大类的库存分页信息 + * + * @param pageReqVO 分页查询 + * @return 物料大类分页 + */ + PageResult getMaterialInventoryPage(@Valid MaterialProductPageReqVO pageReqVO); } \ No newline at end of file diff --git a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductServiceImpl.java b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductServiceImpl.java index 8ce8838..1a8bff6 100644 --- a/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductServiceImpl.java +++ b/zt-module-qms/zt-module-qms-server/src/main/java/com/zt/plat/module/qms/resource/material/service/MaterialProductServiceImpl.java @@ -7,7 +7,6 @@ import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.common.util.object.BeanUtils; import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; import com.zt.plat.module.qms.core.constant.DataTypeConstant; -import com.zt.plat.module.qms.enums.ErrorCodeConstants; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductPageReqVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductRespVO; import com.zt.plat.module.qms.resource.material.controller.vo.MaterialProductSaveReqVO; @@ -20,13 +19,14 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.zt.plat.module.qms.enums.ErrorCodeConstants.*; -import static org.checkerframework.checker.units.qual.Prefix.one; /** * 物料大类 Service 实现类 @@ -40,10 +40,12 @@ public class MaterialProductServiceImpl implements MaterialProductService { @Resource private MaterialProductMapper materialProductMapper; - @Lazy @Autowired private MaterialBatchService materialBatchService; + @Autowired + private MaterialInfomationService materialInfomationService; + /** * 保存分类 * @@ -294,4 +296,47 @@ public class MaterialProductServiceImpl implements MaterialProductService { return materialProductMapper.selectPage(pageReqVO); } + @Override + public MaterialProductDO getMaterialProductInfo(Long id) { + MaterialProductDO mtrlDo = this.getMaterialProduct(id); + if (mtrlDo == null) return null; + MaterialProductDO prnMtrl = materialProductMapper.selectById(mtrlDo.getParentId()); + if (prnMtrl == null) return mtrlDo; + mtrlDo.setCategoryName(prnMtrl.getName()); + return mtrlDo; + } + + + @Override + public List getCategoryAndData(String type) { + List mtrlDos; + if (DataTypeConstant.DATA_TYPE_CATEGORY.equals(type)) { + mtrlDos = materialProductMapper.selectList(Wrappers.lambdaQuery(MaterialProductDO.class) + .eq(MaterialProductDO::getNodeType, DataTypeConstant.DATA_TYPE_CATEGORY)); + } else { + mtrlDos = materialProductMapper.selectList(); + } + if (CollUtil.isEmpty(mtrlDos)) return List.of(); + + return mtrlDos.stream().map(m -> BeanUtils.toBean(m, MaterialProductRespVO.class)).toList(); + } + + @Override + public PageResult getMaterialInventoryPage(MaterialProductPageReqVO pageReqVO) { + PageResult pageResult = materialProductMapper.selectPage(pageReqVO); + List mtrlDos = pageResult.getList(); + if (CollUtil.isEmpty(mtrlDos)) return new PageResult<>(new ArrayList<>(), pageResult.getTotal()); + List mtrlIds = mtrlDos.stream().map(MaterialProductDO::getId).toList(); + List voList = mtrlDos.stream().map(m -> BeanUtils.toBean(m, MaterialProductRespVO.class)).toList(); + // 一次性获取大类下的库存数量 + Map stockQuantityMap = materialInfomationService.getStockQuantityByPdtIds(mtrlIds); + if (CollUtil.isNotEmpty(stockQuantityMap)) { + for (MaterialProductRespVO vo : voList) { + vo.setInventoryQuantity(BigDecimal.valueOf(stockQuantityMap.get(vo.getId()))); + } + } + + return new PageResult<>(voList, pageResult.getTotal()); + } + } \ No newline at end of file