|
@@ -255,6 +255,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
|
|
|
//分页获取项目列表
|
|
|
@Override
|
|
|
+ @Transactional(readOnly = true)
|
|
|
public HttpRespMsg getProjectPage(Integer pageIndex, Integer pageSize, String keyword, Integer searchField,
|
|
|
Integer status, Integer category, Integer projectId,Integer projectMainId,Integer deptId, String sortProp, Integer sortOrder,String inchagerId,String participation,String startDate,String endDate, HttpServletRequest request) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
@@ -262,7 +263,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
//通过公司id获取该公司所有的项目列表
|
|
|
User user = userMapper.selectById(request.getHeader("Token"));
|
|
|
Integer companyId = user.getCompanyId();
|
|
|
- List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全部项目");
|
|
|
+ boolean canViewAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部项目");
|
|
|
//判断用户的角色,如果是管理员和负责人,查看全部的。如果是普通员工,只能是看到参与的项目
|
|
|
QueryWrapper<Project> queryWrapper = null;
|
|
|
List<Department> allDepartmentList=departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id",companyId));
|
|
@@ -278,7 +279,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
//本人所在部门
|
|
|
deptIds.add(user.getDepartmentId());
|
|
|
- if (functionList.size() == 0) {
|
|
|
+ if (!canViewAll) {
|
|
|
//普通员工
|
|
|
List<Participation> pList = participationMapper.selectList(new QueryWrapper<Participation>().eq("user_id", user.getId()));
|
|
|
List<Integer> projectIds = new ArrayList<>();
|
|
@@ -351,6 +352,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
}
|
|
|
IPage<Project> projectIPage;
|
|
|
+ LocalDateTime d1 = LocalDateTime.now();
|
|
|
if(pageIndex!=null && pageSize!=null){
|
|
|
projectIPage= projectMapper.selectPage(new Page<>(pageIndex, pageSize),
|
|
|
queryWrapper);
|
|
@@ -358,14 +360,19 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
projectIPage= projectMapper.selectPage(new Page<>(-1,-1),
|
|
|
queryWrapper);
|
|
|
}
|
|
|
- List<Project> projectList = projectIPage.getRecords();
|
|
|
- List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
|
|
|
+ LocalDateTime d2 = LocalDateTime.now();
|
|
|
+ Project[] projectList = projectIPage.getRecords().toArray(new Project[0]);
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().select("id, name, phone").eq("company_id", companyId));
|
|
|
List<ProviderInfo> providerInfoList = providerInfoMapper.selectList(new QueryWrapper<ProviderInfo>().eq("company_id", companyId));
|
|
|
List<ProviderCategory> providerCategoryList = providerCategoryMapper.selectList(new QueryWrapper<ProviderCategory>().eq("company_id", companyId));
|
|
|
List<ProjectMain> projectMainList = projectMainMapper.selectList(new QueryWrapper<ProjectMain>().eq("company_id", companyId));
|
|
|
List<ProjectLevel> projectLevelList = projectLevelMapper.selectList(new QueryWrapper<ProjectLevel>().eq("company_id", companyId));
|
|
|
TimeType timeType = timeTypeMapper.selectById(companyId);
|
|
|
- List<Integer> projectIds = projectList.stream().map(pl -> pl.getId()).distinct().collect(Collectors.toList());
|
|
|
+ List<Integer> projectIds = new ArrayList<>();
|
|
|
+ for (Project p : projectList) {
|
|
|
+ projectIds.add(p.getId());
|
|
|
+ }
|
|
|
+
|
|
|
List<ProjectSeparate> projectSeparateList=new ArrayList<>();
|
|
|
if(companyId==936){
|
|
|
if (projectIds.size() > 0) {
|
|
@@ -385,8 +392,24 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
if(projectIds.size()==0){
|
|
|
projectIds.add(-1);
|
|
|
}
|
|
|
- List<Map<String,Object>> particpationList=participationMapper.getAllParticipator(projectIds);
|
|
|
- List<Report> reportList = reportMapper.selectList(new QueryWrapper<Report>().in("project_id",projectIds).and(wrapper -> wrapper.eq("state", 0).or().eq("state", 1).or().eq("state", 3)));
|
|
|
+
|
|
|
+ List<ParticipationUser> particpationList;
|
|
|
+ if (canViewAll && pageIndex == null) {
|
|
|
+ particpationList = participationMapper.getAllParticipator(null, companyId);
|
|
|
+ } else {
|
|
|
+ particpationList = participationMapper.getAllParticipator(projectIds, companyId);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Report> reportList = new ArrayList<>();
|
|
|
+ //检测是否开启项目人天预估工时的功能
|
|
|
+ if (timeType.getProjectManDay() == 1) {
|
|
|
+ if (canViewAll && pageIndex == null) {
|
|
|
+ reportList = reportMapper.selectList(new QueryWrapper<Report>().select("id, create_date, project_id, working_time").eq("company_id",companyId).and(wrapper -> wrapper.eq("state", 0).or().eq("state", 1).or().eq("state", 3)));
|
|
|
+ } else {
|
|
|
+ reportList = reportMapper.selectList(new QueryWrapper<Report>().select("id, create_date, project_id, working_time").in("project_id",projectIds).and(wrapper -> wrapper.eq("state", 0).or().eq("state", 1).or().eq("state", 3)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("开始处理项目内数据");
|
|
|
for (Project project : projectList) {
|
|
|
//todo:计算项目预算工时
|
|
|
if(project.getManDay()!=null){
|
|
@@ -408,20 +431,34 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
project.setResidueEstimatedWorkTime(format1);
|
|
|
}
|
|
|
ProjectVO projectVO = new ProjectVO();
|
|
|
+
|
|
|
if(timeType.getProjectLevelState()==1){
|
|
|
Optional<ProjectLevel> first = projectLevelList.stream().filter(pl -> pl.getId().equals(project.getLevel())).findFirst();
|
|
|
if(first.isPresent()){
|
|
|
projectVO.setLevelName(first.get().getProjectLevelName());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
BeanUtils.copyProperties(project, projectVO);
|
|
|
+ long dt0 = System.currentTimeMillis();
|
|
|
Optional<Department> optional = allDepartmentList.stream().filter(ad -> ad.getDepartmentId().equals(projectVO.getDeptId())).findFirst();
|
|
|
if(optional.isPresent()){
|
|
|
projectVO.setDepartmentName(optional.get().getDepartmentName());
|
|
|
}
|
|
|
- /**/
|
|
|
- List<Map<String, Object>> maps = particpationList.stream().filter(pl ->Integer.valueOf(String.valueOf(pl.get("projectId"))).equals(project.getId())).collect(Collectors.toList());
|
|
|
- projectVO.setParticipator(maps);
|
|
|
+ /*此处性能很差, 需要优化*/
|
|
|
+// List<Map<String, Object>> maps = particpationList.stream().filter(pl ->Integer.valueOf(String.valueOf(pl.get("projectId"))).equals(project.getId())).collect(Collectors.toList());
|
|
|
+// List<ParticipationUser> maps = particpationList.stream().filter(pl ->pl.getProjectId().equals(project.getId())).collect(Collectors.toList());
|
|
|
+ List<ParticipationUser> thisProParticipator = new ArrayList<>();
|
|
|
+ for (int i=0;i<particpationList.size(); i++) {
|
|
|
+ ParticipationUser p = particpationList.get(i);
|
|
|
+ if (p.getProjectId().equals(project.getId())) {
|
|
|
+ thisProParticipator.add(p);
|
|
|
+ particpationList.remove(i);
|
|
|
+ i--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ projectVO.setParticipator(thisProParticipator);
|
|
|
+
|
|
|
Optional<User> first = userList.stream().filter(u -> u.getId().equals(project.getInchargerId())).findFirst();
|
|
|
if (first.isPresent()) {
|
|
|
User incharger = first.get();
|
|
@@ -487,8 +524,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
totalProgress = totalProgress/100/100;
|
|
|
projectVO.setProgress(totalProgress);
|
|
|
}
|
|
|
+
|
|
|
list.add(projectVO);
|
|
|
}
|
|
|
+ long end = System.currentTimeMillis();
|
|
|
List<String> stringList = providerCategoryList.stream().map(ProviderCategory::getProviderCategoryName).distinct().collect(Collectors.toList());
|
|
|
//stringList.add("未分类");
|
|
|
stringList.add(MessageUtils.message("excel.unclassified"));
|
|
@@ -5405,13 +5444,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
for (Department department : departmentList) {
|
|
|
department.setDepartmentName(getSupDepartment(department));
|
|
|
}
|
|
|
- String userId = null;
|
|
|
- List<SysRoleFunction> functionList = sysRoleFunctionMapper.getRoleFunctionNames(user.getRoleId());
|
|
|
- if(!functionList.stream().anyMatch(fun->fun.getFunctionName().equals("查看全部项目"))) {
|
|
|
- //无全部项目权限,只能导出自己相关的(创建或参与)
|
|
|
- userId = user.getId();
|
|
|
- }
|
|
|
+ LocalDateTime d1 = LocalDateTime.now();
|
|
|
HttpRespMsg projectPage = getProjectPage(null, null, keyword, searchField, status, category, projectId, projectMainId,deptId, null, null,inchagerId,participation,null,null, request);
|
|
|
+ LocalDateTime d2 = LocalDateTime.now();
|
|
|
+ System.out.println("查询项目耗时:" + Duration.between(d1, d2).toMillis());
|
|
|
List<ProjectKeyNodesSetting> projectKeyNodesSettingList = projectKeyNodesSettingMapper.selectList(new QueryWrapper<ProjectKeyNodesSetting>().eq("company_id", user.getCompanyId()));
|
|
|
Map<String,Object> resultMap= (Map<String, Object>) projectPage.data;
|
|
|
List<ProjectVO> projectVOList= (List<ProjectVO>) resultMap.get("records");
|
|
@@ -5421,7 +5457,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
List<ProjectCustom> projectCustomList = projectCustomMapper.selectList(new QueryWrapper<ProjectCustom>().eq("company_id", company.getId()));
|
|
|
List<ProjectCustom> customList = projectCustomList.stream().filter(pl -> pl.getCustomType() != 1).collect(Collectors.toList());
|
|
|
TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
|
|
|
- List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", company.getId()));
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().select("id, name, corpwx_userid").eq("company_id", company.getId()));
|
|
|
List<String> headList = new ArrayList<String>();
|
|
|
// headList.add("项目编号");
|
|
|
// headList.add("项目分类");
|
|
@@ -5548,20 +5584,20 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}else {
|
|
|
rowData.add(projectVO.getInchargerName());
|
|
|
}
|
|
|
- List<Map<String, Object>> participator = projectVO.getParticipator();
|
|
|
+ List<ParticipationUser> participator = projectVO.getParticipator();
|
|
|
String names="";
|
|
|
for (int i = 0; i < participator.size(); i++) {
|
|
|
if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
if(i==participator.size()-1){
|
|
|
- names+="$userName="+(participator.get(i).get("corpwxUserId"))+"$";
|
|
|
+ names+="$userName="+(participator.get(i).getCorpwxUserId())+"$";
|
|
|
}else {
|
|
|
- names+="$userName="+(participator.get(i).get("corpwxUserId"))+"$"+",";
|
|
|
+ names+="$userName="+(participator.get(i).getCorpwxUserId())+"$"+",";
|
|
|
}
|
|
|
}else {
|
|
|
if(i==participator.size()-1){
|
|
|
- names+=participator.get(i).get("name");
|
|
|
+ names+=participator.get(i).getName();
|
|
|
}else {
|
|
|
- names+=participator.get(i).get("name")+",";
|
|
|
+ names+=participator.get(i).getName()+",";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -5744,6 +5780,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
String token = request.getHeader("TOKEN");
|
|
|
User user = userMapper.selectById(token);
|
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
+ //获取全部用户
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().select("id, name, corpwx_userid").eq("company_id", user.getCompanyId()));
|
|
|
List<HashMap<String, Object>> list = projectMapper.getExportGroupData(user.getCompanyId());
|
|
|
List<List<String>> allList = new ArrayList<>();
|
|
|
List<String> headList = new ArrayList<String>();
|
|
@@ -5764,21 +5802,57 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
item.add((String) map.get("projectName")==null?"":(String)map.get("projectName"));
|
|
|
item.add((String) map.get("groupName")==null?"":(String)map.get("groupName"));
|
|
|
if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
- item.add((String) map.get("corpwxUserId")==null?"":("$userName="+(String)map.get("corpwxUserId")+"$"));
|
|
|
- if(map.get("participatorsCorp")!=null&&!map.get("participatorsCorp").equals("")){
|
|
|
- String participatorsCorp = (String) map.get("participatorsCorp");
|
|
|
- List<String> asList = Arrays.asList(participatorsCorp.split(","));
|
|
|
+ String inchargerId = (String)map.get("inchargerId");
|
|
|
+ if (inchargerId!=null&&!inchargerId.equals("")) {
|
|
|
+ Optional<User> incharger = userList.stream().filter(u -> u.getId().equals(inchargerId)).findFirst();
|
|
|
+ if(incharger.isPresent()){
|
|
|
+ item.add("$userName="+incharger.get().getCorpwxUserid()+"$");
|
|
|
+ }else {
|
|
|
+ item.add("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String participatorIds = (String)map.get("participatorIds");
|
|
|
+ if (participatorIds!=null&&!participatorIds.equals("")) {
|
|
|
+ List<String> asList = Arrays.asList(participatorIds.split(","));
|
|
|
List<String> thisList=new ArrayList<>();
|
|
|
asList.forEach(al->{
|
|
|
- thisList.add("$userName="+al+"$");
|
|
|
+ Optional<User> participator = userList.stream().filter(u -> u.getId().equals(al)).findFirst();
|
|
|
+ if(participator.isPresent()){
|
|
|
+ thisList.add("$userName="+participator.get().getCorpwxUserid()+"$");
|
|
|
+ }
|
|
|
});
|
|
|
item.add(thisList.toString().replaceAll("\\[","").replaceAll("]",""));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
item.add("");
|
|
|
}
|
|
|
}else {
|
|
|
- item.add((String) map.get("inchargerName")==null?"":(String)map.get("inchargerName"));
|
|
|
- item.add((String) map.get("participators")==null?"":(String)map.get("participators"));
|
|
|
+ String inchargerId = (String)map.get("inchargerId");
|
|
|
+ if (inchargerId!=null&&!inchargerId.equals("")) {
|
|
|
+ Optional<User> incharger = userList.stream().filter(u -> u.getId().equals(inchargerId)).findFirst();
|
|
|
+ if (incharger.isPresent()) {
|
|
|
+ User user1 = incharger.get();
|
|
|
+ item.add(user1.getName());
|
|
|
+ } else {
|
|
|
+ item.add("");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ item.add("");
|
|
|
+ }
|
|
|
+ String participatorIds = (String)map.get("participatorIds");
|
|
|
+ if (participatorIds!=null&&!participatorIds.equals("")) {
|
|
|
+ List<String> asList = Arrays.asList(participatorIds.split(","));
|
|
|
+ List<String> thisList=new ArrayList<>();
|
|
|
+ asList.forEach(al->{
|
|
|
+ Optional<User> participator = userList.stream().filter(u -> u.getId().equals(al)).findFirst();
|
|
|
+ if (participator.isPresent()) {
|
|
|
+ User user1 = participator.get();
|
|
|
+ thisList.add(user1.getName());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ item.add(thisList.stream().collect(Collectors.joining(",")));
|
|
|
+ }else {
|
|
|
+ item.add("");
|
|
|
+ }
|
|
|
}
|
|
|
allList.add(item);
|
|
|
}
|