|
@@ -7,9 +7,7 @@ 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.management.platform.entity.*;
|
|
|
-import com.management.platform.entity.vo.CustomerProject;
|
|
|
-import com.management.platform.entity.vo.GanttDataItem;
|
|
|
-import com.management.platform.entity.vo.ProjectVO;
|
|
|
+import com.management.platform.entity.vo.*;
|
|
|
import com.management.platform.mapper.*;
|
|
|
import com.management.platform.service.ProjectNotifyUserService;
|
|
|
import com.management.platform.service.ProjectService;
|
|
@@ -39,6 +37,7 @@ import java.time.LocalDate;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -80,6 +79,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
@Resource
|
|
|
CompanyMapper companyMapper;
|
|
|
@Resource
|
|
|
+ StagesMapper stagesMapper;
|
|
|
+ @Resource
|
|
|
private HttpServletResponse response;
|
|
|
|
|
|
@Value(value = "${upload.path}")
|
|
@@ -92,7 +93,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
User user = userMapper.selectById(request.getHeader("Token"));
|
|
|
if (user.getRole() == 0) {
|
|
|
//普通员工只能看本人相关的项目列表
|
|
|
- httpRespMsg.data = projectMapper.getParticipatedProject(user.getId());
|
|
|
+ httpRespMsg.data = projectMapper.getParticipatedProject(user.getId(), user.getCompanyId());
|
|
|
} else {
|
|
|
//其他的管理员,都可以看全部的
|
|
|
httpRespMsg.data = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", user.getCompanyId()));
|
|
@@ -675,6 +676,36 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getCostInStage(String startDate, String endDate, Integer projectId, HttpServletRequest request) {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ try {
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
|
|
|
+ //首先查看有无浏览权限
|
|
|
+ if (!projectMapper.selectById(projectId).getCompanyId().equals(companyId)) {
|
|
|
+ httpRespMsg.setError("无权查看其他公司的项目详情");
|
|
|
+ } else {
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ List<Map<String, Object>> list = projectMapper.getCostInStage(startDate, endDate, projectId);
|
|
|
+ BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
+ if (!map.containsKey("costMoney")) {
|
|
|
+ map.put("costMoney", 0);
|
|
|
+ } else {
|
|
|
+ totalMoneyCost = totalMoneyCost.add((BigDecimal)map.get("costMoney"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resultMap.put("costList", list);
|
|
|
+ resultMap.put("totalMoneyCost", totalMoneyCost);
|
|
|
+ httpRespMsg.data = resultMap;
|
|
|
+ }
|
|
|
+ } catch (NullPointerException e) {
|
|
|
+ httpRespMsg.setError("验证失败");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+
|
|
|
//获取人员工时成本,可指定项目
|
|
|
@Override
|
|
|
public HttpRespMsg getAllMembCost(String startDate, String endDate, Integer projectId, HttpServletRequest request) {
|
|
@@ -1115,6 +1146,68 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getProjectStagesCost(Integer pageIndex, Integer pageSize, HttpServletRequest request) {
|
|
|
+ String token = request.getHeader("TOKEN");
|
|
|
+ Integer companyId = userMapper.selectById(token).getCompanyId();
|
|
|
+ int startIndex = (pageIndex-1)*pageSize;
|
|
|
+ int endIndex = pageSize*pageIndex;
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ Integer total = projectMapper.selectCount(new QueryWrapper<Project>().eq("company_id", companyId));
|
|
|
+ List<ProjectWithStage> record = projectMapper.selectWithStage(companyId, startIndex, endIndex);
|
|
|
+ //获取全部的列
|
|
|
+ List<Integer> collect = record.stream().map(ProjectWithStage::getId).collect(Collectors.toList());
|
|
|
+ List<Stages> stagesList = stagesMapper.selectList(new QueryWrapper<Stages>().in("project_id", collect));
|
|
|
+ List<String> stageList = stagesList.stream().map(Stages::getStagesName).distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ map.put("records", record);
|
|
|
+ map.put("total", total);
|
|
|
+ map.put("stages", stageList);
|
|
|
+ msg.data = map;
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg exportProjectStagesCost(HttpServletRequest request) {
|
|
|
+ String token = request.getHeader("TOKEN");
|
|
|
+ Integer companyId = userMapper.selectById(token).getCompanyId();
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ List<ProjectWithStage> record = projectMapper.selectWithStage(companyId, null, null);
|
|
|
+ //获取全部的列
|
|
|
+ List<Integer> collect = record.stream().map(ProjectWithStage::getId).collect(Collectors.toList());
|
|
|
+ List<Stages> stagesList = stagesMapper.selectList(new QueryWrapper<Stages>().select("distinct stages_name").in("project_id", collect));
|
|
|
+ List<String> stageList = stagesList.stream().map(Stages::getStagesName).distinct().collect(Collectors.toList());
|
|
|
+ List<String> titleList = new ArrayList<>();
|
|
|
+ titleList.add("项目编号");
|
|
|
+ titleList.add("项目名称");
|
|
|
+ titleList.addAll(stageList);
|
|
|
+ List<List<String>> dataList = new ArrayList<>();
|
|
|
+ dataList.add(titleList);
|
|
|
+ //加完标题再增加数据行
|
|
|
+ record.forEach(r->{
|
|
|
+ List<String> data = new ArrayList<>();
|
|
|
+ data.add(r.projectCode);
|
|
|
+ data.add(r.projectName);
|
|
|
+ for (int i=0;i<stageList.size(); i++) {
|
|
|
+ String curStage = stageList.get(i);
|
|
|
+ //找匹配的记录
|
|
|
+ List<StageCost> stageCostList = r.stageCostList;
|
|
|
+ Optional<StageCost> first = stageCostList.stream().filter(s -> s.stageName.equals(curStage)).findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ data.add(first.get().workingTime+"");
|
|
|
+ } else {
|
|
|
+ data.add("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dataList.add(data);
|
|
|
+ });
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ String fileName = "项目阶段工时报表_"+System.currentTimeMillis();
|
|
|
+ ExcelUtil.exportGeneralExcelByTitleAndList(fileName, dataList, path);
|
|
|
+ httpRespMsg.data = pathPrefix + fileName+".xls";
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -1160,7 +1253,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
if (ExcelUtil.isRowEmpty(row)) {
|
|
|
continue;
|
|
|
}
|
|
|
- System.out.println("当前行="+rowIndex);
|
|
|
//项目编号 项目名称 参与人 负责人 级别 开始日期 截止日期 合同金额
|
|
|
XSSFCell codeCell = row.getCell(0);
|
|
|
XSSFCell nameCell = row.getCell(1);
|
|
@@ -1170,7 +1262,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
XSSFCell startDateCell = row.getCell(5);
|
|
|
XSSFCell endDateCell = row.getCell(6);
|
|
|
XSSFCell amountCell = row.getCell(7);
|
|
|
-
|
|
|
+ XSSFCell isPublicCell = row.getCell(8);
|
|
|
|
|
|
if (codeCell != null)codeCell.setCellType(CellType.STRING);
|
|
|
if (nameCell != null)nameCell.setCellType(CellType.STRING);
|
|
@@ -1180,6 +1272,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
if (startDateCell != null)startDateCell.setCellType(CellType.NUMERIC);
|
|
|
if (endDateCell != null)endDateCell.setCellType(CellType.NUMERIC);
|
|
|
if (amountCell != null)amountCell.setCellType(CellType.STRING);
|
|
|
+ if (isPublicCell != null)isPublicCell.setCellType(CellType.STRING);
|
|
|
if (nameCell == null) {//项目名称为空的直接跳过
|
|
|
throw new Exception("项目名称不能为空");
|
|
|
}
|
|
@@ -1238,7 +1331,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
if (amountCell !=null && !StringUtils.isEmpty(amountCell.getStringCellValue())) {
|
|
|
project.setContractAmount(Double.parseDouble(amountCell.getStringCellValue()));
|
|
|
}
|
|
|
-
|
|
|
+ if (isPublicCell != null && !StringUtils.isEmpty(isPublicCell.getStringCellValue())) {
|
|
|
+ project.setIsPublic("是".equals(isPublicCell.getStringCellValue())?1:0);
|
|
|
+ }
|
|
|
projectMapper.insert(project);
|
|
|
//参与人
|
|
|
if (participatorCell != null) {
|