|
@@ -9692,62 +9692,288 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
|
|
|
//获取FTE报表数据
|
|
//获取FTE报表数据
|
|
@Override
|
|
@Override
|
|
- public HttpRespMsg getFTEData(Integer pageIndex, Integer pageSize, String month, HttpServletRequest request) {
|
|
|
|
|
|
+ public HttpRespMsg getFTEData(Integer pageIndex, Integer pageSize, String month, String area, HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg httpRespMsg =new HttpRespMsg();
|
|
|
|
+ User targetUser = userMapper.selectById(request.getHeader("token"));
|
|
|
|
+ List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "全部部门FTE报表");
|
|
|
|
+ List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "负责部门FTE报表");
|
|
|
|
+ List<Integer> deptIds=null;
|
|
|
|
+ List<Department> allDepartmentList=departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id",targetUser.getCompanyId()));
|
|
|
|
+ List<Department> userDepartmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", targetUser.getId()).eq("company_id",targetUser.getCompanyId()));
|
|
|
|
+ List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", targetUser.getId()));
|
|
|
|
+ //判断查看权限
|
|
|
|
+ if(functionAllList.size()==0){
|
|
|
|
+ deptIds=new ArrayList<>();
|
|
|
|
+ deptIds.add(-1);
|
|
|
|
+ if(functionDeptList.size()>0){
|
|
|
|
+ List<Integer> collect = userDepartmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
|
+ List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
|
+ collect.addAll(otherCollect);
|
|
|
|
+ //将该用户管理的所有部门以及部门的子部门id添加到deptIds集合中
|
|
|
|
+ for (Integer integer : collect) {
|
|
|
|
+ List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
|
|
|
|
+ deptIds.addAll(branchDepartment);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ 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;
|
|
|
|
+ LocalDate time = LocalDate.parse(month, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
|
+ startDate = time.with(TemporalAdjusters.firstDayOfMonth()).toString();
|
|
|
|
+ endDate = time.with(TemporalAdjusters.lastDayOfMonth()).toString();
|
|
|
|
+ int days = WorkDayCalculateUtils.getWorkDaysListInRange(startDate, endDate, 0).size();
|
|
|
|
+ TimeType allDay = timeTypeMapper.selectOne(new QueryWrapper<TimeType>().eq("company_id", targetUser.getCompanyId()));
|
|
|
|
+ Float monthTime = days * allDay.getAllday();
|
|
|
|
|
|
- return null;
|
|
|
|
|
|
+ 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();
|
|
|
|
+ }else{
|
|
|
|
+ resultList=projectMapper.getFTEData(targetUser.getCompanyId(),startDate,endDate,null,null,area,branchDepartment,deptIds);
|
|
|
|
+ }
|
|
|
|
+ for (Map<String, Object> map : resultList) {
|
|
|
|
+ map.put("FTE",Float.parseFloat(map.get("workTime").toString())/monthTime);
|
|
|
|
+ }
|
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", targetUser.getCompanyId()));
|
|
|
|
+ if (wxCorpInfo != null && wxCorpInfo.getSaasSyncContact().equals(1)){
|
|
|
|
+ for (Map<String, Object> map : resultList) {
|
|
|
|
+ map.put("userName",map.get("wxUserId"));
|
|
|
|
+ map.put("corpwx_userid","$userName=" + map.get("wxUserId") + "$");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
|
+ map.put("resultList",resultList);
|
|
|
|
+ map.put("total",total);
|
|
|
|
+ map.put("monthTime",monthTime);
|
|
|
|
+ httpRespMsg.data = map;
|
|
|
|
+ return httpRespMsg;
|
|
}
|
|
}
|
|
|
|
|
|
//导出FTE报表数据
|
|
//导出FTE报表数据
|
|
@Override
|
|
@Override
|
|
- public HttpRespMsg exportFTEData(String month, HttpServletRequest request) {
|
|
|
|
- HttpRespMsg msg=new HttpRespMsg();
|
|
|
|
-// User user = userMapper.selectById(request.getHeader("token"));
|
|
|
|
-// Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
|
-// List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", user.getCompanyId()));
|
|
|
|
-// List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "全部子项目工时成本");
|
|
|
|
-// List<SysRichFunction> functionInchargeList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "负责项目子项目工时成本");
|
|
|
|
-// //判断查看权限
|
|
|
|
-// List<Integer> inchagerIds=null;
|
|
|
|
-// if(functionAllList.size()==0){
|
|
|
|
-// inchagerIds=new ArrayList<>();
|
|
|
|
-// if(functionInchargeList.size()>0){
|
|
|
|
-// List<Project> list = projectList.stream().filter(pl -> (pl.getInchargerId()==null?0:pl.getInchargerId()).equals(user.getId())).collect(Collectors.toList());
|
|
|
|
-// if(list!=null){
|
|
|
|
-// List<Integer> collect = list.stream().map(li -> li.getId()).collect(Collectors.toList());
|
|
|
|
-// inchagerIds.addAll(collect);
|
|
|
|
-// }
|
|
|
|
-// }else {
|
|
|
|
-// inchagerIds.add(-1);
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
|
|
+ public HttpRespMsg exportFTEData(String month, String area,HttpServletRequest request) {
|
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
|
+ HttpRespMsg fteData = getFTEData(null, null, month, area, request);
|
|
|
|
+ Map<String, Object> data = (Map<String, Object>) (Map<String, Object>) fteData.data;
|
|
|
|
+ List<Map<String, Object>> resultList = (List<Map<String, Object>>) data.get("resultList");
|
|
|
|
+ Float monthTime = (Float) data.get("monthTime");
|
|
List<List<String>> dataList=new ArrayList<>();
|
|
List<List<String>> dataList=new ArrayList<>();
|
|
List<String> titleList=new ArrayList<>();
|
|
List<String> titleList=new ArrayList<>();
|
|
- List<List<Integer>> mergeCellList = new ArrayList<>();
|
|
|
|
|
|
+ List<String> subtitle=new ArrayList<>();
|
|
|
|
+ Integer no = 0;
|
|
titleList.add("地区");
|
|
titleList.add("地区");
|
|
titleList.add("序号");
|
|
titleList.add("序号");
|
|
titleList.add("CRC姓名");
|
|
titleList.add("CRC姓名");
|
|
titleList.add("项目号");
|
|
titleList.add("项目号");
|
|
titleList.add("项目名称");
|
|
titleList.add("项目名称");
|
|
- titleList.add("子项目成本/元");
|
|
|
|
|
|
+ titleList.add("工时(H)");
|
|
|
|
+ titleList.add("FTE(工时/当月工时基数)");
|
|
|
|
+ titleList.add("非项目工时(H)(当月工时基数-项目工时合计工时数)");
|
|
dataList.add(titleList);
|
|
dataList.add(titleList);
|
|
- ArrayList<Integer> cell = new ArrayList<>();
|
|
|
|
- cell.add(0);
|
|
|
|
- cell.add(2);
|
|
|
|
- cell.add(0);
|
|
|
|
- cell.add(0);
|
|
|
|
- mergeCellList.add(cell);
|
|
|
|
-
|
|
|
|
- ArrayList<Integer> cell1 = new ArrayList<>();
|
|
|
|
- cell1.add(0);
|
|
|
|
- cell1.add(2);
|
|
|
|
- cell1.add(1);
|
|
|
|
- cell1.add(1);
|
|
|
|
-
|
|
|
|
- mergeCellList.add(cell1);
|
|
|
|
|
|
+ subtitle.add("");
|
|
|
|
+ subtitle.add("");
|
|
|
|
+ subtitle.add("");
|
|
|
|
+ subtitle.add("");
|
|
|
|
+ subtitle.add("");
|
|
|
|
+ subtitle.add("");
|
|
|
|
+ subtitle.add("当月工时:" + monthTime);
|
|
|
|
+ dataList.add(subtitle);
|
|
|
|
+ Float pTimeSum = 0.0F;
|
|
|
|
+ Float pFteSum = 0.0F;
|
|
|
|
+ Float aTimeSum = 0.0F;
|
|
|
|
+ Float aFteSum = 0.0F;
|
|
|
|
+ for (int i = 0; i < resultList.size(); i++) {
|
|
|
|
+ ArrayList<String> row = new ArrayList<>();
|
|
|
|
+ if (i == 0){
|
|
|
|
+ no += 1;
|
|
|
|
+ row.add(resultList.get(i).get("area")==null?"无":resultList.get(i).get("area").toString());
|
|
|
|
+ row.add(no + "");
|
|
|
|
+ if (wxCorpInfo != null && wxCorpInfo.getSaasSyncContact().equals(1)){
|
|
|
|
+ row.add(resultList.get(i).get("corpwx_userid") + "");
|
|
|
|
+ }else {
|
|
|
|
+ row.add(resultList.get(i).get("userName") + "");
|
|
|
|
+ }
|
|
|
|
+ row.add(resultList.get(i).get("projectCode") + "");
|
|
|
|
+ row.add(resultList.get(i).get("projectName") + "");
|
|
|
|
+
|
|
|
|
+ Float workTime = Float.valueOf(resultList.get(i).get("workTime").toString());
|
|
|
|
+ row.add(workTime + "");
|
|
|
|
+ pTimeSum += workTime;
|
|
|
|
+ aTimeSum += workTime;
|
|
|
|
+
|
|
|
|
+ Float FTE = Float.valueOf(resultList.get(i).get("workTime").toString()) / monthTime;
|
|
|
|
+ row.add(new BigDecimal(FTE).setScale(2, RoundingMode.HALF_UP) + "");
|
|
|
|
+ pFteSum += FTE;
|
|
|
|
+ aFteSum += FTE;
|
|
|
|
+
|
|
|
|
+ row.add("");
|
|
|
|
+
|
|
|
|
+ dataList.add(row);
|
|
|
|
+ }else if(resultList.get(i).get("area").equals(resultList.get(i - 1).get("area"))){
|
|
|
|
+ if (resultList.get(i).get("id").equals(resultList.get(i - 1).get("id"))){
|
|
|
|
+ row.add("");
|
|
|
|
+ row.add("");
|
|
|
|
+ row.add("");
|
|
|
|
+ row.add(resultList.get(i).get("projectCode") + "");
|
|
|
|
+ row.add(resultList.get(i).get("projectName") + "");
|
|
|
|
+
|
|
|
|
+ Float workTime = Float.valueOf(resultList.get(i).get("workTime").toString());
|
|
|
|
+ row.add(workTime + "");
|
|
|
|
+ pTimeSum += workTime;
|
|
|
|
+ aTimeSum += workTime;
|
|
|
|
+
|
|
|
|
+ Float FTE = Float.valueOf(resultList.get(i).get("workTime").toString()) / monthTime;
|
|
|
|
+ row.add(new BigDecimal(FTE).setScale(2, RoundingMode.HALF_UP) + "");
|
|
|
|
+ pFteSum += FTE;
|
|
|
|
+ aFteSum += FTE;
|
|
|
|
+
|
|
|
|
+ row.add("");
|
|
|
|
+
|
|
|
|
+ dataList.add(row);
|
|
|
|
+ }else {
|
|
|
|
+ ArrayList<String> sum = new ArrayList<>();
|
|
|
|
+ sum.add("");
|
|
|
|
+ sum.add("");
|
|
|
|
+ sum.add("合计");
|
|
|
|
+ sum.add("");
|
|
|
|
+ sum.add("");
|
|
|
|
+ sum.add(pTimeSum.toString());
|
|
|
|
+ sum.add(new BigDecimal(pFteSum).setScale(2, RoundingMode.HALF_UP) + "");
|
|
|
|
+ sum.add((monthTime - pTimeSum) + "");
|
|
|
|
+ pTimeSum = 0.0F;
|
|
|
|
+ pFteSum = 0.0F;
|
|
|
|
+ dataList.add(sum);
|
|
|
|
+
|
|
|
|
+ no += 1;
|
|
|
|
+ row.add("");
|
|
|
|
+ row.add(no + "");
|
|
|
|
+ if (wxCorpInfo != null && wxCorpInfo.getSaasSyncContact().equals(1)){
|
|
|
|
+ row.add(resultList.get(i).get("corpwx_userid") + "");
|
|
|
|
+ }else {
|
|
|
|
+ row.add(resultList.get(i).get("userName") + "");
|
|
|
|
+ }
|
|
|
|
+ row.add(resultList.get(i).get("projectCode") + "");
|
|
|
|
+ row.add(resultList.get(i).get("projectName") + "");
|
|
|
|
+
|
|
|
|
+ Float workTime = Float.valueOf(resultList.get(i).get("workTime").toString());
|
|
|
|
+ row.add(workTime + "");
|
|
|
|
+ pTimeSum += workTime;
|
|
|
|
+ aTimeSum += workTime;
|
|
|
|
+
|
|
|
|
+ Float FTE = Float.valueOf(resultList.get(i).get("workTime").toString()) / monthTime;
|
|
|
|
+ row.add(new BigDecimal(FTE).setScale(2, RoundingMode.HALF_UP) + "");
|
|
|
|
+ pFteSum += FTE;
|
|
|
|
+ aFteSum += FTE;
|
|
|
|
+
|
|
|
|
+ row.add("");
|
|
|
|
+
|
|
|
|
+ dataList.add(row);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }else {
|
|
|
|
+ ArrayList<String> pSum = new ArrayList<>();
|
|
|
|
+ pSum.add("");
|
|
|
|
+ pSum.add("");
|
|
|
|
+ pSum.add("合计");
|
|
|
|
+ pSum.add("");
|
|
|
|
+ pSum.add("");
|
|
|
|
+ pSum.add(pTimeSum.toString());
|
|
|
|
+ pSum.add(new BigDecimal(pFteSum).setScale(2, RoundingMode.HALF_UP) + "");
|
|
|
|
+ pSum.add((monthTime - pTimeSum) + "");
|
|
|
|
+ pTimeSum = 0.0F;
|
|
|
|
+ pFteSum = 0.0F;
|
|
|
|
+
|
|
|
|
+ dataList.add(pSum);
|
|
|
|
+
|
|
|
|
+ ArrayList<String> sum = new ArrayList<>();
|
|
|
|
+ sum.add("");
|
|
|
|
+ sum.add("");
|
|
|
|
+ sum.add("地区合计");
|
|
|
|
+ sum.add("");
|
|
|
|
+ sum.add("");
|
|
|
|
+ sum.add(aTimeSum.toString());
|
|
|
|
+ //sum.add(new BigDecimal(aFteSum).setScale(2, RoundingMode.HALF_UP) + "");
|
|
|
|
+ sum.add("");
|
|
|
|
+ sum.add((monthTime - aTimeSum) + "");
|
|
|
|
+ pTimeSum = 0.0F;
|
|
|
|
+ pFteSum = 0.0F;
|
|
|
|
+ aTimeSum = 0.0F;
|
|
|
|
+ aFteSum = 0.0F;
|
|
|
|
+ dataList.add(sum);
|
|
|
|
+
|
|
|
|
+ ArrayList<String> n = new ArrayList<>();
|
|
|
|
+ n.add("");
|
|
|
|
+ dataList.add(n);
|
|
|
|
+
|
|
|
|
+ no += 1;
|
|
|
|
+ row.add(resultList.get(i).get("area")==null?"无":resultList.get(i).get("area").toString());
|
|
|
|
+ row.add(no + "");
|
|
|
|
+ if (wxCorpInfo != null && wxCorpInfo.getSaasSyncContact().equals(1)){
|
|
|
|
+ row.add(resultList.get(i).get("corpwx_userid") + "");
|
|
|
|
+ }else {
|
|
|
|
+ row.add(resultList.get(i).get("userName") + "");
|
|
|
|
+ }
|
|
|
|
+ row.add(resultList.get(i).get("projectCode") + "");
|
|
|
|
+ row.add(resultList.get(i).get("projectName") + "");
|
|
|
|
+
|
|
|
|
+ Float workTime = Float.valueOf(resultList.get(i).get("workTime").toString());
|
|
|
|
+ row.add(workTime + "");
|
|
|
|
+ pTimeSum += workTime;
|
|
|
|
+ aTimeSum += workTime;
|
|
|
|
+
|
|
|
|
+ Float FTE = Float.valueOf(resultList.get(i).get("workTime").toString()) / monthTime;
|
|
|
|
+ row.add(new BigDecimal(FTE).setScale(2, RoundingMode.HALF_UP) + "");
|
|
|
|
+ pFteSum += FTE;
|
|
|
|
+ aFteSum += FTE;
|
|
|
|
+
|
|
|
|
+ row.add("");
|
|
|
|
+
|
|
|
|
+ dataList.add(row);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (i == resultList.size()-1){
|
|
|
|
+ ArrayList<String> pSum = new ArrayList<>();
|
|
|
|
+ pSum.add("");
|
|
|
|
+ pSum.add("");
|
|
|
|
+ pSum.add("合计");
|
|
|
|
+ pSum.add("");
|
|
|
|
+ pSum.add("");
|
|
|
|
+ pSum.add(pTimeSum.toString());
|
|
|
|
+ pSum.add(new BigDecimal(pFteSum).setScale(2, RoundingMode.HALF_UP) + "");
|
|
|
|
+ pSum.add((monthTime - pTimeSum) + "");
|
|
|
|
+ dataList.add(pSum);
|
|
|
|
+
|
|
|
|
+ ArrayList<String> sum = new ArrayList<>();
|
|
|
|
+ sum.add("");
|
|
|
|
+ sum.add("");
|
|
|
|
+ sum.add("地区合计");
|
|
|
|
+ sum.add("");
|
|
|
|
+ sum.add("");
|
|
|
|
+ sum.add(aTimeSum.toString());
|
|
|
|
+ //sum.add(new BigDecimal(aFteSum).setScale(2, RoundingMode.HALF_UP) + "");
|
|
|
|
+ sum.add("");
|
|
|
|
+ sum.add((monthTime - aTimeSum) + "");
|
|
|
|
+ dataList.add(sum);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
String fileName = "FTE报表"+System.currentTimeMillis();
|
|
String fileName = "FTE报表"+System.currentTimeMillis();
|
|
- String resp = ExcelUtil.exportGeneralExcelByTitleAndList(fileName, dataList, path,mergeCellList);
|
|
|
|
- msg.data=resp;
|
|
|
|
- return msg;
|
|
|
|
|
|
+ try {
|
|
|
|
+ return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,fileName, dataList, path);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ httpRespMsg.data = pathPrefix + fileName+".xlsx";
|
|
|
|
+ return httpRespMsg;
|
|
}
|
|
}
|
|
}
|
|
}
|