提交 02a80fcd authored 作者: Wangjiajie's avatar Wangjiajie

6.30 添加总行和更改小数显示问题

上级 5dedd539
......@@ -4,6 +4,7 @@ import java.io.UnsupportedEncodingException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
......@@ -16,6 +17,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.modules.iost.basedata.entity.IostReceivinglist;
import org.jeecg.modules.iost.basedata.entity.IostSummarySheetList;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
......@@ -171,7 +173,7 @@ public class IostReceivingNoteController {
//加载标题、日期
addTitleAndDateInfo(document, titleFont, keyFont, smtextFont);
List<IostReceivingNoteList> iostReceivingNoteListList = new ArrayList<IostReceivingNoteList>();
List<IostReceivingNoteList> iostReceivingNoteListList = new ArrayList< IostReceivingNoteList>();
for(IostReceivingNoteList iostReceivingNoteList:iostReceivingNoteLists)
{
......@@ -542,23 +544,32 @@ public class IostReceivingNoteController {
double totleWeightTotal = 0;//重量总
int totlePackagesTotal = 0;//箱数总
double totlePrice = 0;//价格总
double totleMoney = 0;//
double totleMoney = 0;//金额总
for(IostReceivingNoteList iostReceivingNoteList: iostIostReceivingNoteList)
{
totlevolume = totlevolume + iostReceivingNoteList.getVolume();
BigDecimal A1 = new BigDecimal(Double.toString(totlevolume));
BigDecimal A2 = new BigDecimal(Double.toString(iostReceivingNoteList.getVolume()));
totlevolume = A1.add(A2).doubleValue();
A1 = new BigDecimal(Double.toString(totleWeightTotal));
A2 = new BigDecimal(Double.toString(iostReceivingNoteList.getWeight()));
totleWeightTotal = A1.add(A2).doubleValue();
totlePackagesTotal = totlePackagesTotal + iostReceivingNoteList.getPackages();
totleWeightTotal = totleWeightTotal + iostReceivingNoteList.getWeight();
totlePrice = totlePrice + iostReceivingNoteList.getPrice();
totleMoney = totleMoney + iostReceivingNoteList.getMoney();
}
IostReceivingNoteList curIostReceivingNotlist = new IostReceivingNoteList();
curIostReceivingNotlist.setNameChs("总和");
curIostReceivingNotlist.setVolume(totlevolume);
curIostReceivingNotlist.setWeight(totleWeightTotal);
curIostReceivingNotlist.setPackages(totlePackagesTotal);
curIostReceivingNotlist.setPrice(totlePrice);
curIostReceivingNotlist.setMoney(totleMoney);
iostIostReceivingNoteList.add(curIostReceivingNotlist);
A1 = new BigDecimal(Double.toString(totlePrice));
A2 = new BigDecimal(Double.toString(iostReceivingNoteList.getPrice()));
totlePrice = A1.add(A2).doubleValue();
A1 = new BigDecimal(Double.toString(totleMoney));
A2 = new BigDecimal(Double.toString(iostReceivingNoteList.getMoney()));
totleMoney = A1.add(A2).doubleValue();
}
IostReceivingNoteList iostReceivingNoteList = new IostReceivingNoteList();
iostReceivingNoteList.setNameChs("总和");
iostReceivingNoteList.setVolume(totlevolume);
iostReceivingNoteList.setWeight(totleWeightTotal);
iostReceivingNoteList.setPackages(totlePackagesTotal);
iostReceivingNoteList.setPrice(totlePrice);
iostReceivingNoteList.setMoney(totleMoney);
iostIostReceivingNoteList.add(iostReceivingNoteList);
}
/**
......
......@@ -2,6 +2,7 @@ package org.jeecg.modules.iost.basedata.controller;
import java.io.UnsupportedEncodingException;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.text.DecimalFormat;
import java.util.ArrayList;
......@@ -536,15 +537,14 @@ public class IostSummarySheetController {
@GetMapping(value = "/queryIostSummarySheetListByMainIdiostListByMainId")
public Result<?> queryIostReceivingNoteListListMainId(@RequestParam(name="id",required=true) String id) {
List<IostSummarySheetList> iostReceivingNoteListList = iostSummarySheetListService.selectByMainId(id);
addSumRow(iostReceivingNoteListList);
iostReceivingNoteListList.add(addSumRow(iostReceivingNoteListList));
return Result.OK(iostReceivingNoteListList);
}
/***
* 增加统计行
* @param iostSummarySheetLists
*/
private void addSumRow(List<IostSummarySheetList> iostSummarySheetLists)
private IostSummarySheetList addSumRow(List<IostSummarySheetList> iostSummarySheetLists)
{
double totlevolume = 0;//体积总
double totleWeightTotal = 0;//重量总
......@@ -552,19 +552,28 @@ public class IostSummarySheetController {
double totleMoney = 0;//金额总
for(IostSummarySheetList iostSummarySheetList: iostSummarySheetLists)
{
totlevolume = totlevolume + iostSummarySheetList.getVolume();
BigDecimal A1 = new BigDecimal(Double.toString(totlevolume));
BigDecimal A2 = new BigDecimal(Double.toString(iostSummarySheetList.getVolume()));
totlevolume = A1.add(A2).doubleValue();
A1 = new BigDecimal(Double.toString(totleWeightTotal));
A2 = new BigDecimal(Double.toString(iostSummarySheetList.getWeight()));
totleWeightTotal = A1.add(A2).doubleValue();
if(iostSummarySheetList.getPackages()!=null){
totlePackagesTotal = totlePackagesTotal + iostSummarySheetList.getPackages();
totleWeightTotal = totleWeightTotal + iostSummarySheetList.getWeight();
totleMoney = totleMoney + iostSummarySheetList.getMoney();
}
A1 = new BigDecimal(Double.toString(totleMoney));
A2 = new BigDecimal(Double.toString(iostSummarySheetList.getMoney()));
totleMoney = A1.add(A2).doubleValue();
}
IostSummarySheetList iostSummarySheetList = new IostSummarySheetList();
iostSummarySheetList.setCustomerName("总和");
iostSummarySheetList.setVolume((double)Math.round(totlevolume*100)/100);
//iostSummarySheetList.setVolume((Double.valueOf(String.format("%.2f", totlevolume))));
iostSummarySheetList.setVolume(totlevolume);
iostSummarySheetList.setWeight(totleWeightTotal);
iostSummarySheetList.setPackages(totlePackagesTotal);
iostSummarySheetList.setMoney(totleMoney);
iostSummarySheetLists.add(iostSummarySheetList);
return iostSummarySheetList;
}
/**
......@@ -592,6 +601,7 @@ public class IostSummarySheetController {
}
// Step.3 组装pageList
List<IostSummarySheetList> iostSummarySheetPagesList = new ArrayList<IostSummarySheetList>();//记录需要总数的数据
List<IostSummarySheetPage> pageList = new ArrayList<IostSummarySheetPage>();
for (IostSummarySheet main : iostSummarySheetList) {
IostSummarySheetPage vo = new IostSummarySheetPage();
......@@ -599,8 +609,14 @@ public class IostSummarySheetController {
List<IostSummarySheetList> iostSummarySheetListList = iostSummarySheetListService.selectByMainId(main.getId());
vo.setIostSummarySheetListList(iostSummarySheetListList);
pageList.add(vo);
}
iostSummarySheetPagesList.add(addSumRow(iostSummarySheetListList));
}
//把总数放入pageList
IostSummarySheetPage list = new IostSummarySheetPage();
List<IostSummarySheetList> listzongshu = new ArrayList<>();
listzongshu.add(addSumRow(iostSummarySheetPagesList));
list.setIostSummarySheetListList(listzongshu);
pageList.add(list);
// Step.4 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
mv.addObject(NormalExcelConstants.FILE_NAME, "汇总单列表");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论