Commit fc1d86d8 authored by cq990612's avatar cq990612

优化代码结构

parent cebd9600
...@@ -44,7 +44,7 @@ public interface WorkProjectMapper extends BaseMapper<WorkProject> { ...@@ -44,7 +44,7 @@ public interface WorkProjectMapper extends BaseMapper<WorkProject> {
* @param deptIds 所属部门 * @param deptIds 所属部门
* @return * @return
*/ */
List<ManagerProjectsDto> getManagerProjectsDto(@Param("userId") Integer userId, @Param("type") Integer type, @Param("isConclusion") Integer isConclusion,@Param("deptIds") List<Integer> deptIds,@Param("key") String key); List<ManagerProjectsDto> getManagerProjectsDto(@Param("userId") Integer userId, @Param("type") Integer type, @Param("isConclusion") Integer isConclusion,@Param("deptIds") List<Integer> deptIds,@Param("key") String key,@Param("deptAndManager") Integer deptAndManager);
int updateIsConclusionById(Integer id); int updateIsConclusionById(Integer id);
......
...@@ -47,6 +47,6 @@ public interface WorkUserMapper extends BaseMapper<WorkUser> { ...@@ -47,6 +47,6 @@ public interface WorkUserMapper extends BaseMapper<WorkUser> {
List<WorkRole> getUserRole(Integer id); List<WorkRole> getUserRole(Integer id);
int updateStatusById(@Param("userId") Integer userId,@Param("status") Integer status); int updateStatusAndSubmitOrderById(@Param("userId") Integer userId,@Param("status") Integer status,@Param("submitOrder")Integer submitOrder);
} }
...@@ -34,8 +34,8 @@ ...@@ -34,8 +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="businessId !=null">and business_id = #{businessId}</if>
<if test="businessName !=null"> and business_name = #{businessName}</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>
...@@ -139,7 +139,8 @@ ...@@ -139,7 +139,8 @@
<select id="getManagerProjectsDto" resultType="cn.wisenergy.model.dto.ManagerProjectsDto"> <select id="getManagerProjectsDto" resultType="cn.wisenergy.model.dto.ManagerProjectsDto">
select select
p.id,p.oa_project_id,p.project_name,p.business_id,p.business_name,p.manager_id,d.dept_name,lu.manager_name,p.dept_id,p.modify_time,p.type,p.create_time,p.is_conclusion, p.id,p.oa_project_id,p.project_name,p.business_id,p.business_name,p.manager_id,d.dept_name,lu.manager_name,p.dept_id,p.modify_time,p.type,p.create_time,p.is_conclusion,
GROUP_CONCAT(DISTINCT(u.name) ORDER BY CONVERT( u.name USING gbk )) as 'participants',p.cost_budget,p.work_time,p.start_time,p.end_time, GROUP_CONCAT(DISTINCT(u.name) ORDER BY CONVERT( u.name USING gbk )) as
'participants',p.cost_budget,p.work_time,p.start_time,p.end_time,
if(cost is NULL,0,0 + cast(cost as char)) as 'currentLaborCost',if(total_time is NULL,0,0 + cast(total_time as 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', char)) as 'totalCurrentWorkingHours',
if(p.end_time>=curdate(),'否','是') as 'isItOverdue', if(p.end_time>=curdate(),'否','是') as 'isItOverdue',
...@@ -152,18 +153,21 @@ ...@@ -152,18 +153,21 @@
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 !=type"> <if test="deptAndManager !=0">
AND p.type = #{type} <if test="null !=type">
</if> AND p.type = #{type}
<if test="null !=isConclusion"> </if>
AND p.is_conclusion = #{isConclusion} <if test="null !=isConclusion">
</if> AND p.is_conclusion = #{isConclusion}
<if test="deptIds != null and deptIds.size>0"> </if>
AND p.dept_id IN <if test="deptIds != null and deptIds.size>0">
<foreach collection="deptIds" item="deptId" separator="," open="(" close=")"> AND p.dept_id IN
#{deptId} <foreach collection="deptIds" item="deptId" separator="," open="(" close=")">
</foreach> #{deptId}
</foreach>
</if>
</if> </if>
<if test="null != userId"> <if test="null != userId">
OR (p.manager_id = #{userId} OR (p.manager_id = #{userId}
<if test="null !=type"> <if test="null !=type">
......
...@@ -102,9 +102,16 @@ ...@@ -102,9 +102,16 @@
set <include refid="updateCondition"/> set <include refid="updateCondition"/>
where id = #{id} where id = #{id}
</update> </update>
<update id="updateStatusById"> <update id="updateStatusAndSubmitOrderById">
update <include refid="table"/> update <include refid="table"/>
set status = #{status} <set>
<if test="status !=null">
status = #{status},
</if>
<if test="submitOrder !=null">
submit_order = #{submitOrder}
</if>
</set>
where id = #{userId} where id = #{userId}
</update> </update>
...@@ -140,12 +147,9 @@ LEFT JOIN work_role r on ur.role_id = r.id ...@@ -140,12 +147,9 @@ LEFT JOIN work_role r on ur.role_id = r.id
AND r.id = #{roleId} AND r.id = #{roleId}
</if> </if>
<if test="null !=roleId and roleId == 0"> <if test="null !=roleId and roleId == 0">
AND r.id is null AND r.id is null
</if> </if>
ORDER BY CONVERT( u.name USING gbk )
</where> </where>
</select> </select>
<select id="getUserRole" resultType="cn.wisenergy.model.app.WorkRole"> <select id="getUserRole" resultType="cn.wisenergy.model.app.WorkRole">
...@@ -160,7 +164,7 @@ LEFT JOIN work_role r on ur.role_id = r.id ...@@ -160,7 +164,7 @@ LEFT JOIN work_role r on ur.role_id = r.id
from <include refid="table"/> from <include refid="table"/>
<where> <where>
<if test="null != status"> <if test="null != status">
status = #{status} AND status = #{status}
</if> </if>
</where> </where>
ORDER BY CONVERT( `name` USING gbk ) ORDER BY CONVERT( `name` USING gbk )
......
...@@ -10,7 +10,7 @@ import java.util.List; ...@@ -10,7 +10,7 @@ import java.util.List;
* @QQ1799796883 * @QQ1799796883
*/ */
@Data @Data
public class UserRoleDto { public class UserRoleDto {
private Integer id; private Integer id;
private String name; private String name;
private Integer status; private Integer status;
...@@ -18,4 +18,7 @@ public class UserRoleDto { ...@@ -18,4 +18,7 @@ public class UserRoleDto {
private String deptName; private String deptName;
private Integer submitOrder; private Integer submitOrder;
private List<WorkRole> workRoles; private List<WorkRole> workRoles;
} }
...@@ -31,7 +31,10 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -31,7 +31,10 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -209,17 +212,23 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -209,17 +212,23 @@ public class WorkProjectServiceImpl implements WorkProjectService {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN); throw new BaseCustomException(BASE_RESP_CODE_ENUM.THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN);
} }
int index = 0; int projectIndex = 0;
int deptAndManager = 0;
for (UserRoleLevelDto userRoleLevelDto : roleUserLevel) { for (UserRoleLevelDto userRoleLevelDto : roleUserLevel) {
if (LevelEnum.PROJECT_MANAGER.getLevelName().equals(userRoleLevelDto.getLevelName())) { if (LevelEnum.PROJECT_MANAGER.getLevelName().equals(userRoleLevelDto.getLevelName())) {
if (LevelRankEnum.PROJECT_LEVEL.getRank().equals(userRoleLevelDto.getRank())) { if (LevelRankEnum.PROJECT_LEVEL.getRank().equals(userRoleLevelDto.getRank())) {
index++; projectIndex++;
}
if (LevelRankEnum.DEPARTMENT_LEVEL.getRank().equals(userRoleLevelDto.getRank())||LevelRankEnum.CENTRAL_LEVEL.getRank().equals(userRoleLevelDto.getRank())) {
deptAndManager++;
} }
} }
} }
if (index == 0) { if (projectIndex == 0) {
user.setId(null); user.setId(null);
} }
int page = gmpv.getPage() == null ? 1 : gmpv.getPage(); int page = gmpv.getPage() == null ? 1 : gmpv.getPage();
int pageSize = gmpv.getPageSize() == null ? 10 : gmpv.getPageSize(); int pageSize = gmpv.getPageSize() == null ? 10 : gmpv.getPageSize();
Integer isConclusion = gmpv.getIsConclusion(); Integer isConclusion = gmpv.getIsConclusion();
...@@ -233,7 +242,7 @@ public class WorkProjectServiceImpl implements WorkProjectService { ...@@ -233,7 +242,7 @@ public class WorkProjectServiceImpl implements WorkProjectService {
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()); managerProjectsDto = workProjectMapper.getManagerProjectsDto(user.getId(), gmpv.getType(), isConclusion, deptIds,gmpv.getKey(),deptAndManager);
return returnPageInfo(managerProjectsDto); return returnPageInfo(managerProjectsDto);
} }
......
...@@ -183,7 +183,7 @@ public class WorkUserServiceImpl implements WorkUserService { ...@@ -183,7 +183,7 @@ public class WorkUserServiceImpl implements WorkUserService {
int page = getUserListVo.getPage() == null ? 1 : getUserListVo.getPage(); int page = getUserListVo.getPage() == null ? 1 : getUserListVo.getPage();
int pageSize = getUserListVo.getPageSize() == null ? 10 : getUserListVo.getPageSize(); int pageSize = getUserListVo.getPageSize() == null ? 10 : getUserListVo.getPageSize();
Page<UserRoleDto> startPage = PageHelper.startPage(page, pageSize); Page<UserRoleDto> startPage = PageHelper.startPage(page, pageSize);
List<UserRoleDto> userRoleDtos = workUserMapper.getUserRoleDto(getUserListVo.getStatus(), getUserListVo.getKey(),getUserListVo.getDeptId(),getUserListVo.getRoleId()); List<UserRoleDto> userRoleDtos = workUserMapper.getUserRoleDto(getUserListVo.getStatus(), getUserListVo.getKey(), getUserListVo.getDeptId(), getUserListVo.getRoleId());
if (CollectionUtils.isEmpty(userRoleDtos)) { if (CollectionUtils.isEmpty(userRoleDtos)) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.QUERY_DATA_IS_NULL); throw new BaseCustomException(BASE_RESP_CODE_ENUM.QUERY_DATA_IS_NULL);
} }
...@@ -210,8 +210,8 @@ public class WorkUserServiceImpl implements WorkUserService { ...@@ -210,8 +210,8 @@ public class WorkUserServiceImpl implements WorkUserService {
@Transactional @Transactional
@Override @Override
public Boolean modifyRole(Integer userId, List<Integer> roleIds, Integer status,Integer submitOrder) { public Boolean modifyRole(Integer userId, List<Integer> roleIds, Integer status, Integer submitOrder) {
log.info("WorkUserServiceImpl[]modifyRole[].input.param.userId:{},roleIds:{},status:{},submitOrder:{}" + userId, roleIds, status,submitOrder); log.info("WorkUserServiceImpl[]modifyRole[].input.param.userId:{},roleIds:{},status:{},submitOrder:{}" + userId, roleIds, status, submitOrder);
PageHelper.clearPage(); PageHelper.clearPage();
if (CollectionUtils.isEmpty(roleIds)) { if (CollectionUtils.isEmpty(roleIds)) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.CHOOSEATLEASTONEROLE); throw new BaseCustomException(BASE_RESP_CODE_ENUM.CHOOSEATLEASTONEROLE);
...@@ -249,7 +249,7 @@ public class WorkUserServiceImpl implements WorkUserService { ...@@ -249,7 +249,7 @@ public class WorkUserServiceImpl implements WorkUserService {
} }
} }
workUserRoleMapper.deleteByUserId(userId); workUserRoleMapper.deleteByUserId(userId);
int i = workUserMapper.updateStatusById(userId, status); int i = workUserMapper.updateStatusAndSubmitOrderById(userId, status, submitOrder);
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);
} }
...@@ -282,7 +282,6 @@ public class WorkUserServiceImpl implements WorkUserService { ...@@ -282,7 +282,6 @@ public class WorkUserServiceImpl implements WorkUserService {
workCentreService.updateById(centre); workCentreService.updateById(centre);
} }
} }
workUserRoleMapper.insertBatch(userId, roleIds); workUserRoleMapper.insertBatch(userId, roleIds);
return true; return true;
} }
...@@ -302,7 +301,7 @@ public class WorkUserServiceImpl implements WorkUserService { ...@@ -302,7 +301,7 @@ public class WorkUserServiceImpl implements WorkUserService {
} }
workUser.setPassword(Md5Util.digestMD5(user.getPhone())); workUser.setPassword(Md5Util.digestMD5(user.getPhone()));
int i = workUserMapper.updateById(workUser); int i = workUserMapper.updateById(workUser);
return i>0; return i > 0;
} }
@Override @Override
......
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