package com.trs.project.exchange;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.trs.project.entity.*;
import com.trs.project.service.*;
import com.trs.project.util.Base64Util;
import com.trs.project.util.GpDESUtils;
import com.trs.project.util.RSAUtils;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import generator.ZrzyCkqBidwinnoticeDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import org.springframework.web.client.RestTemplate;

import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * XxlJob开发示例（Bean模式）
 *
 * 开发步骤：
 *      1、任务开发：在Spring Bean实例中，开发Job方法；
 *      2、注解配置：为Job方法添加注解 "@XxlJob(value="自定义jobhandler名称", init = "JobHandler初始化方法", destroy = "JobHandler销毁方法")"，注解value值对应的是调度中心新建任务的JobHandler属性的值。
 *      3、执行日志：需要通过 "XxlJobHelper.log" 打印执行日志；
 *      4、任务结果：默认任务结果为 "成功" 状态，不需要主动设置；如有诉求，比如设置任务结果为失败，可以通过 "XxlJobHelper.handleFail/handleSuccess" 自主设置任务结果；
 *
 * @author xuxueli 2019-12-11 21:52:51
 */
@Component
public class SampleXxlJob {
    private static Logger logger = LoggerFactory.getLogger(SampleXxlJob.class);

    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private GcNoticeandfileService gcNoticeandfileService;//1、工程-招标公告与资格预审公告【GC_NOTICEANDFILE】
    @Autowired
    private GcBidopenrecordService gcBidopenrecordService;//3、工程-开标记录【GC_BIDOPENRECORD】
    @Autowired
    private GcBidcandidatePostService gcBidcandidatePostService;//4、工程-中标候选人公示【GC_BIDCANDIDATE_POST】
    @Autowired
    private GcBidpublicityService gcBidpublicityService;//5、工程-中标结果公示【GC_BIDPUBLICITY】
    @Autowired
    private GcProjectService gcProjectService;//6、工程-项目【GC_PROJECT】
    @Autowired
    private GcTenderprojectService gcTenderprojectService;//7、工程-招标项目【GC_TENDERPROJECT】
    @Autowired
    private GcTenderbidfileService gcTenderbidfileService;//8、工程-招标文件/招标文件澄清与修改【Tenderbidfile
    @Autowired
    private GcPubContractService gcPubContractService;//9、工程-合同签订【GC_PUB_CONTRACT】
    @Autowired
    private GcPerformanceService gcPerformanceService;//10、工程-合同履约【GC_PERFORMANCE】
    @Autowired
    private GcBidExceptioNoticeService gcBidExceptioNoticeService;//11、工程-招标异常公告【GC_BID_EXCEPTIO_NOTICE】
    @Autowired
    private GcAttachmentService gcAttachmentService;//12、工程-附件集结构【GC_ATTACHMENT】
    @Autowired
    private TaskRecordService taskRecordService;
    @Autowired
    private GcBidopenFileService gcBidopenFileService;//13、工程-开标明细数据集【GC_BIDOPEN_FILE】
    @Autowired
    private GcPackageService gcPackageService;//

    @Autowired
    private ZrzyTdCedeNoticeService zrzyTdCedeNoticeService;//20、自然资源-土地出让公告信息【ZRZY_TD_CEDE_NOTICE】
    @Autowired
    private ZrzyTdBidwinnoticeService zrzyTdBidwinnoticeService;//21、自然资源-土地成交结果公告【ZRZY_TD_BIDWINNOTICE】
    @Autowired
    private CqSwIssueBulletinService cqSwIssueBulletinService;//30、国有产权-实物资产挂牌披露信息【CQ_SW_ISSUE_BULLETIN】
    @Autowired
    private CqSwBargainResultService cqSwBargainResultService;//31、国有产权-实物资产交易结果信息【CQ_SW_BARGAIN_RESULT】】

    @Autowired
    private CqSwCompleteBulletinService cqSwCompleteBulletinService;
    @Autowired
    private ZtLegalinfoService ztLegalinfoService;//100、主体库

    @Autowired
    private YcNoticeService ycNoticeService;//200、药采公告

    @Autowired
    private JgFieldApplyService jgFieldApplyService;
    @Autowired
    private JgSiteInformationService jgSiteInformationService;//

    @Autowired
    private CqGqIssueBulletinService cqGqIssueBulletinService;//

    @Autowired
    private CqGqBargainResultService cqGqBargainResultService;//
    @Autowired
    private ZrzyCkqNoticeService zrzyCkqNoticeService;//
    @Autowired
    private ZrzyCkqBidwinnoticeService zrzyCkqBidwinnoticeService;//
    @Autowired
    private ZrzyCkqProjectInfoService zrzyCkqProjectInfoService;//

    @Autowired
    private ZrzyTkqNoticeService zrzyTkqNoticeService;//
    @Autowired
    private ZrzyTkqBidwinnoticeService zrzyTkqBidwinnoticeService;//
    @Autowired
    private ZrzyTkqProjectInfoService zrzyTkqProjectInfoService;


    @Autowired
    private ZrzyBgBidwinNoticeService zrzyBgBidwinNoticeService;
    @Autowired
    private ZrzyBgNoticeService zrzyBgNoticeService;
    @Autowired
    private ZrzyBgStockIndexService zrzyBgStockIndexService;
    @Autowired
    private ZrzyDkBinwinNoticeService zrzyDkBinwinNoticeService;
    @Autowired
    private ZrzyDkNoticeService zrzyDkNoticeService;
    @Autowired
    private ZrzyDkProjectService zrzyDkProjectService;
    @Autowired
    private ZrzyJyzbBidwinNoticeService zrzyJyzbBidwinNoticeService;
    @Autowired
    private ZrzyJyzbNoticeService zrzyJyzbNoticeService;
    @Autowired
    private ZrzyJyzbStockIndexService zrzyJyzbStockIndexService;
    @Autowired
    private ZrzyTdCedeInfoService zrzyTdCedeInfoService;
    @Autowired
    private CqGqProjectService cqGqProjectService;
    @Autowired
    private CqSwProjectService cqSwProjectService;

    @Autowired
    private NmNoticeService nmNoticeService;

    @Autowired
    private NmProjectService nmProjectService;

    @Autowired
    private NmResultNoticeService nmResultNoticeService;

    @Autowired
    private ZfcgGongaoService zfcgGongaoService;

    @Autowired
    private GcJihuaInfoService gcJihuaInfoService;

    @Autowired
    private GcTenderbidfilepublicityService gcTenderbidfilepublicityService;

    @Autowired
    private CqcgNoticeandfileService cqcgNoticeandfileService;

    @Autowired
    private CqcgChangeFileService cqcgChangeFileService;

    @Autowired
    private CqcgBidcandidatePostService cqcgBidcandidatePostService;

    @Autowired
    private CqcgBidpublicityService cqcgBidpublicityService;

    @Autowired
    private GcReconsiderService gcReconsiderService;


    /**
     * 1、工程-招标公告与资格预审公告【GC_NOTICEANDFILE】
     */
    @XxlJob("task_GC_NOTICEANDFILE")
    public void GC_NOTICEANDFILE() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 2、工程-招标异常公告【GC_BID_EXCEPTIO_NOTICE】
     */
/*    @XxlJob("task_GC_BID_EXCEPTIO_NOTICE")
    public void GC_BID_EXCEPTIO_NOTICE() throws Exception {
        detailMethod(1);//1:post  0:get
    }*/

    /**
     * 3、工程-开标记录【GC_BIDOPENRECORD】
     */
    @XxlJob("task_GC_BIDOPENRECORD")
    public void GC_BIDOPENRECORD() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 4、工程-中标候选人公示【GC_BIDCANDIDATE_POST】
     */
    @XxlJob("task_GC_BIDCANDIDATE_POST")
    public void GC_BIDCANDIDATE_POST() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 5、工程-中标结果公示【GC_BIDPUBLICITY】
     */
    @XxlJob("task_GC_BIDPUBLICITY")
    public void GC_BIDPUBLICITY() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 6、工程-项目【GC_PROJECT】
     */
    @XxlJob("task_GC_PROJECT")
    public void GC_PROJECT() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 7、工程-招标项目【GC_TENDERPROJECT】
     */
    @XxlJob("task_GC_TENDERPROJECT")
    public void GC_TENDERPROJECT() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 8、工程-招标文件/招标文件澄清与修改【GC_TENDERBIDFILE】
     */
    @XxlJob("task_GC_TENDERBIDFILE")
    public void GC_TENDERBIDFILE() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 9、工程-合同签订【GC_PUB_CONTRACT】
     */
    @XxlJob("task_GC_PUB_CONTRACT")
    public void GC_PUB_CONTRACT() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 10、工程-合同履约【GC_PERFORMANCE】
     */
    @XxlJob("task_GC_PERFORMANCE")
    public void GC_PERFORMANCE() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 11、工程-招标异常公告【GC_BID_EXCEPTIO_NOTICE】
     */
    @XxlJob("task_GC_BID_EXCEPTIO_NOTICE")
    public void GC_BID_EXCEPTIO_NOTICE() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 12、工程-附件集结构【GC_ATTACHMENT】
     */
    @XxlJob("task_GC_ATTACHMENT")
    public void GC_ATTACHMENT() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 13、工程-开标明细数据集【GC_BIDOPEN_FILE】
     */
    @XxlJob("task_GC_BIDOPEN_FILE")
    public void GC_BIDOPEN_FILE() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 16、工程-标段（包）【GC_PACKAGE】
     */
    @XxlJob("task_GC_PACKAGE")
    public void GC_PACKAGE() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 17、工程建设复议信息【GC_RECONSIDER】
     */
    @XxlJob("task_GC_RECONSIDER")
    public void GC_RECONSIDER() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 14、场地预约【JG_FIELDAPPLY】
     */
    @XxlJob("task_JG_FIELDAPPLY")
    public void JG_FIELDAPPLY() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 15、场地信息【JG_SITE_INFORMATION】
     */
    @XxlJob("task_JG_SITE_INFORMATION")
    public void JG_SITE_INFORMATION() throws Exception {
//        detailMethod(0);//1:post  0:get
        detailMethod(1);//1:post  0:get
    }

    /**
     * 20、自然资源-土地出让公告信息【ZRZY_TD_CEDE_NOTICE】
     */
    @XxlJob("task_ZRZY_TD_CEDE_NOTICE")
    public void ZRZY_TD_CEDE_NOTICE() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 21、自然资源-土地成交结果公告【ZRZY_TD_BIDWINNOTICE】
     */
    @XxlJob("task_ZRZY_TD_BIDWINNOTICE")
    public void ZRZY_TD_BIDWINNOTICE() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 22、自然资源-探矿权招拍挂公告信息【ZRZY_TKQ_NOTICE】
     */
    @XxlJob("task_ZRZY_TKQ_NOTICE")
    public void ZRZY_ZRZY_TKQ_NOTICE() throws Exception {
//        detailMethod(0);//1:post  0:get
        detailMethod(1);//1:post  0:get
    }
    /**
     * 23、自然资源-探矿权招拍挂结果公示信息【ZRZY_TKQ_BIDWINNOTICE】
     */
    @XxlJob("task_ZRZY_TKQ_BIDWINNOTICE")
    public void ZRZY_TKQ_BIDWINNOTICE() throws Exception {
        detailMethod(1);//1:post  0:get
//        detailMethod(0);//1:post  0:get
    }

    /**
     * 24、自然资源-采矿权招拍挂公告信息【ZRZY_CKQ_NOTICE】
     */
    @XxlJob("task_ZRZY_CKQ_NOTICE")
    public void ZRZY_CKQ_NOTICE() throws Exception {
        detailMethod(1);//1:post  0:get
//        detailMethod(0);//1:post  0:get
    }
    /**
     * 25、自然资源-采矿权招拍挂结果公示信息【ZRZY_CKQ_BIDWINNOTICE】
     */
    @XxlJob("task_ZRZY_CKQ_BIDWINNOTICE")
    public void ZRZY_CKQ_BIDWINNOTICE() throws Exception {
        detailMethod(1);//1:post  0:get
//        detailMethod(0);//1:post  0:get
    }


    /**
     * 30、国有产权-实物资产挂牌披露信息【CQ_SW_ISSUE_BULLETIN】
     */
    @XxlJob("task_CQ_SW_ISSUE_BULLETIN")
    public void CQ_SW_ISSUE_BULLETIN() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 31、国有产权-实物资产交易结果信息【CQ_SW_BARGAIN_RESULT】】
     */
    @XxlJob("task_CQ_SW_BARGAIN_RESULT")
    public void CQ_SW_BARGAIN_RESULT() throws Exception {
        detailMethod(1);//1:post  0:get
    }
    /**
     * 31-1、国有产权-交易结果公告【CQ_SW_COMPLETE_BULLETIN】
     */
    @XxlJob("task_CQ_SW_COMPLETE_BULLETIN")
    public void CQ_SW_COMPLETE_BULLETIN() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 32、国有产权-挂牌披露信息【CQ_GQ_ISSUE_BULLETIN】
     */
    @XxlJob("task_CQ_GQ_ISSUE_BULLETIN")
    public void CQ_GQ_ISSUE_BULLETIN() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 33、国有产权-交易结果信息【CQ_GQ_BARGAIN_RESULT】
     */
    @XxlJob("task_CQ_GQ_BARGAIN_RESULT")
    public void CQ_GQ_BARGAIN_RESULT() throws Exception {
        detailMethod(1);//1:post  0:get
    }


    /**
     * 100、法人基本信息【ZT_LEGALINFO】
     */
    @XxlJob("task_ZT_LEGALINFO")
    public void ZT_LEGALINFO() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 200、药采公告 【YC_NOTICE】
     */
    @XxlJob("task_YC_NOTICE")
    public void YC_NOTICE() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 26、自然资源-探矿权项目信息【ZRZY_TKQ_PROJECT_INFO】
     */
    @XxlJob("task_ZRZY_TKQ_PROJECT_INFO")
    public void ZRZY_TKQ_PROJECT_INFO() throws Exception {
        detailMethod(1);//1:post  0:get
//        detailMethod(0);//1:post  0:get
    }
    /**
     * 27、自然资源-采矿权项目信息【ZRZY_CKQ_PROJECT_INFO】
     */
    @XxlJob("task_ZRZY_CKQ_PROJECT_INFO")
    public void ZRZY_CKQ_PROJECT_INFO() throws Exception {
        detailMethod(1);//1:post  0:get
//        detailMethod(0);//1:post  0:get
    }
    /**
     * 28、自然资源-土地出让信息【ZRZY_TD_CEDE_INFO】
     */
    @XxlJob("task_ZRZY_TD_CEDE_INFO")
    public void ZRZY_TD_CEDE_INFO() throws Exception {
        detailMethod(1);//1:post  0:get
//        detailMethod(0);//1:post  0:get
    }

    /**
     * 29、自然资源-地质勘查基金项目信息【ZRZY_DK_PROJECT】
     */
    @XxlJob("task_ZRZY_DK_PROJECT")
    public void ZRZY_DK_PROJECT() throws Exception {
        detailMethod(1);//1:post  0:get
//        detailMethod(0);//1:post  0:get
    }

    /**
     * 201、自然资源-地质勘查基金交易公告【ZRZY_DK_NOTICE】
     */
    @XxlJob("task_ZRZY_DK_NOTICE")
    public void ZRZY_DK_NOTICE() throws Exception {
        detailMethod(1);//1:post  0:get
//        detailMethod(0);//1:post  0:get
    }

    /**
     * 202、自然资源-地质勘查基金结果公示【ZRZY_DK_BIDWIN_NOTICE】
     */
    @XxlJob("task_ZRZY_DK_BIDWIN_NOTICE")
    public void ZRZY_DK_BIDWIN_NOTICE() throws Exception {
        detailMethod(1);//1:post  0:get
//        detailMethod(0);//1:post  0:get
    }

    /**
     * 203、自然资源-存量指标【ZRZY_BG_STOCK_INDEX】
     */
    @XxlJob("task_ZRZY_BG_STOCK_INDEX")
    public void ZRZY_BG_STOCK_INDEX() throws Exception {
        detailMethod(1);//1:post  0:get
//        detailMethod(0);//1:post  0:get
    }
    /**
     * 204、自然资源-交易公告【ZRZY_BG_NOTICE】
     */
    @XxlJob("task_ZRZY_BG_NOTICE")
    public void ZRZY_BG_NOTICE() throws Exception {
        detailMethod(1);//1:post  0:get
//        detailMethod(0);//1:post  0:get
    }
    /**
     * 205、自然资源-结果公示【ZRZY_BG_BIDWIN_NOTICE】
     */
    @XxlJob("task_ZRZY_BG_BIDWIN_NOTICE")
    public void ZRZY_BG_BIDWIN_NOTICE() throws Exception {
        detailMethod(1);//1:post  0:get
//        detailMethod(0);//1:post  0:get
    }
    /**
     * 205、自然资源-存量指标库【ZRZY_JYZB_STOCK_INDEX】
     */
    @XxlJob("task_ZRZY_JYZB_STOCK_INDEX")
    public void ZRZY_JYZB_STOCK_INDEX() throws Exception {
        detailMethod(1);//1:post  0:get
//        detailMethod(0);//1:post  0:get
    }
    /**
     * 205、自然资源-节余指标公告【ZRZY_JYZB_NOTICE】
     */
    @XxlJob("task_ZRZY_JYZB_NOTICE")
    public void ZRZY_JYZB_NOTICE() throws Exception {
        detailMethod(1);//1:post  0:get
//        detailMethod(0);//1:post  0:get
    }
    /**
     * 205、自然资源-【ZRZY_JYZB_BIDWIN_NOTICE】
     */
    @XxlJob("task_ZRZY_JYZB_BIDWIN_NOTICE")
    public void ZRZY_JYZB_BIDWIN_NOTICE() throws Exception {
        detailMethod(1);//1:post  0:get
//        detailMethod(0);//1:post  0:get
    }
    /**
     * 34、国有产权-股权类项目信息【CQ_GQ_PROJECT】
     */
    @XxlJob("task_CqGqProject")
    public void CqGqProject() throws Exception {
        detailMethod(1);//1:post  0:get
//        detailMethod(0);//1:post  0:get
    }
    /**
     * 35、国有产权-实物资产类项目信息【CQ_SW_PROJECT】
     */
    @XxlJob("task_CqSwProject")
    public void CqSwProject() throws Exception {
        detailMethod(1);//1:post  0:get
//        detailMethod(0);//1:post  0:get
    }

    /**
     * 36、电力交易-招标公告与资格预审公告【NM_NOTICE】
     */
    @XxlJob("task_NmNotice")
    public void NmNotice() throws Exception {
//        detailMethod(0);//1:post  0:get
        detailMethod(1);//1:post  0:get
    }
    /**
     * 37、电力交易-项目【NM_PROJECT】
     */
    @XxlJob("task_NmProject")
    public void NmProject() throws Exception {
        detailMethod(1);//1:post  0:get
//        detailMethod(0);//1:post  0:get
    }
    /**
     * 38、电力交易-中标结果公示【NM_RESULT_NOTICE】
     */
    @XxlJob("task_NmResultNotice")
    public void NmResultNotice() throws Exception {
        detailMethod(1);//1:post  0:get
//        detailMethod(0);//1:post  0:get
    }

    /**
     * 40、政府采购【GONGAO】
     */
    @XxlJob("task_gongao")
    public void gongao() throws Exception {
        detailMethod(1);//1:post  0:get
//        detailMethod(0);//1:post  0:get
    }

    /**
     * 41、工程招标计划【GcJihuaInfo】
     */
    @XxlJob("task_gciihuainfo")
    public void gciihuainfo() throws Exception {
        detailMethod(1);//1:post  0:get
//        detailMethod(0);//1:post  0:get
    }

    /**
     * 42、招标文件预公示【GcTenderbidfilepublicity】
     */
    @XxlJob("task_gcTenderbidfilepublicity")
    public void gcTenderbidfilepublicity() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 43、产权_企业采购_招标公告【CQCG_NOTICEANDFILE】
     */
    @XxlJob("task_cqcgnoticeandfile")
    public void cqcgNoticeandfile() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 44、产权_企业采购_变更公告【CQCG_CHANGE_FILE】
     */
    @XxlJob("task_cqcgchangefile")
    public void cqcgChangeFile() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 45、产权_企业采购_中标候选人公示【CqcgBidcandidatePost】
     */
    @XxlJob("task_cqcgbidcandidatepost")
    public void cqcgBidcandidatePost() throws Exception {
        detailMethod(1);//1:post  0:get
    }

    /**
     * 46、产权_企业采购_中标结果公示【CqcgBidpublicity】
     */
    @XxlJob("task_cqcgbidpublicity")
    public void cqcgBidpublicity() throws Exception {
        detailMethod(1);//1:post  0:get
    }



    private void detailMethod(Integer type){
        System.out.println("进来了==================");
        String param = XxlJobHelper.getJobParam();
        XxlJobHelper.log("XXL-JOB, start="+param);
        if (param==null || param.trim().length()==0) {
            XxlJobHelper.log("param["+ param +"] invalid.");
            XxlJobHelper.handleFail();
            return;
        }
        String setDateStr = "";
        String tableName = param;
        if(param.contains(";")){
            tableName = param.substring(0,param.lastIndexOf(";"));
            setDateStr = param.substring(param.lastIndexOf(";")+1);
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式
        long startDate = 0;
        try {
            if(!StringUtils.isEmpty(setDateStr)){
                startDate = sdf.parse(setDateStr).getTime();
            }else{

                TaskRecord byId = taskRecordService.getById(tableName);
                if(null == byId){
                    byId = new TaskRecord();
                    byId.setTableName(tableName);
                    byId.setUpdateTime(new Date());
                    byId.setLastDealTime(new Date());
                }

/*                Date startDateTime = byId.getLastDealTime();
//                String startDateStr = Log.getTxtData("time.txt");
//                startDate = sdf.parse(startDateStr).getTime();
                startDate = startDateTime.getTime();

                Date afterDate = new Date(startDate + 5*60*1000);//5分钟后的时间

                //Log.Logger("time.txt",sdf.format(afterDate));
                byId.setLastDealTime(afterDate);*/
                startDate = new Date().getTime();
                Date startDateTime =  new Date(startDate - 24*60*60*1000);//60分钟前的时间
                startDate = startDateTime.getTime();
                byId.setLastDealTime(new Date(startDate));

                byId.setUpdateTime(new Date());
                System.out.println("getTableName"+byId.getTableName());
                taskRecordService.saveOrUpdate(byId);
            }
            System.out.println(startDate);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }

        Integer total = 0;
        try{
            MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
            params.add("platform_code", "e64975be");
            params.add("table_name", tableName);
            params.add("page", "1");
            params.add("page_size", "1");
            params.add("startTime", startDate);
            JSONObject jsonObject1 = null;
            if(type==0){
                jsonObject1 = httpGetMethod("http://10.8.3.137:7401/adminNmg/api/down.do",params);
            }else{
                jsonObject1 = httpPostMethod("http://10.8.3.137:7401/adminNmg/api/down.do",params);//&startTime=1676540529
            }

            total = jsonObject1.getInteger("total");

        }catch (Exception e){
            e.printStackTrace();
        }
        //Integer pages = total/20+1;
        int pages = (int) Math.ceil((double) total / 20);
        for(int i = 1; i <= pages ; i++){
            if(i<=0)i=1;
            try{
                MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
                params.add("platform_code", "e64975be");
                params.add("table_name", tableName);
                params.add("page", i);
                params.add("page_size", "20");
                params.add("startTime", startDate);
                JSONObject jsonObject = null;
                if(type==0){
                    jsonObject = httpGetMethod("http://10.8.3.137:7401/adminNmg/api/down.do",params);
                }else{
                    jsonObject = httpPostMethod("http://10.8.3.137:7401/adminNmg/api/down.do",params);//&startTime=1676540529
                }
                String data = RSAUtils.decrypt(jsonObject.getString("data"));
                JSONArray jsonArray = JSONArray.parseArray(data);
                //数据入库
                updateDatas(tableName,jsonArray);
                XxlJobHelper.handleSuccess();
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }


    //http方法
    public JSONObject httpPostMethod(String uri, MultiValueMap<String, Object> params){
        System.out.println("uri"+uri);
        System.out.println("params"+params);
        restTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
        //JSONObject response = restTemplate.getForObject(uri,JSONObject.class);

        HttpHeaders headers = new HttpHeaders();
        // 以表单的方式提交
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        //将请求头部和参数合成一个请求
        HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity(params, headers);
        //System.out.println("post===============");
        ResponseEntity<JSONObject> response = restTemplate.exchange(uri, HttpMethod.POST, entity, JSONObject.class);
        //System.out.println("response"+response);
        JSONObject body = response.getBody();
        //System.out.println("response2"+body);
        return body;
    }


    public JSONObject httpGetMethod(String uri, MultiValueMap<String, Object> params){
        uri = uri + "?platform_code=e64975be&table_name="+params.get("table_name").get(0)+"&page="+params.get("page").get(0)+"&page_size="+params.get("page_size").get(0)+"&startTime="+params.get("startTime").get(0);
        JSONObject response  = restTemplate.getForObject(uri, JSONObject.class);
        return response;
    }

    private void updateDatas(String param , JSONArray jsonArray ) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
        switch (param)
        {
            case "GC_NOTICEANDFILE"://1、工程-招标公告与资格预审公告【GC_NOTICEANDFILE】
                List<GcNoticeandfile> listGcNoticeandfile = JSONObject.parseArray(jsonArray.toJSONString(), GcNoticeandfile.class);
//                for (GcNoticeandfile gcNoticeandfile : listGcNoticeandfile) {
//                    if(null==gcNoticeandfile.getCreateDate())
//                        gcNoticeandfile.setCreateDate(Long.parseLong(gcNoticeandfile.getDataTimestamp()));
//                        //gcNoticeandfile.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                
                logger.info(param+"：数据入库="+listGcNoticeandfile.size());
                XxlJobHelper.log(param+"：数据入库="+listGcNoticeandfile.size());
                gcNoticeandfileService.saveOrUpdateBatchSelective(listGcNoticeandfile);
/*                for (GcNoticeandfile gcNoticeandfile : listGcNoticeandfile) {
                    if(gcNoticeandfile.getNoticeName()!=null&&!gcNoticeandfile.getNoticeName().equals("")){
                        XxlJobHelper.log(param+"：数据入库="+20);
                        gcNoticeandfileService.saveOrUpdateBatchSelective(listGcNoticeandfile);
                    }
                }*/
                break;
            case "GC_BIDOPENRECORD"://3、工程-开标记录【GC_BIDOPENRECORD】
                List<GcBidopenrecord> listGcBidopenrecord = JSONObject.parseArray(jsonArray.toJSONString(), GcBidopenrecord.class);
//                for (GcBidopenrecord gcBidopenrecord : listGcBidopenrecord) {
//                    if(null==gcBidopenrecord.getCreateDate())
//                        gcBidopenrecord.setCreateDate(gcBidopenrecord.getDataTimestamp());
//                        //gcBidopenrecord.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listGcBidopenrecord.size());
                XxlJobHelper.log(param+"：数据入库="+listGcBidopenrecord.get(0));
                gcBidopenrecordService.saveOrUpdateBatchSelective(listGcBidopenrecord);
                break;
            case "GC_BIDCANDIDATE_POST"://4、工程-中标候选人公示【GC_BIDCANDIDATE_POST】
                List<GcBidcandidatePost> listGcBidcandidatePost = JSONObject.parseArray(jsonArray.toJSONString(), GcBidcandidatePost.class);
//                for (GcBidcandidatePost gcBidcandidatePost : listGcBidcandidatePost) {
//                    if(null==gcBidcandidatePost.getCreateDate())
//                        gcBidcandidatePost.setCreateDate(gcBidcandidatePost.getDataTimestamp());
//                    //gcBidcandidatePost.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listGcBidcandidatePost.size());
                XxlJobHelper.log(param+"：数据入库="+listGcBidcandidatePost.size());
                gcBidcandidatePostService.saveOrUpdateBatchSelective(listGcBidcandidatePost);
                break;
            case "GC_BIDPUBLICITY"://5、工程-中标结果公示【GC_BIDPUBLICITY】
                List<GcBidpublicity> listGcBidpublicity = JSONObject.parseArray(jsonArray.toJSONString(), GcBidpublicity.class);
//                for (GcBidpublicity gcBidpublicity : listGcBidpublicity) {
//                    if(null==gcBidpublicity.getCreateDate())
//                        gcBidpublicity.setCreateDate(gcBidpublicity.getDataTimestamp());
//                    //gcBidpublicity.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listGcBidpublicity.size());
                XxlJobHelper.log(param+"：数据入库="+listGcBidpublicity.size());
                gcBidpublicityService.saveOrUpdateBatchSelective(listGcBidpublicity);
                break;
            case "GC_PROJECT"://6、工程-项目【GC_PROJECT】
                List<GcProject> listGcProject = JSONObject.parseArray(jsonArray.toJSONString(), GcProject.class);
                logger.info(param+"：数据入库="+listGcProject.size());
                XxlJobHelper.log(param+"：数据入库="+listGcProject.size());
                gcProjectService.saveOrUpdateBatch(listGcProject);
                break;
            case "GC_TENDERPROJECT"://7、工程-招标项目【GC_TENDERPROJECT】
                List<GcTenderproject> listGcTenderproject = JSONObject.parseArray(jsonArray.toJSONString(), GcTenderproject.class);
                logger.info(param+"：数据入库="+listGcTenderproject.size());
                XxlJobHelper.log(param+"：数据入库="+listGcTenderproject.size());
                gcTenderprojectService.saveOrUpdateBatch(listGcTenderproject);
                break;
            case "GC_TENDERBIDFILE":////8、工程-招标文件/招标文件澄清与修改【GC_TENDERPROJECT】
                List<GcTenderbidfile> listGcTenderbidfile = JSONObject.parseArray(jsonArray.toJSONString(), GcTenderbidfile.class);
//                for (GcTenderbidfile gcTenderbidfile : listGcTenderbidfile) {
//                    if(null==gcTenderbidfile.getCreateDate())
//                        gcTenderbidfile.setCreateDate(gcTenderbidfile.getDataTimestamp());
//                    //gcTenderbidfile.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listGcTenderbidfile.size());
                XxlJobHelper.log(param+"：数据入库="+listGcTenderbidfile.size());
                gcTenderbidfileService.saveOrUpdateBatchSelective(listGcTenderbidfile);
                break;
            case "GC_PUB_CONTRACT"://9、工程-合同签订【GC_PUB_CONTRACT】
                List<GcPubContract> listGcPubContract = JSONObject.parseArray(jsonArray.toJSONString(), GcPubContract.class);
//                for (GcPubContract gcPubContract : listGcPubContract) {
//                    if(null==gcPubContract.getCreateDate())
//                        gcPubContract.setCreateDate(gcPubContract.getDataTimestamp());
//                    //gcPubContract.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listGcPubContract.size());
                XxlJobHelper.log(param+"：数据入库="+listGcPubContract.size());
                gcPubContractService.saveOrUpdateBatchSelective(listGcPubContract);
                break;
            case "GC_PERFORMANCE"://10、工程-合同履约【GC_PERFORMANCE】
                List<GcPerformance> listGcPerformance = JSONObject.parseArray(jsonArray.toJSONString(), GcPerformance.class);
//                for (GcPerformance gcPerformance : listGcPerformance) {
//                    if(null==gcPerformance.getCreateDate())
//                        gcPerformance.setCreateDate(gcPerformance.getDataTimestamp());
//                    //gcPerformance.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listGcPerformance.size());
                XxlJobHelper.log(param+"：数据入库="+listGcPerformance.size());
                gcPerformanceService.saveOrUpdateBatchSelective(listGcPerformance);
                break;
            case "GC_BID_EXCEPTIO_NOTICE"://11、工程-招标异常公告【GC_BID_EXCEPTIO_NOTICE】
                List<GcBidExceptioNotice> listGcBidExceptioNotice = JSONObject.parseArray(jsonArray.toJSONString(), GcBidExceptioNotice.class);
//                for (GcBidExceptioNotice gcBidExceptioNotice : listGcBidExceptioNotice) {
//                    if(null==gcBidExceptioNotice.getCreateDate())
//                        gcBidExceptioNotice.setCreateDate(gcBidExceptioNotice.getDataTimestamp());
//                    //gcBidExceptioNotice.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listGcBidExceptioNotice.size());
                XxlJobHelper.log(param+"：数据入库="+listGcBidExceptioNotice.size());
                gcBidExceptioNoticeService.saveOrUpdateBatchSelective(listGcBidExceptioNotice);
                break;
            case "GC_ATTACHMENT"://12、工程-附件集结构【GC_ATTACHMENT】
                List<GcAttachment> listGcAttachment = JSONObject.parseArray(jsonArray.toJSONString(), GcAttachment.class);
                logger.info(param+"：数据入库="+listGcAttachment.size());
                XxlJobHelper.log(param+"：数据入库="+listGcAttachment.size());
                gcAttachmentService.saveOrUpdateBatch(listGcAttachment);
                break;
            case "GC_BIDOPEN_FILE"://13、工程-开标明细数据集【GC_BIDOPEN_FILE】
                List<GcBidopenFile> listGcBidopenFile = JSONObject.parseArray(jsonArray.toJSONString(), GcBidopenFile.class);
                logger.info(param+"：数据入库="+listGcBidopenFile.size());
                XxlJobHelper.log(param+"：数据入库="+listGcBidopenFile.size());
                gcBidopenFileService.saveOrUpdateBatch(listGcBidopenFile);
                break;
            case "GC_PACKAGE"://16、工程-标段（包）【GC_PACKAGE】
                List<GcPackage> listGcPackage = JSONObject.parseArray(jsonArray.toJSONString(), GcPackage.class);
                logger.info(param+"：数据入库="+listGcPackage.size());
                XxlJobHelper.log(param+"：数据入库="+listGcPackage.size());
                gcPackageService.saveOrUpdateBatch(listGcPackage);
                break;
            case "GC_RECONSIDER"://17、工程建设复议信息【GC_RECONSIDER】
                List<GcReconsider> gcReconsiderList = JSONObject.parseArray(jsonArray.toJSONString(), GcReconsider.class);
                logger.info(param+"：数据入库="+gcReconsiderList.size());
                XxlJobHelper.log(param+"：数据入库="+gcReconsiderList.size());
                gcReconsiderService.saveOrUpdateBatch(gcReconsiderList);
                break;
            case "ZRZY_TD_CEDE_NOTICE"://20、自然资源-土地出让公告信息【ZRZY_TD_CEDE_NOTICE】
                List<ZrzyTdCedeNotice> listZrzyTdCedeNotice = JSONObject.parseArray(jsonArray.toJSONString(), ZrzyTdCedeNotice.class);
//                for (ZrzyTdCedeNotice zrzyTdCedeNotice : listZrzyTdCedeNotice) {
//                    if(null==zrzyTdCedeNotice.getCreateDate())
//                        zrzyTdCedeNotice.setCreateDate(zrzyTdCedeNotice.getDataTimestamp());
//                    //zrzyTdCedeNotice.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listZrzyTdCedeNotice.size());
                XxlJobHelper.log(param+"：数据入库="+listZrzyTdCedeNotice.size());
                zrzyTdCedeNoticeService.saveOrUpdateBatchSelective(listZrzyTdCedeNotice);
                break;
            case "ZRZY_TD_BIDWINNOTICE"://21、自然资源-土地成交结果公告【ZRZY_TD_BIDWINNOTICE】
                List<ZrzyTdBidwinnotice> listZrzyTdBidwinnotice = JSONObject.parseArray(jsonArray.toJSONString(), ZrzyTdBidwinnotice.class);
//                for (ZrzyTdBidwinnotice zrzyTdBidwinnotice : listZrzyTdBidwinnotice) {
//                    if(null==zrzyTdBidwinnotice.getCreateDate())
//                        zrzyTdBidwinnotice.setCreateDate(zrzyTdBidwinnotice.getDataTimestamp());
//                    //zrzyTdBidwinnotice.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listZrzyTdBidwinnotice.size());
                XxlJobHelper.log(param+"：数据入库="+listZrzyTdBidwinnotice.size());
                zrzyTdBidwinnoticeService.saveOrUpdateBatchSelective(listZrzyTdBidwinnotice);
                break;
            case "CQ_SW_ISSUE_BULLETIN"://30、国有产权-实物资产挂牌披露信息【CQ_SW_ISSUE_BULLETIN】
                List<CqSwIssueBulletin> listCqSwIssueBulletin = JSONObject.parseArray(jsonArray.toJSONString(), CqSwIssueBulletin.class);
//                for (CqSwIssueBulletin cqSwIssueBulletin : listCqSwIssueBulletin) {
//                    if(null==cqSwIssueBulletin.getCreateDate())
//                        cqSwIssueBulletin.setCreateDate(cqSwIssueBulletin.getDataTimestamp());
//                    //cqSwIssueBulletin.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listCqSwIssueBulletin.size());
                XxlJobHelper.log(param+"：数据入库="+listCqSwIssueBulletin.size());
                cqSwIssueBulletinService.saveOrUpdateBatchSelective(listCqSwIssueBulletin);
                break;
            case "CQ_SW_BARGAIN_RESULT"://31、国有产权-实物资产交易结果信息【CQ_SW_BARGAIN_RESULT】】
                List<CqSwBargainResult> listCqSwBargainResult = JSONObject.parseArray(jsonArray.toJSONString(), CqSwBargainResult.class);
//                for (CqSwBargainResult cqSwBargainResult : listCqSwBargainResult) {
//                    if(null==cqSwBargainResult.getCreateDate())
//                        cqSwBargainResult.setCreateDate(cqSwBargainResult.getDataTimestamp());
//                    //cqSwBargainResult.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listCqSwBargainResult.size());
                XxlJobHelper.log(param+"：数据入库="+listCqSwBargainResult.size());
                cqSwBargainResultService.saveOrUpdateBatchSelective(listCqSwBargainResult);
                break;
            case "ZT_LEGALINFO"://100、主体库ZT_LEGALINFO
                List<ZtLegalinfo> listZtLegalinfo = JSONObject.parseArray(jsonArray.toJSONString(), ZtLegalinfo.class);
                logger.info(param+"：数据入库="+listZtLegalinfo.size());
                XxlJobHelper.log(param+"：数据入库="+listZtLegalinfo.size());
                ztLegalinfoService.saveOrUpdateBatch(listZtLegalinfo);
                break;
            case "YC_NOTICE"://200、药采公告 【YC_NOTICE】
                List<YcNotice> listYcNotice = JSONObject.parseArray(jsonArray.toJSONString(), YcNotice.class);
                logger.info(param+"：数据入库="+listYcNotice.size());
                XxlJobHelper.log(param+"：数据入库="+listYcNotice.size());
                ycNoticeService.saveOrUpdateBatch(listYcNotice);
                break;
            case "JG_FIELDAPPLY"://14、场地预约【JG_FIELDAPPLY】
                List<JgFieldApply> listJgFieldApply = JSONObject.parseArray(jsonArray.toJSONString(), JgFieldApply.class);
                logger.info(param+"：数据入库="+listJgFieldApply.size());
                XxlJobHelper.log(param+"：数据入库="+listJgFieldApply.size());
                jgFieldApplyService.saveOrUpdateBatch(listJgFieldApply);
                break;
            case "JG_SITE_INFORMATION"://15、场地信息【JG_SITE_INFORMATION】
                List<JgSiteInformation> listJgSiteInformation = JSONObject.parseArray(jsonArray.toJSONString(), JgSiteInformation.class);
                logger.info(param+"：数据入库="+listJgSiteInformation.size());
                XxlJobHelper.log(param+"：数据入库="+listJgSiteInformation.size());
                jgSiteInformationService.saveOrUpdateBatch(listJgSiteInformation);
                break;
            case "CQ_GQ_ISSUE_BULLETIN"://32、国有产权-挂牌披露信息【CQ_GQ_ISSUE_BULLETIN】
                List<CqGqIssueBulletin> listCqGqIssueBulletin = JSONObject.parseArray(jsonArray.toJSONString(), CqGqIssueBulletin.class);
//                for (CqGqIssueBulletin cqGqIssueBulletin : listCqGqIssueBulletin) {
//                    if(null==cqGqIssueBulletin.getCreateDate())
//                        cqGqIssueBulletin.setCreateDate(cqGqIssueBulletin.getDataTimestamp());
//                        //cqGqIssueBulletin.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listCqGqIssueBulletin.size());
                XxlJobHelper.log(param+"：数据入库="+listCqGqIssueBulletin.size());
                cqGqIssueBulletinService.saveOrUpdateBatchSelective(listCqGqIssueBulletin);
                break;
            case "CQ_GQ_BARGAIN_RESULT"://33、国有产权-交易结果信息【CQ_GQ_BARGAIN_RESULT】
                List<CqGqBargainResult> listCqGqBargainResult = JSONObject.parseArray(jsonArray.toJSONString(), CqGqBargainResult.class);
//                for (CqGqBargainResult cqGqBargainResult : listCqGqBargainResult) {
//                    if(null==cqGqBargainResult.getCreateDate())
//                        cqGqBargainResult.setCreateDate(cqGqBargainResult.getDataTimestamp());
//                    //cqGqBargainResult.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listCqGqBargainResult.size());
                XxlJobHelper.log(param+"：数据入库="+listCqGqBargainResult.size());
                cqGqBargainResultService.saveOrUpdateBatchSelective(listCqGqBargainResult);
                break;
            case "CQ_SW_COMPLETE_BULLETIN"://31-1、国有产权-交易结果公告【CQ_SW_COMPLETE_BULLETIN】
                List<CqSwCompleteBulletin> cqSwCompleteBulletinList = JSONObject.parseArray(jsonArray.toJSONString(), CqSwCompleteBulletin.class);
                logger.info(param+"：数据入库="+cqSwCompleteBulletinList.size());
                XxlJobHelper.log(param+"：数据入库="+cqSwCompleteBulletinList.size());
                cqSwCompleteBulletinService.saveOrUpdateBatch(cqSwCompleteBulletinList);
                break;
            case "ZRZY_TKQ_NOTICE"://22、自然资源-探矿权招拍挂公告信息【ZRZY_TKQ_NOTICE】
                List<ZrzyTkqNotice> listZrzyTkqNotice = JSONObject.parseArray(jsonArray.toJSONString(), ZrzyTkqNotice.class);
//                for (ZrzyTkqNotice zrzyTkqNotice : listZrzyTkqNotice) {
//                    if(null==zrzyTkqNotice.getCreateDate())
//                        zrzyTkqNotice.setCreateDate(zrzyTkqNotice.getDataTimestamp());
//                    //zrzyTkqNotice.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listZrzyTkqNotice.size());
                XxlJobHelper.log(param+"：数据入库="+listZrzyTkqNotice.size());
                zrzyTkqNoticeService.saveOrUpdateBatchSelective(listZrzyTkqNotice);
                break;
            case "ZRZY_TKQ_BIDWINNOTICE"://23、自然资源-探矿权招拍挂结果公示信息【ZRZY_TKQ_BIDWINNOTICE】
                List<ZrzyTkqBidwinnotice> listZrzyTkqBidwinnotice = JSONObject.parseArray(jsonArray.toJSONString(), ZrzyTkqBidwinnotice.class);
//                for (ZrzyTkqBidwinnotice zrzyTkqBidwinnotice : listZrzyTkqBidwinnotice) {
//                    if(null==zrzyTkqBidwinnotice.getCreateDate())
//                        zrzyTkqBidwinnotice.setCreateDate(zrzyTkqBidwinnotice.getDataTimestamp());
//                    //zrzyTkqBidwinnotice.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listZrzyTkqBidwinnotice.size());
                XxlJobHelper.log(param+"：数据入库="+listZrzyTkqBidwinnotice.size());
                zrzyTkqBidwinnoticeService.saveOrUpdateBatchSelective(listZrzyTkqBidwinnotice);
                break;
            case "ZRZY_CKQ_NOTICE"://24、自然资源-采矿权招拍挂公告信息【ZRZY_CKQ_NOTICE】
                List<ZrzyCkqNotice> listZrzyCkqNotice = JSONObject.parseArray(jsonArray.toJSONString(), ZrzyCkqNotice.class);
//                for (ZrzyCkqNotice zrzyCkqNotice : listZrzyCkqNotice) {
//                    if(null==zrzyCkqNotice.getCreateDate())
//                        zrzyCkqNotice.setCreateDate(zrzyCkqNotice.getDataTimestamp());
//                    //zrzyCkqNotice.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listZrzyCkqNotice.size());
                XxlJobHelper.log(param+"：数据入库="+listZrzyCkqNotice.size());
                zrzyCkqNoticeService.saveOrUpdateBatchSelective(listZrzyCkqNotice);
                break;
            case "ZRZY_CKQ_BIDWINNOTICE"://25、自然资源-采矿权招拍挂结果公示信息【ZRZY_CKQ_BIDWINNOTICE】
                List<ZrzyCkqBidwinnotice> listZrzyCkqBidwinnotice = JSONObject.parseArray(jsonArray.toJSONString(), ZrzyCkqBidwinnotice.class);
//                for (ZrzyCkqBidwinnotice zrzyCkqBidwinnotice : listZrzyCkqBidwinnotice) {
//                    if(null==zrzyCkqBidwinnotice.getCreateDate())
//                        zrzyCkqBidwinnotice.setCreateDate(zrzyCkqBidwinnotice.getDataTimestamp());
//                    //zrzyCkqBidwinnotice.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listZrzyCkqBidwinnotice.size());
                XxlJobHelper.log(param+"：数据入库="+listZrzyCkqBidwinnotice.size());
                zrzyCkqBidwinnoticeService.saveOrUpdateBatchSelective(listZrzyCkqBidwinnotice);
                break;

            case "ZRZY_TKQ_PROJECT_INFO"://26、自然资源-探矿权项目信息【ZRZY_TKQ_PROJECT_INFO】
                List<ZrzyTkqProjectInfo> listZrzyTkqProjectInfo = JSONObject.parseArray(jsonArray.toJSONString(), ZrzyTkqProjectInfo.class);
                logger.info(param+"：数据入库="+listZrzyTkqProjectInfo.size());
                XxlJobHelper.log(param+"：数据入库="+listZrzyTkqProjectInfo.size());
                zrzyTkqProjectInfoService.saveOrUpdateBatch(listZrzyTkqProjectInfo);
                break;
            case "ZRZY_CKQ_PROJECT_INFO"://27、自然资源-采矿权项目信息【ZRZY_CKQ_PROJECT_INFO】
                List<ZrzyCkqProjectInfo> listZrzyCkqProjectInfo = JSONObject.parseArray(jsonArray.toJSONString(), ZrzyCkqProjectInfo.class);
                logger.info(param+"：数据入库="+listZrzyCkqProjectInfo.size());
                XxlJobHelper.log(param+"：数据入库="+listZrzyCkqProjectInfo.size());
                zrzyCkqProjectInfoService.saveOrUpdateBatch(listZrzyCkqProjectInfo);
                break;
            case "ZRZY_TD_CEDE_INFO":// 28、自然资源-土地出让信息【ZRZY_TD_CEDE_INFO】
                List<ZrzyTdCedeInfo> listZrzyTdCedeInfo = JSONObject.parseArray(jsonArray.toJSONString(), ZrzyTdCedeInfo.class);
                logger.info(param+"：数据入库="+listZrzyTdCedeInfo.size());
                XxlJobHelper.log(param+"：数据入库="+listZrzyTdCedeInfo.size());
                zrzyTdCedeInfoService.saveOrUpdateBatch(listZrzyTdCedeInfo);
                break;
            case "ZRZY_DK_PROJECT"://29、自然资源-地质勘查基金项目信息【ZRZY_DK_PROJECT】
                List<ZrzyDkProject> listZrzyDkProject = JSONObject.parseArray(jsonArray.toJSONString(), ZrzyDkProject.class);
                logger.info(param+"：数据入库="+listZrzyDkProject.size());
                XxlJobHelper.log(param+"：数据入库="+listZrzyDkProject.size());
                zrzyDkProjectService.saveOrUpdateBatch(listZrzyDkProject);
                break;
            case "ZRZY_DK_NOTICE"://201、自然资源-地质勘查基金交易公告【ZRZY_DK_NOTICE】
                List<ZrzyDkNotice> listZrzyDkNotice = JSONObject.parseArray(jsonArray.toJSONString(), ZrzyDkNotice.class);
//                for (ZrzyDkNotice zrzyDkNotice : listZrzyDkNotice) {
//                    if(null==zrzyDkNotice.getCreateDate())
//                        zrzyDkNotice.setCreateDate(zrzyDkNotice.getDataTimestamp());
//                    //zrzyDkNotice.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listZrzyDkNotice.size());
                XxlJobHelper.log(param+"：数据入库="+listZrzyDkNotice.size());
                zrzyDkNoticeService.saveOrUpdateBatchSelective(listZrzyDkNotice);
                break;
            case "ZRZY_DK_BIDWIN_NOTICE"://202、自然资源-地质勘查基金结果公示【ZRZY_DK_BIDWIN_NOTICE】
                List<ZrzyDkBinwinNotice> listZrzyDkBinwinNotice = JSONObject.parseArray(jsonArray.toJSONString(), ZrzyDkBinwinNotice.class);
//                for (ZrzyDkBinwinNotice zrzyDkBinwinNotice : listZrzyDkBinwinNotice) {
//                    if(null==zrzyDkBinwinNotice.getCreateDate())
//                        zrzyDkBinwinNotice.setCreateDate(zrzyDkBinwinNotice.getDataTimestamp());
//                    //zrzyDkBinwinNotice.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listZrzyDkBinwinNotice.size());
                XxlJobHelper.log(param+"：数据入库="+listZrzyDkBinwinNotice.size());
                zrzyDkBinwinNoticeService.saveOrUpdateBatchSelective(listZrzyDkBinwinNotice);
                break;
            case "ZRZY_BG_STOCK_INDEX"://203、自然资源-存量指标【ZRZY_BG_STOCK_INDEX】
                List<ZrzyBgStockIndex> listZrzyBgStockIndex = JSONObject.parseArray(jsonArray.toJSONString(), ZrzyBgStockIndex.class);
                logger.info(param+"：数据入库="+listZrzyBgStockIndex.size());
                XxlJobHelper.log(param+"：数据入库="+listZrzyBgStockIndex.size());
                zrzyBgStockIndexService.saveOrUpdateBatch(listZrzyBgStockIndex);
                break;
            case "ZRZY_BG_NOTICE":// 204、自然资源-交易公告【ZRZY_BG_NOTICE】
                List<ZrzyBgNotice> listZrzyBgNotice = JSONObject.parseArray(jsonArray.toJSONString(), ZrzyBgNotice.class);
//                for (ZrzyBgNotice zrzyBgNotice : listZrzyBgNotice) {
//                    if(null==zrzyBgNotice.getCreateDate())
//                        zrzyBgNotice.setCreateDate(zrzyBgNotice.getDataTimestamp());
//                    //zrzyBgNotice.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listZrzyBgNotice.size());
                XxlJobHelper.log(param+"：数据入库="+listZrzyBgNotice.size());
                zrzyBgNoticeService.saveOrUpdateBatchSelective(listZrzyBgNotice);
                break;
            case "ZRZY_BG_BIDWIN_NOTICE"://205、自然资源-结果公示【ZRZY_BG_BIDWIN_NOTICE】
                List<ZrzyBgBidwinNotice> listZrzyBgBidwinNotice = JSONObject.parseArray(jsonArray.toJSONString(), ZrzyBgBidwinNotice.class);
//                for (ZrzyBgBidwinNotice zrzyBgBidwinNotice : listZrzyBgBidwinNotice) {
//                    if(null==zrzyBgBidwinNotice.getCreateDate())
//                        zrzyBgBidwinNotice.setCreateDate(zrzyBgBidwinNotice.getDataTimestamp());
//                    //zrzyBgBidwinNotice.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listZrzyBgBidwinNotice.size());
                XxlJobHelper.log(param+"：数据入库="+listZrzyBgBidwinNotice.size());
                zrzyBgBidwinNoticeService.saveOrUpdateBatchSelective(listZrzyBgBidwinNotice);
                break;
            case "ZRZY_JYZB_STOCK_INDEX"://206、自然资源-存量指标库【ZRZY_JYZB_STOCK_INDEX】
                List<ZrzyJyzbStockIndex> listZrzyJyzbStockIndex = JSONObject.parseArray(jsonArray.toJSONString(), ZrzyJyzbStockIndex.class);
                logger.info(param+"：数据入库="+listZrzyJyzbStockIndex.size());
                XxlJobHelper.log(param+"：数据入库="+listZrzyJyzbStockIndex.size());
                zrzyJyzbStockIndexService.saveOrUpdateBatch(listZrzyJyzbStockIndex);
                break;
            case "ZRZY_JYZB_NOTICE"://207、自然资源-节余指标公告【ZRZY_JYZB_NOTICE】
                List<ZrzyJyzbNotice> listZrzyJyzbNotice = JSONObject.parseArray(jsonArray.toJSONString(), ZrzyJyzbNotice.class);
//                for (ZrzyJyzbNotice zrzyJyzbNotice : listZrzyJyzbNotice) {
//                    if(null==zrzyJyzbNotice.getCreateDate())
//                        zrzyJyzbNotice.setCreateDate(zrzyJyzbNotice.getDataTimestamp());
//                    //zrzyJyzbNotice.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listZrzyJyzbNotice.size());
                XxlJobHelper.log(param+"：数据入库="+listZrzyJyzbNotice.size());
                zrzyJyzbNoticeService.saveOrUpdateBatchSelective(listZrzyJyzbNotice);
                break;
            case "ZRZY_JYZB_BIDWIN_NOTICE"://208、自然资源-【ZRZY_JYZB_BIDWIN_NOTICE】
                List<ZrzyJyzbBidwinNotice> listZrzyJyzbBidwinNotice = JSONObject.parseArray(jsonArray.toJSONString(), ZrzyJyzbBidwinNotice.class);
//                for (ZrzyJyzbBidwinNotice zrzyJyzbBidwinNotice : listZrzyJyzbBidwinNotice) {
//                    if(null==zrzyJyzbBidwinNotice.getCreateDate())
//                        zrzyJyzbBidwinNotice.setCreateDate(zrzyJyzbBidwinNotice.getDataTimestamp());
//                    //zrzyJyzbBidwinNotice.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
//                }
                logger.info(param+"：数据入库="+listZrzyJyzbBidwinNotice.size());
                XxlJobHelper.log(param+"：数据入库="+listZrzyJyzbBidwinNotice.size());
                zrzyJyzbBidwinNoticeService.saveOrUpdateBatchSelective(listZrzyJyzbBidwinNotice);
                break;
            case "CQ_GQ_PROJECT"://34、国有产权-股权类项目信息【CQ_GQ_PROJECT】
                List<CqGqProject> listCqGqProject = JSONObject.parseArray(jsonArray.toJSONString(), CqGqProject.class);
                logger.info(param+"：数据入库="+listCqGqProject.size());
                XxlJobHelper.log(param+"：数据入库="+listCqGqProject.size());
                cqGqProjectService.saveOrUpdateBatch(listCqGqProject);
                break;
            case "CQ_SW_PROJECT"://35、国有产权-实物资产类项目信息【CQ_SW_PROJECT】
                List<CqSwProject> listCqSwProject = JSONObject.parseArray(jsonArray.toJSONString(), CqSwProject.class);
                logger.info(param+"：数据入库="+listCqSwProject.size());
                XxlJobHelper.log(param+"：数据入库="+listCqSwProject.size());
                cqSwProjectService.saveOrUpdateBatch(listCqSwProject);
                break;
            case "NM_NOTICE"://36、电力交易-招标公告与资格预审公告【NM_NOTICE】
                List<NmNotice> nmNoticeList = JSONObject.parseArray(jsonArray.toJSONString(), NmNotice.class);
                logger.info(param+"：数据入库="+nmNoticeList.size());
                XxlJobHelper.log(param+"：数据入库="+nmNoticeList.size());
                nmNoticeService.saveOrUpdateBatch(nmNoticeList);
                break;
            case "NM_PROJECT"://37、电力交易-项目【NM_PROJECT】
                List<NmProject> nmProjectList = JSONObject.parseArray(jsonArray.toJSONString(), NmProject.class);
                logger.info(param+"：数据入库="+nmProjectList.size());
                XxlJobHelper.log(param+"：数据入库="+nmProjectList.size());
                nmProjectService.saveOrUpdateBatch(nmProjectList);
                break;
            case "NM_RESULT_NOTICE"://38、电力交易-中标结果公示【NM_RESULT_NOTICE】
                List<NmResultNotice> nmResultNotice = JSONObject.parseArray(jsonArray.toJSONString(), NmResultNotice.class);
                logger.info(param+"：数据入库="+nmResultNotice.size());
                XxlJobHelper.log(param+"：数据入库="+nmResultNotice.size());
                nmResultNoticeService.saveOrUpdateBatch(nmResultNotice);
                break;
            case "JSGC_ProjectJHInfo"://39、工程招标计划【GC_JIHUAN_INFO】
                List<GcJihuaInfo> gcJihuaInfos = JSONObject.parseArray(jsonArray.toJSONString(), GcJihuaInfo.class);
                for (GcJihuaInfo gcJihuaInfo : gcJihuaInfos) {
                    gcJihuaInfo.setDataTimestamp(Long.parseLong(simpleDateFormat.format(new Date())));
//                    if(null==gcJihuaInfo.getCreateDate())
//                        gcJihuaInfo.setCreateDate(gcJihuaInfo.getDataTimestamp());
                    //gcJihuaInfo.setCreateDate(Long.parseLong(simpleDateFormat.format(new Date())));
                }
                logger.info(param+"：数据入库="+gcJihuaInfos.size());
                XxlJobHelper.log(param+"：数据入库="+gcJihuaInfos.size());
                gcJihuaInfoService.saveOrUpdateBatchSelective(gcJihuaInfos);
                break;
            case "GC_TENDERBIDFILEPUBLICITY"://39、工程招标计划【GC_JIHUAN_INFO】
                List<GcTenderbidfilepublicity> gcTenderbidfilepublicitiesList = JSONObject.parseArray(jsonArray.toJSONString(), GcTenderbidfilepublicity.class);
                for (GcTenderbidfilepublicity gcTenderbidfilepublicity : gcTenderbidfilepublicitiesList) {
                    gcTenderbidfilepublicity.setDataTimestamp(Long.parseLong(simpleDateFormat.format(new Date())));
                }
                logger.info(param+"：数据入库="+gcTenderbidfilepublicitiesList.size());
                XxlJobHelper.log(param+"：数据入库="+gcTenderbidfilepublicitiesList.size());
                gcTenderbidfilepublicityService.saveOrUpdateBatchSelective(gcTenderbidfilepublicitiesList);
                break;
            case "CQCG_NOTICEANDFILE"://43、产权_企业采购_招标公告【CQCG_NOTICEANDFILE】
                List<CqcgNoticeandfile> cqcgNoticeandfileList = JSONObject.parseArray(jsonArray.toJSONString(), CqcgNoticeandfile.class);
                for (CqcgNoticeandfile cqcgNoticeandfile : cqcgNoticeandfileList) {
                    cqcgNoticeandfile.setDataTimestamp(cqcgNoticeandfile.getVersion());
                }
                logger.info(param+"：数据入库="+cqcgNoticeandfileList.size());
                XxlJobHelper.log(param+"：数据入库="+cqcgNoticeandfileList.size());
                cqcgNoticeandfileService.saveOrUpdateBatch(cqcgNoticeandfileList);
                break;
            case "CQCG_CHANGE_FILE"://44、产权_企业采购_变更公告【CQCG_CHANGE_FILE】
                List<CqcgChangeFile> cqcgChangeFileList = JSONObject.parseArray(jsonArray.toJSONString(), CqcgChangeFile.class);
                for (CqcgChangeFile cqcgChangeFile : cqcgChangeFileList) {
                    cqcgChangeFile.setDataTimestamp(cqcgChangeFile.getVersion());
                }
                logger.info(param+"：数据入库="+cqcgChangeFileList.size());
                XxlJobHelper.log(param+"：数据入库="+cqcgChangeFileList.size());
                cqcgChangeFileService.saveOrUpdateBatch(cqcgChangeFileList);
                break;
            case "CQCG_BIDCANDIDATE_POST"://45、产权_企业采购_中标候选人公告【CQCG_BIDCANDIDATE_POST】
                List<CqcgBidcandidatePost> cqcgBidcandidatePostList = JSONObject.parseArray(jsonArray.toJSONString(), CqcgBidcandidatePost.class);
                for (CqcgBidcandidatePost cqcgBidcandidatePost : cqcgBidcandidatePostList) {
                    cqcgBidcandidatePost.setDataTimestamp(cqcgBidcandidatePost.getVersion());
                }
                logger.info(param+"：数据入库="+cqcgBidcandidatePostList.size());
                XxlJobHelper.log(param+"：数据入库="+cqcgBidcandidatePostList.size());
                cqcgBidcandidatePostService.saveOrUpdateBatch(cqcgBidcandidatePostList);
                break;
            case "CQCG_BIDPUBLICITY"://46、产权_企业采购_中标结果公告【CQCG_BIDPUBLICITY】
                List<CqcgBidpublicity> cqcgBidpublicityList = JSONObject.parseArray(jsonArray.toJSONString(), CqcgBidpublicity.class);
                for (CqcgBidpublicity cqcgBidpublicity : cqcgBidpublicityList) {
                    cqcgBidpublicity.setDataTimestamp(cqcgBidpublicity.getVersion());
                }
                logger.info(param+"：数据入库="+cqcgBidpublicityList.size());
                XxlJobHelper.log(param+"：数据入库="+cqcgBidpublicityList.size());
                cqcgBidpublicityService.saveOrUpdateBatch(cqcgBidpublicityList);
                break;
            case "ZFCG_GONGAO"://38、政府采购【ZfcgGongao】
                List<Gongao> gongaoList = JSONObject.parseArray(jsonArray.toJSONString(), Gongao.class);
                List<ZfcgGongao> gongaoDbList = new ArrayList<>();
                for(Gongao gongao : gongaoList){
                    ZfcgGongao zfcgGongao = new ZfcgGongao();
                    try{
                        zfcgGongao.setNoticeTime((gongao.getNoticeTime()));
                        zfcgGongao.setNoticeName(gongao.getNoticeName());
                        zfcgGongao.setNoticeGuid(gongao.getNoticeGuid());
                        zfcgGongao.setNoticeType(gongao.getNoticeType());
                        zfcgGongao.setRegionName(gongao.getRegionName());
                        zfcgGongao.setSourceDataKey(gongao.getId());
                        zfcgGongao.setRegionCode(gongao.getRegionCode());
                        zfcgGongao.setDataTimestamp(Long.parseLong(simpleDateFormat.format(new Date())));
                        String regionCode = gongao.getRegionCode();
                        if(!"1504".equals(regionCode.substring(0,4))){
                            zfcgGongao.setNoticeContent(Base64Util.decode(gongao.getNoticeContent()));
                        }else {
                            zfcgGongao.setNoticeContent(gongao.getNoticeContent());

                        }
                        gongaoDbList.add(zfcgGongao);
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                }
                logger.info(param+"：数据入库="+gongaoDbList.size());
                XxlJobHelper.log(param+"：数据入库="+gongaoDbList.size());
                zfcgGongaoService.saveOrUpdateBatch(gongaoDbList);
                break;
            default:
        }
    }

}
