|
@@ -9,6 +9,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.google.common.collect.ImmutableMap;
|
|
|
import com.management.platform.entity.*;
|
|
|
import com.management.platform.entity.Task;
|
|
|
import com.management.platform.entity.vo.*;
|
|
@@ -254,6 +255,431 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
private String path;
|
|
|
@Value("${configEnv.isDev}")
|
|
|
public boolean isDev;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getProjectListByPage(Integer pageIndex, Integer pageSize, String infoString, Integer id, Integer forReport, HttpServletRequest request) {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ try {
|
|
|
+ User user = userMapper.selectById(request.getHeader("Token"));
|
|
|
+ if (forReport == 1) {
|
|
|
+ if (!sysFunctionService.hasPriviledge(user.getRoleId(), "可填报全部项目")) {
|
|
|
+ //只能看本人参与的项目
|
|
|
+ pageIndex=(pageIndex-1)*pageSize;
|
|
|
+ List<Map<String, Object>> data = projectMapper.getOnlyJoinProjectsPage(user.getId(), user.getCompanyId(),pageIndex,pageSize,infoString);
|
|
|
+ Integer total = projectMapper.getOnlyJoinProjectsTotal(user.getId(), user.getCompanyId(),pageIndex,pageSize,infoString);
|
|
|
+ HashMap<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("total", total);
|
|
|
+ if (id!=null){
|
|
|
+ List<Map<String, Object>> dataByID = projectMapper.getOnlyJoinProjectsById(user.getId(), user.getCompanyId(),id);
|
|
|
+ data.addAll(0,dataByID);
|
|
|
+ }
|
|
|
+ resultMap.put("data", data);
|
|
|
+
|
|
|
+ httpRespMsg.data = resultMap;
|
|
|
+
|
|
|
+ } else {
|
|
|
+ //有权限的填报全部的进行中项目
|
|
|
+ QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
|
|
|
+ if (!StringUtils.isEmpty(infoString)){
|
|
|
+ queryWrapper.eq("company_id", user.getCompanyId())
|
|
|
+ .eq("status", 1)
|
|
|
+ .and(i->i.like("project_name",infoString).or()
|
|
|
+ .like("project_code",infoString))
|
|
|
+ .orderByDesc("is_public")
|
|
|
+ .orderByAsc("id")
|
|
|
+ .select("id", "project_code", "project_name");
|
|
|
+ }else {
|
|
|
+ queryWrapper.eq("company_id", user.getCompanyId())
|
|
|
+ .eq("status", 1)
|
|
|
+ .orderByDesc("is_public")
|
|
|
+ .orderByAsc("id")
|
|
|
+ .select("id", "project_code", "project_name");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Page<Project> projectPage = new Page<>(pageIndex, pageSize);
|
|
|
+ IPage<Project> projectIPage = projectMapper.selectPage(projectPage, queryWrapper);
|
|
|
+
|
|
|
+ HashMap<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("total", projectIPage.getTotal());
|
|
|
+ List<Project> projectList = projectIPage.getRecords();
|
|
|
+ if (id!=null){
|
|
|
+ Project project = projectMapper.selectOne(new QueryWrapper<Project>().eq("company_id", user.getCompanyId()).eq("status", 1).eq("id", id).select("id", "project_code", "project_name"));
|
|
|
+ if (project!=null){
|
|
|
+ projectList.add(0,project);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resultMap.put("data", projectList);
|
|
|
+ httpRespMsg.data = resultMap;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (!sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部项目")) {
|
|
|
+ //只能看本人相关的项目
|
|
|
+ pageIndex=(pageIndex-1)*pageSize;
|
|
|
+ List<Map<String, Object>> data = projectMapper.getParticipatedProjectPage(user.getId(), user.getCompanyId(),pageIndex,pageSize,infoString);
|
|
|
+ Integer total = projectMapper.getParticipatedProjectTotal(user.getId(), user.getCompanyId(),pageIndex,pageSize,infoString);
|
|
|
+ HashMap<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("total", total);
|
|
|
+ if (id!=null){
|
|
|
+ List<Map<String, Object>> dataByID = projectMapper.getParticipatedProjectById(user.getId(), user.getCompanyId(),id);
|
|
|
+ data.addAll(0,dataByID);
|
|
|
+ }
|
|
|
+ resultMap.put("data", data);
|
|
|
+ httpRespMsg.data = resultMap;
|
|
|
+ } else {
|
|
|
+ //有权限的看全部的
|
|
|
+ httpRespMsg.data = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", user.getCompanyId()).orderByDesc("is_public").orderByAsc("id"));
|
|
|
+ QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
|
|
|
+ if (!StringUtils.isEmpty(infoString)){
|
|
|
+ queryWrapper.eq("company_id", user.getCompanyId())
|
|
|
+ .and(i->i.like("project_name",infoString).or().like("project_code",infoString))
|
|
|
+ .orderByDesc("is_public").orderByAsc("id")
|
|
|
+ .select("id", "project_code", "project_name");
|
|
|
+ }else {
|
|
|
+ queryWrapper.eq("company_id", user.getCompanyId())
|
|
|
+ .orderByDesc("is_public").orderByAsc("id")
|
|
|
+ .select("id", "project_code", "project_name");
|
|
|
+ }
|
|
|
+ Page<Project> projectPage =new Page<>(pageIndex, pageSize);
|
|
|
+ IPage<Project> projectIPage = projectMapper.selectPage(projectPage, queryWrapper);
|
|
|
+ HashMap<String, Object> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("total", projectIPage.getTotal());
|
|
|
+ List<Project> projectList = projectIPage.getRecords();
|
|
|
+ if (id!=null){
|
|
|
+ Project project = projectMapper.selectOne(new QueryWrapper<Project>().eq("company_id", user.getCompanyId()).eq("id", id).select("id", "project_code", "project_name"));
|
|
|
+ if (project!=null){
|
|
|
+ projectList.add(0,project);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resultMap.put("data", projectList);
|
|
|
+ httpRespMsg.data = resultMap;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (NullPointerException e) {
|
|
|
+ //httpRespMsg.setError("验证失败");
|
|
|
+ httpRespMsg.setError(MessageUtils.message("access.verificationError"));
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg exportTimeByProjectAndEmployee(String date, HttpServletRequest request) {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ String[] strings = date.split("-");
|
|
|
+ int year = Integer.parseInt(strings[0]);
|
|
|
+ int month = Integer.parseInt(strings[1]);
|
|
|
+ YearMonth yearMonth = YearMonth.of((year), month);
|
|
|
+ int daysInMonth = yearMonth.lengthOfMonth();
|
|
|
+
|
|
|
+ // 获取该月份的第一天
|
|
|
+ String startDate = String.format("%04d-%02d-01", year, month);
|
|
|
+ // 获取下个月的第一天
|
|
|
+ LocalDate lastDate = LocalDate.of(year, month, 1).plusDays(LocalDate.of(year, month, 1).lengthOfMonth() - 1);
|
|
|
+ String endDate = String.format("%04d-%02d-%02d", year, month, lastDate.getDayOfMonth());
|
|
|
+ try {
|
|
|
+ User targetUser = userMapper.selectById(request.getHeader("Token"));
|
|
|
+ Integer companyId = targetUser.getCompanyId();
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
|
|
|
+ CompanyDingding dingding = companyDingdingMapper.selectOne(new LambdaQueryWrapper<CompanyDingding>().eq(CompanyDingding::getCompanyId, companyId));
|
|
|
+
|
|
|
+ //当前用户管理部门
|
|
|
+ List<Department> allDepartmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", targetUser.getCompanyId()));
|
|
|
+ Department[] deptArray = allDepartmentList.toArray(new Department[0]);
|
|
|
+
|
|
|
+ List<Map<String, Object>> list = new ArrayList<>();
|
|
|
+ List<List<String>> allList = null;
|
|
|
+ List<String> sumRow = null;
|
|
|
+
|
|
|
+ List<String> headList = new ArrayList<String>();
|
|
|
+ //headList.add("项目编号");
|
|
|
+ headList.add(MessageUtils.message("entry.projectId"));
|
|
|
+ //headList.add("项目名称");
|
|
|
+ headList.add(MessageUtils.message("entry.projectName"));
|
|
|
+ //headList.add("项目分类");
|
|
|
+ headList.add(MessageUtils.message("entry.projectType"));
|
|
|
+ //headList.add("人员");
|
|
|
+ headList.add(MessageUtils.message("entry.personnel"));
|
|
|
+ //headList.add("部门");
|
|
|
+ headList.add(MessageUtils.message("excel.department"));
|
|
|
+ headList.add("月度总工时(h)");
|
|
|
+ for (int i = 1; i <= daysInMonth; i++) {
|
|
|
+ headList.add(i+"日");
|
|
|
+ }
|
|
|
+
|
|
|
+ allList = new ArrayList<>();
|
|
|
+ allList.add(headList);
|
|
|
+
|
|
|
+ //查询到的前六个字段
|
|
|
+ List<Map<String, Object>> dataList = projectMapper.getTimeCostGroupByProjectUserSumTime(companyId,startDate, endDate);
|
|
|
+ for (Map<String, Object> membMap : dataList) {
|
|
|
+ Department dept = null;
|
|
|
+ Department targetDept = new Department();
|
|
|
+ if (membMap.get("deptId") != null) {
|
|
|
+ targetDept.setDepartmentId(Integer.valueOf(membMap.get("deptId").toString()));
|
|
|
+ int index = Arrays.binarySearch(deptArray, targetDept, Comparator.comparing(Department::getDepartmentId));
|
|
|
+ if (index >= 0) {
|
|
|
+ dept = deptArray[index];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ if(membMap.get("departmentName").equals("未分配")){
|
|
|
+ membMap.put("departmentNameComplete","未分配");
|
|
|
+ }else {
|
|
|
+ membMap.put("departmentNameComplete",departmentService.exportWxDepartment(dept,allDepartmentList));
|
|
|
+ }
|
|
|
+ }else if(dingding!=null&&dingding.getContactNeedTranslate()==1){
|
|
|
+ if(membMap.get("departmentName").equals("未分配")){
|
|
|
+ membMap.put("departmentNameComplete","未分配");
|
|
|
+ }else {
|
|
|
+ membMap.put("departmentNameComplete",departmentService.exportDdDepartment(dept,allDepartmentList));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ membMap.put("departmentNameComplete",departmentService.getSupDepartment(dept,allDepartmentList));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //抽取出来项目编号,项目名称
|
|
|
+ List<Map<String, Object>> uniqueDataList = dataList.stream()
|
|
|
+ .distinct() // 确保唯一性
|
|
|
+ .map(item -> ImmutableMap.of(
|
|
|
+ "id", item.get("id"),
|
|
|
+ "projectCode", item.get("projectCode"),
|
|
|
+ "projectName", item.get("projectName")
|
|
|
+ ))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ //查询项目对应人员填写的每次工时时长
|
|
|
+ List<Map<String, Object>> dataDetailList = projectMapper.getTimeCostProjectUserWorkTime(companyId,startDate, endDate);
|
|
|
+
|
|
|
+
|
|
|
+ for (Map<String, Object> map : uniqueDataList) {
|
|
|
+ //每个项目的统计
|
|
|
+ List<String> rowList = new ArrayList<String>();
|
|
|
+ rowList.add(map.get("projectCode")==null?"":map.get("projectCode").toString());
|
|
|
+ rowList.add(map.get("projectName")==null?"":map.get("projectName").toString());
|
|
|
+ rowList.add("");//项目分类
|
|
|
+ rowList.add("");//人员
|
|
|
+ rowList.add("");//部门
|
|
|
+ double sumCost = dataList.stream().filter(d -> d.get("id").toString().equals(map.get("id").toString()))
|
|
|
+ .mapToDouble(d -> Double.parseDouble(d.get("cost").toString())) // 映射到 cost
|
|
|
+ .sum();// 计算总和
|
|
|
+ rowList.add(sumCost+"");//月度总工时
|
|
|
+ for (int i = 1; i <= daysInMonth; i++) {
|
|
|
+ int finalI = i;
|
|
|
+ double sumDay=0;
|
|
|
+ sumDay = dataDetailList.stream().filter(d -> d.get("id").toString().equals(map.get("id").toString())&&d.get("dayOnly")!=null && d.get("dayOnly").toString().equals("" + finalI))
|
|
|
+ .mapToDouble(d -> Double.parseDouble(d.get("cost").toString())) // 映射到 cost
|
|
|
+ .sum();
|
|
|
+ if (sumDay==0){
|
|
|
+ rowList.add("");//每天填报总工时
|
|
|
+ }else {
|
|
|
+ rowList.add(sumDay+"");//每天的该项目的填报总工时
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ allList.add(rowList);
|
|
|
+
|
|
|
+ //项目下每个员工的记录
|
|
|
+ List<Map<String, Object>> userDataList = dataList.stream().filter(d -> d.get("id").toString().equals(map.get("id").toString())).collect(Collectors.toList());
|
|
|
+ for (Map<String, Object> objectMap : userDataList) {
|
|
|
+ List<String> rowUserList = new ArrayList<String>();
|
|
|
+ rowUserList.add("");//项目编号
|
|
|
+ rowUserList.add("");//项目名称
|
|
|
+ rowUserList.add(objectMap.get("categoryName")==null?"":objectMap.get("categoryName").toString());
|
|
|
+ String name = objectMap.get("name")==null?"":objectMap.get("name").toString();
|
|
|
+ if (wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1) {
|
|
|
+ rowUserList.add("$userName="+name+"$");
|
|
|
+ } else {
|
|
|
+ rowUserList.add(name);
|
|
|
+ }
|
|
|
+
|
|
|
+ rowUserList.add(objectMap.get("departmentNameComplete")==null?"":objectMap.get("departmentNameComplete").toString());
|
|
|
+ rowUserList.add(objectMap.get("cost")==null?"":objectMap.get("cost").toString());
|
|
|
+ for (int i = 1; i <= daysInMonth; i++) {
|
|
|
+ int finalI = i;
|
|
|
+ double sumDay=0;
|
|
|
+ sumDay = dataDetailList.stream().filter(
|
|
|
+ d -> d.get("id").toString().equals(objectMap.get("id").toString())
|
|
|
+ &&d.get("dayOnly")!=null
|
|
|
+ && d.get("dayOnly").toString().equals("" + finalI)
|
|
|
+ && d.get("userId").toString().equals(objectMap.get("userId").toString())
|
|
|
+ )
|
|
|
+ .mapToDouble(d -> Double.parseDouble(d.get("cost").toString())) // 映射到 cost
|
|
|
+ .sum();
|
|
|
+ if (sumDay==0){
|
|
|
+ rowUserList.add("");//每天填报总工时
|
|
|
+ }else {
|
|
|
+ rowUserList.add(sumDay+"");//每天的该项目的填报总工时
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ allList.add(rowUserList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<String> rowEndList = new ArrayList<String>();
|
|
|
+ rowEndList.add("总计");
|
|
|
+ rowEndList.add("");
|
|
|
+ rowEndList.add("");
|
|
|
+ rowEndList.add("");
|
|
|
+ rowEndList.add("");
|
|
|
+ double totalCost = dataList.stream()
|
|
|
+ .mapToDouble(d -> Double.parseDouble(d.get("cost").toString())) // 映射到 cost
|
|
|
+ .sum();
|
|
|
+ rowEndList.add(""+totalCost);//月度总工时
|
|
|
+ for (int i = 1; i <= daysInMonth; i++) {
|
|
|
+ int finalI = i;
|
|
|
+ double sumDay=0;
|
|
|
+ sumDay = dataDetailList.stream().filter(
|
|
|
+ d -> d.get("dayOnly")!=null&& d.get("dayOnly").toString().equals("" + finalI)
|
|
|
+ )
|
|
|
+ .mapToDouble(d -> Double.parseDouble(d.get("cost").toString())) // 映射到 cost
|
|
|
+ .sum();
|
|
|
+ if (sumDay==0){
|
|
|
+ rowEndList.add("");//每天填报总工时
|
|
|
+ }else {
|
|
|
+ rowEndList.add(sumDay+"");//每天填报总工时
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ allList.add(rowEndList);
|
|
|
+
|
|
|
+
|
|
|
+ List<Map<String, Object>> costTimeByUser=projectMapper.getCostTimeByUserSum(companyId,startDate, endDate);
|
|
|
+ List<Map<String, Object>> costTimeByUserForDay=projectMapper.getCostTimeByUserForDay(companyId,startDate, endDate);
|
|
|
+ List<Map<String, Object>> allProjectNew=projectMapper.getTotalProjectByTime(companyId,startDate, endDate);
|
|
|
+ for (Map<String, Object> membMap : costTimeByUser) {
|
|
|
+ Department dept = null;
|
|
|
+ Department targetDept = new Department();
|
|
|
+ if (membMap.get("deptId") != null) {
|
|
|
+ targetDept.setDepartmentId(Integer.valueOf(membMap.get("deptId").toString()));
|
|
|
+ int index = Arrays.binarySearch(deptArray, targetDept, Comparator.comparing(Department::getDepartmentId));
|
|
|
+ if (index >= 0) {
|
|
|
+ dept = deptArray[index];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ if(membMap.get("departmentName").equals("未分配")){
|
|
|
+ membMap.put("departmentNameComplete","未分配");
|
|
|
+ }else {
|
|
|
+ membMap.put("departmentNameComplete",departmentService.exportWxDepartment(dept,allDepartmentList));
|
|
|
+ }
|
|
|
+ }else if(dingding!=null&&dingding.getContactNeedTranslate()==1){
|
|
|
+ if(membMap.get("departmentName").equals("未分配")){
|
|
|
+ membMap.put("departmentNameComplete","未分配");
|
|
|
+ }else {
|
|
|
+ membMap.put("departmentNameComplete",departmentService.exportDdDepartment(dept,allDepartmentList));
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ membMap.put("departmentNameComplete",departmentService.getSupDepartment(dept,allDepartmentList));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<List<String>> secondList = new ArrayList<>();
|
|
|
+ List<String> headsecondList = new ArrayList<String>();
|
|
|
+ headsecondList.add("工号");
|
|
|
+ headsecondList.add("姓名");
|
|
|
+ headsecondList.add("部门");
|
|
|
+ headsecondList.add("月度总工时(h)");
|
|
|
+ headsecondList.add(month+"月");
|
|
|
+ for (int i = 2; i <= daysInMonth; i++) {
|
|
|
+ headsecondList.add("");
|
|
|
+ }
|
|
|
+ headsecondList.add("项目工时分配");
|
|
|
+ if (!allProjectNew.isEmpty()){
|
|
|
+ for (int i = 1; i <= allProjectNew.size()-1; i++) {
|
|
|
+ headsecondList.add("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ secondList.add(headsecondList);
|
|
|
+
|
|
|
+ List<String> headsecondList_new = new ArrayList<String>();
|
|
|
+ headsecondList_new.add("");
|
|
|
+ headsecondList_new.add("");
|
|
|
+ headsecondList_new.add("");
|
|
|
+ headsecondList_new.add("");
|
|
|
+ for (int i = 1; i <= daysInMonth; i++) {
|
|
|
+ headsecondList_new.add(i+"日");
|
|
|
+ }
|
|
|
+ if (!allProjectNew.isEmpty()){
|
|
|
+ for (Map<String, Object> map : allProjectNew) {
|
|
|
+ headsecondList_new.add(map.get("projectName")==null?"":map.get("projectName").toString());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ headsecondList_new.add("");
|
|
|
+ }
|
|
|
+ secondList.add(headsecondList_new);
|
|
|
+
|
|
|
+ if (!costTimeByUser.isEmpty()){
|
|
|
+ for (Map<String, Object> map : costTimeByUser) {
|
|
|
+ List<String> row = new ArrayList<String>();
|
|
|
+ row.add(map.get("jobNumber")==null?"":map.get("jobNumber").toString());
|
|
|
+ if (wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1) {
|
|
|
+ row.add("$userName="+map.get("name").toString()+"$");
|
|
|
+ } else {
|
|
|
+ row.add(map.get("name")==null?"":map.get("name").toString());
|
|
|
+ }
|
|
|
+ row.add(map.get("departmentNameComplete")==null?"":map.get("departmentNameComplete").toString());
|
|
|
+ row.add(map.get("cost")==null?"":map.get("cost").toString());
|
|
|
+ for (int i = 1; i <=daysInMonth; i++) {
|
|
|
+ double sum=0;
|
|
|
+ int finalI = i;
|
|
|
+ sum = costTimeByUserForDay.stream().filter(c -> c.get("userId").toString().equals(map.get("userId").toString())
|
|
|
+ && c.get("dayOnly") != null && c.get("dayOnly").toString().equals(finalI + ""))
|
|
|
+ .mapToDouble(d -> Double.parseDouble(d.get("cost").toString()))
|
|
|
+ .sum();
|
|
|
+ if (sum==0){
|
|
|
+ row.add("");
|
|
|
+ }else {
|
|
|
+ row.add(sum+"");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!allProjectNew.isEmpty()){
|
|
|
+ for (Map<String, Object> objectMap : allProjectNew) {
|
|
|
+ double sum=0;
|
|
|
+ sum = costTimeByUserForDay.stream().filter(c -> c.get("projectId").toString().equals(objectMap.get("projectId").toString())
|
|
|
+ && c.get("userId").toString().equals(map.get("userId").toString()))
|
|
|
+ .mapToDouble(d -> Double.parseDouble(d.get("cost").toString()))
|
|
|
+ .sum();
|
|
|
+ if (sum==0){
|
|
|
+ row.add("");
|
|
|
+ }else {
|
|
|
+ row.add(sum+"");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ row.add("");
|
|
|
+ }
|
|
|
+
|
|
|
+ secondList.add(row);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List[] totalList = new ArrayList[2];
|
|
|
+ totalList[0] = allList;
|
|
|
+ totalList[1] = secondList;
|
|
|
+
|
|
|
+ String[] sheetNames = new String[2];
|
|
|
+ sheetNames[0] = "项目统计表";
|
|
|
+ sheetNames[1] = "人员统计表";
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+// return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,dingding,"月度工时统计表" , allList, path);
|
|
|
+// return excelExportService.exportMultiSheetGeneralExcelByTitleAndList(wxCorpInfo,dingding,"月度工时统计表" , totalList, path,sheetNames);
|
|
|
+ return excelExportService.exportMultiSheetGeneralExcelByTitleAndListNew(wxCorpInfo,dingding,"月度工时统计表" , totalList, path,sheetNames);
|
|
|
+ } catch (NullPointerException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ //httpRespMsg.setError("验证失败");
|
|
|
+ httpRespMsg.setError(MessageUtils.message("access.verificationError"));
|
|
|
+ return httpRespMsg;
|
|
|
+ } catch (Exception exception) {
|
|
|
+ exception.printStackTrace();
|
|
|
+ httpRespMsg.setError(exception.getMessage());
|
|
|
+ }
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+
|
|
|
//获取项目列表
|
|
|
@Override
|
|
|
public HttpRespMsg getProjectList(Integer forReport, String userId, HttpServletRequest request) {
|
|
@@ -626,10 +1052,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
projectVO.setProviderInfoList(mapList);
|
|
|
}
|
|
|
if(companyId==936){
|
|
|
- Optional<ProjectSeparate> first1 = projectSeparateList.stream().filter(ps -> ps.getId().equals(project.getId())).findFirst();
|
|
|
- if(first1.isPresent()){
|
|
|
- projectVO.setProjectSeparate(first1.get());
|
|
|
- }
|
|
|
+ Optional<ProjectSeparate> first1 = projectSeparateList.stream().filter(ps -> ps.getId().equals(project.getId())).findFirst();
|
|
|
+ if(first1.isPresent()){
|
|
|
+ projectVO.setProjectSeparate(first1.get());
|
|
|
+ }
|
|
|
}
|
|
|
//工程专业版:计算当前项目的总进度
|
|
|
if (company.getPackageEngineering() == 1) {
|
|
@@ -1719,7 +2145,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
//导出查询者所在公司每个项目的工时成本,包括项目人员明细统计
|
|
|
@Override
|
|
|
public HttpRespMsg exportTimeCost(Integer withMainProject, String exportContent,String startDate, String endDate,Integer projectId, String userIds,
|
|
|
- Boolean projectSum,Integer type,Integer deptId, Integer stateKey, Integer withPercent,Integer projectCategoryId, HttpServletRequest request) {
|
|
|
+ Boolean projectSum,Integer type,Integer deptId, Integer stateKey, Integer withPercent,Integer projectCategoryId, HttpServletRequest request) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
try {
|
|
|
User targetUser = userMapper.selectById(request.getHeader("Token"));
|
|
@@ -2379,7 +2805,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
ProjectSeparate projectSeparate = projectSeparateMapper.selectById(id);
|
|
|
project.setProjectSeparate(projectSeparate);
|
|
|
}
|
|
|
- //判断当前用户是否是这个项目所属BU的直接或者上级部门负责人(主要或其他负责人)
|
|
|
+ //判断当前用户是否是这个项目所属BU的直接或者上级部门负责人(主要或其他负责人)
|
|
|
String deptCascade = project.getDeptCascade();
|
|
|
if (!StringUtils.isEmpty(deptCascade)) {
|
|
|
if (user.getManageDeptId() > 0) {
|
|
@@ -2404,7 +2830,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- List<ProjectCustom> proCustomList = projectCustomMapper.selectList(new QueryWrapper<ProjectCustom>().eq("company_id", companyId));
|
|
|
+ List<ProjectCustom> proCustomList = projectCustomMapper.selectList(new QueryWrapper<ProjectCustom>().eq("company_id", companyId));
|
|
|
//按顺序存储项目自定义字段 对应plate
|
|
|
HashMap map=new HashMap();
|
|
|
for(int i=0;i<proCustomList.size();i++){
|
|
@@ -2463,7 +2889,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
}
|
|
|
project.setPlateMap(map);
|
|
|
- HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
msg.data = project;
|
|
|
return msg;
|
|
|
}
|
|
@@ -2485,11 +2911,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
project.setEstimatedWorkTime(format);
|
|
|
//todo:计算剩余工时
|
|
|
List<Report> reportList;
|
|
|
- if(project.getManDayStartDate()!=null){
|
|
|
- reportList = reportMapper.selectList(new QueryWrapper<Report>().eq("project_id", project.getId()).gt("create_date",project.getManDayStartDate()).and(wrapper -> wrapper.eq("state", 0).or().eq("state", 1).or().eq("state", 3)));
|
|
|
- }else {
|
|
|
- reportList = reportMapper.selectList(new QueryWrapper<Report>().eq("project_id", project.getId()).and(wrapper -> wrapper.eq("state", 0).or().eq("state", 1).or().eq("state", 3)));
|
|
|
- }
|
|
|
+ if(project.getManDayStartDate()!=null){
|
|
|
+ reportList = reportMapper.selectList(new QueryWrapper<Report>().eq("project_id", project.getId()).gt("create_date",project.getManDayStartDate()).and(wrapper -> wrapper.eq("state", 0).or().eq("state", 1).or().eq("state", 3)));
|
|
|
+ }else {
|
|
|
+ reportList = reportMapper.selectList(new QueryWrapper<Report>().eq("project_id", project.getId()).and(wrapper -> wrapper.eq("state", 0).or().eq("state", 1).or().eq("state", 3)));
|
|
|
+ }
|
|
|
//已发送工时
|
|
|
double sum = reportList.stream().mapToDouble(Report::getWorkingTime).sum();
|
|
|
bigDecimal=bigDecimal.subtract(new BigDecimal(sum));
|
|
@@ -3656,8 +4082,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
parent.text=department.getDepartmentName();
|
|
|
parent.type="";
|
|
|
if(department.getSuperiorId()!=null){
|
|
|
- parent.parent=String.valueOf(department.getSuperiorId());
|
|
|
- parent.type="milestone";
|
|
|
+ parent.parent=String.valueOf(department.getSuperiorId());
|
|
|
+ parent.type="milestone";
|
|
|
}
|
|
|
Set set=new HashSet();
|
|
|
if(set.add(parent.id)){
|
|
@@ -4052,8 +4478,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
List<Integer> inchagerIds=null;
|
|
|
if(functionAllList.size()==0){
|
|
|
if(functionInchargeList.size()>0){
|
|
|
- record = projectMapper.selectWithStage(companyId, null, null, null,user.getId(),startDate,endDate);
|
|
|
- allStageCostList = projectMapper.selectStageSum(projectIds,projectId,user.getId(),startDate,endDate);
|
|
|
+ record = projectMapper.selectWithStage(companyId, null, null, null,user.getId(),startDate,endDate);
|
|
|
+ allStageCostList = projectMapper.selectStageSum(projectIds,projectId,user.getId(),startDate,endDate);
|
|
|
}
|
|
|
}
|
|
|
//获取全部的列
|
|
@@ -5782,7 +6208,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
case "全部":
|
|
|
case "whole":
|
|
|
project.setStatus(0);
|
|
|
- break;
|
|
|
+ break;
|
|
|
case "进行中":
|
|
|
case "on going":
|
|
|
project.setStatus(1);
|
|
@@ -5958,18 +6384,18 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
//兼容中英文逗号
|
|
|
String mainName = mainNameCell.getStringCellValue();
|
|
|
if (mainName != null) {
|
|
|
- if (!StringUtils.isEmpty(mainName)) {
|
|
|
- Optional<ProjectMain> first = projectMainList.stream().filter(pm -> pm.getName().equals(mainName)).findFirst();
|
|
|
- if(first.isPresent()){
|
|
|
- project.setProjectMainId(first.get().getId());
|
|
|
- project.setCategory(first.get().getCategoryId());
|
|
|
- project.setCategoryName(first.get().getCategoryName());
|
|
|
- }else {
|
|
|
- //msg.setError("主项目["+mainName+"]不存在");
|
|
|
- msg.setError(MessageUtils.message("project.masterProjectNull",mainName));
|
|
|
- return msg;
|
|
|
- }
|
|
|
+ if (!StringUtils.isEmpty(mainName)) {
|
|
|
+ Optional<ProjectMain> first = projectMainList.stream().filter(pm -> pm.getName().equals(mainName)).findFirst();
|
|
|
+ if(first.isPresent()){
|
|
|
+ project.setProjectMainId(first.get().getId());
|
|
|
+ project.setCategory(first.get().getCategoryId());
|
|
|
+ project.setCategoryName(first.get().getCategoryName());
|
|
|
+ }else {
|
|
|
+ //msg.setError("主项目["+mainName+"]不存在");
|
|
|
+ msg.setError(MessageUtils.message("project.masterProjectNull",mainName));
|
|
|
+ return msg;
|
|
|
}
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -6012,7 +6438,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
projectSeparate.setProjectCategorySub(projectCategorySubCell.getStringCellValue());
|
|
|
}
|
|
|
if(exists&&check){
|
|
|
- projectSeparateMapper.updateById(projectSeparate);
|
|
|
+ projectSeparateMapper.updateById(projectSeparate);
|
|
|
List<ProjectKeyNodes> nodes = projectKeyNodesMapper.selectList(new QueryWrapper<ProjectKeyNodes>().eq("project_id", id));
|
|
|
for (int x = 0; x < projectKeyNodesSettingList.size(); x++) {
|
|
|
ProjectKeyNodesSetting projectKeyNodesSetting = projectKeyNodesSettingList.get(x);
|
|
@@ -6379,7 +6805,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
for (String str : partSplit) {
|
|
|
String s1;
|
|
|
if(str.startsWith("/")){
|
|
|
- s1=str.substring(1,str.length());
|
|
|
+ s1=str.substring(1,str.length());
|
|
|
}else s1=str;
|
|
|
String s2;
|
|
|
if(s1.endsWith("/")){
|
|
@@ -7203,11 +7629,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
if (inchargerId!=null&&!inchargerId.equals("")) {
|
|
|
Optional<User> incharger = userList.stream().filter(u -> u.getId().equals(inchargerId)).findFirst();
|
|
|
if(incharger.isPresent()){
|
|
|
- if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
- item.add("$userName="+incharger.get().getCorpwxUserid()+"$");
|
|
|
- }else if(dingding!=null&&dingding.getContactNeedTranslate()==1) {
|
|
|
- item.add("$userName="+incharger.get().getDingdingUserid()+"$");
|
|
|
- }
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ item.add("$userName="+incharger.get().getCorpwxUserid()+"$");
|
|
|
+ }else if(dingding!=null&&dingding.getContactNeedTranslate()==1) {
|
|
|
+ item.add("$userName="+incharger.get().getDingdingUserid()+"$");
|
|
|
+ }
|
|
|
}else {
|
|
|
item.add("");
|
|
|
}
|
|
@@ -8482,7 +8908,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
long total = list.size();
|
|
|
List<Map<String, Object>> resultList = null;
|
|
|
if (pageIndex!=null && pageSize!=null){
|
|
|
- resultList = list.stream().skip((pageIndex - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
|
|
|
+ resultList = list.stream().skip((pageIndex - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
|
|
|
}else {
|
|
|
resultList = list;
|
|
|
}
|
|
@@ -8810,10 +9236,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
//根据设置
|
|
|
switch (timeliness){
|
|
|
case 1:createDate=createDate.plusDays(1);
|
|
|
- while(!WorkDayCalculateUtils.isWorkDay(createDate)){
|
|
|
- createDate=createDate.plusDays(1);
|
|
|
- }
|
|
|
- break;
|
|
|
+ while(!WorkDayCalculateUtils.isWorkDay(createDate)){
|
|
|
+ createDate=createDate.plusDays(1);
|
|
|
+ }
|
|
|
+ break;
|
|
|
case 2:
|
|
|
Integer a=0;
|
|
|
while(a!=2){
|
|
@@ -8822,7 +9248,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
a++;
|
|
|
}
|
|
|
}
|
|
|
- break;
|
|
|
+ break;
|
|
|
}
|
|
|
if(createTimeDate.isBefore(createDate)||createTimeDate.isEqual(createDate)){
|
|
|
num++;
|
|
@@ -8837,7 +9263,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
BigDecimal divide;
|
|
|
BigDecimal divideWithLeave;
|
|
|
if(days!=0){
|
|
|
- divide = bigDecimal.divide(BigDecimal.valueOf(days), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ divide = bigDecimal.divide(BigDecimal.valueOf(days), 2, BigDecimal.ROUND_HALF_UP);
|
|
|
}else if(days==0){
|
|
|
divide=new BigDecimal(1);
|
|
|
//查看当天有请假直接算100%
|
|
@@ -9094,11 +9520,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
OperationRecord operationRecord=new OperationRecord();
|
|
|
operationRecord.setModuleName("项目管理")
|
|
|
- .setOperatorName(user.getName())
|
|
|
- .setProjectName(project.getProjectName())
|
|
|
- .setCompanyId(user.getCompanyId())
|
|
|
- .setOperationTime(LocalDateTime.now())
|
|
|
- .setContent("批量添加项目参与人");
|
|
|
+ .setOperatorName(user.getName())
|
|
|
+ .setProjectName(project.getProjectName())
|
|
|
+ .setCompanyId(user.getCompanyId())
|
|
|
+ .setOperationTime(LocalDateTime.now())
|
|
|
+ .setContent("批量添加项目参与人");
|
|
|
operationRecordService.save(operationRecord);
|
|
|
}
|
|
|
participationService.saveBatch(list);
|
|
@@ -9123,7 +9549,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
return new HttpRespMsg();
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
+ @Override
|
|
|
public HttpRespMsg getUserWorkingTimeStatic(String startDate, String endDate, Integer pageIndex, Integer pageSize, HttpServletRequest request,String userId,Integer departmentId) {
|
|
|
HttpRespMsg httpRespMsg =new HttpRespMsg();
|
|
|
DecimalFormat dft = new DecimalFormat("0%");
|
|
@@ -9237,7 +9663,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
|
|
|
|
|
|
|
|
|
- @Override
|
|
|
+ @Override
|
|
|
public HttpRespMsg batchDeleteProject(String projectIdArray, HttpServletRequest request) {
|
|
|
String token = request.getHeader("TOKEN");
|
|
|
User user = userMapper.selectById(token);
|
|
@@ -10035,44 +10461,44 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
//msg.data = "成功导入" + importCount + "条数据。";
|
|
|
msg.data = MessageUtils.message("data.importSucRow",importCount);
|
|
|
}catch(IOException e){
|
|
|
- e.printStackTrace();
|
|
|
- //msg.setError("文件处理出错");
|
|
|
- msg.setError(MessageUtils.message("file.error"));
|
|
|
- return msg;
|
|
|
- } catch(NullPointerException e){
|
|
|
- e.printStackTrace();
|
|
|
- //msg.setError("数据格式有误或存在空数据 导入失败");
|
|
|
- msg.setError(MessageUtils.message("file.dataFormatError"));
|
|
|
- return msg;
|
|
|
- }catch(InvalidFormatException e){
|
|
|
- e.printStackTrace();
|
|
|
- //msg.setError("文件格式错误,如果安装了加密软件需要先解密再上传");
|
|
|
- msg.setError(MessageUtils.message("file.FormatErrorAndDecrypt"));
|
|
|
- }catch(EncryptedDocumentException e){
|
|
|
- e.printStackTrace();
|
|
|
- //msg.setError("文件加密状态,需要先解除加密状态再上传");
|
|
|
- msg.setError(MessageUtils.message("file.encryption"));
|
|
|
- return msg;
|
|
|
- } catch(Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- //msg.setError("上传失败:" + e.getMessage());
|
|
|
- msg.setError(MessageUtils.message("file.uploadError",e.getMessage()));
|
|
|
- return msg;
|
|
|
- } finally{
|
|
|
- //关闭流
|
|
|
- try {
|
|
|
- if (outputStream != null && inputStream != null) {
|
|
|
- outputStream.close();
|
|
|
- inputStream.close();
|
|
|
- System.out.println("流已关闭");
|
|
|
- }
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ e.printStackTrace();
|
|
|
+ //msg.setError("文件处理出错");
|
|
|
+ msg.setError(MessageUtils.message("file.error"));
|
|
|
+ return msg;
|
|
|
+ } catch(NullPointerException e){
|
|
|
+ e.printStackTrace();
|
|
|
+ //msg.setError("数据格式有误或存在空数据 导入失败");
|
|
|
+ msg.setError(MessageUtils.message("file.dataFormatError"));
|
|
|
+ return msg;
|
|
|
+ }catch(InvalidFormatException e){
|
|
|
+ e.printStackTrace();
|
|
|
+ //msg.setError("文件格式错误,如果安装了加密软件需要先解密再上传");
|
|
|
+ msg.setError(MessageUtils.message("file.FormatErrorAndDecrypt"));
|
|
|
+ }catch(EncryptedDocumentException e){
|
|
|
+ e.printStackTrace();
|
|
|
+ //msg.setError("文件加密状态,需要先解除加密状态再上传");
|
|
|
+ msg.setError(MessageUtils.message("file.encryption"));
|
|
|
+ return msg;
|
|
|
+ } catch(Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ //msg.setError("上传失败:" + e.getMessage());
|
|
|
+ msg.setError(MessageUtils.message("file.uploadError",e.getMessage()));
|
|
|
+ return msg;
|
|
|
+ } finally{
|
|
|
+ //关闭流
|
|
|
+ try {
|
|
|
+ if (outputStream != null && inputStream != null) {
|
|
|
+ outputStream.close();
|
|
|
+ inputStream.close();
|
|
|
+ System.out.println("流已关闭");
|
|
|
}
|
|
|
-// file.deleteOnExit();//程序退出时删除临时文件
|
|
|
- System.out.println(file.delete());
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- return msg;
|
|
|
+// file.deleteOnExit();//程序退出时删除临时文件
|
|
|
+ System.out.println(file.delete());
|
|
|
+ }
|
|
|
+ return msg;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -12119,9 +12545,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
itemList=new ArrayList<>();
|
|
|
}
|
|
|
for (GanttDataItem ganttDataItem : itemList) {
|
|
|
- if(ganttDataItem.getId().equals(userGantt.parent)){
|
|
|
- ganttDataItem.children.add(userGantt);
|
|
|
- }
|
|
|
+ if(ganttDataItem.getId().equals(userGantt.parent)){
|
|
|
+ ganttDataItem.children.add(userGantt);
|
|
|
+ }
|
|
|
getUserGanttDataItemList(userGantt,ganttDataItem.children);
|
|
|
}
|
|
|
return itemList;
|
|
@@ -14342,7 +14768,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
String fileName = "项目耗用进度表_"+System.currentTimeMillis();
|
|
|
try {
|
|
|
- return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,dingding,fileName , dataList, path);
|
|
|
+ return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,dingding,fileName , dataList, path);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|