Browse Source

Merge remote-tracking branch 'origin/master'

tags/24080901
WendyYang 1 year ago
parent
commit
8d5b7f181c
2 changed files with 33 additions and 13 deletions
  1. +22
    -12
      pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java
  2. +11
    -1
      pmapi/src/test/java/com/ningdatech/pmapi/statemachine/StateMachineTest.java

+ 22
- 12
pmapi/src/main/java/com/ningdatech/pmapi/projectlib/manage/ProjectLibManage.java View File

@@ -1,5 +1,7 @@
package com.ningdatech.pmapi.projectlib.manage; package com.ningdatech.pmapi.projectlib.manage;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -260,13 +262,15 @@ public class ProjectLibManage {
* 新增一个新的项目 新的版本号 * 新增一个新的项目 新的版本号
*/ */
public Project newProjectWithVersion(ProjectDTO projecDto){ public Project newProjectWithVersion(ProjectDTO projecDto){
Project project = projectService.getById(projecDto.getId());
VUtils.isTrue(Objects.isNull(project))
Project oldProject = projectService.getById(projecDto.getId());
Project project = new Project();
VUtils.isTrue(Objects.isNull(oldProject))
.throwMessage("项目不存在!"); .throwMessage("项目不存在!");

project.setVersion(project.getVersion() + 1);
BeanUtils.copyProperties(projecDto,project);
BeanUtil.copyProperties(oldProject,project, CopyOptions.create()
.setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE));
BeanUtil.copyProperties(projecDto,project, CopyOptions.create()
.setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE));
project.setVersion(oldProject.getVersion() + 1);
project.setId(null); project.setId(null);
project.setCreateOn(LocalDateTime.now()); project.setCreateOn(LocalDateTime.now());
project.setUpdateOn(LocalDateTime.now()); project.setUpdateOn(LocalDateTime.now());
@@ -282,13 +286,15 @@ public class ProjectLibManage {
} }


public Project saveProjectWithVersionAndStatus(ProjectDTO projecDto,Integer stageCode,Integer statusCode){ public Project saveProjectWithVersionAndStatus(ProjectDTO projecDto,Integer stageCode,Integer statusCode){
Project project = projectService.getById(projecDto.getId());
VUtils.isTrue(Objects.isNull(project))
Project oldProject = projectService.getById(projecDto.getId());
Project project = new Project();
VUtils.isTrue(Objects.isNull(oldProject))
.throwMessage("项目不存在!"); .throwMessage("项目不存在!");

project.setVersion(project.getVersion() + 1);
BeanUtils.copyProperties(projecDto,project);
BeanUtil.copyProperties(oldProject,project, CopyOptions.create()
.setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE));
BeanUtil.copyProperties(projecDto,project, CopyOptions.create()
.setIgnoreError(Boolean.TRUE).setIgnoreNullValue(Boolean.TRUE));
project.setVersion(oldProject.getVersion() + 1);
project.setId(null); project.setId(null);
project.setCreateOn(LocalDateTime.now()); project.setCreateOn(LocalDateTime.now());
project.setUpdateOn(LocalDateTime.now()); project.setUpdateOn(LocalDateTime.now());
@@ -448,4 +454,8 @@ public class ProjectLibManage {
} }
return user; return user;
} }

private void copyProperties(ProjectDTO projecDto, Project project) {

}
} }

+ 11
- 1
pmapi/src/test/java/com/ningdatech/pmapi/statemachine/StateMachineTest.java View File

@@ -1,9 +1,9 @@
package com.ningdatech.pmapi.statemachine; package com.ningdatech.pmapi.statemachine;


import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.pmapi.AppTests; import com.ningdatech.pmapi.AppTests;
import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils; import com.ningdatech.pmapi.common.statemachine.util.StateMachineUtils;
import com.ningdatech.pmapi.projectlib.enumeration.ProjectStatusEnum;
import com.ningdatech.pmapi.projectlib.model.entity.Project; import com.ningdatech.pmapi.projectlib.model.entity.Project;
import com.ningdatech.pmapi.projectlib.service.IProjectService; import com.ningdatech.pmapi.projectlib.service.IProjectService;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@@ -32,4 +32,14 @@ public class StateMachineTest extends AppTests {
System.out.println(String.format("project:%s", JSON.toJSONString(project))); System.out.println(String.format("project:%s", JSON.toJSONString(project)));
projectService.updateById(project); projectService.updateById(project);
} }

@Test
public void yyyyyy(){
Project project = projectService.getById(400);
projectService.update(Wrappers.lambdaUpdate(Project.class)
.set(Project::getNewest,Boolean.FALSE)
.ne(Project::getId,project.getId())
.eq(Project::getProjectCode,project.getProjectCode()));
System.out.println(project);
}
} }

Loading…
Cancel
Save