fuliqi
2024-11-27 3e800a08d6bc93e2723bf0e18e5732684bb3b387
项目基本信息
12个文件已修改
107 ■■■■ 已修改文件
business/src/main/java/com/ycl/domain/entity/File.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
business/src/main/java/com/ycl/domain/vo/ProjectInfoVO.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
business/src/main/java/com/ycl/mapper/ProjectInfoMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java 51 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
business/src/main/resources/mapper/ProgressPlanMapper.xml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
business/src/main/resources/mapper/ProjectProcessMapper.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/pom.xml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
common/src/main/java/com/ycl/common/enums/business/FileTypeEnum.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
start/src/main/resources/application.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
system/pom.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
system/src/main/java/com/ycl/system/domain/base/AbsEntity.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
system/src/main/java/com/ycl/system/domain/base/AbsVo.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
business/src/main/java/com/ycl/domain/entity/File.java
@@ -1,9 +1,6 @@
package com.ycl.domain.entity;
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 com.baomidou.mybatisplus.annotation.*;
import com.ycl.common.enums.business.FileTypeEnum;
import com.ycl.system.domain.base.AbsEntity;
import lombok.Data;
@@ -34,6 +31,7 @@
    /**
     * 文件分类
     */
    @TableField(value = "type")
    private FileTypeEnum type;
    /**
     * 文件名
business/src/main/java/com/ycl/domain/vo/ProjectInfoVO.java
@@ -1,5 +1,7 @@
package com.ycl.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ycl.domain.entity.File;
import com.ycl.domain.entity.ProjectInfo;
import com.ycl.system.domain.base.AbsVo;
import io.swagger.annotations.ApiModel;
@@ -93,14 +95,17 @@
    /** 立项时间 */
    @ApiModelProperty("立项时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createProjectTime;
    /** 计划开工时间 */
    @ApiModelProperty("计划开工时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date planStartTime;
    /** 计划竣工时间 */
    @ApiModelProperty("计划竣工时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date planCompleteTime;
    /** 中标单位 */
@@ -113,6 +118,7 @@
    /** 中标时间 */
    @ApiModelProperty("中标时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date winTime;
    /** 详细地址 */
@@ -147,6 +153,13 @@
    @ApiModelProperty("创建人")
    private Long createBy;
    /** 状态码 */
    @ApiModelProperty("状态码")
    private String projectColorCode;
    @ApiModelProperty("文件")
    private List<File> fileList;
    public static ProjectInfoVO getVoByEntity(@NonNull ProjectInfo entity, ProjectInfoVO vo) {
        if(vo == null) {
            vo = new ProjectInfoVO();
business/src/main/java/com/ycl/mapper/ProjectInfoMapper.java
@@ -22,7 +22,7 @@
     * @param id
     * @return
     */
    ProjectInfoVO getById(Integer id);
    ProjectInfo getById(Integer id);
    /**
    *  分页
business/src/main/java/com/ycl/service/impl/ProjectInfoServiceImpl.java
@@ -1,15 +1,18 @@
package com.ycl.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ycl.common.base.Result;
import com.ycl.common.enums.business.FileTypeEnum;
import com.ycl.common.utils.SecurityUtils;
import com.ycl.domain.entity.File;
import com.ycl.domain.entity.ProjectInfo;
import com.ycl.domain.form.ProjectInfoForm;
import com.ycl.domain.query.ProjectInfoQuery;
import com.ycl.domain.vo.*;
import com.ycl.framework.utils.PageUtil;
import com.ycl.mapper.FileMapper;
import com.ycl.mapper.ProjectInfoMapper;
import com.ycl.service.FileService;
import com.ycl.service.ProjectInfoService;
@@ -37,6 +40,7 @@
    private final ProjectInfoMapper projectInfoMapper;
    private final FileService fileService;
    private final FileMapper fileMapper;
    /**
     * 添加
     *
@@ -48,6 +52,9 @@
    public Result add(ProjectInfoForm form) {
        //添加基本信息
        ProjectInfo entity = ProjectInfoForm.getEntityByForm(form, null);
        Long userId = SecurityUtils.getUserId();
        entity.setCreateBy(userId);
        entity.setUpdateBy(userId);
        baseMapper.insert(entity);
        //添加文件
        List<File> fileList = form.getFileList();
@@ -66,12 +73,28 @@
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Result update(ProjectInfoForm form) {
        ProjectInfo entity = baseMapper.selectById(form.getId());
        // 为空抛IllegalArgumentException,做全局异常处理
        Assert.notNull(entity, "记录不存在");
        BeanUtils.copyProperties(form, entity);
        ProjectInfoForm.getEntityByForm(form,entity);
        Long userId = SecurityUtils.getUserId();
        entity.setUpdateBy(userId);
        List<File> fileList = form.getFileList();
        fileList.forEach(item->{
            item.setBusId(entity.getId());
            item.setType(FileTypeEnum.PROJECT_INFO);
        });
        //删除原有文件
        QueryWrapper<File> fileQueryWrapper = new QueryWrapper<>();
        fileQueryWrapper.eq("type",FileTypeEnum.PROJECT_INFO.getType());
        fileQueryWrapper.eq("bus_id",entity.getId());
        fileMapper.delete(fileQueryWrapper);
        //替换成现有
        fileService.saveBatch(fileList);
        //更新项目信息
        baseMapper.updateById(entity);
        return Result.ok("修改成功");
    }
@@ -83,6 +106,7 @@
     * @return
     */
    @Override
    //TODO:待完善
    public Result remove(List<String> ids) {
        baseMapper.deleteBatchIds(ids);
        return Result.ok("删除成功");
@@ -95,6 +119,7 @@
     * @return
     */
    @Override
    //TODO:待完善
    public Result removeById(String id) {
        baseMapper.deleteById(id);
        return Result.ok("删除成功");
@@ -108,9 +133,17 @@
     */
    @Override
    public Result page(ProjectInfoQuery query) {
        IPage<ProjectInfoVO> page = PageUtil.getPage(query, ProjectInfoVO.class);
        IPage<ProjectInfo> page = PageUtil.getPage(query, ProjectInfo.class);
        baseMapper.getPage(page, query);
        return Result.ok().data(page.getRecords()).total(page.getTotal());
        List<ProjectInfo> records = page.getRecords();
        List<ProjectInfoVO> list = records.stream()
                .map(entity -> {
                    ProjectInfoVO vo = ProjectInfoVO.getVoByEntity(entity, null);
                    vo.setProjectColorCode("green");
                    return vo;
                })
                .collect(Collectors.toList());
        return Result.ok().data(list).total(page.getTotal());
    }
    /**
@@ -121,8 +154,14 @@
     */
    @Override
    public Result detail(Integer id) {
        ProjectInfoVO vo = baseMapper.getById(id);
        Assert.notNull(vo, "记录不存在");
        ProjectInfo entity = baseMapper.getById(id);
        Assert.notNull(entity, "记录不存在");
        ProjectInfoVO vo = ProjectInfoVO.getVoByEntity(entity, null);
        QueryWrapper<File> fileQueryWrapper = new QueryWrapper<>();
        fileQueryWrapper.eq("type",FileTypeEnum.PROJECT_INFO.getType());
        fileQueryWrapper.eq("bus_id",vo.getId());
        List<File> files = fileMapper.selectList(fileQueryWrapper);
        vo.setFileList(files);
        return Result.ok().data(vo);
    }
business/src/main/resources/mapper/ProgressPlanMapper.xml
@@ -13,12 +13,6 @@
        <result column="gmt_update_time" property="gmtUpdateTime" />
    </resultMap>
    <select id="getById" resultMap="BaseResultMap">
        SELECT
            TPP.project_info_id,
business/src/main/resources/mapper/ProjectProcessMapper.xml
@@ -45,9 +45,6 @@
    <select id="getById" resultMap="BaseResultMap">
        SELECT
            TPP.project_id,
common/pom.xml
@@ -16,7 +16,11 @@
    </description>
    <dependencies>
        <!-- MybatisPlus -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
        </dependency>
        <!-- lombok -->
        <dependency>
            <groupId>org.projectlombok</groupId>
common/src/main/java/com/ycl/common/enums/business/FileTypeEnum.java
@@ -1,5 +1,6 @@
package com.ycl.common.enums.business;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
@@ -13,12 +14,14 @@
public enum FileTypeEnum {
    PROJECT_INFO("project_info", "项目基本信息");
    private final String code;
    @EnumValue // 标明该字段存入数据库
    private final String type;
    @JsonValue // 标明在转JSON时使用该字段
    private final String desc;
    FileTypeEnum(String code, String desc) {
        this.code = code;
    FileTypeEnum(String type, String desc) {
        this.type = type;
        this.desc = desc;
    }
}
start/src/main/resources/application.yml
@@ -5,7 +5,7 @@
  # 实体扫描,多个package用逗号或者分号分隔
  typeAliasesPackage: com.ycl.**.domain
  configuration:
    default-enum-type-handler: org.apache.ibatis.type.EnumOrdinalTypeHandler # 通用枚举处理器
    default-enum-type-handler: com.baomidou.mybatisplus.core.handlers.MybatisEnumTypeHandler # 通用枚举处理器
  #    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 日志打印
  global-config:
    db-config:
system/pom.xml
@@ -28,11 +28,6 @@
            <artifactId>easyexcel</artifactId>
        </dependency>
        <!-- MybatisPlus -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
        </dependency>
        <!-- 验证码 -->
        <dependency>
system/src/main/java/com/ycl/system/domain/base/AbsEntity.java
@@ -17,7 +17,7 @@
    private static final long serialVersionUID = 1L;
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    /** 创建时间 */
system/src/main/java/com/ycl/system/domain/base/AbsVo.java
@@ -13,7 +13,7 @@
public abstract class AbsVo {
    @ApiModelProperty("id")
    private Integer id;
    private Long id;
    @ApiModelProperty("创建时间")
    private Date gmtCreate;