|
@@ -2058,27 +2058,58 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
for (Map<String, Object> map : mapList) {
|
|
|
curUserTotalTime += (Double)map.get("cost");
|
|
|
}
|
|
|
+ //计算占比,并进行四舍五入造成的误差进行修正
|
|
|
+ if (withPercent == 1) {
|
|
|
+ for (Map<String, Object> map : mapList) {
|
|
|
+ double cost = (Double)map.get("cost");
|
|
|
+ if (curUserTotalTime > 0) {
|
|
|
+ map.put("percent", new BigDecimal(cost/curUserTotalTime*100).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
+ } else {
|
|
|
+ map.put("percent", 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (curUserTotalTime > 0) {
|
|
|
+ //修正误差
|
|
|
+ BigDecimal totalPercent = new BigDecimal(0.0);
|
|
|
+ for (Map<String, Object> map : mapList) {
|
|
|
+ totalPercent = totalPercent.add((BigDecimal)map.get("percent"));
|
|
|
+ }
|
|
|
+ if (totalPercent.doubleValue() != 100) {
|
|
|
+ //取最后一条数据,修正偏差
|
|
|
+ int last = mapList.size() - 1;
|
|
|
+ BigDecimal lastPercent = (BigDecimal)mapList.get(last).get("percent");
|
|
|
+ mapList.get(last).put("percent", lastPercent.add(new BigDecimal(100).subtract(totalPercent)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
for(Object i:projectIds){
|
|
|
List<Map<String, Object>> resultList = mapList.stream().filter(mp -> mp.get("projectId").equals(i)).collect(Collectors.toList());
|
|
|
if(resultList.size()>0){
|
|
|
+ Map<String, Object> resultItem = resultList.get(0);
|
|
|
if ("hours".equals(exportContent) && functionTimeList.size()>0){
|
|
|
- membRowData.add(String.valueOf(resultList.get(0).get("cost")));
|
|
|
+ membRowData.add(String.valueOf(resultItem.get("cost")));
|
|
|
}else if ("cost".equals(exportContent) && functionCostList.size()>0){
|
|
|
- membRowData.add(String.valueOf(resultList.get(0).get("costMoney")));
|
|
|
+ membRowData.add(String.valueOf(resultItem.get("costMoney")));
|
|
|
}else {
|
|
|
if(functionTimeList.size()>0){
|
|
|
- membRowData.add(String.valueOf(resultList.get(0).get("cost")));
|
|
|
+ membRowData.add(String.valueOf(resultItem.get("cost")));
|
|
|
}
|
|
|
if (functionCostList.size()>0){
|
|
|
- membRowData.add(String.valueOf(resultList.get(0).get("costMoney")));
|
|
|
+ membRowData.add(String.valueOf(resultItem.get("costMoney")));
|
|
|
}
|
|
|
}
|
|
|
if (withPercent == 1) {
|
|
|
//工时占比
|
|
|
- membRowData.add(String.valueOf(new BigDecimal((Double)resultList.get(0).get("cost")/curUserTotalTime*100).setScale(2, BigDecimal.ROUND_HALF_UP))+"%");
|
|
|
+ if (resultItem.get("percent") != null) {
|
|
|
+ membRowData.add((BigDecimal)resultItem.get("percent")+"%");
|
|
|
+ } else {
|
|
|
+ membRowData.add("0");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
costTime += (Double)resultList.get(0).get("cost");
|
|
|
- moneyCost = moneyCost.add((BigDecimal)resultList.get(0).get("costMoney"));
|
|
|
+ moneyCost = moneyCost.add((BigDecimal)resultItem.get("costMoney"));
|
|
|
}else{
|
|
|
if ("hours".equals(exportContent) && functionTimeList.size()>0){
|
|
|
membRowData.add("0");
|
|
@@ -2098,7 +2129,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
if ("hours".equals(exportContent) && functionTimeList.size()>0){
|
|
|
membRowData.add(""+new BigDecimal(costTime).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
}else if ("cost".equals(exportContent) && functionCostList.size()>0){
|