Commit 51d0c1c7 authored by cq990612's avatar cq990612

优化代码结构

parent 9d8b385d
...@@ -80,6 +80,7 @@ public enum BASE_RESP_CODE_ENUM { ...@@ -80,6 +80,7 @@ public enum BASE_RESP_CODE_ENUM {
DEPARTMENT_MANAGER_ALREADY_EXISTS("660", "该部门已有部门负责人"), DEPARTMENT_MANAGER_ALREADY_EXISTS("660", "该部门已有部门负责人"),
CENTERMANAGERALREADYEXISTS("661","该中心已经有中心负责人"), CENTERMANAGERALREADYEXISTS("661","该中心已经有中心负责人"),
ROLE_CANNOTBE_EMPTY("662", "设置的角色不能为空"), ROLE_CANNOTBE_EMPTY("662", "设置的角色不能为空"),
NOADMIN_ISTRATIVE_RIGHTS("663", "设置的负责人没有管理权限"),
; ;
......
...@@ -4,19 +4,19 @@ ...@@ -4,19 +4,19 @@
<!-- 通用查询映射结果 --> <!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.wisenergy.model.app.WorkProject"> <resultMap id="BaseResultMap" type="cn.wisenergy.model.app.WorkProject">
<id column="id" property="id" /> <id column="id" property="id"/>
<result column="oa_project_id" property="oaProjectId" /> <result column="oa_project_id" property="oaProjectId"/>
<result column="project_name" property="projectName" /> <result column="project_name" property="projectName"/>
<result column="type" property="type" /> <result column="type" property="type"/>
<result column="manager_id" property="managerId" /> <result column="manager_id" property="managerId"/>
<result column="dept_id" property="deptId" /> <result column="dept_id" property="deptId"/>
<result column="work_time" property="workTime" /> <result column="work_time" property="workTime"/>
<result column="cost_budget" property="costBudget" /> <result column="cost_budget" property="costBudget"/>
<result column="is_conclusion" property="isConclusion" /> <result column="is_conclusion" property="isConclusion"/>
<result column="start_time" property="startTime" /> <result column="start_time" property="startTime"/>
<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"/>
</resultMap> </resultMap>
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
...@@ -66,6 +66,9 @@ ...@@ -66,6 +66,9 @@
<if test="null != costBudget"> <if test="null != costBudget">
cost_budget =#{costBudget}, cost_budget =#{costBudget},
</if> </if>
<if test="null != managerId">
manager_id = #{managerId},
</if>
modify_time = now() modify_time = now()
</set> </set>
<where> <where>
...@@ -79,8 +82,10 @@ ...@@ -79,8 +82,10 @@
</update> </update>
<select id="getProjectsByCriteria" resultMap="BaseResultMap" parameterType="map"> <select id="getProjectsByCriteria" resultMap="BaseResultMap" parameterType="map">
select <include refid="Base_Column_List"/> select
from <include refid="table"/> <include refid="Base_Column_List"/>
from
<include refid="table"/>
<where> <where>
<if test="isConclusion != null"> <if test="isConclusion != null">
is_conclusion = #{isConclusion} is_conclusion = #{isConclusion}
...@@ -101,8 +106,10 @@ ...@@ -101,8 +106,10 @@
</select> </select>
<select id="getProjectsByIds" resultType="cn.wisenergy.model.app.WorkProject"> <select id="getProjectsByIds" resultType="cn.wisenergy.model.app.WorkProject">
select <include refid="Base_Column_List"/> select
from <include refid="table"/> <include refid="Base_Column_List"/>
from
<include refid="table"/>
<where> <where>
<if test="ids != null"> <if test="ids != null">
...@@ -117,17 +124,19 @@ ...@@ -117,17 +124,19 @@
</where> </where>
</select> </select>
<select id="getManagerProjectsDto" resultType="cn.wisenergy.model.dto.ManagerProjectsDto"> <select id="getManagerProjectsDto" resultType="cn.wisenergy.model.dto.ManagerProjectsDto">
select p.id,p.oa_project_id,p.project_name,p.type,p.create_time,p.is_conclusion, select
GROUP_CONCAT(DISTINCT(u.name)) as 'participants',p.cost_budget,p.work_time,p.start_time,p.end_time, p.id,p.oa_project_id,p.project_name,p.manager_id,p.dept_id,p.modify_time,p.type,p.create_time,p.is_conclusion,
if(cost is NULL,0,0 + cast(cost as char)) as 'currentLaborCost',if(total_time is NULL,0,0 + cast(total_time as char)) as 'totalCurrentWorkingHours', GROUP_CONCAT(DISTINCT(u.name)) as 'participants',p.cost_budget,p.work_time,p.start_time,p.end_time,
if(p.end_time>=curdate(),'否','是') as 'isItOverdue', if(cost is NULL,0,0 + cast(cost as char)) as 'currentLaborCost',if(total_time is NULL,0,0 + cast(total_time as
if(p.create_time = p.modify_time,'否','是') as 'isThereABudgetChange' char)) as 'totalCurrentWorkingHours',
if(p.end_time>=curdate(),'否','是') as 'isItOverdue',
if(p.create_time = p.modify_time,'否','是') as 'isThereABudgetChange'
from work_project p LEFT JOIN (select project_id,SUM(total_time) as 'total_time',SUM(cost)/10000 as 'cost' from work_project p LEFT JOIN (select project_id,SUM(total_time) as 'total_time',SUM(cost)/10000 as 'cost'
FROM work_project_time_cost FROM work_project_time_cost
GROUP BY project_id) o on p.id = o.project_id GROUP BY project_id) o on p.id = o.project_id
LEFT JOIN work_user_project up ON p.id = up.project_id LEFT JOIN work_user_project up ON p.id = up.project_id
LEFT JOIN work_user u on u.id = up.user_id LEFT JOIN work_user u on u.id = up.user_id
<where> <where>
<if test="null != userId"> <if test="null != userId">
AND p.manager_id = #{userId} AND p.manager_id = #{userId}
...@@ -153,17 +162,19 @@ if(p.create_time = p.modify_time,'否','是') as 'isThereABudgetChange' ...@@ -153,17 +162,19 @@ if(p.create_time = p.modify_time,'否','是') as 'isThereABudgetChange'
) )
</if> </if>
</where> </where>
GROUP BY p.id GROUP BY p.id
ORDER BY p.is_conclusion DESC, p.create_time DESC ORDER BY p.is_conclusion DESC, p.create_time DESC
</select> </select>
<select id="getListByCriteria" resultType="cn.wisenergy.model.app.WorkProject"> <select id="getListByCriteria" resultType="cn.wisenergy.model.app.WorkProject">
select <include refid="Base_Column_List"/> select
from <include refid="table"/> <include refid="Base_Column_List"/>
from
<include refid="table"/>
<where> <where>
<include refid="criteria"/> <include refid="criteria"/>
</where> </where>
...@@ -171,12 +182,14 @@ ORDER BY p.is_conclusion DESC, p.create_time DESC ...@@ -171,12 +182,14 @@ ORDER BY p.is_conclusion DESC, p.create_time DESC
<select id="getProjectIdByManager" resultType="java.lang.Integer"> <select id="getProjectIdByManager" resultType="java.lang.Integer">
select id select id
from <include refid="table"/> from
<include refid="table"/>
where manager_id = #{userId} where manager_id = #{userId}
</select> </select>
<select id="getListByCentreIdAndIsConclusion" resultType="cn.wisenergy.model.app.WorkProject"> <select id="getListByCentreIdAndIsConclusion" resultType="cn.wisenergy.model.app.WorkProject">
select <include refid="Base_Column_List"/> select
<include refid="Base_Column_List"/>
from work_project p join work_dept d on p.dept_id = d.id from work_project p join work_dept d on p.dept_id = d.id
where centre_id = #{centreId} where centre_id = #{centreId}
<if test="isConclusion != null"> <if test="isConclusion != null">
......
...@@ -61,6 +61,14 @@ public class WorkTimeOrderDto { ...@@ -61,6 +61,14 @@ public class WorkTimeOrderDto {
@ApiModelProperty(name = "isOvertime", value = "0:正常工时,1:加班") @ApiModelProperty(name = "isOvertime", value = "0:正常工时,1:加班")
private Integer isOvertime; private Integer isOvertime;
@JsonFormat(shape=JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd")
@ApiModelProperty(name = "createTime", value = "工单创建时间")
private Date createTime;
@JsonFormat(shape=JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd")
@ApiModelProperty(name = "modifyTime", value = "审批时间")
private Date modifyTime;
@JsonFormat(shape=JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd") @JsonFormat(shape=JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd")
@ApiModelProperty(name = "rejectTime",value = "驳回时间") @ApiModelProperty(name = "rejectTime",value = "驳回时间")
private Date rejectTime; private Date rejectTime;
......
...@@ -9,7 +9,7 @@ public enum ChangeTypeEnum { ...@@ -9,7 +9,7 @@ public enum ChangeTypeEnum {
WORKINGHOURSBUDGET(2, "工时预算(人/天)"), WORKINGHOURSBUDGET(2, "工时预算(人/天)"),
STARTINGTIME(3, "预计开始时间"), STARTINGTIME(3, "预计开始时间"),
ENDTIME(4, "预计结束时间"), ENDTIME(4, "预计结束时间"),
MANAGER(5,"项目/商机负责人")
; ;
......
...@@ -18,6 +18,10 @@ import java.util.List; ...@@ -18,6 +18,10 @@ import java.util.List;
@ApiModel(value="ModifyProjectVo", description="项目编辑VO") @ApiModel(value="ModifyProjectVo", description="项目编辑VO")
public class ModifyProjectVo { public class ModifyProjectVo {
private Integer managerId;
private String manageIdReason;
private Integer projectId; private Integer projectId;
private List<Integer> userIds; private List<Integer> userIds;
......
...@@ -316,15 +316,25 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -316,15 +316,25 @@ public class WorkProjectServiceImpl implements WorkProjectService {
if (!StringUtils.isBlank(modifyProjectVo.getStartTimeReason()) || if (!StringUtils.isBlank(modifyProjectVo.getStartTimeReason()) ||
!StringUtils.isBlank(modifyProjectVo.getEndTimeReason()) || !StringUtils.isBlank(modifyProjectVo.getEndTimeReason()) ||
!StringUtils.isBlank(modifyProjectVo.getWorkTimeReason()) || !StringUtils.isBlank(modifyProjectVo.getWorkTimeReason()) ||
!StringUtils.isBlank(modifyProjectVo.getCostBudgetReason()) !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.getManageIdReason())) {
WorkProjectChange workProjectChange = new WorkProjectChange();
workProjectChange.setProjectId(modifyProjectVo.getProjectId());
workProjectChange.setModifyTime(new Date());
workProjectChange.setChangeType(5);
workProjectChange.setModifyBefore(workUserService.getById(workProject.getManagerId()).getName());
workProjectChange.setModifyAfter(workUserService.getById(modifyProjectVo.getManagerId()).getName());
workProjectChange.setReason(modifyProjectVo.getManageIdReason());
workProjectChanges.add(workProjectChange);
}
if (!StringUtils.isBlank(modifyProjectVo.getStartTimeReason())) { if (!StringUtils.isBlank(modifyProjectVo.getStartTimeReason())) {
WorkProjectChange workProjectChange = new WorkProjectChange(); WorkProjectChange workProjectChange = new WorkProjectChange();
workProjectChange.setProjectId(modifyProjectVo.getProjectId()); workProjectChange.setProjectId(modifyProjectVo.getProjectId());
...@@ -498,8 +508,14 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -498,8 +508,14 @@ 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()) {
List<Integer> role = UserRoleLevelUtils.getRole(modifyProjectVo.getManagerId());
if (1 == role.size() && role.get(0).equals(0)) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.NOADMIN_ISTRATIVE_RIGHTS);
}
}
if (null == modifyProjectVo.getStartTime() && null == modifyProjectVo.getEndTime() && null == modifyProjectVo.getCostBudget() && null == modifyProjectVo.getWorkTime()) { if (null == modifyProjectVo.getStartTime() && null == modifyProjectVo.getEndTime() && null == modifyProjectVo.getCostBudget() && null == modifyProjectVo.getWorkTime() && null == 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);
......
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