|
@@ -5062,6 +5062,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
public HttpRespMsg exportReport(@RequestParam String startDate, @RequestParam String endDate, Integer projectId,Integer stateKey,Integer departmentId, HttpServletRequest request) {
|
|
|
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);
|
|
@@ -5071,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>();
|
|
@@ -5172,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);
|
|
@@ -5223,11 +5227,15 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
else {
|
|
|
//看公司所有人的
|
|
|
+ long t1 = System.currentTimeMillis();
|
|
|
if (timeType.getShowFillauditTime() == 1) {
|
|
|
allReportByDate = reportMapper.getAllReportByDateWithReportLog(startDate, user.getCompanyId(), null, endDate, projectId,stateKey,branchDepartment);
|
|
|
} else {
|
|
|
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");
|
|
|
}
|
|
|
//获取企业微信考勤数据
|
|
|
List<UserCorpwxTime> userCorpwxTimeList = new ArrayList<>();
|
|
@@ -5309,9 +5317,9 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
}
|
|
|
List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
|
|
|
- long t1 = System.currentTimeMillis();
|
|
|
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"));
|
|
@@ -5332,20 +5340,22 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
item.add(value);
|
|
|
}
|
|
|
Department dept = null;
|
|
|
- for (Department department : departments) {
|
|
|
- if (map.containsKey("departmentId") && department.getDepartmentId().toString().equals(map.get("departmentId").toString())){
|
|
|
- dept = department;
|
|
|
- break;
|
|
|
+ Department targetDept = new Department();
|
|
|
+ if (map.get("departmentId") != null) {
|
|
|
+ targetDept.setDepartmentId(Integer.valueOf(map.get("departmentId").toString()));
|
|
|
+ int index = Arrays.binarySearch(deptArray, targetDept, Comparator.comparing(Department::getDepartmentId));
|
|
|
+ if (index >= 0) {
|
|
|
+ dept = deptArray[index];
|
|
|
}
|
|
|
}
|
|
|
- if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+
|
|
|
+ if(needCorpWxTranslate){
|
|
|
item.add("$userName="+(map.get("corpwxUserId")==null?"":map.get("corpwxUserId"))+"$");
|
|
|
item.add(departmentService.exportWxDepartment(dept,departments));
|
|
|
}else {
|
|
|
item.add((String) map.get("name"));
|
|
|
item.add(departmentService.getSupDepartment(dept,departments));
|
|
|
}
|
|
|
-
|
|
|
item.add((String) map.get("projectCode"));
|
|
|
item.add((String) map.get("project"));
|
|
|
if(companyId==936){
|
|
@@ -5408,13 +5418,13 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
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 {
|
|
@@ -5446,7 +5456,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("提交了")){
|
|
@@ -5476,7 +5486,6 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}
|
|
|
item.add(sb.toString());
|
|
|
}
|
|
|
- item.add((String) map.get("content"));
|
|
|
if(stateKey==1){
|
|
|
Integer state = (Integer) map.get("state");
|
|
|
switch (state){
|
|
@@ -5517,7 +5526,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){
|
|
@@ -5534,18 +5543,16 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
}else {
|
|
|
item.add("待" + departmentName + "(" + userItem.getName() + ")审核");
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}else {
|
|
|
//项目审核或分组审核
|
|
|
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() +"$";
|