package com.sunxung.factoring.service.salescontractmanagement.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sunxung.factoring.component.exception.BusinessException;
import com.sunxung.factoring.component.exception.ValidatorException;
import com.sunxung.factoring.component.util.*;
import com.sunxung.factoring.dict.impl.FileModuleDict;
import com.sunxung.factoring.dict.impl.ProjectInitiationStatusDict;
import com.sunxung.factoring.entity.project.BusinessProcessingLog;
import com.sunxung.factoring.entity.project.ProjectInformation;
import com.sunxung.factoring.entity.project.vo.BusinessProcessingTaskVo;
import com.sunxung.factoring.entity.project.vo.ProjectInformationVo;
import com.sunxung.factoring.entity.project.vo.SearchBusinessProcessingTask;
import com.sunxung.factoring.entity.salescontractmanagement.*;
import com.sunxung.factoring.entity.salescontractmanagement.vo.SalesContractBasicVo;
import com.sunxung.factoring.entity.sys.Dictionary;
import com.sunxung.factoring.entity.sys.FileStorage;
import com.sunxung.factoring.entity.sys.FileStorageDO;
import com.sunxung.factoring.entity.sys.User;
import com.sunxung.factoring.mapper.salescontractmanagement.SalesContractMapper;
import com.sunxung.factoring.service.project.BusinessProcessingLogService;
import com.sunxung.factoring.service.project.IProjectInformationService;
import com.sunxung.factoring.service.salescontractmanagement.*;
import com.sunxung.factoring.service.sys.*;
import com.sunxung.factoring.service.sys.dto.AttachmentDto;
import com.sunxung.factoring.service.sys.flowable.FlowableService;
import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Description : 销售合同service实现类
 * @Author : L.Jia
 * @Date: 2021-09-03 16:03
 */
@Service("salesContractService")
public class SalesContractServiceImpl extends ServiceImpl<SalesContractMapper, CSalesContract>
        implements SalesContractService {

    @Autowired
    private ICSalesContractBasicInfoService salesContractBasicInfoService;

    @Autowired
    private SalesContractGoodsInfoService salesContractGoodsInfoService;

    @Autowired
    private DictionaryService dictService;

    @Autowired
    private FlowableService flowableService;

    @Autowired
    private UserService userService;

    @Autowired
    private ISysAttachmentRefService attachmentRefService;

    @Autowired
    private FileStorageService fileStorageService;

    @Autowired
    private ISalesContractManagementHisService salesContractManagementHisService;

    @Autowired
    private FileService fileService;

    @Autowired
    private BusinessProcessingLogService businessProcessingLogService;

    @Resource(name = "projectInformationService")
    private IProjectInformationService projectInformationService;

    @Autowired
    private ISalesContractSupplementInfoService salesContractSupplementInfoService;

    @Autowired
    private ICSalesSignConfirmationService salesSignConfirmationService;

    @Autowired
    private ICSalesSignConfirmationElectronicInfoService signConfirmationElectronicInfoService;

    @Autowired
    private ICSalesContractSupplementBasicInfoService salesContractSupplementBasicInfoService;

    @Autowired
    private ICSalesSupplementSignConfirmationService salesSupplementSignConfirmationService;

    @Autowired
    private ICSalesSupplementSignConfirmationElectronicInfoService salesSupplementSignConfirmationElectronicInfoService;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void doCreate(CSalesContract salesContractManagement) {

        salesContractManagement.setContractStatus(ProjectInitiationStatusDict.ChildEnum.PROCESSING.getCode());

        if (salesContractManagement.getId() == null) {
            //数据处理
            save(salesContractManagement);

            //文件处理
            if (CollectionUtil.isNotEmpty(salesContractManagement.getFileIds())) {
                salesContractManagement.getFileIds().forEach(c -> {
                    FileStorageDO fileStorageDO = fileService.getById(c);
                    fileStorageDO.setBusinessId(salesContractManagement.getId());
                    fileService.updateById(fileStorageDO);
                });
            }

            //开启流程
            startSalesContractProcess(salesContractManagement);
            //变更项目的是否已做销售合同标识
            projectInformationService.lambdaUpdate().set(ProjectInformation::getSales, 1)
                    .eq(ProjectInformation::getBusinessNumber, salesContractManagement.getBusinessNumber())
                    .update();
        } else {
            updateById(salesContractManagement);
            //文件处理
            fileService.lambdaUpdate().eq(FileStorageDO::getBusinessId, salesContractManagement.getId())
                    .eq(FileStorageDO::getBusinessType, FileModuleDict.ChildEnum.SALES_CONTRACT_MANAGEMENT_FILE.getCode())
                    .set(FileStorageDO::getBusinessId, null);
            if (CollectionUtil.isNotEmpty(salesContractManagement.getFileIds())) {
                salesContractManagement.getFileIds().forEach(c -> {
                    FileStorageDO fileStorageDO = fileService.getById(c);
                    fileStorageDO.setBusinessId(salesContractManagement.getId());
                    fileService.updateById(fileStorageDO);
                });
            }

        }

        //查询taskId
        BusinessProcessingLog lastLog = businessProcessingLogService
                .getByBusinessTypeBusinessKey(ConstantUtil.SALES_CONTRACT, salesContractManagement.getId());
        salesContractManagement.setTaskId(lastLog.getHistoricTaskId());
        //处理流程
        handleProcess(salesContractManagement);
    }

    @Override
    public CSalesContract get(Long id) {
        CSalesContract salesContractManagement = baseMapper.get(id);
        Dictionary status = dictService.getByCode(salesContractManagement.getContractStatus());
        salesContractManagement.setStatusDictionary(status);
        return salesContractManagement;
    }

    private Long addHistory(CSalesContract salesContractManagement) {

        SalesContractManagementHis contractManagementHis = new SalesContractManagementHis();
        BeanUtil.copyProperties(salesContractManagement, contractManagementHis);
        salesContractManagementHisService.save(contractManagementHis);

        //保存文件
        List<FileStorageDO> fileStorageDOS = fileService.listByIds(salesContractManagement.getFileIds());
        fileStorageDOS.stream().forEach(fileStorageDO -> {
            fileStorageDO.setId(null);
            fileStorageDO.setBusinessType(FileModuleDict.ChildEnum.SALES_CONTRACT_MANAGEMENT_HIS_FILE.getCode());
            fileStorageDO.setBusinessId(contractManagementHis.getId());
            fileService.save(fileStorageDO);
        });

        return contractManagementHis.getId();
    }


    @Override
    public List<BusinessProcessingTaskVo> findMyCompletedList(SearchBusinessProcessingTask search) {
        return baseMapper.findMyCompletedList(search);
    }

    @Override
    public List<BusinessProcessingTaskVo> findAllList(SearchBusinessProcessingTask search) {

        List<BusinessProcessingTaskVo> list = baseMapper.findAllList(search);
        if (CollectionUtil.isNotEmpty(list)) {
            list.forEach(r -> {
                BusinessProcessingLog log = businessProcessingLogService.getByBusinessTypeBusinessKey(search.getSimpleClassName(), r.getId());
                if (log != null && log.getEndTime() == null) {
                    String taskName = log.getTaskName();
                    if (taskName.contains("创建") || taskName.contains("录入") || taskName.contains("签署确认")) {
                        r.setExecutor("供应商");
                    } else if (taskName.contains("初审") || taskName.contains("审核") || taskName.contains("签署确认审核")) {
                        r.setExecutor("法务专员");
                    } else if (taskName.contains("模板复审")) {
                        r.setExecutor("法务经理");
                    }
                }
            });
        }

        return list;
    }


    @Override
    @Transactional(rollbackFor = Exception.class)
    public void change(Long id) {
        CSalesContract salesContractManagement = baseMapper.selectById(id);

        if (salesContractManagement == null) {
            throw new ValidatorException(CodeUtil.FAIL, "对应销售信息不存在");
        }

        User admin = userService.getByLoginName("admin");

        //2.开启销售合同变更流程
        //开启流程实例
        Map<String, Object> procVariables = new HashMap<>(1);
        procVariables.put(ConstantUtil.SALES_CONTRACT_CHANGE + ConstantUtil.ASSIGNEE, admin.getId());
        //查询条件：业务编号/项目名称/主企业名称/核心企业名称
        //项目信息
        ProjectInformation projectInformation = projectInformationService
                .getOne(new QueryWrapper<ProjectInformation>()
                        .eq("business_number", salesContractManagement.getBusinessNumber()));
        ProjectInformationVo projectInformationVo = projectInformationService.getByBusinessNo(salesContractManagement.getBusinessNumber());


        //查询条件：业务编号/买方名称/业务名称
        String queryBusiness = salesContractManagement.getBusinessNumber() + FlowableUtil.splitChar +
                projectInformation.getProjectName() + FlowableUtil.splitChar + projectInformationVo.getEnterprise()
                + FlowableUtil.splitChar + projectInformationVo.getMainEnterprise();

        ProcessInstance processInst = flowableService.startProcessInstance(salesContractManagement, procVariables,
                FlowableUtil.generateBusinessKey(salesContractManagement, ConstantUtil.SALES_CONTRACT_CHANGE_PROCESS, queryBusiness),
                null, ConstantUtil.SALES_CONTRACT_CHANGE_PROCESS);
        if (processInst == null) {
            throw new BusinessException(CodeUtil.FAIL, "流程启动失败");
        }
    }

    @Override
    public List<CSalesContractGoodsInfo> importGoodsInfo(MultipartFile file) {
        return salesContractGoodsInfoService.importGoodsInfo(file);
    }

    @Override
    public CSalesContract getByBusinessNumber(String businessNumber) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("business_number", businessNumber);
        return baseMapper.selectOne(queryWrapper);
    }

    @Override
    public void downloadTemplateFile(HttpServletResponse response) {

        OutputStream out = null;
        BufferedInputStream inputStream = null;
        try {
            ClassPathResource classPathResource = new ClassPathResource("templateFiles/销售合同货物信息.xlsx");
            response.setHeader("Content-Type", "application/vnd.ms-exce");
            response.setHeader("Content-Length", String.valueOf(classPathResource.contentLength()));
            response.setHeader("Content-disposition", "attachment;filename=" + java.net.URLEncoder.encode(classPathResource.getFilename(), "UTF-8"));
            out = response.getOutputStream();
            inputStream = new BufferedInputStream(classPathResource.getInputStream());
            byte[] buffer = new byte[1024];
            while ((inputStream.read(buffer)) > 0) {
                out.write(buffer);
                out.flush();
            }

        } catch (Exception e) {
            throw new BusinessException("500", "下载模板失败!");
        } finally {
            try {
                inputStream.close();
                out.close();
            } catch (IOException e) {
                log.error("关闭文件流失败!");
            }
        }
    }

    @Override
    public CSalesContractBasicInfo findByBusinessNumber(String businessNumber) {
        CSalesContract contractManagement = getOne(new QueryWrapper<CSalesContract>().eq("business_number", businessNumber));
        CSalesContractBasicInfo contractBasicInfo = salesContractBasicInfoService.getOne(new QueryWrapper<CSalesContractBasicInfo>()
                .eq("c_sales_contract_management_id", contractManagement.getId())
                .orderByDesc("gmt_modified")
                .last("limit 1"));
        return contractBasicInfo;
    }

    /**
     * 销售合同流程开启
     *
     * @param salesContractManagement
     */
    private void startSalesContractProcess(CSalesContract salesContractManagement) {

        User admin = userService.getByLoginName("admin");

        List<Long> legalSpecialists = userService.findUserIdByRole(ConstantUtil.LEGAL_SPECIALIST);
        if (legalSpecialists == null || legalSpecialists.size() == 0) {
            throw new ValidatorException(CodeUtil.FAIL, ConstantUtil.OPERATION_SPECIALIST + "角色内无任何用户！");
        }

        //3.开启流程实例
        Map<String, Object> procVariables = new HashMap<>();
        procVariables.put(ConstantUtil.SALES_CONTRACT_CREATE + ConstantUtil.ASSIGNEE, admin.getId());
        //项目信息
        ProjectInformation projectInformation = projectInformationService
                .getOne(new QueryWrapper<ProjectInformation>()
                        .eq("business_number", salesContractManagement.getBusinessNumber()));
        ProjectInformationVo projectInformationVo = projectInformationService.getByBusinessNo(salesContractManagement.getBusinessNumber());


        //查询条件：业务编号/买方名称/业务名称
        String queryBusiness = salesContractManagement.getBusinessNumber() + FlowableUtil.splitChar +
                projectInformation.getProjectName() + FlowableUtil.splitChar + projectInformationVo.getEnterprise()
                + FlowableUtil.splitChar + projectInformationVo.getMainEnterprise();

        flowableService.startProcessInstance(salesContractManagement, procVariables,
                FlowableUtil.generateBusinessKey(salesContractManagement, ConstantUtil.SALES_CONTRACT, queryBusiness), null, ConstantUtil.SALES_CONTRACT);
    }

    /**
     * 处理流程
     *
     * @param salesContractManagement
     * @return
     */
    private void handleProcess(CSalesContract salesContractManagement) {
        ThreadLocalUtil.setUser(userService.getByLoginName("admin"));
        //流程处理
        String processKey = ConstantUtil.SALES_CONTRACT;
        String assigneeKey = ConstantUtil.TEMPLATE_FIRST_APPROVAL + ConstantUtil._CANDIDATE;

        List<Long> legalIdList = userService.findUserIdByRole(ConstantUtil.LEGAL_SPECIALIST);
        String legalIds = legalIdList.stream().map(c -> c.toString()).collect(Collectors.joining(","));

        Map<String, Object> procVariables = new HashMap<>(1);
        procVariables.put(assigneeKey, legalIds);
        Map<String, Object> msgVariables = new HashMap<>(2);
        //项目信息
        ProjectInformation projectInformation = projectInformationService
                .getOne(new QueryWrapper<ProjectInformation>()
                        .eq("business_number", salesContractManagement.getBusinessNumber()));
        msgVariables.put(ConstantUtil.FLOWABLE_MSG_TITLE, projectInformation.getProjectName());
        msgVariables.put(ConstantUtil.FLOWABLE_MSG_CONTENT,
                "业务编号为" + salesContractManagement.getBusinessNumber() + "”的项目已inOut“"
                        + ConstantConversionUtil.flowBusinessKeyNames.get(processKey) + "—formBusiness”阶段，");
        Long historyId = addHistory(salesContractManagement);
        Boolean success = flowableService.completeMyTask(salesContractManagement.getTaskId(), salesContractManagement, procVariables, null, historyId,
                msgVariables, processKey, legalIdList);
        if (success == null || !success) {
            throw new ValidatorException(CodeUtil.FAIL, "销售合同-业务录入时出错啦！");
        }
    }

    @Override
    public SalesContractBasicVo getBasicInfoById(Long id) {
        return baseMapper.getBasicInfoById(id);
    }

    @Override
    public SalesContractBasicVo getBasicInfoByHisId(Long hisId) {
        return baseMapper.getBasicByHisId(hisId);
    }

    @Override
    public void downloadAllSalesContractFile(Long id, HttpServletResponse response) {

        List<FileStorage> salesContractAllFile = new ArrayList<>();
        CSalesContract salesContractManagement = get(id);
        CSalesContractBasicInfo salesContractBasicInfo = salesContractBasicInfoService
                .getOne(new QueryWrapper<CSalesContractBasicInfo>().eq("c_sales_contract_management_id", id));
        //销售合同原件
        //合同文件
        List<FileStorageDO> fileStorageDOS = fileService.findByBusinessId(salesContractBasicInfo.getId(), FileModuleDict.ChildEnum.SALES_CONTRACT_FILE.getCode());
        if (CollectionUtil.isNotEmpty(fileStorageDOS)) {
            fileStorageDOS.forEach(fileStorageDO -> {
                FileStorage fileStorage = new FileStorage();
                fileStorage.setAbsolutePath(fileStorageDO.getAbsolutePath());
                fileStorage.setName(fileStorageDO.getOriginalName());
                fileStorage.setPath(fileStorageDO.getPath());
                fileStorage.setId(fileStorageDO.getId());
                fileStorage.setOriginalName(fileStorageDO.getOriginalName());
                salesContractAllFile.add(fileStorage);
            });
        }
        //已签署的文件
        CSalesSignConfirmation salesSignConfirmation = salesSignConfirmationService
                .lambdaQuery().eq(CSalesSignConfirmation::getcSalesContractManagementId, id).one();
        if (salesSignConfirmation != null) {
            List<CSalesSignConfirmationElectronicInfo> signElectronicInfos = signConfirmationElectronicInfoService
                    .list(new QueryWrapper<CSalesSignConfirmationElectronicInfo>().eq("c_sales_sign_confirmation_id", salesSignConfirmation.getId()));
            if (CollectionUtil.isNotEmpty(signElectronicInfos)) {
                signElectronicInfos.forEach(signElectronicInfo -> {
                    salesContractAllFile.addAll(attachmentRefService.getFiles(AttachmentDto.builder()
                            .setChildEnum(FileModuleDict.ChildEnum.SIGN_CONFIRM_BACK_FILE).setEntityId(signElectronicInfo.getId()).build()));
                });
            }
        }
        //销售合同补充文件
        List<CSalesContractSupplementInfo> salesContractSupplementInfos = salesContractSupplementInfoService
                .list(new QueryWrapper<CSalesContractSupplementInfo>().eq("c_sales_contract_management_id", salesContractManagement.getId()));
        if (CollectionUtil.isNotEmpty(salesContractSupplementInfos)) {
            salesContractSupplementInfos.stream().forEach(s -> {
                if (salesContractManagement.getContractStatus().equals(ProjectInitiationStatusDict.ChildEnum.COMPLETED.getCode())) {

                    //补充合同原件
                    CSalesContractSupplementBasicInfo salesContractSupplementBasicInfo = salesContractSupplementBasicInfoService.lambdaQuery()
                            .eq(CSalesContractSupplementBasicInfo::getcSalesContractSupplementInfoId, s.getId())
                            .one();
                    List<FileStorageDO> SupplementFileStorageDOS = fileService.findByBusinessId(salesContractSupplementBasicInfo.getId(),
                            FileModuleDict.ChildEnum.SALES_CONTRACT_SUPPLEMENT_CONTRACT_FILE.getCode());
                    if (CollectionUtil.isNotEmpty(SupplementFileStorageDOS)) {
                        SupplementFileStorageDOS.forEach(fileStorageDO -> {
                            FileStorage fileStorage = new FileStorage();
                            fileStorage.setAbsolutePath(fileStorageDO.getAbsolutePath());
                            fileStorage.setName(fileStorageDO.getOriginalName());
                            fileStorage.setPath(fileStorageDO.getPath());
                            fileStorage.setId(fileStorageDO.getId());
                            fileStorage.setOriginalName(fileStorageDO.getOriginalName());
                            salesContractAllFile.add(fileStorage);
                        });
                    }

                    CSalesSupplementSignConfirmation salesSupplementSignConfirmation = salesSupplementSignConfirmationService
                            .lambdaQuery().eq(CSalesSupplementSignConfirmation::getcSalesContractSupplementInfoId, s.getId()).one();
                    if (salesSupplementSignConfirmation != null) {
                        List<CSalesSupplementSignConfirmationElectronicInfo> supplementSignConfirmationElectronicInfos = salesSupplementSignConfirmationElectronicInfoService
                                .lambdaQuery().eq(CSalesSupplementSignConfirmationElectronicInfo::getcSalesSupplementSignConfirmationId, salesSupplementSignConfirmation.getId()).list();
                        if (CollectionUtil.isNotEmpty(supplementSignConfirmationElectronicInfos)) {
                            //获取销售合同补充签署的附件
                            supplementSignConfirmationElectronicInfos.forEach(supplementSignConfirmationElectronicInfo -> {
                                List<FileStorage> salesContractSupplementFiles = attachmentRefService.getFiles(AttachmentDto.builder()
                                        .setChildEnum(FileModuleDict.ChildEnum.SALES_SUPPLEMENT_SIGN_CONFIRM_BACK_FILE)
                                        .setEntityId(supplementSignConfirmationElectronicInfo.getId()).build());
                                salesContractAllFile.addAll(salesContractSupplementFiles);
                            });
                        }

                    }
                }
            });
        }

        //文件名去重
        fileStorageService.renameFileStorageList(salesContractAllFile);
        //打包下载文件
        fileStorageService.downloadZipFile(salesContractAllFile, FileModuleDict.ChildEnum.SALES_CONTRACT_ZIP_FILE.getCname(),
                FileModuleDict.ChildEnum.SALES_CONTRACT_ZIP_FILE, response);
    }

    @Override
    public void downloadReportUrl(Long id, HttpServletResponse res) throws IOException {

        List<FileStorage> salesReportFiles = new ArrayList<>();

        CSalesContract cSalesContract = get(id);
        CSalesSignConfirmation salesSignConfirmation = salesSignConfirmationService
                .lambdaQuery().eq(CSalesSignConfirmation::getcSalesContractManagementId, id).one();
        //销售合同 出证文件
        if (salesSignConfirmation != null) {
            List<CSalesSignConfirmationElectronicInfo> signElectronicInfos = signConfirmationElectronicInfoService
                    .list(new QueryWrapper<CSalesSignConfirmationElectronicInfo>().eq("c_sales_sign_confirmation_id", salesSignConfirmation.getId()));
            if (CollectionUtil.isNotEmpty(signElectronicInfos)) {
                signElectronicInfos.forEach(signElectronicInfo -> {
                    salesReportFiles.addAll(attachmentRefService.getFiles(AttachmentDto.builder()
                            .setChildEnum(FileModuleDict.ChildEnum.SIGN_CONFIRM_REPORT_FILE).setEntityId(signElectronicInfo.getId()).build()));
                });
            }
        }

        //销售合同变更 出证文件
        List<CSalesContractSupplementInfo> salesContractSupplementInfos = salesContractSupplementInfoService
                .list(new QueryWrapper<CSalesContractSupplementInfo>().eq("c_sales_contract_management_id", id));
        if (CollectionUtil.isNotEmpty(salesContractSupplementInfos)) {
            salesContractSupplementInfos.stream().forEach(s -> {
                if (cSalesContract.getContractStatus().equals(ProjectInitiationStatusDict.ChildEnum.COMPLETED.getCode())) {

                    CSalesSupplementSignConfirmation salesSupplementSignConfirmation = salesSupplementSignConfirmationService
                            .lambdaQuery().eq(CSalesSupplementSignConfirmation::getcSalesContractSupplementInfoId, s.getId()).one();
                    if (salesSupplementSignConfirmation != null) {
                        List<CSalesSupplementSignConfirmationElectronicInfo> supplementSignConfirmationElectronicInfos = salesSupplementSignConfirmationElectronicInfoService
                                .lambdaQuery().eq(CSalesSupplementSignConfirmationElectronicInfo::getcSalesSupplementSignConfirmationId, salesSupplementSignConfirmation.getId()).list();
                        if (CollectionUtil.isNotEmpty(supplementSignConfirmationElectronicInfos)) {
                            supplementSignConfirmationElectronicInfos.forEach(supplementSignConfirmationElectronicInfo -> {
                                List<FileStorage> salesContractSupplementFiles = attachmentRefService.getFiles(AttachmentDto.builder()
                                        .setChildEnum(FileModuleDict.ChildEnum.SSALES_SUPPLEMENT_SIGN_CONFIRM_BACK_REPORT_FILE)
                                        .setEntityId(supplementSignConfirmationElectronicInfo.getId()).build());
                                salesReportFiles.addAll(salesContractSupplementFiles);
                            });
                        }

                    }
                }
            });
        }

        if (CollectionUtil.isEmpty(salesReportFiles)) {
            throw new BusinessException(CodeUtil.FAIL, "未查询到出证文件！");
        }

        //文件名去重
        fileStorageService.renameFileStorageList(salesReportFiles);
        //打包下载文件
        String fileName = "出证文件.zip";
        fileStorageService.downloadZipFile(salesReportFiles, fileName,
                FileModuleDict.ChildEnum.SALES_CONTRACT_ZIP_FILE, res);
    }

}

