|
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.github.pagehelper.util.StringUtil;
|
|
|
import com.management.platform.entity.*;
|
|
|
import com.management.platform.entity.vo.*;
|
|
|
import com.management.platform.mapper.*;
|
|
@@ -47,6 +48,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
+import java.sql.Array;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.text.DecimalFormat;
|
|
|
import java.text.NumberFormat;
|
|
@@ -1103,7 +1105,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
|
|
|
//获取查询者所在公司每个项目的工时成本
|
|
|
@Override
|
|
|
- public HttpRespMsg getTimeCost(String startDate, String endDate, String userIds,Integer projectId, HttpServletRequest request) {
|
|
|
+ public HttpRespMsg getTimeCost(String startDate, String endDate, String userIds,Integer projectId, Integer type,HttpServletRequest request) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
try {
|
|
|
//根据系统配置的员工成本计算方式,按固定时薪还是固定月薪,分情况计算。
|
|
@@ -1164,6 +1166,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (type.equals(0)){
|
|
|
+ list = list.stream().sorted(Comparator.comparing(l -> -Double.parseDouble(l.get("costMoney").toString()))).collect(Collectors.toList());
|
|
|
+ }else {
|
|
|
+ list = list.stream().sorted(Comparator.comparing(l -> -Double.parseDouble(l.get("cost").toString()))).collect(Collectors.toList());
|
|
|
+ }
|
|
|
resultMap.put("costList", list);
|
|
|
resultMap.put("totalMoneyCost", totalMoneyCost);
|
|
|
if(functionCostList.size()==0){
|
|
@@ -9691,4 +9698,301 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
httpRespMsg.data = projects;
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
+
|
|
|
+ //获取FTE报表数据
|
|
|
+ @Override
|
|
|
+ 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();
|
|
|
+
|
|
|
+ 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报表数据
|
|
|
+ @Override
|
|
|
+ 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()));
|
|
|
+ List<UserCustom> userCustoms = userCustomMapper.selectList(new QueryWrapper<UserCustom>().eq("company_id", user.getCompanyId()).orderByAsc("id"));
|
|
|
+ String customName = "";
|
|
|
+ if (userCustoms.size() != 0){
|
|
|
+ customName = userCustoms.get(0).getName();
|
|
|
+ }
|
|
|
+ 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<String> titleList=new ArrayList<>();
|
|
|
+ List<String> subtitle=new ArrayList<>();
|
|
|
+ Integer no = 0;
|
|
|
+ titleList.add(customName);
|
|
|
+ titleList.add("序号");
|
|
|
+ titleList.add("CRC姓名");
|
|
|
+ titleList.add("项目号");
|
|
|
+ titleList.add("项目名称");
|
|
|
+ titleList.add("工时(H)");
|
|
|
+ titleList.add("FTE(工时/当月工时基数)");
|
|
|
+ titleList.add("非项目工时(H)(当月工时基数-项目工时合计工时数)");
|
|
|
+ dataList.add(titleList);
|
|
|
+ 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++) {
|
|
|
+ if (!resultList.get(i).containsKey("area")){
|
|
|
+ resultList.get(i).put("area","无");
|
|
|
+ }else if(org.apache.commons.lang3.StringUtils.isBlank(resultList.get(i).get("area").toString())){
|
|
|
+ resultList.get(i).put("area","无");
|
|
|
+ }
|
|
|
+ ArrayList<String> row = new ArrayList<>();
|
|
|
+ if (i == 0){
|
|
|
+ no += 1;
|
|
|
+ row.add(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(customName + "合计");
|
|
|
+ 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(customName + "合计");
|
|
|
+ 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();
|
|
|
+ try {
|
|
|
+ return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,fileName, dataList, path);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ httpRespMsg.data = pathPrefix + fileName+".xlsx";
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
}
|