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

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

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