|
@@ -2,11 +2,13 @@ package com.management.platform.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.management.platform.controller.WeiXinCorpController;
|
|
import com.management.platform.controller.WeiXinCorpController;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.entity.vo.DepartmentVO;
|
|
import com.management.platform.entity.vo.DepartmentVO;
|
|
|
|
+import com.management.platform.entity.vo.UserDailyWorkItem;
|
|
import com.management.platform.entity.vo.UserMonthWork;
|
|
import com.management.platform.entity.vo.UserMonthWork;
|
|
import com.management.platform.entity.vo.WorktimeItem;
|
|
import com.management.platform.entity.vo.WorktimeItem;
|
|
import com.management.platform.mapper.*;
|
|
import com.management.platform.mapper.*;
|
|
@@ -19,6 +21,7 @@ import me.chanjar.weixin.mp.api.WxMpService;
|
|
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
|
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
|
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
|
|
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
|
|
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
|
|
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
|
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
import org.apache.poi.ss.usermodel.*;
|
|
import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
@@ -100,6 +103,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
@Resource
|
|
@Resource
|
|
private ReportMapper reportMapper;
|
|
private ReportMapper reportMapper;
|
|
@Resource
|
|
@Resource
|
|
|
|
+ private ParticipationMapper participationMapper;
|
|
|
|
+ @Resource
|
|
private UserMapper userMapper;
|
|
private UserMapper userMapper;
|
|
@Resource
|
|
@Resource
|
|
private TimeCalculationMapper timeCalculationMapper;
|
|
private TimeCalculationMapper timeCalculationMapper;
|
|
@@ -1908,6 +1913,10 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
//由于第一行需要指明列对应的标题
|
|
//由于第一行需要指明列对应的标题
|
|
int rowNum = sheet.getLastRowNum();
|
|
int rowNum = sheet.getLastRowNum();
|
|
|
|
+ if (rowNum == 0) {
|
|
|
|
+ msg.setError("请填写工时数据");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
List<String> projectList = new ArrayList<>();
|
|
List<String> projectList = new ArrayList<>();
|
|
List<String> subProjectList = new ArrayList<>();
|
|
List<String> subProjectList = new ArrayList<>();
|
|
List<Project> allProjectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId));
|
|
List<Project> allProjectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId));
|
|
@@ -1991,14 +2000,17 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
List<SimpleProjectime> timeCostList = new ArrayList<SimpleProjectime>();
|
|
List<SimpleProjectime> timeCostList = new ArrayList<SimpleProjectime>();
|
|
double totalTime = 0;
|
|
double totalTime = 0;
|
|
for (int i=projectNameStartIndex; i < projectNameStartIndex + projectList.size(); i++) {
|
|
for (int i=projectNameStartIndex; i < projectNameStartIndex + projectList.size(); i++) {
|
|
- String stringCellValue = row.getCell(i)==null?"0":row.getCell(i).getStringCellValue();
|
|
|
|
|
|
+ if (row.getCell(i) == null) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ String stringCellValue = row.getCell(i).getStringCellValue();
|
|
double time = 0;
|
|
double time = 0;
|
|
- String pName = projectList.get(i-projectNameStartIndex);
|
|
|
|
- Project project = allProjectList.stream().filter(p -> p.getProjectName().equals(pName)).findFirst().get();
|
|
|
|
- String subPName = subProjectList.get(i-projectNameStartIndex);
|
|
|
|
if (!StringUtils.isEmpty(stringCellValue)) {
|
|
if (!StringUtils.isEmpty(stringCellValue)) {
|
|
time = Double.parseDouble(stringCellValue);
|
|
time = Double.parseDouble(stringCellValue);
|
|
if (time > 0) {
|
|
if (time > 0) {
|
|
|
|
+ String pName = projectList.get(i-projectNameStartIndex);
|
|
|
|
+ Project project = allProjectList.stream().filter(p -> p.getProjectName().equals(pName)).findFirst().get();
|
|
|
|
+ String subPName = subProjectList.get(i-projectNameStartIndex);
|
|
totalTime += time;
|
|
totalTime += time;
|
|
Report report = new Report();
|
|
Report report = new Report();
|
|
report.setCompanyId(companyId);
|
|
report.setCompanyId(companyId);
|
|
@@ -2030,24 +2042,55 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //检查个人总工时不能为0
|
|
|
|
-// if (totalTime == 0) {
|
|
|
|
-// msg.setError(username + "的工时为0,请检查修改");
|
|
|
|
-// return msg;
|
|
|
|
-// }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (reportList.size() == 0) {
|
|
|
|
+ msg.setError("缺少工时数据");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
//先删除老数据, 修改为批处理
|
|
//先删除老数据, 修改为批处理
|
|
|
|
+ long t1 = System.currentTimeMillis();
|
|
|
|
+
|
|
|
|
+ DateTimeFormatter standFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
+ HashMap<String, Object> dataMap = new HashMap<>();
|
|
for (Report r : reportList) {
|
|
for (Report r : reportList) {
|
|
- reportMapper.delete(new QueryWrapper<Report>()
|
|
|
|
- .eq("company_id", companyId)
|
|
|
|
- .eq("creator_id", r.getCreatorId())
|
|
|
|
- .eq("create_date", r.getCreateDate()));
|
|
|
|
|
|
+ //组合一下人员
|
|
|
|
+ String date = standFormat.format(r.getCreateDate());
|
|
|
|
+ if (dataMap.containsKey(date)) {
|
|
|
|
+ List<String> userList = (List)dataMap.get(date);
|
|
|
|
+ userList.add(r.getCreatorId());
|
|
|
|
+ } else {
|
|
|
|
+ List<String> newList = new ArrayList<>();
|
|
|
|
+ newList.add(r.getCreatorId());
|
|
|
|
+ dataMap.put(date, newList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ LambdaQueryWrapper<Report> queryWrapper = new QueryWrapper<Report>().lambda();
|
|
|
|
+ Iterator<String> it = dataMap.keySet().iterator();
|
|
|
|
+
|
|
|
|
+ while (it.hasNext()) {
|
|
|
|
+ String key = it.next();
|
|
|
|
+ List<String> userList = (List)dataMap.get(key);
|
|
|
|
+ queryWrapper.or(wrapper->wrapper.eq(Report::getCompanyId, companyId).eq(Report::getCreateDate, key).in(Report::getCreatorId, userList));
|
|
|
|
+ }
|
|
|
|
+ System.out.println(queryWrapper.getSqlSegment()+", "+queryWrapper.getSqlSelect()+", " + queryWrapper.getCustomSqlSegment());
|
|
|
|
+ if (queryWrapper.getSqlSegment() != null) {
|
|
|
|
+ reportMapper.delete(queryWrapper);
|
|
|
|
+ long t2 = System.currentTimeMillis();
|
|
|
|
+ System.out.println("删除耗时:" + (t2-t1));
|
|
|
|
+ //存储
|
|
|
|
+ reportService.saveBatch(reportList);
|
|
|
|
+ long t3 = System.currentTimeMillis();
|
|
|
|
+ System.out.println("插入耗时:"+ (t3-t2));
|
|
|
|
+ msg.data = dataCount;
|
|
|
|
+ } else {
|
|
|
|
+ msg.setError("工时数据不能为空");
|
|
}
|
|
}
|
|
- //存储
|
|
|
|
- reportService.saveBatch(reportList);
|
|
|
|
- msg.data = dataCount;
|
|
|
|
|
|
+
|
|
|
|
+// msg.setError("接口维护中...");
|
|
|
|
+
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
msg.setError("文件处理出错");
|
|
msg.setError("文件处理出错");
|
|
@@ -2069,6 +2112,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
+// FileUtils.copyFileToDirectory(file, new File(path));
|
|
// file.deleteOnExit();//程序退出时删除临时文件
|
|
// file.deleteOnExit();//程序退出时删除临时文件
|
|
System.out.println(file.delete());
|
|
System.out.println(file.delete());
|
|
}
|
|
}
|
|
@@ -2443,4 +2487,55 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg getNoReportUserList(HttpServletRequest request, String startDate, String endDate) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ User user = userMapper.selectById(request.getHeader("TOKEN"));
|
|
|
|
+ List<User> allRangeUserList = new ArrayList<>();
|
|
|
|
+ Integer companyId = user.getCompanyId();
|
|
|
|
+ List<Map<String, Object>> list = null;
|
|
|
|
+ //分角色权限:管理员看全部的,部门负责人看自己部门的,个人只能看自己的。
|
|
|
|
+ if (user.getRole() == 0) {
|
|
|
|
+ //检查是不是部门负责人
|
|
|
|
+ if (user.getManageDeptId() != null && user.getManageDeptId() != 0) {
|
|
|
|
+ List<Department> allDepts = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
|
|
|
|
+ List<Department> myDeptList = allDepts.stream().filter(d->user.getId().equals(d.getManagerId())).collect(Collectors.toList());
|
|
|
|
+ List<Department> subDepts = new ArrayList<>();
|
|
|
|
+ for (Department dp : myDeptList) {
|
|
|
|
+ subDepts.addAll(getSubDepts(dp, allDepts));
|
|
|
|
+ subDepts.add(dp);
|
|
|
|
+ }
|
|
|
|
+ List<Integer> collect = subDepts.stream().map(Department::getDepartmentId).collect(Collectors.toList());
|
|
|
|
+ list = reportMapper.getUserDailyWorkTime(companyId, startDate, endDate, collect, null);
|
|
|
|
+ //部门负责人看自己部门相关的
|
|
|
|
+ allRangeUserList = userMapper.selectList(new QueryWrapper<User>().in("department_id", collect));
|
|
|
|
+ } else {
|
|
|
|
+ //看自己的所负责的项目相关人员的
|
|
|
|
+ list = reportMapper.getUserDailyWorkTime(companyId, startDate, endDate, null, user.getId());
|
|
|
|
+ //项目相关的人员列表
|
|
|
|
+ List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("incharger_id", user.getId()));
|
|
|
|
+ List<Project> collect = projectList.stream().collect(Collectors.toList());
|
|
|
|
+ if (collect.size() > 0) {
|
|
|
|
+ List<Participation> participationList = participationMapper.selectList(new QueryWrapper<Participation>().in("project_id", collect));
|
|
|
|
+ List<String> collect1 = participationList.stream().map(Participation::getUserId).collect(Collectors.toList());
|
|
|
|
+ allRangeUserList = userMapper.selectList(new QueryWrapper<User>().in("id", collect1));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ list = reportMapper.getUserDailyWorkTime(companyId, startDate, endDate, null, null);
|
|
|
|
+ //管理员看全公司所有人
|
|
|
|
+ allRangeUserList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
|
|
|
|
+ }
|
|
|
|
+ List<UserDailyWorkItem> userMonthWorks = new ArrayList<UserDailyWorkItem>();
|
|
|
|
+
|
|
|
|
+ String lastUserId = null;
|
|
|
|
+ UserMonthWork lastUserData = null;
|
|
|
|
+ //按人员过滤
|
|
|
|
+ for (User curUser: allRangeUserList) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|