|
@@ -64,6 +64,7 @@ import java.util.*;
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
import java.util.concurrent.Executor;
|
|
|
import java.util.concurrent.Executors;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
@@ -130,6 +131,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
@Resource
|
|
|
ProjectBasecostMapper projectBasecostMapper;
|
|
|
@Resource
|
|
|
+ CategoryRatioTblSettingMapper categoryRatioTblSettingMapper;
|
|
|
+ @Resource
|
|
|
CompanyMapper companyMapper;
|
|
|
@Resource
|
|
|
StagesMapper stagesMapper;
|
|
@@ -240,6 +243,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
|
|
|
@Value(value = "${upload.path}")
|
|
|
private String path;
|
|
|
+ @Value("${configEnv.isDev}")
|
|
|
+ public boolean isDev;
|
|
|
//获取项目列表
|
|
|
@Override
|
|
|
public HttpRespMsg getProjectList(Integer forReport, HttpServletRequest request) {
|
|
@@ -773,7 +778,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
if(timeType.getProjectManDay()==1){
|
|
|
project.setManDay(manDay);
|
|
|
- if (!StringUtils.isEmpty(planEndDate)) {
|
|
|
+ if (!StringUtils.isEmpty(manDayStartDate)) {
|
|
|
project.setManDayStartDate(LocalDate.parse(manDayStartDate));
|
|
|
}
|
|
|
}
|
|
@@ -1433,7 +1438,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
String[] split = userIds.split(",");
|
|
|
userIdList = Arrays.asList(split);
|
|
|
}
|
|
|
- List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, projectId, userIdList,deptIds,null, deptRelatedProjectIds, projectIds, inchargeUserIds);
|
|
|
+ List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, projectId, userIdList,deptIds,null, deptRelatedProjectIds, projectIds, inchargeUserIds,null);
|
|
|
BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
|
|
|
for (Map<String, Object> map : list) {
|
|
|
if (!map.containsKey("cost")) {
|
|
@@ -1475,14 +1480,152 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
|
+ private HashMap fillMainProjectRowData(Integer projectMainId, Integer companyId, String startDate, String endDate, Integer stateKey, List<String> userIdList, List<Map<String, Object>> list,
|
|
|
+ List<UserCustom> userCustoms, List<SysRichFunction> functionTimeList, List<SysRichFunction> functionCostList,
|
|
|
+ String exportContent, List<User> userList, List<Integer> deptIds, List<Integer> deptRelatedProjectIds,
|
|
|
+ List<Integer> filterDeptIds, Boolean projectSum, WxCorpInfo wxCorpInfo) {
|
|
|
+ List<List<String>> allList = new ArrayList<List<String>>();
|
|
|
+ BigDecimal totalMoneyCost = new BigDecimal(0);
|
|
|
+ double totalCostTime = 0;
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
+ //只查找和当前主项目相关的项目
|
|
|
+ Integer pmid = (Integer)map.get("projectMainId");
|
|
|
+ if (projectMainId == null) {
|
|
|
+ if (pmid != null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (pmid == null || !pmid.equals(projectMainId)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!map.containsKey("cost")) {
|
|
|
+ map.put("cost", 0);
|
|
|
+ }
|
|
|
+ if (!map.containsKey("costMoney")) {
|
|
|
+ map.put("costMoney", 0);
|
|
|
+ } else {
|
|
|
+ totalMoneyCost = totalMoneyCost.add((BigDecimal)map.get("costMoney"));
|
|
|
+ }
|
|
|
+ totalCostTime += (Double)map.get("cost");
|
|
|
+ List<String> rowData = new ArrayList<String>();
|
|
|
+ //空出两类主项目编号和名称
|
|
|
+ rowData.add("");
|
|
|
+ rowData.add("");
|
|
|
+ rowData.add((String)map.get("projectCode"));
|
|
|
+ rowData.add((String)map.get("project"));
|
|
|
+ rowData.add((String)map.get("categoryName"));
|
|
|
+ rowData.add("");
|
|
|
+ rowData.add("");
|
|
|
+ //针对项目合计行,自定义的字段要空出来
|
|
|
+ for (UserCustom userCustom : userCustoms) {
|
|
|
+ rowData.add("");
|
|
|
+ }
|
|
|
+ if ("hours".equals(exportContent) && functionTimeList.size()>0){
|
|
|
+ rowData.add(((Double)map.get("cost")).toString());
|
|
|
+ }else if ("cost".equals(exportContent) && functionCostList.size()>0){
|
|
|
+ rowData.add(((BigDecimal)map.get("costMoney")).toString());
|
|
|
+ }else {
|
|
|
+ if(functionTimeList.size()>0){
|
|
|
+ rowData.add(((Double)map.get("cost")).toString());
|
|
|
+ }
|
|
|
+ if (functionCostList.size()>0){
|
|
|
+ rowData.add(((BigDecimal)map.get("costMoney")).toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (projectSum != null && projectSum == true) {
|
|
|
+ allList.add(rowData);
|
|
|
+ }
|
|
|
+ //统计每个项目中的人员时间成本投入
|
|
|
+ int curProjectId = (Integer)map.get("id");
|
|
|
+ //判断是否是当前项目的所属部门的主要或者其他负责人
|
|
|
+ List<Integer> finalDeptIds = null;
|
|
|
+ if (deptRelatedProjectIds.contains(curProjectId)) {
|
|
|
+ //有权限看该项目的全部参与人员,不需要按照部门过滤了
|
|
|
+ } else {
|
|
|
+ finalDeptIds = deptIds;
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> membList = projectMapper.getProjectCost(companyId,startDate, endDate, curProjectId,stateKey, userIdList,finalDeptIds,filterDeptIds, true);
|
|
|
+ map.put("membList", membList);
|
|
|
+ for (Map<String, Object> membMap : membList) {
|
|
|
+ double pTotalTime = 0;
|
|
|
+ BigDecimal pTotalMoney = new BigDecimal(0);
|
|
|
+ List<String> membRowData = new ArrayList<String>();
|
|
|
+ if (projectSum == null || projectSum == false) {
|
|
|
+ membRowData.add("");
|
|
|
+ membRowData.add("");
|
|
|
+ membRowData.add((String)map.get("projectCode"));
|
|
|
+ membRowData.add((String)map.get("project"));
|
|
|
+ membRowData.add((String)map.get("categoryName"));
|
|
|
+ } else {
|
|
|
+ membRowData.add("");
|
|
|
+ membRowData.add("");
|
|
|
+ membRowData.add("");
|
|
|
+ membRowData.add("");
|
|
|
+ membRowData.add("");
|
|
|
+ }
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ membRowData.add((String)("$userName="+membMap.get("corpwxUserId")+"$"));
|
|
|
+ if(membMap.get("departmentName").equals("未分配")){
|
|
|
+ membRowData.add("未分配");
|
|
|
+ }else {
|
|
|
+ membRowData.add((String)("$departmentName="+membMap.get("corpwxDeptId")+"$"));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ membRowData.add((String)membMap.get("name"));
|
|
|
+ membRowData.add((String)membMap.get("departmentName"));
|
|
|
+ }
|
|
|
+ String creatorId = (String)membMap.get("creatorId");
|
|
|
+ User us = userList.stream().filter(u->u.getId().equals(creatorId)).findFirst().get();
|
|
|
+ for (int i = 0; i < userCustoms.size(); i++) {
|
|
|
+ switch (i){
|
|
|
+ case 0:
|
|
|
+ membRowData.add(us.getPlate1()==null?"":us.getPlate1());
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ membRowData.add(us.getPlate2()==null?"":us.getPlate2());
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ membRowData.add(us.getPlate3()==null?"":us.getPlate3());
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ membRowData.add(us.getPlate4()==null?"":us.getPlate4());
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ membRowData.add(us.getPlate5()==null?"":us.getPlate5());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("hours".equals(exportContent) && functionTimeList.size()>0){
|
|
|
+ membRowData.add(((Double)membMap.get("cost")).toString());
|
|
|
+ }else if ("cost".equals(exportContent) && functionCostList.size()>0){
|
|
|
+ membRowData.add(((BigDecimal)membMap.get("costMoney")).toString());
|
|
|
+ }else {
|
|
|
+ if(functionTimeList.size()>0){
|
|
|
+ membRowData.add(((Double)membMap.get("cost")).toString());
|
|
|
+ }
|
|
|
+ if (functionCostList.size()>0){
|
|
|
+ membRowData.add(((BigDecimal)membMap.get("costMoney")).toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ allList.add(membRowData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ HashMap map = new HashMap();
|
|
|
+ map.put("totalMoneyCost", totalMoneyCost);
|
|
|
+ map.put("totalCostTime", totalCostTime);
|
|
|
+ map.put("allList", allList);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
//导出查询者所在公司每个项目的工时成本,包括项目人员明细统计
|
|
|
@Override
|
|
|
- public HttpRespMsg exportTimeCost(String exportContent,String startDate, String endDate,Integer projectId, String userIds,
|
|
|
- Boolean projectSum,Integer type,Integer deptId, Integer stateKey, Integer withPercent, HttpServletRequest request) {
|
|
|
+ public HttpRespMsg exportTimeCost(Integer withMainProject, String exportContent,String startDate, String endDate,Integer projectId, String userIds,
|
|
|
+ Boolean projectSum,Integer type,Integer deptId, Integer stateKey, Integer withPercent,Integer projectCategoryId, HttpServletRequest request) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
try {
|
|
|
User targetUser = userMapper.selectById(request.getHeader("Token"));
|
|
|
- Integer companyId =targetUser.getCompanyId();
|
|
|
+ Integer companyId = targetUser.getCompanyId();
|
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
//当前用户管理部门
|
|
@@ -1557,13 +1700,29 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
String[] split = userIds.split(",");
|
|
|
userIdList = Arrays.asList(split);
|
|
|
}
|
|
|
- List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, projectId, userIdList,deptIds,filterDeptIds,deptRelatedProjectIds, manProjectIds, inchargeUserIds);
|
|
|
+ List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, projectId, userIdList,deptIds,filterDeptIds,deptRelatedProjectIds, manProjectIds, inchargeUserIds,projectCategoryId);
|
|
|
BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
|
|
|
List<List<String>> allList=null ;
|
|
|
List<String> sumRow = null;
|
|
|
List<UserCustom> userCustoms = userCustomMapper.selectList(new QueryWrapper<UserCustom>().eq("company_id", companyId));
|
|
|
- if(type==0){
|
|
|
+ //按主项目导出时,项目固定在行上
|
|
|
+ if(type==0 || withMainProject == 1){
|
|
|
+ //取主项目
|
|
|
+ List<Integer> mainPidList = list.stream().map(m -> (Integer)m.get("projectMainId")).distinct().collect(Collectors.toList());
|
|
|
+ //查找有没有未分类的
|
|
|
+ boolean hasNoMainProject = list.stream().anyMatch(m -> m.get("projectMainId") == null);
|
|
|
+ List<ProjectMain> mainProjectList = new ArrayList<>();
|
|
|
+ if (mainPidList.size() > 0) {
|
|
|
+ mainProjectList = projectMainMapper.selectList(new QueryWrapper<ProjectMain>().in("id", mainPidList));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
List<String> headList = new ArrayList<String>();
|
|
|
+ if (withMainProject == 1) {
|
|
|
+ //增加主项目合计的一行
|
|
|
+ headList.add("主项目编号");
|
|
|
+ headList.add("主项目名称");
|
|
|
+ }
|
|
|
//headList.add("项目编号");
|
|
|
headList.add(MessageUtils.message("entry.projectId"));
|
|
|
//headList.add("项目名称");
|
|
@@ -1598,119 +1757,165 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
allList=new ArrayList<>();
|
|
|
allList.add(headList);
|
|
|
double totalCostTime = 0;
|
|
|
- for (Map<String, Object> map : list) {
|
|
|
- if (!map.containsKey("cost")) {
|
|
|
- map.put("cost", 0);
|
|
|
- }
|
|
|
- if (!map.containsKey("costMoney")) {
|
|
|
- map.put("costMoney", 0);
|
|
|
- } else {
|
|
|
- totalMoneyCost = totalMoneyCost.add((BigDecimal)map.get("costMoney"));
|
|
|
- }
|
|
|
- totalCostTime += (Double)map.get("cost");
|
|
|
- List<String> rowData = new ArrayList<String>();
|
|
|
- rowData.add((String)map.get("projectCode"));
|
|
|
- rowData.add((String)map.get("project"));
|
|
|
- rowData.add((String)map.get("categoryName"));
|
|
|
- rowData.add("");
|
|
|
- rowData.add("");
|
|
|
- //针对项目合计行,自定义的字段要空出来
|
|
|
- for (UserCustom userCustom : userCustoms) {
|
|
|
- rowData.add("");
|
|
|
- }
|
|
|
- if ("hours".equals(exportContent) && functionTimeList.size()>0){
|
|
|
- rowData.add(((Double)map.get("cost")).toString());
|
|
|
- }else if ("cost".equals(exportContent) && functionCostList.size()>0){
|
|
|
- rowData.add(((BigDecimal)map.get("costMoney")).toString());
|
|
|
- }else {
|
|
|
+ if (withMainProject == 1) {
|
|
|
+ //主项目模式下的导出数据
|
|
|
+ //存在无主项目的数据,放在最后
|
|
|
+ if (hasNoMainProject) {
|
|
|
+ ProjectMain noMainProject = new ProjectMain();
|
|
|
+ noMainProject.setName("无主项目");
|
|
|
+ mainProjectList.add(noMainProject);
|
|
|
+ }
|
|
|
+ for (ProjectMain mainP : mainProjectList) {
|
|
|
+ HashMap sumData = fillMainProjectRowData(mainP.getId(), companyId, startDate, endDate, stateKey, userIdList, list, userCustoms, functionTimeList, functionCostList, exportContent, userList, deptIds, deptRelatedProjectIds, filterDeptIds, projectSum, wxCorpInfo);
|
|
|
+ totalMoneyCost = totalMoneyCost.add((BigDecimal)sumData.get("totalMoneyCost"));
|
|
|
+ totalCostTime += (double)sumData.get("totalCostTime");
|
|
|
+ //增加主项目合计的一行
|
|
|
+ List<String> mainProjectRowData = new ArrayList<String>();
|
|
|
+ mainProjectRowData.add(mainP.getCode());
|
|
|
+ mainProjectRowData.add(mainP.getName());
|
|
|
+ mainProjectRowData.add("");//项目编号
|
|
|
+ mainProjectRowData.add("");//项目名称
|
|
|
+ mainProjectRowData.add("");//项目分类
|
|
|
+ mainProjectRowData.add("");//姓名
|
|
|
+ mainProjectRowData.add("");//部门
|
|
|
+ //针对项目合计行,自定义的字段要空出来
|
|
|
+ for (UserCustom userCustom : userCustoms) {
|
|
|
+ mainProjectRowData.add("");
|
|
|
+ }
|
|
|
+
|
|
|
if(functionTimeList.size()>0){
|
|
|
- rowData.add(((Double)map.get("cost")).toString());
|
|
|
+ mainProjectRowData.add(((Double)sumData.get("totalCostTime")).toString());
|
|
|
}
|
|
|
if (functionCostList.size()>0){
|
|
|
- rowData.add(((BigDecimal)map.get("costMoney")).toString());
|
|
|
+ mainProjectRowData.add(((BigDecimal)sumData.get("totalMoneyCost")).toString());
|
|
|
}
|
|
|
+ allList.add(mainProjectRowData);
|
|
|
+ //增加主项目下的项目列表
|
|
|
+ allList.addAll((List<List<String>>)sumData.get("allList"));
|
|
|
}
|
|
|
- if (projectSum != null && projectSum == true) {
|
|
|
- allList.add(rowData);
|
|
|
- }
|
|
|
- //统计每个项目中的人员时间成本投入
|
|
|
- int curProjectId = (Integer)map.get("id");
|
|
|
- //判断是否是当前项目的所属部门的主要或者其他负责人
|
|
|
- List<Integer> finalDeptIds = null;
|
|
|
- if (deptRelatedProjectIds.contains(curProjectId)) {
|
|
|
- //有权限看该项目的全部参与人员,不需要按照部门过滤了
|
|
|
- } else {
|
|
|
- finalDeptIds = deptIds;
|
|
|
- }
|
|
|
- List<Map<String, Object>> membList = projectMapper.getProjectCost(companyId,startDate, endDate, curProjectId,stateKey, userIdList,finalDeptIds,filterDeptIds, true);
|
|
|
- map.put("membList", membList);
|
|
|
- for (Map<String, Object> membMap : membList) {
|
|
|
- double pTotalTime = 0;
|
|
|
- BigDecimal pTotalMoney = new BigDecimal(0);
|
|
|
- List<String> membRowData = new ArrayList<String>();
|
|
|
- if (projectSum == null || projectSum == false) {
|
|
|
- membRowData.add((String)map.get("projectCode"));
|
|
|
- membRowData.add((String)map.get("project"));
|
|
|
- membRowData.add((String)map.get("categoryName"));
|
|
|
-
|
|
|
+ } else {
|
|
|
+ //常规项目的工时导出
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
+ if (!map.containsKey("cost")) {
|
|
|
+ map.put("cost", 0);
|
|
|
+ }
|
|
|
+ if (!map.containsKey("costMoney")) {
|
|
|
+ map.put("costMoney", 0);
|
|
|
} else {
|
|
|
- membRowData.add("");
|
|
|
- membRowData.add("");
|
|
|
- membRowData.add("");
|
|
|
-
|
|
|
+ totalMoneyCost = totalMoneyCost.add((BigDecimal)map.get("costMoney"));
|
|
|
}
|
|
|
- if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
- membRowData.add((String)("$userName="+membMap.get("corpwxUserId")+"$"));
|
|
|
- if(membMap.get("departmentName").equals("未分配")){
|
|
|
- membRowData.add("未分配");
|
|
|
- }else {
|
|
|
- membRowData.add((String)("$departmentName="+membMap.get("corpwxDeptId")+"$"));
|
|
|
- }
|
|
|
- }else {
|
|
|
- membRowData.add((String)membMap.get("name"));
|
|
|
- membRowData.add((String)membMap.get("departmentName"));
|
|
|
- }
|
|
|
- String creatorId = (String)membMap.get("creatorId");
|
|
|
- User us = userList.stream().filter(u->u.getId().equals(creatorId)).findFirst().get();
|
|
|
- for (int i = 0; i < userCustoms.size(); i++) {
|
|
|
- switch (i){
|
|
|
- case 0:
|
|
|
- membRowData.add(us.getPlate1()==null?"":us.getPlate1());
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- membRowData.add(us.getPlate2()==null?"":us.getPlate2());
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- membRowData.add(us.getPlate3()==null?"":us.getPlate3());
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- membRowData.add(us.getPlate4()==null?"":us.getPlate4());
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- membRowData.add(us.getPlate5()==null?"":us.getPlate5());
|
|
|
- break;
|
|
|
- }
|
|
|
+ totalCostTime += (Double)map.get("cost");
|
|
|
+ List<String> rowData = new ArrayList<String>();
|
|
|
+ rowData.add((String)map.get("projectCode"));
|
|
|
+ rowData.add((String)map.get("project"));
|
|
|
+ rowData.add((String)map.get("categoryName"));
|
|
|
+ rowData.add("");
|
|
|
+ rowData.add("");
|
|
|
+ //针对项目合计行,自定义的字段要空出来
|
|
|
+ for (UserCustom userCustom : userCustoms) {
|
|
|
+ rowData.add("");
|
|
|
}
|
|
|
if ("hours".equals(exportContent) && functionTimeList.size()>0){
|
|
|
- membRowData.add(((Double)membMap.get("cost")).toString());
|
|
|
+ rowData.add(((Double)map.get("cost")).toString());
|
|
|
}else if ("cost".equals(exportContent) && functionCostList.size()>0){
|
|
|
- membRowData.add(((BigDecimal)membMap.get("costMoney")).toString());
|
|
|
+ rowData.add(((BigDecimal)map.get("costMoney")).toString());
|
|
|
}else {
|
|
|
if(functionTimeList.size()>0){
|
|
|
- membRowData.add(((Double)membMap.get("cost")).toString());
|
|
|
+ rowData.add(((Double)map.get("cost")).toString());
|
|
|
}
|
|
|
if (functionCostList.size()>0){
|
|
|
- membRowData.add(((BigDecimal)membMap.get("costMoney")).toString());
|
|
|
+ rowData.add(((BigDecimal)map.get("costMoney")).toString());
|
|
|
}
|
|
|
}
|
|
|
+ if (projectSum != null && projectSum == true) {
|
|
|
+ allList.add(rowData);
|
|
|
+ }
|
|
|
+ //统计每个项目中的人员时间成本投入
|
|
|
+ int curProjectId = (Integer)map.get("id");
|
|
|
+ //判断是否是当前项目的所属部门的主要或者其他负责人
|
|
|
+ List<Integer> finalDeptIds = null;
|
|
|
+ if (deptRelatedProjectIds.contains(curProjectId)) {
|
|
|
+ //有权限看该项目的全部参与人员,不需要按照部门过滤了
|
|
|
+ } else {
|
|
|
+ finalDeptIds = deptIds;
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> membList = projectMapper.getProjectCost(companyId,startDate, endDate, curProjectId,stateKey, userIdList,finalDeptIds,filterDeptIds, true);
|
|
|
+ map.put("membList", membList);
|
|
|
+ for (Map<String, Object> membMap : membList) {
|
|
|
+ double pTotalTime = 0;
|
|
|
+ BigDecimal pTotalMoney = new BigDecimal(0);
|
|
|
+ List<String> membRowData = new ArrayList<String>();
|
|
|
+ if (projectSum == null || projectSum == false) {
|
|
|
+ membRowData.add((String)map.get("projectCode"));
|
|
|
+ membRowData.add((String)map.get("project"));
|
|
|
+ membRowData.add((String)map.get("categoryName"));
|
|
|
|
|
|
- allList.add(membRowData);
|
|
|
+ } else {
|
|
|
+ membRowData.add("");
|
|
|
+ membRowData.add("");
|
|
|
+ membRowData.add("");
|
|
|
+
|
|
|
+ }
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ membRowData.add((String)("$userName="+membMap.get("corpwxUserId")+"$"));
|
|
|
+ if(membMap.get("departmentName").equals("未分配")){
|
|
|
+ membRowData.add("未分配");
|
|
|
+ }else {
|
|
|
+ membRowData.add((String)("$departmentName="+membMap.get("corpwxDeptId")+"$"));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ membRowData.add((String)membMap.get("name"));
|
|
|
+ membRowData.add((String)membMap.get("departmentName"));
|
|
|
+ }
|
|
|
+ String creatorId = (String)membMap.get("creatorId");
|
|
|
+ User us = userList.stream().filter(u->u.getId().equals(creatorId)).findFirst().get();
|
|
|
+ for (int i = 0; i < userCustoms.size(); i++) {
|
|
|
+ switch (i){
|
|
|
+ case 0:
|
|
|
+ membRowData.add(us.getPlate1()==null?"":us.getPlate1());
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ membRowData.add(us.getPlate2()==null?"":us.getPlate2());
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ membRowData.add(us.getPlate3()==null?"":us.getPlate3());
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ membRowData.add(us.getPlate4()==null?"":us.getPlate4());
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ membRowData.add(us.getPlate5()==null?"":us.getPlate5());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("hours".equals(exportContent) && functionTimeList.size()>0){
|
|
|
+ membRowData.add(((Double)membMap.get("cost")).toString());
|
|
|
+ }else if ("cost".equals(exportContent) && functionCostList.size()>0){
|
|
|
+ membRowData.add(((BigDecimal)membMap.get("costMoney")).toString());
|
|
|
+ }else {
|
|
|
+ if(functionTimeList.size()>0){
|
|
|
+ membRowData.add(((Double)membMap.get("cost")).toString());
|
|
|
+ }
|
|
|
+ if (functionCostList.size()>0){
|
|
|
+ membRowData.add(((BigDecimal)membMap.get("costMoney")).toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ allList.add(membRowData);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
//合计
|
|
|
sumRow=new ArrayList<>();
|
|
|
//sumRow.add("合计");
|
|
|
sumRow.add(MessageUtils.message("entry.total"));
|
|
|
+ if (withMainProject == 1) {
|
|
|
+ //多两列
|
|
|
+ sumRow.add("");
|
|
|
+ sumRow.add("");
|
|
|
+ }
|
|
|
sumRow.add("");
|
|
|
sumRow.add("");
|
|
|
sumRow.add("");
|
|
@@ -1891,7 +2096,13 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
//生成excel文件导出
|
|
|
//String fileName = "项目成本工时统计_"+System.currentTimeMillis();
|
|
|
- String fileName = MessageUtils.message("fileName.projectCost")+System.currentTimeMillis();
|
|
|
+ String fileName = null;
|
|
|
+ if (withMainProject == 1) {
|
|
|
+ fileName = "主项目成本工时统计"+System.currentTimeMillis();
|
|
|
+ } else {
|
|
|
+ fileName = MessageUtils.message("fileName.projectCost")+System.currentTimeMillis();
|
|
|
+ }
|
|
|
+
|
|
|
return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,fileName , allList, path);
|
|
|
} catch (NullPointerException e) {
|
|
|
e.printStackTrace();
|
|
@@ -2488,7 +2699,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg getProjectTask(Integer pageIndex, Integer pageSize, Integer projectId, HttpServletRequest request,Integer taskType) {
|
|
|
+ public HttpRespMsg getProjectTask(Integer pageIndex, Integer pageSize, Integer projectId,Integer groupId, HttpServletRequest request,Integer taskType) {
|
|
|
User user = userMapper.selectById(request.getHeader("Token"));
|
|
|
Integer companyId = user.getCompanyId();
|
|
|
int pageStart = (pageIndex -1) * pageSize;
|
|
@@ -2509,8 +2720,25 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
inchagerIds.add(-1);
|
|
|
}
|
|
|
}
|
|
|
- int total = taskMapper.getProjectTaskCount(companyId, projectId,taskType,inchagerIds);
|
|
|
- List projectTask = taskMapper.getProjectTask(companyId, pageStart, pageSize, projectId,taskType,inchagerIds);
|
|
|
+ int total = taskMapper.getProjectTaskCount(companyId, projectId,groupId,taskType,inchagerIds);
|
|
|
+ List<Map<String,Object>> projectTask = taskMapper.getProjectTask(companyId, pageStart, pageSize, projectId,groupId,taskType,inchagerIds);
|
|
|
+ if(companyId==3092){
|
|
|
+ List<Integer> groupIds = projectTask.stream().map(p -> Integer.valueOf(String.valueOf(p.get("groupId")))).distinct().collect(Collectors.toList());
|
|
|
+ groupIds.add(-1);
|
|
|
+ List<Report> reportList = reportMapper.selectList(new LambdaQueryWrapper<Report>().select(Report::getGroupId, Report::getWorkingTime).in(Report::getGroupId, groupIds));
|
|
|
+ List<TaskGroup> taskGroupList = taskGroupMapper.selectList(new LambdaQueryWrapper<TaskGroup>().in(TaskGroup::getId, groupIds));
|
|
|
+ for (Map<String, Object> p : projectTask) {
|
|
|
+ Optional<TaskGroup> group = taskGroupList.stream().filter(t -> t.getId().equals(Integer.valueOf(String.valueOf(p.get("groupId"))))).findFirst();
|
|
|
+ p.put("group_plan_hours",0);
|
|
|
+ if(group.isPresent()){
|
|
|
+ p.put("group_plan_hours",0);
|
|
|
+ }
|
|
|
+ List<Report> reports = reportList.stream().filter(r -> r.getGroupId().equals(Integer.valueOf(String.valueOf(p.get("groupId"))))).collect(Collectors.toList());
|
|
|
+ BigDecimal reduce = reports.stream().map(r -> new BigDecimal(r.getWorkingTime())).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ reduce = reduce.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ p.put("group_real_hours",reduce.doubleValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("records", projectTask);
|
|
@@ -2546,7 +2774,24 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
inchagerIds.add(-1);
|
|
|
}
|
|
|
}
|
|
|
- List<Map> projectList = taskMapper.getProjectTask(companyId, null, null, null,taskType,inchagerIds);
|
|
|
+ List<Map<String,Object>> projectList = taskMapper.getProjectTask(companyId, null, null, null,null,taskType,inchagerIds);
|
|
|
+ if(companyId==3092){
|
|
|
+ List<Integer> groupIds = projectList.stream().map(p -> Integer.valueOf(String.valueOf(p.get("groupId")))).distinct().collect(Collectors.toList());
|
|
|
+ groupIds.add(-1);
|
|
|
+ List<Report> reportList = reportMapper.selectList(new LambdaQueryWrapper<Report>().select(Report::getGroupId, Report::getWorkingTime).in(Report::getGroupId, groupIds));
|
|
|
+ List<TaskGroup> taskGroupList = taskGroupMapper.selectList(new LambdaQueryWrapper<TaskGroup>().in(TaskGroup::getId, groupIds));
|
|
|
+ for (Map<String, Object> p : projectList) {
|
|
|
+ Optional<TaskGroup> group = taskGroupList.stream().filter(t -> t.getId().equals(Integer.valueOf(String.valueOf(p.get("groupId"))))).findFirst();
|
|
|
+ p.put("group_plan_hours",0);
|
|
|
+ if(group.isPresent()){
|
|
|
+ p.put("group_plan_hours",0);
|
|
|
+ }
|
|
|
+ List<Report> reports = reportList.stream().filter(r -> r.getGroupId().equals(Integer.valueOf(String.valueOf(p.get("groupId"))))).collect(Collectors.toList());
|
|
|
+ BigDecimal reduce = reports.stream().map(r -> new BigDecimal(r.getWorkingTime())).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ reduce = reduce.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ p.put("group_real_hours",reduce.doubleValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
List<ProjectVO> list = new ArrayList<>();
|
|
|
//String[] statusNames = {"进行中","已完成","已撤销"};
|
|
|
String[] statusNames = {MessageUtils.message("excel.onGoing"),MessageUtils.message("excel.complete"),MessageUtils.message("excel.revoke")};
|
|
@@ -2555,11 +2800,19 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
List<List<String>> exportList = new ArrayList<>();
|
|
|
//String[] titles = {"项目编号", "项目名称", "任务名称", "执行人","计划工时(h)", "实际工时(h)","状态", "类型", "截止日期"};
|
|
|
String[] titles = {MessageUtils.message("entry.projectId"), MessageUtils.message("entry.projectName"), MessageUtils.message("entry.taskName"), MessageUtils.message("excel.executor"),MessageUtils.message("excel.plannedWork"), MessageUtils.message("excel.actualWork"),MessageUtils.message("leave.status"), MessageUtils.message("excel.type"), MessageUtils.message("entry.endDate")};
|
|
|
+ if(companyId==3092){
|
|
|
+ titles = new String[]{"项目编号", "项目名称","任务分组","分组预估工时","分组实际工时", "任务名称", "执行人","计划工时(h)", "实际工时(h)","状态", "类型", "截止日期"};
|
|
|
+ }
|
|
|
exportList.add(Lists.list(titles));
|
|
|
for (Map task : projectList) {
|
|
|
List<String> data = new ArrayList<>();
|
|
|
data.add(task.get("project_code") == null?"":task.get("project_code").toString());
|
|
|
data.add(task.get("project_name") == null?"":task.get("project_name").toString());
|
|
|
+ if(companyId==3092){
|
|
|
+ data.add(task.get("groupName") == null?"":task.get("groupName").toString());
|
|
|
+ data.add(task.get("group_plan_hours") == null?"":task.get("group_plan_hours").toString());
|
|
|
+ data.add(task.get("group_real_hours") == null?"":task.get("group_real_hours").toString());
|
|
|
+ }
|
|
|
data.add(task.get("name") != null?task.get("name").toString():"");
|
|
|
if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
String userName = "";
|
|
@@ -10942,13 +11195,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
long total = 0;
|
|
|
List<Map<String,Object>> resultList = null;
|
|
|
- List<Integer> branchDepartment =null;
|
|
|
- //若用户传入departmentId参数,则查询该部门所有子部门,添加到branchDepartment集合中
|
|
|
-// if(departmentId!=null){
|
|
|
-// branchDepartment = getBranchDepartment(departmentId, allDepartmentList);
|
|
|
-// }
|
|
|
String startDate = null;
|
|
|
String endDate = null;
|
|
|
+ System.out.println("month==="+month);
|
|
|
LocalDate time = LocalDate.parse(month, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
startDate = time.with(TemporalAdjusters.firstDayOfMonth()).toString();
|
|
|
endDate = time.with(TemporalAdjusters.lastDayOfMonth()).toString();
|
|
@@ -10958,10 +11207,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
if(pageIndex!=null&&pageSize!=null){
|
|
|
Integer size=pageSize;
|
|
|
Integer start=(pageIndex-1)*size;
|
|
|
- resultList=projectMapper.getFTEData(targetUser.getCompanyId(),startDate,endDate,start,size,area,branchDepartment,deptIds);
|
|
|
- total=projectMapper.getFTEData(targetUser.getCompanyId(),startDate,endDate,null,null,area,branchDepartment,deptIds).size();
|
|
|
+ resultList=projectMapper.getFTEData(targetUser.getCompanyId(),startDate,endDate,start,size,area,null,deptIds);
|
|
|
+ total=projectMapper.getFTEData(targetUser.getCompanyId(),startDate,endDate,null,null,area,null,deptIds).size();
|
|
|
}else{
|
|
|
- resultList=projectMapper.getFTEData(targetUser.getCompanyId(),startDate,endDate,null,null,area,branchDepartment,deptIds);
|
|
|
+ resultList=projectMapper.getFTEData(targetUser.getCompanyId(),startDate,endDate,null,null,area,null,deptIds);
|
|
|
}
|
|
|
for (Map<String, Object> map : resultList) {
|
|
|
map.put("FTE",Float.parseFloat(map.get("workTime") == null?"0":map.get("workTime").toString())/monthTime);
|
|
@@ -11378,21 +11627,15 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg syncProjectWithSap(String startDate,String endDate) {
|
|
|
+ public HttpRespMsg syncProjectWithSap(String startDate,String endDate,String projectCodes) {
|
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
|
Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
//获取SAP项目服务数据 ----> 工时管家任务分组下阶段作为项目服务数据
|
|
|
- if(StringUtils.isEmpty(startDate)||StringUtils.isEmpty(endDate)){
|
|
|
- //没设置开始或者结束日期 同步当天新增的项目数据
|
|
|
- DateTimeFormatter df=DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- startDate=df.format(LocalDate.now());
|
|
|
- endDate=df.format(LocalDate.now());
|
|
|
- }
|
|
|
- XmlResponseData projectServiceData= SyncSapUtils.syncServiceData("2020-01-01", endDate, companyId);
|
|
|
+ XmlResponseData projectServiceData= SyncSapUtils.syncServiceData("2020-01-01", endDate, companyId,isDev);
|
|
|
//已有的项目分类
|
|
|
List<ProjectCategory> allProjectCategoryList = projectCategoryMapper.selectList(new QueryWrapper<ProjectCategory>().eq("company_id", companyId));
|
|
|
List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId));
|
|
|
- XmlResponseData xmlResponseData = SyncSapUtils.syncProjectFromSap(startDate, endDate);
|
|
|
+ XmlResponseData xmlResponseData = SyncSapUtils.syncProjectFromSap(startDate, endDate,projectCodes,isDev);
|
|
|
List<ProjectQueryResponse> projectQueryResponses = xmlResponseData.getProjectQueryResponses();
|
|
|
List<Map<String,Object>> idsMapList=new ArrayList<>();
|
|
|
LocalDate localDate=LocalDate.now();
|
|
@@ -11473,6 +11716,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
List<String> stagesUUIDList = stagesList.stream().map(ProjectTask::getUUID).collect(Collectors.toList());
|
|
|
//抽调出最末级
|
|
|
List<ProjectTask> taskList = projectTasks.stream().filter(p ->p.getParentTaskUUID() != null &&stagesUUIDList.contains(p.getParentTaskUUID())&&(p.getSummaryTaskIndicator()==null||(p.getSummaryTaskIndicator()!=null && !p.getSummaryTaskIndicator().equals("true")))).collect(Collectors.toList());
|
|
|
+ List<Task> tasks=new ArrayList<>();
|
|
|
if(taskGroupList!=null && taskGroupList.size()>0){
|
|
|
for (ProjectTask group : taskGroupList) {
|
|
|
//如果作为第二层数据是不存在下级数据的 把当前数据作为第四层数据 手动添加阶段数据 作为该数据的上级数据
|
|
@@ -11507,7 +11751,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
if(three!=null){
|
|
|
task.setId(three.getId());
|
|
|
}
|
|
|
- taskService.saveOrUpdate(task);
|
|
|
+// taskService.saveOrUpdate(task);
|
|
|
+ tasks.add(task);
|
|
|
}else {
|
|
|
TaskGroup taskGroup=new TaskGroup();
|
|
|
taskGroup.setProjectId(project.getId());
|
|
@@ -11556,7 +11801,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
if(two!=null){
|
|
|
task.setId(two.getId());
|
|
|
}
|
|
|
- taskService.saveOrUpdate(task);
|
|
|
+// taskService.saveOrUpdate(task);
|
|
|
+ tasks.add(task);
|
|
|
}else {
|
|
|
Stages stage = new Stages();
|
|
|
stage.setSequence(1);
|
|
@@ -11594,8 +11840,20 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
if(one!=null){
|
|
|
task.setId(one.getId());
|
|
|
}
|
|
|
- taskService.saveOrUpdate(task);
|
|
|
+// taskService.saveOrUpdate(task);
|
|
|
+ tasks.add(task);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(tasks.size()>0){
|
|
|
+ Map<Integer, List<Task>> listMap = tasks.stream().collect(Collectors.groupingBy(t -> t.getStagesId()));
|
|
|
+ List<Integer> list = tasks.stream().map(Task::getStagesId).collect(Collectors.toList());
|
|
|
+ for (Integer id : list) {
|
|
|
+ List<Task> subList = listMap.get(id);
|
|
|
+ for (int i = 0; i < subList.size(); i++) {
|
|
|
+ subList.get(i).setSeq(i);
|
|
|
+ }
|
|
|
}
|
|
|
+ taskService.saveOrUpdateBatch(tasks);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -11607,21 +11865,23 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
List<ServiceProduct> serviceProducts = projectServiceData.getServiceProducts();
|
|
|
if(serviceProducts!=null&&serviceProducts.size()>0){
|
|
|
for (ServiceProduct serviceProduct : serviceProducts) {
|
|
|
- if(serviceProduct.getProductCategoryID().equals("901")&&serviceProduct.getBaseMeasureUnitCode().equals("HUR")){
|
|
|
+ if(serviceProduct.getProductCategoryID().equals("901")&&serviceProduct.getBaseMeasureUnitCode().equals("HUR")&&serviceProduct.getSales()!=null&&serviceProduct.getSales().getLifeCycleStatusCode().equals("2")){
|
|
|
SapProjectService sapProjectService=new SapProjectService();
|
|
|
sapProjectService.setServiceCode(serviceProduct.getInternalID());
|
|
|
sapProjectService.setServiceName(serviceProduct.getDescription().getDescription());
|
|
|
sapProjectService.setCompanyId(companyId);
|
|
|
- boolean match = serviceList.stream().anyMatch(s -> s.getServiceCode().equals(serviceProduct.getInternalID()));
|
|
|
- if(!match){
|
|
|
- sapProjectServiceList.add(sapProjectService);
|
|
|
+ sapProjectService.setStatus(Integer.valueOf(serviceProduct.getSales().getLifeCycleStatusCode()));
|
|
|
+ Optional<SapProjectService> first = serviceList.stream().filter(s -> s.getServiceCode().equals(serviceProduct.getInternalID())).findFirst();
|
|
|
+ if(first.isPresent()){
|
|
|
+ sapProjectService.setId(first.get().getId());
|
|
|
}
|
|
|
+ sapProjectServiceList.add(sapProjectService);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if(sapProjectServiceList.size()>0){
|
|
|
- sapProjectServiceService.saveBatch(sapProjectServiceList);
|
|
|
+ sapProjectServiceService.saveOrUpdateBatch(sapProjectServiceList);
|
|
|
}
|
|
|
msg.setData(xmlResponseData);
|
|
|
return msg;
|
|
@@ -11760,6 +12020,83 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getMembProjectCateRatio(String startDate, String endDate, Integer onlyShowWarning) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
+ List<UserCateTimeVo> timeList = projectMapper.getMembProjectCateTime(companyId, startDate, endDate);
|
|
|
+ CategoryRatioTblSetting categoryRatioTblSetting = categoryRatioTblSettingMapper.selectById(companyId);
|
|
|
+ //把timeList按照用户分组
|
|
|
+ Map<String, List<UserCateTimeVo>> userMap = timeList.stream().collect(Collectors.groupingBy(UserCateTimeVo::getUserId));
|
|
|
+ List<ProjectCategory> categoryList = projectCategoryMapper.selectList(new QueryWrapper<ProjectCategory>().eq("company_id", companyId));
|
|
|
+ List<Map> retList = new ArrayList();
|
|
|
+ for (Map.Entry<String, List<UserCateTimeVo>> entry : userMap.entrySet()) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("userId", entry.getKey());
|
|
|
+ List<UserCateTimeVo> value = entry.getValue();
|
|
|
+ map.put("userName", value.get(0).getName());
|
|
|
+ map.put("cateTimeList", value);
|
|
|
+ //计算这个人的总工时
|
|
|
+ double sum = value.stream().mapToDouble(UserCateTimeVo::getWorkingTime).sum();
|
|
|
+ map.put("workingTime", sum);
|
|
|
+ //计算占比
|
|
|
+ value.forEach(v->{
|
|
|
+ if (sum > 0) {
|
|
|
+ double v1 = v.getWorkingTime() * 100 / sum;
|
|
|
+ v.setPercent(v1);
|
|
|
+ } else {
|
|
|
+ v.setPercent(0.0);
|
|
|
+ }
|
|
|
+ if (categoryRatioTblSetting != null && categoryRatioTblSetting.getRatio() != null) {
|
|
|
+ UserCateTimeVo userCateTimeVo = v;
|
|
|
+ //获取用户的总工时预警
|
|
|
+ int ratio = categoryRatioTblSetting.getRatio();
|
|
|
+ if (categoryRatioTblSetting.getMoreOrLess() == 1) {
|
|
|
+ //大于预设比例的需要预警
|
|
|
+ if (userCateTimeVo.getPercent() > ratio) {
|
|
|
+ v.setWarning(true);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //小于预设比例的需要预警;
|
|
|
+ if (userCateTimeVo.getPercent() < ratio) {
|
|
|
+ v.setWarning(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //是否仅达到预警的用户列表
|
|
|
+ if (onlyShowWarning == 1) {
|
|
|
+ //获取用户的总工时
|
|
|
+ if (categoryRatioTblSetting != null && categoryRatioTblSetting.getRatio() != null) {
|
|
|
+ Optional<UserCateTimeVo> first = value.stream().filter(v -> categoryRatioTblSetting.getMonitorCategoryId().equals(v.getCategory())).findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ UserCateTimeVo userCateTimeVo = first.get();
|
|
|
+ //获取用户的总工时预警
|
|
|
+ int ratio = categoryRatioTblSetting.getRatio();
|
|
|
+ if (categoryRatioTblSetting.getMoreOrLess() == 1) {
|
|
|
+ //大于预设比例的需要预警,小于等于则跳过
|
|
|
+ if (userCateTimeVo.getWorkingTime() <= sum * ratio / 100) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //小于预设比例的需要预警;大于等于则跳过
|
|
|
+ if (userCateTimeVo.getWorkingTime() >= sum * ratio / 100) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ retList.add(map);
|
|
|
+ }
|
|
|
+ HashMap retMap = new HashMap();
|
|
|
+ retMap.put("categoryList", categoryList);
|
|
|
+ retMap.put("userList", retList);
|
|
|
+ msg.data = retMap;
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// public void setDeptIdList(Integer departmentId,List<Integer> deptIds){
|
|
|
// LambdaQueryWrapper<Department> lqw = new LambdaQueryWrapper<>();
|