组织架构物料管理新增组织级别的属性管理 http://172.16.46.63:31560/index.php?m=task&f=view&id=688

This commit is contained in:
ranke
2026-01-12 10:38:09 +08:00
parent 1ea3e847b4
commit 47fd100b44
20 changed files with 278 additions and 14 deletions

View File

@@ -0,0 +1,5 @@
ALTER TABLE "BSE_MTRL_PRPS" ADD COLUMN "DEPT_ID" BIGINT;
COMMENT ON COLUMN "BSE_MTRL_PRPS"."DEPT_ID" IS '部门ID,如果为空则表示通用属性,不为空则是对应部门的私有属性';
ALTER TABLE "BSE_MTRL_HS_PRPS" ADD COLUMN "DEPT_ID" BIGINT;
COMMENT ON COLUMN "BSE_MTRL_HS_PRPS"."DEPT_ID" IS '部门ID,如果为空则表示通用属性,不为空则是对应部门的私有属性';

View File

@@ -110,7 +110,7 @@ public class DepartmentMaterialController {
@Parameter(name = "ids", description = "要克隆的数据ID", required = true) @Parameter(name = "ids", description = "要克隆的数据ID", required = true)
@Parameter(name = "deptId", description = "目标组织架构ID", required = true) @Parameter(name = "deptId", description = "目标组织架构ID", required = true)
@PreAuthorize("@ss.hasPermission('base:department-material:clone')") @PreAuthorize("@ss.hasPermission('base:department-material:clone')")
@Transactional @Transactional(rollbackFor = Exception.class)
public CommonResult<Boolean> getDepartmentMaterial(@RequestBody DepartmentMaterialCloneReqVO req) { public CommonResult<Boolean> getDepartmentMaterial(@RequestBody DepartmentMaterialCloneReqVO req) {
List<DepartmentMaterialRespVO> list = departmentMaterialService.getDepartmentMaterialByIds(req.getIds()); List<DepartmentMaterialRespVO> list = departmentMaterialService.getDepartmentMaterialByIds(req.getIds());
for (DepartmentMaterialRespVO departmentMaterial : list) { for (DepartmentMaterialRespVO departmentMaterial : list) {

View File

@@ -87,6 +87,7 @@ public class MaterialHasPropertiesController {
@Operation(summary = "获得物料持有属性分页") @Operation(summary = "获得物料持有属性分页")
@PreAuthorize("@ss.hasPermission('base:material-has-properties:query')") @PreAuthorize("@ss.hasPermission('base:material-has-properties:query')")
public CommonResult<PageResult<MaterialHasPropertiesRespVO>> getMaterialHasPropertiesPage(@Valid MaterialHasPropertiesPageReqVO pageReqVO) { public CommonResult<PageResult<MaterialHasPropertiesRespVO>> getMaterialHasPropertiesPage(@Valid MaterialHasPropertiesPageReqVO pageReqVO) {
pageReqVO.setDeptId(null);
PageResult<MaterialHasPropertiesDO> pageResult = materialHasPropertiesService.getMaterialHasPropertiesPage(pageReqVO); PageResult<MaterialHasPropertiesDO> pageResult = materialHasPropertiesService.getMaterialHasPropertiesPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, MaterialHasPropertiesRespVO.class)); return success(BeanUtils.toBean(pageResult, MaterialHasPropertiesRespVO.class));
} }
@@ -95,7 +96,7 @@ public class MaterialHasPropertiesController {
@Operation(summary = "批量保存物料持有属性(全量替换)") @Operation(summary = "批量保存物料持有属性(全量替换)")
@PreAuthorize("@ss.hasPermission('base:material-has-properties:update')") @PreAuthorize("@ss.hasPermission('base:material-has-properties:update')")
public CommonResult<MaterialHasPropertiesBatchSaveRespVO> batchSave(@Valid @RequestBody MaterialHasPropertiesBatchSaveReqVO reqVO) { public CommonResult<MaterialHasPropertiesBatchSaveRespVO> batchSave(@Valid @RequestBody MaterialHasPropertiesBatchSaveReqVO reqVO) {
MaterialHasPropertiesBatchSaveRespVO resp = materialHasPropertiesService.batchSave(reqVO); MaterialHasPropertiesBatchSaveRespVO resp = materialHasPropertiesService.batchSave(reqVO, null);
return success(resp); return success(resp);
} }

View File

@@ -0,0 +1,61 @@
package com.zt.plat.module.base.controller.admin.materialhasproperties;
import com.zt.plat.framework.common.exception.ServiceException;
import com.zt.plat.framework.common.pojo.CommonResult;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.module.base.controller.admin.materialhasproperties.vo.MaterialHasPropertiesBatchSaveReqVO;
import com.zt.plat.module.base.controller.admin.materialhasproperties.vo.MaterialHasPropertiesBatchSaveRespVO;
import com.zt.plat.module.base.controller.admin.materialhasproperties.vo.MaterialHasPropertiesPageReqVO;
import com.zt.plat.module.base.controller.admin.materialhasproperties.vo.MaterialHasPropertiesRespVO;
import com.zt.plat.module.base.dal.dataobject.materialhasproperties.MaterialHasPropertiesDO;
import com.zt.plat.module.base.service.materialhasproperties.MaterialHasPropertiesService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
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("/base/material-has-properties-dept")
@Validated
public class MaterialHasPropertiesDeptController {
@Resource
private MaterialHasPropertiesService materialHasPropertiesService;
@GetMapping("/page")
@Operation(summary = "获得物料持有属性分页")
@PreAuthorize("@ss.hasPermission('base:material-has-properties-dept:query')")
public CommonResult<PageResult<MaterialHasPropertiesRespVO>> getMaterialHasPropertiesPage(@Valid MaterialHasPropertiesPageReqVO pageReqVO) {
Long deptId = pageReqVO.getDeptId();
if (deptId == null) {
throw new ServiceException(401, "部门ID不能为空");
}
PageResult<MaterialHasPropertiesDO> pageResult = materialHasPropertiesService.getMaterialHasPropertiesPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, MaterialHasPropertiesRespVO.class));
}
@PostMapping("/batch-save")
@Operation(summary = "批量保存物料持有属性(全量替换)")
@PreAuthorize("@ss.hasPermission('base:material-has-properties-dept:update')")
public CommonResult<MaterialHasPropertiesBatchSaveRespVO> batchSave(@Valid @RequestBody MaterialHasPropertiesBatchSaveReqVO reqVO) {
Long deptId = reqVO.getDeptId();
if (deptId == null) {
throw new ServiceException(401, "部门ID不能为空");
}
MaterialHasPropertiesBatchSaveRespVO resp = materialHasPropertiesService.batchSave(reqVO, deptId);
return success(resp);
}
}

View File

@@ -29,4 +29,5 @@ public class MaterialHasPropertiesBatchItemReqVO {
@Schema(description = "排序号") @Schema(description = "排序号")
private Long sort; private Long sort;
} }

View File

@@ -19,4 +19,7 @@ public class MaterialHasPropertiesBatchSaveReqVO {
@Schema(description = "属性列表", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "属性列表", requiredMode = Schema.RequiredMode.REQUIRED)
@Valid @Valid
private List<MaterialHasPropertiesBatchItemReqVO> properties = new ArrayList<>(); private List<MaterialHasPropertiesBatchItemReqVO> properties = new ArrayList<>();
@Schema(description = "部门ID,私有属性有值,通用属性无值")
private Long deptId;
} }

View File

@@ -38,4 +38,9 @@ public class MaterialHasPropertiesPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime; private LocalDateTime[] createTime;
@Schema(description = "部门ID,私有属性有值,通用属性无值")
private Long deptId;
} }

View File

@@ -1,7 +1,5 @@
package com.zt.plat.module.base.controller.admin.materialproperties; package com.zt.plat.module.base.controller.admin.materialproperties;
import com.zt.plat.framework.common.util.object.BeanUtils;
import com.zt.plat.module.base.dal.dataobject.materialproperties.MaterialPropertiesDO;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@@ -45,6 +43,7 @@ public class MaterialPropertiesController {
@Operation(summary = "创建物料属性") @Operation(summary = "创建物料属性")
@PreAuthorize("@ss.hasPermission('base:material-properties:create')") @PreAuthorize("@ss.hasPermission('base:material-properties:create')")
public CommonResult<MaterialPropertiesRespVO> createMaterialProperties(@Valid @RequestBody MaterialPropertiesSaveReqVO createReqVO) { public CommonResult<MaterialPropertiesRespVO> createMaterialProperties(@Valid @RequestBody MaterialPropertiesSaveReqVO createReqVO) {
createReqVO.setDeptId(null);
return success(materialPropertiesService.createMaterialProperties(createReqVO)); return success(materialPropertiesService.createMaterialProperties(createReqVO));
} }
@@ -52,6 +51,7 @@ public class MaterialPropertiesController {
@Operation(summary = "更新物料属性") @Operation(summary = "更新物料属性")
@PreAuthorize("@ss.hasPermission('base:material-properties:update')") @PreAuthorize("@ss.hasPermission('base:material-properties:update')")
public CommonResult<Boolean> updateMaterialProperties(@Valid @RequestBody MaterialPropertiesSaveReqVO updateReqVO) { public CommonResult<Boolean> updateMaterialProperties(@Valid @RequestBody MaterialPropertiesSaveReqVO updateReqVO) {
updateReqVO.setDeptId(null);
materialPropertiesService.updateMaterialProperties(updateReqVO); materialPropertiesService.updateMaterialProperties(updateReqVO);
return success(true); return success(true);
} }
@@ -80,6 +80,9 @@ public class MaterialPropertiesController {
@PreAuthorize("@ss.hasPermission('base:material-properties:query')") @PreAuthorize("@ss.hasPermission('base:material-properties:query')")
public CommonResult<MaterialPropertiesRespVO> getMaterialProperties(@RequestParam("id") Long id) { public CommonResult<MaterialPropertiesRespVO> getMaterialProperties(@RequestParam("id") Long id) {
MaterialPropertiesRespVO materialProperties = materialPropertiesService.getMaterialProperties(id); MaterialPropertiesRespVO materialProperties = materialPropertiesService.getMaterialProperties(id);
if (materialProperties.getDeptId() != null) {
return CommonResult.error(401, "没有权限");
}
return success(materialProperties); return success(materialProperties);
} }
@@ -87,6 +90,7 @@ public class MaterialPropertiesController {
@Operation(summary = "获得物料属性分页") @Operation(summary = "获得物料属性分页")
@PreAuthorize("@ss.hasPermission('base:material-properties:query')") @PreAuthorize("@ss.hasPermission('base:material-properties:query')")
public CommonResult<PageResult<MaterialPropertiesRespVO>> getMaterialPropertiesPage(@Valid MaterialPropertiesPageReqVO pageReqVO) { public CommonResult<PageResult<MaterialPropertiesRespVO>> getMaterialPropertiesPage(@Valid MaterialPropertiesPageReqVO pageReqVO) {
pageReqVO.setDeptId(null);
PageResult<MaterialPropertiesRespVO> pageResult = materialPropertiesService.getMaterialPropertiesPage(pageReqVO); PageResult<MaterialPropertiesRespVO> pageResult = materialPropertiesService.getMaterialPropertiesPage(pageReqVO);
return success(pageResult); return success(pageResult);
} }
@@ -95,6 +99,7 @@ public class MaterialPropertiesController {
@Operation(summary = "获得物料属性精简分页") @Operation(summary = "获得物料属性精简分页")
@PreAuthorize("@ss.hasPermission('base:material-properties:query')") @PreAuthorize("@ss.hasPermission('base:material-properties:query')")
public CommonResult<PageResult<MaterialPropertiesSimpleRespVO>> getMaterialPropertiesSimplePage(@Valid MaterialPropertiesSimplePageReqVO pageReqVO) { public CommonResult<PageResult<MaterialPropertiesSimpleRespVO>> getMaterialPropertiesSimplePage(@Valid MaterialPropertiesSimplePageReqVO pageReqVO) {
pageReqVO.setDeptId(null);
return success(materialPropertiesService.getMaterialPropertiesSimplePage(pageReqVO)); return success(materialPropertiesService.getMaterialPropertiesSimplePage(pageReqVO));
} }
@@ -105,7 +110,8 @@ public class MaterialPropertiesController {
public void exportMaterialPropertiesExcel(@Valid MaterialPropertiesPageReqVO pageReqVO, public void exportMaterialPropertiesExcel(@Valid MaterialPropertiesPageReqVO pageReqVO,
HttpServletResponse response) throws IOException { HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<MaterialPropertiesRespVO> list = materialPropertiesService.getMaterialPropertiesPage(pageReqVO).getList(); pageReqVO.setDeptId(null);
List<MaterialPropertiesRespVO> list = materialPropertiesService.getMaterialPropertiesPage(pageReqVO).getList();
// 导出 Excel // 导出 Excel
ExcelUtils.write(response, "物料属性.xls", "数据", MaterialPropertiesRespVO.class, ExcelUtils.write(response, "物料属性.xls", "数据", MaterialPropertiesRespVO.class,
list); list);

View File

@@ -0,0 +1,142 @@
package com.zt.plat.module.base.controller.admin.materialproperties;
import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
import com.zt.plat.framework.common.exception.ServiceException;
import com.zt.plat.framework.common.pojo.CommonResult;
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.excel.core.util.ExcelUtils;
import com.zt.plat.module.base.controller.admin.departmentmaterial.vo.DepartmentMaterialRespVO;
import com.zt.plat.module.base.controller.admin.materialproperties.vo.MaterialPropertiesPageReqVO;
import com.zt.plat.module.base.controller.admin.materialproperties.vo.MaterialPropertiesRespVO;
import com.zt.plat.module.base.controller.admin.materialproperties.vo.MaterialPropertiesSaveReqVO;
import com.zt.plat.module.base.controller.admin.materialproperties.vo.MaterialPropertiesSimplePageReqVO;
import com.zt.plat.module.base.controller.admin.materialproperties.vo.MaterialPropertiesSimpleRespVO;
import com.zt.plat.module.base.service.departmentmaterial.DepartmentMaterialService;
import com.zt.plat.module.base.service.materialproperties.MaterialPropertiesService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.List;
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static com.zt.plat.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 部门私有物料属性")
@RestController
@RequestMapping("/base/material-properties-dept")
@Validated
public class MaterialPropertiesDeptController {
@Resource
private MaterialPropertiesService materialPropertiesService;
@Resource
private DepartmentMaterialService departmentMaterialService;
@PostMapping("/create")
@Operation(summary = "创建物料属性")
@PreAuthorize("@ss.hasPermission('base:material-properties-dept:create')")
public CommonResult<MaterialPropertiesRespVO> createMaterialProperties(@Valid @RequestBody MaterialPropertiesSaveReqVO createReqVO) {
if (createReqVO.getDeptId() == null) {
throw new ServiceException(401, "部门ID不能为空");
}
return success(materialPropertiesService.createMaterialProperties(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新物料属性")
@PreAuthorize("@ss.hasPermission('base:material-properties-dept:update')")
public CommonResult<Boolean> updateMaterialProperties(@Valid @RequestBody MaterialPropertiesSaveReqVO updateReqVO) {
if (updateReqVO.getDeptId() == null) {
throw new ServiceException(401, "部门ID不能为空");
}
materialPropertiesService.updateMaterialProperties(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除物料属性")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('base:material-properties-dept:delete')")
public CommonResult<Boolean> deleteMaterialProperties(@RequestParam("id") Long id) {
materialPropertiesService.deleteMaterialProperties(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除物料属性")
@PreAuthorize("@ss.hasPermission('base:material-properties-dept:delete')")
public CommonResult<Boolean> deleteMaterialPropertiesList(@RequestBody BatchDeleteReqVO req) {
materialPropertiesService.deleteMaterialPropertiesListByIds(req.getIds());
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得物料属性")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('base:material-properties-dept:query')")
public CommonResult<MaterialPropertiesRespVO> getMaterialProperties(@RequestParam("id") Long id) {
MaterialPropertiesRespVO materialProperties = materialPropertiesService.getMaterialProperties(id);
if (materialProperties.getDeptId() == null) {
throw new ServiceException(401, "没有权限");
}
return success(materialProperties);
}
@GetMapping("/page")
@Operation(summary = "获得物料属性分页")
@PreAuthorize("@ss.hasPermission('base:material-properties-dept:query')")
public CommonResult<PageResult<MaterialPropertiesRespVO>> getMaterialPropertiesPage(@Valid MaterialPropertiesPageReqVO pageReqVO) {
if (pageReqVO.getDeptId() == null) {
throw new ServiceException(401, "部门ID不能为空");
}
PageResult<MaterialPropertiesRespVO> pageResult = materialPropertiesService.getMaterialPropertiesPage(pageReqVO);
return success(pageResult);
}
@GetMapping("/simple-page")
@Operation(summary = "获得物料属性精简分页")
@PreAuthorize("@ss.hasPermission('base:material-properties-dept:query')")
public CommonResult<PageResult<MaterialPropertiesSimpleRespVO>> getMaterialPropertiesSimplePage(@Valid MaterialPropertiesSimplePageReqVO pageReqVO) {
if (pageReqVO.getDeptId() == null) {
throw new ServiceException(401, "部门ID不能为空");
}
return success(materialPropertiesService.getMaterialPropertiesSimplePage(pageReqVO));
}
@GetMapping("/export-excel")
@Operation(summary = "导出物料属性 Excel")
@PreAuthorize("@ss.hasPermission('base:material-properties-dept:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportMaterialPropertiesExcel(@Valid MaterialPropertiesPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
if (pageReqVO.getDeptId() == null) {
throw new ServiceException(401, "部门ID不能为空");
}
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<MaterialPropertiesRespVO> list = materialPropertiesService.getMaterialPropertiesPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "物料属性.xls", "数据", MaterialPropertiesRespVO.class,
list);
}
}

View File

@@ -38,4 +38,7 @@ public class MaterialPropertiesPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime; private LocalDateTime[] createTime;
@Schema(description = "部门ID,私有属性有值,通用属性无值")
private Long deptId;
} }

View File

@@ -60,4 +60,7 @@ public class MaterialPropertiesRespVO {
@ExcelProperty("创建时间") @ExcelProperty("创建时间")
private LocalDateTime createTime; private LocalDateTime createTime;
@Schema(description = "部门ID,私有属性有值,通用属性无值")
private Long deptId;
} }

View File

@@ -35,4 +35,7 @@ public class MaterialPropertiesSaveReqVO {
@NotEmpty(message = "备注不能为空") @NotEmpty(message = "备注不能为空")
private String remark; private String remark;
@Schema(description = "部门ID,私有属性有值,通用属性无值")
private Long deptId;
} }

View File

@@ -13,4 +13,7 @@ public class MaterialPropertiesSimplePageReqVO extends PageParam {
@Schema(description = "属性类型") @Schema(description = "属性类型")
private String dictionaryDataValue; private String dictionaryDataValue;
@Schema(description = "部门ID,私有属性有值,通用属性无值")
private Long deptId;
} }

View File

@@ -18,7 +18,7 @@ import com.zt.plat.module.base.controller.admin.materialhasproperties.vo.*;
public interface MaterialHasPropertiesMapper extends BaseMapperX<MaterialHasPropertiesDO> { public interface MaterialHasPropertiesMapper extends BaseMapperX<MaterialHasPropertiesDO> {
default PageResult<MaterialHasPropertiesDO> selectPage(MaterialHasPropertiesPageReqVO reqVO) { default PageResult<MaterialHasPropertiesDO> selectPage(MaterialHasPropertiesPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<MaterialHasPropertiesDO>() LambdaQueryWrapperX<MaterialHasPropertiesDO> query = new LambdaQueryWrapperX<MaterialHasPropertiesDO>()
.eqIfPresent(MaterialHasPropertiesDO::getInfomationId, reqVO.getInfomationId()) .eqIfPresent(MaterialHasPropertiesDO::getInfomationId, reqVO.getInfomationId())
.eqIfPresent(MaterialHasPropertiesDO::getPropertiesId, reqVO.getPropertiesId()) .eqIfPresent(MaterialHasPropertiesDO::getPropertiesId, reqVO.getPropertiesId())
.eqIfPresent(MaterialHasPropertiesDO::getUnitId, reqVO.getUnitId()) .eqIfPresent(MaterialHasPropertiesDO::getUnitId, reqVO.getUnitId())
@@ -27,7 +27,13 @@ public interface MaterialHasPropertiesMapper extends BaseMapperX<MaterialHasProp
.eqIfPresent(MaterialHasPropertiesDO::getIsMetering, reqVO.getIsMetering()) .eqIfPresent(MaterialHasPropertiesDO::getIsMetering, reqVO.getIsMetering())
.eqIfPresent(MaterialHasPropertiesDO::getSort, reqVO.getSort()) .eqIfPresent(MaterialHasPropertiesDO::getSort, reqVO.getSort())
.betweenIfPresent(MaterialHasPropertiesDO::getCreateTime, reqVO.getCreateTime()) .betweenIfPresent(MaterialHasPropertiesDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(MaterialHasPropertiesDO::getId)); .orderByDesc(MaterialHasPropertiesDO::getId);
if (reqVO.getDeptId() == null) {
query.isNull(MaterialHasPropertiesDO::getDeptId);
} else {
query.eq(MaterialHasPropertiesDO::getDeptId, reqVO.getDeptId());
}
return selectPage(reqVO, query);
} }
default List<MaterialHasPropertiesDO> selectByInfoIdsAndPropertyIds(Collection<Long> infoIds, Collection<Long> propertyIds) { default List<MaterialHasPropertiesDO> selectByInfoIdsAndPropertyIds(Collection<Long> infoIds, Collection<Long> propertyIds) {

View File

@@ -30,6 +30,11 @@ public interface MaterialPropertiesMapper extends BaseMapperX<MaterialProperties
.eqIfPresent(MaterialPropertiesDO::getDataType, reqVO.getDataType()) .eqIfPresent(MaterialPropertiesDO::getDataType, reqVO.getDataType())
.eqIfPresent(MaterialPropertiesDO::getRemark, reqVO.getRemark()) .eqIfPresent(MaterialPropertiesDO::getRemark, reqVO.getRemark())
.betweenIfPresent(MaterialPropertiesDO::getCreateTime, reqVO.getCreateTime()); .betweenIfPresent(MaterialPropertiesDO::getCreateTime, reqVO.getCreateTime());
if (reqVO.getDeptId() == null) {
query.isNull(MaterialPropertiesDO::getDeptId);
} else {
query.eq(MaterialPropertiesDO::getDeptId, reqVO.getDeptId());
}
if (StrUtil.isNotBlank(reqVO.getKeyword())) { if (StrUtil.isNotBlank(reqVO.getKeyword())) {
query.and(w -> w.like(MaterialPropertiesDO::getCode, reqVO.getKeyword()) query.and(w -> w.like(MaterialPropertiesDO::getCode, reqVO.getKeyword())
.or() .or()
@@ -40,13 +45,18 @@ public interface MaterialPropertiesMapper extends BaseMapperX<MaterialProperties
} }
default PageResult<MaterialPropertiesDO> selectSimplePage(MaterialPropertiesSimplePageReqVO reqVO) { default PageResult<MaterialPropertiesDO> selectSimplePage(MaterialPropertiesSimplePageReqVO reqVO) {
LambdaQueryWrapperX<MaterialPropertiesDO> query = new LambdaQueryWrapperX<MaterialPropertiesDO>() LambdaQueryWrapperX<MaterialPropertiesDO> query = new LambdaQueryWrapperX<MaterialPropertiesDO>()
.eqIfPresent(MaterialPropertiesDO::getDictionaryDataValue, reqVO.getDictionaryDataValue()); .eqIfPresent(MaterialPropertiesDO::getDictionaryDataValue, reqVO.getDictionaryDataValue());
if (StrUtil.isNotBlank(reqVO.getKeyword())) { if (StrUtil.isNotBlank(reqVO.getKeyword())) {
query.and(w -> w.like(MaterialPropertiesDO::getCode, reqVO.getKeyword()) query.and(w -> w.like(MaterialPropertiesDO::getCode, reqVO.getKeyword())
.or() .or()
.like(MaterialPropertiesDO::getName, reqVO.getKeyword())); .like(MaterialPropertiesDO::getName, reqVO.getKeyword()));
} }
if (reqVO.getDeptId() == null) {
query.isNull(MaterialPropertiesDO::getDeptId);
} else {
query.eq(MaterialPropertiesDO::getDeptId, reqVO.getDeptId());
}
query.orderByAsc(MaterialPropertiesDO::getCode); query.orderByAsc(MaterialPropertiesDO::getCode);
return selectPage(reqVO, query); return selectPage(reqVO, query);
} }

View File

@@ -67,4 +67,9 @@ public class MaterialHasPropertiesDO extends BaseDO {
@TableField("SRT") @TableField("SRT")
private Long sort; private Long sort;
/**
* 部门ID,私有属性有值,通用属性无值
*/
@TableField("DEPT_ID")
private Long deptId;
} }

View File

@@ -62,4 +62,10 @@ public class MaterialPropertiesDO extends BaseDO {
@TableField("RMK") @TableField("RMK")
private String remark; private String remark;
/**
* 部门ID,如果为空则表示通用属性,不为空则是对应部门的私有属性
*/
@TableField("DEPT_ID")
private Long deptId;
} }

View File

@@ -64,6 +64,6 @@ public interface MaterialHasPropertiesService {
* @param batchReqVO 请求参数 * @param batchReqVO 请求参数
* @return 行级校验错误(为空表示成功) * @return 行级校验错误(为空表示成功)
*/ */
MaterialHasPropertiesBatchSaveRespVO batchSave(MaterialHasPropertiesBatchSaveReqVO batchReqVO); MaterialHasPropertiesBatchSaveRespVO batchSave(MaterialHasPropertiesBatchSaveReqVO batchReqVO, Long deptId);
} }

View File

@@ -106,7 +106,7 @@ public class MaterialHasPropertiesServiceImpl implements MaterialHasPropertiesSe
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public MaterialHasPropertiesBatchSaveRespVO batchSave(MaterialHasPropertiesBatchSaveReqVO batchReqVO) { public MaterialHasPropertiesBatchSaveRespVO batchSave(MaterialHasPropertiesBatchSaveReqVO batchReqVO, Long deptId) {
MaterialHasPropertiesBatchSaveRespVO resp = new MaterialHasPropertiesBatchSaveRespVO(); MaterialHasPropertiesBatchSaveRespVO resp = new MaterialHasPropertiesBatchSaveRespVO();
Long infoId = batchReqVO.getInfomationId(); Long infoId = batchReqVO.getInfomationId();
if (infoId == null) { if (infoId == null) {
@@ -163,6 +163,7 @@ public class MaterialHasPropertiesServiceImpl implements MaterialHasPropertiesSe
.isKey(item.getIsKey()) .isKey(item.getIsKey())
.isMetering(item.getIsMetering()) .isMetering(item.getIsMetering())
.sort(item.getSort() == null ? (long) (i + 1) : item.getSort()) .sort(item.getSort() == null ? (long) (i + 1) : item.getSort())
.deptId(deptId)
.build(); .build();
materialHasPropertiesMapper.insert(entity); materialHasPropertiesMapper.insert(entity);
} }

View File

@@ -70,7 +70,7 @@ class MaterialHasPropertiesServiceImplTest extends BaseDbUnitTest {
req.setInfomationId(infoId); req.setInfomationId(infoId);
req.setProperties(CollUtil.newArrayList(item1, item2, itemDuplicate)); req.setProperties(CollUtil.newArrayList(item1, item2, itemDuplicate));
MaterialHasPropertiesBatchSaveRespVO resp = materialHasPropertiesService.batchSave(req); MaterialHasPropertiesBatchSaveRespVO resp = materialHasPropertiesService.batchSave(req, null);
assertThat(resp.getRowErrors()).isEmpty(); assertThat(resp.getRowErrors()).isEmpty();
@@ -94,7 +94,7 @@ class MaterialHasPropertiesServiceImplTest extends BaseDbUnitTest {
@Test @Test
void batchSave_missingInfoId_shouldReturnErrorAndSkipInsert() { void batchSave_missingInfoId_shouldReturnErrorAndSkipInsert() {
MaterialHasPropertiesBatchSaveReqVO req = new MaterialHasPropertiesBatchSaveReqVO(); MaterialHasPropertiesBatchSaveReqVO req = new MaterialHasPropertiesBatchSaveReqVO();
MaterialHasPropertiesBatchSaveRespVO resp = materialHasPropertiesService.batchSave(req); MaterialHasPropertiesBatchSaveRespVO resp = materialHasPropertiesService.batchSave(req, null);
assertThat(resp.getRowErrors()).hasSize(1); assertThat(resp.getRowErrors()).hasSize(1);
RowValidationErrorVO error = resp.getRowErrors().get(0); RowValidationErrorVO error = resp.getRowErrors().get(0);
@@ -112,7 +112,7 @@ class MaterialHasPropertiesServiceImplTest extends BaseDbUnitTest {
req.setInfomationId(infoId); req.setInfomationId(infoId);
req.setProperties(List.of()); req.setProperties(List.of());
MaterialHasPropertiesBatchSaveRespVO resp = materialHasPropertiesService.batchSave(req); MaterialHasPropertiesBatchSaveRespVO resp = materialHasPropertiesService.batchSave(req, null);
assertThat(resp.getRowErrors()).isEmpty(); assertThat(resp.getRowErrors()).isEmpty();
List<MaterialHasPropertiesDO> current = materialHasPropertiesMapper.selectList(new QueryWrapper<MaterialHasPropertiesDO>() List<MaterialHasPropertiesDO> current = materialHasPropertiesMapper.selectList(new QueryWrapper<MaterialHasPropertiesDO>()
@@ -132,7 +132,7 @@ class MaterialHasPropertiesServiceImplTest extends BaseDbUnitTest {
req.setInfomationId(infoId); req.setInfomationId(infoId);
req.setProperties(List.of(item)); req.setProperties(List.of(item));
MaterialHasPropertiesBatchSaveRespVO resp = materialHasPropertiesService.batchSave(req); MaterialHasPropertiesBatchSaveRespVO resp = materialHasPropertiesService.batchSave(req, null);
assertThat(resp.getRowErrors()).hasSize(1); assertThat(resp.getRowErrors()).hasSize(1);
RowValidationErrorVO error = resp.getRowErrors().get(0); RowValidationErrorVO error = resp.getRowErrors().get(0);