for(MouldPlan mouldPlan:list){
Double totalCost=null;
Integer id=mouldPlan.getPlanId();
List lineList=mouldPlanService.findMouldPlanLine(id);
//查询出一个生产计划对应的模具
for(MouldPlanLine mouldPlanLine:lineList){
Double totalCost1 = null;
Integer lineId=mouldPlanLine.getId();
List technologylist=mouldTechnologyService.findById(lineId);
//每一个模具模具对应的工艺总和
for(MouldTechnology mouldTechnology:technologylist){
Double cost=mouldTechnology.getCosts();
totalCost1+=cost;
}
mouldPlanLine.setCost(totalCost1);
totalCost+=totalCost1;
}
//
//计划对应的所有材料总和
Double costMaterial=null;
String mouldPlanNo=mouldPlan.getMouldPlanNo();
List listMaterial=mouldMaterialOutService.findById(mouldPlanNo);
for(MouldMaterialOut mouldMaterialOut:listMaterial){
Double price=mouldMaterialOut.getPrice();
Double weight=mouldMaterialOut.getWeight();
Double cost1=price*weight;
mouldMaterialOut.setCost(cost1);
costMaterial+=cost1;
}
mouldMaterialOut.setCost(costMaterial);
//一个计划的总成本
mouldPlan.setTotalCost(totalCost+costMaterial);
}
Double totalCost=null;
Double costMaterial=null;
等这些double变量没有初始化。赋值一下,
Double totalCost = 0.0;
Double costMaterial=0.0;
楼上的分析应该是正确的。如果不是请把详细的错误信息发上来。