<commit_before>package cn.cerc.mis.excel.output;

import cn.cerc.db.core.ClassResource;
import cn.cerc.db.core.DataRow;
import cn.cerc.db.core.DataSet;
import cn.cerc.mis.SummerMIS;
import cn.cerc.mis.config.ApplicationConfig;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WriteException;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.List;

/**
 * 批次导出单据明细
 */
public class BatchFormTemplate extends FormTemplate {
    private static final ClassResource res = new ClassResource(BatchFormTemplate.class, SummerMIS.ID);
    DecimalFormat df = new DecimalFormat(ApplicationConfig.getPattern());

    List<DataSet> items;

    @Override
    public void output(WritableSheet sheet) throws WriteException {
        int newRow = 0;
        for (DataSet dataSet : items) {
            this.setDataSet(dataSet);
            this.setFooter((template, sheet1) -> {
                DataRow footer = new DataRow();
                for (DataRow item : dataSet) {
                    footer.setValue(res.getString(1, "合计数量"), footer.getDouble(res.getString(1, "合计数量")) + item.getDouble("Num_"));
                    footer.setValue(res.getString(2, "合计金额"), footer.getDouble(res.getString(2, "合计金额")) + item.getDouble("OriAmount_"));
                }
                int row = template.getRow();
                for (String field : footer.items().keySet()) {
                    row++;
                    Object val = footer.items().get(field);
                    sheet1.addCell(new Label(0, row, field));
                    sheet1.addCell(new Label(1, row, df.format(new BigDecimal(Double.toString((Double) val)))));
                }
            });

            // 输出原来的表格<commit_msg>!104 清理编译警告，未变更逻辑<commit_after>package cn.cerc.mis.excel.output;

import java.text.DecimalFormat;
import java.util.List;

import cn.cerc.db.core.ClassResource;
import cn.cerc.db.core.DataRow;
import cn.cerc.db.core.DataSet;
import cn.cerc.mis.SummerMIS;
import cn.cerc.mis.config.ApplicationConfig;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WriteException;

/**
 * 批次导出单据明细
 */
public class BatchFormTemplate extends FormTemplate {
    private static final ClassResource res = new ClassResource(BatchFormTemplate.class, SummerMIS.ID);
    DecimalFormat df = new DecimalFormat(ApplicationConfig.getPattern());

    List<DataSet> items;

    @Override
    public void output(WritableSheet sheet) throws WriteException {
        int newRow = 0;
        for (DataSet dataSet : items) {
            this.setDataSet(dataSet);
            this.setFooter((template, sheet1) -> {
                DataRow footer = new DataRow();
                for (DataRow item : dataSet) {
                    footer.setValue(res.getString(1, "合计数量"), footer.getDouble(res.getString(1, "合计数量")) + item.getDouble("Num_"));
                    footer.setValue(res.getString(2, "合计金额"), footer.getDouble(res.getString(2, "合计金额")) + item.getDouble("OriAmount_"));
                }
                int row = template.getRow();
                for (String field : footer.fields().names()) {
                    row++;
                    sheet1.addCell(new Label(0, row, field));
                    sheet1.addCell(new Label(1, row, df.format(footer.getString(field))));
                }
            });

            // 输出原来的表格
{'fraction_non_alphanumeric': 0.12384912384912385, 'fraction_numerical': 0.006831006831006831, 'mean_word_length': 2.4937759336099585, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3958288', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1057, 'n_words': 195}