|
@@ -1164,7 +1164,10 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
//加上待分摊的无工时项目,如果当前项目列表没有的话
|
|
//加上待分摊的无工时项目,如果当前项目列表没有的话
|
|
if (assignNoProUser != null && assignNoProUser && noProjectItem.project != null) {
|
|
if (assignNoProUser != null && assignNoProUser && noProjectItem.project != null) {
|
|
List<FinanceProjects> financeProjects = financeProjectsMapper.selectList(new QueryWrapper<FinanceProjects>().eq("company_id", companyId).eq("ymonth", yearMonth));
|
|
List<FinanceProjects> financeProjects = financeProjectsMapper.selectList(new QueryWrapper<FinanceProjects>().eq("company_id", companyId).eq("ymonth", yearMonth));
|
|
-
|
|
|
|
|
|
+ if (financeProjects.size() == 0) {
|
|
|
|
+ httpRespMsg.setError("缺少待分摊项目,请重新设置并保存分摊比例设置");
|
|
|
|
+ return httpRespMsg;
|
|
|
|
+ }
|
|
//检查是否已经设置好分配规则
|
|
//检查是否已经设置好分配规则
|
|
ProjectPercentage percentage = projectPercentageMapper.selectOne(new QueryWrapper<ProjectPercentage>().eq("company_id", companyId).eq("ymonth", yearMonth));
|
|
ProjectPercentage percentage = projectPercentageMapper.selectOne(new QueryWrapper<ProjectPercentage>().eq("company_id", companyId).eq("ymonth", yearMonth));
|
|
List<Map> noPUserDataList = new ArrayList<>();
|
|
List<Map> noPUserDataList = new ArrayList<>();
|
|
@@ -1176,8 +1179,9 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
//获取设置的项目
|
|
//获取设置的项目
|
|
String data = percentage.getData();
|
|
String data = percentage.getData();
|
|
JSONArray parse = JSONArray.parseArray(data);
|
|
JSONArray parse = JSONArray.parseArray(data);
|
|
|
|
+
|
|
//获取到无项目人员配置的项目
|
|
//获取到无项目人员配置的项目
|
|
- financeProjects.forEach(f->{
|
|
|
|
|
|
+ for (FinanceProjects f : financeProjects) {
|
|
for (int i = 0; i < parse.size(); i++) {
|
|
for (int i = 0; i < parse.size(); i++) {
|
|
JSONObject json = parse.getJSONObject(i);
|
|
JSONObject json = parse.getJSONObject(i);
|
|
String userId = json.getString("id");
|
|
String userId = json.getString("id");
|
|
@@ -1187,16 +1191,22 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
userCostMap.put("creatorId", userId);
|
|
userCostMap.put("creatorId", userId);
|
|
userCostMap.put("workingTime", 0.0f);
|
|
userCostMap.put("workingTime", 0.0f);
|
|
double percent = json.getDouble(f.getProjectId()+"");
|
|
double percent = json.getDouble(f.getProjectId()+"");
|
|
- Finance finance = noProjectUser.stream().filter(no -> no.getUserId().equals(userId)).findFirst().get();
|
|
|
|
|
|
+ Optional<Finance> first = noProjectUser.stream().filter(no -> no.getUserId().equals(userId)).findFirst();
|
|
|
|
+ if (first.isPresent()) {
|
|
|
|
+ Finance finance = first.get();
|
|
// BigDecimal curProjectCost = finance.getTotalCost().multiply(new BigDecimal(percent)).divide(new BigDecimal(100));
|
|
// BigDecimal curProjectCost = finance.getTotalCost().multiply(new BigDecimal(percent)).divide(new BigDecimal(100));
|
|
- userCostMap.put("finance", finance);
|
|
|
|
- userCostMap.put("percent", percent);
|
|
|
|
- userCostMap.put("project", f.getProjectId());
|
|
|
|
- userCostMap.put("projectId", f.getProjectId());
|
|
|
|
- userCostMap.put("projectCode", f.getProjectCode());
|
|
|
|
- noPUserDataList.add(userCostMap);
|
|
|
|
|
|
+ userCostMap.put("finance", finance);
|
|
|
|
+ userCostMap.put("percent", percent);
|
|
|
|
+ userCostMap.put("project", f.getProjectName());
|
|
|
|
+ userCostMap.put("projectId", f.getProjectId());
|
|
|
|
+ userCostMap.put("projectCode", f.getProjectCode());
|
|
|
|
+ noPUserDataList.add(userCostMap);
|
|
|
|
+ System.out.println("添加="+f.getProjectId()+", "+f.getProjectName()+", "+percent);
|
|
|
|
+ } else {
|
|
|
|
+ System.out.println("未找到人员=="+username);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- });
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1221,6 +1231,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
|
|
//按比例分配
|
|
//按比例分配
|
|
for (ProjectSumItem p : pList) {
|
|
for (ProjectSumItem p : pList) {
|
|
List<Map> filterUserList = noPUserDataList.stream().filter(map->((Integer)map.get("projectId")).equals(p.projectId)).collect(Collectors.toList());
|
|
List<Map> filterUserList = noPUserDataList.stream().filter(map->((Integer)map.get("projectId")).equals(p.projectId)).collect(Collectors.toList());
|
|
|
|
+ System.out.println("过滤到的无项目人员size==="+filterUserList.size());
|
|
for (Map f : filterUserList) {
|
|
for (Map f : filterUserList) {
|
|
String curUserId = (String)f.get("creatorId");
|
|
String curUserId = (String)f.get("creatorId");
|
|
double percent = (double)f.get("percent");
|
|
double percent = (double)f.get("percent");
|