|
@@ -1752,12 +1752,20 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
@Override
|
|
|
public HttpRespMsg getProjectStagesCost(Integer pageIndex, Integer pageSize, HttpServletRequest request) {
|
|
|
String token = request.getHeader("TOKEN");
|
|
|
- Integer companyId = userMapper.selectById(token).getCompanyId();
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
+ Integer companyId = user.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<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看阶段成本");
|
|
|
+ if (functionList.size() == 0) {
|
|
|
+ //去掉成本
|
|
|
+ record.forEach(re->{
|
|
|
+ re.getStageCostList().forEach(s->s.cost = 0.0);
|
|
|
+ });
|
|
|
+ }
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
map.put("records", record);
|
|
|
map.put("total", total);
|
|
@@ -1778,7 +1786,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
@Override
|
|
|
public HttpRespMsg exportProjectStagesCost(HttpServletRequest request) {
|
|
|
String token = request.getHeader("TOKEN");
|
|
|
- Integer companyId = userMapper.selectById(token).getCompanyId();
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
+ Integer companyId = user.getCompanyId();
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
List<ProjectWithStage> record = projectMapper.selectWithStage(companyId, null, null);
|
|
|
//获取全部的列
|
|
@@ -1791,6 +1800,14 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
titleList.addAll(stageList);
|
|
|
List<List<String>> dataList = new ArrayList<>();
|
|
|
dataList.add(titleList);
|
|
|
+ List<SysRichFunction> functionList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "查看阶段成本");
|
|
|
+ if (functionList.size() == 0) {
|
|
|
+ //去掉成本
|
|
|
+ record.forEach(re->{
|
|
|
+ re.getStageCostList().forEach(s->s.cost = 0.0);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("#0.0");
|
|
|
//加完标题再增加数据行
|
|
|
record.forEach(r->{
|
|
|
List<String> data = new ArrayList<>();
|
|
@@ -1802,9 +1819,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
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+"");
|
|
|
+ data.add(decimalFormat.format(first.get().workingTime)+(functionList.size() == 0?"":("h/¥"+decimalFormat.format(first.get().cost))));
|
|
|
} else {
|
|
|
- data.add("0");
|
|
|
+ data.add("0h"+(functionList.size() == 0?"":"/¥0.0"));
|
|
|
}
|
|
|
}
|
|
|
dataList.add(data);
|