From b2682976d5a99ddc2a3d594b315b55e0c901687a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E5=85=81=E6=9E=9E?= <3422692813@qq.com> Date: Thu, 7 Nov 2024 14:53:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A3=80=E6=B5=8B=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=AD=90=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/DlInspectionProject.java | 5 + .../inspection/entity/ProjectRoyalty.java | 50 +++++++++ .../mapper/ProjectRoyaltyMapper.java | 29 +++++ .../service/ProjectRoyaltyService.java | 82 ++++++++++++++ .../impl/DlInspectionProjectServiceImpl.java | 33 +++++- .../impl/ProjectRoyaltyServiceImpl.java | 102 ++++++++++++++++++ .../vo/DlInspectionProjectSaveReqVO.java | 9 +- .../vo/ProjectRoyaltyPageReqVO.java | 31 ++++++ .../inspection/vo/ProjectRoyaltyRespVO.java | 35 ++++++ .../vo/ProjectRoyaltySaveReqVO.java | 24 +++++ .../inspection/ProjectRoyaltyMapper.xml | 42 ++++++++ 11 files changed, 438 insertions(+), 4 deletions(-) create mode 100644 dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/ProjectRoyalty.java create mode 100644 dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/ProjectRoyaltyMapper.java create mode 100644 dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/ProjectRoyaltyService.java create mode 100644 dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/ProjectRoyaltyServiceImpl.java create mode 100644 dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/ProjectRoyaltyPageReqVO.java create mode 100644 dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/ProjectRoyaltyRespVO.java create mode 100644 dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/ProjectRoyaltySaveReqVO.java create mode 100644 dl-module-inspection/src/main/resources/mapper/inspection/ProjectRoyaltyMapper.xml diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/DlInspectionProject.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/DlInspectionProject.java index 7e68bd8c..e96e64fb 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/DlInspectionProject.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/DlInspectionProject.java @@ -2,10 +2,13 @@ package cn.iocoder.yudao.module.inspection.entity; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; +import java.util.List; + /** * 检测项目 * @@ -38,4 +41,6 @@ public class DlInspectionProject extends TenantBaseDO { */ private String remark; + @TableField(exist = false) + private List projectRoyaltyList; } \ No newline at end of file diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/ProjectRoyalty.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/ProjectRoyalty.java new file mode 100644 index 00000000..d5f70693 --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/ProjectRoyalty.java @@ -0,0 +1,50 @@ +package cn.iocoder.yudao.module.inspection.entity; + +import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 检测项目子表(项目提成) DO + * + * @author 若依 + */ +@TableName("inspection_project_royalty") +@KeySequence("inspection_project_royalty_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ProjectRoyalty extends TenantBaseDO { + + /** + * 主键 + */ + @TableId + private Long id; + /** + * 检测项目主键 + */ + private String projectId; + /** + * 商品主键 + */ + private Long goodsId; + /** + * 提成金额 单位:分 + */ + private Long royaltyAmount; + + /** + * 商品名称 + */ + @TableField(exist = false) + private String title; + +} \ No newline at end of file diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/ProjectRoyaltyMapper.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/ProjectRoyaltyMapper.java new file mode 100644 index 00000000..cb9ac2a3 --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/ProjectRoyaltyMapper.java @@ -0,0 +1,29 @@ +package cn.iocoder.yudao.module.inspection.mapper; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.inspection.entity.ProjectRoyalty; +import cn.iocoder.yudao.module.inspection.vo.ProjectRoyaltyPageReqVO; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 检测项目子表(项目提成) Mapper + * + * @author 若依 + */ +@Mapper +public interface ProjectRoyaltyMapper extends BaseMapper { + + void insertBatch(@Param("createReq") List createReq); + + void deleteByProjectId(String projectId); + + List selectListByProjrctId(String projectId); + + void updtaBatch(@Param("list") List createReq); +} \ No newline at end of file diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/ProjectRoyaltyService.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/ProjectRoyaltyService.java new file mode 100644 index 00000000..e4126fa7 --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/ProjectRoyaltyService.java @@ -0,0 +1,82 @@ +package cn.iocoder.yudao.module.inspection.service; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.module.inspection.entity.ProjectRoyalty; +import cn.iocoder.yudao.module.inspection.vo.ProjectRoyaltyPageReqVO; +import cn.iocoder.yudao.module.inspection.vo.ProjectRoyaltySaveReqVO; + +/** + * 检测项目子表(项目提成) Service 接口 + * + * @author 若依 + */ +public interface ProjectRoyaltyService { + + /** + * 创建检测项目子表(项目提成) + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createProjectRoyalty(@Valid ProjectRoyaltySaveReqVO createReqVO); + + /** + * 批量创建检测项目子表(项目提成) + * + * @param createReq 创建信息 + */ + void batchInsertProjectRoyalty(@Valid List createReq); + + /** + * 根据项目id删除检测项目子表(项目提成) + * @param projectId + */ + void deleteInsertProjectRoyalty(String projectId); + + /** + * 根据项目id查询检测项目子表(项目提成) + * @param projectId + * @return + */ + List getProjectRoyaltyList(String projectId); + + /** + * 批量更新检测项目子表(项目提成) + * @param createReq + */ + void updtaBatch(List createReq); + +// /** +// * 更新检测项目子表(项目提成) +// * +// * @param updateReqVO 更新信息 +// */ +// void updateProjectRoyalty(@Valid ProjectRoyaltySaveReqVO updateReqVO); +// +// /** +// * 删除检测项目子表(项目提成) +// * +// * @param id 编号 +// */ +// void deleteProjectRoyalty(Long id); +// +// /** +// * 获得检测项目子表(项目提成) +// * +// * @param id 编号 +// * @return 检测项目子表(项目提成) +// */ +// ProjectRoyalty getProjectRoyalty(Long id); +// +// /** +// * 获得检测项目子表(项目提成)分页 +// * +// * @param pageReqVO 分页查询 +// * @return 检测项目子表(项目提成)分页 +// */ +// PageResult getProjectRoyaltyPage(ProjectRoyaltyPageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/DlInspectionProjectServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/DlInspectionProjectServiceImpl.java index 51919d1c..2dfcfdac 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/DlInspectionProjectServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/DlInspectionProjectServiceImpl.java @@ -1,10 +1,14 @@ package cn.iocoder.yudao.module.inspection.service.impl; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.inspection.entity.DlInspectionProject; +import cn.iocoder.yudao.module.inspection.entity.ProjectRoyalty; import cn.iocoder.yudao.module.inspection.mapper.DlInspectionProjectMapper; +import cn.iocoder.yudao.module.inspection.mapper.ProjectRoyaltyMapper; import cn.iocoder.yudao.module.inspection.service.DlInspectionProjectService; +import cn.iocoder.yudao.module.inspection.service.ProjectRoyaltyService; import cn.iocoder.yudao.module.inspection.vo.DlInspectionProjectPageReqVO; import cn.iocoder.yudao.module.inspection.vo.DlInspectionProjectRespVO; import cn.iocoder.yudao.module.inspection.vo.DlInspectionProjectSaveReqVO; @@ -12,9 +16,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; +import java.util.List; +import java.util.stream.Collectors; + +import static com.github.yulichang.method.SqlMethod.collect; /** @@ -29,7 +38,11 @@ public class DlInspectionProjectServiceImpl extends ServiceImpl() @@ -41,29 +54,45 @@ public class DlInspectionProjectServiceImpl extends ServiceImpl projectRoyaltyList = createReqVO.getProjectRoyaltyList(); + //设置项目id + List collect = projectRoyaltyList.stream().map(item -> item.setProjectId(dlInspectionProject.getId())).collect(Collectors.toList()); + projectRoyaltyService.batchInsertProjectRoyalty(collect); // 返回 return dlInspectionProject.getId(); } @Override + @Transactional(rollbackFor = Exception.class) public void updateDlInspectionProject(DlInspectionProjectSaveReqVO updateReqVO) { // 更新 DlInspectionProject updateObj = BeanUtils.toBean(updateReqVO, DlInspectionProject.class); dlInspectionProjectMapper.updateById(updateObj); + + // 更新项目子表 + List projectRoyaltyList = updateReqVO.getProjectRoyaltyList(); + projectRoyaltyService.updtaBatch(projectRoyaltyList); } @Override + @Transactional(rollbackFor = Exception.class) public void deleteDlInspectionProject(String id) { // 删除 dlInspectionProjectMapper.deleteById(id); + //删除项目子表 + projectRoyaltyService.deleteInsertProjectRoyalty(id); } - @Override public DlInspectionProject getDlInspectionProject(String id) { - return dlInspectionProjectMapper.selectById(id); + DlInspectionProject dlInspectionProject = dlInspectionProjectMapper.selectById(id); + List projectRoyaltyList = projectRoyaltyService.getProjectRoyaltyList(id); + dlInspectionProject.setProjectRoyaltyList(projectRoyaltyList); + return dlInspectionProject; } @Override diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/ProjectRoyaltyServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/ProjectRoyaltyServiceImpl.java new file mode 100644 index 00000000..5b1a4c8b --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/ProjectRoyaltyServiceImpl.java @@ -0,0 +1,102 @@ +package cn.iocoder.yudao.module.inspection.service.impl; + +import cn.iocoder.yudao.module.inspection.entity.ProjectRoyalty; +import cn.iocoder.yudao.module.inspection.mapper.ProjectRoyaltyMapper; +import cn.iocoder.yudao.module.inspection.service.ProjectRoyaltyService; +import cn.iocoder.yudao.module.inspection.vo.ProjectRoyaltySaveReqVO; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import java.util.List; + +/** + * 检测项目子表(项目提成) Service 实现类 + * + * @author 若依 + */ +@Service +@Validated +public class ProjectRoyaltyServiceImpl extends ServiceImpl implements ProjectRoyaltyService { + + @Resource + private ProjectRoyaltyMapper projectRoyaltyMapper; + + @Override + public Long createProjectRoyalty(ProjectRoyaltySaveReqVO createReqVO) { + // 插入 + ProjectRoyalty projectRoyalty = BeanUtils.toBean(createReqVO, ProjectRoyalty.class); + projectRoyaltyMapper.insert(projectRoyalty); + // 返回 + return projectRoyalty.getId(); + } + + /** + * 批量创建检测项目子表(项目提成) + * + * @param createReq 创建信息 + */ + @Override + public void batchInsertProjectRoyalty(List createReq) { + projectRoyaltyMapper.insertBatch(createReq); + } + + /** + * 根据项目id删除检测项目子表(项目提成) + * + * @param projectId + */ + @Override + public void deleteInsertProjectRoyalty(String projectId) { + projectRoyaltyMapper.deleteByProjectId(projectId); + } + + /** + * 根据项目id查询检测项目子表(项目提成) + * + * @param projectId + * @return + */ + @Override + public List getProjectRoyaltyList(String projectId) { + return baseMapper.selectListByProjrctId(projectId); + } + + /** + * 批量更新检测项目子表(项目提成) + * + * @param createReq + */ + @Override + public void updtaBatch(List createReq) { + projectRoyaltyMapper.updtaBatch(createReq); + } + +// @Override +// public void updateProjectRoyalty(ProjectRoyaltySaveReqVO updateReqVO) { +// // 校验存在 +// validateProjectRoyaltyExists(updateReqVO.getId()); +// // 更新 +// ProjectRoyalty updateObj = BeanUtils.toBean(updateReqVO, ProjectRoyalty.class); +// projectRoyaltyMapper.updateById(updateObj); +// } +// +// @Override +// public void deleteProjectRoyalty(Long id) { +// // 校验存在 +// validateProjectRoyaltyExists(id); +// // 删除 +// projectRoyaltyMapper.deleteById(id); +// } +// +// +// @Override +// public ProjectRoyalty getProjectRoyalty(Long id) { +// return projectRoyaltyMapper.selectById(id); +// } + + +} \ No newline at end of file diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/DlInspectionProjectSaveReqVO.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/DlInspectionProjectSaveReqVO.java index 935351f2..b3aa1f4b 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/DlInspectionProjectSaveReqVO.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/DlInspectionProjectSaveReqVO.java @@ -1,13 +1,18 @@ package cn.iocoder.yudao.module.inspection.vo; import cn.iocoder.yudao.module.inspection.entity.DlInspectionProject; +import cn.iocoder.yudao.module.inspection.entity.ProjectRoyalty; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.util.List; + @Schema(description = "管理后台 - 检测项目新增/修改 Request VO") @Data public class DlInspectionProjectSaveReqVO extends DlInspectionProject { - - + /** + * 项目提成 + */ + private List projectRoyaltyList; } \ No newline at end of file diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/ProjectRoyaltyPageReqVO.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/ProjectRoyaltyPageReqVO.java new file mode 100644 index 00000000..a1faf348 --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/ProjectRoyaltyPageReqVO.java @@ -0,0 +1,31 @@ +package cn.iocoder.yudao.module.inspection.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 检测项目子表(项目提成)分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ProjectRoyaltyPageReqVO extends PageParam { + + @Schema(description = "检测项目主键", example = "21579") + private String projectId; + + @Schema(description = "商品主键", example = "3154") + private Long goodsId; + + @Schema(description = "提成金额 单位:分") + private Long royaltyAmount; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/ProjectRoyaltyRespVO.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/ProjectRoyaltyRespVO.java new file mode 100644 index 00000000..a6a51584 --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/ProjectRoyaltyRespVO.java @@ -0,0 +1,35 @@ +package cn.iocoder.yudao.module.inspection.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 ProjectRoyaltyRespVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "18948") + @ExcelProperty("主键") + private Long id; + + @Schema(description = "检测项目主键", example = "21579") + @ExcelProperty("检测项目主键") + private String projectId; + + @Schema(description = "商品主键", example = "3154") + @ExcelProperty("商品主键") + private Long goodsId; + + @Schema(description = "提成金额 单位:分") + @ExcelProperty("提成金额 单位:分") + private Long royaltyAmount; + + @Schema(description = "创建时间") + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/ProjectRoyaltySaveReqVO.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/ProjectRoyaltySaveReqVO.java new file mode 100644 index 00000000..bd8c0776 --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/ProjectRoyaltySaveReqVO.java @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.module.inspection.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 检测项目子表(项目提成)新增/修改 Request VO") +@Data +public class ProjectRoyaltySaveReqVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "18948") + private Long id; + + @Schema(description = "检测项目主键", example = "21579") + private String projectId; + + @Schema(description = "商品主键", example = "3154") + private Long goodsId; + + @Schema(description = "提成金额 单位:分") + private Long royaltyAmount; + +} \ No newline at end of file diff --git a/dl-module-inspection/src/main/resources/mapper/inspection/ProjectRoyaltyMapper.xml b/dl-module-inspection/src/main/resources/mapper/inspection/ProjectRoyaltyMapper.xml new file mode 100644 index 00000000..6ec80d45 --- /dev/null +++ b/dl-module-inspection/src/main/resources/mapper/inspection/ProjectRoyaltyMapper.xml @@ -0,0 +1,42 @@ + + + + + + + + INSERT INTO inspection_project_royalty (project_id, goods_id, royalty_amount, deleted, create_time) VALUES + + (#{item.projectId},#{item.goodsId},#{item.royaltyAmount},0, NOW()) + + + + UPDATE inspection_project_royalty + SET royalty_amount = + CASE + + WHEN id = #{item.id} THEN #{item.royaltyAmount} + + ELSE royalty_amount + END + WHERE id IN + + #{item.id} + + + + UPDATE inspection_project_royalty SET deleted = 1 WHERE project_id = #{projectId} + + + \ No newline at end of file