数据计算

This commit is contained in:
pengjie 2024-09-11 11:33:24 +08:00
parent bc85884bfd
commit 6015454465
4 changed files with 86 additions and 18 deletions

View File

@ -53,7 +53,9 @@ public class CostBudgetServiceImpl extends ServiceImpl<CostBudgetMapper, CostBud
List<CostSubject> total = list.stream().filter(l -> StringUtils.isBlank(l.getName())).collect(Collectors.toList()); List<CostSubject> total = list.stream().filter(l -> StringUtils.isBlank(l.getName())).collect(Collectors.toList());
dtoList.addAll(convert(total)); dtoList.addAll(convert(total));
if (dtoList.size() > 0) { if (dtoList.size() > 0) {
List<CostSubject> allList = costSubjectService.list(); List<CostSubject> allList = costSubjectService.list(Wrappers.<CostSubject>lambdaQuery()
.eq(CostSubject::getSn, projectSn)
.eq(CostSubject::getLevelType, 3));
List<CostBudgetDto> allDtoList = convert(allList); List<CostBudgetDto> allDtoList = convert(allList);
List<CostBudget> budgetList = this.list(Wrappers.<CostBudget>lambdaQuery() List<CostBudget> budgetList = this.list(Wrappers.<CostBudget>lambdaQuery()
.eq(CostBudget::getProjectSn, projectSn) .eq(CostBudget::getProjectSn, projectSn)
@ -66,13 +68,25 @@ public class CostBudgetServiceImpl extends ServiceImpl<CostBudgetMapper, CostBud
.in(CostContractPay::getHtmc, contractList.stream().map(c -> c.getId()).collect(Collectors.toList()))); .in(CostContractPay::getHtmc, contractList.stream().map(c -> c.getId()).collect(Collectors.toList())));
} }
for (CostBudget costBudget : budgetList) { for (CostBudget costBudget : budgetList) {
List<String> contractIds = contractList.stream().filter(c -> c.getSubjectId().toString().equals(costBudget.getSubjectId().toString())).map(c -> c.getId().toString()).collect(Collectors.toList()); List<CostSubject> children = allList.stream().filter(a -> a.getParentId().toString().equals(costBudget.getSubjectId().toString())).collect(Collectors.toList());
BigDecimal reduce = costContractPayList.stream().filter(c -> contractIds.contains(c.getHtmc())).map(c -> new BigDecimal(c.getBczfje())) if (children.size() > 0) {
.reduce(BigDecimal.ZERO, BigDecimal::add); List<String> contractIds = contractList.stream().filter(c -> children.stream().map(d -> d.getId().toString()).collect(Collectors.toList()).contains(c.getSubjectId().toString())).map(c -> c.getId().toString()).collect(Collectors.toList());
costBudget.setActualCost(reduce.toString()); BigDecimal reduce = costContractPayList.stream().filter(c -> contractIds.contains(c.getHtmc())).map(c -> new BigDecimal(c.getBczfje()))
if (!costBudget.getActualCost().equals("0")) { .reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal ratio = reduce.subtract(new BigDecimal(costBudget.getBudgetCost())).divide(new BigDecimal(costBudget.getBudgetCost()), 2, BigDecimal.ROUND_HALF_UP); costBudget.setActualCost(reduce.toString());
costBudget.setCostDifference(ratio.multiply(new BigDecimal(100)).toString()); if (!costBudget.getActualCost().equals("0")) {
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());
}
} else {
List<String> contractIds = contractList.stream().filter(c -> c.getSubjectId().toString().equals(costBudget.getSubjectId().toString())).map(c -> c.getId().toString()).collect(Collectors.toList());
BigDecimal reduce = costContractPayList.stream().filter(c -> contractIds.contains(c.getHtmc())).map(c -> new BigDecimal(c.getBczfje()))
.reduce(BigDecimal.ZERO, BigDecimal::add);
costBudget.setActualCost(reduce.toString());
if (!costBudget.getActualCost().equals("0")) {
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);

View File

@ -196,18 +196,32 @@ public class CostContractPlanServiceImpl extends ServiceImpl<CostContractPlanMap
DynamicCostDto dynamicCostDto = new DynamicCostDto(); DynamicCostDto dynamicCostDto = new DynamicCostDto();
dynamicCostDto.setSubjectId(costSubject.getId()); dynamicCostDto.setSubjectId(costSubject.getId());
dynamicCostDto.setSubjectName(costSubject.getName()); dynamicCostDto.setSubjectName(costSubject.getName());
// 查询合约 // 查询合约
List<CostSubject> children = allList.stream().filter(a -> a.getParentId().toString().equals(costSubject.getId().toString())).collect(Collectors.toList()); List<CostSubject> children = allList.stream().filter(a -> a.getParentId().toString().equals(costSubject.getId().toString())).collect(Collectors.toList());
// List<CostSubject> allChildren = allList.stream().filter(a -> Arrays.asList(a.getAncestors().split(",")).contains(costSubject.getId().toString())).collect(Collectors.toList()); if (children.size() > 0) {
List<CostContract> contracts = contractList.stream().filter(c -> c.getSubjectId().toString().equals(costSubject.getId().toString())).collect(Collectors.toList()); List<String> stringList = children.stream().map(d -> d.getId().toString()).collect(Collectors.toList());
dynamicCostDto.setGoal(costBudgetList.stream().filter(c -> c.getSubjectId().toString().equals(costSubject.getId().toString())) List<CostContract> contracts = contractList.stream().filter(c -> stringList.contains(c.getSubjectId().toString())).collect(Collectors.toList());
.map(c -> new BigDecimal(c.getBudgetCost())).reduce(BigDecimal.ZERO, BigDecimal::add)); dynamicCostDto.setGoal(costBudgetList.stream().filter(c -> stringList.contains(c.getSubjectId().toString()))
dynamicCostDto.setContractAmount(contracts.stream().filter(c -> c.getZt().equals("已生效")).map(c -> c.getHthszj()).reduce(BigDecimal.ZERO, BigDecimal::add)); .map(c -> new BigDecimal(c.getBudgetCost())).reduce(BigDecimal.ZERO, BigDecimal::add));
dynamicCostDto.setUnderApproval(contracts.stream().filter(c -> c.getZt().equals("内审中")).map(c -> c.getHthszj()).reduce(BigDecimal.ZERO, BigDecimal::add)); dynamicCostDto.setContractAmount(contracts.stream().filter(c -> c.getZt().equals("已生效")).map(c -> c.getHthszj()).reduce(BigDecimal.ZERO, BigDecimal::add));
dynamicCostDto.setDynamicCost(dynamicCostDto.getContractAmount().add(dynamicCostDto.getUnderApproval()).add(dynamicCostDto.getToOccur()).add(dynamicCostDto.getContractAmount())); dynamicCostDto.setUnderApproval(contracts.stream().filter(c -> c.getZt().equals("内审中")).map(c -> c.getHthszj()).reduce(BigDecimal.ZERO, BigDecimal::add));
BigDecimal subtract = dynamicCostDto.getGoal().subtract(dynamicCostDto.getDynamicCost()); dynamicCostDto.setDynamicCost(dynamicCostDto.getContractAmount().add(dynamicCostDto.getUnderApproval()).add(dynamicCostDto.getToOccur()).add(dynamicCostDto.getContractAmount()));
dynamicCostDto.setCostDifference(dynamicCostDto.getGoal().compareTo(new BigDecimal(0)) > 0 ? subtract.divide(dynamicCostDto.getGoal(), 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).toString() : "0"); BigDecimal subtract = dynamicCostDto.getGoal().subtract(dynamicCostDto.getDynamicCost());
dynamicCostDto.setAllowance(subtract); dynamicCostDto.setCostDifference(dynamicCostDto.getGoal().compareTo(new BigDecimal(0)) > 0 ? subtract.divide(dynamicCostDto.getGoal(), 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).toString() : "0");
dynamicCostDto.setAllowance(subtract);
} else {
List<CostContract> contracts = contractList.stream().filter(c -> c.getSubjectId().toString().equals(costSubject.getId().toString())).collect(Collectors.toList());
dynamicCostDto.setGoal(costBudgetList.stream().filter(c -> c.getSubjectId().toString().equals(costSubject.getId().toString()))
.map(c -> new BigDecimal(c.getBudgetCost())).reduce(BigDecimal.ZERO, BigDecimal::add));
dynamicCostDto.setContractAmount(contracts.stream().filter(c -> c.getZt().equals("已生效")).map(c -> c.getHthszj()).reduce(BigDecimal.ZERO, BigDecimal::add));
dynamicCostDto.setUnderApproval(contracts.stream().filter(c -> c.getZt().equals("内审中")).map(c -> c.getHthszj()).reduce(BigDecimal.ZERO, BigDecimal::add));
dynamicCostDto.setDynamicCost(dynamicCostDto.getContractAmount().add(dynamicCostDto.getUnderApproval()).add(dynamicCostDto.getToOccur()).add(dynamicCostDto.getContractAmount()));
BigDecimal subtract = dynamicCostDto.getGoal().subtract(dynamicCostDto.getDynamicCost());
dynamicCostDto.setCostDifference(dynamicCostDto.getGoal().compareTo(new BigDecimal(0)) > 0 ? subtract.divide(dynamicCostDto.getGoal(), 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).toString() : "0");
dynamicCostDto.setAllowance(subtract);
}
// List<CostSubject> allChildren = allList.stream().filter(a -> Arrays.asList(a.getAncestors().split(",")).contains(costSubject.getId().toString())).collect(Collectors.toList());
dynamicCostDto.setChildren(getDynamicChildren(children, allList, costBudgetList, contractList)); dynamicCostDto.setChildren(getDynamicChildren(children, allList, costBudgetList, contractList));
dynamicCostDtoList.add(dynamicCostDto); dynamicCostDtoList.add(dynamicCostDto);
} }

View File

@ -28,6 +28,7 @@ import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
import com.zhgd.xmgl.modules.project.service.*; import com.zhgd.xmgl.modules.project.service.*;
import com.zhgd.xmgl.security.entity.UserInfo; import com.zhgd.xmgl.security.entity.UserInfo;
import com.zhgd.xmgl.security.util.SecurityUtils; import com.zhgd.xmgl.security.util.SecurityUtils;
import com.zhgd.xmgl.util.JiuzhuDateUtil;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
@ -63,6 +64,9 @@ public class ProgressPanoramaNodePlanServiceImpl extends ServiceImpl<ProgressPan
@Autowired @Autowired
private IProjectService projectService; private IProjectService projectService;
@Autowired
private JiuzhuDateUtil jiuzhuDateUtil;
@Autowired @Autowired
private IDictionaryItemService dictionaryItemService; private IDictionaryItemService dictionaryItemService;
@ -332,6 +336,8 @@ public class ProgressPanoramaNodePlanServiceImpl extends ServiceImpl<ProgressPan
progressPanoramaNodePlan.setApprovalStatue(0); progressPanoramaNodePlan.setApprovalStatue(0);
boolean flag = this.updateById(progressPanoramaNodePlan); boolean flag = this.updateById(progressPanoramaNodePlan);
draftInfo(progressPanoramaNodePlan, 2); draftInfo(progressPanoramaNodePlan, 2);
ProgressPanoramaNodePlan nodePlan = this.getById(progressPanoramaNodePlan.getId());
jiuzhuDateUtil.sendPlan(nodePlan);
return flag; return flag;
} }

View File

@ -21,6 +21,7 @@ import com.zhgd.xmgl.modules.cost.entity.CostContractPay;
import com.zhgd.xmgl.modules.cost.service.ICostContractPayService; import com.zhgd.xmgl.modules.cost.service.ICostContractPayService;
import com.zhgd.xmgl.modules.cost.service.ICostContractService; import com.zhgd.xmgl.modules.cost.service.ICostContractService;
import com.zhgd.xmgl.modules.jz.dto.PlanTargetDto; import com.zhgd.xmgl.modules.jz.dto.PlanTargetDto;
import com.zhgd.xmgl.modules.project.entity.ProgressPanoramaNodePlan;
import com.zhgd.xmgl.modules.project.entity.Project; import com.zhgd.xmgl.modules.project.entity.Project;
import com.zhgd.xmgl.modules.project.entity.ProjectSupplier; import com.zhgd.xmgl.modules.project.entity.ProjectSupplier;
import com.zhgd.xmgl.modules.project.service.IProjectService; import com.zhgd.xmgl.modules.project.service.IProjectService;
@ -212,6 +213,39 @@ public class JiuzhuDateUtil {
return planTargetDtoList; return planTargetDtoList;
} }
public List<PlanTargetDto> sendPlan(ProgressPanoramaNodePlan progressPanoramaNodePlan) {
String url = "/api/cube/restful/interface/getModeDataPageList/JHRW";
String systemid = "JHTS";
String d_password = "F510A75A00ED495389C685792E416269";
JSONObject mainTable = convert(progressPanoramaNodePlan);
String result = doAction(url, systemid, d_password, mainTable);
List<PlanTargetDto> planTargetDtoList = new ArrayList<>();
if (StringUtils.isNotBlank(result)) {
JSONObject obj = JSONObject.parseObject(result);
System.out.println("推送任务结果======" + obj);
}
return planTargetDtoList;
}
private JSONObject convert(ProgressPanoramaNodePlan progressPanoramaNodePlan) {
JSONObject main = new JSONObject();
main.put("id", progressPanoramaNodePlan.getId());
main.put("rwlx", progressPanoramaNodePlan.getLevelName());
main.put("rwlb", progressPanoramaNodePlan.getType());
main.put("sfwgjjd", progressPanoramaNodePlan.getKeyNode());
main.put("sfwlcb", progressPanoramaNodePlan.getMilepostNode());
main.put("jhksrq", progressPanoramaNodePlan.getPlanStartDate());
main.put("jhjsrq", progressPanoramaNodePlan.getPlanFinishDate());
main.put("zzr", progressPanoramaNodePlan.getChargerId());
main.put("zzbm", progressPanoramaNodePlan.getChargerDeptId());
main.put("lcb", progressPanoramaNodePlan.getMilepostId());
main.put("jdxcg", progressPanoramaNodePlan.getResultId());
main.put("bh", progressPanoramaNodePlan.getNodeCode());
main.put("gq", progressPanoramaNodePlan.getDuration());
main.put("xzr", progressPanoramaNodePlan.getAssistId());
return main;
}
/** /**
*restful接口调用案例 *restful接口调用案例
*以getModeDataPageList为例 *以getModeDataPageList为例