|
@@ -2271,6 +2271,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
inchagerIds.add(-1);
|
|
|
}
|
|
|
}
|
|
|
+ //获取表头
|
|
|
+ List<ExpenseMainType> mainTypeList = expenseMainTypeMapper.selectList(new QueryWrapper<ExpenseMainType>().eq("company_id", companyId));
|
|
|
+
|
|
|
//撤销的项目不算
|
|
|
QueryWrapper<Project> queryWrapper = new QueryWrapper<Project>().eq("company_id", companyId);
|
|
|
queryWrapper.and(wrapper->wrapper.isNull("status").or().ne("status", 3));
|
|
@@ -2279,7 +2282,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
int total = projectMapper.selectCount(queryWrapper);
|
|
|
int pageStart = (pageIndex -1) * pageSize;
|
|
|
- System.out.println("companyId="+companyId+", pageStart="+pageStart+", pageSize="+pageSize);
|
|
|
List<Map<String, Object>> projectTask = projectMapper.getAllProjectCost(companyId, pageStart, pageSize, projectId, inchagerIds);
|
|
|
List<Integer> projectIdCollect = projectTask.stream().map(pt -> Integer.valueOf(String.valueOf(pt.get("id")))).distinct().collect(Collectors.toList());
|
|
|
projectIdCollect.add(-1);
|
|
@@ -2303,6 +2305,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
bigDecimal=bigDecimal.add(new BigDecimal(sum));
|
|
|
}
|
|
|
map.put("costDetail",itemList);
|
|
|
+ bigDecimal = bigDecimal.add(new BigDecimal(map.get("feeMan").toString()));
|
|
|
double totalFee = bigDecimal.doubleValue();
|
|
|
//totalFee保留小数点后两位
|
|
|
totalFee = Double.parseDouble(df.format(totalFee));
|
|
@@ -2378,10 +2381,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
data.add(String.valueOf(sum));
|
|
|
bigDecimal=bigDecimal.add(new BigDecimal(sum));
|
|
|
}
|
|
|
+ bigDecimal = bigDecimal.add(new BigDecimal(item.get("feeMan").toString()));
|
|
|
double totalFee = bigDecimal.doubleValue();
|
|
|
//totalFee保留小数点后两位
|
|
|
totalFee = Double.parseDouble(df.format(totalFee));
|
|
|
- data.add(totalFee+"");
|
|
|
+ data.add(totalFee +"");
|
|
|
exportList.add(data);
|
|
|
}
|
|
|
//String fileName = "项目成本报表_"+System.currentTimeMillis();
|
|
@@ -2416,6 +2420,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
inchagerIds.add(-1);
|
|
|
}
|
|
|
}
|
|
|
+ //获取表头
|
|
|
+ List<ExpenseMainType> mainTypeList = expenseMainTypeMapper.selectList(new QueryWrapper<ExpenseMainType>().eq("company_id", companyId));
|
|
|
+
|
|
|
//撤销的项目不算
|
|
|
QueryWrapper<Project> queryWrapper = new QueryWrapper<Project>().eq("company_id", companyId);
|
|
|
queryWrapper.and(wrapper->wrapper.isNull("status").or().ne("status", 3));
|
|
@@ -2424,10 +2431,21 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
int total = projectMapper.selectCount(queryWrapper);
|
|
|
int pageStart = (pageIndex -1) * pageSize;
|
|
|
- List projectTask = projectMapper.getProjectInAndOut(companyId, pageStart, pageSize, projectId,inchagerIds);
|
|
|
+ List<Project> projectTask = projectMapper.getProjectInAndOut(companyId, pageStart, pageSize, projectId,inchagerIds);
|
|
|
+ List<Integer> collect = projectTask.stream().map(Project::getId).collect(Collectors.toList());
|
|
|
+ if (collect.size() > 0) {
|
|
|
+ List<Map<String, Object>> projectExpenseFee = projectMapper.getProjectExpenseFee(companyId, collect);
|
|
|
+ projectTask.forEach(p->{
|
|
|
+ p.setProjectExpenseFeeList(projectExpenseFee.stream().filter(pef->pef.get("projectId").equals(p.getId())).collect(Collectors.toList()));
|
|
|
+ double amount = p.getProjectExpenseFeeList().stream().mapToDouble(pef -> Double.parseDouble(pef.get("amount").toString())).sum();
|
|
|
+ p.setBudget(amount + (p.getFeeMan()==null?0:p.getFeeMan()));
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("records", projectTask);
|
|
|
+ map.put("mainTypeList", mainTypeList);
|
|
|
map.put("total", total);
|
|
|
httpRespMsg.data = map;
|
|
|
return httpRespMsg;
|
|
@@ -2459,6 +2477,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
//通过公司id获取该公司所有的项目列表
|
|
|
User user = userMapper.selectById(request.getHeader("Token"));
|
|
|
Integer companyId = user.getCompanyId();
|
|
|
+ Company company = companyMapper.selectById(companyId);
|
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
|
|
|
List<Project> projectAllList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId));
|
|
|
List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "全部项目任务报表");
|
|
@@ -2477,29 +2496,81 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
inchagerIds.add(-1);
|
|
|
}
|
|
|
}
|
|
|
- QueryWrapper<Project> queryWrapper = new QueryWrapper<Project>().eq("company_id", companyId);
|
|
|
+ //获取表头
|
|
|
+ List<ExpenseMainType> mainTypeList = expenseMainTypeMapper.selectList(new QueryWrapper<ExpenseMainType>().eq("company_id", companyId));
|
|
|
List<Project> projectList = projectMapper.getProjectInAndOut(companyId, null, null, null,inchagerIds);
|
|
|
+ List<Integer> collect = projectList.stream().map(Project::getId).collect(Collectors.toList());
|
|
|
+ if (collect.size() > 0) {
|
|
|
+ List<Map<String, Object>> projectExpenseFee = projectMapper.getProjectExpenseFee(companyId, collect);
|
|
|
+ projectList.forEach(p->{
|
|
|
+ p.setProjectExpenseFeeList(projectExpenseFee.stream().filter(pef->pef.get("projectId").equals(p.getId())).collect(Collectors.toList()));
|
|
|
+ double amount = p.getProjectExpenseFeeList().stream().mapToDouble(pef -> Double.parseDouble(pef.get("amount").toString())).sum();
|
|
|
+ p.setBudget(amount + (p.getFeeMan()==null?0:p.getFeeMan()));
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
List<List<String>> exportList = new ArrayList<>();
|
|
|
- //String[] titles = {"项目编号", "项目名称", "合同金额", "人工成本", "一般费用", "差旅费用","外包费用", "总费用", "利润", "利润率"};
|
|
|
- String[] titles = {MessageUtils.message("entry.projectId"), MessageUtils.message("entry.projectName"), MessageUtils.message("entry.contract"), MessageUtils.message("entry.laborCost"), MessageUtils.message("excel.genExp"), MessageUtils.message("excel.traExp"),MessageUtils.message("excel.OutExp"), MessageUtils.message("excel.totalExp"), MessageUtils.message("excel.profit"), MessageUtils.message("excel.profitMargin")};
|
|
|
+ //String[] titles = {"项目编号", "项目名称", "合同金额", "人工成本", "自定义费用类型"...};
|
|
|
+ String[] titles = {MessageUtils.message("entry.projectId"), MessageUtils.message("entry.projectName"), MessageUtils.message("entry.contract")};
|
|
|
+ ArrayList<String> strings = Lists.newArrayList(titles);
|
|
|
+ if (company.getPackageContract() == 1) {
|
|
|
+ strings.add("已回款金额");
|
|
|
+ }
|
|
|
+ strings.add(MessageUtils.message("entry.laborCost"));
|
|
|
+ mainTypeList.forEach(m->{
|
|
|
+ strings.add(m.getName());
|
|
|
+ });
|
|
|
+ strings.add(MessageUtils.message("excel.totalExp"));
|
|
|
+ if (company.getPackageContract() == 1) {
|
|
|
+ strings.add("已回款利润");
|
|
|
+ strings.add("已回款利润率");
|
|
|
+ }
|
|
|
+ strings.add(MessageUtils.message("excel.profit"));
|
|
|
+ strings.add(MessageUtils.message("excel.profitMargin"));
|
|
|
+ titles = strings.toArray(new String[0]);
|
|
|
+
|
|
|
exportList.add(Lists.list(titles));
|
|
|
for (Project project : projectList) {
|
|
|
List<String> data = new ArrayList<>();
|
|
|
data.add(project.getProjectCode());
|
|
|
data.add(project.getProjectName());
|
|
|
data.add(project.getContractAmount() != null?project.getContractAmount().toString():"");
|
|
|
+ if (company.getPackageContract() == 1) {
|
|
|
+ data.add(project.getPayment() != null?project.getPayment().toString():"");
|
|
|
+ }
|
|
|
data.add(project.getFeeMan().toString());
|
|
|
- data.add(project.getFeeNormal().toString());
|
|
|
- data.add(project.getFeeTravel().toString());
|
|
|
- data.add(project.getFeeOutsourcing().toString());
|
|
|
- double totalFee = project.getFeeMan() + project.getFeeNormal()+ project.getFeeTravel()+ project.getFeeOutsourcing();
|
|
|
- data.add(totalFee+"");
|
|
|
+ for (ExpenseMainType mainType : mainTypeList) {
|
|
|
+ if (project.getProjectExpenseFeeList() != null) {
|
|
|
+ Optional<Map<String, Object>> first = project.getProjectExpenseFeeList().stream().filter(pef -> pef.get("typeId").equals(mainType.getId())).findFirst();
|
|
|
+ if (first.isPresent()) {
|
|
|
+ data.add(first.get().get("amount").toString());
|
|
|
+ } else {
|
|
|
+ data.add("");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ data.add("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ double totalFee = project.getBudget();
|
|
|
+ data.add(new java.text.DecimalFormat("#0.00").format(totalFee));
|
|
|
+ if (company.getPackageContract() == 1) {
|
|
|
+ //已回款利润
|
|
|
+ double profitPayment = project.getPayment().doubleValue() - totalFee;
|
|
|
+ double profitRate = profitPayment / project.getPayment().doubleValue();
|
|
|
+ data.add(new java.text.DecimalFormat("#0.00").format(profitPayment));
|
|
|
+ if (profitRate > 0) {
|
|
|
+ data.add(new java.text.DecimalFormat("#0.0").format(100*profitRate)+"%");
|
|
|
+ } else {
|
|
|
+ data.add("-");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (project.getContractAmount() != null && project.getContractAmount() > 0) {
|
|
|
double profitAmt = project.getContractAmount() - totalFee;
|
|
|
data.add(profitAmt+"");
|
|
|
data.add(new java.text.DecimalFormat("#0.0").format((100*profitAmt/project.getContractAmount()))+"%");
|
|
|
} else {
|
|
|
- double profitAmt = -totalFee;
|
|
|
+ double profitAmt = 0 -totalFee;
|
|
|
data.add(profitAmt+"");
|
|
|
data.add("");
|
|
|
}
|
|
@@ -2535,10 +2606,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
data.add("");
|
|
|
data.add(project.getContractAmount() != null?project.getContractAmount().toString():"");
|
|
|
data.add(project.getFeeMan().toString());
|
|
|
- data.add(project.getFeeNormal().toString());
|
|
|
- data.add(project.getFeeTravel().toString());
|
|
|
- data.add(project.getFeeOutsourcing().toString());
|
|
|
- double totalFee = project.getFeeMan() + project.getFeeNormal()+ project.getFeeTravel()+ project.getFeeOutsourcing();
|
|
|
+// data.add(project.getFeeNormal().toString());
|
|
|
+// data.add(project.getFeeTravel().toString());
|
|
|
+// data.add(project.getFeeOutsourcing().toString());
|
|
|
+ double totalFee = project.getFeeMan();
|
|
|
data.add(totalFee+"");
|
|
|
if (project.getContractAmount() != null && project.getContractAmount() > 0) {
|
|
|
double profitAmt = project.getContractAmount() - totalFee;
|
|
@@ -2560,10 +2631,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
dataChild.add(child.getProjectNames());
|
|
|
dataChild.add(child.getContractAmount() != null?child.getContractAmount().toString():"");
|
|
|
dataChild.add(child.getFeeMan().toString());
|
|
|
- dataChild.add(child.getFeeNormal().toString());
|
|
|
- dataChild.add(child.getFeeTravel().toString());
|
|
|
- dataChild.add(child.getFeeOutsourcing().toString());
|
|
|
- double totalFeeChild = child.getFeeMan() + child.getFeeNormal()+ child.getFeeTravel()+ child.getFeeOutsourcing();
|
|
|
+// dataChild.add(child.getFeeNormal().toString());
|
|
|
+// dataChild.add(child.getFeeTravel().toString());
|
|
|
+// dataChild.add(child.getFeeOutsourcing().toString());
|
|
|
+ double totalFeeChild = child.getFeeMan();
|
|
|
dataChild.add(totalFeeChild+"");
|
|
|
if (child.getContractAmount() != null && child.getContractAmount() > 0) {
|
|
|
double profitAmt = child.getContractAmount() - totalFeeChild;
|