|
@@ -5063,6 +5063,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
DateFormat timeDf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
long t0 = System.currentTimeMillis();
|
|
|
+ long fetchDataTime = 0;
|
|
|
try {
|
|
|
String userId = request.getHeader("Token");
|
|
|
User user = userMapper.selectById(userId);
|
|
@@ -5072,6 +5073,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
Integer companyId = company.getId();
|
|
|
List<UserCustom> userCustomList = userCustomMapper.selectList(new QueryWrapper<UserCustom>().eq("company_id", companyId));
|
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
|
|
|
+ boolean needCorpWxTranslate = (wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1);
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
List<List<String>> dataList=new ArrayList<>();
|
|
|
List<String> titles = new ArrayList<String>();
|
|
@@ -5173,6 +5175,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看全公司工时");
|
|
|
//获取部门的所有子部门
|
|
|
List<Department> departments = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id",companyId));
|
|
|
+ Department[] deptArray = departments.toArray(new Department[0]);
|
|
|
List<Integer> branchDepartment = null;
|
|
|
if(departmentId != null){
|
|
|
branchDepartment = departmentService.getBranchDepartment(departmentId,departments);
|
|
@@ -5231,6 +5234,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
allReportByDate = reportMapper.getAllReportByDate(startDate, user.getCompanyId(), null, endDate, projectId,stateKey,branchDepartment);
|
|
|
}
|
|
|
long t2 = System.currentTimeMillis();
|
|
|
+ fetchDataTime = (t2-t1);
|
|
|
System.out.println("查数据库耗时:"+(t2-t1)/1000+"s");
|
|
|
}
|
|
|
//获取企业微信考勤数据
|
|
@@ -5314,8 +5318,18 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
|
|
|
long t1 = System.currentTimeMillis();
|
|
|
+ long calculateTime1 = 0;
|
|
|
+ long c1 = 0;
|
|
|
+ long c2 = 0;
|
|
|
+ long calculateTime2 = 0;
|
|
|
+ long calculateTime3 = 0;
|
|
|
+ long calculateTime4 = 0;
|
|
|
+ long calculateTime5 = 0;
|
|
|
+ long initListTime = 0;
|
|
|
+ long addStringNumTime = 0;
|
|
|
DateTimeFormatter dft = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
for (Map<String, Object> map : allReportByDate) {
|
|
|
+ long p1 = System.currentTimeMillis();
|
|
|
List<String> item=new ArrayList<>();
|
|
|
item.add(String.valueOf(rowNum));
|
|
|
item.add((String) map.get("jobNumber"));
|
|
@@ -5335,14 +5349,29 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
item.add(value);
|
|
|
}
|
|
|
+ long k = System.currentTimeMillis();
|
|
|
+ initListTime += (k-p1);
|
|
|
+
|
|
|
Department dept = null;
|
|
|
- for (Department department : departments) {
|
|
|
- if (map.containsKey("departmentId") && department.getDepartmentId().toString().equals(map.get("departmentId").toString())){
|
|
|
- dept = department;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ Department targetDept = new Department();
|
|
|
+ targetDept.setDepartmentId(Integer.valueOf(map.get("departmentId").toString()));
|
|
|
+ int index = Arrays.binarySearch(deptArray, targetDept, Comparator.comparing(Department::getDepartmentId));
|
|
|
+ if (index >= 0) {
|
|
|
+ dept = deptArray[index];
|
|
|
+ }
|
|
|
+// for (int p=0;p<departments.size();p++) {
|
|
|
+// Department department = departments.get(p);
|
|
|
+// if (department.getDepartmentId().equals((Long)map.get("departmentId"))){
|
|
|
+// dept = department;
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+ long q1 = System.currentTimeMillis();
|
|
|
+ calculateTime5 += (q1-k);
|
|
|
+ long t2 = System.currentTimeMillis();
|
|
|
+ c1 += (t2-p1);
|
|
|
+ long m1 = System.currentTimeMillis();
|
|
|
+ if(needCorpWxTranslate){
|
|
|
item.add("$userName="+(map.get("corpwxUserId")==null?"":map.get("corpwxUserId"))+"$");
|
|
|
item.add(departmentService.exportWxDepartment(dept,departments));
|
|
|
}else {
|
|
@@ -5352,6 +5381,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
|
|
|
item.add((String) map.get("projectCode"));
|
|
|
item.add((String) map.get("project"));
|
|
|
+
|
|
|
if(companyId==936){
|
|
|
String projectStatus="";
|
|
|
switch (Integer.valueOf(String.valueOf(map.get("projectStatus")))){
|
|
@@ -5367,6 +5397,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
item.add(projectStatus.equals("已完成")?projectStatus+"("+map.get("finishDate")+")":projectStatus);
|
|
|
item.add((String)map.get("projectCategorySub"));
|
|
|
}
|
|
|
+ long m2 = System.currentTimeMillis();
|
|
|
+ c2 += (m2-m1);
|
|
|
item.add((String) map.get("categoryName"));
|
|
|
if(timeType.getMainProjectState()==1){
|
|
|
item.add((String) map.get("projectMainName"));
|
|
@@ -5377,9 +5409,14 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
if (company.getPackageProject() == 1) {
|
|
|
item.add((String) map.get("taskName"));
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
item.add(new SimpleDateFormat("yyyy-MM-dd")
|
|
|
.format((java.sql.Date) map.get("createDate")));
|
|
|
item.add(map.get("duration").toString());
|
|
|
+
|
|
|
+ long p2 = System.currentTimeMillis();
|
|
|
+ calculateTime1 += (p2-p1);
|
|
|
if (timeType.getMultiWorktime() == 1) {
|
|
|
if ((Integer)map.get("multiWorktime") == 1) {
|
|
|
item.add(map.get("startTime").toString()+"-"+map.get("endTime").toString());
|
|
@@ -5410,15 +5447,17 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
item.add(map.get("groupName") != null? map.get("groupName").toString():"");
|
|
|
item.add(map.get("stage") != null?map.get("stage").toString():"");
|
|
|
}
|
|
|
+ long p3 = System.currentTimeMillis();
|
|
|
+ calculateTime2 += (p3-p2);
|
|
|
if (timeType.getShowFillauditTime() == 1) {
|
|
|
item.add(sdf.format((Date)map.get("time")));
|
|
|
- if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ if(needCorpWxTranslate){
|
|
|
String projectAuditorName ="$userName="+String.valueOf(map.get("projectAuditorCorpwxUserId"))+"$";
|
|
|
item.add(projectAuditorName);
|
|
|
}else {
|
|
|
item.add((String)map.get("projectAuditorName"));
|
|
|
}
|
|
|
- if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ if(needCorpWxTranslate){
|
|
|
String projectManagerName ="$userName="+String.valueOf(map.get("projectManagerCorpwxUserId"))+"$";
|
|
|
item.add(projectManagerName);
|
|
|
}else {
|
|
@@ -5450,7 +5489,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
String time = dtf.format(operateDate);
|
|
|
String msg= "";
|
|
|
- if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ if(needCorpWxTranslate){
|
|
|
Optional<User> first = userList.stream().filter(ul -> ul.getId().equals(audit.getOperatorId())).findFirst();
|
|
|
if(first.isPresent()){
|
|
|
if(audit.getMsg().contains("提交了")){
|
|
@@ -5480,6 +5519,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
item.add(sb.toString());
|
|
|
}
|
|
|
+ long p4 = System.currentTimeMillis();
|
|
|
+ calculateTime3 += (p4-p3);
|
|
|
item.add((String) map.get("content"));
|
|
|
if(stateKey==1){
|
|
|
Integer state = (Integer) map.get("state");
|
|
@@ -5521,7 +5562,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
String departmentName = map.get("departmentName") + "";
|
|
|
for (User userItem : userList) {
|
|
|
if (userItem.getId().equals(deptAuditorId)){
|
|
|
- if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ if(needCorpWxTranslate){
|
|
|
String deptAuditorName ="$userName="+ userItem.getCorpwxRealUserid() +"$";
|
|
|
departmentName = "$departmentName=" + departmentName + "$";
|
|
|
if(timeType.getReportAuditType()==4){
|
|
@@ -5549,7 +5590,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
if (String.valueOf(map.get("projectAuditState")).equals("0") || String.valueOf(map.get("groupAuditState")).equals("0")){
|
|
|
String projectAuditorName = map.get("projectAuditorName")+"";
|
|
|
String projectAuditorId = map.get("projectAuditorId")+"";
|
|
|
- if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ if(needCorpWxTranslate){
|
|
|
for (User userItem : userList) {
|
|
|
if (userItem.getId().equals(projectAuditorId)){
|
|
|
projectAuditorName ="$userName="+ userItem.getCorpwxUserid() +"$";
|
|
@@ -5564,13 +5605,19 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ long p5 = System.currentTimeMillis();
|
|
|
+ calculateTime4 += (p5-p4);
|
|
|
dataList.add(item);
|
|
|
rowNum++;
|
|
|
}
|
|
|
//生成Excel文件
|
|
|
String fileUrlSuffix = (startDate==null?"":(startDate+MessageUtils.message("leave.to")+endDate))+MessageUtils.message("excel.workReport") + System.currentTimeMillis();
|
|
|
long t3 = System.currentTimeMillis();
|
|
|
- System.out.println("处理数据耗时:"+(t3-t0)+"ms");
|
|
|
+ System.out.println("处理数据耗时:"+(t3-t0)/1000+"s");
|
|
|
+ System.out.println("计算总耗时:"+((t3-t0) - fetchDataTime)/1000+"s");
|
|
|
+ System.out.println("分别耗时:"+calculateTime1/1000+"s,"+calculateTime2/1000+"s,"+calculateTime3/1000+"s,"+calculateTime4/1000+"s");
|
|
|
+ System.out.println("阶段1中分别耗时:calculateTime5="+calculateTime5+"ms," + c1+"ms,"+c2+"ms");
|
|
|
+ System.out.println("initListTime="+initListTime+"ms,addStringNumTime="+addStringNumTime+"ms");
|
|
|
httpRespMsg = excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,fileUrlSuffix,dataList,path);
|
|
|
} catch (NullPointerException e) {
|
|
|
//httpRespMsg.setError("验证失败或缺少数据");
|