Commit 69e136a8 authored by cq990612's avatar cq990612

优化代码结构

parent 01dc286d
...@@ -81,7 +81,7 @@ public enum BASE_RESP_CODE_ENUM { ...@@ -81,7 +81,7 @@ public enum BASE_RESP_CODE_ENUM {
CENTERMANAGERALREADYEXISTS("661","该中心已经有中心负责人"), CENTERMANAGERALREADYEXISTS("661","该中心已经有中心负责人"),
ROLE_CANNOTBE_EMPTY("662", "设置的角色不能为空"), ROLE_CANNOTBE_EMPTY("662", "设置的角色不能为空"),
NOADMIN_ISTRATIVE_RIGHTS("663", "设置的负责人没有管理权限"), NOADMIN_ISTRATIVE_RIGHTS("663", "设置的负责人没有管理权限"),
NON_PROJECT_OPPORTUNITYNUMBERNAME_ISEMPTY("664","非项目,无商机属性")
; ;
......
...@@ -17,11 +17,13 @@ ...@@ -17,11 +17,13 @@
<result column="end_time" property="endTime"/> <result column="end_time" property="endTime"/>
<result column="create_time" property="createTime"/> <result column="create_time" property="createTime"/>
<result column="modify_time" property="modifyTime"/> <result column="modify_time" property="modifyTime"/>
<result column="business_id" property="businessId"/>
<result column="business_name" property="businessName"/>
</resultMap> </resultMap>
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, oa_project_id, project_name, type, manager_id, dept_id, work_time, cost_budget, is_conclusion,start_time,end_time, create_time, modify_time id, oa_project_id, project_name,business_id,business_name, type, manager_id, dept_id, work_time, cost_budget, is_conclusion,start_time,end_time, create_time, modify_time
</sql> </sql>
<sql id="table"> <sql id="table">
...@@ -32,6 +34,8 @@ ...@@ -32,6 +34,8 @@
<if test="id != null">and id = #{id}</if> <if test="id != null">and id = #{id}</if>
<if test="oaProjectId != null">and oa_project_id = #{oaProjectId}</if> <if test="oaProjectId != null">and oa_project_id = #{oaProjectId}</if>
<if test="projectName != null">and project_name = #{projectName}</if> <if test="projectName != null">and project_name = #{projectName}</if>
<if test="businessId !=null"> and business_id = #{businessId}</if>
<if test="businessName !=null"> and business_name = #{businessName}</if>
<if test="type != null">and `type` =#{type}</if> <if test="type != null">and `type` =#{type}</if>
<if test="managerId != null">and manager_id = #{managerId}</if> <if test="managerId != null">and manager_id = #{managerId}</if>
<if test="deptId != null">and dept_id = #{deptId}</if> <if test="deptId != null">and dept_id = #{deptId}</if>
...@@ -69,6 +73,15 @@ ...@@ -69,6 +73,15 @@
<if test="null != managerId"> <if test="null != managerId">
manager_id = #{managerId}, manager_id = #{managerId},
</if> </if>
<if test="null != deptId">
dept_id = #{deptId},
</if>
<if test="null != businessId">
business_id = #{businessId},
</if>
<if test="null != businessName">
business_name = #{businessName},
</if>
modify_time = now() modify_time = now()
</set> </set>
<where> <where>
......
...@@ -37,8 +37,9 @@ ORDER BY rank desc ...@@ -37,8 +37,9 @@ ORDER BY rank desc
select u.id,u.name,u.dept_id select u.id,u.name,u.dept_id
from work_user_role r left JOIN work_user u on r.user_id = u.id from work_user_role r left JOIN work_user u on r.user_id = u.id
<where> <where>
u.status = 1
<if test="null != roleId"> <if test="null != roleId">
r.role_id = #{roleId} AND r.role_id = #{roleId}
</if> </if>
group by r.user_id group by r.user_id
</where> </where>
......
...@@ -37,6 +37,12 @@ public class WorkProject implements Serializable { ...@@ -37,6 +37,12 @@ public class WorkProject implements Serializable {
@ApiModelProperty(name = "projectName",value = "项目名称") @ApiModelProperty(name = "projectName",value = "项目名称")
private String projectName; private String projectName;
@ApiModelProperty(name = "businessId",value = "商机编号")
private String businessId;
@ApiModelProperty(name = "businessName",value = "商机名称")
private String businessName;
@ApiModelProperty(name = "type",value = "1:项目,2:商机") @ApiModelProperty(name = "type",value = "1:项目,2:商机")
private Integer type; private Integer type;
......
...@@ -31,11 +31,17 @@ public class ManagerProjectsDto implements Serializable { ...@@ -31,11 +31,17 @@ public class ManagerProjectsDto implements Serializable {
@ApiModelProperty(name = "projectName",value = "项目名称") @ApiModelProperty(name = "projectName",value = "项目名称")
private String projectName; private String projectName;
@ApiModelProperty(name = "businessId",value = "商机编号")
private String businessId;
@ApiModelProperty(name = "businessName",value = "商机名称")
private String businessName;
@ApiModelProperty(name = "type",value = "1:项目,2:商机") @ApiModelProperty(name = "type",value = "1:项目,2:商机")
private Integer type; private Integer type;
@ApiModelProperty(name = "managerId",value = "项目负责人id") @ApiModelProperty(name = "managerId",value = "项目负责人id")
private Integer managerId; private String managerId;
@ApiModelProperty(name = "managerName", value = "项目负责人名字") @ApiModelProperty(name = "managerName", value = "项目负责人名字")
private String managerName; private String managerName;
......
...@@ -9,7 +9,8 @@ public enum ChangeTypeEnum { ...@@ -9,7 +9,8 @@ public enum ChangeTypeEnum {
WORKINGHOURSBUDGET(2, "工时预算(人/天)"), WORKINGHOURSBUDGET(2, "工时预算(人/天)"),
STARTINGTIME(3, "预计开始时间"), STARTINGTIME(3, "预计开始时间"),
ENDTIME(4, "预计结束时间"), ENDTIME(4, "预计结束时间"),
MANAGER(5,"项目/商机负责人") MANAGER(5,"项目/商机负责人"),
DEPARTMENT(6,"项目/商机所属部门")
; ;
......
package cn.wisenergy.model.enums;
public enum WorkOrderType {
PROJECT(1, "项目"),
BUSINESS(2, "商机"),
LEAVE(3, "请假"),
CONMPENSATORY_LEAVE(4, "调休"),
EXTERNAL_WORK(5, "外部商务、技术交流"),
INTERNAL_WORK(6, "内部培训、技术准备、管理"),
OTHER_NOT_PROJECT_BUSINESS(7, "其他非项目、商机工作");
private Integer code;
private String desc;
WorkOrderType(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
...@@ -47,4 +47,10 @@ public class CreateProjectVo { ...@@ -47,4 +47,10 @@ public class CreateProjectVo {
@ApiModelProperty(name = "deptId",value = "部门id") @ApiModelProperty(name = "deptId",value = "部门id")
private Integer deptId; private Integer deptId;
@ApiModelProperty(name = "businessId",value = "商机编号")
private String businessId;
@ApiModelProperty(name = "businessName",value = "商机名称")
private String businessName;
} }
...@@ -26,6 +26,10 @@ public class ModifyProjectVo { ...@@ -26,6 +26,10 @@ public class ModifyProjectVo {
private List<Integer> userIds; private List<Integer> userIds;
private Integer deptId;
private String deptIdReason;
@JsonFormat(shape=JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd") @JsonFormat(shape=JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd")
private Date startTime; private Date startTime;
...@@ -43,4 +47,8 @@ public class ModifyProjectVo { ...@@ -43,4 +47,8 @@ public class ModifyProjectVo {
private BigDecimal costBudget; private BigDecimal costBudget;
private String costBudgetReason; private String costBudgetReason;
private String businessId;
private String businessName;
} }
...@@ -16,10 +16,7 @@ import cn.wisenergy.model.enums.ManagerEnum; ...@@ -16,10 +16,7 @@ import cn.wisenergy.model.enums.ManagerEnum;
import cn.wisenergy.model.vo.CreateProjectVo; import cn.wisenergy.model.vo.CreateProjectVo;
import cn.wisenergy.model.vo.GetManagerProjectsVo; import cn.wisenergy.model.vo.GetManagerProjectsVo;
import cn.wisenergy.model.vo.ModifyProjectVo; import cn.wisenergy.model.vo.ModifyProjectVo;
import cn.wisenergy.service.WorkProjectChangeService; import cn.wisenergy.service.*;
import cn.wisenergy.service.WorkProjectService;
import cn.wisenergy.service.WorkUserProjectService;
import cn.wisenergy.service.WorkUserService;
import cn.wisenergy.service.utils.UserRoleLevelUtils; import cn.wisenergy.service.utils.UserRoleLevelUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
...@@ -60,6 +57,9 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -60,6 +57,9 @@ public class WorkProjectServiceImpl implements WorkProjectService {
@Autowired @Autowired
private WorkDeptMapper workDeptMapper; private WorkDeptMapper workDeptMapper;
@Autowired
private WorkDeptService workDeptService;
@Autowired @Autowired
private WorkCentreMapper workCentreMapper; private WorkCentreMapper workCentreMapper;
...@@ -313,18 +313,23 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -313,18 +313,23 @@ public class WorkProjectServiceImpl implements WorkProjectService {
// 2.更新表数据 // 2.更新表数据
// 更新workProject数据 // 更新workProject数据
if (!StringUtils.isBlank(modifyProjectVo.getStartTimeReason()) ||
!StringUtils.isBlank(modifyProjectVo.getEndTimeReason()) ||
!StringUtils.isBlank(modifyProjectVo.getWorkTimeReason()) ||
!StringUtils.isBlank(modifyProjectVo.getCostBudgetReason()) ||
!StringUtils.isBlank(modifyProjectVo.getManageIdReason())
) {
int i = workProjectMapper.updateProject(modifyProjectVo); int i = workProjectMapper.updateProject(modifyProjectVo);
if (i == 0) { if (i == 0) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.UPDATE_DATA_FAIL); throw new BaseCustomException(BASE_RESP_CODE_ENUM.UPDATE_DATA_FAIL);
} }
// 向workProjectChange插入内容 // 向workProjectChange插入内容
List<WorkProjectChange> workProjectChanges = new ArrayList<>(); List<WorkProjectChange> workProjectChanges = new ArrayList<>();
if (!StringUtils.isBlank(modifyProjectVo.getDeptIdReason())) {
WorkProjectChange workProjectChange = new WorkProjectChange();
workProjectChange.setProjectId(modifyProjectVo.getProjectId());
workProjectChange.setModifyTime(new Date());
workProjectChange.setChangeType(6);
workProjectChange.setModifyBefore(workDeptService.getById(workProject.getDeptId()).getDeptName());
workProjectChange.setModifyAfter(workDeptService.getById(modifyProjectVo.getDeptId()).getDeptName());
workProjectChange.setReason(modifyProjectVo.getDeptIdReason());
workProjectChanges.add(workProjectChange);
}
if (!StringUtils.isBlank(modifyProjectVo.getManageIdReason())) { if (!StringUtils.isBlank(modifyProjectVo.getManageIdReason())) {
WorkProjectChange workProjectChange = new WorkProjectChange(); WorkProjectChange workProjectChange = new WorkProjectChange();
workProjectChange.setProjectId(modifyProjectVo.getProjectId()); workProjectChange.setProjectId(modifyProjectVo.getProjectId());
...@@ -376,10 +381,10 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -376,10 +381,10 @@ public class WorkProjectServiceImpl implements WorkProjectService {
workProjectChange.setReason(modifyProjectVo.getCostBudgetReason()); workProjectChange.setReason(modifyProjectVo.getCostBudgetReason());
workProjectChanges.add(workProjectChange); workProjectChanges.add(workProjectChange);
} }
if (!CollectionUtils.isEmpty(workProjectChanges)) {
workProjectChangeService.insertbatch(workProjectChanges); workProjectChangeService.insertbatch(workProjectChanges);
} }
// 更新workUserProject数据 // 更新workUserProject数据
if (!userIds.containsAll(modifyProjectVo.getUserIds()) || !modifyProjectVo.getUserIds().containsAll(userIds)) { if (!userIds.containsAll(modifyProjectVo.getUserIds()) || !modifyProjectVo.getUserIds().containsAll(userIds)) {
// 先删除,后插入 // 先删除,后插入
...@@ -402,7 +407,7 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -402,7 +407,7 @@ public class WorkProjectServiceImpl implements WorkProjectService {
if (null == createProjectVo) { if (null == createProjectVo) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL); throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
} }
if (null == createProjectVo.getManagerId() || null == createProjectVo.getStartTime() || null == createProjectVo.getEndTime() || StringUtils.isBlank(createProjectVo.getOaProjectId()) || null == createProjectVo.getWorkTime() || null == createProjectVo.getCostBudget() || if (null == createProjectVo.getManagerId() || null == createProjectVo.getStartTime() || null == createProjectVo.getEndTime() || StringUtils.isBlank(createProjectVo.getOaProjectId()) || null == createProjectVo.getWorkTime() || null == createProjectVo.getCostBudget() || null == createProjectVo.getDeptId() ||
StringUtils.isBlank(createProjectVo.getProjectName()) || CollectionUtils.isEmpty(createProjectVo.getUserIds()) || null == createProjectVo.getDeptId()) { StringUtils.isBlank(createProjectVo.getProjectName()) || CollectionUtils.isEmpty(createProjectVo.getUserIds()) || null == createProjectVo.getDeptId()) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL); throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
} }
...@@ -452,6 +457,19 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -452,6 +457,19 @@ 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 (1 != workProject.getType() && (!StringUtils.isBlank(modifyProjectVo.getBusinessId()) || !StringUtils.isBlank(modifyProjectVo.getBusinessName()))) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.NON_PROJECT_OPPORTUNITYNUMBERNAME_ISEMPTY);
}
// 校验部门
if (!workProject.getDeptId().equals(modifyProjectVo.getDeptId())) {
if (StringUtils.isBlank(modifyProjectVo.getDeptIdReason())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.REASON_CANNOT_BE_EMPTY);
}
}
// 校验开始时间
if (null != modifyProjectVo.getStartTime()) { if (null != modifyProjectVo.getStartTime()) {
if (StringUtils.isBlank(modifyProjectVo.getStartTimeReason())) { if (StringUtils.isBlank(modifyProjectVo.getStartTimeReason())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.REASON_CANNOT_BE_EMPTY); throw new BaseCustomException(BASE_RESP_CODE_ENUM.REASON_CANNOT_BE_EMPTY);
...@@ -469,6 +487,7 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -469,6 +487,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);
} }
} }
// 校验结束时间
if (null != modifyProjectVo.getEndTime()) { if (null != modifyProjectVo.getEndTime()) {
if (StringUtils.isBlank(modifyProjectVo.getEndTimeReason())) { if (StringUtils.isBlank(modifyProjectVo.getEndTimeReason())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.REASON_CANNOT_BE_EMPTY); throw new BaseCustomException(BASE_RESP_CODE_ENUM.REASON_CANNOT_BE_EMPTY);
...@@ -486,6 +505,7 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -486,6 +505,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);
} }
} }
// 校验成本预算
if (null != modifyProjectVo.getCostBudget()) { if (null != modifyProjectVo.getCostBudget()) {
if (BigDecimal.ZERO.compareTo(modifyProjectVo.getCostBudget()) > 0) { if (BigDecimal.ZERO.compareTo(modifyProjectVo.getCostBudget()) > 0) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.BUDGET_CANNOT_BELESSTHAN_ZERO); throw new BaseCustomException(BASE_RESP_CODE_ENUM.BUDGET_CANNOT_BELESSTHAN_ZERO);
...@@ -497,6 +517,7 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -497,6 +517,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);
} }
} }
// 校验工时预算
if (null != modifyProjectVo.getWorkTime()) { if (null != modifyProjectVo.getWorkTime()) {
if (BigDecimal.ZERO.compareTo(modifyProjectVo.getWorkTime()) > 0) { if (BigDecimal.ZERO.compareTo(modifyProjectVo.getWorkTime()) > 0) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.BUDGET_CANNOT_BELESSTHAN_ZERO); throw new BaseCustomException(BASE_RESP_CODE_ENUM.BUDGET_CANNOT_BELESSTHAN_ZERO);
...@@ -508,7 +529,11 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -508,7 +529,11 @@ 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);
} }
} }
if (null != modifyProjectVo.getManagerId()) { // 校验负责人
if (!workProject.getManagerId().equals(modifyProjectVo.getManagerId())) {
if (StringUtils.isBlank(modifyProjectVo.getManageIdReason())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.REASON_CANNOT_BE_EMPTY);
}
List<Integer> roles = UserRoleLevelUtils.getRole(modifyProjectVo.getManagerId()); List<Integer> roles = UserRoleLevelUtils.getRole(modifyProjectVo.getManagerId());
int index = 0; int index = 0;
for (Integer role : roles) { for (Integer role : roles) {
...@@ -521,12 +546,13 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -521,12 +546,13 @@ public class WorkProjectServiceImpl implements WorkProjectService {
} }
} }
if (null == modifyProjectVo.getStartTime() && null == modifyProjectVo.getEndTime() && null == modifyProjectVo.getCostBudget() && null == modifyProjectVo.getWorkTime() && null == modifyProjectVo.getManagerId()) { /*if (null == modifyProjectVo.getStartTime() && null == modifyProjectVo.getEndTime() && null == modifyProjectVo.getCostBudget() && null == modifyProjectVo.getWorkTime() && workProject.getDeptId().equals(modifyProjectVo.getDeptId()) && workProject.getManagerId().equals(modifyProjectVo.getManagerId()) ) {
if (userIds.containsAll(modifyProjectVo.getUserIds()) && if (userIds.containsAll(modifyProjectVo.getUserIds()) &&
modifyProjectVo.getUserIds().containsAll(userIds)) { modifyProjectVo.getUserIds().containsAll(userIds)) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.theNewContent_IsEqual_ToTheOriginal_Content); throw new BaseCustomException(BASE_RESP_CODE_ENUM.theNewContent_IsEqual_ToTheOriginal_Content);
} }
} }*/
} }
} }
...@@ -172,12 +172,14 @@ public class UserRoleLevelUtils { ...@@ -172,12 +172,14 @@ public class UserRoleLevelUtils {
} }
List<Integer> getlevelIds = getlevelIds(roles); List<Integer> getlevelIds = getlevelIds(roles);
Set<Integer> hashSet = new HashSet<>(); Set<Integer> hashSet = new HashSet<>();
if (!CollectionUtils.isEmpty(getlevelIds)) {
for (Integer id : getlevelIds) { for (Integer id : getlevelIds) {
if (!hashSet.add(id)){ if (!hashSet.add(id)){
//有重复值 //有重复值
return true; return true;
} }
} }
}
return false; return false;
} }
......
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