This commit is contained in:
pengjie 2024-09-02 17:16:21 +08:00
parent 621e6dabfa
commit c0f53b1a9e
4 changed files with 30 additions and 13 deletions

View File

@ -161,10 +161,19 @@ public class ProjectDataController {
for (int i = 0; i < jsonArray.size(); i++) { for (int i = 0; i < jsonArray.size(); i++) {
JSONObject projectObj = jsonArray.getJSONObject(i).getJSONObject("mainTable"); JSONObject projectObj = jsonArray.getJSONObject(i).getJSONObject("mainTable");
CostContract costContract = JSONObject.parseObject(JSON.toJSONString(projectObj), CostContract.class); CostContract costContract = JSONObject.parseObject(JSON.toJSONString(projectObj), CostContract.class);
contractList.add(costContract);
JSONArray detailArray = jsonArray.getJSONObject(i).getJSONArray("detail1"); JSONArray detailArray = jsonArray.getJSONObject(i).getJSONArray("detail1");
StringBuilder gys = new StringBuilder();
for (int j = 0; j < detailArray.size(); j++) {
String gysbm = detailArray.getJSONObject(j).getString("gysbm");
if (StringUtils.isNotBlank(gysbm)) {
gys.append(gysbm);
gys.append(",");
}
}
System.out.println(detailArray); System.out.println(detailArray);
costContract.setGysbm(gys.toString());
contractList.add(costContract);
} }
costContractService.saveOrUpdateBatch(contractList); costContractService.saveOrUpdateBatch(contractList);
} }

View File

@ -448,17 +448,17 @@ public class CostBudgetController {
long count = 1; long count = 1;
while (count > 0 && num < 10) { while (count > 0 && num < 10) {
for (CostBudget costBudget : costBudgetList) { for (CostBudget costBudget : costBudgetList) {
if (StringUtils.isBlank(costBudget.getBudgetCost()) || costBudget.getBudgetCost().equals("0")) { // if (StringUtils.isBlank(costBudget.getBudgetCost()) || costBudget.getBudgetCost().equals("0")) {
List<String> subIds = subjectList.stream().filter(s -> s.getParentId().toString().equals(costBudget.getSubjectId().toString())) List<String> subIds = subjectList.stream().filter(s -> s.getParentId().toString().equals(costBudget.getSubjectId().toString()))
.map(c -> c.getId().toString()).collect(Collectors.toList()); .map(c -> c.getId().toString()).collect(Collectors.toList());
List<CostBudget> costSubjects = costBudgetList.stream().filter(c -> subIds.contains(c.getSubjectId().toString())).collect(Collectors.toList()); List<CostBudget> costSubjects = costBudgetList.stream().filter(c -> subIds.contains(c.getSubjectId().toString())).collect(Collectors.toList());
if (costSubjects.size() > 0 && costSubjects.stream().filter(c -> StringUtils.isBlank(c.getBudgetCost())).count() == 0) { if (costSubjects.size() > 0 && costSubjects.stream().filter(c -> StringUtils.isBlank(c.getBudgetCost())).count() == 0) {
BigDecimal budgetCost = costSubjects.stream().map(s -> new BigDecimal(s.getBudgetCost())).reduce(BigDecimal.ZERO, BigDecimal::add); BigDecimal budgetCost = costSubjects.stream().map(s -> new BigDecimal(s.getBudgetCost())).reduce(BigDecimal.ZERO, BigDecimal::add);
costBudget.setBudgetCost(budgetCost.toString()); costBudget.setBudgetCost(budgetCost.toString());
costBudget.setActualCost("0"); costBudget.setActualCost("0");
costBudget.setCostDifference("0"); costBudget.setCostDifference("0");
}
} }
// }
} }
count = costBudgetList.stream().filter(c -> StringUtils.isBlank(c.getBudgetCost())).count(); count = costBudgetList.stream().filter(c -> StringUtils.isBlank(c.getBudgetCost())).count();
num ++; num ++;

View File

@ -416,6 +416,12 @@ public class CostContract implements Serializable {
@Excel(name = "项目信息", width = 15) @Excel(name = "项目信息", width = 15)
@ApiModelProperty(value = "项目信息") @ApiModelProperty(value = "项目信息")
private String xmxx; private String xmxx;
/**
* 供应商编码
*/
@Excel(name = "供应商编码", width = 15)
@ApiModelProperty(value = "供应商编码")
private String gysbm;
/** /**
* 项目SN * 项目SN
*/ */

View File

@ -71,8 +71,10 @@ public class CostBudgetServiceImpl extends ServiceImpl<CostBudgetMapper, CostBud
BigDecimal reduce = costContractPayList.stream().filter(c -> contractIds.contains(c.getHtmc())).map(c -> new BigDecimal(c.getBczfje())) BigDecimal reduce = costContractPayList.stream().filter(c -> contractIds.contains(c.getHtmc())).map(c -> new BigDecimal(c.getBczfje()))
.reduce(BigDecimal.ZERO, BigDecimal::add); .reduce(BigDecimal.ZERO, BigDecimal::add);
costBudget.setActualCost(reduce.toString()); costBudget.setActualCost(reduce.toString());
BigDecimal ratio = reduce.subtract(new BigDecimal(costBudget.getBudgetCost())).divide(new BigDecimal(costBudget.getBudgetCost()), 2, BigDecimal.ROUND_HALF_UP); if (!costBudget.getActualCost().equals("0")) {
costBudget.setCostDifference(ratio.multiply(new BigDecimal(100)).toString()); BigDecimal ratio = reduce.subtract(new BigDecimal(costBudget.getBudgetCost())).divide(new BigDecimal(costBudget.getBudgetCost()), 2, BigDecimal.ROUND_HALF_UP);
costBudget.setCostDifference(ratio.multiply(new BigDecimal(100)).toString());
}
} }
getChildren(dtoList, allDtoList, budgetList, true); getChildren(dtoList, allDtoList, budgetList, true);
} }