package org.jeecg.modules.spyderUtils.spider;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.config.TenantContext;
import org.jeecg.modules.demo.linkpersonalbankcarddetection.entity.LinkPersonalBankCardDetection;
import org.jeecg.modules.demo.linkpersonalbankcarddetection.service.ILinkPersonalBankCardDetectionService;
import org.jeecg.modules.demo.linkpersonalbankcarddetectionlog.entity.LinkPersonalBankCardDetectionLog;
import org.jeecg.modules.demo.linkpersonalbankcarddetectionlog.service.ILinkPersonalBankCardDetectionLogService;
import org.jeecg.modules.demo.linkpersonalbankcarddetectionstatistics.entity.LinkPersonalBankCardDetectionStatistics;
import org.jeecg.modules.demo.linkpersonalbankcarddetectionstatistics.service.ILinkPersonalBankCardDetectionStatisticsService;
import org.jeecg.modules.demo.linkpersonalidnumberdetection.entity.LinkPersonalIdNumberDetection;
import org.jeecg.modules.demo.linkpersonalidnumberdetection.service.ILinkPersonalIdNumberDetectionService;
import org.jeecg.modules.demo.linkpersonalidnumberdetectionlog.entity.LinkPersonalIdNumberDetectionLog;
import org.jeecg.modules.demo.linkpersonalidnumberdetectionlog.service.ILinkPersonalIdNumberDetectionLogService;
import org.jeecg.modules.demo.linkpersonalidnumberwhitelist.service.ILinkPersonalIdNumberWhiteListService;
import org.jeecg.modules.demo.linkpersonalpersonaliddetectionstatistics.entity.LinkPersonalPersonalIdDetectionStatistics;
import org.jeecg.modules.demo.linkpersonalpersonaliddetectionstatistics.service.ILinkPersonalPersonalIdDetectionStatisticsService;
import org.jeecg.modules.demo.linkpersonalphonedetection.entity.LinkPersonalPhoneDetection;
import org.jeecg.modules.demo.linkpersonalphonedetection.service.ILinkPersonalPhoneDetectionService;
import org.jeecg.modules.demo.linkpersonalphonedetectionlog.entity.LinkPersonalPhoneDetectionLog;
import org.jeecg.modules.demo.linkpersonalphonedetectionlog.service.ILinkPersonalPhoneDetectionLogService;
import org.jeecg.modules.demo.linkpersonalphonedetectionstatistics.entity.LinkPersonalPhoneDetectionStatistics;
import org.jeecg.modules.demo.linkpersonalphonedetectionstatistics.service.ILinkPersonalPhoneDetectionStatisticsService;
import org.jeecg.modules.demo.mainsite.entity.MainSite;
import org.jeecg.modules.demo.mainsite.service.IMainSiteService;
import org.jsoup.helper.StringUtil;
import org.jsoup.nodes.Document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.DigestUtils;
import org.springframework.util.ObjectUtils;

import java.util.Date;
import java.util.List;

@Slf4j
@Component
public class CrawlingPhoneIdNumberCardNumber {


    @Autowired
    private TrendsSpyder trendsSpyder;

    @Autowired
    private JsoupUtils jsoupUtils;

    @Autowired
    private JsoupUtilsService jsoupUtilsService;

    @Autowired
    private ILinkPersonalPhoneDetectionService iLinkPersonalPhoneDetectionService;

    @Autowired
    private ILinkPersonalPhoneDetectionLogService iLinkPersonalPhoneDetectionLogService;

    @Autowired
    private ILinkPersonalIdNumberDetectionService iLinkPersonalIdNumberDetectionService;

    @Autowired
    private ILinkPersonalIdNumberDetectionLogService iLinkPersonalIdNumberDetectionLogService;

    @Autowired
    private ILinkPersonalBankCardDetectionService iLinkPersonalBankCardDetectionService;

    @Autowired
    private ILinkPersonalBankCardDetectionLogService iLinkPersonalBankCardDetectionLogService;

    @Autowired
    private ILinkPersonalBankCardDetectionStatisticsService linkPersonalBankCardDetectionStatisticsService;

    @Autowired
    private ILinkPersonalPersonalIdDetectionStatisticsService linkPersonalPersonalIdDetectionStatisticsService;

    @Autowired
    private ILinkPersonalPhoneDetectionStatisticsService linkPersonalPhoneDetectionStatisticsService;

    @Autowired
    private ILinkPersonalIdNumberWhiteListService iLinkPersonalIdNumberWhiteListService;

    @Autowired
    private ILinkPersonalIdNumberDetectionService linkPersonalIdNumberDetectionService;


    @Autowired
    private IMainSiteService iMainSiteService;

    public void crawling(
            String mainSiteId,
            String mainSiteName,
            String mainSiteUrl,
            String source,
            String title,
            Date articleReleaseTime,
            String content,
            String isInvalid,
            String tenantId
    ){
        if(!ObjectUtils.isEmpty(source) && !ObjectUtils.isEmpty(content) ){
            //设置手机号
            log.info("================设置手机号====================");
            LinkPersonalPhoneDetection linkPersonalPhoneDetection = new LinkPersonalPhoneDetection();
            linkPersonalPhoneDetection.setId(DigestUtils.md5DigestAsHex(source.getBytes()));
            linkPersonalPhoneDetection.setCreateTime(new Date());
            linkPersonalPhoneDetection.setUpdateTime(new Date());
            linkPersonalPhoneDetection.setMainSiteId(mainSiteId);
            linkPersonalPhoneDetection.setMainSiteName(mainSiteName);
            linkPersonalPhoneDetection.setMainSiteUrl(mainSiteUrl);
            linkPersonalPhoneDetection.setSource(source);
            linkPersonalPhoneDetection.setTitle(title);
            linkPersonalPhoneDetection.setArticleReleaseTime(articleReleaseTime);
            linkPersonalPhoneDetection.setContent(content);
            linkPersonalPhoneDetection.setIsInvalid(isInvalid);
            linkPersonalPhoneDetection.setTenantId(tenantId);
            LinkPersonalPhoneDetection personalPhoneDetection = iLinkPersonalPhoneDetectionService.getById(linkPersonalPhoneDetection.getId());
            if(!ObjectUtils.isEmpty(personalPhoneDetection)){
                Integer numberScans = personalPhoneDetection.getNumberScans();
                if(!ObjectUtils.isEmpty(numberScans)){
                    if(numberScans != 0){
                        numberScans = numberScans + 1;
                        linkPersonalPhoneDetection.setIsIgnore(personalPhoneDetection.getIsIgnore());
                    }else{
                        linkPersonalPhoneDetection.setIsIgnore("2");
                    }
                }else {
                    numberScans = 0;
                    linkPersonalPhoneDetection.setIsIgnore("2");
                }
                linkPersonalPhoneDetection.setNumberScans(numberScans);
            }else{
                linkPersonalPhoneDetection.setNumberScans(0);
                linkPersonalPhoneDetection.setIsIgnore("2");
            }

            JsoupReturn phone = jsoupUtilsService.getPhone(content,tenantId);
            List<String> aListPhone = phone.getAList();
            List<String> htmlListPhone = phone.getHtmlList();
            List<String> strListPhone = phone.getStrList();
            if(htmlListPhone.size() > 0){
                String htmlList = StringUtil.join(htmlListPhone,",");
                linkPersonalPhoneDetection.setHtmlList(htmlList);
                String ahtmlList = StringUtil.join(aListPhone,",");
                linkPersonalPhoneDetection.setAhtmlList(ahtmlList);
                String strList = StringUtil.join(strListPhone,",");
                System.out.println("========================================================================================");
                System.out.println(htmlList);
                System.out.println(ahtmlList);
                System.out.println(strList);
                System.out.println(phone.getHtml());
                System.out.println("========================================================================================");
                linkPersonalPhoneDetection.setStrList(strList);
                String htmlPhone = phone.getHtml();
                linkPersonalPhoneDetection.setRetMsg(htmlPhone);
                Integer indexIn = 0;
                try {
                    String[] split = htmlList.split(",");
                    indexIn = split.length;
                }catch (Exception e){

                }
                linkPersonalPhoneDetection.setErrorCount(indexIn);
                linkPersonalPhoneDetection.setIsRevise("1");
                linkPersonalPhoneDetection.setCheckState("2");
                iLinkPersonalPhoneDetectionService.saveOrUpdate(linkPersonalPhoneDetection);
                saveLinkPersonalPhoneDetectionLog(linkPersonalPhoneDetection);
                //saveLinkPersonalPhoneDetectionStatistics(mainSiteId,mainSiteName,mainSiteUrl,tenantId,"1");
            }

            log.info("================设置身份证号====================");
            LinkPersonalIdNumberDetection linkPersonalIdNumberDetection = new LinkPersonalIdNumberDetection();
            linkPersonalIdNumberDetection.setId(DigestUtils.md5DigestAsHex(source.getBytes()));
            linkPersonalIdNumberDetection.setCheckTime(new Date());
            linkPersonalIdNumberDetection.setUpdateTime(new Date());
            linkPersonalIdNumberDetection.setMainSiteId(mainSiteId);
            linkPersonalIdNumberDetection.setMainSiteName(mainSiteName);
            linkPersonalIdNumberDetection.setMainSiteUrl(mainSiteUrl);
            linkPersonalIdNumberDetection.setSource(source);
            linkPersonalIdNumberDetection.setTitle(title);
            linkPersonalIdNumberDetection.setArticleReleaseTime(articleReleaseTime);
            linkPersonalIdNumberDetection.setContent(content);
            linkPersonalIdNumberDetection.setIsInvalid(isInvalid);
            linkPersonalIdNumberDetection.setTenantId(tenantId);
            LinkPersonalIdNumberDetection personalIdNumberDetection = iLinkPersonalIdNumberDetectionService.getById(linkPersonalPhoneDetection.getId());
            if(!ObjectUtils.isEmpty(personalIdNumberDetection)){
                Integer numberScans = personalIdNumberDetection.getNumberScans();
                if(!ObjectUtils.isEmpty(numberScans)){
                    if(numberScans != 0){
                        numberScans = numberScans + 1;
                        linkPersonalIdNumberDetection.setIsIgnore(personalIdNumberDetection.getIsIgnore());
                    }else{
                        linkPersonalIdNumberDetection.setIsIgnore("2");
                    }
                }else {
                    numberScans = 0;
                    linkPersonalIdNumberDetection.setIsIgnore("2");
                }
                linkPersonalIdNumberDetection.setNumberScans(numberScans);
            }else{
                linkPersonalIdNumberDetection.setNumberScans(0);
                linkPersonalIdNumberDetection.setIsIgnore("2");

            }
            JsoupReturn idNumber = jsoupUtilsService.getIdNumber(content,tenantId);
            List<String> aListIdNumber = idNumber.getAList();
            List<String> htmlListIdNumber = idNumber.getHtmlList();
            List<String> strListIdNumber = idNumber.getStrList();
            if(htmlListIdNumber.size() > 0){
                String idhtmlList = StringUtil.join(htmlListIdNumber,",");
                linkPersonalIdNumberDetection.setHtmlList(idhtmlList);
                String idahtmlList = StringUtil.join(aListIdNumber,",");
                linkPersonalIdNumberDetection.setAhtmlList(idahtmlList);
                String idstrList = StringUtil.join(strListIdNumber,",");
                linkPersonalIdNumberDetection.setStrList(idstrList);
                String htmlidNumber = idNumber.getHtml();
                linkPersonalIdNumberDetection.setRetMsg(htmlidNumber);
                Integer indexIn = 0;
                try {
                    String[] split = idahtmlList.split(",");
                    indexIn = split.length;
                }catch (Exception e){

                }
                linkPersonalIdNumberDetection.setErrorCount(indexIn);
                linkPersonalIdNumberDetection.setIsRevise("1");
                linkPersonalIdNumberDetection.setCheckState("2");
                iLinkPersonalIdNumberDetectionService.saveOrUpdate(linkPersonalIdNumberDetection);
                saveLinkPersonalIdNumberDetectionLog(linkPersonalIdNumberDetection);
                //saveLinkPersonalPersonalIdDetectionStatistics(mainSiteId,mainSiteName,mainSiteUrl,tenantId,"1");
            }
            log.info("================设置银行卡号====================");
            LinkPersonalBankCardDetection linkPersonalBankCardDetection = new LinkPersonalBankCardDetection();
            linkPersonalBankCardDetection.setId(DigestUtils.md5DigestAsHex(source.getBytes()));
            linkPersonalBankCardDetection.setCheckTime(new Date());
            linkPersonalBankCardDetection.setUpdateTime(new Date());
            linkPersonalBankCardDetection.setMainSiteId(mainSiteId);
            linkPersonalBankCardDetection.setMainSiteName(mainSiteName);
            linkPersonalBankCardDetection.setMainSiteUrl(mainSiteUrl);
            linkPersonalBankCardDetection.setSource(source);
            linkPersonalBankCardDetection.setTitle(title);
            linkPersonalBankCardDetection.setArticleReleaseTime(articleReleaseTime);
            linkPersonalBankCardDetection.setContent(content);
            linkPersonalBankCardDetection.setIsInvalid(isInvalid);
            linkPersonalBankCardDetection.setTenantId(tenantId);
            LinkPersonalBankCardDetection personalBankCardDetection = iLinkPersonalBankCardDetectionService.getById(linkPersonalPhoneDetection.getId());
            if(!ObjectUtils.isEmpty(personalBankCardDetection)){
                Integer numberScans = personalBankCardDetection.getNumberScans();
                if(!ObjectUtils.isEmpty(numberScans)){
                    if(numberScans != 0){
                        numberScans = numberScans + 1;
                        linkPersonalBankCardDetection.setIsIgnore(personalBankCardDetection.getIsIgnore());
                    }else{
                        linkPersonalBankCardDetection.setIsIgnore("2");
                    }
                }else {
                    numberScans = 0;
                    linkPersonalBankCardDetection.setIsIgnore("2");
                }
                linkPersonalBankCardDetection.setNumberScans(numberScans);
            }else{
                linkPersonalBankCardDetection.setNumberScans(0);
                linkPersonalBankCardDetection.setIsIgnore("2");
            }
            JsoupReturn bankCardNumber = jsoupUtilsService.getBankCardNumber(content,tenantId);
            List<String> aListBankCardNumber = bankCardNumber.getAList();
            List<String> htmlListBankCardNumber = bankCardNumber.getHtmlList();
            List<String> strListBankCardNumber = bankCardNumber.getStrList();
            if(htmlListBankCardNumber.size() > 0){
                String bankCardNumberhtmlList = StringUtil.join(htmlListBankCardNumber,",");

                linkPersonalBankCardDetection.setHtmlList(bankCardNumberhtmlList);
                String bankCardahtmlList = StringUtil.join(aListBankCardNumber,",");

                linkPersonalBankCardDetection.setAhtmlList(bankCardahtmlList);
                String bankCardNumberstrList = StringUtil.join(strListBankCardNumber,",");

                linkPersonalBankCardDetection.setStrList(bankCardNumberstrList);
                String htmlbankCard = bankCardNumber.getHtml();
                linkPersonalBankCardDetection.setRetMsg(htmlbankCard);
                Integer indexIn = 0;
                try {
                    String[] split = bankCardahtmlList.split(",");
                    indexIn = split.length;
                }catch (Exception e){

                }
                linkPersonalBankCardDetection.setErrorCount(indexIn);
                linkPersonalBankCardDetection.setIsRevise("1");
                linkPersonalBankCardDetection.setCheckState("2");
                iLinkPersonalBankCardDetectionService.saveOrUpdate(linkPersonalBankCardDetection);
                saveLinkPersonalBankCardDetectionLog(linkPersonalBankCardDetection);
                //saveLinkPersonalBankCardDetectionStatistics(mainSiteId,mainSiteName,mainSiteUrl,tenantId,"1");
            }
        }
    }

    public void crawlingIdNumber(
            String mainSiteId,
            String mainSiteName,
            String mainSiteUrl,
            String source,
            String title,
            Date articleReleaseTime,
            String content,
            String isInvalid,
            String tenantId
    ){
        if(!ObjectUtils.isEmpty(source) && !ObjectUtils.isEmpty(content) ){
            LinkPersonalIdNumberDetection linkPersonalIdNumberDetection = new LinkPersonalIdNumberDetection();
            linkPersonalIdNumberDetection.setId(DigestUtils.md5DigestAsHex(source.getBytes()));
            linkPersonalIdNumberDetection.setCheckTime(new Date());
            linkPersonalIdNumberDetection.setUpdateTime(new Date());
            linkPersonalIdNumberDetection.setMainSiteId(mainSiteId);
            linkPersonalIdNumberDetection.setMainSiteName(mainSiteName);
            linkPersonalIdNumberDetection.setMainSiteUrl(mainSiteUrl);
            linkPersonalIdNumberDetection.setSource(source);
            linkPersonalIdNumberDetection.setTitle(title);
            linkPersonalIdNumberDetection.setArticleReleaseTime(articleReleaseTime);
            linkPersonalIdNumberDetection.setContent(content);
            linkPersonalIdNumberDetection.setIsInvalid(isInvalid);
            linkPersonalIdNumberDetection.setTenantId(tenantId);
            LinkPersonalIdNumberDetection personalIdNumberDetection = iLinkPersonalIdNumberDetectionService.getById(linkPersonalIdNumberDetection.getId());
            if(!ObjectUtils.isEmpty(personalIdNumberDetection)){
                Integer numberScans = personalIdNumberDetection.getNumberScans();
                if(!ObjectUtils.isEmpty(numberScans)){
                    if(numberScans != 0){
                        numberScans = numberScans + 1;
                        linkPersonalIdNumberDetection.setIsIgnore(personalIdNumberDetection.getIsIgnore());
                    }else{
                        linkPersonalIdNumberDetection.setIsIgnore("2");
                    }
                }else {
                    numberScans = 0;
                    linkPersonalIdNumberDetection.setIsIgnore("2");
                }
                linkPersonalIdNumberDetection.setNumberScans(numberScans);
            }else{
                linkPersonalIdNumberDetection.setNumberScans(0);
                linkPersonalIdNumberDetection.setIsIgnore("2");
            }
            JsoupReturn idNumber = jsoupUtilsService.getIdNumber(content,tenantId);
            List<String> aListIdNumber = idNumber.getAList();
            List<String> htmlListIdNumber = idNumber.getHtmlList();
            List<String> strListIdNumber = idNumber.getStrList();
            System.out.println("============="+source);
            System.out.println("============="+htmlListIdNumber.size());
            if(htmlListIdNumber.size() > 0){
                String idhtmlList = StringUtil.join(htmlListIdNumber,",");
                linkPersonalIdNumberDetection.setHtmlList(idhtmlList);
                String idahtmlList = StringUtil.join(aListIdNumber,",");
                linkPersonalIdNumberDetection.setAhtmlList(idahtmlList);
                String idstrList = StringUtil.join(strListIdNumber,",");
                linkPersonalIdNumberDetection.setStrList(idstrList);
                String htmlidNumber = idNumber.getHtml();
                linkPersonalIdNumberDetection.setRetMsg(htmlidNumber);
                Integer indexIn = 0;
                try {
                    String[] split = idahtmlList.split(",");
                    indexIn = split.length;
                }catch (Exception e){
                }
                linkPersonalIdNumberDetection.setErrorCount(indexIn);
                linkPersonalIdNumberDetection.setIsRevise("1");
                linkPersonalIdNumberDetection.setCheckState("2");
                iLinkPersonalIdNumberDetectionService.saveOrUpdate(linkPersonalIdNumberDetection);
                saveLinkPersonalIdNumberDetectionLog(linkPersonalIdNumberDetection);
            }
        }
    }

    public void crawlingPhone(
            String mainSiteId,
            String mainSiteName,
            String mainSiteUrl,
            String source,
            String title,
            Date articleReleaseTime,
            String content,
            String isInvalid,
            String tenantId
    ){
        if(!ObjectUtils.isEmpty(source) && !ObjectUtils.isEmpty(content) ){
            //设置手机号
            log.info("================设置手机号====================");
            LinkPersonalPhoneDetection linkPersonalPhoneDetection = new LinkPersonalPhoneDetection();
            linkPersonalPhoneDetection.setId(DigestUtils.md5DigestAsHex(source.getBytes()));
            linkPersonalPhoneDetection.setCreateTime(new Date());
            linkPersonalPhoneDetection.setUpdateTime(new Date());
            linkPersonalPhoneDetection.setMainSiteId(mainSiteId);
            linkPersonalPhoneDetection.setMainSiteName(mainSiteName);
            linkPersonalPhoneDetection.setMainSiteUrl(mainSiteUrl);
            linkPersonalPhoneDetection.setSource(source);
            linkPersonalPhoneDetection.setTitle(title);
            linkPersonalPhoneDetection.setArticleReleaseTime(articleReleaseTime);
            linkPersonalPhoneDetection.setContent(content);
            linkPersonalPhoneDetection.setIsInvalid(isInvalid);
            linkPersonalPhoneDetection.setTenantId(tenantId);
            LinkPersonalPhoneDetection personalPhoneDetection = iLinkPersonalPhoneDetectionService.getById(linkPersonalPhoneDetection.getId());
            if(!ObjectUtils.isEmpty(personalPhoneDetection)){
                Integer numberScans = personalPhoneDetection.getNumberScans();
                if(!ObjectUtils.isEmpty(numberScans)){
                    if(numberScans != 0){
                        numberScans = numberScans + 1;
                        linkPersonalPhoneDetection.setIsIgnore(personalPhoneDetection.getIsIgnore());
                    }else{
                        linkPersonalPhoneDetection.setIsIgnore("2");
                    }
                }else {
                    numberScans = 0;
                    linkPersonalPhoneDetection.setIsIgnore("2");
                }
                linkPersonalPhoneDetection.setNumberScans(numberScans);
            }else{
                linkPersonalPhoneDetection.setNumberScans(0);
                linkPersonalPhoneDetection.setIsIgnore("2");
            }

            JsoupReturn phone = jsoupUtilsService.getPhone(content,tenantId);
            List<String> aListPhone = phone.getAList();
            List<String> htmlListPhone = phone.getHtmlList();
            List<String> strListPhone = phone.getStrList();
            if(htmlListPhone.size() > 0){
                String htmlList = StringUtil.join(htmlListPhone,",");
                linkPersonalPhoneDetection.setHtmlList(htmlList);
                String ahtmlList = StringUtil.join(aListPhone,",");
                linkPersonalPhoneDetection.setAhtmlList(ahtmlList);
                String strList = StringUtil.join(strListPhone,",");
                System.out.println("========================================================================================");
                System.out.println(htmlList);
                System.out.println(ahtmlList);
                System.out.println(strList);
                System.out.println(phone.getHtml());
                System.out.println("========================================================================================");
                linkPersonalPhoneDetection.setStrList(strList);
                String htmlPhone = phone.getHtml();
                linkPersonalPhoneDetection.setRetMsg(htmlPhone);
                Integer indexIn = 0;
                try {
                    String[] split = htmlList.split(",");
                    indexIn = split.length;
                }catch (Exception e){
                }
                linkPersonalPhoneDetection.setErrorCount(indexIn);
                linkPersonalPhoneDetection.setIsRevise("1");
                linkPersonalPhoneDetection.setCheckState("2");
                iLinkPersonalPhoneDetectionService.saveOrUpdate(linkPersonalPhoneDetection);
                saveLinkPersonalPhoneDetectionLog(linkPersonalPhoneDetection);
            }
        }
    }

    public void crawlingCheck(
            LinkPersonalPhoneDetection linkPersonalPhoneDetection
    ){
        if(!ObjectUtils.isEmpty(linkPersonalPhoneDetection)){
            try {
                String source = linkPersonalPhoneDetection.getSource();
                String mainSiteId = linkPersonalPhoneDetection.getMainSiteId();
                MainSite byId = iMainSiteService.getById(mainSiteId);
                SpyderReturn spyderReturn = trendsSpyder.companyTrendsSpyderMessage(source, byId.getGrabPage());
                Document document = spyderReturn.getDocument();
                String baseUri = spyderReturn.getBaseUri();
                document = jsoupUtils.setUrl(document, baseUri);
                JsoupReturn phone = jsoupUtilsService.getPhone(document.toString(),linkPersonalPhoneDetection.getTenantId());
                List<String> aListPhone = phone.getAList();
                List<String> htmlListPhone = phone.getHtmlList();
                List<String> strListPhone = phone.getStrList();
                if(htmlListPhone.size() > 0){
                    String htmlList = StringUtil.join(htmlListPhone,",");
                    linkPersonalPhoneDetection.setHtmlList(htmlList);
                    String ahtmlList = StringUtil.join(aListPhone,",");
                    linkPersonalPhoneDetection.setAhtmlList(ahtmlList);
                    String strList = StringUtil.join(strListPhone,",");
                    linkPersonalPhoneDetection.setStrList(strList);
                    String htmlPhone = phone.getHtml();
                    linkPersonalPhoneDetection.setRetMsg(htmlPhone);
                    Integer indexIn = 0;
                    try {
                        String[] split = htmlList.split(",");
                        indexIn = split.length;
                    }catch (Exception e){
                    }
                    linkPersonalPhoneDetection.setCheckErrorCount(indexIn);
                    Integer numberScans = linkPersonalPhoneDetection.getNumberScans();
                    if(!ObjectUtils.isEmpty(linkPersonalPhoneDetection)){
                        numberScans = numberScans + 1;
                        linkPersonalPhoneDetection.setNumberScans(numberScans);
                    }
                    linkPersonalPhoneDetection.setIsRevise("1");
                }else{
                    linkPersonalPhoneDetection.setIsRevise("2");
                    linkPersonalPhoneDetection.setCheckErrorCount(0);
                }
                linkPersonalPhoneDetection.setCheckState("1");
                linkPersonalPhoneDetection.setCheckTime(new Date());
                iLinkPersonalPhoneDetectionService.saveOrUpdate(linkPersonalPhoneDetection);
                saveLinkPersonalPhoneDetectionLog(linkPersonalPhoneDetection);
            }catch (Exception e){
                e.printStackTrace();
            }

        }
    }

    public void crawlingBankCard(
            String mainSiteId,
            String mainSiteName,
            String mainSiteUrl,
            String source,
            String title,
            Date articleReleaseTime,
            String content,
            String isInvalid,
            String tenantId
    ){
        if(!ObjectUtils.isEmpty(source) && !ObjectUtils.isEmpty(content) ){
            LinkPersonalBankCardDetection linkPersonalBankCardDetection = new LinkPersonalBankCardDetection();
            linkPersonalBankCardDetection.setId(DigestUtils.md5DigestAsHex(source.getBytes()));
            linkPersonalBankCardDetection.setCheckTime(new Date());
            linkPersonalBankCardDetection.setUpdateTime(new Date());
            linkPersonalBankCardDetection.setMainSiteId(mainSiteId);
            linkPersonalBankCardDetection.setMainSiteName(mainSiteName);
            linkPersonalBankCardDetection.setMainSiteUrl(mainSiteUrl);
            linkPersonalBankCardDetection.setSource(source);
            linkPersonalBankCardDetection.setTitle(title);
            linkPersonalBankCardDetection.setArticleReleaseTime(articleReleaseTime);
            linkPersonalBankCardDetection.setContent(content);
            linkPersonalBankCardDetection.setIsInvalid(isInvalid);
            linkPersonalBankCardDetection.setTenantId(tenantId);
            LinkPersonalBankCardDetection personalBankCardDetection = iLinkPersonalBankCardDetectionService.getById(linkPersonalBankCardDetection.getId());
            if(!ObjectUtils.isEmpty(personalBankCardDetection)){
                Integer numberScans = personalBankCardDetection.getNumberScans();
                if(!ObjectUtils.isEmpty(numberScans)){
                    if(numberScans != 0){
                        numberScans = numberScans + 1;
                        linkPersonalBankCardDetection.setIsIgnore(personalBankCardDetection.getIsIgnore());
                    }else{
                        linkPersonalBankCardDetection.setIsIgnore("2");
                    }
                }else {
                    numberScans = 0;
                    linkPersonalBankCardDetection.setIsIgnore("2");
                }
                linkPersonalBankCardDetection.setNumberScans(numberScans);
            }else{
                linkPersonalBankCardDetection.setNumberScans(0);
                linkPersonalBankCardDetection.setIsIgnore("2");
            }
            JsoupReturn bankCardNumber = jsoupUtilsService.getBankCardNumber(content,tenantId);
            List<String> aListBankCardNumber = bankCardNumber.getAList();
            List<String> htmlListBankCardNumber = bankCardNumber.getHtmlList();
            List<String> strListBankCardNumber = bankCardNumber.getStrList();
            if(htmlListBankCardNumber.size() > 0){
                String bankCardNumberhtmlList = StringUtil.join(htmlListBankCardNumber,",");

                linkPersonalBankCardDetection.setHtmlList(bankCardNumberhtmlList);
                String bankCardahtmlList = StringUtil.join(aListBankCardNumber,",");

                linkPersonalBankCardDetection.setAhtmlList(bankCardahtmlList);
                String bankCardNumberstrList = StringUtil.join(strListBankCardNumber,",");

                linkPersonalBankCardDetection.setStrList(bankCardNumberstrList);
                String htmlbankCard = bankCardNumber.getHtml();
                linkPersonalBankCardDetection.setRetMsg(htmlbankCard);
                Integer indexIn = 0;
                try {
                    String[] split = bankCardahtmlList.split(",");
                    indexIn = split.length;
                }catch (Exception e){

                }
                linkPersonalBankCardDetection.setErrorCount(indexIn);
                linkPersonalBankCardDetection.setIsRevise("1");
                linkPersonalBankCardDetection.setCheckState("2");
                iLinkPersonalBankCardDetectionService.saveOrUpdate(linkPersonalBankCardDetection);
                saveLinkPersonalBankCardDetectionLog(linkPersonalBankCardDetection);
            }
        }
    }

    public void crawlingCheckPersonalIdNumber(LinkPersonalIdNumberDetection linkPersonalIdNumberDetection) {
        if(!ObjectUtils.isEmpty(linkPersonalIdNumberDetection)){
            try {
                String source = linkPersonalIdNumberDetection.getSource();
                String mainSiteId = linkPersonalIdNumberDetection.getMainSiteId();
                MainSite byId = iMainSiteService.getById(mainSiteId);
                SpyderReturn spyderReturn = trendsSpyder.companyTrendsSpyderMessage(source, byId.getGrabPage());
                Document document = spyderReturn.getDocument();
                String baseUri = spyderReturn.getBaseUri();
                document = jsoupUtils.setUrl(document, baseUri);
                JsoupReturn IdNumber = jsoupUtilsService.getIdNumber(document.toString(),linkPersonalIdNumberDetection.getTenantId());
                List<String> aListIdNumber = IdNumber.getAList();
                List<String> htmlListIdNumber = IdNumber.getHtmlList();
                List<String> strListIdNumber = IdNumber.getStrList();
                if(htmlListIdNumber.size() > 0){
                    String htmlList = StringUtil.join(htmlListIdNumber,",");
                    linkPersonalIdNumberDetection.setHtmlList(htmlList);
                    String ahtmlList = StringUtil.join(aListIdNumber,",");
                    linkPersonalIdNumberDetection.setAhtmlList(ahtmlList);
                    String strList = StringUtil.join(strListIdNumber,",");
                    linkPersonalIdNumberDetection.setStrList(strList);
                    String htmlPhone = IdNumber.getHtml();
                    linkPersonalIdNumberDetection.setRetMsg(htmlPhone);
                    Integer indexIn = 0;
                    try {
                        String[] split = htmlList.split(",");
                        indexIn = split.length;
                    }catch (Exception e){
                    }
                    linkPersonalIdNumberDetection.setCheckErrorCount(indexIn);
                    Integer numberScans = linkPersonalIdNumberDetection.getNumberScans();
                    if(!ObjectUtils.isEmpty(linkPersonalIdNumberDetection)){
                        numberScans = numberScans + 1;
                        linkPersonalIdNumberDetection.setNumberScans(numberScans);
                    }
                    linkPersonalIdNumberDetection.setIsRevise("1");
                }else{
                    linkPersonalIdNumberDetection.setIsRevise("2");
                    linkPersonalIdNumberDetection.setCheckErrorCount(0);
                }
                linkPersonalIdNumberDetection.setCheckState("1");
                linkPersonalIdNumberDetection.setCheckTime(new Date());
                linkPersonalIdNumberDetectionService.saveOrUpdate(linkPersonalIdNumberDetection);
                saveLinkPersonalIdNumberDetectionLog(linkPersonalIdNumberDetection);
            }catch (Exception e){
                e.printStackTrace();
            }
            try {
                String source = linkPersonalIdNumberDetection.getSource();
                String mainSiteId = linkPersonalIdNumberDetection.getMainSiteId();
                MainSite byId = iMainSiteService.getById(mainSiteId);
                SpyderReturn spyderReturn = trendsSpyder.companyTrendsSpyderMessage(source, byId.getGrabPage());
                Document document = spyderReturn.getDocument();
                String baseUri = spyderReturn.getBaseUri();
                document = jsoupUtils.setUrl(document, baseUri);
                JsoupReturn phone = jsoupUtilsService.getPhone(document.toString(),linkPersonalIdNumberDetection.getTenantId());
                List<String> aListPhone = phone.getAList();
                List<String> htmlListPhone = phone.getHtmlList();
                List<String> strListPhone = phone.getStrList();
                if(htmlListPhone.size() > 0){
                    String htmlList = StringUtil.join(htmlListPhone,",");
                    linkPersonalIdNumberDetection.setHtmlList(htmlList);
                    String ahtmlList = StringUtil.join(aListPhone,",");
                    linkPersonalIdNumberDetection.setAhtmlList(ahtmlList);
                    String strList = StringUtil.join(strListPhone,",");
                    linkPersonalIdNumberDetection.setStrList(strList);
                    String htmlPhone = phone.getHtml();
                    linkPersonalIdNumberDetection.setRetMsg(htmlPhone);
                    Integer indexIn = 0;
                    try {
                        String[] split = htmlList.split(",");
                        indexIn = split.length;
                    }catch (Exception e){
                    }
                    linkPersonalIdNumberDetection.setCheckErrorCount(indexIn);
                    Integer numberScans = linkPersonalIdNumberDetection.getNumberScans();
                    if(!ObjectUtils.isEmpty(linkPersonalIdNumberDetection)){
                        numberScans = numberScans + 1;
                        linkPersonalIdNumberDetection.setNumberScans(numberScans);
                    }
                    linkPersonalIdNumberDetection.setIsRevise("1");
                }else{
                    linkPersonalIdNumberDetection.setIsRevise("2");
                    linkPersonalIdNumberDetection.setCheckErrorCount(0);
                }
                linkPersonalIdNumberDetection.setCheckState("1");
                linkPersonalIdNumberDetection.setCheckTime(new Date());
                linkPersonalIdNumberDetectionService.saveOrUpdate(linkPersonalIdNumberDetection);
                saveLinkPersonalIdNumberDetectionLog(linkPersonalIdNumberDetection);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }

    public void crawlingCheckBankCard(LinkPersonalBankCardDetection linkPersonalBankCardDetections) {
        if(!ObjectUtils.isEmpty(linkPersonalBankCardDetections)){
            try {
                String source = linkPersonalBankCardDetections.getSource();
                String mainSiteId = linkPersonalBankCardDetections.getMainSiteId();
                MainSite byId = iMainSiteService.getById(mainSiteId);
                SpyderReturn spyderReturn = trendsSpyder.companyTrendsSpyderMessage(source, byId.getGrabPage());
                Document document = spyderReturn.getDocument();
                String baseUri = spyderReturn.getBaseUri();
                document = jsoupUtils.setUrl(document, baseUri);
                JsoupReturn BankCardNumber = jsoupUtilsService.getBankCardNumber(document.toString(),linkPersonalBankCardDetections.getTenantId());
                List<String> aListBankCard = BankCardNumber.getAList();
                List<String> htmlListBankCard = BankCardNumber.getHtmlList();
                List<String> strListBankCard = BankCardNumber.getStrList();
                if(htmlListBankCard.size() > 0){
                    String htmlList = StringUtil.join(htmlListBankCard,",");
                    linkPersonalBankCardDetections.setHtmlList(htmlList);
                    String ahtmlList = StringUtil.join(aListBankCard,",");
                    linkPersonalBankCardDetections.setAhtmlList(ahtmlList);
                    String strList = StringUtil.join(strListBankCard,",");
                    linkPersonalBankCardDetections.setStrList(strList);
                    String htmlBankCard = BankCardNumber.getHtml();
                    linkPersonalBankCardDetections.setRetMsg(htmlBankCard);
                    Integer indexIn = 0;
                    try {
                        String[] split = htmlList.split(",");
                        indexIn = split.length;
                    }catch (Exception e){
                    }
                    linkPersonalBankCardDetections.setCheckErrorCount(indexIn);
                    Integer numberScans = linkPersonalBankCardDetections.getNumberScans();
                    if(!ObjectUtils.isEmpty(linkPersonalBankCardDetections)){
                        numberScans = numberScans + 1;
                        linkPersonalBankCardDetections.setNumberScans(numberScans);
                    }
                    linkPersonalBankCardDetections.setIsRevise("1");
                }else{
                    linkPersonalBankCardDetections.setIsRevise("2");
                    linkPersonalBankCardDetections.setCheckErrorCount(0);
                }
                linkPersonalBankCardDetections.setCheckState("1");
                linkPersonalBankCardDetections.setCheckTime(new Date());
                iLinkPersonalBankCardDetectionService.saveOrUpdate(linkPersonalBankCardDetections);
                saveLinkPersonalBankCardDetectionLog(linkPersonalBankCardDetections);
            }catch (Exception e){
                e.printStackTrace();
            }
            try {
                String source = linkPersonalBankCardDetections.getSource();
                String mainSiteId = linkPersonalBankCardDetections.getMainSiteId();
                MainSite byId = iMainSiteService.getById(mainSiteId);
                SpyderReturn spyderReturn = trendsSpyder.companyTrendsSpyderMessage(source, byId.getGrabPage());
                Document document = spyderReturn.getDocument();
                String baseUri = spyderReturn.getBaseUri();
                document = jsoupUtils.setUrl(document, baseUri);
                JsoupReturn phone = jsoupUtilsService.getPhone(document.toString(),linkPersonalBankCardDetections.getTenantId());
                List<String> aListPhone = phone.getAList();
                List<String> htmlListPhone = phone.getHtmlList();
                List<String> strListPhone = phone.getStrList();
                if(htmlListPhone.size() > 0){
                    String htmlList = StringUtil.join(htmlListPhone,",");
                    linkPersonalBankCardDetections.setHtmlList(htmlList);
                    String ahtmlList = StringUtil.join(aListPhone,",");
                    linkPersonalBankCardDetections.setAhtmlList(ahtmlList);
                    String strList = StringUtil.join(strListPhone,",");
                    linkPersonalBankCardDetections.setStrList(strList);
                    String htmlPhone = phone.getHtml();
                    linkPersonalBankCardDetections.setRetMsg(htmlPhone);
                    Integer indexIn = 0;
                    try {
                        String[] split = htmlList.split(",");
                        indexIn = split.length;
                    }catch (Exception e){
                    }
                    linkPersonalBankCardDetections.setCheckErrorCount(indexIn);
                    Integer numberScans = linkPersonalBankCardDetections.getNumberScans();
                    if(!ObjectUtils.isEmpty(linkPersonalBankCardDetections)){
                        numberScans = numberScans + 1;
                        linkPersonalBankCardDetections.setNumberScans(numberScans);
                    }
                    linkPersonalBankCardDetections.setIsRevise("1");
                }else{
                    linkPersonalBankCardDetections.setIsRevise("2");
                    linkPersonalBankCardDetections.setCheckErrorCount(0);
                }
                linkPersonalBankCardDetections.setCheckState("1");
                linkPersonalBankCardDetections.setCheckTime(new Date());
                iLinkPersonalBankCardDetectionService.saveOrUpdate(linkPersonalBankCardDetections);
                saveLinkPersonalBankCardDetectionLog(linkPersonalBankCardDetections);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
    }



    public void saveLinkPersonalPhoneDetectionLog(LinkPersonalPhoneDetection linkPersonalPhoneDetection){
        LinkPersonalPhoneDetectionLog linkPersonalPhoneDetectionLog = new LinkPersonalPhoneDetectionLog();
        linkPersonalPhoneDetectionLog.setId(IdWorker.getIdStr());
        linkPersonalPhoneDetectionLog.setCreateBy(linkPersonalPhoneDetection.getCreateBy());
        linkPersonalPhoneDetectionLog.setCreateTime(linkPersonalPhoneDetection.getCreateTime());
        linkPersonalPhoneDetectionLog.setUpdateBy(linkPersonalPhoneDetection.getUpdateBy());
        linkPersonalPhoneDetectionLog.setUpdateTime(linkPersonalPhoneDetection.getUpdateTime());
        linkPersonalPhoneDetectionLog.setMainSiteId(linkPersonalPhoneDetection.getMainSiteId());
        linkPersonalPhoneDetectionLog.setMainSiteName(linkPersonalPhoneDetection.getMainSiteName());
        linkPersonalPhoneDetectionLog.setMainSiteUrl(linkPersonalPhoneDetection.getMainSiteUrl());
        linkPersonalPhoneDetectionLog.setSource(linkPersonalPhoneDetection.getSource());
        linkPersonalPhoneDetectionLog.setTitle(linkPersonalPhoneDetection.getTitle());
        linkPersonalPhoneDetectionLog.setArticleReleaseTime(linkPersonalPhoneDetection.getArticleReleaseTime());
        linkPersonalPhoneDetectionLog.setContent(linkPersonalPhoneDetection.getContent());
        linkPersonalPhoneDetectionLog.setRetMsg(linkPersonalPhoneDetection.getRetMsg());
        linkPersonalPhoneDetectionLog.setErrorCount(linkPersonalPhoneDetection.getErrorCount());
        linkPersonalPhoneDetectionLog.setHtmlList(linkPersonalPhoneDetection.getHtmlList());
        linkPersonalPhoneDetectionLog.setStrList(linkPersonalPhoneDetection.getStrList());
        linkPersonalPhoneDetectionLog.setAhtmlList(linkPersonalPhoneDetection.getAhtmlList());
        linkPersonalPhoneDetectionLog.setIsInvalid(linkPersonalPhoneDetection.getIsInvalid());
        linkPersonalPhoneDetectionLog.setIsRevise(linkPersonalPhoneDetection.getIsRevise());
        linkPersonalPhoneDetectionLog.setIsIgnore(linkPersonalPhoneDetection.getIsIgnore());
        linkPersonalPhoneDetectionLog.setCheckTime(linkPersonalPhoneDetection.getCheckTime());
        linkPersonalPhoneDetectionLog.setCheckState(linkPersonalPhoneDetection.getCheckState());
        linkPersonalPhoneDetectionLog.setCheckErrorCount(linkPersonalPhoneDetection.getCheckErrorCount());
        linkPersonalPhoneDetectionLog.setCheckMessage(linkPersonalPhoneDetection.getCheckMessage());
        linkPersonalPhoneDetectionLog.setNumberScans(linkPersonalPhoneDetection.getNumberScans());
        linkPersonalPhoneDetectionLog.setTenantId(linkPersonalPhoneDetection.getTenantId());
        iLinkPersonalPhoneDetectionLogService.save(linkPersonalPhoneDetectionLog);
    }
    public void saveLinkPersonalIdNumberDetectionLog(LinkPersonalIdNumberDetection linkPersonalIdNumberDetection){
        LinkPersonalIdNumberDetectionLog linkPersonalIdNumberDetectionLog = new LinkPersonalIdNumberDetectionLog();
        linkPersonalIdNumberDetectionLog.setId(IdWorker.getIdStr());
        linkPersonalIdNumberDetectionLog.setCreateBy(linkPersonalIdNumberDetection.getCreateBy());
        linkPersonalIdNumberDetectionLog.setCreateTime(linkPersonalIdNumberDetection.getCreateTime());
        linkPersonalIdNumberDetectionLog.setUpdateBy(linkPersonalIdNumberDetection.getUpdateBy());
        linkPersonalIdNumberDetectionLog.setUpdateTime(linkPersonalIdNumberDetection.getUpdateTime());
        linkPersonalIdNumberDetectionLog.setMainSiteId(linkPersonalIdNumberDetection.getMainSiteId());
        linkPersonalIdNumberDetectionLog.setMainSiteName(linkPersonalIdNumberDetection.getMainSiteName());
        linkPersonalIdNumberDetectionLog.setMainSiteUrl(linkPersonalIdNumberDetection.getMainSiteUrl());
        linkPersonalIdNumberDetectionLog.setSource(linkPersonalIdNumberDetection.getSource());
        linkPersonalIdNumberDetectionLog.setTitle(linkPersonalIdNumberDetection.getTitle());
        linkPersonalIdNumberDetectionLog.setArticleReleaseTime(linkPersonalIdNumberDetection.getArticleReleaseTime());
        linkPersonalIdNumberDetectionLog.setContent(linkPersonalIdNumberDetection.getContent());
        linkPersonalIdNumberDetectionLog.setRetMsg(linkPersonalIdNumberDetection.getRetMsg());
        linkPersonalIdNumberDetectionLog.setErrorCount(linkPersonalIdNumberDetection.getErrorCount());
        linkPersonalIdNumberDetectionLog.setHtmlList(linkPersonalIdNumberDetection.getHtmlList());
        linkPersonalIdNumberDetectionLog.setStrList(linkPersonalIdNumberDetection.getStrList());
        linkPersonalIdNumberDetectionLog.setAhtmlList(linkPersonalIdNumberDetection.getAhtmlList());
        linkPersonalIdNumberDetectionLog.setIsInvalid(linkPersonalIdNumberDetection.getIsInvalid());
        linkPersonalIdNumberDetectionLog.setIsRevise(linkPersonalIdNumberDetection.getIsRevise());
        linkPersonalIdNumberDetectionLog.setIsIgnore(linkPersonalIdNumberDetection.getIsIgnore());
        linkPersonalIdNumberDetectionLog.setCheckTime(linkPersonalIdNumberDetection.getCheckTime());
        linkPersonalIdNumberDetectionLog.setCheckState(linkPersonalIdNumberDetection.getCheckState());
        linkPersonalIdNumberDetectionLog.setCheckErrorCount(linkPersonalIdNumberDetection.getCheckErrorCount());
        linkPersonalIdNumberDetectionLog.setCheckMessage(linkPersonalIdNumberDetection.getCheckMessage());
        linkPersonalIdNumberDetectionLog.setNumberScans(linkPersonalIdNumberDetection.getNumberScans());
        linkPersonalIdNumberDetectionLog.setTenantId(linkPersonalIdNumberDetection.getTenantId());
        iLinkPersonalIdNumberDetectionLogService.save(linkPersonalIdNumberDetectionLog);
    }

    public void saveLinkPersonalBankCardDetectionLog(LinkPersonalBankCardDetection linkPersonalBankCardDetection){
        LinkPersonalBankCardDetectionLog linkPersonalBankCardDetectionLog = new LinkPersonalBankCardDetectionLog();
        linkPersonalBankCardDetectionLog.setId(IdWorker.getIdStr());
        linkPersonalBankCardDetectionLog.setCreateBy(linkPersonalBankCardDetection.getCreateBy());
        linkPersonalBankCardDetectionLog.setCreateTime(linkPersonalBankCardDetection.getCreateTime());
        linkPersonalBankCardDetectionLog.setUpdateBy(linkPersonalBankCardDetection.getUpdateBy());
        linkPersonalBankCardDetectionLog.setUpdateTime(linkPersonalBankCardDetection.getUpdateTime());
        linkPersonalBankCardDetectionLog.setMainSiteId(linkPersonalBankCardDetection.getMainSiteId());
        linkPersonalBankCardDetectionLog.setMainSiteName(linkPersonalBankCardDetection.getMainSiteName());
        linkPersonalBankCardDetectionLog.setMainSiteUrl(linkPersonalBankCardDetection.getMainSiteUrl());
        linkPersonalBankCardDetectionLog.setSource(linkPersonalBankCardDetection.getSource());
        linkPersonalBankCardDetectionLog.setTitle(linkPersonalBankCardDetection.getTitle());
        linkPersonalBankCardDetectionLog.setArticleReleaseTime(linkPersonalBankCardDetection.getArticleReleaseTime());
        linkPersonalBankCardDetectionLog.setContent(linkPersonalBankCardDetection.getContent());
        linkPersonalBankCardDetectionLog.setRetMsg(linkPersonalBankCardDetection.getRetMsg());
        linkPersonalBankCardDetectionLog.setErrorCount(linkPersonalBankCardDetection.getErrorCount());
        linkPersonalBankCardDetectionLog.setHtmlList(linkPersonalBankCardDetection.getHtmlList());
        linkPersonalBankCardDetectionLog.setStrList(linkPersonalBankCardDetection.getStrList());
        linkPersonalBankCardDetectionLog.setAhtmlList(linkPersonalBankCardDetection.getAhtmlList());
        linkPersonalBankCardDetectionLog.setIsInvalid(linkPersonalBankCardDetection.getIsInvalid());
        linkPersonalBankCardDetectionLog.setIsRevise(linkPersonalBankCardDetection.getIsRevise());
        linkPersonalBankCardDetectionLog.setIsIgnore(linkPersonalBankCardDetection.getIsIgnore());
        linkPersonalBankCardDetectionLog.setCheckTime(linkPersonalBankCardDetection.getCheckTime());
        linkPersonalBankCardDetectionLog.setCheckState(linkPersonalBankCardDetection.getCheckState());
        linkPersonalBankCardDetectionLog.setCheckErrorCount(linkPersonalBankCardDetection.getCheckErrorCount());
        linkPersonalBankCardDetectionLog.setCheckMessage(linkPersonalBankCardDetection.getCheckMessage());
        linkPersonalBankCardDetectionLog.setNumberScans(linkPersonalBankCardDetection.getNumberScans());
        linkPersonalBankCardDetectionLog.setTenantId(linkPersonalBankCardDetection.getTenantId());
        iLinkPersonalBankCardDetectionLogService.save(linkPersonalBankCardDetectionLog);
    }

    public void saveLinkPersonalPhoneDetectionStatistics(
            String mainSiteId,
            String mainSiteName,
            String mainSiteUrl,
            String tenantId,
            String type
    ){
        LinkPersonalPhoneDetectionStatistics linkPersonalPhoneDetectionStatistics = new LinkPersonalPhoneDetectionStatistics();
        linkPersonalPhoneDetectionStatistics.setId(IdWorker.getIdStr());
        linkPersonalPhoneDetectionStatistics.setMainSiteId(mainSiteId);
        linkPersonalPhoneDetectionStatistics.setMainSiteName(mainSiteName);
        linkPersonalPhoneDetectionStatistics.setMainSiteUrl(mainSiteUrl);
        linkPersonalPhoneDetectionStatistics.setScanTime(new Date());
        linkPersonalPhoneDetectionStatistics.setTestType(type);
        try {
            linkPersonalPhoneDetectionStatistics.setTenantId(Integer.parseInt(tenantId));
        }catch (Exception e){
        }
        //只统计外链
        TenantContext.setTenant(tenantId);
        LinkPersonalPhoneDetection personalPhoneDetection = iLinkPersonalPhoneDetectionService.listCountByMainUrl(mainSiteUrl);
        if(!ObjectUtils.isEmpty(personalPhoneDetection)){
            Integer errorCount = personalPhoneDetection.getErrorCount();
            if(!ObjectUtils.isEmpty(errorCount)){
                linkPersonalPhoneDetectionStatistics.setPersonalPhoneCount(errorCount);
                linkPersonalPhoneDetectionStatisticsService.save(linkPersonalPhoneDetectionStatistics);
            }
        }
    }
    public void saveLinkPersonalPersonalIdDetectionStatistics(
            String mainSiteId,
            String mainSiteName,
            String mainSiteUrl,
            String tenantId,
            String type
    ){
        LinkPersonalPersonalIdDetectionStatistics linkPersonalPersonalIdDetectionStatistics = new LinkPersonalPersonalIdDetectionStatistics();
        linkPersonalPersonalIdDetectionStatistics.setId(IdWorker.getIdStr());
        linkPersonalPersonalIdDetectionStatistics.setMainSiteId(mainSiteId);
        linkPersonalPersonalIdDetectionStatistics.setMainSiteName(mainSiteName);
        linkPersonalPersonalIdDetectionStatistics.setMainSiteUrl(mainSiteUrl);
        linkPersonalPersonalIdDetectionStatistics.setScanTime(new Date());
        linkPersonalPersonalIdDetectionStatistics.setTestType(type);
        try {
            linkPersonalPersonalIdDetectionStatistics.setTenantId(Integer.parseInt(tenantId));
        }catch (Exception e){
        }
        //只统计外链
        TenantContext.setTenant(tenantId);
        LinkPersonalIdNumberDetection linkPersonalIdNumberDetection = iLinkPersonalIdNumberDetectionService.listCountByMainUrl(mainSiteUrl);
        if(!ObjectUtils.isEmpty(linkPersonalIdNumberDetection)){
            Integer errorCount = linkPersonalIdNumberDetection.getErrorCount();
            if(!ObjectUtils.isEmpty(errorCount)){
                linkPersonalPersonalIdDetectionStatistics.setPersonalIdCount(errorCount);
                linkPersonalPersonalIdDetectionStatisticsService.save(linkPersonalPersonalIdDetectionStatistics);
            }
        }
    }
    public void saveLinkPersonalBankCardDetectionStatistics(
            String mainSiteId,
            String mainSiteName,
            String mainSiteUrl,
            String tenantId,
            String type
    ){
        LinkPersonalBankCardDetectionStatistics linkPersonalBankCardDetectionStatistics = new LinkPersonalBankCardDetectionStatistics();
        linkPersonalBankCardDetectionStatistics.setId(IdWorker.getIdStr());
        linkPersonalBankCardDetectionStatistics.setMainSiteId(mainSiteId);
        linkPersonalBankCardDetectionStatistics.setMainSiteName(mainSiteName);
        linkPersonalBankCardDetectionStatistics.setMainSiteUrl(mainSiteUrl);
        linkPersonalBankCardDetectionStatistics.setScanTime(new Date());
        linkPersonalBankCardDetectionStatistics.setTestType(type);
        try {
            linkPersonalBankCardDetectionStatistics.setTenantId(Integer.parseInt(tenantId));
        }catch (Exception e){
        }
        TenantContext.setTenant(tenantId);
        LinkPersonalBankCardDetection linkPersonalBankCardDetection = iLinkPersonalBankCardDetectionService.listCountByMainUrl(mainSiteUrl);
        if(!ObjectUtils.isEmpty(linkPersonalBankCardDetection)){
            Integer errorCount = linkPersonalBankCardDetection.getErrorCount();
            if(!ObjectUtils.isEmpty(errorCount)){
                linkPersonalBankCardDetectionStatistics.setBankCardCount(errorCount);
                linkPersonalBankCardDetectionStatisticsService.save(linkPersonalBankCardDetectionStatistics);
            }
        }
    }
}
