From aabad64a174838cfb0054b010e91e42e73e3fe80 Mon Sep 17 00:00:00 2001 From: ma <1062634917@qq.com> Date: Thu, 15 Apr 2021 15:28:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=92=E8=89=B2=E5=B1=95=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ccsens/tall/service/ExcelService.java | 19 +++++++++++++++++++ .../ccsens/tall/service/IProRoleService.java | 11 ++++++++++- .../ccsens/tall/service/ProMemberService.java | 3 +++ .../ccsens/tall/service/ProRoleService.java | 16 ++++++++++++++-- .../ccsens/tall/web/ProjectController.java | 5 +++-- .../com/ccsens/tall/web/RoleController.java | 15 +++++++++++++++ .../main/java/com/ccsens/util/CodeEnum.java | 2 ++ .../java/com/ccsens/util/WebConstant.java | 3 +++ 8 files changed, 69 insertions(+), 5 deletions(-) diff --git a/tall/src/main/java/com/ccsens/tall/service/ExcelService.java b/tall/src/main/java/com/ccsens/tall/service/ExcelService.java index 87207e10..c58f4a0b 100644 --- a/tall/src/main/java/com/ccsens/tall/service/ExcelService.java +++ b/tall/src/main/java/com/ccsens/tall/service/ExcelService.java @@ -76,6 +76,8 @@ public class ExcelService implements IExcelService { @Resource private IUserAttentionService userAttentionService; @Resource + private UserAttentionDao userAttentionDao; + @Resource private IWbsSubSheetService wbsSubSheetService; @Resource private IWpsService wpsService; @@ -93,6 +95,17 @@ public class ExcelService implements IExcelService { XSSFWorkbook xssfWorkbook = new XSSFWorkbook(is); //读取WBS表 SysProject sysProject = readWbs(xssfWorkbook, currentUserId); + //查看创建人是否关注了项目 + UserAttentionExample example = new UserAttentionExample(); + example.createCriteria().andUserIdEqualTo(currentUserId).andProjectIdEqualTo(sysProject.getId()); + long count = userAttentionDao.countByExample(example); + if (0 == count){ + UserAttention userAttention = new UserAttention(); + userAttention.setId(snowflake.nextId()); + userAttention.setProjectId(sysProject.getId()); + userAttention.setUserId(currentUserId); + userAttentionDao.insertSelective(userAttention); + } return selectByProjectId(currentUserId, sysProject); } @@ -536,9 +549,11 @@ public class ExcelService implements IExcelService { //添加奖惩干系人 if (StrUtil.isNotEmpty(stakeholderCell)) { + //判断奖惩干系人的手机号是否为空 if ( StrUtil.isEmpty(stakeholderPhoneCell)){ throw new BaseException(CodeEnum.WBS_NOT_PHONE.addMsg(memberSheet.getSheetName(), (i+1),stakeholderCell)); } + //判断奖惩干系人的手机号格式是否正确 if (!stakeholderPhoneCell.matches(regex)){ throw new BaseException(CodeEnum.WBS_PHONE_ERROR.addMsg(memberSheet.getSheetName(),(i+1),stakeholderCell)); } @@ -740,6 +755,10 @@ public class ExcelService implements IExcelService { } if(map.get("标签")!=null){ label=StringUtil.replaceStrSpace(ExcelUtil.getCellValue(row.getCell(map.get("标签")))); + int length = label.length(); + if (WebConstant.LABEL_LENGTH < length){ + throw new BaseException(CodeEnum.LABEL_TOO_LONG.addMsg(wbsSheet.getSheetName(),(i+1),label)); + } }else { throw new BaseException(CodeEnum.NOTNAME.addMsgLwb("标签")); } diff --git a/tall/src/main/java/com/ccsens/tall/service/IProRoleService.java b/tall/src/main/java/com/ccsens/tall/service/IProRoleService.java index 3c9df8fd..b58f3717 100644 --- a/tall/src/main/java/com/ccsens/tall/service/IProRoleService.java +++ b/tall/src/main/java/com/ccsens/tall/service/IProRoleService.java @@ -15,7 +15,16 @@ public interface IProRoleService { List getProRoleByProjectIdAndUserId(Long projectId, Long currentUserId); - List getRolesByProjectIdAndUserId(Long projectId, Long currentUserId,Integer imitation) throws Exception; + /** + * + * @param projectId + * @param currentUserId + * @param imitation + * @param queryType 0是查可见角色,1是查全部 + * @return + * @throws Exception + */ + List getRolesByProjectIdAndUserId(Long projectId, Long currentUserId,Integer imitation,int queryType) throws Exception; List getRealMemberRolesByProjectId(Long projectId); diff --git a/tall/src/main/java/com/ccsens/tall/service/ProMemberService.java b/tall/src/main/java/com/ccsens/tall/service/ProMemberService.java index bd30ac64..efd9750e 100644 --- a/tall/src/main/java/com/ccsens/tall/service/ProMemberService.java +++ b/tall/src/main/java/com/ccsens/tall/service/ProMemberService.java @@ -402,6 +402,9 @@ public class ProMemberService implements IProMemberService { } //修改奖惩干系人 Long stakeholderId = null; + if (ObjectUtil.isNotNull(updateMemberInfo.getStakeholderName()) && ObjectUtil.isNull(updateMemberInfo.getStakeholderPhone())){ + throw new BaseException(CodeEnum.WBS_STAKEHOLDER_PHONE_NOT_FOUND); + } if (ObjectUtil.isNotNull(updateMemberInfo.getStakeholderPhone())) { ProMemberExample stakeholderExample = new ProMemberExample(); stakeholderExample.createCriteria().andProjectIdEqualTo(proMember.getProjectId()).andPhoneEqualTo(updateMemberInfo.getStakeholderPhone()); diff --git a/tall/src/main/java/com/ccsens/tall/service/ProRoleService.java b/tall/src/main/java/com/ccsens/tall/service/ProRoleService.java index 29dc7755..f468cff6 100644 --- a/tall/src/main/java/com/ccsens/tall/service/ProRoleService.java +++ b/tall/src/main/java/com/ccsens/tall/service/ProRoleService.java @@ -91,14 +91,19 @@ public class ProRoleService implements IProRoleService { * 根据项目id和用户Id查询项目下的所有二级角色的详细信息 */ @Override - public List getRolesByProjectIdAndUserId(Long projectId, Long currentUserId, Integer imitation) throws Exception { + public List getRolesByProjectIdAndUserId(Long projectId, Long currentUserId, Integer imitation,int queryType) throws Exception { List memberRoleList; //获取用户在项目中的角色 List roleList = proMemberService.selectRolesByUserIdAndProjectId(currentUserId, projectId, imitation); //1.查询二级角色(项目经理+项目成员+mvp)(所有二级角色) - memberRoleList = getRealMemberRolesShowByProjectId(projectId,currentUserId); + if (queryType == 0){ + memberRoleList = getRealMemberRolesShowByProjectId(projectId,currentUserId); + }else{ + memberRoleList = getRealMemberRolesShowByProjectIdAll(projectId,currentUserId); + } + if (CollectionUtil.isNotEmpty(memberRoleList)) { if (CollectionUtil.isNotEmpty(roleList)) { @@ -238,6 +243,13 @@ public class ProRoleService implements IProRoleService { // } return memberRoleList; } + + private List getRealMemberRolesShowByProjectIdAll(Long projectId, Long currentUserId) { + List memberRoleList; + memberRoleList = proRoleDao.selectSecondRolesByProjectId(projectId); + return memberRoleList; + } + @Override public List getRealMemberRolesByProjectId(Long projectId) { //查询二级角色 diff --git a/tall/src/main/java/com/ccsens/tall/web/ProjectController.java b/tall/src/main/java/com/ccsens/tall/web/ProjectController.java index 30a4f4a6..3e8bb488 100644 --- a/tall/src/main/java/com/ccsens/tall/web/ProjectController.java +++ b/tall/src/main/java/com/ccsens/tall/web/ProjectController.java @@ -85,7 +85,7 @@ public class ProjectController { return JsonResponse.newInstance().ok(projectInfo); } - @ApiOperation(value = "根据项目id获取二级角色列表",notes = "PM,MVP,Mine,Others...") + @ApiOperation(value = "根据项目id获取二级角色列表(查询全部)",notes = "PM,MVP,Mine,Others...") @ApiImplicitParams({ @ApiImplicitParam(name = "id", value = "项目Id", required = true, paramType = "path"), @ApiImplicitParam(name = "imitation", value = "是否是变身模式 0否 1是", required = true, paramType = "query") @@ -95,7 +95,8 @@ public class ProjectController { @PathVariable("id") Long projectId, @RequestParam(required = false) Integer imitation) throws Exception { Long currentUserId = Long.valueOf(((Claims) request.getAttribute(WebConstant.REQUEST_KEY_CLAIMS)).getSubject()); - List roleInfoList = proRoleService.getRolesByProjectIdAndUserId(projectId, currentUserId,imitation); + int queryType = 1; + List roleInfoList = proRoleService.getRolesByProjectIdAndUserId(projectId, currentUserId,imitation,queryType); return JsonResponse.newInstance().ok(roleInfoList); } diff --git a/tall/src/main/java/com/ccsens/tall/web/RoleController.java b/tall/src/main/java/com/ccsens/tall/web/RoleController.java index 2930ab70..1ca21552 100644 --- a/tall/src/main/java/com/ccsens/tall/web/RoleController.java +++ b/tall/src/main/java/com/ccsens/tall/web/RoleController.java @@ -144,4 +144,19 @@ public class RoleController { proRoleService.upRoleShowsOrder(param); return JsonResponse.newInstance().ok(); } + + @ApiOperation(value = "根据项目id获取二级角色列表(当前用户可见)",notes = "PM,MVP,Mine,Others...") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "项目Id", required = true, paramType = "path"), + @ApiImplicitParam(name = "imitation", value = "是否是变身模式 0否 1是", required = true, paramType = "query") + }) + @RequestMapping(value = "/{id}/roles", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) + public JsonResponse> getRolesByProjectId(HttpServletRequest request, + @PathVariable("id") Long projectId, + @RequestParam(required = false) Integer imitation) throws Exception { + Long currentUserId = Long.valueOf(((Claims) request.getAttribute(WebConstant.REQUEST_KEY_CLAIMS)).getSubject()); + int queryType = 0; + List roleInfoList = proRoleService.getRolesByProjectIdAndUserId(projectId, currentUserId,imitation,queryType); + return JsonResponse.newInstance().ok(roleInfoList); + } } diff --git a/util/src/main/java/com/ccsens/util/CodeEnum.java b/util/src/main/java/com/ccsens/util/CodeEnum.java index 9654a48c..ba1a6827 100644 --- a/util/src/main/java/com/ccsens/util/CodeEnum.java +++ b/util/src/main/java/com/ccsens/util/CodeEnum.java @@ -34,6 +34,7 @@ public enum CodeEnum { WBS_NOT_PHONE(19,"手机号为空",true), WBS_PHONE_ERROR(19,"手机号格式错误",true), WBS_STAKEHOLDER_PHONE(20,"奖惩干系人和手机号不匹配",true), + WBS_STAKEHOLDER_PHONE_NOT_FOUND(20,"请填写奖惩干系人手机号",true), WBS_REPEAT_MEMBER_PHONE(21,"成员名或手机号与其他人重复",true), WBS_NOT_FIRST_ROLE(22,"系统角色名称错误",true), WBS_REPEAT_ROLE_NAME(23,"角色名称重复",true), @@ -207,6 +208,7 @@ public enum CodeEnum { WBS_TASK_START_TIME_ERROR(168,"任务开始时间格式错误,请检查后操作",true), WBS_TASK_END_TIME_ERROR(169,"任务结束时间格式错误,请检查后操作",true), CANNOT_DELETE_PM(170,"无法删除项目经理",true), + LABEL_TOO_LONG(170,"标签长度过长,请不要超过六个字",true), ; diff --git a/util/src/main/java/com/ccsens/util/WebConstant.java b/util/src/main/java/com/ccsens/util/WebConstant.java index d3bf817c..fc45fc14 100644 --- a/util/src/main/java/com/ccsens/util/WebConstant.java +++ b/util/src/main/java/com/ccsens/util/WebConstant.java @@ -22,6 +22,9 @@ public class WebConstant { // public static final String REGEX_PHONE = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,1-9]))\\d{8}$"; public static final String REGEX_PHONE = "^[1]([3-9])[0-9]{9}$"; + /* 导入WBS ,规定标签长度 */ + public static final Integer LABEL_LENGTH = 6; + /**属性名*/ public static class Field{ public static final String CODE = "code";