package com.ruoyi.common.service.impl;

import com.ruoyi.app.mapper.SlaughterBatchMapper;
import com.ruoyi.app.model.response.GetEnvCheck;
import com.ruoyi.common.model.ExportField;
import com.ruoyi.common.service.IExportFieldConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class ExportFieldConfigServiceImpl implements IExportFieldConfigService {
    @Autowired
    private SlaughterBatchMapper slaughterBatchMapper;

    /**
     * 生猪屠宰情况日汇总表可用字段配置
     */
    @Override
    public List<ExportField> getDailySlaughterReportFields() {
        List<ExportField> fields = new ArrayList<>();
        ExportField createTime = new ExportField("createTime", "日期", 1);
        ExportField animalType = new ExportField("animalType", "畜种", 1);
        ExportField amount = new ExportField("amount", "到场活头数", 2);

        // 违禁药物检测情况
        ExportField drugCheckGroup = new ExportField("drugCheck", "违禁药物检测情况", 3);
        drugCheckGroup.setLevel(0);
        drugCheckGroup.setHasChildren(true);
        drugCheckGroup.setChildren(Arrays.asList(
                createField("checkAmount", "抽检头数", 3, 1, "drugCheck"),
                createField("qualifiedAmount", "合格头数", 4, 1, "drugCheck")
        ));

        // 屠宰头数
        ExportField tuzaiAmountTotalGroup = new ExportField("tuzaiAmountTotal", "屠宰头数", 5);
        tuzaiAmountTotalGroup.setLevel(0);
        tuzaiAmountTotalGroup.setHasChildren(true);
        tuzaiAmountTotalGroup.setChildren(Arrays.asList(
                createField("tuzaiAmount", "准宰头数", 5, 1, "tuzaiAmountTotal"),
                createField("snapKillAmount", "急宰头数", 6, 1, "tuzaiAmountTotal"),
                createField("allTuzaiAmount", "合计", 7, 1, "tuzaiAmountTotal")
        ));

        // 生猪产品出厂情况
        ExportField produceOutputGroup = new ExportField("produceOutput", "产品出厂情况", 8);
        produceOutputGroup.setLevel(0);
        produceOutputGroup.setHasChildren(true);
        produceOutputGroup.setChildren(Arrays.asList(
                createField("dongAmountStr", "胴体头数", 8, 1, "produceOutput"),
                createField("weightStr", "产品重量", 9, 1, "produceOutput")
        ));

        // 病害猪及其产品无害化处理情况
        ExportField harmLessGroup = new ExportField("harmLess", "无害化处理情况", 10);
        harmLessGroup.setLevel(0);
        harmLessGroup.setHasChildren(true);
        harmLessGroup.setChildren(Arrays.asList(
                createField("roadDealAmount", "途亡头数", 10, 1, "harmLess"),
                createField("illnessDeadAmount", "病死数量", 11, 1, "harmLess"),
                createField("illnessDiseaseAmount", "病害数量", 12, 1, "harmLess"),
                createField("dealAmount", "静养病死病害头数", 13, 1, "harmLess")
        ));

        fields.addAll(Arrays.asList(createTime,animalType,amount,drugCheckGroup,tuzaiAmountTotalGroup,produceOutputGroup,harmLessGroup));
        return fields;
    }

    /**
     * 违禁药物检测及屠宰检验情况表
     */
    @Override
    public List<ExportField> getDailyDrugCheckAndSlaughterReportFields() {
        List<ExportField> fields = new ArrayList<>();
        ExportField createTime = new ExportField("createTime", "日期", 1);
        ExportField cargoOwner = new ExportField("cargoOwner", "货主", 2);

        // 违禁药物检测情况
        ExportField drugCheckGroup = new ExportField("drugResult", "违禁药物检测", 3);
        drugCheckGroup.setLevel(0);
        drugCheckGroup.setHasChildren(true);
        drugCheckGroup.setChildren(Arrays.asList(
                createField("drugResult.checkAmount", "抽检头数", 3, 1, "drugResult"),
                createField("drugResult.result", "抽检结果", 4, 1, "drugResult"),
                createField("drugResult.examineItemsStr", "抽检详情", 5, 1, "drugResult")
        ));

        // 违禁药物检测情况
        ExportField antibioticCheckGroup = new ExportField("antibioticResult", "抗生素检测", 6);
        antibioticCheckGroup.setLevel(0);
        antibioticCheckGroup.setHasChildren(true);
        antibioticCheckGroup.setChildren(Arrays.asList(
                createField("antibioticResult.checkAmount", "抽检头数", 6, 1, "antibioticResult"),
                createField("antibioticResult.result", "抽检结果", 7, 1, "antibioticResult"),
                createField("antibioticResult.examineItemsStr", "抽检详情", 8, 1, "antibioticResult")
        ));

        // 宰前检验情况
        ExportField beforeSlaughterGroup = new ExportField("beforeSlaughter", "宰前检验情况", 9);
        beforeSlaughterGroup.setLevel(0);
        beforeSlaughterGroup.setHasChildren(true);
        beforeSlaughterGroup.setChildren(Arrays.asList(
                createField("roadDealAmount", "途亡头数", 9, 1, "beforeSlaughter"),
                createField("illnessDeadAmount", "进场病死头数", 10, 1, "beforeSlaughter"),
                createField("illnessDiseaseAmount", "进场病害头数", 11, 1, "beforeSlaughter"),
                createField("snapKillAmount", "急宰头数", 12, 1, "beforeSlaughter"),
                createField("dealAmount", "静养病死病害头数", 13, 1, "beforeSlaughter"),
                createField("qualifiedAmountBefore", "合格头数", 14, 1, "beforeSlaughter")
        ));

        // 屠宰头数
        ExportField tuzaiAmount = new ExportField("tuzaiAmount", "屠宰头数", 15);

        // 宰后检验情况
        ExportField afterSlaughterCheckGroup = new ExportField("afterSlaughterCheck", "宰后检验情况", 16);
        afterSlaughterCheckGroup.setLevel(0);
        afterSlaughterCheckGroup.setHasChildren(true);
        afterSlaughterCheckGroup.setChildren(Arrays.asList(
                createField("weight", "病害产品重量", 16, 1, "afterSlaughterCheck"),
                createField("qualifiedAmountAfter", "合格头数", 17, 1, "afterSlaughterCheck")
        ));

        fields.addAll(Arrays.asList(createTime,cargoOwner,drugCheckGroup,antibioticCheckGroup,beforeSlaughterGroup,tuzaiAmount,afterSlaughterCheckGroup));
        return fields;
    }

    /**
     * 生猪屠宰环节无害化处理表可用字段配置
     */
    @Override
    public List<ExportField> getDailyHarmlessReportFields() {
        List<ExportField> fields = new ArrayList<>();
        ExportField createTime = new ExportField("createTime", "日期", 1);
        ExportField cargoOwner = new ExportField("cargoOwner", "货主", 2);
        ExportField animalType = new ExportField("animalType", "畜种", 2);

        // 处理数量
        ExportField dealSumGroup = new ExportField("dealSum", "处理数量", 3);
        dealSumGroup.setLevel(0);
        dealSumGroup.setHasChildren(true);
        dealSumGroup.setChildren(Arrays.asList(
                createField("roadDealAmount", "途亡头数", 3, 1, "dealSum"),
                createField("illnessDiseaseAmount", "进场病害头数", 4, 1, "dealSum"),
                createField("illnessDeadAmount", "进场病死头数", 5, 1, "dealSum"),
                createField("snapKillAmount", "静养病死病害头数", 6, 1, "dealSum")
        ));

        // 病害产品
        ExportField illnessDiseaseProductGroup = new ExportField("produceCheckVos", "病害产品", 7);
        illnessDiseaseProductGroup.setLevel(0);
        illnessDiseaseProductGroup.setHasChildren(true);
        illnessDiseaseProductGroup.setChildren(Arrays.asList(
                createMergeField("produceCheckVos", "produceName", "产品(部位)名称", 7, 1),
                createMergeField("produceCheckVos", "unqualifiedNumStr", "重量/数量",8, 1)
        ));


        fields.addAll(Arrays.asList(createTime,cargoOwner,animalType,dealSumGroup,illnessDiseaseProductGroup));
        return fields;
    }

    /**
     * 产品出场情况表可用字段配置
     */
    @Override
    public List<ExportField> getDailyOutputReportFields() {
        List<ExportField> fields = new ArrayList<>();
        ExportField createTime = new ExportField("createTime", "日期", 1);
        ExportField cargoOwner = new ExportField("cargoOwner", "货主", 2);
        ExportField animalType = new ExportField("animalType", "畜种", 2);
        ExportField produceName = new ExportField("produceName", "产品名称", 3);
        ExportField animalCert = new ExportField("animalCert", "动物检疫合格证", 4);
        ExportField meatCert = new ExportField("meatCert", "肉品品质检验合格证", 5);



        // 本市
        ExportField inCityGroup = new ExportField("inCity", "本市", 6);
        inCityGroup.setLevel(1);
        inCityGroup.setHasChildren(true);
        inCityGroup.setParent("salePlaceAndSum");
        inCityGroup.setChildren(Arrays.asList(
                createField("amountStr_1", "数量", 8, 2, "inCity"),
                createField("weightStr_1", "重量", 9, 2, "inCity")
        ));

        // 本省
        ExportField inProvinceGroup = new ExportField("inProvince", "本省", 7);
        inProvinceGroup.setLevel(1);
        inProvinceGroup.setHasChildren(true);
        inProvinceGroup.setParent("salePlaceAndSum");
        inProvinceGroup.setChildren(Arrays.asList(
                createField("amountStr_2", "数量", 10, 2, "inProvince"),
                createField("weightStr_2", "重量", 11, 2, "inProvince")
        ));

        // 外省
        ExportField outProvinceGroup = new ExportField("outProvince", "外省", 8);
        outProvinceGroup.setLevel(1);
        outProvinceGroup.setHasChildren(true);
        outProvinceGroup.setParent("salePlaceAndSum");
        outProvinceGroup.setChildren(Arrays.asList(
                createField("amountStr_3", "数量", 12, 2, "outProvince"),
                createField("weightStr_3", "重量", 13, 2, "outProvince")
        ));

        // 销售地流向与数量
        ExportField salePlaceAndSumGroup = new ExportField("salePlaceAndSum", "销售地流向与数量", 6);
        salePlaceAndSumGroup.setLevel(0);
        salePlaceAndSumGroup.setHasChildren(true);
        salePlaceAndSumGroup.setChildren(Arrays.asList(inCityGroup,inProvinceGroup,outProvinceGroup));

        fields.addAll(Arrays.asList(createTime,cargoOwner,animalType,produceName,animalCert,meatCert,salePlaceAndSumGroup));
        return fields;
    }

    /**
     * 生猪入场查验情况表可用字段配置
     */
    @Override
    public List<ExportField> getDailyEntranceReportFields() {
        List<ExportField> fields = new ArrayList<>();
        ExportField createTime = new ExportField("createTime", "日期", 1);
        ExportField animalType = new ExportField("animalType", "畜种", 1);
        ExportField cargoOwner = new ExportField("cargoOwner", "货主", 2);
        ExportField originPlace = new ExportField("originPlace", "产地", 3);
        ExportField animalCertNo = new ExportField("animalCertNo", "动物检疫合格证明编号", 4);
        ExportField roadDealAmount = new ExportField("roadDealAmount", "途亡头数", 5);

        // 到场活猪头数
        ExportField entranceAmountGroup = new ExportField("entranceAmount", "到场存活头数", 6);
        entranceAmountGroup.setLevel(0);
        entranceAmountGroup.setHasChildren(true);
        entranceAmountGroup.setChildren(Arrays.asList(
                createField("tuzaiAmount", "待宰", 6, 1, "entranceAmount")
        ));

        // 入场查验情况
        ExportField inspectDetailGroup = new ExportField("inspectDetail", "入场查验情况", 7);
        inspectDetailGroup.setLevel(0);
        inspectDetailGroup.setHasChildren(true);
        inspectDetailGroup.setChildren(Arrays.asList(
                createField("illnessDiseaseAmount", "病害头数", 7, 1, "inspectDetail"),
                createField("illnessDeadAmount", "病死头数", 8, 1, "inspectDetail"),
                createField("snapKillAmount", "急宰头数", 9, 1, "inspectDetail"),
                createField("qualifiedAmount", "查验合格入场头数", 10, 1, "inspectDetail")
        ));

        fields.addAll(Arrays.asList(createTime,animalType ,cargoOwner,originPlace,animalCertNo,roadDealAmount,entranceAmountGroup,inspectDetailGroup));
        return fields;
    }

    @Override
    public List<ExportField> getStockReportFields() {
        List<ExportField> fields = new ArrayList<>();
        ExportField createTime = new ExportField("createTime", "日期", 1);
        ExportField materialName = new ExportField("materialName", "品种", 2);
        ExportField inNum = new ExportField("inNum", "进货数量", 3);
        ExportField outNum = new ExportField("outNum", "出库数量", 4);
        ExportField number = new ExportField("number", "库存数量", 5);
        ExportField linghuoren = new ExportField("linghuoren", "领货人", 6);
        ExportField shenpi = new ExportField("shenpi", "审批人", 7);


        fields.addAll(Arrays.asList(createTime,materialName,inNum,outNum,number,linghuoren,shenpi));
        return fields;
    }


    @Override
    public List<ExportField> getZhuanYunReportFields() {

        List<ExportField> fields = new ArrayList<>();
        ExportField ruKuTime = new ExportField("ruKuTime", "入库日期", 1);
        ExportField ruKuNum = new ExportField("ruKuNum", "入库数量", 2);
        ExportField chuLiTime = new ExportField("chuLiTime", "处理日期", 3);
        ExportField chuLinum = new ExportField("chuLinum", "处理数量", 4);
        ExportField guanLiYuan = new ExportField("guanLiYuan", "管理人签字", 5);
        ExportField jiaoJieChuLiRen = new ExportField("jiaoJieChuLiRen", "交接处理人签字", 6);
        ExportField kuChunNum = new ExportField("kuChunNum", "库存数量", 7);
        ExportField beiZhu = new ExportField("beiZhu", "备注", 7);

        fields.addAll(Arrays.asList(ruKuTime,ruKuNum,chuLiTime,chuLinum,guanLiYuan,jiaoJieChuLiRen,kuChunNum,beiZhu));
        return fields;

    }

    private List<ExportField> getProect() {
        List<GetEnvCheck> proect = slaughterBatchMapper.getProect();
        List<ExportField> list = new ArrayList<>();
        int i =1;
        for (GetEnvCheck s : proect) {
            list.add(   createField(s.getCheckContent(), s.getProjectName(), i+2, 1, "examineItems"));
            i++;
        }
        return list;
    }


    @Override
    public List<ExportField> getZhaoHuiReportFields() {
        List<ExportField> fields = new ArrayList<>();
        ExportField order = new ExportField("order", "序号", 1);
        ExportField produceName = new ExportField("produceName", "产品名称", 2);
        ExportField consumer = new ExportField("consumer", "购买者", 3);
        ExportField recallAmount = new ExportField("recallAmount", "召回数量", 4);
        ExportField recallTime = new ExportField("recallTime", "召回日期", 5);
        ExportField recallReason = new ExportField("recallReason", "召回原因", 6);
        ExportField recallDeal = new ExportField("recallDeal", "处理方式", 7);
        ExportField recallReust = new ExportField("recallReust", "处理结果", 8);
        ExportField remark = new ExportField("remark", "备注", 9);


        fields.addAll(Arrays.asList(order,produceName,consumer,recallAmount,recallTime,recallReason,recallDeal,recallReust,remark));
        return fields;
    }

    @Override
    public List<ExportField> getZaiQianReportFields() {
        List<ExportField> fields = new ArrayList<>();
        ExportField animalCertNo = new ExportField("animalCertNo", "批次", 1);
        ExportField divideTime = new ExportField("divideTime", "入圈时间", 2);
        ExportField amount = new ExportField("amount", "数 量", 3);
        ExportField zunZai = new ExportField("zunZai", "准宰数量", 4);
        ExportField snapKillAmount = new ExportField("snapKillAmount", "急宰数量", 5);
        ExportField siWang = new ExportField("siWang", "死亡数量", 6);
        ExportField inspectionDetail = new ExportField("inspectionDetail", "处理情况", 7);
        ExportField staffName = new ExportField("staffName", "检验人", 8);


        fields.addAll(Arrays.asList(animalCertNo,divideTime,amount,zunZai,snapKillAmount,siWang,inspectionDetail,staffName));
        return fields;
    }

    @Override
    public List<ExportField> getYangPinReportFields() {

        List<ExportField> fields = new ArrayList<>();
        ExportField checkTime = new ExportField("checkTime", "日期", 1);
        ExportField checkProject = new ExportField("checkProject", "检测项目", 2);

        ExportField examineItems = new ExportField("examineItems", "检测环境及结果", 3);
        examineItems.setLevel(0);
        examineItems.setHasChildren(true);
        List<ExportField> list =  getProect();
        examineItems.setChildren(list);

        ExportField examinerConfirm = new ExportField("examinerConfirm", "检测人员", 4);

        fields.addAll(Arrays.asList(checkTime,checkProject,examineItems,examinerConfirm));
        return fields;
    }

    @Override
    public List<ExportField> getDaiZaiReportFields() {
        List<ExportField> fields = new ArrayList<>();
        ExportField pigpenName = new ExportField("pigpenName", "圈舍号", 1);
        ExportField amount = new ExportField("amount", "数量", 2);

        ExportField animalCertNo = new ExportField("animalCertNo", "自营或代宰", 3);

        ExportField divideTime = new ExportField("divideTime", "入圈时间", 4);
        ExportField planStartTime = new ExportField("planStartTime", "送宰时间", 5);
        ExportField hourDiff = new ExportField("hourDiff", "停食静养时间", 6);
        ExportField siWang = new ExportField("siWang", "待宰前死亡数量", 7);
        ExportField illnessDiseaseAmount = new ExportField("illnessDiseaseAmount", "病害处理数量", 8);
        ExportField examinerConfirm = new ExportField("examinerConfirm", "无害化处理", 9);
        examinerConfirm.setLevel(0);
        examinerConfirm.setHasChildren(true);
        examinerConfirm.setChildren(Arrays.asList(
                createField("dealReason", "原因", 9, 1, "examinerConfirm"),
                createField("inspectionDetail", "方式", 10, 1, "examinerConfirm")

        ));
        ExportField snapKillAmount = new ExportField("snapKillAmount", "急宰数量", 11);
        ExportField zunZai = new ExportField("zunZai", "准宰数量", 12);
        ExportField staffName = new ExportField("staffName", "检验人员签字", 13);

        fields.addAll(Arrays.asList(pigpenName,amount,animalCertNo,divideTime,planStartTime,hourDiff,
                siWang,illnessDiseaseAmount,examinerConfirm,snapKillAmount,zunZai,staffName));
        return fields;
    }
    @Override
    public List<ExportField> getRuChangReportFields() {
        List<ExportField> fields = new ArrayList<>();
        ExportField cargoOwner = new ExportField("cargoOwner", "货主姓名", 1);
        ExportField cargoOwnerPhone = new ExportField("cargoOwnerPhone", "联系方式", 2);

        ExportField transportVehicle = new ExportField("transportVehicle", "车牌号", 3);

        ExportField dictLabel = new ExportField("dictLabel", "产地", 4);
        ExportField animalType = new ExportField("animalType", "畜种", 4);
        ExportField animalCertNo = new ExportField("animalCertNo", "动物检疫合格证明号", 5);
        ExportField examinerConfirm = new ExportField("examinerConfirm", "数量", 6);
        examinerConfirm.setLevel(0);
        examinerConfirm.setHasChildren(true);
        examinerConfirm.setChildren(Arrays.asList(
                createField("buhege", "原因", 6, 1, "examinerConfirm"),
                createField("hege", "方式", 7, 1, "examinerConfirm")

        ));

        ExportField pigpenName = new ExportField("pigpenName", "圈舍号", 6);
        ExportField amount = new ExportField("amount", "存栏数量", 7);
        ExportField jieGuo = new ExportField("jieGuo", "验收结果", 8);
        ExportField illnessDiseaseAmount = new ExportField("illnessDiseaseAmount", "检验人员签字", 9);


        fields.addAll(Arrays.asList(cargoOwner,cargoOwnerPhone,transportVehicle,dictLabel,animalType ,animalCertNo,
                examinerConfirm,pigpenName,jieGuo,illnessDiseaseAmount,amount));
        return fields;
    }
    @Override
    public List<ExportField> getChuChangReportFields() {
        List<ExportField> fields = new ArrayList<>();
        ExportField produNum = new ExportField("produNum", "生产批号", 1);
        ExportField supplierName = new ExportField("supplierName", "货主", 2);

        ExportField produceName = new ExportField("produceName", "产品名称", 3);

        ExportField unit = new ExportField("unit", "规格", 4);
        ExportField amount = new ExportField("amount", "数量", 5);
        ExportField animalCertNo = new ExportField("animalCertNo", "检疫证明号", 6);

        ExportField meatCert = new ExportField("meatCert", "肉品品质检验合格证号", 7);
        ExportField tuZaiDate = new ExportField("tuZaiDate", "屠宰日期", 8);
        ExportField distributionTime = new ExportField("distributionTime", "出厂日期", 9);
        ExportField other = new ExportField("other", "检验员签字", 10);


        fields.addAll(Arrays.asList(produNum,supplierName,produceName,unit,amount,animalCertNo,
                meatCert,tuZaiDate,distributionTime,other));
        return fields;
    }
    @Override
    public List<ExportField> getFuJianReportFields() {
        List<ExportField> fields = new ArrayList<>();
        ExportField produNum = new ExportField("produNum", "样品复检登记表", 1);
        produNum.setLevel(0);
        produNum.setHasChildren(true);
        produNum.setChildren(Arrays.asList(
                createField("produceName", "样品名称", 2, 1, "produNum"),
                createField("keepTime", "留样时间", 3, 1, "produNum"),
                createField("checkTime", "首次检测时间", 3, 1, "produNum"),
                createField("examineItems", "检测结果", 3, 1, "produNum"),
                createField("recheckTime", "复检时间", 3, 1, "produNum"),
                createField("recheckItem", "复检结果", 3, 1, "produNum"),
                createField("hege", "差异分析", 3, 1, "produNum")

        ));

        fields.addAll(Arrays.asList(produNum));
        return fields;
    }
    @Override
    public List<ExportField> getZaiHouReportFields() {
        List<ExportField> fields = new ArrayList<>();
        ExportField animalCertNo = new ExportField("animalCertNo", "批次", 1);
        ExportField cargoOwner = new ExportField("cargoOwner", "货主名称", 2);
        ExportField tuZai = new ExportField("tuZai", "屠宰数量", 3);
        ExportField animalType = new ExportField("animalType", "畜种", 3);
        ExportField zaiHou = new ExportField("zaiHou", "宰后检验", 4);
        zaiHou.setLevel(0);
        zaiHou.setHasChildren(true);
        ExportField buHeGe = createField("buHeGe", "不合格", 4, 1, "zaiHou");
            buHeGe.setHasChildren(true);
                 ExportField wuHaiHua = createField("wuHaiHua", "无害化处理", 7, 2, "buHeGe");
                 wuHaiHua.setHasChildren(true);
                     wuHaiHua.setChildren(  Arrays.asList(
                             createField("dealReason", "原因", 7, 3, "wuHaiHua"),
                             createField("inspectionDetail", "方式", 8, 3, "wuHaiHua")
                     ));
            buHeGe.setChildren(  Arrays.asList(
                    createField("illnessDiseaseAmount", "病害处理数量", 5, 2, "buHeGe"),
                    createField("illnessDiseaseProduAmount", "病害产品处理数量", 6, 2, "buHeGe"),
                    wuHaiHua
            ));

        zaiHou.setChildren(Arrays.asList(buHeGe,
                createField("heGe", "合格数量", 5, 1, "zaiHou")

        ));
        ExportField jianyan = new ExportField("jianyan", "检验人员签字", 6);

        fields.addAll(Arrays.asList(animalCertNo,cargoOwner,tuZai,animalType ,zaiHou,jianyan));
        return fields;
    }

    @Override
    public List<ExportField> getXunChaReportFields() {
        List<ExportField> fields = new ArrayList<>();
        ExportField animalCertNo = new ExportField("animalCertNo", "批次", 1);
        ExportField defaultWeight = new ExportField("defaultWeight", "货主名称", 2);
        ExportField seriesNo = new ExportField("seriesNo", "屠宰数量", 3);
        ExportField amount = new ExportField("amount", "宰后检验", 4);

        ExportField zaiQianZhonliang = new ExportField("zaiQianZhonliang", "宰后检验", 5);
        ExportField variety = new ExportField("variety", "宰后检验", 6);
        ExportField zaiHouZhongLiang = new ExportField("zaiHouZhongLiang", "宰后检验", 7);
        ExportField supplierName = new ExportField("supplierName", "宰后检验", 8);
        ExportField produNum = new ExportField("produNum", "宰后检验", 9);
        ExportField planStartTime = new ExportField("planStartTime", "宰后检验", 10);

        fields.addAll(Arrays.asList(animalCertNo,defaultWeight,seriesNo,amount,zaiQianZhonliang,variety,zaiHouZhongLiang,supplierName,produNum,planStartTime));
        return fields;
    }

    @Override
    public List<ExportField> getTuzaiShengChanReportFields() {
        List<ExportField> fields = new ArrayList<>();
        ExportField produNum = new ExportField("produNum", "现场巡查记录表", 1);
        produNum.setLevel(0);
        produNum.setHasChildren(true);
        produNum.setChildren(Arrays.asList(
                createField("produceName", "巡查点位", 2, 1, "produNum"),
                createField("animalType", "畜种", 2, 1, "animalType"),
                createField("abnormal", "巡查内容", 3, 1, "produNum"),
                createField("disposalMethod", "异常情况描述", 3, 1, "produNum"),
                createField("result", "处置方式", 3, 1, "produNum"),
                createField("inspector", "处置结果", 3, 1, "produNum"),
                createField("inspector", "巡查人", 3, 1, "produNum"),
                createField("inspectTime", "巡查时间", 3, 1, "produNum")

        ));

        fields.addAll(Arrays.asList(produNum));
        return fields;
    }
    /**
     * 创建可合并的字段
     */
    private ExportField createMergeField(String listField, String property,
                                         String columnName, int order, int level) {
        ExportField field = new ExportField();
        field.setFieldName(listField + "[0]." + property); // 使用索引0作为模板
        field.setColumnName(columnName);
        field.setOrder(order);
        field.setLevel(level);
        field.setParent(listField);
        field.setSelected(true);
        field.setChildren(new ArrayList<>());
        field.setHasChildren(false);
        field.setMergeable(true);
        field.setListField(listField);
        field.setListProperty(property);

        return field;
    }

    private ExportField createNestedField(String fieldPath, String columnName,
                                          int order, int level, String parent) {
        ExportField field = new ExportField();
        field.setFieldName(fieldPath);
        field.setColumnName(columnName);
        field.setOrder(order);
        field.setLevel(level);
        field.setParent(parent);
        field.setSelected(true);
        field.setChildren(new ArrayList<>());
        field.setHasChildren(false);
        field.setMergeable(false);

        return field;
    }

    private ExportField createField(String fieldName, String columnName, int order, int level, String parent) {
        ExportField field = new ExportField();
        field.setFieldName(fieldName);
        field.setColumnName(columnName);
        field.setOrder(order);
        field.setLevel(level);
        field.setParent(parent);
        field.setSelected(true);
        field.setChildren(new ArrayList<>());
        field.setHasChildren(false);
        return field;
    }
}