Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -1,13 +1,23 @@
|
|||||||
FROM 172.16.46.66:10043/base-service/eclipse-temurin:21-jre
|
ARG BASE_IMAGE=172.16.46.66:10043/base-service/skywalking-agent-jre:9.7.0
|
||||||
|
FROM ${BASE_IMAGE}
|
||||||
|
|
||||||
# 设置应用目录
|
# 设置应用目录
|
||||||
|
RUN mkdir -p /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# 复制应用文件
|
# 复制应用文件
|
||||||
COPY target/base-server.jar /app/base-server.jar
|
COPY target/base-server.jar app.jar
|
||||||
|
|
||||||
|
# 设置环境变量
|
||||||
|
ENV TZ=Asia/Shanghai
|
||||||
|
ENV JAVA_OPTS="-Xms512m -Xmx512m"
|
||||||
|
ENV SW_AGENT_HOME=/opt/skywalking/agent
|
||||||
|
ENV SW_AGENT_NAME=base-server
|
||||||
|
ENV SW_AGENT_COLLECTOR_BACKEND_SERVICES=172.16.46.63:30201
|
||||||
|
ENV AGENT_JAVA_OPTS="-javaagent:${SW_AGENT_HOME}/skywalking-agent.jar -Dskywalking.agent.service_name=${SW_AGENT_NAME} -Dskywalking.collector.backend_service=${SW_AGENT_COLLECTOR_BACKEND_SERVICES}"
|
||||||
|
|
||||||
# 暴露端口
|
# 暴露端口
|
||||||
EXPOSE 48200
|
EXPOSE 48200
|
||||||
|
|
||||||
# 运行应用
|
# 运行应用
|
||||||
ENTRYPOINT ["java", "-jar", "/app/base-server.jar"]
|
CMD java ${AGENT_JAVA_OPTS} ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar app.jar
|
||||||
|
|||||||
@@ -53,6 +53,12 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode DEPARTMENT_MATERIAL_NOT_EXISTS = new ErrorCode(1_027_101_004, "组织物料不存在");
|
ErrorCode DEPARTMENT_MATERIAL_NOT_EXISTS = new ErrorCode(1_027_101_004, "组织物料不存在");
|
||||||
ErrorCode MATERIAL_HAS_CLASSES_NOT_EXISTS = new ErrorCode(1_027_101_004, "物料持有属性不存在");
|
ErrorCode MATERIAL_HAS_CLASSES_NOT_EXISTS = new ErrorCode(1_027_101_004, "物料持有属性不存在");
|
||||||
|
|
||||||
|
ErrorCode MATERIAL_CLASSES_HIERARCHY_INVALID = new ErrorCode(1_027_101_101, "物料分类层级不符合 1-2-3 的层级规则");
|
||||||
|
ErrorCode MATERIAL_CLASSES_PARENT_NOT_EXISTS = new ErrorCode(1_027_101_102, "上级物料分类不存在");
|
||||||
|
ErrorCode MATERIAL_CLASSES_MAX_LEVEL_EXCEEDED = new ErrorCode(1_027_101_103, "物料分类最多支持三级");
|
||||||
|
ErrorCode MATERIAL_CLASSES_LEVEL_CONFLICT_WITH_CHILDREN = new ErrorCode(1_027_101_104, "存在下级分类,无法调整当前分类层级");
|
||||||
|
ErrorCode MATERIAL_CLASSES_LEVEL3_REQUIRED_FOR_MATERIAL = new ErrorCode(1_027_101_105, "仅允许三级物料分类关联物料");
|
||||||
|
|
||||||
// ========== 工艺信息属性 ==========
|
// ========== 工艺信息属性 ==========
|
||||||
ErrorCode PROCESSING_INFOMATION_NOT_EXISTS = new ErrorCode(1_027_101_005, "工艺信息不存在");
|
ErrorCode PROCESSING_INFOMATION_NOT_EXISTS = new ErrorCode(1_027_101_005, "工艺信息不存在");
|
||||||
ErrorCode PROCESSING_INFOMATION_OPERATION_NOT_EXISTS = new ErrorCode(1_027_101_006, "工艺工序不存在");
|
ErrorCode PROCESSING_INFOMATION_OPERATION_NOT_EXISTS = new ErrorCode(1_027_101_006, "工艺工序不存在");
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ import com.zt.plat.framework.common.pojo.CommonResult;
|
|||||||
import com.zt.plat.framework.common.pojo.PageParam;
|
import com.zt.plat.framework.common.pojo.PageParam;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
|
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
|
||||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
|
||||||
import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
||||||
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationPageReqVO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationPageReqVO;
|
||||||
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationRespVO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationRespVO;
|
||||||
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSaveReqVO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSaveReqVO;
|
||||||
import com.zt.plat.module.base.dal.dataobject.base.MaterialInfomationDO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSimplePageReqVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSimpleRespVO;
|
||||||
import com.zt.plat.module.base.service.base.MaterialInfomationService;
|
import com.zt.plat.module.base.service.base.MaterialInfomationService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
@@ -76,16 +76,23 @@ public class MaterialInfomationController {
|
|||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('base:material-infomation:query')")
|
@PreAuthorize("@ss.hasPermission('base:material-infomation:query')")
|
||||||
public CommonResult<MaterialInfomationRespVO> getMaterialInfomation(@RequestParam("id") Long id) {
|
public CommonResult<MaterialInfomationRespVO> getMaterialInfomation(@RequestParam("id") Long id) {
|
||||||
MaterialInfomationDO materialInfomation = materialInfomationService.getMaterialInfomation(id);
|
MaterialInfomationRespVO materialInfomation = materialInfomationService.getMaterialInfomation(id);
|
||||||
return success(BeanUtils.toBean(materialInfomation, MaterialInfomationRespVO.class));
|
return success(materialInfomation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@Operation(summary = "获得物料信息分页")
|
@Operation(summary = "获得物料信息分页")
|
||||||
@PreAuthorize("@ss.hasPermission('base:material-infomation:query')")
|
@PreAuthorize("@ss.hasPermission('base:material-infomation:query')")
|
||||||
public CommonResult<PageResult<MaterialInfomationRespVO>> getMaterialInfomationPage(@Valid MaterialInfomationPageReqVO pageReqVO) {
|
public CommonResult<PageResult<MaterialInfomationRespVO>> getMaterialInfomationPage(@Valid MaterialInfomationPageReqVO pageReqVO) {
|
||||||
PageResult<MaterialInfomationDO> pageResult = materialInfomationService.getMaterialInfomationPage(pageReqVO);
|
PageResult<MaterialInfomationRespVO> pageResult = materialInfomationService.getMaterialInfomationPage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, MaterialInfomationRespVO.class));
|
return success(pageResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/simple-page")
|
||||||
|
@Operation(summary = "获得物料信息精简分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('base:material-infomation:query')")
|
||||||
|
public CommonResult<PageResult<MaterialInfomationSimpleRespVO>> getMaterialInfomationSimplePage(@Valid MaterialInfomationSimplePageReqVO pageReqVO) {
|
||||||
|
return success(materialInfomationService.getMaterialInfomationSimplePage(pageReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/export-excel")
|
@GetMapping("/export-excel")
|
||||||
@@ -95,10 +102,10 @@ public class MaterialInfomationController {
|
|||||||
public void exportMaterialInfomationExcel(@Valid MaterialInfomationPageReqVO pageReqVO,
|
public void exportMaterialInfomationExcel(@Valid MaterialInfomationPageReqVO pageReqVO,
|
||||||
HttpServletResponse response) throws IOException {
|
HttpServletResponse response) throws IOException {
|
||||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
List<MaterialInfomationDO> list = materialInfomationService.getMaterialInfomationPage(pageReqVO).getList();
|
List<MaterialInfomationRespVO> list = materialInfomationService.getMaterialInfomationPage(pageReqVO).getList();
|
||||||
// 导出 Excel
|
// 导出 Excel
|
||||||
ExcelUtils.write(response, "物料信息.xls", "数据", MaterialInfomationRespVO.class,
|
ExcelUtils.write(response, "物料信息.xls", "数据", MaterialInfomationRespVO.class,
|
||||||
BeanUtils.toBean(list, MaterialInfomationRespVO.class));
|
list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/getOneTest")
|
@GetMapping("/getOneTest")
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.zt.plat.module.base.controller.admin.base.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import com.zt.plat.framework.common.pojo.PageParam;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料信息精简分页 Request VO
|
||||||
|
*/
|
||||||
|
@Schema(description = "管理后台 - 物料信息精简分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class MaterialInfomationSimplePageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "关键字(编码/名称模糊匹配)")
|
||||||
|
private String keyword;
|
||||||
|
|
||||||
|
@Schema(description = "分类 ID")
|
||||||
|
private Long classesId;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.zt.plat.module.base.controller.admin.base.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 精简的物料信息 Response VO
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MaterialInfomationSimpleRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "物料信息ID", example = "1024")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "物料编码")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
@Schema(description = "物料名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "分类ID")
|
||||||
|
private Long classesId;
|
||||||
|
|
||||||
|
@Schema(description = "备注")
|
||||||
|
private String remark;
|
||||||
|
}
|
||||||
@@ -116,4 +116,12 @@ public class BusinessDictionaryTypeController implements BusinessControllerMarke
|
|||||||
return success(businessDictionaryTypeService.getBusinessDictionaryDataListByDictionaryTypeId(dictionaryTypeId));
|
return success(businessDictionaryTypeService.getBusinessDictionaryDataListByDictionaryTypeId(dictionaryTypeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/business-dictionary-data/list-by-type")
|
||||||
|
@Operation(summary = "根据字典类型编码获取业务字典数据列表")
|
||||||
|
@PreAuthorize("@ss.hasPermission('base:business-dictionary-type:query')")
|
||||||
|
public CommonResult<List<BusinessDictionaryDataDO>> getBusinessDictionaryDataListByType(@RequestParam("type") String type) {
|
||||||
|
// 通过类型编码直接获取对应的业务字典项,避免前端重复查询字典类型 ID
|
||||||
|
return success(businessDictionaryTypeService.getBusinessDictionaryDataListByType(type));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,6 @@ import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
|
|||||||
import com.zt.plat.framework.common.pojo.PageParam;
|
import com.zt.plat.framework.common.pojo.PageParam;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
|
||||||
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
||||||
@@ -79,8 +78,8 @@ public class DepartmentMaterialController {
|
|||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('base:department-material:query')")
|
@PreAuthorize("@ss.hasPermission('base:department-material:query')")
|
||||||
public CommonResult<DepartmentMaterialRespVO> getDepartmentMaterial(@RequestParam("id") Long id) {
|
public CommonResult<DepartmentMaterialRespVO> getDepartmentMaterial(@RequestParam("id") Long id) {
|
||||||
DepartmentMaterialDO departmentMaterial = departmentMaterialService.getDepartmentMaterial(id);
|
DepartmentMaterialRespVO departmentMaterial = departmentMaterialService.getDepartmentMaterial(id);
|
||||||
return success(BeanUtils.toBean(departmentMaterial, DepartmentMaterialRespVO.class));
|
return success(departmentMaterial);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ public class DepartmentMaterialPageReqVO extends PageParam {
|
|||||||
private String dictionaryDataValue;
|
private String dictionaryDataValue;
|
||||||
|
|
||||||
@Schema(description = "状态编码", example = "1")
|
@Schema(description = "状态编码", example = "1")
|
||||||
private String isEnable;
|
// 对应系统字典 base_material_status,用于前端筛选
|
||||||
|
private String status;
|
||||||
|
|
||||||
@Schema(description = "物料编码")
|
@Schema(description = "物料编码")
|
||||||
private String materialNumber;
|
private String materialNumber;
|
||||||
|
|||||||
@@ -74,10 +74,7 @@ public class DepartmentMaterialRespVO {
|
|||||||
|
|
||||||
@Schema(description = "状态编码")
|
@Schema(description = "状态编码")
|
||||||
@ExcelProperty("状态编码")
|
@ExcelProperty("状态编码")
|
||||||
private String isEnable;
|
// base_material_status 系统字典取值
|
||||||
|
private String status;
|
||||||
@Schema(description = "状态名称")
|
|
||||||
@ExcelProperty("状态")
|
|
||||||
private String statusLabel;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,10 @@ public class DepartmentMaterialSaveReqVO {
|
|||||||
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "5674")
|
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "5674")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "部门ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1001")
|
||||||
|
@NotNull(message = "部门ID不能为空")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
@Schema(description = "物料信息ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "3923")
|
@Schema(description = "物料信息ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "3923")
|
||||||
@NotNull(message = "物料信息ID不能为空")
|
@NotNull(message = "物料信息ID不能为空")
|
||||||
private Long infomationId;
|
private Long infomationId;
|
||||||
@@ -23,6 +27,11 @@ public class DepartmentMaterialSaveReqVO {
|
|||||||
@NotEmpty(message = "字典数据值-物料类型不能为空")
|
@NotEmpty(message = "字典数据值-物料类型不能为空")
|
||||||
private String dictionaryDataValue;
|
private String dictionaryDataValue;
|
||||||
|
|
||||||
|
@Schema(description = "状态编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
|
// 对应系统字典 base_material_status
|
||||||
|
@NotEmpty(message = "状态不能为空")
|
||||||
|
private String status;
|
||||||
|
|
||||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotEmpty(message = "备注不能为空")
|
@NotEmpty(message = "备注不能为空")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
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;
|
||||||
@@ -19,7 +21,6 @@ import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
|
|||||||
import com.zt.plat.framework.common.pojo.PageParam;
|
import com.zt.plat.framework.common.pojo.PageParam;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
|
||||||
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
import com.zt.plat.framework.excel.core.util.ExcelUtils;
|
||||||
@@ -28,7 +29,6 @@ import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
|
|||||||
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
|
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||||
|
|
||||||
import com.zt.plat.module.base.controller.admin.materialproperties.vo.*;
|
import com.zt.plat.module.base.controller.admin.materialproperties.vo.*;
|
||||||
import com.zt.plat.module.base.dal.dataobject.materialproperties.MaterialPropertiesDO;
|
|
||||||
import com.zt.plat.module.base.service.materialproperties.MaterialPropertiesService;
|
import com.zt.plat.module.base.service.materialproperties.MaterialPropertiesService;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 物料属性")
|
@Tag(name = "管理后台 - 物料属性")
|
||||||
@@ -79,16 +79,23 @@ public class MaterialPropertiesController {
|
|||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@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) {
|
||||||
MaterialPropertiesDO materialProperties = materialPropertiesService.getMaterialProperties(id);
|
MaterialPropertiesRespVO materialProperties = materialPropertiesService.getMaterialProperties(id);
|
||||||
return success(BeanUtils.toBean(materialProperties, MaterialPropertiesRespVO.class));
|
return success(materialProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
@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) {
|
||||||
PageResult<MaterialPropertiesDO> pageResult = materialPropertiesService.getMaterialPropertiesPage(pageReqVO);
|
PageResult<MaterialPropertiesRespVO> pageResult = materialPropertiesService.getMaterialPropertiesPage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, MaterialPropertiesRespVO.class));
|
return success(pageResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/simple-page")
|
||||||
|
@Operation(summary = "获得物料属性精简分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('base:material-properties:query')")
|
||||||
|
public CommonResult<PageResult<MaterialPropertiesSimpleRespVO>> getMaterialPropertiesSimplePage(@Valid MaterialPropertiesSimplePageReqVO pageReqVO) {
|
||||||
|
return success(materialPropertiesService.getMaterialPropertiesSimplePage(pageReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/export-excel")
|
@GetMapping("/export-excel")
|
||||||
@@ -98,10 +105,10 @@ 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<MaterialPropertiesDO> list = materialPropertiesService.getMaterialPropertiesPage(pageReqVO).getList();
|
List<MaterialPropertiesRespVO> list = materialPropertiesService.getMaterialPropertiesPage(pageReqVO).getList();
|
||||||
// 导出 Excel
|
// 导出 Excel
|
||||||
ExcelUtils.write(response, "物料属性.xls", "数据", MaterialPropertiesRespVO.class,
|
ExcelUtils.write(response, "物料属性.xls", "数据", MaterialPropertiesRespVO.class,
|
||||||
BeanUtils.toBean(list, MaterialPropertiesRespVO.class));
|
list);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -19,10 +19,13 @@ public class MaterialPropertiesPageReqVO extends PageParam {
|
|||||||
@Schema(description = "属性名称", example = "芋艿")
|
@Schema(description = "属性名称", example = "芋艿")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "关键字(编码/名称模糊匹配)")
|
||||||
|
private String keyword;
|
||||||
|
|
||||||
@Schema(description = "计量单位量ID", example = "30468")
|
@Schema(description = "计量单位量ID", example = "30468")
|
||||||
private Long unitQuantityId;
|
private Long unitQuantityId;
|
||||||
|
|
||||||
@Schema(description = "业务字典数据值")
|
@Schema(description = "属性类型")
|
||||||
private String dictionaryDataValue;
|
private String dictionaryDataValue;
|
||||||
|
|
||||||
@Schema(description = "数据类型", example = "1")
|
@Schema(description = "数据类型", example = "1")
|
||||||
|
|||||||
@@ -28,10 +28,14 @@ public class MaterialPropertiesRespVO {
|
|||||||
@ExcelProperty("计量单位量ID")
|
@ExcelProperty("计量单位量ID")
|
||||||
private Long unitQuantityId;
|
private Long unitQuantityId;
|
||||||
|
|
||||||
@Schema(description = "业务字典数据值", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "属性类型", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@ExcelProperty("业务字典数据值")
|
@ExcelProperty("属性类型")
|
||||||
private String dictionaryDataValue;
|
private String dictionaryDataValue;
|
||||||
|
|
||||||
|
@Schema(description = "属性类型名称")
|
||||||
|
@ExcelProperty("属性类型名称")
|
||||||
|
private String dictionaryDataLabel;
|
||||||
|
|
||||||
@Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
@ExcelProperty("数据类型")
|
@ExcelProperty("数据类型")
|
||||||
private String dataType;
|
private String dataType;
|
||||||
@@ -40,6 +44,18 @@ public class MaterialPropertiesRespVO {
|
|||||||
@ExcelProperty("备注")
|
@ExcelProperty("备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "量纲名称")
|
||||||
|
@ExcelProperty("量纲名称")
|
||||||
|
private String unitQuantityName;
|
||||||
|
|
||||||
|
@Schema(description = "计量单位名称")
|
||||||
|
@ExcelProperty("计量单位")
|
||||||
|
private String unitName;
|
||||||
|
|
||||||
|
@Schema(description = "计量单位符号")
|
||||||
|
@ExcelProperty("计量单位符号")
|
||||||
|
private String unitSymbol;
|
||||||
|
|
||||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@ExcelProperty("创建时间")
|
@ExcelProperty("创建时间")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ public class MaterialPropertiesSaveReqVO {
|
|||||||
@NotEmpty(message = "属性名称不能为空")
|
@NotEmpty(message = "属性名称不能为空")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Schema(description = "计量单位量ID", example = "30468")
|
@Schema(description = "计量单位量ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "30468")
|
||||||
private Long unitQuantityId;
|
private Long unitQuantityId;
|
||||||
|
|
||||||
@Schema(description = "业务字典数据值", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "属性类型(业务字典数据值)", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotEmpty(message = "业务字典数据值不能为空")
|
@NotEmpty(message = "属性类型不能为空")
|
||||||
private String dictionaryDataValue;
|
private String dictionaryDataValue;
|
||||||
|
|
||||||
@Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "数据类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.zt.plat.module.base.controller.admin.materialproperties.vo;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.PageParam;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 物料属性精简分页 Request VO")
|
||||||
|
@Data
|
||||||
|
public class MaterialPropertiesSimplePageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "关键字(编码/名称模糊匹配)")
|
||||||
|
private String keyword;
|
||||||
|
|
||||||
|
@Schema(description = "属性类型")
|
||||||
|
private String dictionaryDataValue;
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.zt.plat.module.base.controller.admin.materialproperties.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 精简的物料属性 Response VO
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class MaterialPropertiesSimpleRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "物料属性ID", example = "1001")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "属性编码")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
@Schema(description = "属性名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "数据类型")
|
||||||
|
private String dataType;
|
||||||
|
|
||||||
|
@Schema(description = "单位名称")
|
||||||
|
private String unitName;
|
||||||
|
|
||||||
|
@Schema(description = "单位符号")
|
||||||
|
private String unitSymbol;
|
||||||
|
|
||||||
|
@Schema(description = "属性类型")
|
||||||
|
private String dictionaryDataValue;
|
||||||
|
|
||||||
|
@Schema(description = "属性类型名称")
|
||||||
|
private String dictionaryDataLabel;
|
||||||
|
}
|
||||||
@@ -91,6 +91,13 @@ public class QuantityUnitRelationController implements BusinessControllerMarker
|
|||||||
return success(BeanUtils.toBean(pageResult, QuantityUnitRelationRespVO.class));
|
return success(BeanUtils.toBean(pageResult, QuantityUnitRelationRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/simple-page")
|
||||||
|
@Operation(summary = "获得计量单位量与单位关联精简分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('unitmanagement:quantity-unit-relation:query')")
|
||||||
|
public CommonResult<PageResult<QuantityUnitRelationSimpleRespVO>> getQuantityUnitRelationSimplePage(@Valid QuantityUnitRelationSimplePageReqVO pageReqVO) {
|
||||||
|
return success(quantityUnitRelationService.getQuantityUnitRelationSimplePage(pageReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/export-excel")
|
@GetMapping("/export-excel")
|
||||||
@Operation(summary = "导出计量单位量与单位关联 Excel")
|
@Operation(summary = "导出计量单位量与单位关联 Excel")
|
||||||
@PreAuthorize("@ss.hasPermission('unitmanagement:quantity-unit-relation:export')")
|
@PreAuthorize("@ss.hasPermission('unitmanagement:quantity-unit-relation:export')")
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.zt.plat.module.base.controller.admin.quantityUnitRelation.vo;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.PageParam;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计量单位量与单位关联精简分页 Request VO
|
||||||
|
*/
|
||||||
|
@Schema(description = "管理后台 - 计量单位量与单位关联精简分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class QuantityUnitRelationSimplePageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "量纲ID")
|
||||||
|
private Long untQtyId;
|
||||||
|
|
||||||
|
@Schema(description = "关键字(量纲/单位名称、符号模糊匹配)")
|
||||||
|
private String keyword;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package com.zt.plat.module.base.controller.admin.quantityUnitRelation.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 精简的量纲-单位关联响应
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class QuantityUnitRelationSimpleRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "关联关系ID", example = "1001")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "量纲ID", example = "2001")
|
||||||
|
private Long untQtyId;
|
||||||
|
|
||||||
|
@Schema(description = "量纲名称")
|
||||||
|
private String untQtyName;
|
||||||
|
|
||||||
|
@Schema(description = "计量单位ID", example = "3001")
|
||||||
|
private Long untId;
|
||||||
|
|
||||||
|
@Schema(description = "计量单位名称")
|
||||||
|
private String untName;
|
||||||
|
|
||||||
|
@Schema(description = "计量单位符号")
|
||||||
|
private String untSymbol;
|
||||||
|
|
||||||
|
@Schema(description = "是否基准单位:1表示是,0表示否")
|
||||||
|
private Integer isBse;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,7 +2,9 @@ package com.zt.plat.module.base.dal.dao.businessdictionarytype;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryDataDO;
|
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryDataDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@@ -26,4 +28,16 @@ public interface BusinessDictionaryDataMapper extends BaseMapperX<BusinessDictio
|
|||||||
return deleteBatch(BusinessDictionaryDataDO::getDictionaryTypeId, dictionaryTypeIds);
|
return deleteBatch(BusinessDictionaryDataDO::getDictionaryTypeId, dictionaryTypeIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default List<BusinessDictionaryDataDO> selectListByValues(Iterable<String> values) {
|
||||||
|
if (values == null || !values.iterator().hasNext()) {
|
||||||
|
return CollUtil.newArrayList();
|
||||||
|
}
|
||||||
|
List<String> valueList = CollUtil.newArrayList(values);
|
||||||
|
if (CollUtil.isEmpty(valueList)) {
|
||||||
|
return CollUtil.newArrayList();
|
||||||
|
}
|
||||||
|
return selectList(new LambdaQueryWrapperX<BusinessDictionaryDataDO>()
|
||||||
|
.in(BusinessDictionaryDataDO::getValue, valueList));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,4 +23,8 @@ public interface BusinessDictionaryTypeMapper extends BaseMapperX<BusinessDictio
|
|||||||
.orderByDesc(BusinessDictionaryTypeDO::getId));
|
.orderByDesc(BusinessDictionaryTypeDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default BusinessDictionaryTypeDO selectByType(String type) {
|
||||||
|
return selectOne(BusinessDictionaryTypeDO::getType, type);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,7 @@ public interface DepartmentMaterialMapper extends BaseMapperX<DepartmentMaterial
|
|||||||
.eqIfPresent(DepartmentMaterialDO::getClassesId, reqVO.getClassesId())
|
.eqIfPresent(DepartmentMaterialDO::getClassesId, reqVO.getClassesId())
|
||||||
.eqIfPresent(DepartmentMaterialDO::getDeptId, reqVO.getDeptId())
|
.eqIfPresent(DepartmentMaterialDO::getDeptId, reqVO.getDeptId())
|
||||||
.eqIfPresent(DepartmentMaterialDO::getDictionaryDataValue, reqVO.getDictionaryDataValue())
|
.eqIfPresent(DepartmentMaterialDO::getDictionaryDataValue, reqVO.getDictionaryDataValue())
|
||||||
|
.eqIfPresent(DepartmentMaterialDO::getStatus, reqVO.getStatus())
|
||||||
.eqIfPresent(DepartmentMaterialDO::getRemark, reqVO.getRemark())
|
.eqIfPresent(DepartmentMaterialDO::getRemark, reqVO.getRemark())
|
||||||
.betweenIfPresent(DepartmentMaterialDO::getCreateTime, reqVO.getCreateTime())
|
.betweenIfPresent(DepartmentMaterialDO::getCreateTime, reqVO.getCreateTime())
|
||||||
.orderByDesc(DepartmentMaterialDO::getId));
|
.orderByDesc(DepartmentMaterialDO::getId));
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package com.zt.plat.module.base.dal.dao.materialproperties;
|
package com.zt.plat.module.base.dal.dao.materialproperties;
|
||||||
|
|
||||||
import java.util.*;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
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.mapper.BaseMapperX;
|
||||||
|
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import com.zt.plat.module.base.controller.admin.materialproperties.vo.MaterialPropertiesPageReqVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.materialproperties.vo.MaterialPropertiesSimplePageReqVO;
|
||||||
import com.zt.plat.module.base.dal.dataobject.materialproperties.MaterialPropertiesDO;
|
import com.zt.plat.module.base.dal.dataobject.materialproperties.MaterialPropertiesDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import com.zt.plat.module.base.controller.admin.materialproperties.vo.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物料属性 Mapper
|
* 物料属性 Mapper
|
||||||
@@ -18,15 +18,33 @@ import com.zt.plat.module.base.controller.admin.materialproperties.vo.*;
|
|||||||
public interface MaterialPropertiesMapper extends BaseMapperX<MaterialPropertiesDO> {
|
public interface MaterialPropertiesMapper extends BaseMapperX<MaterialPropertiesDO> {
|
||||||
|
|
||||||
default PageResult<MaterialPropertiesDO> selectPage(MaterialPropertiesPageReqVO reqVO) {
|
default PageResult<MaterialPropertiesDO> selectPage(MaterialPropertiesPageReqVO reqVO) {
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<MaterialPropertiesDO>()
|
LambdaQueryWrapperX<MaterialPropertiesDO> query = new LambdaQueryWrapperX<MaterialPropertiesDO>()
|
||||||
.eqIfPresent(MaterialPropertiesDO::getCode, reqVO.getCode())
|
.eqIfPresent(MaterialPropertiesDO::getCode, reqVO.getCode())
|
||||||
.likeIfPresent(MaterialPropertiesDO::getName, reqVO.getName())
|
.likeIfPresent(MaterialPropertiesDO::getName, reqVO.getName())
|
||||||
.eqIfPresent(MaterialPropertiesDO::getUnitQuantityId, reqVO.getUnitQuantityId())
|
.eqIfPresent(MaterialPropertiesDO::getUnitQuantityId, reqVO.getUnitQuantityId())
|
||||||
.eqIfPresent(MaterialPropertiesDO::getDictionaryDataValue, reqVO.getDictionaryDataValue())
|
.eqIfPresent(MaterialPropertiesDO::getDictionaryDataValue, reqVO.getDictionaryDataValue())
|
||||||
.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());
|
||||||
.orderByDesc(MaterialPropertiesDO::getId));
|
if (StrUtil.isNotBlank(reqVO.getKeyword())) {
|
||||||
|
query.and(w -> w.like(MaterialPropertiesDO::getCode, reqVO.getKeyword())
|
||||||
|
.or()
|
||||||
|
.like(MaterialPropertiesDO::getName, reqVO.getKeyword()));
|
||||||
|
}
|
||||||
|
query.orderByDesc(MaterialPropertiesDO::getId);
|
||||||
|
return selectPage(reqVO, query);
|
||||||
|
}
|
||||||
|
|
||||||
|
default PageResult<MaterialPropertiesDO> selectSimplePage(MaterialPropertiesSimplePageReqVO reqVO) {
|
||||||
|
LambdaQueryWrapperX<MaterialPropertiesDO> query = new LambdaQueryWrapperX<MaterialPropertiesDO>()
|
||||||
|
.eqIfPresent(MaterialPropertiesDO::getDictionaryDataValue, reqVO.getDictionaryDataValue());
|
||||||
|
if (StrUtil.isNotBlank(reqVO.getKeyword())) {
|
||||||
|
query.and(w -> w.like(MaterialPropertiesDO::getCode, reqVO.getKeyword())
|
||||||
|
.or()
|
||||||
|
.like(MaterialPropertiesDO::getName, reqVO.getKeyword()));
|
||||||
|
}
|
||||||
|
query.orderByAsc(MaterialPropertiesDO::getCode);
|
||||||
|
return selectPage(reqVO, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
package com.zt.plat.module.base.dal.dao.quantityUnitRelation;
|
package com.zt.plat.module.base.dal.dao.quantityUnitRelation;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
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.mapper.BaseMapperX;
|
||||||
|
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import com.zt.plat.module.base.controller.admin.quantityUnitRelation.vo.QuantityUnitRelationPageReqVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.quantityUnitRelation.vo.QuantityUnitRelationSimplePageReqVO;
|
||||||
import com.zt.plat.module.base.dal.dataobject.quantityUnitRelation.QuantityUnitRelationDO;
|
import com.zt.plat.module.base.dal.dataobject.quantityUnitRelation.QuantityUnitRelationDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import com.zt.plat.module.base.controller.admin.quantityUnitRelation.vo.*;
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计量单位量与单位关联 Mapper
|
* 计量单位量与单位关联 Mapper
|
||||||
@@ -24,6 +25,10 @@ public interface QuantityUnitRelationMapper extends BaseMapperX<QuantityUnitRela
|
|||||||
.orderByDesc(QuantityUnitRelationDO::getUntQtyId));
|
.orderByDesc(QuantityUnitRelationDO::getUntQtyId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default PageResult<QuantityUnitRelationDO> selectSimplePage(QuantityUnitRelationSimplePageReqVO reqVO, LambdaQueryWrapperX<QuantityUnitRelationDO> wrapper) {
|
||||||
|
return BaseMapperX.super.selectPage(reqVO, wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据量纲ID查询所有关联关系
|
* 根据量纲ID查询所有关联关系
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -52,6 +52,11 @@ public class DepartmentMaterialDO extends BaseDO {
|
|||||||
@TableField("DIC_DAT_VAL")
|
@TableField("DIC_DAT_VAL")
|
||||||
private String dictionaryDataValue;
|
private String dictionaryDataValue;
|
||||||
/**
|
/**
|
||||||
|
* 状态编码,对应系统字典 base_material_status
|
||||||
|
*/
|
||||||
|
@TableField("STS")
|
||||||
|
private String status;
|
||||||
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
@TableField("RMK")
|
@TableField("RMK")
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.zt.plat.framework.common.pojo.PageResult;
|
|||||||
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
import com.zt.plat.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationPageReqVO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationPageReqVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSimplePageReqVO;
|
||||||
import com.zt.plat.module.base.dal.dataobject.base.MaterialInfomationDO;
|
import com.zt.plat.module.base.dal.dataobject.base.MaterialInfomationDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@@ -31,4 +32,8 @@ public interface MaterialInfomationMapper extends BaseMapperX<MaterialInfomation
|
|||||||
.orderByDesc(MaterialInfomationDO::getId));
|
.orderByDesc(MaterialInfomationDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default PageResult<MaterialInfomationDO> selectSimplePage(MaterialInfomationSimplePageReqVO reqVO, LambdaQueryWrapperX<MaterialInfomationDO> wrapper) {
|
||||||
|
return BaseMapperX.super.selectPage(reqVO, wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,8 @@ import com.zt.plat.framework.common.pojo.PageResult;
|
|||||||
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationPageReqVO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationPageReqVO;
|
||||||
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationRespVO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationRespVO;
|
||||||
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSaveReqVO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSaveReqVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSimplePageReqVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSimpleRespVO;
|
||||||
import com.zt.plat.module.base.dal.dataobject.base.MaterialInfomationDO;
|
import com.zt.plat.module.base.dal.dataobject.base.MaterialInfomationDO;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
@@ -51,7 +53,7 @@ public interface MaterialInfomationService {
|
|||||||
* @param id 编号
|
* @param id 编号
|
||||||
* @return 物料信息
|
* @return 物料信息
|
||||||
*/
|
*/
|
||||||
MaterialInfomationDO getMaterialInfomation(Long id);
|
MaterialInfomationRespVO getMaterialInfomation(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得物料信息分页
|
* 获得物料信息分页
|
||||||
@@ -59,7 +61,15 @@ public interface MaterialInfomationService {
|
|||||||
* @param pageReqVO 分页查询
|
* @param pageReqVO 分页查询
|
||||||
* @return 物料信息分页
|
* @return 物料信息分页
|
||||||
*/
|
*/
|
||||||
PageResult<MaterialInfomationDO> getMaterialInfomationPage(MaterialInfomationPageReqVO pageReqVO);
|
PageResult<MaterialInfomationRespVO> getMaterialInfomationPage(MaterialInfomationPageReqVO pageReqVO);
|
||||||
|
|
||||||
String getOneTest();
|
String getOneTest();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得精简的物料信息分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页参数
|
||||||
|
* @return 精简分页列表
|
||||||
|
*/
|
||||||
|
PageResult<MaterialInfomationSimpleRespVO> getMaterialInfomationSimplePage(MaterialInfomationSimplePageReqVO pageReqVO);
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,21 @@
|
|||||||
package com.zt.plat.module.base.service.base;
|
package com.zt.plat.module.base.service.base;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
|
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationPageReqVO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationPageReqVO;
|
||||||
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationRespVO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationRespVO;
|
||||||
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSaveReqVO;
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSaveReqVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSimplePageReqVO;
|
||||||
|
import com.zt.plat.module.base.controller.admin.base.vo.MaterialInfomationSimpleRespVO;
|
||||||
|
import com.zt.plat.module.base.dal.dao.materialclasses.MaterialClassesMapper;
|
||||||
import com.zt.plat.module.base.dal.dao.materialhasclasses.MaterialHasClassesMapper;
|
import com.zt.plat.module.base.dal.dao.materialhasclasses.MaterialHasClassesMapper;
|
||||||
import com.zt.plat.module.base.dal.dataobject.base.MaterialInfomationDO;
|
import com.zt.plat.module.base.dal.dataobject.base.MaterialInfomationDO;
|
||||||
|
import com.zt.plat.module.base.dal.dataobject.materialclasses.MaterialClassesDO;
|
||||||
import com.zt.plat.module.base.dal.dataobject.materialhasclasses.MaterialHasClassesDO;
|
import com.zt.plat.module.base.dal.dataobject.materialhasclasses.MaterialHasClassesDO;
|
||||||
import com.zt.plat.module.base.dal.mysql.base.MaterialInfomationMapper;
|
import com.zt.plat.module.base.dal.mysql.base.MaterialInfomationMapper;
|
||||||
import com.zt.plat.module.erp.api.ErpExternalApi;
|
import com.zt.plat.module.erp.api.ErpExternalApi;
|
||||||
@@ -20,12 +26,16 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static com.zt.plat.module.base.enums.ErrorCodeConstants.MATERIAL_CLASSES_LEVEL3_REQUIRED_FOR_MATERIAL;
|
||||||
|
import static com.zt.plat.module.base.enums.ErrorCodeConstants.MATERIAL_CLASSES_NOT_EXISTS;
|
||||||
import static com.zt.plat.module.base.enums.ErrorCodeConstants.MATERIAL_INFOMATION_NOT_EXISTS;
|
import static com.zt.plat.module.base.enums.ErrorCodeConstants.MATERIAL_INFOMATION_NOT_EXISTS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,143 +47,254 @@ import static com.zt.plat.module.base.enums.ErrorCodeConstants.MATERIAL_INFOMATI
|
|||||||
@Validated
|
@Validated
|
||||||
public class MaterialInfomationServiceImpl implements MaterialInfomationService {
|
public class MaterialInfomationServiceImpl implements MaterialInfomationService {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private MaterialInfomationMapper materialInfomationMapper;
|
private MaterialInfomationMapper materialInfomationMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ErpExternalApi erpExternalApi;
|
private ErpExternalApi erpExternalApi;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private MaterialHasClassesMapper materialHasClassesMapper;
|
private MaterialHasClassesMapper materialHasClassesMapper;
|
||||||
|
|
||||||
@Override
|
@Resource
|
||||||
@Transactional(rollbackFor = Exception.class)
|
private MaterialClassesMapper materialClassesMapper;
|
||||||
public MaterialInfomationRespVO createMaterialInfomation(MaterialInfomationSaveReqVO createReqVO) {
|
|
||||||
// 插入
|
|
||||||
MaterialInfomationDO materialInfomation = BeanUtils.toBean(createReqVO, MaterialInfomationDO.class);
|
|
||||||
materialInfomationMapper.insert(materialInfomation);
|
|
||||||
// 维护分类关联
|
|
||||||
if (createReqVO.getClassesId() != null) {
|
|
||||||
MaterialHasClassesDO relation = MaterialHasClassesDO.builder()
|
|
||||||
.classesId(createReqVO.getClassesId())
|
|
||||||
.infomationId(materialInfomation.getId())
|
|
||||||
.build();
|
|
||||||
materialHasClassesMapper.insert(relation);
|
|
||||||
materialInfomation.setClassesId(createReqVO.getClassesId());
|
|
||||||
}
|
|
||||||
// 返回
|
|
||||||
return BeanUtils.toBean(materialInfomation, MaterialInfomationRespVO.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateMaterialInfomation(MaterialInfomationSaveReqVO updateReqVO) {
|
public MaterialInfomationRespVO createMaterialInfomation(MaterialInfomationSaveReqVO createReqVO) {
|
||||||
// 校验存在
|
validateMaterialClassForBinding(createReqVO.getClassesId());
|
||||||
validateMaterialInfomationExists(updateReqVO.getId());
|
MaterialInfomationDO materialInfomation = BeanUtils.toBean(createReqVO, MaterialInfomationDO.class);
|
||||||
// 更新
|
materialInfomationMapper.insert(materialInfomation);
|
||||||
MaterialInfomationDO updateObj = BeanUtils.toBean(updateReqVO, MaterialInfomationDO.class);
|
if (createReqVO.getClassesId() != null) {
|
||||||
materialInfomationMapper.updateById(updateObj);
|
MaterialHasClassesDO relation = MaterialHasClassesDO.builder()
|
||||||
// 更新分类关联
|
.classesId(createReqVO.getClassesId())
|
||||||
materialHasClassesMapper.delete(new LambdaUpdateWrapper<MaterialHasClassesDO>()
|
.infomationId(materialInfomation.getId())
|
||||||
.eq(MaterialHasClassesDO::getInfomationId, updateReqVO.getId()));
|
.build();
|
||||||
if (updateReqVO.getClassesId() != null) {
|
materialHasClassesMapper.insert(relation);
|
||||||
MaterialHasClassesDO relation = MaterialHasClassesDO.builder()
|
materialInfomation.setClassesId(createReqVO.getClassesId());
|
||||||
.classesId(updateReqVO.getClassesId())
|
}
|
||||||
.infomationId(updateReqVO.getId())
|
return CollUtil.getFirst(buildRespList(Collections.singletonList(materialInfomation)));
|
||||||
.build();
|
}
|
||||||
materialHasClassesMapper.insert(relation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteMaterialInfomation(Long id) {
|
@Transactional(rollbackFor = Exception.class)
|
||||||
// 校验存在
|
public void updateMaterialInfomation(MaterialInfomationSaveReqVO updateReqVO) {
|
||||||
validateMaterialInfomationExists(id);
|
validateMaterialInfomationExists(updateReqVO.getId());
|
||||||
// 删除
|
validateMaterialClassForBinding(updateReqVO.getClassesId());
|
||||||
materialInfomationMapper.deleteById(id);
|
MaterialInfomationDO updateObj = BeanUtils.toBean(updateReqVO, MaterialInfomationDO.class);
|
||||||
materialHasClassesMapper.delete(new LambdaUpdateWrapper<MaterialHasClassesDO>()
|
materialInfomationMapper.updateById(updateObj);
|
||||||
.eq(MaterialHasClassesDO::getInfomationId, id));
|
materialHasClassesMapper.delete(new LambdaUpdateWrapper<MaterialHasClassesDO>()
|
||||||
}
|
.eq(MaterialHasClassesDO::getInfomationId, updateReqVO.getId()));
|
||||||
|
if (updateReqVO.getClassesId() != null) {
|
||||||
|
MaterialHasClassesDO relation = MaterialHasClassesDO.builder()
|
||||||
|
.classesId(updateReqVO.getClassesId())
|
||||||
|
.infomationId(updateReqVO.getId())
|
||||||
|
.build();
|
||||||
|
materialHasClassesMapper.insert(relation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteMaterialInfomationListByIds(List<Long> ids) {
|
public void deleteMaterialInfomation(Long id) {
|
||||||
// 校验存在
|
validateMaterialInfomationExists(id);
|
||||||
validateMaterialInfomationExists(ids);
|
materialInfomationMapper.deleteById(id);
|
||||||
// 删除
|
materialHasClassesMapper.delete(new LambdaUpdateWrapper<MaterialHasClassesDO>()
|
||||||
materialInfomationMapper.deleteByIds(ids);
|
.eq(MaterialHasClassesDO::getInfomationId, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateMaterialInfomationExists(List<Long> ids) {
|
@Override
|
||||||
List<MaterialInfomationDO> list = materialInfomationMapper.selectByIds(ids);
|
public void deleteMaterialInfomationListByIds(List<Long> ids) {
|
||||||
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
validateMaterialInfomationExists(ids);
|
||||||
throw exception(MATERIAL_INFOMATION_NOT_EXISTS);
|
materialInfomationMapper.deleteByIds(ids);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void validateMaterialInfomationExists(Long id) {
|
private void validateMaterialInfomationExists(List<Long> ids) {
|
||||||
if (materialInfomationMapper.selectById(id) == null) {
|
List<MaterialInfomationDO> list = materialInfomationMapper.selectByIds(ids);
|
||||||
throw exception(MATERIAL_INFOMATION_NOT_EXISTS);
|
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
|
||||||
}
|
throw exception(MATERIAL_INFOMATION_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
private void validateMaterialInfomationExists(Long id) {
|
||||||
public MaterialInfomationDO getMaterialInfomation(Long id) {
|
if (materialInfomationMapper.selectById(id) == null) {
|
||||||
MaterialInfomationDO info = materialInfomationMapper.selectById(id);
|
throw exception(MATERIAL_INFOMATION_NOT_EXISTS);
|
||||||
if (info == null) {
|
}
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
MaterialHasClassesDO relation = materialHasClassesMapper.selectFirstOne(MaterialHasClassesDO::getInfomationId, id);
|
|
||||||
if (relation != null) {
|
|
||||||
info.setClassesId(relation.getClassesId());
|
|
||||||
}
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
private void validateMaterialClassForBinding(Long classesId) {
|
||||||
public PageResult<MaterialInfomationDO> getMaterialInfomationPage(MaterialInfomationPageReqVO pageReqVO) {
|
if (classesId == null) {
|
||||||
List<Long> infomationIds = null;
|
throw exception(MATERIAL_CLASSES_LEVEL3_REQUIRED_FOR_MATERIAL);
|
||||||
List<MaterialHasClassesDO> relationList = Collections.emptyList();
|
}
|
||||||
if (pageReqVO.getClassesId() != null) {
|
MaterialClassesDO materialClasses = materialClassesMapper.selectById(classesId);
|
||||||
relationList = materialHasClassesMapper.selectList(MaterialHasClassesDO::getClassesId, pageReqVO.getClassesId());
|
if (materialClasses == null) {
|
||||||
if (CollUtil.isEmpty(relationList)) {
|
throw exception(MATERIAL_CLASSES_NOT_EXISTS);
|
||||||
return PageResult.empty();
|
}
|
||||||
}
|
if (!isThirdLevelClass(materialClasses)) {
|
||||||
infomationIds = relationList.stream()
|
throw exception(MATERIAL_CLASSES_LEVEL3_REQUIRED_FOR_MATERIAL);
|
||||||
.map(MaterialHasClassesDO::getInfomationId)
|
}
|
||||||
.filter(Objects::nonNull)
|
}
|
||||||
.distinct()
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
PageResult<MaterialInfomationDO> pageResult = materialInfomationMapper.selectPage(pageReqVO, infomationIds);
|
private boolean isThirdLevelClass(MaterialClassesDO materialClasses) {
|
||||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
Long level = materialClasses.getLevel();
|
||||||
return pageResult;
|
if (Objects.equals(level, 3L)) {
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
|
if (level != null && level > 3L) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Long depth = resolveClassDepth(materialClasses);
|
||||||
|
return depth != null && depth == 3L;
|
||||||
|
}
|
||||||
|
|
||||||
List<Long> currentInfoIds = pageResult.getList().stream()
|
private Long resolveClassDepth(MaterialClassesDO materialClasses) {
|
||||||
.map(MaterialInfomationDO::getId)
|
long depth = 1L;
|
||||||
.collect(Collectors.toList());
|
Set<Long> visited = new HashSet<>();
|
||||||
|
if (materialClasses.getId() != null) {
|
||||||
|
visited.add(materialClasses.getId());
|
||||||
|
}
|
||||||
|
Long parentId = materialClasses.getParentId();
|
||||||
|
while (parentId != null) {
|
||||||
|
if (!visited.add(parentId)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
MaterialClassesDO parent = materialClassesMapper.selectById(parentId);
|
||||||
|
if (parent == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
depth++;
|
||||||
|
if (depth > 3L) {
|
||||||
|
return depth;
|
||||||
|
}
|
||||||
|
parentId = parent.getParentId();
|
||||||
|
}
|
||||||
|
return depth;
|
||||||
|
}
|
||||||
|
|
||||||
if (pageReqVO.getClassesId() == null) {
|
@Override
|
||||||
relationList = materialHasClassesMapper.selectList(MaterialHasClassesDO::getInfomationId, currentInfoIds);
|
public MaterialInfomationRespVO getMaterialInfomation(Long id) {
|
||||||
}
|
MaterialInfomationDO info = materialInfomationMapper.selectById(id);
|
||||||
|
if (info == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
MaterialHasClassesDO relation = materialHasClassesMapper.selectFirstOne(MaterialHasClassesDO::getInfomationId, id);
|
||||||
|
if (relation != null) {
|
||||||
|
info.setClassesId(relation.getClassesId());
|
||||||
|
}
|
||||||
|
return CollUtil.getFirst(buildRespList(Collections.singletonList(info)));
|
||||||
|
}
|
||||||
|
|
||||||
Map<Long, Long> infoClassMap = relationList.stream()
|
@Override
|
||||||
.filter(item -> item.getInfomationId() != null)
|
public PageResult<MaterialInfomationRespVO> getMaterialInfomationPage(MaterialInfomationPageReqVO pageReqVO) {
|
||||||
.collect(Collectors.toMap(MaterialHasClassesDO::getInfomationId, MaterialHasClassesDO::getClassesId, (existing, replacement) -> existing));
|
List<Long> infomationIds = null;
|
||||||
|
List<MaterialHasClassesDO> relationList = Collections.emptyList();
|
||||||
|
if (pageReqVO.getClassesId() != null) {
|
||||||
|
relationList = materialHasClassesMapper.selectList(MaterialHasClassesDO::getClassesId, pageReqVO.getClassesId());
|
||||||
|
if (CollUtil.isEmpty(relationList)) {
|
||||||
|
return PageResult.empty();
|
||||||
|
}
|
||||||
|
infomationIds = relationList.stream()
|
||||||
|
.map(MaterialHasClassesDO::getInfomationId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
pageResult.getList().forEach(item -> item.setClassesId(infoClassMap.get(item.getId())));
|
PageResult<MaterialInfomationDO> pageResult = materialInfomationMapper.selectPage(pageReqVO, infomationIds);
|
||||||
return pageResult;
|
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||||
}
|
return PageResult.empty(pageResult.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
List<Long> currentInfoIds = pageResult.getList().stream()
|
||||||
public String getOneTest() {
|
.map(MaterialInfomationDO::getId)
|
||||||
ErpProductiveVersionReqDTO reqDTO = new ErpProductiveVersionReqDTO();
|
.collect(Collectors.toList());
|
||||||
reqDTO.setFactoryNumber("5020");
|
|
||||||
reqDTO.setMaterialNumber("224814");
|
|
||||||
CommonResult<String> erpProductiveVersion = erpExternalApi.getErpProductiveVersionByFM(reqDTO);
|
|
||||||
return erpProductiveVersion.getData();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (pageReqVO.getClassesId() == null) {
|
||||||
|
relationList = materialHasClassesMapper.selectList(MaterialHasClassesDO::getInfomationId, currentInfoIds);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
Map<Long, Long> infoClassMap = relationList.stream()
|
||||||
|
.filter(item -> item.getInfomationId() != null)
|
||||||
|
.collect(Collectors.toMap(MaterialHasClassesDO::getInfomationId, MaterialHasClassesDO::getClassesId, (existing, replacement) -> existing));
|
||||||
|
|
||||||
|
pageResult.getList().forEach(item -> item.setClassesId(infoClassMap.get(item.getId())));
|
||||||
|
List<MaterialInfomationRespVO> respList = buildRespList(pageResult.getList());
|
||||||
|
return new PageResult<>(respList, pageResult.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOneTest() {
|
||||||
|
ErpProductiveVersionReqDTO reqDTO = new ErpProductiveVersionReqDTO();
|
||||||
|
reqDTO.setFactoryNumber("5020");
|
||||||
|
reqDTO.setMaterialNumber("224814");
|
||||||
|
CommonResult<String> erpProductiveVersion = erpExternalApi.getErpProductiveVersionByFM(reqDTO);
|
||||||
|
return erpProductiveVersion.getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<MaterialInfomationSimpleRespVO> getMaterialInfomationSimplePage(MaterialInfomationSimplePageReqVO pageReqVO) {
|
||||||
|
LambdaQueryWrapperX<MaterialInfomationDO> wrapper = new LambdaQueryWrapperX<>();
|
||||||
|
if (StrUtil.isNotBlank(pageReqVO.getKeyword())) {
|
||||||
|
wrapper.and(w -> w.like(MaterialInfomationDO::getCode, pageReqVO.getKeyword())
|
||||||
|
.or().like(MaterialInfomationDO::getName, pageReqVO.getKeyword()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Long, Long> infoClassMap = Collections.emptyMap();
|
||||||
|
if (pageReqVO.getClassesId() != null) {
|
||||||
|
List<MaterialHasClassesDO> relations = materialHasClassesMapper.selectList(MaterialHasClassesDO::getClassesId, pageReqVO.getClassesId());
|
||||||
|
if (CollUtil.isEmpty(relations)) {
|
||||||
|
return new PageResult<>(Collections.emptyList(), 0L);
|
||||||
|
}
|
||||||
|
List<Long> infoIds = relations.stream()
|
||||||
|
.map(MaterialHasClassesDO::getInfomationId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.distinct()
|
||||||
|
.toList();
|
||||||
|
if (CollUtil.isEmpty(infoIds)) {
|
||||||
|
return new PageResult<>(Collections.emptyList(), 0L);
|
||||||
|
}
|
||||||
|
wrapper.in(MaterialInfomationDO::getId, infoIds);
|
||||||
|
infoClassMap = relations.stream()
|
||||||
|
.filter(item -> item.getInfomationId() != null)
|
||||||
|
.collect(Collectors.toMap(MaterialHasClassesDO::getInfomationId,
|
||||||
|
MaterialHasClassesDO::getClassesId, (existing, replacement) -> existing));
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapper.orderByAsc(MaterialInfomationDO::getCode);
|
||||||
|
|
||||||
|
PageResult<MaterialInfomationDO> pageResult = materialInfomationMapper.selectSimplePage(pageReqVO, wrapper);
|
||||||
|
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||||
|
return new PageResult<>(Collections.emptyList(), pageResult.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pageReqVO.getClassesId() == null) {
|
||||||
|
List<Long> infoIds = pageResult.getList().stream().map(MaterialInfomationDO::getId).toList();
|
||||||
|
List<MaterialHasClassesDO> relations = materialHasClassesMapper.selectList(MaterialHasClassesDO::getInfomationId, infoIds);
|
||||||
|
infoClassMap = relations.stream()
|
||||||
|
.filter(item -> item.getInfomationId() != null)
|
||||||
|
.collect(Collectors.toMap(MaterialHasClassesDO::getInfomationId,
|
||||||
|
MaterialHasClassesDO::getClassesId, (existing, replacement) -> existing));
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Long, Long> finalInfoClassMap = infoClassMap;
|
||||||
|
List<MaterialInfomationSimpleRespVO> respList = pageResult.getList().stream().map(item -> {
|
||||||
|
MaterialInfomationSimpleRespVO vo = new MaterialInfomationSimpleRespVO();
|
||||||
|
vo.setId(item.getId());
|
||||||
|
vo.setCode(item.getCode());
|
||||||
|
vo.setName(item.getName());
|
||||||
|
vo.setRemark(item.getRemark());
|
||||||
|
vo.setClassesId(finalInfoClassMap.get(item.getId()));
|
||||||
|
return vo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
|
return new PageResult<>(respList, pageResult.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<MaterialInfomationRespVO> buildRespList(List<MaterialInfomationDO> list) {
|
||||||
|
if (CollUtil.isEmpty(list)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return list.stream()
|
||||||
|
.map(item -> BeanUtils.toBean(item, MaterialInfomationRespVO.class))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -69,4 +69,12 @@ public interface BusinessDictionaryTypeService {
|
|||||||
*/
|
*/
|
||||||
List<BusinessDictionaryDataDO> getBusinessDictionaryDataListByDictionaryTypeId(Long dictionaryTypeId);
|
List<BusinessDictionaryDataDO> getBusinessDictionaryDataListByDictionaryTypeId(Long dictionaryTypeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据字典类型编码获取业务字典数据列表
|
||||||
|
*
|
||||||
|
* @param type 字典类型编码
|
||||||
|
* @return 字典数据列表
|
||||||
|
*/
|
||||||
|
List<BusinessDictionaryDataDO> getBusinessDictionaryDataListByType(String type);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@ package com.zt.plat.module.base.service.businessdictionarytype;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -116,6 +117,19 @@ public class BusinessDictionaryTypeServiceImpl implements BusinessDictionaryType
|
|||||||
return businessDictionaryDataMapper.selectListByDictionaryTypeId(dictionaryTypeId);
|
return businessDictionaryDataMapper.selectListByDictionaryTypeId(dictionaryTypeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BusinessDictionaryDataDO> getBusinessDictionaryDataListByType(String type) {
|
||||||
|
if (StrUtil.isBlank(type)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
BusinessDictionaryTypeDO dictionaryType = businessDictionaryTypeMapper.selectByType(type);
|
||||||
|
if (dictionaryType == null) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
// 直接根据类型编码定位字典类型,简化前端查询流程
|
||||||
|
return businessDictionaryDataMapper.selectListByDictionaryTypeId(dictionaryType.getId());
|
||||||
|
}
|
||||||
|
|
||||||
private void createBusinessDictionaryDataList(Long dictionaryTypeId, List<BusinessDictionaryDataDO> list) {
|
private void createBusinessDictionaryDataList(Long dictionaryTypeId, List<BusinessDictionaryDataDO> list) {
|
||||||
list.forEach(o -> o.setDictionaryTypeId(dictionaryTypeId).clean());
|
list.forEach(o -> o.setDictionaryTypeId(dictionaryTypeId).clean());
|
||||||
businessDictionaryDataMapper.insertBatch(list);
|
businessDictionaryDataMapper.insertBatch(list);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public interface DepartmentMaterialService {
|
|||||||
* @param id 编号
|
* @param id 编号
|
||||||
* @return 组织架构物料
|
* @return 组织架构物料
|
||||||
*/
|
*/
|
||||||
DepartmentMaterialDO getDepartmentMaterial(Long id);
|
DepartmentMaterialRespVO getDepartmentMaterial(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得组织架构物料分页
|
* 获得组织架构物料分页
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import java.util.stream.Collectors;
|
|||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.util.collection.CollectionUtils;
|
import com.zt.plat.framework.common.util.collection.CollectionUtils;
|
||||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
||||||
import com.zt.plat.module.base.controller.admin.departmentmaterial.vo.*;
|
import com.zt.plat.module.base.controller.admin.departmentmaterial.vo.*;
|
||||||
import com.zt.plat.module.base.dal.dao.departmentmaterial.DepartmentMaterialMapper;
|
import com.zt.plat.module.base.dal.dao.departmentmaterial.DepartmentMaterialMapper;
|
||||||
import com.zt.plat.module.base.dal.dao.materialclasses.MaterialClassesMapper;
|
import com.zt.plat.module.base.dal.dao.materialclasses.MaterialClassesMapper;
|
||||||
@@ -21,6 +20,9 @@ import com.zt.plat.module.base.dal.dataobject.base.MaterialInfomationDO;
|
|||||||
import com.zt.plat.module.base.dal.dataobject.departmentmaterial.DepartmentMaterialDO;
|
import com.zt.plat.module.base.dal.dataobject.departmentmaterial.DepartmentMaterialDO;
|
||||||
import com.zt.plat.module.base.dal.dataobject.materialclasses.MaterialClassesDO;
|
import com.zt.plat.module.base.dal.dataobject.materialclasses.MaterialClassesDO;
|
||||||
import com.zt.plat.module.base.dal.mysql.base.MaterialInfomationMapper;
|
import com.zt.plat.module.base.dal.mysql.base.MaterialInfomationMapper;
|
||||||
|
import com.zt.plat.module.base.dal.dao.businessdictionarytype.BusinessDictionaryDataMapper;
|
||||||
|
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryDataDO;
|
||||||
|
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import com.zt.plat.module.system.api.dept.DeptApi;
|
import com.zt.plat.module.system.api.dept.DeptApi;
|
||||||
import com.zt.plat.module.system.api.dept.dto.DeptRespDTO;
|
import com.zt.plat.module.system.api.dept.dto.DeptRespDTO;
|
||||||
|
|
||||||
@@ -45,6 +47,9 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
|||||||
@Resource
|
@Resource
|
||||||
private MaterialClassesMapper materialClassesMapper;
|
private MaterialClassesMapper materialClassesMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BusinessDictionaryDataMapper businessDictionaryDataMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private DeptApi deptApi;
|
private DeptApi deptApi;
|
||||||
|
|
||||||
@@ -53,8 +58,8 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
|||||||
// 插入
|
// 插入
|
||||||
DepartmentMaterialDO departmentMaterial = BeanUtils.toBean(createReqVO, DepartmentMaterialDO.class);
|
DepartmentMaterialDO departmentMaterial = BeanUtils.toBean(createReqVO, DepartmentMaterialDO.class);
|
||||||
departmentMaterialMapper.insert(departmentMaterial);
|
departmentMaterialMapper.insert(departmentMaterial);
|
||||||
// 返回
|
// 构造完整响应,方便前端直接刷新数据
|
||||||
return BeanUtils.toBean(departmentMaterial, DepartmentMaterialRespVO.class);
|
return CollUtil.getFirst(decorateDepartmentMaterials(Collections.singletonList(departmentMaterial)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -96,8 +101,12 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DepartmentMaterialDO getDepartmentMaterial(Long id) {
|
public DepartmentMaterialRespVO getDepartmentMaterial(Long id) {
|
||||||
return departmentMaterialMapper.selectById(id);
|
DepartmentMaterialDO data = departmentMaterialMapper.selectById(id);
|
||||||
|
if (data == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return CollUtil.getFirst(decorateDepartmentMaterials(Collections.singletonList(data)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -124,8 +133,17 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
|||||||
return PageResult.empty(pageResult.getTotal());
|
return PageResult.empty(pageResult.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<DepartmentMaterialRespVO> respList = decorateDepartmentMaterials(pageResult.getList());
|
||||||
|
return new PageResult<>(respList, pageResult.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<DepartmentMaterialRespVO> decorateDepartmentMaterials(List<DepartmentMaterialDO> sourceList) {
|
||||||
|
if (CollUtil.isEmpty(sourceList)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
// 关联数据准备
|
// 关联数据准备
|
||||||
Set<Long> infoIds = pageResult.getList().stream()
|
Set<Long> infoIds = sourceList.stream()
|
||||||
.map(DepartmentMaterialDO::getInfomationId)
|
.map(DepartmentMaterialDO::getInfomationId)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
@@ -136,7 +154,7 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
|||||||
.collect(Collectors.toMap(MaterialInfomationDO::getId, Function.identity()));
|
.collect(Collectors.toMap(MaterialInfomationDO::getId, Function.identity()));
|
||||||
|
|
||||||
Set<Long> classIds = new HashSet<>();
|
Set<Long> classIds = new HashSet<>();
|
||||||
pageResult.getList().forEach(item -> {
|
sourceList.forEach(item -> {
|
||||||
if (item.getClassesId() != null) {
|
if (item.getClassesId() != null) {
|
||||||
classIds.add(item.getClassesId());
|
classIds.add(item.getClassesId());
|
||||||
}
|
}
|
||||||
@@ -148,13 +166,13 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
|||||||
|
|
||||||
Map<Long, MaterialClassesDO> classCache = loadClassHierarchy(classIds);
|
Map<Long, MaterialClassesDO> classCache = loadClassHierarchy(classIds);
|
||||||
|
|
||||||
Set<Long> deptIds = pageResult.getList().stream()
|
Set<Long> deptIds = sourceList.stream()
|
||||||
.map(DepartmentMaterialDO::getDeptId)
|
.map(DepartmentMaterialDO::getDeptId)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
Map<Long, DeptRespDTO> deptMap = Collections.emptyMap();
|
Map<Long, DeptRespDTO> deptMap = Collections.emptyMap();
|
||||||
if (!deptIds.isEmpty()) {
|
if (CollUtil.isNotEmpty(deptIds)) {
|
||||||
try {
|
try {
|
||||||
deptMap = CollectionUtils.convertMap(deptApi.getDeptList(deptIds).getCheckedData(), DeptRespDTO::getId);
|
deptMap = CollectionUtils.convertMap(deptApi.getDeptList(deptIds).getCheckedData(), DeptRespDTO::getId);
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
@@ -162,8 +180,18 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DepartmentMaterialRespVO> respList = new ArrayList<>(pageResult.getList().size());
|
Set<String> dictionaryValues = sourceList.stream()
|
||||||
for (DepartmentMaterialDO item : pageResult.getList()) {
|
.map(DepartmentMaterialDO::getDictionaryDataValue)
|
||||||
|
.filter(StrUtil::isNotBlank)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
Map<String, BusinessDictionaryDataDO> dictionaryMap = dictionaryValues.isEmpty()
|
||||||
|
? Collections.emptyMap()
|
||||||
|
: businessDictionaryDataMapper.selectListByValues(dictionaryValues).stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toMap(BusinessDictionaryDataDO::getValue, Function.identity(), (exist, replace) -> exist));
|
||||||
|
|
||||||
|
List<DepartmentMaterialRespVO> respList = new ArrayList<>(sourceList.size());
|
||||||
|
for (DepartmentMaterialDO item : sourceList) {
|
||||||
DepartmentMaterialRespVO respVO = BeanUtils.toBean(item, DepartmentMaterialRespVO.class);
|
DepartmentMaterialRespVO respVO = BeanUtils.toBean(item, DepartmentMaterialRespVO.class);
|
||||||
|
|
||||||
MaterialInfomationDO info = infoMap.get(item.getInfomationId());
|
MaterialInfomationDO info = infoMap.get(item.getInfomationId());
|
||||||
@@ -195,13 +223,16 @@ public class DepartmentMaterialServiceImpl implements DepartmentMaterialService
|
|||||||
respVO.setDeptName(deptRespDTO.getName());
|
respVO.setDeptName(deptRespDTO.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
respVO.setStatusLabel(StrUtil.isNotBlank(respVO.getStatusLabel()) ? respVO.getStatusLabel() : "未配置");
|
BusinessDictionaryDataDO dictionaryData = dictionaryMap.get(respVO.getDictionaryDataValue());
|
||||||
|
if (dictionaryData != null) {
|
||||||
|
respVO.setDictionaryDataLabel(dictionaryData.getLabel());
|
||||||
|
} else {
|
||||||
|
respVO.setDictionaryDataLabel(respVO.getDictionaryDataValue());
|
||||||
|
}
|
||||||
|
|
||||||
respVO.setDictionaryDataLabel(respVO.getDictionaryDataValue());
|
|
||||||
respList.add(respVO);
|
respList.add(respVO);
|
||||||
}
|
}
|
||||||
|
return respList;
|
||||||
return new PageResult<>(respList, pageResult.getTotal());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Long, MaterialClassesDO> loadClassHierarchy(Set<Long> initialIds) {
|
private Map<Long, MaterialClassesDO> loadClassHierarchy(Set<Long> initialIds) {
|
||||||
|
|||||||
@@ -10,14 +10,11 @@ import java.util.*;
|
|||||||
import com.zt.plat.module.base.controller.admin.materialclasses.vo.*;
|
import com.zt.plat.module.base.controller.admin.materialclasses.vo.*;
|
||||||
import com.zt.plat.module.base.dal.dataobject.materialclasses.MaterialClassesDO;
|
import com.zt.plat.module.base.dal.dataobject.materialclasses.MaterialClassesDO;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.pojo.PageParam;
|
|
||||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
import com.zt.plat.module.base.dal.dao.materialclasses.MaterialClassesMapper;
|
import com.zt.plat.module.base.dal.dao.materialclasses.MaterialClassesMapper;
|
||||||
|
|
||||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList;
|
|
||||||
import static com.zt.plat.framework.common.util.collection.CollectionUtils.diffList;
|
|
||||||
import static com.zt.plat.module.base.enums.ErrorCodeConstants.*;
|
import static com.zt.plat.module.base.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,10 +29,21 @@ public class MaterialClassesServiceImpl implements MaterialClassesService {
|
|||||||
@Resource
|
@Resource
|
||||||
private MaterialClassesMapper materialClassesMapper;
|
private MaterialClassesMapper materialClassesMapper;
|
||||||
|
|
||||||
|
private static final int MAX_LEVEL = 3;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MaterialClassesRespVO createMaterialClasses(MaterialClassesSaveReqVO createReqVO) {
|
public MaterialClassesRespVO createMaterialClasses(MaterialClassesSaveReqVO createReqVO) {
|
||||||
|
Long normalizedParentId = normalizeParentId(createReqVO.getParentId());
|
||||||
|
MaterialClassesDO parent = validateAndGetParent(null, normalizedParentId);
|
||||||
|
long resolvedLevel = resolveLevel(parent);
|
||||||
|
validateLevel(resolvedLevel);
|
||||||
|
if (createReqVO.getLevel() != null && !Objects.equals(createReqVO.getLevel(), resolvedLevel)) {
|
||||||
|
throw exception(MATERIAL_CLASSES_HIERARCHY_INVALID);
|
||||||
|
}
|
||||||
// 插入
|
// 插入
|
||||||
MaterialClassesDO materialClasses = BeanUtils.toBean(createReqVO, MaterialClassesDO.class);
|
MaterialClassesDO materialClasses = BeanUtils.toBean(createReqVO, MaterialClassesDO.class);
|
||||||
|
materialClasses.setParentId(normalizedParentId);
|
||||||
|
materialClasses.setLevel(resolvedLevel);
|
||||||
materialClassesMapper.insert(materialClasses);
|
materialClassesMapper.insert(materialClasses);
|
||||||
// 返回
|
// 返回
|
||||||
return BeanUtils.toBean(materialClasses, MaterialClassesRespVO.class);
|
return BeanUtils.toBean(materialClasses, MaterialClassesRespVO.class);
|
||||||
@@ -45,8 +53,18 @@ public class MaterialClassesServiceImpl implements MaterialClassesService {
|
|||||||
public void updateMaterialClasses(MaterialClassesSaveReqVO updateReqVO) {
|
public void updateMaterialClasses(MaterialClassesSaveReqVO updateReqVO) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateMaterialClassesExists(updateReqVO.getId());
|
validateMaterialClassesExists(updateReqVO.getId());
|
||||||
|
Long normalizedParentId = normalizeParentId(updateReqVO.getParentId());
|
||||||
|
MaterialClassesDO parent = validateAndGetParent(updateReqVO.getId(), normalizedParentId);
|
||||||
|
long resolvedLevel = resolveLevel(parent);
|
||||||
|
validateLevel(resolvedLevel);
|
||||||
|
if (updateReqVO.getLevel() != null && !Objects.equals(updateReqVO.getLevel(), resolvedLevel)) {
|
||||||
|
throw exception(MATERIAL_CLASSES_HIERARCHY_INVALID);
|
||||||
|
}
|
||||||
|
ensureChildrenCompatible(updateReqVO.getId(), resolvedLevel);
|
||||||
// 更新
|
// 更新
|
||||||
MaterialClassesDO updateObj = BeanUtils.toBean(updateReqVO, MaterialClassesDO.class);
|
MaterialClassesDO updateObj = BeanUtils.toBean(updateReqVO, MaterialClassesDO.class);
|
||||||
|
updateObj.setParentId(normalizedParentId);
|
||||||
|
updateObj.setLevel(resolvedLevel);
|
||||||
materialClassesMapper.updateById(updateObj);
|
materialClassesMapper.updateById(updateObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,4 +112,80 @@ public class MaterialClassesServiceImpl implements MaterialClassesService {
|
|||||||
return materialClassesMapper.selectList();
|
return materialClassesMapper.selectList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Long normalizeParentId(Long parentId) {
|
||||||
|
if (parentId == null || parentId <= 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private MaterialClassesDO validateAndGetParent(Long currentId, Long parentId) {
|
||||||
|
if (parentId == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (currentId != null && Objects.equals(currentId, parentId)) {
|
||||||
|
throw exception(MATERIAL_CLASSES_HIERARCHY_INVALID);
|
||||||
|
}
|
||||||
|
MaterialClassesDO parent = materialClassesMapper.selectById(parentId);
|
||||||
|
if (parent == null) {
|
||||||
|
throw exception(MATERIAL_CLASSES_PARENT_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
if (parent.getLevel() == null) {
|
||||||
|
throw exception(MATERIAL_CLASSES_HIERARCHY_INVALID);
|
||||||
|
}
|
||||||
|
if (parent.getLevel() >= MAX_LEVEL) {
|
||||||
|
throw exception(MATERIAL_CLASSES_MAX_LEVEL_EXCEEDED);
|
||||||
|
}
|
||||||
|
if (currentId != null) {
|
||||||
|
Long cursorId = parent.getParentId();
|
||||||
|
while (cursorId != null && cursorId > 0) {
|
||||||
|
if (Objects.equals(cursorId, currentId)) {
|
||||||
|
throw exception(MATERIAL_CLASSES_HIERARCHY_INVALID);
|
||||||
|
}
|
||||||
|
MaterialClassesDO cursor = materialClassesMapper.selectById(cursorId);
|
||||||
|
if (cursor == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cursorId = cursor.getParentId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
private long resolveLevel(MaterialClassesDO parent) {
|
||||||
|
if (parent == null) {
|
||||||
|
return 1L;
|
||||||
|
}
|
||||||
|
Long parentLevel = parent.getLevel();
|
||||||
|
if (parentLevel == null) {
|
||||||
|
throw exception(MATERIAL_CLASSES_HIERARCHY_INVALID);
|
||||||
|
}
|
||||||
|
return parentLevel + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateLevel(long level) {
|
||||||
|
if (level < 1L) {
|
||||||
|
throw exception(MATERIAL_CLASSES_HIERARCHY_INVALID);
|
||||||
|
}
|
||||||
|
if (level > MAX_LEVEL) {
|
||||||
|
throw exception(MATERIAL_CLASSES_MAX_LEVEL_EXCEEDED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ensureChildrenCompatible(Long currentId, long level) {
|
||||||
|
List<MaterialClassesDO> children = materialClassesMapper.selectList(MaterialClassesDO::getParentId, currentId);
|
||||||
|
if (CollUtil.isEmpty(children)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long expectedChildLevel = level + 1;
|
||||||
|
if (expectedChildLevel > MAX_LEVEL) {
|
||||||
|
throw exception(MATERIAL_CLASSES_LEVEL_CONFLICT_WITH_CHILDREN);
|
||||||
|
}
|
||||||
|
boolean mismatch = children.stream()
|
||||||
|
.anyMatch(child -> child.getLevel() == null || !Objects.equals(child.getLevel(), expectedChildLevel));
|
||||||
|
if (mismatch) {
|
||||||
|
throw exception(MATERIAL_CLASSES_HIERARCHY_INVALID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,12 @@ package com.zt.plat.module.base.service.materialproperties;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import jakarta.validation.*;
|
import jakarta.validation.*;
|
||||||
import com.zt.plat.module.base.controller.admin.materialproperties.vo.*;
|
import com.zt.plat.module.base.controller.admin.materialproperties.vo.MaterialPropertiesPageReqVO;
|
||||||
import com.zt.plat.module.base.dal.dataobject.materialproperties.MaterialPropertiesDO;
|
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.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.pojo.PageParam;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物料属性 Service 接口
|
* 物料属性 Service 接口
|
||||||
@@ -49,7 +51,7 @@ public interface MaterialPropertiesService {
|
|||||||
* @param id 编号
|
* @param id 编号
|
||||||
* @return 物料属性
|
* @return 物料属性
|
||||||
*/
|
*/
|
||||||
MaterialPropertiesDO getMaterialProperties(Long id);
|
MaterialPropertiesRespVO getMaterialProperties(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得物料属性分页
|
* 获得物料属性分页
|
||||||
@@ -57,6 +59,14 @@ public interface MaterialPropertiesService {
|
|||||||
* @param pageReqVO 分页查询
|
* @param pageReqVO 分页查询
|
||||||
* @return 物料属性分页
|
* @return 物料属性分页
|
||||||
*/
|
*/
|
||||||
PageResult<MaterialPropertiesDO> getMaterialPropertiesPage(MaterialPropertiesPageReqVO pageReqVO);
|
PageResult<MaterialPropertiesRespVO> getMaterialPropertiesPage(MaterialPropertiesPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得精简的物料属性分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 精简分页结果
|
||||||
|
*/
|
||||||
|
PageResult<MaterialPropertiesSimpleRespVO> getMaterialPropertiesSimplePage(MaterialPropertiesSimplePageReqVO pageReqVO);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,29 +1,43 @@
|
|||||||
package com.zt.plat.module.base.service.materialproperties;
|
package com.zt.plat.module.base.service.materialproperties;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import org.springframework.stereotype.Service;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import com.zt.plat.module.base.controller.admin.materialproperties.vo.*;
|
|
||||||
import com.zt.plat.module.base.dal.dataobject.materialproperties.MaterialPropertiesDO;
|
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.pojo.PageParam;
|
|
||||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
|
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.dal.dao.materialproperties.MaterialPropertiesMapper;
|
import com.zt.plat.module.base.dal.dao.materialproperties.MaterialPropertiesMapper;
|
||||||
|
import com.zt.plat.module.base.dal.dao.quantityUnitRelation.QuantityUnitRelationMapper;
|
||||||
|
import com.zt.plat.module.base.dal.dao.unitQuantity.UnitQuantityMapper;
|
||||||
|
import com.zt.plat.module.base.dal.dao.untInfo.UntInfoMapper;
|
||||||
|
import com.zt.plat.module.base.dal.dao.businessdictionarytype.BusinessDictionaryDataMapper;
|
||||||
|
import com.zt.plat.module.base.dal.dataobject.materialproperties.MaterialPropertiesDO;
|
||||||
|
import com.zt.plat.module.base.dal.dataobject.quantityUnitRelation.QuantityUnitRelationDO;
|
||||||
|
import com.zt.plat.module.base.dal.dataobject.unitQuantity.UnitQuantityDO;
|
||||||
|
import com.zt.plat.module.base.dal.dataobject.untInfo.UntInfoDO;
|
||||||
|
import com.zt.plat.module.base.dal.dataobject.businessdictionarytype.BusinessDictionaryDataDO;
|
||||||
|
|
||||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList;
|
import static com.zt.plat.module.base.enums.ErrorCodeConstants.MATERIAL_PROPERTIES_NOT_EXISTS;
|
||||||
import static com.zt.plat.framework.common.util.collection.CollectionUtils.diffList;
|
|
||||||
import static com.zt.plat.module.base.enums.ErrorCodeConstants.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物料属性 Service 实现类
|
* 物料属性 Service 实现类
|
||||||
*
|
|
||||||
* @author 后台管理-1
|
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@Validated
|
@Validated
|
||||||
@@ -32,39 +46,43 @@ public class MaterialPropertiesServiceImpl implements MaterialPropertiesService
|
|||||||
@Resource
|
@Resource
|
||||||
private MaterialPropertiesMapper materialPropertiesMapper;
|
private MaterialPropertiesMapper materialPropertiesMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private QuantityUnitRelationMapper quantityUnitRelationMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UnitQuantityMapper unitQuantityMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UntInfoMapper untInfoMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BusinessDictionaryDataMapper businessDictionaryDataMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MaterialPropertiesRespVO createMaterialProperties(MaterialPropertiesSaveReqVO createReqVO) {
|
public MaterialPropertiesRespVO createMaterialProperties(MaterialPropertiesSaveReqVO createReqVO) {
|
||||||
// 插入
|
|
||||||
MaterialPropertiesDO materialProperties = BeanUtils.toBean(createReqVO, MaterialPropertiesDO.class);
|
MaterialPropertiesDO materialProperties = BeanUtils.toBean(createReqVO, MaterialPropertiesDO.class);
|
||||||
materialPropertiesMapper.insert(materialProperties);
|
materialPropertiesMapper.insert(materialProperties);
|
||||||
// 返回
|
return CollUtil.getFirst(buildRespList(Collections.singletonList(materialProperties)));
|
||||||
return BeanUtils.toBean(materialProperties, MaterialPropertiesRespVO.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateMaterialProperties(MaterialPropertiesSaveReqVO updateReqVO) {
|
public void updateMaterialProperties(MaterialPropertiesSaveReqVO updateReqVO) {
|
||||||
// 校验存在
|
|
||||||
validateMaterialPropertiesExists(updateReqVO.getId());
|
validateMaterialPropertiesExists(updateReqVO.getId());
|
||||||
// 更新
|
|
||||||
MaterialPropertiesDO updateObj = BeanUtils.toBean(updateReqVO, MaterialPropertiesDO.class);
|
MaterialPropertiesDO updateObj = BeanUtils.toBean(updateReqVO, MaterialPropertiesDO.class);
|
||||||
materialPropertiesMapper.updateById(updateObj);
|
materialPropertiesMapper.updateById(updateObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteMaterialProperties(Long id) {
|
public void deleteMaterialProperties(Long id) {
|
||||||
// 校验存在
|
|
||||||
validateMaterialPropertiesExists(id);
|
validateMaterialPropertiesExists(id);
|
||||||
// 删除
|
|
||||||
materialPropertiesMapper.deleteById(id);
|
materialPropertiesMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteMaterialPropertiesListByIds(List<Long> ids) {
|
public void deleteMaterialPropertiesListByIds(List<Long> ids) {
|
||||||
// 校验存在
|
|
||||||
validateMaterialPropertiesExists(ids);
|
validateMaterialPropertiesExists(ids);
|
||||||
// 删除
|
|
||||||
materialPropertiesMapper.deleteByIds(ids);
|
materialPropertiesMapper.deleteByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateMaterialPropertiesExists(List<Long> ids) {
|
private void validateMaterialPropertiesExists(List<Long> ids) {
|
||||||
List<MaterialPropertiesDO> list = materialPropertiesMapper.selectByIds(ids);
|
List<MaterialPropertiesDO> list = materialPropertiesMapper.selectByIds(ids);
|
||||||
@@ -80,13 +98,122 @@ public class MaterialPropertiesServiceImpl implements MaterialPropertiesService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MaterialPropertiesDO getMaterialProperties(Long id) {
|
public MaterialPropertiesRespVO getMaterialProperties(Long id) {
|
||||||
return materialPropertiesMapper.selectById(id);
|
MaterialPropertiesDO entity = materialPropertiesMapper.selectById(id);
|
||||||
|
if (entity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return CollUtil.getFirst(buildRespList(Collections.singletonList(entity)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<MaterialPropertiesDO> getMaterialPropertiesPage(MaterialPropertiesPageReqVO pageReqVO) {
|
public PageResult<MaterialPropertiesRespVO> getMaterialPropertiesPage(MaterialPropertiesPageReqVO pageReqVO) {
|
||||||
return materialPropertiesMapper.selectPage(pageReqVO);
|
PageResult<MaterialPropertiesDO> pageResult = materialPropertiesMapper.selectPage(pageReqVO);
|
||||||
|
List<MaterialPropertiesRespVO> respList = buildRespList(pageResult.getList());
|
||||||
|
return new PageResult<>(respList, pageResult.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<MaterialPropertiesSimpleRespVO> getMaterialPropertiesSimplePage(MaterialPropertiesSimplePageReqVO pageReqVO) {
|
||||||
|
PageResult<MaterialPropertiesDO> pageResult = materialPropertiesMapper.selectSimplePage(pageReqVO);
|
||||||
|
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||||
|
return new PageResult<>(Collections.emptyList(), pageResult.getTotal());
|
||||||
|
}
|
||||||
|
List<MaterialPropertiesRespVO> respList = buildRespList(pageResult.getList());
|
||||||
|
List<MaterialPropertiesSimpleRespVO> simpleList = buildSimpleList(respList);
|
||||||
|
return new PageResult<>(simpleList, pageResult.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<MaterialPropertiesSimpleRespVO> buildSimpleList(List<MaterialPropertiesRespVO> respList) {
|
||||||
|
if (CollUtil.isEmpty(respList)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return respList.stream().map(item -> {
|
||||||
|
MaterialPropertiesSimpleRespVO vo = new MaterialPropertiesSimpleRespVO();
|
||||||
|
vo.setId(item.getId());
|
||||||
|
vo.setCode(item.getCode());
|
||||||
|
vo.setName(item.getName());
|
||||||
|
vo.setDataType(item.getDataType());
|
||||||
|
vo.setUnitName(item.getUnitName());
|
||||||
|
vo.setUnitSymbol(item.getUnitSymbol());
|
||||||
|
vo.setDictionaryDataValue(item.getDictionaryDataValue());
|
||||||
|
vo.setDictionaryDataLabel(item.getDictionaryDataLabel());
|
||||||
|
return vo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<MaterialPropertiesRespVO> buildRespList(List<MaterialPropertiesDO> list) {
|
||||||
|
if (CollUtil.isEmpty(list)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<Long> relationIds = list.stream()
|
||||||
|
.map(MaterialPropertiesDO::getUnitQuantityId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
Map<Long, QuantityUnitRelationDO> relationMap = relationIds.isEmpty()
|
||||||
|
? Collections.emptyMap()
|
||||||
|
: quantityUnitRelationMapper.selectBatchIds(relationIds).stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toMap(QuantityUnitRelationDO::getId, Function.identity()));
|
||||||
|
|
||||||
|
Set<Long> quantityIds = relationMap.values().stream()
|
||||||
|
.map(QuantityUnitRelationDO::getUntQtyId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
Set<Long> unitIds = relationMap.values().stream()
|
||||||
|
.map(QuantityUnitRelationDO::getUntId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
Map<Long, UnitQuantityDO> quantityMap = quantityIds.isEmpty()
|
||||||
|
? Collections.emptyMap()
|
||||||
|
: unitQuantityMapper.selectBatchIds(quantityIds).stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toMap(UnitQuantityDO::getId, Function.identity()));
|
||||||
|
|
||||||
|
Map<Long, UntInfoDO> unitMap = unitIds.isEmpty()
|
||||||
|
? Collections.emptyMap()
|
||||||
|
: untInfoMapper.selectBatchIds(unitIds).stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toMap(UntInfoDO::getId, Function.identity()));
|
||||||
|
|
||||||
|
Set<String> dictionaryValues = list.stream()
|
||||||
|
.map(MaterialPropertiesDO::getDictionaryDataValue)
|
||||||
|
.filter(StrUtil::isNotBlank)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
Map<String, BusinessDictionaryDataDO> dictionaryMap = dictionaryValues.isEmpty()
|
||||||
|
? Collections.emptyMap()
|
||||||
|
: businessDictionaryDataMapper.selectListByValues(dictionaryValues).stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toMap(BusinessDictionaryDataDO::getValue, Function.identity(), (existing, replacement) -> existing));
|
||||||
|
|
||||||
|
return list.stream().map(item -> {
|
||||||
|
MaterialPropertiesRespVO respVO = BeanUtils.toBean(item, MaterialPropertiesRespVO.class);
|
||||||
|
|
||||||
|
QuantityUnitRelationDO relation = relationMap.get(item.getUnitQuantityId());
|
||||||
|
if (relation != null) {
|
||||||
|
UnitQuantityDO quantity = quantityMap.get(relation.getUntQtyId());
|
||||||
|
if (quantity != null) {
|
||||||
|
respVO.setUnitQuantityName(quantity.getName());
|
||||||
|
}
|
||||||
|
UntInfoDO unit = unitMap.get(relation.getUntId());
|
||||||
|
if (unit != null) {
|
||||||
|
respVO.setUnitName(unit.getName());
|
||||||
|
respVO.setUnitSymbol(unit.getSmb());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BusinessDictionaryDataDO dictionaryDataDO = dictionaryMap.get(item.getDictionaryDataValue());
|
||||||
|
if (dictionaryDataDO != null) {
|
||||||
|
respVO.setDictionaryDataLabel(dictionaryDataDO.getLabel());
|
||||||
|
} else {
|
||||||
|
respVO.setDictionaryDataLabel(respVO.getDictionaryDataValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
return respVO;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ import jakarta.validation.*;
|
|||||||
import com.zt.plat.module.base.controller.admin.quantityUnitRelation.vo.*;
|
import com.zt.plat.module.base.controller.admin.quantityUnitRelation.vo.*;
|
||||||
import com.zt.plat.module.base.dal.dataobject.quantityUnitRelation.QuantityUnitRelationDO;
|
import com.zt.plat.module.base.dal.dataobject.quantityUnitRelation.QuantityUnitRelationDO;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
|
import com.zt.plat.module.base.controller.admin.quantityUnitRelation.vo.QuantityUnitRelationSimplePageReqVO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计量单位量与单位关联 Service 接口
|
* 计量单位量与单位关联 Service 接口
|
||||||
@@ -85,4 +86,12 @@ public interface QuantityUnitRelationService {
|
|||||||
*/
|
*/
|
||||||
void deleteUnitWithRelation(@Valid DeleteUnitWithRelationReqVO deleteReqVO);
|
void deleteUnitWithRelation(@Valid DeleteUnitWithRelationReqVO deleteReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询精简的量纲-单位关联分页,用于下拉框
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询条件
|
||||||
|
* @return 关联关系列表
|
||||||
|
*/
|
||||||
|
PageResult<QuantityUnitRelationSimpleRespVO> getQuantityUnitRelationSimplePage(QuantityUnitRelationSimplePageReqVO pageReqVO);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.zt.plat.module.base.service.quantityUnitRelation;
|
package com.zt.plat.module.base.service.quantityUnitRelation;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -11,11 +12,19 @@ import com.zt.plat.module.base.controller.admin.quantityUnitRelation.vo.*;
|
|||||||
import com.zt.plat.module.base.dal.dataobject.quantityUnitRelation.QuantityUnitRelationDO;
|
import com.zt.plat.module.base.dal.dataobject.quantityUnitRelation.QuantityUnitRelationDO;
|
||||||
import com.zt.plat.framework.common.pojo.PageResult;
|
import com.zt.plat.framework.common.pojo.PageResult;
|
||||||
import com.zt.plat.framework.common.util.object.BeanUtils;
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
|
import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
|
||||||
import com.zt.plat.module.base.dal.dao.quantityUnitRelation.QuantityUnitRelationMapper;
|
import com.zt.plat.module.base.dal.dao.quantityUnitRelation.QuantityUnitRelationMapper;
|
||||||
|
import com.zt.plat.module.base.dal.dao.unitQuantity.UnitQuantityMapper;
|
||||||
|
import com.zt.plat.module.base.dal.dao.untInfo.UntInfoMapper;
|
||||||
import com.zt.plat.module.base.service.untInfo.UntInfoService;
|
import com.zt.plat.module.base.service.untInfo.UntInfoService;
|
||||||
import com.zt.plat.module.base.controller.admin.untInfo.vo.UntInfoSaveReqVO;
|
import com.zt.plat.module.base.controller.admin.untInfo.vo.UntInfoSaveReqVO;
|
||||||
import com.zt.plat.module.base.controller.admin.untInfo.vo.UntInfoRespVO;
|
import com.zt.plat.module.base.controller.admin.untInfo.vo.UntInfoRespVO;
|
||||||
|
import com.zt.plat.module.base.dal.dataobject.unitQuantity.UnitQuantityDO;
|
||||||
|
import com.zt.plat.module.base.dal.dataobject.untInfo.UntInfoDO;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList;
|
import static com.zt.plat.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
@@ -36,6 +45,12 @@ public class QuantityUnitRelationServiceImpl implements QuantityUnitRelationServ
|
|||||||
@Resource
|
@Resource
|
||||||
private UntInfoService untInfoService;
|
private UntInfoService untInfoService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UnitQuantityMapper unitQuantityMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UntInfoMapper untInfoMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QuantityUnitRelationRespVO createQuantityUnitRelation(QuantityUnitRelationSaveReqVO createReqVO) {
|
public QuantityUnitRelationRespVO createQuantityUnitRelation(QuantityUnitRelationSaveReqVO createReqVO) {
|
||||||
// 插入
|
// 插入
|
||||||
@@ -170,4 +185,90 @@ public class QuantityUnitRelationServiceImpl implements QuantityUnitRelationServ
|
|||||||
untInfoService.deleteUntInfo(deleteReqVO.getUntId());
|
untInfoService.deleteUntInfo(deleteReqVO.getUntId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<QuantityUnitRelationSimpleRespVO> getQuantityUnitRelationSimplePage(QuantityUnitRelationSimplePageReqVO pageReqVO) {
|
||||||
|
LambdaQueryWrapperX<QuantityUnitRelationDO> wrapper = new LambdaQueryWrapperX<>();
|
||||||
|
wrapper.eqIfPresent(QuantityUnitRelationDO::getUntQtyId, pageReqVO.getUntQtyId());
|
||||||
|
|
||||||
|
if (StrUtil.isNotBlank(pageReqVO.getKeyword())) {
|
||||||
|
String keyword = pageReqVO.getKeyword();
|
||||||
|
List<Long> matchedQtyIds = unitQuantityMapper.selectList(new LambdaQueryWrapperX<UnitQuantityDO>()
|
||||||
|
.like(UnitQuantityDO::getName, keyword))
|
||||||
|
.stream()
|
||||||
|
.map(UnitQuantityDO::getId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.toList();
|
||||||
|
List<Long> matchedUntIds = untInfoMapper.selectList(new LambdaQueryWrapperX<UntInfoDO>()
|
||||||
|
.like(UntInfoDO::getName, keyword)
|
||||||
|
.or()
|
||||||
|
.like(UntInfoDO::getSmb, keyword))
|
||||||
|
.stream()
|
||||||
|
.map(UntInfoDO::getId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
if (CollUtil.isEmpty(matchedQtyIds) && CollUtil.isEmpty(matchedUntIds)) {
|
||||||
|
return new PageResult<>(Collections.emptyList(), 0L);
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapper.and(w -> {
|
||||||
|
boolean hasCondition = false;
|
||||||
|
if (CollUtil.isNotEmpty(matchedQtyIds)) {
|
||||||
|
w.in(QuantityUnitRelationDO::getUntQtyId, matchedQtyIds);
|
||||||
|
hasCondition = true;
|
||||||
|
}
|
||||||
|
if (CollUtil.isNotEmpty(matchedUntIds)) {
|
||||||
|
if (hasCondition) {
|
||||||
|
w.or();
|
||||||
|
}
|
||||||
|
w.in(QuantityUnitRelationDO::getUntId, matchedUntIds);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapper.orderByAsc(QuantityUnitRelationDO::getUntQtyId).orderByAsc(QuantityUnitRelationDO::getId);
|
||||||
|
|
||||||
|
PageResult<QuantityUnitRelationDO> pageResult = quantityUnitRelationMapper.selectSimplePage(pageReqVO, wrapper);
|
||||||
|
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||||
|
return new PageResult<>(Collections.emptyList(), pageResult.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<Long> qtyIds = pageResult.getList().stream()
|
||||||
|
.map(QuantityUnitRelationDO::getUntQtyId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
Set<Long> unitIds = pageResult.getList().stream()
|
||||||
|
.map(QuantityUnitRelationDO::getUntId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
Map<Long, UnitQuantityDO> qtyMap = qtyIds.isEmpty() ? Collections.emptyMap()
|
||||||
|
: unitQuantityMapper.selectBatchIds(qtyIds).stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toMap(UnitQuantityDO::getId, Function.identity()));
|
||||||
|
Map<Long, UntInfoDO> unitMap = unitIds.isEmpty() ? Collections.emptyMap()
|
||||||
|
: untInfoMapper.selectBatchIds(unitIds).stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toMap(UntInfoDO::getId, Function.identity()));
|
||||||
|
|
||||||
|
List<QuantityUnitRelationSimpleRespVO> respList = pageResult.getList().stream().map(item -> {
|
||||||
|
QuantityUnitRelationSimpleRespVO vo = new QuantityUnitRelationSimpleRespVO();
|
||||||
|
vo.setId(item.getId());
|
||||||
|
vo.setUntQtyId(item.getUntQtyId());
|
||||||
|
UnitQuantityDO quantityDO = qtyMap.get(item.getUntQtyId());
|
||||||
|
if (quantityDO != null) {
|
||||||
|
vo.setUntQtyName(quantityDO.getName());
|
||||||
|
}
|
||||||
|
vo.setUntId(item.getUntId());
|
||||||
|
UntInfoDO untInfoDO = unitMap.get(item.getUntId());
|
||||||
|
if (untInfoDO != null) {
|
||||||
|
vo.setUntName(untInfoDO.getName());
|
||||||
|
vo.setUntSymbol(untInfoDO.getSmb());
|
||||||
|
}
|
||||||
|
vo.setIsBse(item.getIsBse());
|
||||||
|
return vo;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
return new PageResult<>(respList, pageResult.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user