|
@@ -15,6 +15,7 @@ import java.io.FileOutputStream;
|
|
|
import java.io.InputStream;
|
|
|
import java.io.OutputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
@@ -162,7 +163,7 @@ public class Print {
|
|
|
JxlsHelper.getInstance().processTemplate(is, os, context);
|
|
|
}
|
|
|
|
|
|
- public static void printWater(List<EnergyWaterVo> waterVos) throws Exception {
|
|
|
+ public static void printWater(List<EnergyWater> waterVos,EnergyWater water) throws Exception {
|
|
|
|
|
|
//准备数据
|
|
|
String path = "/opt/guowei/water.xls";
|
|
@@ -173,15 +174,31 @@ public class Print {
|
|
|
//绑定数据
|
|
|
Context context = new Context();
|
|
|
List<WaterVo> list = new ArrayList<>();
|
|
|
- for (EnergyWaterVo waterVo : waterVos) {
|
|
|
+ int i = 0;
|
|
|
+ BigDecimal count = BigDecimal.ZERO;
|
|
|
+ for (EnergyWater waterVo : waterVos) {
|
|
|
+ i=i+1;
|
|
|
WaterVo waterVo1 = new WaterVo();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- waterVo1.setDate(sdf.format(waterVo.getCreateDate()));
|
|
|
+ String format = sdf.format(waterVo.getCreateDate());
|
|
|
+ waterVo1.setDate(format);
|
|
|
waterVo1.setLocation(waterVo.getChipName());
|
|
|
waterVo1.setWater(waterVo.getWaterValue());
|
|
|
+ BigDecimal bd = new BigDecimal(waterVo.getWaterValue());
|
|
|
+ BigDecimal result = bd.setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ count = count.add(result);
|
|
|
list.add(waterVo1);
|
|
|
+ if (i == 4) {
|
|
|
+ WaterVo one = new WaterVo();
|
|
|
+ one.setDate(format);
|
|
|
+ one.setLocation("合计:");
|
|
|
+ one.setWater(count.toString());
|
|
|
+ list.add(one);
|
|
|
+ i = 0;
|
|
|
+ }
|
|
|
}
|
|
|
context.putVar("list", list);
|
|
|
+ context.putVar("waterCount", water.getWaterValue());
|
|
|
//生成
|
|
|
JxlsHelper.getInstance().processTemplate(is, os, context);
|
|
|
}
|
|
@@ -202,7 +219,7 @@ public class Print {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
waterVo1.setDate(sdf.format(waterVo.getCreateDate()));
|
|
|
waterVo1.setLocation(waterVo.getChipName());
|
|
|
- waterVo1.setWater(waterVo.getWaterValue());
|
|
|
+ waterVo1.setWater(waterVo.getWaterValue().toString());
|
|
|
list.add(waterVo1);
|
|
|
}
|
|
|
context.putVar("list", list);
|