|
@@ -52,6 +52,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
import java.io.*;
|
|
import java.io.*;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
|
|
+import java.net.URLDecoder;
|
|
import java.sql.Timestamp;
|
|
import java.sql.Timestamp;
|
|
import java.text.*;
|
|
import java.text.*;
|
|
import java.time.*;
|
|
import java.time.*;
|
|
@@ -14899,8 +14900,15 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 从map中获取Double值,如果键不存在则返回0.0
|
|
|
|
+ private static double getDoubleValue(Map<String, Object> map, String key) {
|
|
|
|
+ return Optional.ofNullable(map.get(key))
|
|
|
|
+ .filter(Double.class::isInstance)
|
|
|
|
+ .map(Double.class::cast)
|
|
|
|
+ .orElse(0.0);
|
|
|
|
+ }
|
|
@Override
|
|
@Override
|
|
- public HttpRespMsg exportGroupExpendProcessListForUser(String startDate, String endDate, String projectIds, String groupNames,String titleStr, String deptIdStr) {
|
|
|
|
|
|
+ public HttpRespMsg exportGroupExpendProcessListForUser(String startDate, String endDate, String projectIds, String groupNames,String titleStr, String deptIdStr) throws UnsupportedEncodingException {
|
|
User user = userMapper.selectById(request.getHeader("token"));
|
|
User user = userMapper.selectById(request.getHeader("token"));
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new LambdaQueryWrapper<WxCorpInfo>().eq(WxCorpInfo::getCompanyId, user.getCompanyId()));
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new LambdaQueryWrapper<WxCorpInfo>().eq(WxCorpInfo::getCompanyId, user.getCompanyId()));
|
|
List<List<String>> dataList=new ArrayList<>();
|
|
List<List<String>> dataList=new ArrayList<>();
|
|
@@ -14908,8 +14916,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
titleList.add("所属部门");
|
|
titleList.add("所属部门");
|
|
titleList.add("工号");
|
|
titleList.add("工号");
|
|
titleList.add("员工");
|
|
titleList.add("员工");
|
|
|
|
+ List<String> strings=new ArrayList<>();
|
|
if(!StringUtils.isEmpty(titleStr)){
|
|
if(!StringUtils.isEmpty(titleStr)){
|
|
- List<String> strings = Arrays.asList(titleStr.split(","));
|
|
|
|
|
|
+ // 解码
|
|
|
|
+ String decodedString = URLDecoder.decode(titleStr, "UTF-8");
|
|
|
|
+ System.out.println("Decoded String: " + decodedString);
|
|
|
|
+ strings = Arrays.asList(decodedString.split(","));
|
|
titleList.addAll(strings);
|
|
titleList.addAll(strings);
|
|
}
|
|
}
|
|
dataList.add(titleList);
|
|
dataList.add(titleList);
|
|
@@ -14917,6 +14929,13 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
Map<String, Object> data = (Map<String, Object>) msg.data;
|
|
Map<String, Object> data = (Map<String, Object>) msg.data;
|
|
List<Map<String, Object>> mapList = (List<Map<String, Object>>) data.get("record");
|
|
List<Map<String, Object>> mapList = (List<Map<String, Object>>) data.get("record");
|
|
for (Map<String, Object> map : mapList) {
|
|
for (Map<String, Object> map : mapList) {
|
|
|
|
+ // 提取值并提供默认值
|
|
|
|
+ double design = getDoubleValue(map, "方案设计");
|
|
|
|
+ double research = getDoubleValue(map, "研发部");
|
|
|
|
+ double researchDesign = getDoubleValue(map, "研发部工艺设计");
|
|
|
|
+ double researchDesignShou = getDoubleValue(map, "研发部工艺调试验收");
|
|
|
|
+ double researchTiao = getDoubleValue(map, "研发部工艺调试");
|
|
|
|
+ Double sum=design+research+researchDesign+researchDesignShou+researchTiao;
|
|
List<String> item=new ArrayList<>();
|
|
List<String> item=new ArrayList<>();
|
|
if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
item.add("$departmentName="+String.valueOf(map.get("departmentName"))+"$");
|
|
item.add("$departmentName="+String.valueOf(map.get("departmentName"))+"$");
|
|
@@ -14929,7 +14948,24 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
}else {
|
|
}else {
|
|
item.add(String.valueOf(map.get("userName")));
|
|
item.add(String.valueOf(map.get("userName")));
|
|
}
|
|
}
|
|
- for (String s : titleList) {
|
|
|
|
|
|
+ // 格式化为两位小数
|
|
|
|
+ DecimalFormat df = new DecimalFormat("#.00");
|
|
|
|
+ for (String s : strings) {
|
|
|
|
+ if (s.equals("报价占比")){
|
|
|
|
+ extracted(sum, design, df, item);
|
|
|
|
+ continue;
|
|
|
|
+ } else if (s.equals("行政占比")) {
|
|
|
|
+ // 计算百分比
|
|
|
|
+ extracted(sum, research, df, item);
|
|
|
|
+ continue;
|
|
|
|
+ } else if (s.equals("项目设计占比")) {
|
|
|
|
+ // 计算百分比
|
|
|
|
+ extracted(sum, researchDesign, df, item);
|
|
|
|
+ continue;
|
|
|
|
+ }else if (s.equals("总计")) {
|
|
|
|
+ item.add(String.valueOf(sum));
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
item.add(String.valueOf(map.get(s)));
|
|
item.add(String.valueOf(map.get(s)));
|
|
}
|
|
}
|
|
dataList.add(item);
|
|
dataList.add(item);
|
|
@@ -14941,4 +14977,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
}
|
|
}
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private static void extracted(Double sum, double design, DecimalFormat df, List<String> item) {
|
|
|
|
+ // 计算百分比
|
|
|
|
+ double percentage = (sum == 0) ? 0 : (design / sum) * 100;
|
|
|
|
+ String formattedPercentage =percentage==0 ? "0.00%": df.format(percentage)+"%";
|
|
|
|
+ item.add(formattedPercentage);
|
|
|
|
+ }
|
|
}
|
|
}
|