<commit_before>package services;


import controllers.DomainKey;
import dtos.report.KhoiLuongReportRequest;
import models.sunerp.PhongBan;
import net.sf.dynamicreports.jasper.builder.JasperReportBuilder;
import net.sf.dynamicreports.report.builder.column.TextColumnBuilder;
import net.sf.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder;
import net.sf.dynamicreports.report.constant.*;
import utils.DateTimeUtils;

import java.util.Date;

import static net.sf.dynamicreports.report.builder.DynamicReports.*;
import static services.ReportStyle.*;

/**
 * The Class KhoiLuongReportColumnBuilder.
 *
 * @author <NAME>
 * @since 4/15/14 9:32 AM
 */

public final class KhoiLuongReportColumnBuilder {

    public static final TextColumnBuilder<String> maCv = col.column("Mã Cv", "taskCode", type.stringType()).setStyle(COLUMN_CENTER_STYLE).setFixedWidth(40);
    public static final TextColumnBuilder<String> taskName = col.column("Nội dung Cv", "taskName", type.stringType()).setFixedWidth(200);
    public static final TextColumnBuilder<String> taskUnit = col.column("Đơn vị", "taskUnit", type.stringType()).setStyle(COLUMN_CENTER_STYLE);
    public static final TextColumnBuilder<Double> taskKL = col.column("KL", "taskKL", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> taskGio = col.column("Giờ", "taskGio", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> totalKL = col.column("KL", "totalKhoiLuong", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> totalGio = col.column("Giờ", "totalGio", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> dinhMuc = col.column("ĐM", "taskDinhMuc", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> soLan = col.column("Số lần", "taskSoLan", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> quyKL = col.column("KL", "quyKl", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> quyGio = col.column("Giờ", "quyGio", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> conLaiKL = col.column("KL", "conLaiKL", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> conLaiGio = col.column("Giờ", "conLaiGio", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> xnKL = col.column("KL", "xnKL", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> xnGio = col.column("Giờ", "xnGio", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<String> tenNV = col.column("Tên người làm", "tenNV", type.stringType()).setFixedWidth(150);
    public static final TextColumnBuilder<String> ngay = col.column("Ngày", "ngay", type.stringType()).setStyle(COLUMN_CENTER_STYLE).setFixedWidth(30);
    public static final TextColumnBuilder<Integer> stt = col.column("TT", "stt", type.integerType()).setStyle(COLUMN_CENTER_STYLE).setFixedWidth(30);
    public static final TextColumnBuilder<Double> hsl = col.column("HSL", "hsl", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE).setFixedWidth(50);
    public static final TextColumnBuilder<Double> sanPham = col.column("Sản phẩm", "sanPham", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> hop = col.column("Họp", "hop", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> hocNH = col.column("Học NH", "hocNH", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> hocDH = col.column("Học DH", "hocDH", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> gianTiep = col.column("Gián tiếp", "gianTiep", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> nghiPhep = col.column("Nghỉ phép", "nghiPhep", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> leTet = col.column("Lễ tết", "leTet", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> tongCacKhoanCong = col.column("Tổng cộng", "tongCacKhoanCong", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> tongCacKhoanTru = col.column("Tổng cộng", "tongCacKhoanTru", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> omDau = col.column("Ốm đau", "tongCong", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> thaiSan = col.column("Thai sản", "tongCong", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> conOm = col.column("Con ốm", "tongCong", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> taiNanLaoDong = col.column("TNLĐ bệnh NN", "taiNanLaoDong", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> phuCapLamDem = col.column("Phụ cấp làm đêm", "phuCapLamDem", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> trucBHLD = col.column("Trực bảo hộ LĐ", "trucBHLD", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> phuCapDocHai = col.column("Phụ cấp độc hại", "phuCapDocHai", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> giuaCa = col.column("Giữa ca", "giuaCa", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> tongGioCong = col.column("Tổng giờ công", "tongGioCong", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> diemHeSo = col.column("Điểm hệ số", "diemHeSo", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<String> xepLoai = col.column("Xếp loại ABC", "xepLoai", type.stringType());
    public static final TextColumnBuilder<String> ghiChu = col.column("Ghi chú", "ghiChu", type.stringType());

    public static JasperReportBuilder buildBangChamCong(KhoiLuongReportRequest request) {
        JasperReportBuilder builder = report()
                .title(
                        cmp.verticalList(
                                cmp.horizontalList(
                                        cmp.verticalList(
                                                cmp.text("Đơn vị: " + request.donViName()).setStyle(stl.style(LEFT_SUB_TITLE_STYLE)
                                                        .setBottomPadding(0).setTopPadding(0)),
                                                cmp.text("Bộ phận: " + request.phongBanName()).setStyle(stl.style(LEFT_SUB_TITLE_STYLE))
                                        ).setFixedWidth(300),
                                        cmp.verticalList(
                                                cmp.text("BẢNG CHẤM CÔNG").setStyle(stl.style(TITLE_STYLE).setBottomPadding(0).setTopPadding(0)),
                                                cmp.text("Tháng " + request.month() + " năm " + request.year()).setStyle(SUB_TITLE_STYLE)
                                        ).setFixedWidth(570)
                                )
                        )
                )
                .setColumnTitleStyle(COLUMN_TITLE_STYLE)
                .setColumnStyle(COLUMN_STYLE)
                .setWhenNoDataType(WhenNoDataType.ALL_SECTIONS_NO_DETAIL)
                .setPageFormat(PageType.A2, PageOrientation.LANDSCAPE);

        builder.columns(
                stt, tenNV, hsl, sanPham, hop, hocNH, hocDH, gianTiep, nghiPhep, leTet, tongCacKhoanCong,
                omDau, thaiSan, conOm, taiNanLaoDong, tongCacKhoanTru,
                phuCapLamDem, trucBHLD, phuCapDocHai, giuaCa, tongGioCong, diemHeSo, xepLoai, ghiChu
        );

        ColumnTitleGroupBuilder tg1 = grid.titleGroup();
        tg1.setTitle("Ngày trong tháng");
        for (Integer i = 1; i <= 31; i++) {
            TextColumnBuilder<Double> _col = col
                    .column(i.toString(), "khoiLuongCongViec." + i, type.doubleType())
                    .setStyle(COLUMN_NUMBER_STYLE)
                    .setWidth(50);
            builder.addColumn(_col);
            tg1.add(_col);
        }

        ColumnTitleGroupBuilder tg2 = grid.titleGroup();
        tg2.setTitle("Tổng hợp các loại công");

        ColumnTitleGroupBuilder tg3 = grid.titleGroup();
        tg3.setTitle("Số công làm việc và nghỉ chế độ");
        tg3.add(sanPham, hop, hocNH, hocDH, gianTiep, nghiPhep, leTet);

        ColumnTitleGroupBuilder tg4 = grid.titleGroup();
        tg4.setTitle("Số công nghỉ BHXH");
        tg4.add(omDau, thaiSan, conOm, taiNanLaoDong);

        tg2.add(tg3, tongCacKhoanCong, tg4, tongCacKhoanTru, phuCapLamDem, trucBHLD, phuCapDocHai, giuaCa);

        builder.columnGrid(stt, tenNV, hsl, tg1, tg2, tongGioCong, diemHeSo, xepLoai, ghiChu);
        return builder;<commit_msg>Implement "BangChamCong" report.<commit_after>package services;


import controllers.DomainKey;
import dtos.report.KhoiLuongReportRequest;
import models.sunerp.PhongBan;
import net.sf.dynamicreports.jasper.builder.JasperReportBuilder;
import net.sf.dynamicreports.report.builder.column.TextColumnBuilder;
import net.sf.dynamicreports.report.builder.grid.ColumnTitleGroupBuilder;
import net.sf.dynamicreports.report.constant.*;
import utils.DateTimeUtils;

import java.util.Date;

import static net.sf.dynamicreports.report.builder.DynamicReports.*;
import static services.ReportStyle.*;

/**
 * The Class KhoiLuongReportColumnBuilder.
 *
 * @author <NAME>
 * @since 4/15/14 9:32 AM
 */

public final class KhoiLuongReportColumnBuilder {

    public static final TextColumnBuilder<String> maCv = col.column("Mã Cv", "taskCode", type.stringType()).setStyle(COLUMN_CENTER_STYLE).setFixedWidth(40);
    public static final TextColumnBuilder<String> taskName = col.column("Nội dung Cv", "taskName", type.stringType()).setFixedWidth(200);
    public static final TextColumnBuilder<String> taskUnit = col.column("Đơn vị", "taskUnit", type.stringType()).setStyle(COLUMN_CENTER_STYLE);
    public static final TextColumnBuilder<Double> taskKL = col.column("KL", "taskKL", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> taskGio = col.column("Giờ", "taskGio", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> totalKL = col.column("KL", "totalKhoiLuong", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> totalGio = col.column("Giờ", "totalGio", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> dinhMuc = col.column("ĐM", "taskDinhMuc", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> soLan = col.column("Số lần", "taskSoLan", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> quyKL = col.column("KL", "quyKl", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> quyGio = col.column("Giờ", "quyGio", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> conLaiKL = col.column("KL", "conLaiKL", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> conLaiGio = col.column("Giờ", "conLaiGio", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> xnKL = col.column("KL", "xnKL", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> xnGio = col.column("Giờ", "xnGio", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<String> tenNV = col.column("Tên người làm", "tenNV", type.stringType()).setFixedWidth(150);
    public static final TextColumnBuilder<String> ngay = col.column("Ngày", "ngay", type.stringType()).setStyle(COLUMN_CENTER_STYLE).setFixedWidth(30);
    public static final TextColumnBuilder<Integer> stt = col.column("TT", "stt", type.integerType()).setStyle(COLUMN_CENTER_STYLE).setFixedWidth(30);
    public static final TextColumnBuilder<Double> hsl = col.column("HSL", "hsl", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE).setFixedWidth(30);
    public static final TextColumnBuilder<Double> sanPham = col.column("Sản phẩm", "sanPham", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> hop = col.column("Họp", "hop", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> hocNH = col.column("Học NH", "hocNH", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> hocDH = col.column("Học DH", "hocDH", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> gianTiep = col.column("Gián tiếp", "gianTiep", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> nghiPhep = col.column("Nghỉ phép", "nghiPhep", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> leTet = col.column("Lễ tết", "leTet", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> tongCacKhoanCong = col.column("Tổng cộng", "tongCacKhoanCong", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> tongCacKhoanTru = col.column("Tổng cộng", "tongCacKhoanTru", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> omDau = col.column("Ốm đau", "tongCong", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> thaiSan = col.column("Thai sản", "tongCong", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> conOm = col.column("Con ốm", "tongCong", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> taiNanLaoDong = col.column("TNLĐ bệnh NN", "taiNanLaoDong", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> phuCapLamDem = col.column("Phụ cấp làm đêm", "phuCapLamDem", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> trucBHLD = col.column("Trực bảo hộ LĐ", "trucBHLD", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> phuCapDocHai = col.column("Phụ cấp độc hại", "phuCapDocHai", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> giuaCa = col.column("Giữa ca", "giuaCa", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> tongGioCong = col.column("Tổng giờ công", "tongGioCong", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<Double> diemHeSo = col.column("Điểm hệ số", "diemHeSo", type.doubleType()).setStyle(COLUMN_NUMBER_STYLE);
    public static final TextColumnBuilder<String> xepLoai = col.column("Xếp loại ABC", "xepLoai", type.stringType());
    public static final TextColumnBuilder<String> ghiChu = col.column("Ghi chú", "ghiChu", type.stringType()).setFixedWidth(100);

    public static JasperReportBuilder buildBangChamCong(KhoiLuongReportRequest request) {
        JasperReportBuilder builder = report()
                .title(
                        cmp.verticalList(
                                cmp.horizontalList(
                                        cmp.verticalList(
                                                cmp.text("Đơn vị: " + request.donViName()).setStyle(stl.style(LEFT_SUB_TITLE_STYLE)
                                                        .setBottomPadding(0).setTopPadding(0)),
                                                cmp.text("Bộ phận: " + request.phongBanName()).setStyle(stl.style(LEFT_SUB_TITLE_STYLE))
                                        ).setFixedWidth(300),
                                        cmp.verticalList(
                                                cmp.text("BẢNG CHẤM CÔNG").setStyle(stl.style(TITLE_STYLE).setBottomPadding(0).setTopPadding(0)),
                                                cmp.text("Tháng " + request.month() + " năm " + request.year()).setStyle(SUB_TITLE_STYLE)
                                        ).setFixedWidth(1100)
                                )
                        )
                )
                .setColumnTitleStyle(COLUMN_TITLE_STYLE)
                .setColumnStyle(COLUMN_STYLE)
                .setWhenNoDataType(WhenNoDataType.ALL_SECTIONS_NO_DETAIL)
                .setPageFormat(PageType.A2, PageOrientation.LANDSCAPE);

        builder.columns(
                stt, tenNV, hsl, sanPham, hop, hocNH, hocDH, gianTiep, nghiPhep, leTet, tongCacKhoanCong,
                omDau, thaiSan, conOm, taiNanLaoDong, tongCacKhoanTru,
                phuCapLamDem, trucBHLD, phuCapDocHai, giuaCa, tongGioCong, diemHeSo, xepLoai, ghiChu
        );

        ColumnTitleGroupBuilder tg1 = grid.titleGroup();
        tg1.setTitle("Ngày trong tháng");
        for (Integer i = 1; i <= 31; i++) {
            TextColumnBuilder<Double> _col = col
                    .column(i.toString(), "khoiLuongCongViec." + i, type.doubleType())
                    .setStyle(COLUMN_NUMBER_STYLE)
                    .setWidth(50);
            builder.addColumn(_col);
            tg1.add(_col);
        }

        ColumnTitleGroupBuilder tg2 = grid.titleGroup();
        tg2.setTitle("Tổng hợp các loại công");

        ColumnTitleGroupBuilder tg3 = grid.titleGroup();
        tg3.setTitle("Số công làm việc và nghỉ chế độ");
        tg3.add(sanPham.setTitleHeight(40), hop, hocNH, hocDH, gianTiep, nghiPhep, leTet);
        tg3.setTitleHeight(20);

        ColumnTitleGroupBuilder tg4 = grid.titleGroup();
        tg4.setTitle("Số công nghỉ BHXH");
        tg4.add(omDau.setTitleHeight(40), thaiSan, conOm, taiNanLaoDong);
        tg4.setTitleHeight(20);

        tg2.add(tg3, tongCacKhoanCong, tg4, tongCacKhoanTru, phuCapLamDem, trucBHLD, phuCapDocHai, giuaCa);
        tg2.setTitleHeight(20);

        builder.columnGrid(stt, tenNV, hsl, tg1, tg2, tongGioCong, diemHeSo, xepLoai, ghiChu);
        return builder;
{'fraction_non_alphanumeric': 0.11957845681300641, 'fraction_numerical': 0.006619710851030027, 'mean_word_length': 3.8858990944372573, 'pattern_counts': {'":': 0, '<': 89, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1553038', 'n_tokens_mistral': 6380, 'n_tokens_neox': 6103, 'n_words': 1074}