feat:新增计量单位管理模块,包括实体、请求和响应对象,服务接口及实现,控制器,依赖配置等

This commit is contained in:
hewencai
2025-10-22 16:56:13 +08:00
parent 163da2f79d
commit fc289752df
43 changed files with 2124 additions and 1 deletions

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>dsc-base</artifactId>
<groupId>com.zt.plat</groupId>
<version>${revision}</version>
</parent>
<modules>
<module>zt-module-unit-management-api</module>
<module>zt-module-unit-management-server</module>
</modules>
<modelVersion>4.0.0</modelVersion>
<artifactId>zt-module-unit-management</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<description>
计量单位 模块。
</description>
</project>

View File

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>zt-module-unit-management</artifactId>
<groupId>com.zt.plat</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>zt-module-unit-management-api</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>
暴露给其它模块调用
</description>
<dependencies>
<dependency>
<groupId>com.zt.plat</groupId>
<artifactId>zt-common</artifactId>
</dependency>
<!-- Web 相关 -->
<dependency>
<groupId>org.springdoc</groupId> <!-- 接口文档:使用最新版本的 Swagger 模型 -->
<artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- 参数校验 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<optional>true</optional>
</dependency>
<!-- RPC 远程调用相关 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,22 @@
package com.zt.plat.module.unitmanagement.enums;
import com.zt.plat.framework.common.exception.ErrorCode;
/**
* unit-management 模块的错误码常量
*/
public interface UnitErrorCodeConstants {
ErrorCode QUANTITY_UNIT_RELATION_NOT_EXISTS =
new ErrorCode(1_010_000_001, "计量单位量与单位关联不存在");
ErrorCode UNIT_CONVERSION_NOT_EXISTS =
new ErrorCode(1_010_000_002, "单位转换记录不存在");
ErrorCode UNIT_QUANTITY_NOT_EXISTS =
new ErrorCode(1_010_000_003, "单位数量记录不存在");
ErrorCode UNT_INFO_NOT_EXISTS =
new ErrorCode(1_010_000_004, "单位信息记录不存在");
}

View File

@@ -0,0 +1,151 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>zt-module-unit-management</artifactId>
<groupId>com.zt.plat</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<artifactId>zt-module-unit-management-server</artifactId>
<name>${project.artifactId}</name>
<description>
计量单位管理 模块。
</description>
<dependencies>
<!-- Spring Cloud 基础 -->
<dependency>
<groupId>com.zt.plat</groupId>
<artifactId>zt-spring-boot-starter-env</artifactId>
</dependency>
<!-- 依赖服务 -->
<dependency>
<groupId>com.zt.plat</groupId>
<artifactId>zt-module-system-api</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.zt.plat</groupId>
<artifactId>zt-module-infra-api</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.zt.plat</groupId>
<artifactId>zt-module-unit-management-api</artifactId>
<version>${revision}</version>
</dependency>
<!-- 业务组件 -->
<dependency>
<groupId>com.zt.plat</groupId>
<artifactId>zt-spring-boot-starter-biz-data-permission</artifactId>
</dependency>
<dependency>
<groupId>com.zt.plat</groupId>
<artifactId>zt-spring-boot-starter-biz-tenant</artifactId>
</dependency>
<!-- Web 相关 -->
<dependency>
<groupId>com.zt.plat</groupId>
<artifactId>zt-spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.zt.plat</groupId>
<artifactId>zt-spring-boot-starter-security</artifactId>
</dependency>
<!-- DB 相关 -->
<dependency>
<groupId>com.zt.plat</groupId>
<artifactId>zt-spring-boot-starter-mybatis</artifactId>
</dependency>
<dependency>
<groupId>com.zt.plat</groupId>
<artifactId>zt-spring-boot-starter-redis</artifactId>
</dependency>
<!-- RPC 远程调用相关 -->
<dependency>
<groupId>com.zt.plat</groupId>
<artifactId>zt-spring-boot-starter-rpc</artifactId>
</dependency>
<!-- Registry 注册中心相关 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- Config 配置中心相关 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- Job 定时任务相关 -->
<dependency>
<groupId>com.zt.plat</groupId>
<artifactId>zt-spring-boot-starter-job</artifactId>
</dependency>
<!-- 消息队列相关 -->
<dependency>
<groupId>com.zt.plat</groupId>
<artifactId>zt-spring-boot-starter-mq</artifactId>
</dependency>
<!-- Test 测试相关 -->
<dependency>
<groupId>com.zt.plat</groupId>
<artifactId>zt-spring-boot-starter-test</artifactId>
</dependency>
<!-- 工具类相关 -->
<dependency>
<groupId>com.zt.plat</groupId>
<artifactId>zt-spring-boot-starter-excel</artifactId>
</dependency>
<!-- 监控相关 -->
<dependency>
<groupId>com.zt.plat</groupId>
<artifactId>zt-spring-boot-starter-monitor</artifactId>
</dependency>
<dependency>
<groupId>com.zt.plat</groupId>
<artifactId>zt-spring-boot-starter-biz-business</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>
<build>
<!-- 设置构建的 jar 包名 -->
<finalName>${project.artifactId}</finalName>
<!-- <plugins>-->
<!-- &lt;!&ndash; 打包 &ndash;&gt;-->
<!-- <plugin>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
<!-- <version>${spring.boot.version}</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <goals>-->
<!-- <goal>repackage</goal> &lt;!&ndash; 将引入的 jar 打入其中 &ndash;&gt;-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<!-- </plugins>-->
</build>
</project>

View File

@@ -0,0 +1,116 @@
package com.zt.plat.module.unitmanagement.controller.admin.QuantityUnitRelation;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import com.zt.plat.framework.business.interceptor.BusinessControllerMarker;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;
import java.io.IOException;
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
import com.zt.plat.framework.common.pojo.PageParam;
import com.zt.plat.framework.common.pojo.PageResult;
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 com.zt.plat.framework.excel.core.util.ExcelUtils;
import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
import com.zt.plat.module.unitmanagement.controller.admin.QuantityUnitRelation.vo.*;
import com.zt.plat.module.unitmanagement.dal.dataobject.QuantityUnitRelation.QuantityUnitRelationDO;
import com.zt.plat.module.unitmanagement.service.QuantityUnitRelation.QuantityUnitRelationService;
@Tag(name = "管理后台 - 计量单位量与单位关联")
@RestController
@RequestMapping("/base/unit-management/quantity-unit-relation")
@Validated
public class QuantityUnitRelationController implements BusinessControllerMarker {
@Resource
private QuantityUnitRelationService quantityUnitRelationService;
@PostMapping("/create")
@Operation(summary = "创建计量单位量与单位关联")
@PreAuthorize("@ss.hasPermission('unitmanagement:quantity-unit-relation:create')")
public CommonResult<QuantityUnitRelationRespVO> createQuantityUnitRelation(@Valid @RequestBody QuantityUnitRelationSaveReqVO createReqVO) {
return success(quantityUnitRelationService.createQuantityUnitRelation(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新计量单位量与单位关联")
@PreAuthorize("@ss.hasPermission('unitmanagement:quantity-unit-relation:update')")
public CommonResult<Boolean> updateQuantityUnitRelation(@Valid @RequestBody QuantityUnitRelationSaveReqVO updateReqVO) {
quantityUnitRelationService.updateQuantityUnitRelation(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除计量单位量与单位关联")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('unitmanagement:quantity-unit-relation:delete')")
public CommonResult<Boolean> deleteQuantityUnitRelation(@RequestParam("id") Long id) {
quantityUnitRelationService.deleteQuantityUnitRelation(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除计量单位量与单位关联")
@PreAuthorize("@ss.hasPermission('unitmanagement:quantity-unit-relation:delete')")
public CommonResult<Boolean> deleteQuantityUnitRelationList(@RequestBody BatchDeleteReqVO req) {
quantityUnitRelationService.deleteQuantityUnitRelationListByIds(req.getIds());
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得计量单位量与单位关联")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('unitmanagement:quantity-unit-relation:query')")
public CommonResult<QuantityUnitRelationRespVO> getQuantityUnitRelation(@RequestParam("id") Long id) {
QuantityUnitRelationDO quantityUnitRelation = quantityUnitRelationService.getQuantityUnitRelation(id);
return success(BeanUtils.toBean(quantityUnitRelation, QuantityUnitRelationRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得计量单位量与单位关联分页")
@PreAuthorize("@ss.hasPermission('unitmanagement:quantity-unit-relation:query')")
public CommonResult<PageResult<QuantityUnitRelationRespVO>> getQuantityUnitRelationPage(@Valid QuantityUnitRelationPageReqVO pageReqVO) {
PageResult<QuantityUnitRelationDO> pageResult = quantityUnitRelationService.getQuantityUnitRelationPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, QuantityUnitRelationRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出计量单位量与单位关联 Excel")
@PreAuthorize("@ss.hasPermission('unitmanagement:quantity-unit-relation:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportQuantityUnitRelationExcel(@Valid QuantityUnitRelationPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<QuantityUnitRelationDO> list = quantityUnitRelationService.getQuantityUnitRelationPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "计量单位量与单位关联.xls", "数据", QuantityUnitRelationRespVO.class,
BeanUtils.toBean(list, QuantityUnitRelationRespVO.class));
}
@PostMapping("/batch-save")
@Operation(summary = "批量保存计量单位量与单位关联")
@PreAuthorize("@ss.hasPermission('unitmanagement:quantity-unit-relation:create')")
public CommonResult<Boolean> batchSaveQuantityUnitRelations(@Valid @RequestBody QuantityUnitRelationBatchSaveReqVO batchSaveReqVO) {
quantityUnitRelationService.batchSaveQuantityUnitRelations(batchSaveReqVO);
return success(true);
}
}

View File

@@ -0,0 +1,35 @@
package com.zt.plat.module.unitmanagement.controller.admin.QuantityUnitRelation.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import jakarta.validation.constraints.*;
@Schema(description = "管理后台 - 计量单位量与单位关联批量保存 Request VO")
@Data
public class QuantityUnitRelationBatchSaveReqVO {
@Schema(description = "计量单位量ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11015")
@NotNull(message = "计量单位量ID不能为空")
private Long untQtyId;
@Schema(description = "单位关联列表", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "单位关联列表不能为空")
private List<UnitRelationItemVO> unitRelations;
@Schema(description = "单位关联项")
@Data
public static class UnitRelationItemVO {
@Schema(description = "主键ID(新增时为空,更新时必填)", example = "11015")
private Long id;
@Schema(description = "计量单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "30976")
@NotNull(message = "计量单位ID不能为空")
private Long untId;
@Schema(description = "是否基准单位-标识该维度基准单位")
private Integer isBse;
}
}

View File

@@ -0,0 +1,22 @@
package com.zt.plat.module.unitmanagement.controller.admin.QuantityUnitRelation.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.zt.plat.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 计量单位量与单位关联分页 Request VO")
@Data
public class QuantityUnitRelationPageReqVO extends PageParam {
@Schema(description = "所属量纲")
private Long untQtyId;
@Schema(description = "是否基准单位-标识该维度基准单位")
private Integer isBse;
}

View File

@@ -0,0 +1,34 @@
package com.zt.plat.module.unitmanagement.controller.admin.QuantityUnitRelation.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 计量单位量与单位关联 Response VO")
@Data
@ExcelIgnoreUnannotated
public class QuantityUnitRelationRespVO {
@Schema(description = "ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11015")
@ExcelProperty("ID")
private Long id;
@Schema(description = "计量单位量ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11015")
@ExcelProperty("计量单位量ID")
private Long untQtyId;
@Schema(description = "计量单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "30976")
@ExcelProperty("计量单位ID")
private Long untId;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "是否基准单位-标识该维度基准单位")
@ExcelProperty("是否基准单位-标识该维度基准单位")
private Integer isBse;
}

View File

@@ -0,0 +1,24 @@
package com.zt.plat.module.unitmanagement.controller.admin.QuantityUnitRelation.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import jakarta.validation.constraints.*;
@Schema(description = "管理后台 - 计量单位量与单位关联新增/修改 Request VO")
@Data
public class QuantityUnitRelationSaveReqVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11015")
private Long id;
@Schema(description = "计量单位量ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "11015")
private Long untQtyId;
@Schema(description = "计量单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "30976")
private Long untId;
@Schema(description = "是否基准单位-标识该维度基准单位")
private Integer isBse;
}

View File

@@ -0,0 +1,108 @@
package com.zt.plat.module.unitmanagement.controller.admin.UnitConversion;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import com.zt.plat.framework.business.interceptor.BusinessControllerMarker;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;
import java.io.IOException;
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
import com.zt.plat.framework.common.pojo.PageParam;
import com.zt.plat.framework.common.pojo.PageResult;
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 com.zt.plat.framework.excel.core.util.ExcelUtils;
import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
import com.zt.plat.module.unitmanagement.controller.admin.UnitConversion.vo.*;
import com.zt.plat.module.unitmanagement.dal.dataobject.UnitConversion.UnitConversionDO;
import com.zt.plat.module.unitmanagement.service.UnitConversion.UnitConversionService;
@Tag(name = "管理后台 - 单位转换")
@RestController
@RequestMapping("/base/unit-management/unit-conversion")
@Validated
public class UnitConversionController implements BusinessControllerMarker {
@Resource
private UnitConversionService unitConversionService;
@PostMapping("/create")
@Operation(summary = "创建单位转换")
@PreAuthorize("@ss.hasPermission('unitmanagement:unit-conversion:create')")
public CommonResult<UnitConversionRespVO> createUnitConversion(@Valid @RequestBody UnitConversionSaveReqVO createReqVO) {
return success(unitConversionService.createUnitConversion(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新单位转换")
@PreAuthorize("@ss.hasPermission('unitmanagement:unit-conversion:update')")
public CommonResult<Boolean> updateUnitConversion(@Valid @RequestBody UnitConversionSaveReqVO updateReqVO) {
unitConversionService.updateUnitConversion(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除单位转换")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('unitmanagement:unit-conversion:delete')")
public CommonResult<Boolean> deleteUnitConversion(@RequestParam("id") Long id) {
unitConversionService.deleteUnitConversion(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除单位转换")
@PreAuthorize("@ss.hasPermission('unitmanagement:unit-conversion:delete')")
public CommonResult<Boolean> deleteUnitConversionList(@RequestBody BatchDeleteReqVO req) {
unitConversionService.deleteUnitConversionListByIds(req.getIds());
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得单位转换")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('unitmanagement:unit-conversion:query')")
public CommonResult<UnitConversionRespVO> getUnitConversion(@RequestParam("id") Long id) {
UnitConversionDO unitConversion = unitConversionService.getUnitConversion(id);
return success(BeanUtils.toBean(unitConversion, UnitConversionRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得单位转换分页")
@PreAuthorize("@ss.hasPermission('unitmanagement:unit-conversion:query')")
public CommonResult<PageResult<UnitConversionRespVO>> getUnitConversionPage(@Valid UnitConversionPageReqVO pageReqVO) {
PageResult<UnitConversionDO> pageResult = unitConversionService.getUnitConversionPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, UnitConversionRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出单位转换 Excel")
@PreAuthorize("@ss.hasPermission('unitmanagement:unit-conversion:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportUnitConversionExcel(@Valid UnitConversionPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<UnitConversionDO> list = unitConversionService.getUnitConversionPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "单位转换.xls", "数据", UnitConversionRespVO.class,
BeanUtils.toBean(list, UnitConversionRespVO.class));
}
}

View File

@@ -0,0 +1,33 @@
package com.zt.plat.module.unitmanagement.controller.admin.UnitConversion.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.zt.plat.framework.common.pojo.PageParam;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 单位转换分页 Request VO")
@Data
public class UnitConversionPageReqVO extends PageParam {
@Schema(description = "源单位ID", example = "26239")
private Long srcUntId;
@Schema(description = "目标单位ID", example = "25640")
private Long tgtUntId;
@Schema(description = "转换因子")
private BigDecimal fctr;
@Schema(description = "转换公式")
private String fmu;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@@ -0,0 +1,40 @@
package com.zt.plat.module.unitmanagement.controller.admin.UnitConversion.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 单位转换 Response VO")
@Data
@ExcelIgnoreUnannotated
public class UnitConversionRespVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "339")
@ExcelProperty("主键ID")
private Long id;
@Schema(description = "源单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "26239")
@ExcelProperty("源单位ID")
private Long srcUntId;
@Schema(description = "目标单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25640")
@ExcelProperty("目标单位ID")
private Long tgtUntId;
@Schema(description = "转换因子")
@ExcelProperty("转换因子")
private BigDecimal fctr;
@Schema(description = "转换公式", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("转换公式")
private String fmu;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,30 @@
package com.zt.plat.module.unitmanagement.controller.admin.UnitConversion.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import jakarta.validation.constraints.*;
import java.math.BigDecimal;
@Schema(description = "管理后台 - 单位转换新增/修改 Request VO")
@Data
public class UnitConversionSaveReqVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "339")
private Long id;
@Schema(description = "源单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "26239")
@NotNull(message = "源单位ID不能为空")
private Long srcUntId;
@Schema(description = "目标单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "25640")
@NotNull(message = "目标单位ID不能为空")
private Long tgtUntId;
@Schema(description = "转换因子")
private BigDecimal fctr;
@Schema(description = "转换公式", requiredMode = Schema.RequiredMode.REQUIRED)
private String fmu;
}

View File

@@ -0,0 +1,108 @@
package com.zt.plat.module.unitmanagement.controller.admin.UnitQuantity;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import com.zt.plat.framework.business.interceptor.BusinessControllerMarker;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;
import java.io.IOException;
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
import com.zt.plat.framework.common.pojo.PageParam;
import com.zt.plat.framework.common.pojo.PageResult;
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 com.zt.plat.framework.excel.core.util.ExcelUtils;
import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
import com.zt.plat.module.unitmanagement.controller.admin.UnitQuantity.vo.*;
import com.zt.plat.module.unitmanagement.dal.dataobject.UnitQuantity.UnitQuantityDO;
import com.zt.plat.module.unitmanagement.service.UnitQuantity.UnitQuantityService;
@Tag(name = "管理后台 - 计量单位量")
@RestController
@RequestMapping("/base/unit-management/unit-quantity")
@Validated
public class UnitQuantityController implements BusinessControllerMarker {
@Resource
private UnitQuantityService unitQuantityService;
@PostMapping("/create")
@Operation(summary = "创建计量单位量")
@PreAuthorize("@ss.hasPermission('unitmanagement:unit-quantity:create')")
public CommonResult<UnitQuantityRespVO> createUnitQuantity(@Valid @RequestBody UnitQuantitySaveReqVO createReqVO) {
return success(unitQuantityService.createUnitQuantity(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新计量单位量")
@PreAuthorize("@ss.hasPermission('unitmanagement:unit-quantity:update')")
public CommonResult<Boolean> updateUnitQuantity(@Valid @RequestBody UnitQuantitySaveReqVO updateReqVO) {
unitQuantityService.updateUnitQuantity(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除计量单位量")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('unitmanagement:unit-quantity:delete')")
public CommonResult<Boolean> deleteUnitQuantity(@RequestParam("id") Long id) {
unitQuantityService.deleteUnitQuantity(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除计量单位量")
@PreAuthorize("@ss.hasPermission('unitmanagement:unit-quantity:delete')")
public CommonResult<Boolean> deleteUnitQuantityList(@RequestBody BatchDeleteReqVO req) {
unitQuantityService.deleteUnitQuantityListByIds(req.getIds());
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得计量单位量")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('unitmanagement:unit-quantity:query')")
public CommonResult<UnitQuantityRespVO> getUnitQuantity(@RequestParam("id") Long id) {
UnitQuantityDO unitQuantity = unitQuantityService.getUnitQuantity(id);
return success(BeanUtils.toBean(unitQuantity, UnitQuantityRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得计量单位量分页")
@PreAuthorize("@ss.hasPermission('unitmanagement:unit-quantity:query')")
public CommonResult<PageResult<UnitQuantityRespVO>> getUnitQuantityPage(@Valid UnitQuantityPageReqVO pageReqVO) {
PageResult<UnitQuantityDO> pageResult = unitQuantityService.getUnitQuantityPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, UnitQuantityRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出计量单位量 Excel")
@PreAuthorize("@ss.hasPermission('unitmanagement:unit-quantity:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportUnitQuantityExcel(@Valid UnitQuantityPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<UnitQuantityDO> list = unitQuantityService.getUnitQuantityPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "计量单位量.xls", "数据", UnitQuantityRespVO.class,
BeanUtils.toBean(list, UnitQuantityRespVO.class));
}
}

View File

@@ -0,0 +1,29 @@
package com.zt.plat.module.unitmanagement.controller.admin.UnitQuantity.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.zt.plat.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 计量单位量分页 Request VO")
@Data
public class UnitQuantityPageReqVO extends PageParam {
@Schema(description = "计量名称", example = "王五")
private String name;
@Schema(description = "计量符号")
private String symbol;
@Schema(description = "计量描述")
private String dsp;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@@ -0,0 +1,35 @@
package com.zt.plat.module.unitmanagement.controller.admin.UnitQuantity.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 计量单位量 Response VO")
@Data
@ExcelIgnoreUnannotated
public class UnitQuantityRespVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "314")
@ExcelProperty("主键ID")
private Long id;
@Schema(description = "计量名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@ExcelProperty("计量名称")
private String name;
@Schema(description = "计量符号", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("计量符号")
private String symbol;
@Schema(description = "计量描述", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("计量描述")
private String dsp;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,27 @@
package com.zt.plat.module.unitmanagement.controller.admin.UnitQuantity.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import jakarta.validation.constraints.*;
@Schema(description = "管理后台 - 计量单位量新增/修改 Request VO")
@Data
public class UnitQuantitySaveReqVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "314")
private Long id;
@Schema(description = "计量名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@NotEmpty(message = "计量名称不能为空")
private String name;
@Schema(description = "计量符号", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "计量符号不能为空")
private String symbol;
@Schema(description = "计量描述", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "计量描述不能为空")
private String dsp;
}

View File

@@ -0,0 +1,108 @@
package com.zt.plat.module.unitmanagement.controller.admin.UntInfo;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import com.zt.plat.framework.business.interceptor.BusinessControllerMarker;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;
import java.io.IOException;
import com.zt.plat.framework.common.pojo.vo.BatchDeleteReqVO;
import com.zt.plat.framework.common.pojo.PageParam;
import com.zt.plat.framework.common.pojo.PageResult;
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 com.zt.plat.framework.excel.core.util.ExcelUtils;
import com.zt.plat.framework.apilog.core.annotation.ApiAccessLog;
import static com.zt.plat.framework.apilog.core.enums.OperateTypeEnum.*;
import com.zt.plat.module.unitmanagement.controller.admin.UntInfo.vo.*;
import com.zt.plat.module.unitmanagement.dal.dataobject.UntInfo.UntInfoDO;
import com.zt.plat.module.unitmanagement.service.UntInfo.UntInfoService;
@Tag(name = "管理后台 - 计量单位")
@RestController
@RequestMapping("/base/unit-management/unt-info")
@Validated
public class UntInfoController implements BusinessControllerMarker {
@Resource
private UntInfoService untInfoService;
@PostMapping("/create")
@Operation(summary = "创建计量单位")
@PreAuthorize("@ss.hasPermission('unitmanagement:unt-info:create')")
public CommonResult<UntInfoRespVO> createUntInfo(@Valid @RequestBody UntInfoSaveReqVO createReqVO) {
return success(untInfoService.createUntInfo(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新计量单位")
@PreAuthorize("@ss.hasPermission('unitmanagement:unt-info:update')")
public CommonResult<Boolean> updateUntInfo(@Valid @RequestBody UntInfoSaveReqVO updateReqVO) {
untInfoService.updateUntInfo(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除计量单位")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('unitmanagement:unt-info:delete')")
public CommonResult<Boolean> deleteUntInfo(@RequestParam("id") Long id) {
untInfoService.deleteUntInfo(id);
return success(true);
}
@DeleteMapping("/delete-list")
@Parameter(name = "ids", description = "编号", required = true)
@Operation(summary = "批量删除计量单位")
@PreAuthorize("@ss.hasPermission('unitmanagement:unt-info:delete')")
public CommonResult<Boolean> deleteUntInfoList(@RequestBody BatchDeleteReqVO req) {
untInfoService.deleteUntInfoListByIds(req.getIds());
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得计量单位")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('unitmanagement:unt-info:query')")
public CommonResult<UntInfoRespVO> getUntInfo(@RequestParam("id") Long id) {
UntInfoDO untInfo = untInfoService.getUntInfo(id);
return success(BeanUtils.toBean(untInfo, UntInfoRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得计量单位分页")
@PreAuthorize("@ss.hasPermission('unitmanagement:unt-info:query')")
public CommonResult<PageResult<UntInfoRespVO>> getUntInfoPage(@Valid UntInfoPageReqVO pageReqVO) {
PageResult<UntInfoDO> pageResult = untInfoService.getUntInfoPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, UntInfoRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出计量单位 Excel")
@PreAuthorize("@ss.hasPermission('unitmanagement:unt-info:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportUntInfoExcel(@Valid UntInfoPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<UntInfoDO> list = untInfoService.getUntInfoPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "计量单位.xls", "数据", UntInfoRespVO.class,
BeanUtils.toBean(list, UntInfoRespVO.class));
}
}

View File

@@ -0,0 +1,26 @@
package com.zt.plat.module.unitmanagement.controller.admin.UntInfo.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.zt.plat.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.zt.plat.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 计量单位分页 Request VO")
@Data
public class UntInfoPageReqVO extends PageParam {
@Schema(description = "单位名称", example = "王五")
private String name;
@Schema(description = "单位符号")
private String smb;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@@ -0,0 +1,31 @@
package com.zt.plat.module.unitmanagement.controller.admin.UntInfo.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 计量单位 Response VO")
@Data
@ExcelIgnoreUnannotated
public class UntInfoRespVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18527")
@ExcelProperty("主键ID")
private Long id;
@Schema(description = "单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@ExcelProperty("单位名称")
private String name;
@Schema(description = "单位符号", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("单位符号")
private String smb;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@@ -0,0 +1,23 @@
package com.zt.plat.module.unitmanagement.controller.admin.UntInfo.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import jakarta.validation.constraints.*;
@Schema(description = "管理后台 - 计量单位新增/修改 Request VO")
@Data
public class UntInfoSaveReqVO {
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "18527")
private Long id;
@Schema(description = "单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@NotEmpty(message = "单位名称不能为空")
private String name;
@Schema(description = "单位符号", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "单位符号不能为空")
private String smb;
}

View File

@@ -0,0 +1,38 @@
package com.zt.plat.module.unitmanagement.dal.dao.QuantityUnitRelation;
import java.util.*;
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.module.unitmanagement.dal.dataobject.QuantityUnitRelation.QuantityUnitRelationDO;
import org.apache.ibatis.annotations.Mapper;
import com.zt.plat.module.unitmanagement.controller.admin.QuantityUnitRelation.vo.*;
/**
* 计量单位量与单位关联 Mapper
*
* @author 后台管理-1
*/
@Mapper
public interface QuantityUnitRelationMapper extends BaseMapperX<QuantityUnitRelationDO> {
default PageResult<QuantityUnitRelationDO> selectPage(QuantityUnitRelationPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<QuantityUnitRelationDO>()
.eqIfPresent(QuantityUnitRelationDO::getUntQtyId, reqVO.getUntQtyId())
.eqIfPresent(QuantityUnitRelationDO::getIsBse, reqVO.getIsBse())
.orderByDesc(QuantityUnitRelationDO::getUntQtyId));
}
/**
* 根据量纲ID查询所有关联关系
*
* @param untQtyId 量纲ID
* @return 关联关系列表
*/
default List<QuantityUnitRelationDO> selectListByUntQtyId(Long untQtyId) {
return selectList(new LambdaQueryWrapperX<QuantityUnitRelationDO>()
.eq(QuantityUnitRelationDO::getUntQtyId, untQtyId));
}
}

View File

@@ -0,0 +1,30 @@
package com.zt.plat.module.unitmanagement.dal.dao.UnitConversion;
import java.util.*;
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.module.unitmanagement.dal.dataobject.UnitConversion.UnitConversionDO;
import org.apache.ibatis.annotations.Mapper;
import com.zt.plat.module.unitmanagement.controller.admin.UnitConversion.vo.*;
/**
* 单位转换 Mapper
*
* @author 后台管理-1
*/
@Mapper
public interface UnitConversionMapper extends BaseMapperX<UnitConversionDO> {
default PageResult<UnitConversionDO> selectPage(UnitConversionPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<UnitConversionDO>()
.eqIfPresent(UnitConversionDO::getSrcUntId, reqVO.getSrcUntId())
.eqIfPresent(UnitConversionDO::getTgtUntId, reqVO.getTgtUntId())
.eqIfPresent(UnitConversionDO::getFctr, reqVO.getFctr())
.eqIfPresent(UnitConversionDO::getFmu, reqVO.getFmu())
.betweenIfPresent(UnitConversionDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(UnitConversionDO::getId));
}
}

View File

@@ -0,0 +1,29 @@
package com.zt.plat.module.unitmanagement.dal.dao.UnitQuantity;
import java.util.*;
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.module.unitmanagement.dal.dataobject.UnitQuantity.UnitQuantityDO;
import org.apache.ibatis.annotations.Mapper;
import com.zt.plat.module.unitmanagement.controller.admin.UnitQuantity.vo.*;
/**
* 计量单位量 Mapper
*
* @author 后台管理-1
*/
@Mapper
public interface UnitQuantityMapper extends BaseMapperX<UnitQuantityDO> {
default PageResult<UnitQuantityDO> selectPage(UnitQuantityPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<UnitQuantityDO>()
.likeIfPresent(UnitQuantityDO::getName, reqVO.getName())
.eqIfPresent(UnitQuantityDO::getSymbol, reqVO.getSymbol())
.eqIfPresent(UnitQuantityDO::getDsp, reqVO.getDsp())
.betweenIfPresent(UnitQuantityDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(UnitQuantityDO::getId));
}
}

View File

@@ -0,0 +1,28 @@
package com.zt.plat.module.unitmanagement.dal.dao.UntInfo;
import java.util.*;
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.module.unitmanagement.dal.dataobject.UntInfo.UntInfoDO;
import org.apache.ibatis.annotations.Mapper;
import com.zt.plat.module.unitmanagement.controller.admin.UntInfo.vo.*;
/**
* 计量单位 Mapper
*
* @author 后台管理-1
*/
@Mapper
public interface UntInfoMapper extends BaseMapperX<UntInfoDO> {
default PageResult<UntInfoDO> selectPage(UntInfoPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<UntInfoDO>()
.likeIfPresent(UntInfoDO::getName, reqVO.getName())
.eqIfPresent(UntInfoDO::getSmb, reqVO.getSmb())
.betweenIfPresent(UntInfoDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(UntInfoDO::getId));
}
}

View File

@@ -0,0 +1,49 @@
package com.zt.plat.module.unitmanagement.dal.dataobject.QuantityUnitRelation;
import com.zt.plat.framework.mybatis.core.dataobject.BaseDO;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
/**
* 计量单位量与单位关联 DO
*
* @author 后台管理-1
*/
@TableName("bse_unt_qty_unt")
@KeySequence("bse_unt_qty_unt_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
/**
* 支持业务基类继承isBusiness=true 时继承 BusinessBaseDO否则继承 BaseDO
*/
public class QuantityUnitRelationDO extends BaseDO {
/**
* 主键ID
*/
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* 计量单位量ID
*/
@TableField("UNT_QTY_ID")
private Long untQtyId;
/**
* 计量单位ID
*/
@TableField("UNT_ID")
private Long untId;
/**
* 是否基准单位-标识该维度基准单位
*/
@TableField("IS_BSE")
private Integer isBse;
}

View File

@@ -0,0 +1,56 @@
package com.zt.plat.module.unitmanagement.dal.dataobject.UnitConversion;
import com.zt.plat.framework.mybatis.core.dataobject.BaseDO;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
/**
* 单位转换 DO
*
* @author 后台管理-1
*/
@TableName("bse_unt_cnv")
@KeySequence("bse_unt_cnv_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
/**
* 支持业务基类继承isBusiness=true 时继承 BusinessBaseDO否则继承 BaseDO
*/
public class UnitConversionDO extends BaseDO {
/**
* 主键ID
*/
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* 源单位ID
*/
@TableField("SRC_UNT_ID")
private Long srcUntId;
/**
* 目标单位ID
*/
@TableField("TGT_UNT_ID")
private Long tgtUntId;
/**
* 转换因子
*/
@TableField("FCTR")
private BigDecimal fctr;
/**
* 转换公式
*/
@TableField("FMU")
private String fmu;
}

View File

@@ -0,0 +1,50 @@
package com.zt.plat.module.unitmanagement.dal.dataobject.UnitQuantity;
import com.zt.plat.framework.mybatis.core.dataobject.BaseDO;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
/**
* 计量单位量 DO
*
* @author 后台管理-1
*/
@TableName("bse_unt_qty")
@KeySequence("bse_unt_qty_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
/**
* 支持业务基类继承isBusiness=true 时继承 BusinessBaseDO否则继承 BaseDO
*/
public class UnitQuantityDO extends BaseDO {
/**
* 主键ID
*/
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* 计量名称
*/
@TableField("NAME")
private String name;
/**
* 计量符号
*/
@TableField("SYMBOL")
private String symbol;
/**
* 计量描述
*/
@TableField("DSP")
private String dsp;
}

View File

@@ -0,0 +1,45 @@
package com.zt.plat.module.unitmanagement.dal.dataobject.UntInfo;
import com.zt.plat.framework.mybatis.core.dataobject.BaseDO;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
/**
* 计量单位 DO
*
* @author 后台管理-1
*/
@TableName("bse_unt_inf")
@KeySequence("bse_unt_inf_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
/**
* 支持业务基类继承isBusiness=true 时继承 BusinessBaseDO否则继承 BaseDO
*/
public class UntInfoDO extends BaseDO {
/**
* 主键ID
*/
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/**
* 单位名称
*/
@TableField("NAME")
private String name;
/**
* 单位符号
*/
@TableField("SMB")
private String smb;
}

View File

@@ -0,0 +1,70 @@
package com.zt.plat.module.unitmanagement.service.QuantityUnitRelation;
import java.util.*;
import jakarta.validation.*;
import com.zt.plat.module.unitmanagement.controller.admin.QuantityUnitRelation.vo.*;
import com.zt.plat.module.unitmanagement.dal.dataobject.QuantityUnitRelation.QuantityUnitRelationDO;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.pojo.PageParam;
/**
* 计量单位量与单位关联 Service 接口
*
* @author 后台管理-1
*/
public interface QuantityUnitRelationService {
/**
* 创建计量单位量与单位关联
*
* @param createReqVO 创建信息
* @return 编号
*/
QuantityUnitRelationRespVO createQuantityUnitRelation(@Valid QuantityUnitRelationSaveReqVO createReqVO);
/**
* 更新计量单位量与单位关联
*
* @param updateReqVO 更新信息
*/
void updateQuantityUnitRelation(@Valid QuantityUnitRelationSaveReqVO updateReqVO);
/**
* 删除计量单位量与单位关联
*
* @param id 编号
*/
void deleteQuantityUnitRelation(Long id);
/**
* 批量删除计量单位量与单位关联
*
* @param ids 编号
*/
void deleteQuantityUnitRelationListByIds(List<Long> ids);
/**
* 获得计量单位量与单位关联
*
* @param id 编号
* @return 计量单位量与单位关联
*/
QuantityUnitRelationDO getQuantityUnitRelation(Long id);
/**
* 获得计量单位量与单位关联分页
*
* @param pageReqVO 分页查询
* @return 计量单位量与单位关联分页
*/
PageResult<QuantityUnitRelationDO> getQuantityUnitRelationPage(QuantityUnitRelationPageReqVO pageReqVO);
/**
* 批量保存计量单位量与单位关联
* 根据传入的量纲ID和单位列表,进行新增、更新和逻辑删除操作
*
* @param batchSaveReqVO 批量保存请求
*/
void batchSaveQuantityUnitRelations(@Valid QuantityUnitRelationBatchSaveReqVO batchSaveReqVO);
}

View File

@@ -0,0 +1,141 @@
package com.zt.plat.module.unitmanagement.service.QuantityUnitRelation;
import cn.hutool.core.collection.CollUtil;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import com.zt.plat.module.unitmanagement.controller.admin.QuantityUnitRelation.vo.*;
import com.zt.plat.module.unitmanagement.dal.dataobject.QuantityUnitRelation.QuantityUnitRelationDO;
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.module.unitmanagement.dal.dao.QuantityUnitRelation.QuantityUnitRelationMapper;
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.unitmanagement.enums.UnitErrorCodeConstants.*;
/**
* 计量单位量与单位关联 Service 实现类
*
* @author 后台管理-1
*/
@Service
@Validated
public class QuantityUnitRelationServiceImpl implements QuantityUnitRelationService {
@Resource
private QuantityUnitRelationMapper quantityUnitRelationMapper;
@Override
public QuantityUnitRelationRespVO createQuantityUnitRelation(QuantityUnitRelationSaveReqVO createReqVO) {
// 插入
QuantityUnitRelationDO quantityUnitRelation = BeanUtils.toBean(createReqVO, QuantityUnitRelationDO.class);
quantityUnitRelationMapper.insert(quantityUnitRelation);
// 返回
return BeanUtils.toBean(quantityUnitRelation, QuantityUnitRelationRespVO.class);
}
@Override
public void updateQuantityUnitRelation(QuantityUnitRelationSaveReqVO updateReqVO) {
// 校验存在
validateQuantityUnitRelationExists(updateReqVO.getId());
// 更新
QuantityUnitRelationDO updateObj = BeanUtils.toBean(updateReqVO, QuantityUnitRelationDO.class);
quantityUnitRelationMapper.updateById(updateObj);
}
@Override
public void deleteQuantityUnitRelation(Long id) {
// 校验存在
validateQuantityUnitRelationExists(id);
// 删除
quantityUnitRelationMapper.deleteById(id);
}
@Override
public void deleteQuantityUnitRelationListByIds(List<Long> ids) {
// 校验存在
validateQuantityUnitRelationExists(ids);
// 删除
quantityUnitRelationMapper.deleteByIds(ids);
}
private void validateQuantityUnitRelationExists(List<Long> ids) {
List<QuantityUnitRelationDO> list = quantityUnitRelationMapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
throw exception(QUANTITY_UNIT_RELATION_NOT_EXISTS);
}
}
private void validateQuantityUnitRelationExists(Long id) {
if (quantityUnitRelationMapper.selectById(id) == null) {
throw exception(QUANTITY_UNIT_RELATION_NOT_EXISTS);
}
}
@Override
public QuantityUnitRelationDO getQuantityUnitRelation(Long id) {
return quantityUnitRelationMapper.selectById(id);
}
@Override
public PageResult<QuantityUnitRelationDO> getQuantityUnitRelationPage(QuantityUnitRelationPageReqVO pageReqVO) {
return quantityUnitRelationMapper.selectPage(pageReqVO);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void batchSaveQuantityUnitRelations(QuantityUnitRelationBatchSaveReqVO batchSaveReqVO) {
Long untQtyId = batchSaveReqVO.getUntQtyId();
List<QuantityUnitRelationBatchSaveReqVO.UnitRelationItemVO> requestItems = batchSaveReqVO.getUnitRelations();
// 1. 查询数据库中该量纲下的所有现有关联关系
List<QuantityUnitRelationDO> existingRelations = quantityUnitRelationMapper.selectListByUntQtyId(untQtyId);
// 2. 提取请求中的ID列表(排除null)
List<Long> requestIds = requestItems.stream()
.map(QuantityUnitRelationBatchSaveReqVO.UnitRelationItemVO::getId)
.filter(Objects::nonNull)
.toList();
// 3. 提取现有数据的ID列表
List<Long> existingIds = convertList(existingRelations, QuantityUnitRelationDO::getId);
// 4. 找出需要删除的ID(数据库有但请求中没有的)
List<Long> toDeleteIds = new ArrayList<>();
for (Long existingId : existingIds) {
if (!requestIds.contains(existingId)) {
toDeleteIds.add(existingId);
}
}
// 5. 执行逻辑删除
if (CollUtil.isNotEmpty(toDeleteIds)) {
quantityUnitRelationMapper.deleteByIds(toDeleteIds);
}
// 6. 处理新增和更新
for (QuantityUnitRelationBatchSaveReqVO.UnitRelationItemVO item : requestItems) {
QuantityUnitRelationDO relation = new QuantityUnitRelationDO();
relation.setUntQtyId(untQtyId);
relation.setUntId(item.getUntId());
relation.setIsBse(item.getIsBse());
if (item.getId() != null) {
// 更新操作
relation.setId(item.getId());
quantityUnitRelationMapper.updateById(relation);
} else {
// 新增操作
quantityUnitRelationMapper.insert(relation);
}
}
}
}

View File

@@ -0,0 +1,62 @@
package com.zt.plat.module.unitmanagement.service.UnitConversion;
import java.util.*;
import jakarta.validation.*;
import com.zt.plat.module.unitmanagement.controller.admin.UnitConversion.vo.*;
import com.zt.plat.module.unitmanagement.dal.dataobject.UnitConversion.UnitConversionDO;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.pojo.PageParam;
/**
* 单位转换 Service 接口
*
* @author 后台管理-1
*/
public interface UnitConversionService {
/**
* 创建单位转换
*
* @param createReqVO 创建信息
* @return 编号
*/
UnitConversionRespVO createUnitConversion(@Valid UnitConversionSaveReqVO createReqVO);
/**
* 更新单位转换
*
* @param updateReqVO 更新信息
*/
void updateUnitConversion(@Valid UnitConversionSaveReqVO updateReqVO);
/**
* 删除单位转换
*
* @param id 编号
*/
void deleteUnitConversion(Long id);
/**
* 批量删除单位转换
*
* @param ids 编号
*/
void deleteUnitConversionListByIds(List<Long> ids);
/**
* 获得单位转换
*
* @param id 编号
* @return 单位转换
*/
UnitConversionDO getUnitConversion(Long id);
/**
* 获得单位转换分页
*
* @param pageReqVO 分页查询
* @return 单位转换分页
*/
PageResult<UnitConversionDO> getUnitConversionPage(UnitConversionPageReqVO pageReqVO);
}

View File

@@ -0,0 +1,92 @@
package com.zt.plat.module.unitmanagement.service.UnitConversion;
import cn.hutool.core.collection.CollUtil;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import com.zt.plat.module.unitmanagement.controller.admin.UnitConversion.vo.*;
import com.zt.plat.module.unitmanagement.dal.dataobject.UnitConversion.UnitConversionDO;
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.module.unitmanagement.dal.dao.UnitConversion.UnitConversionMapper;
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.unitmanagement.enums.UnitErrorCodeConstants.*;
/**
* 单位转换 Service 实现类
*
* @author 后台管理-1
*/
@Service
@Validated
public class UnitConversionServiceImpl implements UnitConversionService {
@Resource
private UnitConversionMapper unitConversionMapper;
@Override
public UnitConversionRespVO createUnitConversion(UnitConversionSaveReqVO createReqVO) {
// 插入
UnitConversionDO unitConversion = BeanUtils.toBean(createReqVO, UnitConversionDO.class);
unitConversionMapper.insert(unitConversion);
// 返回
return BeanUtils.toBean(unitConversion, UnitConversionRespVO.class);
}
@Override
public void updateUnitConversion(UnitConversionSaveReqVO updateReqVO) {
// 校验存在
validateUnitConversionExists(updateReqVO.getId());
// 更新
UnitConversionDO updateObj = BeanUtils.toBean(updateReqVO, UnitConversionDO.class);
unitConversionMapper.updateById(updateObj);
}
@Override
public void deleteUnitConversion(Long id) {
// 校验存在
validateUnitConversionExists(id);
// 删除
unitConversionMapper.deleteById(id);
}
@Override
public void deleteUnitConversionListByIds(List<Long> ids) {
// 校验存在
validateUnitConversionExists(ids);
// 删除
unitConversionMapper.deleteByIds(ids);
}
private void validateUnitConversionExists(List<Long> ids) {
List<UnitConversionDO> list = unitConversionMapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
throw exception(UNIT_CONVERSION_NOT_EXISTS);
}
}
private void validateUnitConversionExists(Long id) {
if (unitConversionMapper.selectById(id) == null) {
throw exception(UNIT_CONVERSION_NOT_EXISTS);
}
}
@Override
public UnitConversionDO getUnitConversion(Long id) {
return unitConversionMapper.selectById(id);
}
@Override
public PageResult<UnitConversionDO> getUnitConversionPage(UnitConversionPageReqVO pageReqVO) {
return unitConversionMapper.selectPage(pageReqVO);
}
}

View File

@@ -0,0 +1,62 @@
package com.zt.plat.module.unitmanagement.service.UnitQuantity;
import java.util.*;
import jakarta.validation.*;
import com.zt.plat.module.unitmanagement.controller.admin.UnitQuantity.vo.*;
import com.zt.plat.module.unitmanagement.dal.dataobject.UnitQuantity.UnitQuantityDO;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.pojo.PageParam;
/**
* 计量单位量 Service 接口
*
* @author 后台管理-1
*/
public interface UnitQuantityService {
/**
* 创建计量单位量
*
* @param createReqVO 创建信息
* @return 编号
*/
UnitQuantityRespVO createUnitQuantity(@Valid UnitQuantitySaveReqVO createReqVO);
/**
* 更新计量单位量
*
* @param updateReqVO 更新信息
*/
void updateUnitQuantity(@Valid UnitQuantitySaveReqVO updateReqVO);
/**
* 删除计量单位量
*
* @param id 编号
*/
void deleteUnitQuantity(Long id);
/**
* 批量删除计量单位量
*
* @param ids 编号
*/
void deleteUnitQuantityListByIds(List<Long> ids);
/**
* 获得计量单位量
*
* @param id 编号
* @return 计量单位量
*/
UnitQuantityDO getUnitQuantity(Long id);
/**
* 获得计量单位量分页
*
* @param pageReqVO 分页查询
* @return 计量单位量分页
*/
PageResult<UnitQuantityDO> getUnitQuantityPage(UnitQuantityPageReqVO pageReqVO);
}

View File

@@ -0,0 +1,92 @@
package com.zt.plat.module.unitmanagement.service.UnitQuantity;
import cn.hutool.core.collection.CollUtil;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import com.zt.plat.module.unitmanagement.controller.admin.UnitQuantity.vo.*;
import com.zt.plat.module.unitmanagement.dal.dataobject.UnitQuantity.UnitQuantityDO;
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.module.unitmanagement.dal.dao.UnitQuantity.UnitQuantityMapper;
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.unitmanagement.enums.UnitErrorCodeConstants.*;
/**
* 计量单位量 Service 实现类
*
* @author 后台管理-1
*/
@Service
@Validated
public class UnitQuantityServiceImpl implements UnitQuantityService {
@Resource
private UnitQuantityMapper unitQuantityMapper;
@Override
public UnitQuantityRespVO createUnitQuantity(UnitQuantitySaveReqVO createReqVO) {
// 插入
UnitQuantityDO unitQuantity = BeanUtils.toBean(createReqVO, UnitQuantityDO.class);
unitQuantityMapper.insert(unitQuantity);
// 返回
return BeanUtils.toBean(unitQuantity, UnitQuantityRespVO.class);
}
@Override
public void updateUnitQuantity(UnitQuantitySaveReqVO updateReqVO) {
// 校验存在
validateUnitQuantityExists(updateReqVO.getId());
// 更新
UnitQuantityDO updateObj = BeanUtils.toBean(updateReqVO, UnitQuantityDO.class);
unitQuantityMapper.updateById(updateObj);
}
@Override
public void deleteUnitQuantity(Long id) {
// 校验存在
validateUnitQuantityExists(id);
// 删除
unitQuantityMapper.deleteById(id);
}
@Override
public void deleteUnitQuantityListByIds(List<Long> ids) {
// 校验存在
validateUnitQuantityExists(ids);
// 删除
unitQuantityMapper.deleteByIds(ids);
}
private void validateUnitQuantityExists(List<Long> ids) {
List<UnitQuantityDO> list = unitQuantityMapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
throw exception(UNIT_QUANTITY_NOT_EXISTS);
}
}
private void validateUnitQuantityExists(Long id) {
if (unitQuantityMapper.selectById(id) == null) {
throw exception(UNIT_QUANTITY_NOT_EXISTS);
}
}
@Override
public UnitQuantityDO getUnitQuantity(Long id) {
return unitQuantityMapper.selectById(id);
}
@Override
public PageResult<UnitQuantityDO> getUnitQuantityPage(UnitQuantityPageReqVO pageReqVO) {
return unitQuantityMapper.selectPage(pageReqVO);
}
}

View File

@@ -0,0 +1,62 @@
package com.zt.plat.module.unitmanagement.service.UntInfo;
import java.util.*;
import jakarta.validation.*;
import com.zt.plat.module.unitmanagement.controller.admin.UntInfo.vo.*;
import com.zt.plat.module.unitmanagement.dal.dataobject.UntInfo.UntInfoDO;
import com.zt.plat.framework.common.pojo.PageResult;
import com.zt.plat.framework.common.pojo.PageParam;
/**
* 计量单位 Service 接口
*
* @author 后台管理-1
*/
public interface UntInfoService {
/**
* 创建计量单位
*
* @param createReqVO 创建信息
* @return 编号
*/
UntInfoRespVO createUntInfo(@Valid UntInfoSaveReqVO createReqVO);
/**
* 更新计量单位
*
* @param updateReqVO 更新信息
*/
void updateUntInfo(@Valid UntInfoSaveReqVO updateReqVO);
/**
* 删除计量单位
*
* @param id 编号
*/
void deleteUntInfo(Long id);
/**
* 批量删除计量单位
*
* @param ids 编号
*/
void deleteUntInfoListByIds(List<Long> ids);
/**
* 获得计量单位
*
* @param id 编号
* @return 计量单位
*/
UntInfoDO getUntInfo(Long id);
/**
* 获得计量单位分页
*
* @param pageReqVO 分页查询
* @return 计量单位分页
*/
PageResult<UntInfoDO> getUntInfoPage(UntInfoPageReqVO pageReqVO);
}

View File

@@ -0,0 +1,92 @@
package com.zt.plat.module.unitmanagement.service.UntInfo;
import cn.hutool.core.collection.CollUtil;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import com.zt.plat.module.unitmanagement.controller.admin.UntInfo.vo.*;
import com.zt.plat.module.unitmanagement.dal.dataobject.UntInfo.UntInfoDO;
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.module.unitmanagement.dal.dao.UntInfo.UntInfoMapper;
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.unitmanagement.enums.UnitErrorCodeConstants.*;
/**
* 计量单位 Service 实现类
*
* @author 后台管理-1
*/
@Service
@Validated
public class UntInfoServiceImpl implements UntInfoService {
@Resource
private UntInfoMapper untInfoMapper;
@Override
public UntInfoRespVO createUntInfo(UntInfoSaveReqVO createReqVO) {
// 插入
UntInfoDO untInfo = BeanUtils.toBean(createReqVO, UntInfoDO.class);
untInfoMapper.insert(untInfo);
// 返回
return BeanUtils.toBean(untInfo, UntInfoRespVO.class);
}
@Override
public void updateUntInfo(UntInfoSaveReqVO updateReqVO) {
// 校验存在
validateUntInfoExists(updateReqVO.getId());
// 更新
UntInfoDO updateObj = BeanUtils.toBean(updateReqVO, UntInfoDO.class);
untInfoMapper.updateById(updateObj);
}
@Override
public void deleteUntInfo(Long id) {
// 校验存在
validateUntInfoExists(id);
// 删除
untInfoMapper.deleteById(id);
}
@Override
public void deleteUntInfoListByIds(List<Long> ids) {
// 校验存在
validateUntInfoExists(ids);
// 删除
untInfoMapper.deleteByIds(ids);
}
private void validateUntInfoExists(List<Long> ids) {
List<UntInfoDO> list = untInfoMapper.selectByIds(ids);
if (CollUtil.isEmpty(list) || list.size() != ids.size()) {
throw exception(UNT_INFO_NOT_EXISTS);
}
}
private void validateUntInfoExists(Long id) {
if (untInfoMapper.selectById(id) == null) {
throw exception(UNT_INFO_NOT_EXISTS);
}
}
@Override
public UntInfoDO getUntInfo(Long id) {
return untInfoMapper.selectById(id);
}
@Override
public PageResult<UntInfoDO> getUntInfoPage(UntInfoPageReqVO pageReqVO) {
return untInfoMapper.selectPage(pageReqVO);
}
}

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zt.plat.module.unit-management.dal.dao.QuantityUnitRelation.QuantityUnitRelationMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zt.plat.module.unit-management.dal.dao.UnitConversion.UnitConversionMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zt.plat.module.unit-management.dal.dao.unitQuantity.UnitQuantityMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zt.plat.module.unit-management.dal.dao.untinfo.UntInfoMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>