Commit 99b61ac1 authored by cq990612's avatar cq990612

优化代码结构

parent dc82a373
...@@ -11,31 +11,33 @@ ...@@ -11,31 +11,33 @@
<result column="modify_before" property="modifyBefore" /> <result column="modify_before" property="modifyBefore" />
<result column="reason" property="reason" /> <result column="reason" property="reason" />
<result column="modify_time" property="modifyTime" /> <result column="modify_time" property="modifyTime" />
<result column="reviser_id" property="reviserId"/>
<result column="operation_type" property="operationType"/>
</resultMap> </resultMap>
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, project_id, change_type, modify_after,modify_before, reason, modify_time id, project_id, change_type, modify_after,modify_before, reason, modify_time,reviser_id,operation_type
</sql> </sql>
<sql id="not_id_Column_List"> <sql id="not_id_Column_List">
project_id, change_type, modify_after,modify_before, reason, modify_time project_id, change_type, modify_after,modify_before, reason, modify_time,reviser_id,operation_type
</sql> </sql>
<insert id="insertBatch"> <insert id="insertBatch">
INSERT INTO work_project_change INSERT INTO work_project_change
(<include refid="not_id_Column_List"/> ) (<include refid="not_id_Column_List"/> )
VALUES VALUES
<foreach collection ="workProjectChanges" item="workProjectChange" separator =","> <foreach collection ="workProjectChanges" item="workProjectChange" separator =",">
(#{workProjectChange.projectId}, #{workProjectChange.changeType},#{workProjectChange.modifyAfter},#{workProjectChange.modifyBefore},#{workProjectChange.reason},#{workProjectChange.modifyTime}) (#{workProjectChange.projectId}, #{workProjectChange.changeType},#{workProjectChange.modifyAfter},#{workProjectChange.modifyBefore},#{workProjectChange.reason},#{workProjectChange.modifyTime},#{workProjectChange.reviserId},#{workProjectChange.operationType})
</foreach > </foreach >
</insert> </insert>
<select id="getByProjectId" resultType="cn.wisenergy.model.app.WorkProjectChange"> <select id="getByProjectId" resultType="cn.wisenergy.model.app.WorkProjectChange">
SELECT <include refid="Base_Column_List"/> SELECT c.id,c.project_id,c.change_type,c.modify_after,c.modify_before,c.reason,c.modify_time,c.reviser_id,c.operation_type,u.name as 'reviser_name'
FROM work_project_change FROM work_project_change c LEFT JOIN work_user u on c.reviser_id = u.id
WHERE project_id = #{projectId} WHERE c.project_id = #{projectId}
ORDER BY modify_time DESC ORDER BY c.modify_time DESC
</select> </select>
</mapper> </mapper>
...@@ -77,4 +77,7 @@ public class WorkProject implements Serializable { ...@@ -77,4 +77,7 @@ public class WorkProject implements Serializable {
@ApiModelProperty(name = "conclusionTime",value = "结项时间") @ApiModelProperty(name = "conclusionTime",value = "结项时间")
private Date conclusionTime; private Date conclusionTime;
@ApiModelProperty(name = "creatorId",value = "创建人id")
private Integer creatorId;
} }
package cn.wisenergy.model.app; package cn.wisenergy.model.app;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
...@@ -51,8 +52,19 @@ public class WorkProjectChange implements Serializable { ...@@ -51,8 +52,19 @@ public class WorkProjectChange implements Serializable {
@ApiModelProperty(name = "modify_time",value = "变更日期") @ApiModelProperty(name = "modify_time",value = "变更日期")
private Date modifyTime; private Date modifyTime;
@ApiModelProperty(name = "reviserId",value = "更变人id")
private Integer reviserId;
/** 附加字段 更变项名*/ @ApiModelProperty(name = "operationType",value = "1:新增 2:修改 3:结项")
private Integer operationType;
/** 附加字段 更变项名 变更人姓名*/
@TableField(exist = false)
private String changeTypeName; private String changeTypeName;
@TableField(exist = false)
private String reviserName;
@TableField(exist = false)
private String operationTypeName;
} }
...@@ -12,6 +12,8 @@ public enum ChangeTypeEnum { ...@@ -12,6 +12,8 @@ public enum ChangeTypeEnum {
MANAGER(5,"项目/商机负责人"), MANAGER(5,"项目/商机负责人"),
DEPARTMENT(6, "项目/商机所属部门"), DEPARTMENT(6, "项目/商机所属部门"),
PARTICIPANTS(7, "参与人员"), PARTICIPANTS(7, "参与人员"),
PROJECT_NUMBER(8, "项目/商机编号"),
PROJECT_NAME(9, "项目/商机名称"),
; ;
......
package cn.wisenergy.model.enums;
/**
* @Authotr:陈奇
* @QQ1799796883
*/
public enum OperationTypeEnum {
ADD(1, "新增"),
MODIFY(2, "修改"),
END(3, "结项"),
;
private Integer OperationType;
private String OperationTypeName;
OperationTypeEnum(Integer changeType, String changeTypeName) {
this.OperationType = changeType;
this.OperationTypeName = changeTypeName;
}
public Integer getChangeType() {
return OperationType;
}
public String getChangeTypeName() {
return OperationTypeName;
}}
\ No newline at end of file
...@@ -25,6 +25,9 @@ public class CreateProjectVo { ...@@ -25,6 +25,9 @@ public class CreateProjectVo {
@ApiModelProperty(name = "projectName",value = "项目名称") @ApiModelProperty(name = "projectName",value = "项目名称")
private String projectName; private String projectName;
@ApiModelProperty(name = "creatorId",value = "创建人id")
private Integer creatorId;
@JsonFormat(shape=JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd") @JsonFormat(shape=JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd")
@ApiModelProperty(name = "startTime",value = "项目开始时间") @ApiModelProperty(name = "startTime",value = "项目开始时间")
private Date startTime; private Date startTime;
......
...@@ -53,4 +53,15 @@ public class ModifyProjectVo { ...@@ -53,4 +53,15 @@ public class ModifyProjectVo {
private String businessId; private String businessId;
private String businessName; private String businessName;
private String oaProjectId;
private String oaProjectIdReason;
private String projectName;
private String projectNameReason;
//变更人Id
private Integer reviserId;
} }
...@@ -5,7 +5,9 @@ import cn.wisenergy.common.utils.exception.BaseCustomException; ...@@ -5,7 +5,9 @@ import cn.wisenergy.common.utils.exception.BaseCustomException;
import cn.wisenergy.mapper.WorkProjectChangeMapper; import cn.wisenergy.mapper.WorkProjectChangeMapper;
import cn.wisenergy.model.app.WorkProjectChange; import cn.wisenergy.model.app.WorkProjectChange;
import cn.wisenergy.model.enums.ChangeTypeEnum; import cn.wisenergy.model.enums.ChangeTypeEnum;
import cn.wisenergy.model.enums.OperationTypeEnum;
import cn.wisenergy.service.WorkProjectChangeService; import cn.wisenergy.service.WorkProjectChangeService;
import cn.wisenergy.service.WorkUserService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -28,6 +30,9 @@ public class WorkProjectChangeServiceImpl implements WorkProjectChangeService { ...@@ -28,6 +30,9 @@ public class WorkProjectChangeServiceImpl implements WorkProjectChangeService {
@Autowired @Autowired
private WorkProjectChangeMapper workProjectChangeMapper; private WorkProjectChangeMapper workProjectChangeMapper;
@Autowired
private WorkUserService workUserService;
/** /**
* 批量插入 * 批量插入
* *
...@@ -67,7 +72,15 @@ public class WorkProjectChangeServiceImpl implements WorkProjectChangeService { ...@@ -67,7 +72,15 @@ public class WorkProjectChangeServiceImpl implements WorkProjectChangeService {
workProjectChange.setChangeTypeName(value.getChangeTypeName()); workProjectChange.setChangeTypeName(value.getChangeTypeName());
} }
} }
for (OperationTypeEnum value : OperationTypeEnum.values()) {
if (value.getChangeType().equals(workProjectChange.getOperationType())) {
workProjectChange.setOperationTypeName(value.getChangeTypeName());
}
}
} }
return workProjectChanges; return workProjectChanges;
} }
} }
...@@ -5,6 +5,7 @@ import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM; ...@@ -5,6 +5,7 @@ import cn.wisenergy.common.utils.exception.BASE_RESP_CODE_ENUM;
import cn.wisenergy.common.utils.exception.BaseCustomException; import cn.wisenergy.common.utils.exception.BaseCustomException;
import cn.wisenergy.mapper.WorkCentreMapper; import cn.wisenergy.mapper.WorkCentreMapper;
import cn.wisenergy.mapper.WorkDeptMapper; import cn.wisenergy.mapper.WorkDeptMapper;
import cn.wisenergy.mapper.WorkProjectChangeMapper;
import cn.wisenergy.mapper.WorkProjectMapper; import cn.wisenergy.mapper.WorkProjectMapper;
import cn.wisenergy.model.app.*; import cn.wisenergy.model.app.*;
import cn.wisenergy.model.dto.ManagerProjectsDto; import cn.wisenergy.model.dto.ManagerProjectsDto;
...@@ -70,6 +71,9 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -70,6 +71,9 @@ public class WorkProjectServiceImpl implements WorkProjectService {
@Autowired @Autowired
private WorkProjectChangeService workProjectChangeService; private WorkProjectChangeService workProjectChangeService;
@Autowired
private WorkProjectChangeMapper workProjectChangeMapper;
/** /**
* 功能:根据项目id获取项目 * 功能:根据项目id获取项目
...@@ -216,14 +220,14 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -216,14 +220,14 @@ public class WorkProjectServiceImpl implements WorkProjectService {
if (LevelRankEnum.PROJECT_LEVEL.getRank().equals(userRoleLevelDto.getRank())) { if (LevelRankEnum.PROJECT_LEVEL.getRank().equals(userRoleLevelDto.getRank())) {
projectIndex++; projectIndex++;
} }
if (LevelRankEnum.DEPARTMENT_LEVEL.getRank().equals(userRoleLevelDto.getRank())||LevelRankEnum.CENTRAL_LEVEL.getRank().equals(userRoleLevelDto.getRank())) { if (LevelRankEnum.DEPARTMENT_LEVEL.getRank().equals(userRoleLevelDto.getRank()) || LevelRankEnum.CENTRAL_LEVEL.getRank().equals(userRoleLevelDto.getRank())) {
deptAndManager++; deptAndManager++;
} }
if (LevelRankEnum.DEPARTMENT_LEVEL.getRank().equals(userRoleLevelDto.getRank())) { if (LevelRankEnum.DEPARTMENT_LEVEL.getRank().equals(userRoleLevelDto.getRank())) {
if (null !=gmpv.getDeptId() && !user.getDeptId().equals(gmpv.getDeptId())) { if (null != gmpv.getDeptId() && !user.getDeptId().equals(gmpv.getDeptId())) {
int isCentre = 0; int isCentre = 0;
for (UserRoleLevelDto roleLevelDto : roleUserLevel) { for (UserRoleLevelDto roleLevelDto : roleUserLevel) {
if (LevelEnum.PROJECT_MANAGER.getLevelName().equals(roleLevelDto.getLevelName()) ) { if (LevelEnum.PROJECT_MANAGER.getLevelName().equals(roleLevelDto.getLevelName())) {
if (LevelRankEnum.CENTRAL_LEVEL.getRank().equals(roleLevelDto.getRank())) { if (LevelRankEnum.CENTRAL_LEVEL.getRank().equals(roleLevelDto.getRank())) {
isCentre++; isCentre++;
} }
...@@ -248,12 +252,12 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -248,12 +252,12 @@ public class WorkProjectServiceImpl implements WorkProjectService {
List<Integer> deptIds = new ArrayList<>(); List<Integer> deptIds = new ArrayList<>();
if (null == gmpv.getDeptId()) { if (null == gmpv.getDeptId()) {
List<WorkDept> workdepts = workDeptService.getDeptOfProjectOfManager(gmpv.getUserId()); List<WorkDept> workdepts = workDeptService.getDeptOfProjectOfManager(gmpv.getUserId());
workdepts.forEach(workdept->deptIds.add(workdept.getId())); workdepts.forEach(workdept -> deptIds.add(workdept.getId()));
} else { } else {
deptIds.add(gmpv.getDeptId()); deptIds.add(gmpv.getDeptId());
} }
PageHelper.startPage(page, pageSize); PageHelper.startPage(page, pageSize);
managerProjectsDto = workProjectMapper.getManagerProjectsDto(user.getId(), gmpv.getType(), isConclusion, deptIds,gmpv.getKey(),deptAndManager); managerProjectsDto = workProjectMapper.getManagerProjectsDto(user.getId(), gmpv.getType(), isConclusion, deptIds, gmpv.getKey(), deptAndManager);
return returnPageInfo(managerProjectsDto); return returnPageInfo(managerProjectsDto);
} }
...@@ -279,8 +283,19 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -279,8 +283,19 @@ public class WorkProjectServiceImpl implements WorkProjectService {
if (null == workProject) { if (null == workProject) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.WORK_PROJECT_IS_NULL); throw new BaseCustomException(BASE_RESP_CODE_ENUM.WORK_PROJECT_IS_NULL);
} }
int i = workProjectMapper.updateIsConclusionById(projectId); workProjectMapper.updateIsConclusionById(projectId);
return i > 0;
// 插入更变日志
List<WorkProjectChange> workProjectChanges = new ArrayList<>();
WorkProjectChange workProjectChange = new WorkProjectChange();
workProjectChange.setProjectId(projectId);
workProjectChange.setReviserId(userId);
workProjectChange.setModifyTime(new Date());
workProjectChange.setOperationType(3);
workProjectChanges.add(workProjectChange);
workProjectChangeService.insertbatch(workProjectChanges);
return true;
} }
@Transactional @Transactional
...@@ -317,6 +332,38 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -317,6 +332,38 @@ public class WorkProjectServiceImpl implements WorkProjectService {
} }
// 向workProjectChange插入内容 // 向workProjectChange插入内容
List<WorkProjectChange> workProjectChanges = new ArrayList<>(); List<WorkProjectChange> workProjectChanges = new ArrayList<>();
if (!StringUtils.isBlank(modifyProjectVo.getOaProjectIdReason())) {
if (StringUtils.isBlank(modifyProjectVo.getOaProjectId())) {
throw new BaseCustomException("666", "请填写项目/商机编号");
}
WorkProjectChange workProjectChange = new WorkProjectChange();
workProjectChange.setProjectId(modifyProjectVo.getProjectId());
workProjectChange.setModifyTime(new Date());
workProjectChange.setChangeType(8);
workProjectChange.setModifyBefore(workProject.getOaProjectId());
workProjectChange.setModifyAfter(modifyProjectVo.getOaProjectId());
workProjectChange.setReason(modifyProjectVo.getOaProjectIdReason());
workProjectChange.setOperationType(2);
workProjectChange.setReviserId(modifyProjectVo.getReviserId());
workProjectChanges.add(workProjectChange);
}
if (!StringUtils.isBlank(modifyProjectVo.getProjectNameReason())) {
if (StringUtils.isBlank(modifyProjectVo.getProjectName())) {
throw new BaseCustomException("666", "请填写项目/商机名称");
}
WorkProjectChange workProjectChange = new WorkProjectChange();
workProjectChange.setProjectId(modifyProjectVo.getProjectId());
workProjectChange.setModifyTime(new Date());
workProjectChange.setChangeType(9);
workProjectChange.setModifyBefore(workProject.getProjectName());
workProjectChange.setModifyAfter(modifyProjectVo.getProjectName());
workProjectChange.setReason(modifyProjectVo.getProjectNameReason());
workProjectChange.setOperationType(2);
workProjectChange.setReviserId(modifyProjectVo.getReviserId());
workProjectChanges.add(workProjectChange);
}
if (!StringUtils.isBlank(modifyProjectVo.getDeptIdReason())) { if (!StringUtils.isBlank(modifyProjectVo.getDeptIdReason())) {
if (!workProject.getDeptId().equals(modifyProjectVo.getDeptId())) { if (!workProject.getDeptId().equals(modifyProjectVo.getDeptId())) {
WorkProjectChange workProjectChange = new WorkProjectChange(); WorkProjectChange workProjectChange = new WorkProjectChange();
...@@ -326,6 +373,8 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -326,6 +373,8 @@ public class WorkProjectServiceImpl implements WorkProjectService {
workProjectChange.setModifyBefore(workDeptService.getById(workProject.getDeptId()).getDeptName()); workProjectChange.setModifyBefore(workDeptService.getById(workProject.getDeptId()).getDeptName());
workProjectChange.setModifyAfter(workDeptService.getById(modifyProjectVo.getDeptId()).getDeptName()); workProjectChange.setModifyAfter(workDeptService.getById(modifyProjectVo.getDeptId()).getDeptName());
workProjectChange.setReason(modifyProjectVo.getDeptIdReason()); workProjectChange.setReason(modifyProjectVo.getDeptIdReason());
workProjectChange.setOperationType(2);
workProjectChange.setReviserId(modifyProjectVo.getReviserId());
workProjectChanges.add(workProjectChange); workProjectChanges.add(workProjectChange);
} }
} }
...@@ -338,6 +387,8 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -338,6 +387,8 @@ public class WorkProjectServiceImpl implements WorkProjectService {
workProjectChange.setModifyBefore(workUserService.getById(workProject.getManagerId()).getName()); workProjectChange.setModifyBefore(workUserService.getById(workProject.getManagerId()).getName());
workProjectChange.setModifyAfter(workUserService.getById(modifyProjectVo.getManagerId()).getName()); workProjectChange.setModifyAfter(workUserService.getById(modifyProjectVo.getManagerId()).getName());
workProjectChange.setReason(modifyProjectVo.getManagerIdReason()); workProjectChange.setReason(modifyProjectVo.getManagerIdReason());
workProjectChange.setOperationType(2);
workProjectChange.setReviserId(modifyProjectVo.getReviserId());
workProjectChanges.add(workProjectChange); workProjectChanges.add(workProjectChange);
} }
...@@ -350,6 +401,8 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -350,6 +401,8 @@ public class WorkProjectServiceImpl implements WorkProjectService {
workProjectChange.setModifyBefore(DateUtil.convertDateToStr(workProject.getStartTime(), "yyyy-MM-dd")); workProjectChange.setModifyBefore(DateUtil.convertDateToStr(workProject.getStartTime(), "yyyy-MM-dd"));
workProjectChange.setModifyAfter(DateUtil.convertDateToStr(modifyProjectVo.getStartTime(), "yyyy-MM-dd")); workProjectChange.setModifyAfter(DateUtil.convertDateToStr(modifyProjectVo.getStartTime(), "yyyy-MM-dd"));
workProjectChange.setReason(modifyProjectVo.getStartTimeReason()); workProjectChange.setReason(modifyProjectVo.getStartTimeReason());
workProjectChange.setOperationType(2);
workProjectChange.setReviserId(modifyProjectVo.getReviserId());
workProjectChanges.add(workProjectChange); workProjectChanges.add(workProjectChange);
} }
if (!StringUtils.isBlank(modifyProjectVo.getEndTimeReason())) { if (!StringUtils.isBlank(modifyProjectVo.getEndTimeReason())) {
...@@ -360,6 +413,8 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -360,6 +413,8 @@ public class WorkProjectServiceImpl implements WorkProjectService {
workProjectChange.setModifyBefore(DateUtil.convertDateToStr(workProject.getEndTime(), "yyyy-MM-dd")); workProjectChange.setModifyBefore(DateUtil.convertDateToStr(workProject.getEndTime(), "yyyy-MM-dd"));
workProjectChange.setModifyAfter(DateUtil.convertDateToStr(modifyProjectVo.getEndTime(), "yyyy-MM-dd")); workProjectChange.setModifyAfter(DateUtil.convertDateToStr(modifyProjectVo.getEndTime(), "yyyy-MM-dd"));
workProjectChange.setReason(modifyProjectVo.getEndTimeReason()); workProjectChange.setReason(modifyProjectVo.getEndTimeReason());
workProjectChange.setOperationType(2);
workProjectChange.setReviserId(modifyProjectVo.getReviserId());
workProjectChanges.add(workProjectChange); workProjectChanges.add(workProjectChange);
} }
if (!StringUtils.isBlank(modifyProjectVo.getWorkTimeReason())) { if (!StringUtils.isBlank(modifyProjectVo.getWorkTimeReason())) {
...@@ -375,6 +430,8 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -375,6 +430,8 @@ public class WorkProjectServiceImpl implements WorkProjectService {
} }
workProjectChange.setModifyAfter(modifyProjectVo.getWorkTime().setScale(2, BigDecimal.ROUND_HALF_UP).toString()); workProjectChange.setModifyAfter(modifyProjectVo.getWorkTime().setScale(2, BigDecimal.ROUND_HALF_UP).toString());
workProjectChange.setReason(modifyProjectVo.getWorkTimeReason()); workProjectChange.setReason(modifyProjectVo.getWorkTimeReason());
workProjectChange.setOperationType(2);
workProjectChange.setReviserId(modifyProjectVo.getReviserId());
workProjectChanges.add(workProjectChange); workProjectChanges.add(workProjectChange);
} }
if (!StringUtils.isBlank(modifyProjectVo.getCostBudgetReason())) { if (!StringUtils.isBlank(modifyProjectVo.getCostBudgetReason())) {
...@@ -390,6 +447,8 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -390,6 +447,8 @@ public class WorkProjectServiceImpl implements WorkProjectService {
} }
workProjectChange.setModifyAfter(modifyProjectVo.getCostBudget().setScale(2, BigDecimal.ROUND_HALF_UP).toString()); workProjectChange.setModifyAfter(modifyProjectVo.getCostBudget().setScale(2, BigDecimal.ROUND_HALF_UP).toString());
workProjectChange.setReason(modifyProjectVo.getCostBudgetReason()); workProjectChange.setReason(modifyProjectVo.getCostBudgetReason());
workProjectChange.setOperationType(2);
workProjectChange.setReviserId(modifyProjectVo.getReviserId());
workProjectChanges.add(workProjectChange); workProjectChanges.add(workProjectChange);
} }
if (!StringUtils.isBlank(modifyProjectVo.getUserIdsReason())) { if (!StringUtils.isBlank(modifyProjectVo.getUserIdsReason())) {
...@@ -429,6 +488,8 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -429,6 +488,8 @@ public class WorkProjectServiceImpl implements WorkProjectService {
workProjectChange.setModifyBefore(userModifyBefore); workProjectChange.setModifyBefore(userModifyBefore);
workProjectChange.setModifyAfter(userModifyAfter); workProjectChange.setModifyAfter(userModifyAfter);
workProjectChange.setReason(modifyProjectVo.getUserIdsReason()); workProjectChange.setReason(modifyProjectVo.getUserIdsReason());
workProjectChange.setOperationType(2);
workProjectChange.setReviserId(modifyProjectVo.getReviserId());
workProjectChanges.add(workProjectChange); workProjectChanges.add(workProjectChange);
} }
} }
...@@ -482,23 +543,30 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -482,23 +543,30 @@ public class WorkProjectServiceImpl implements WorkProjectService {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.ITEMOADUPLICATE); throw new BaseCustomException(BASE_RESP_CODE_ENUM.ITEMOADUPLICATE);
} }
} }
// 插入项目信息 // 插入项目信息
Date date = new Date(); Date date = new Date();
WorkProject workProject = new WorkProject(); WorkProject workProject = new WorkProject();
workProject.setIsConclusion(1); workProject.setIsConclusion(1);
workProject.setCreateTime(date); workProject.setCreateTime(date);
workProject.setModifyTime(date); workProject.setModifyTime(date);
BeanUtils.copyProperties(createProjectVo, workProject); BeanUtils.copyProperties(createProjectVo, workProject);
int insert = workProjectMapper.insert(workProject); int insert = workProjectMapper.insert(workProject);
if (insert == 0) { if (insert == 0) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INSERT_DATA_IS_FAIL); throw new BaseCustomException(BASE_RESP_CODE_ENUM.INSERT_DATA_IS_FAIL);
} }
// 插入参与人员信息 // 插入参与人员信息
if (!CollectionUtils.isEmpty(createProjectVo.getUserIds())) { if (!CollectionUtils.isEmpty(createProjectVo.getUserIds())) {
return workUserProjectService.insertBatch(createProjectVo.getUserIds(), workProject.getId()); workUserProjectService.insertBatch(createProjectVo.getUserIds(), workProject.getId());
} }
// 插入更变日志
WorkProjectChange workProjectChange = new WorkProjectChange();
workProjectChange.setProjectId(workProject.getId());
workProjectChange.setReviserId(createProjectVo.getCreatorId());
workProjectChange.setModifyTime(new Date());
workProjectChange.setOperationType(1);
int insert1 = workProjectChangeMapper.insert(workProjectChange);
return true; return true;
} }
...@@ -517,12 +585,16 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -517,12 +585,16 @@ public class WorkProjectServiceImpl implements WorkProjectService {
private void verificationItem(ModifyProjectVo modifyProjectVo, WorkProject workProject, List<Integer> userIds) { private void verificationItem(ModifyProjectVo modifyProjectVo, WorkProject workProject, List<Integer> userIds) {
// 校验部门 // 校验部门
if (!workProject.getDeptId().equals(modifyProjectVo.getDeptId())) { if (null != modifyProjectVo.getDeptId()) {
if (StringUtils.isBlank(modifyProjectVo.getDeptIdReason())) { if (StringUtils.isBlank(modifyProjectVo.getDeptIdReason())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.REASON_CANNOT_BE_EMPTY); throw new BaseCustomException(BASE_RESP_CODE_ENUM.REASON_CANNOT_BE_EMPTY);
} }
if (workProject.getDeptId().equals(modifyProjectVo.getDeptId())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.theNewContent_IsEqual_ToTheOriginal_Content);
}
} }
System.out.println("1111111111");
// 校验开始时间 // 校验开始时间
if (null != modifyProjectVo.getStartTime()) { if (null != modifyProjectVo.getStartTime()) {
if (StringUtils.isBlank(modifyProjectVo.getStartTimeReason())) { if (StringUtils.isBlank(modifyProjectVo.getStartTimeReason())) {
...@@ -541,7 +613,7 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -541,7 +613,7 @@ public class WorkProjectServiceImpl implements WorkProjectService {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.theNewContent_IsEqual_ToTheOriginal_Content); throw new BaseCustomException(BASE_RESP_CODE_ENUM.theNewContent_IsEqual_ToTheOriginal_Content);
} }
} }
System.out.println("22222222");
// 校验结束时间 // 校验结束时间
if (null != modifyProjectVo.getEndTime()) { if (null != modifyProjectVo.getEndTime()) {
if (StringUtils.isBlank(modifyProjectVo.getEndTimeReason())) { if (StringUtils.isBlank(modifyProjectVo.getEndTimeReason())) {
...@@ -560,6 +632,7 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -560,6 +632,7 @@ public class WorkProjectServiceImpl implements WorkProjectService {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.theNewContent_IsEqual_ToTheOriginal_Content); throw new BaseCustomException(BASE_RESP_CODE_ENUM.theNewContent_IsEqual_ToTheOriginal_Content);
} }
} }
System.out.println("33333333333");
// 校验成本预算 // 校验成本预算
if (null != modifyProjectVo.getCostBudget()) { if (null != modifyProjectVo.getCostBudget()) {
if (BigDecimal.ZERO.compareTo(modifyProjectVo.getCostBudget()) > 0) { if (BigDecimal.ZERO.compareTo(modifyProjectVo.getCostBudget()) > 0) {
...@@ -573,9 +646,31 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -573,9 +646,31 @@ public class WorkProjectServiceImpl implements WorkProjectService {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.theNewContent_IsEqual_ToTheOriginal_Content); throw new BaseCustomException(BASE_RESP_CODE_ENUM.theNewContent_IsEqual_ToTheOriginal_Content);
} }
} }
} }
System.out.println("4444444444");
// oa编号验证
if (!StringUtils.isBlank(modifyProjectVo.getOaProjectId())) {
if (StringUtils.isBlank(modifyProjectVo.getOaProjectIdReason())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.REASON_CANNOT_BE_EMPTY);
}
if (null != workProject.getOaProjectId()) {
if (workProject.getOaProjectId().equals(modifyProjectVo.getOaProjectId())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.theNewContent_IsEqual_ToTheOriginal_Content);
}
}
}
// 项目名称验证
if (!StringUtils.isBlank(modifyProjectVo.getProjectName())) {
if (StringUtils.isBlank(modifyProjectVo.getProjectNameReason())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.REASON_CANNOT_BE_EMPTY);
}
if (!StringUtils.isBlank(workProject.getProjectName())) {
if (workProject.getProjectName().equals(modifyProjectVo.getProjectName())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.theNewContent_IsEqual_ToTheOriginal_Content);
}
}
}
System.out.println("555555555");
// 校验工时预算 // 校验工时预算
if (null != modifyProjectVo.getWorkTime()) { if (null != modifyProjectVo.getWorkTime()) {
if (BigDecimal.ZERO.compareTo(modifyProjectVo.getWorkTime()) > 0) { if (BigDecimal.ZERO.compareTo(modifyProjectVo.getWorkTime()) > 0) {
...@@ -584,14 +679,15 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -584,14 +679,15 @@ public class WorkProjectServiceImpl implements WorkProjectService {
if (StringUtils.isBlank(modifyProjectVo.getWorkTimeReason())) { if (StringUtils.isBlank(modifyProjectVo.getWorkTimeReason())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.REASON_CANNOT_BE_EMPTY); throw new BaseCustomException(BASE_RESP_CODE_ENUM.REASON_CANNOT_BE_EMPTY);
} }
if (null !=workProject.getWorkTime()) { if (null != workProject.getWorkTime()) {
if (modifyProjectVo.getWorkTime().compareTo(workProject.getWorkTime()) == 0) { if (modifyProjectVo.getWorkTime().compareTo(workProject.getWorkTime()) == 0) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.theNewContent_IsEqual_ToTheOriginal_Content); throw new BaseCustomException(BASE_RESP_CODE_ENUM.theNewContent_IsEqual_ToTheOriginal_Content);
} }
} }
} }
System.out.println("66666666666");
// 校验负责人 // 校验负责人
if (!workProject.getManagerId().equals(modifyProjectVo.getManagerId())) { if (!workProject.getManagerId().equals(modifyProjectVo.getManagerId())) {
if (StringUtils.isBlank(modifyProjectVo.getManagerIdReason())) { if (StringUtils.isBlank(modifyProjectVo.getManagerIdReason())) {
...@@ -608,6 +704,7 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -608,6 +704,7 @@ public class WorkProjectServiceImpl implements WorkProjectService {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.NOADMIN_ISTRATIVE_RIGHTS); throw new BaseCustomException(BASE_RESP_CODE_ENUM.NOADMIN_ISTRATIVE_RIGHTS);
} }
} }
System.out.println("7777777777");
if (!(userIds.containsAll(modifyProjectVo.getUserIds()) && if (!(userIds.containsAll(modifyProjectVo.getUserIds()) &&
modifyProjectVo.getUserIds().containsAll(userIds))) { modifyProjectVo.getUserIds().containsAll(userIds))) {
...@@ -615,7 +712,7 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -615,7 +712,7 @@ public class WorkProjectServiceImpl implements WorkProjectService {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.REASON_CANNOT_BE_EMPTY); throw new BaseCustomException(BASE_RESP_CODE_ENUM.REASON_CANNOT_BE_EMPTY);
} }
} }
System.out.println("888888888");
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment