package org.jeecg.modules.demo.linkpersonalphonedetection.controller;

import java.util.*;
import javax.servlet.http.HttpServletRequest;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import lombok.Data;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.demo.externalinternalsite.entity.ExternalInternalSite;
import org.jeecg.modules.demo.externalinternalsite.service.IExternalInternalSiteService;
import org.jeecg.modules.demo.linkanchorlist.entity.LinkAnchorList;
import org.jeecg.modules.demo.linkanchorlist.service.ILinkAnchorListService;
import org.jeecg.modules.demo.linkpersonalphonedetection.entity.LinkPersonalPhoneDetection;
import org.jeecg.modules.demo.linkpersonalphonedetection.entity.LinkPersonalPhoneDetectionVo;
import org.jeecg.modules.demo.linkpersonalphonedetection.service.ILinkPersonalPhoneDetectionService;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;

import org.jeecg.modules.demo.linkpersonalphonedetection.service.ILinkPersonalPhoneDetectionVoService;
import org.jeecg.modules.demo.linkpersonalphonewhitelist.entity.LinkPersonalPhoneWhiteList;
import org.jeecg.modules.demo.linkpersonalphonewhitelist.service.ILinkPersonalPhoneWhiteListService;
import org.jeecg.modules.demo.linkpublishingtimegrasping.entity.LinkPublishingTimeGrasping;
import org.jeecg.modules.demo.linkpublishingtitle.entity.LinkPublishingTitle;
import org.jeecg.modules.demo.mainsite.entity.MainSite;
import org.jeecg.modules.demo.mainsite.service.IMainSiteService;
import org.jeecg.modules.demo.pagecontentcapture.controller.Params;
import org.jeecg.modules.demo.pagecontentcapture.entity.JsResult;
import org.jeecg.modules.demo.pagecontentcapture.entity.PageContentCapture;
import org.jeecg.modules.demo.pagecontentcapture.service.IPageContentCaptureService;
import org.jeecg.modules.spyderUtils.spider.*;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.DigestUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;

 /**
 * @Description: 个人信息手机号检测
 * @Author: jeecg-boot
 * @Date:   2023-05-26
 * @Version: V1.0
 */
@Api(tags="个人信息手机号检测")
@RestController
@RequestMapping("/linkpersonalphonedetection/linkPersonalPhoneDetection")
@Slf4j
public class LinkPersonalPhoneDetectionController extends JeecgController<LinkPersonalPhoneDetection, ILinkPersonalPhoneDetectionService> {
	 @Autowired
	 private ILinkPersonalPhoneDetectionService linkPersonalPhoneDetectionService;

	 @Autowired
	 private ILinkPersonalPhoneDetectionVoService linkPersonalPhoneDetectionVoService;

	 @Autowired
	 private ILinkPersonalPhoneWhiteListService linkPersonalPhoneWhiteListService;

	 @Autowired
	 private IExternalInternalSiteService externalInternalSiteService;

	 @Autowired
	 private IPageContentCaptureService iPageContentCaptureService;

	 @Autowired
	 private IMainSiteService iMainSiteService;

	 @Autowired
	 private TrendsSpyder trendsSpyder;

	 @Autowired
	 private JsoupUtils jsoupUtils;

	 @Autowired
	 private CrawlingUtils crawlingUtils;


	 @Autowired
	 private FangCunUtils fangCunUtils;

	 @Autowired
	 private CrawlingPhoneIdNumberCardNumber crawlingPhoneIdNumberCardNumber;

	 @Autowired
	 private LinkOrWordSaveUtils linkOrWordSaveUtils;


	 @Autowired
	 private ILinkAnchorListService iLinkAnchorListService;
	 /**
	 * 分页列表查询
	 *
	 * @param linkPersonalPhoneDetection
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	//@AutoLog(value = "个人信息手机号检测-分页列表查询")
	@ApiOperation(value="个人信息手机号检测-分页列表查询", notes="个人信息手机号检测-分页列表查询")
	@GetMapping(value = "/list")
	public Result<IPage<LinkPersonalPhoneDetection>> queryPageList(LinkPersonalPhoneDetection linkPersonalPhoneDetection,
								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								   HttpServletRequest req) {
		QueryWrapper<LinkPersonalPhoneDetection> queryWrapper = QueryGenerator.initQueryWrapper(linkPersonalPhoneDetection, req.getParameterMap());
		Page<LinkPersonalPhoneDetection> page = new Page<LinkPersonalPhoneDetection>(pageNo, pageSize);
		IPage<LinkPersonalPhoneDetection> pageList = linkPersonalPhoneDetectionService.page(page, queryWrapper);
		for (LinkPersonalPhoneDetection record : pageList.getRecords()) {
			List<String> aHrefHtmlList = new ArrayList<String>();
			String ahtmlList = record.getAhtmlList();
			String[] split = ahtmlList.split(",");
			for (String ahref : split) {
				aHrefHtmlList.add(ahref);
			}
			record.setAHrefHtmlList(aHrefHtmlList);
		}
		return Result.OK(pageList);
	}

	 @ApiOperation(value="个人信息手机号检测-分页列表查询", notes="个人信息手机号检测-分页列表查询")
	 @GetMapping(value = "/listVo")
	 public Result<IPage<LinkPersonalPhoneDetectionVo>> queryPageListVo(LinkPersonalPhoneDetectionVo linkPersonalPhoneDetectionVo,
																	  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
																	  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
																	  HttpServletRequest req) {
		 QueryWrapper<LinkPersonalPhoneDetectionVo> queryWrapper = QueryGenerator.initQueryWrapper(linkPersonalPhoneDetectionVo, req.getParameterMap());
		 Page<LinkPersonalPhoneDetectionVo> page = new Page<LinkPersonalPhoneDetectionVo>(pageNo, pageSize);
		 IPage<LinkPersonalPhoneDetectionVo> pageList = linkPersonalPhoneDetectionVoService.page(page, queryWrapper);
		 for (LinkPersonalPhoneDetectionVo record : pageList.getRecords()) {
			 List<String> aHrefHtmlList = new ArrayList<String>();
			 String ahtmlList = record.getAhtmlList();
			 String[] split = ahtmlList.split(",");
			 for (String ahref : split) {
				 aHrefHtmlList.add(ahref);
			 }
			 record.setAHrefHtmlList(aHrefHtmlList);
		 }
		 return Result.OK(pageList);
	 }
	 /*
	  * 错敏词扫描
	  */
	 @ApiOperation(value="页面抓取以及错敏词校验", notes="页面抓取以及错敏词校验-分页列表查询")
	 @GetMapping(value = "/listCrawling")
	 public Result<String> queryPageListCrawling(
			 ExternalInternalSite externalInternalSite
	 ) throws Exception {
		 //如果没有选择任何内容，对所有内容进行校验
		 List<MainSite> list = iMainSiteService.list();
		 for (MainSite mainSite : list) {
			 crawlingContentCapture(mainSite);
			 crawlingPhoneIdNumberCardNumber.saveLinkPersonalPhoneDetectionStatistics(mainSite.getId(),mainSite.getMainSiteName(),mainSite.getMainSiteUrl(),mainSite.getTenantId()+"","1");
		 }
		 return Result.OK("抓取成功");
	 }


	 public void  crawlingContentCapture(MainSite mainSite){
		 QueryWrapper<LinkAnchorList> listQueryWrapper = new QueryWrapper<LinkAnchorList>();
		 Page<LinkAnchorList> linkAnchorListPage = new Page<LinkAnchorList>(1, 1);
		 Page<LinkAnchorList> page1 = iLinkAnchorListService.page(linkAnchorListPage, listQueryWrapper);
		 List<LinkAnchorList> records = page1.getRecords();
		 LinkAnchorList linkAnchorList = null;
		 if(records.size() > 0){
			 linkAnchorList = records.get(0);
		 }
		 Integer count =  0;
		 if(!ObjectUtils.isEmpty(linkAnchorList)){
			 //查询链接不是锚链接的链接
			 count = externalInternalSiteService.countSourceNoAnchor(mainSite.getMainSiteUrl(),linkAnchorList.getAnchorLink());
		 }else{
			 count = externalInternalSiteService.countSource(mainSite.getMainSiteUrl());
		 }
		 Integer pageSize = 100;
		 Integer pageNum = (int)Math.ceil((double)count/pageSize);
		 for(int i = 1; i <= pageNum;i+=1){
			 Page<ExternalInternalSite> page = new Page<ExternalInternalSite>(i, pageSize);
			 List<ExternalInternalSite> recordsList = null;
			 if(!ObjectUtils.isEmpty(linkAnchorList)){
				 //查询链接不是锚链接的链接
				 IPage<ExternalInternalSite> pageList = externalInternalSiteService.pageSourceMainUrlNoAnchor(page,mainSite.getMainSiteUrl(),linkAnchorList.getAnchorLink());
				 recordsList = pageList.getRecords();
			 }else{
				 IPage<ExternalInternalSite> pageList = externalInternalSiteService.pageSourceMainUrl(page,mainSite.getMainSiteUrl());
				 recordsList = pageList.getRecords();
			 }
			 if(!ObjectUtils.isEmpty(recordsList)){
				 for (ExternalInternalSite record : recordsList) {
					 String LinkCaptureErrorLogId = IdWorker.getIdStr();
					 PageContentCapture pageContentCapture = new PageContentCapture();
					 pageContentCapture.setId(DigestUtils.md5DigestAsHex(record.getSource().getBytes()));
					 //查询当前id有没有对应的内容
					 try {
						 PageContentCapture byId = iPageContentCaptureService.getById(DigestUtils.md5DigestAsHex(record.getSource().getBytes()));
						 if(!ObjectUtils.isEmpty(byId)){
							 pageContentCapture = byId;
						 }
					 }catch (Exception e){
						 e.printStackTrace();
					 }
					 pageContentCapture.setCreateTime(new Date());
					 pageContentCapture.setUpdateTime(new Date());
					 pageContentCapture.setSource(record.getSource());
					 if(!ObjectUtils.isEmpty(record.getSource())){
						 //爬取页面
						 Document document = null;
						 String baseUri = null;
						 String grabPage = mainSite.getGrabPage();
						 try {
							 SpyderReturn spyderReturn = trendsSpyder.companyTrendsSpyderMessage(record.getSource(), grabPage);
							 document = spyderReturn.getDocument();
							 baseUri = spyderReturn.getBaseUri();
							 pageContentCapture.setIsInvalid("2");
						 }catch (Exception e){
							 pageContentCapture.setIsInvalid("1");
							 document = null;
						 }
						 if(!ObjectUtils.isEmpty(document)){
							 document= jsoupUtils.setUrl(document, baseUri);
							 String sHtml = document.toString();
							 sHtml = sHtml.replaceAll("amp;","");
							 pageContentCapture.setContent(sHtml);
							 //获取文章发布的标题
							 QueryWrapper<LinkPublishingTitle> linkPublishingTitleQueryWrapper =new QueryWrapper<LinkPublishingTitle>();
							 linkPublishingTitleQueryWrapper.eq("main_site_url",record.getMainUrl());
							 String title = null;
							 title = crawlingUtils.getPublishingTitle(record.getMainUrl(), document);
							 if(title != null && title != "" && title.length() != 0){
								 pageContentCapture.setTitle(title);
							 }else{
								 //抓取网页title的内容
								 Elements eles = document.getElementsByTag("title");
								 String string = eles.text();
								 pageContentCapture.setTitle(string);
							 }
							 QueryWrapper<LinkPublishingTimeGrasping> linkPublishingTimeGraspingQueryWrapper =new QueryWrapper<LinkPublishingTimeGrasping>();
							 linkPublishingTimeGraspingQueryWrapper.eq("main_site_url",record.getMainUrl());
							 //获取文章发布的时间
							 Date parse = crawlingUtils.getPublishingTimeGrasping(record.getMainUrl(), document);
							 if(!ObjectUtils.isEmpty(parse)){
								 pageContentCapture.setArticleReleaseTime(parse);
							 }
							 //父地址类型  typeSource
							 pageContentCapture.setTypeSource(record.getTypeSource());
							 pageContentCapture.setStateSource(record.getStateSource());
							 pageContentCapture.setMainUrl(record.getMainUrl());
							 //错敏词校验-----开始
							 JsResult jsonObject = fangCunUtils.getJsResult(pageContentCapture.getContent());
							 String ret_msg = jsonObject.getRet_msg();
							 pageContentCapture.setErrorCount(jsonObject.getErrorCount());
							 pageContentCapture.setRetMsg(jsonObject.getRet_msg());
							 pageContentCapture.setRetCode(jsonObject.getRet_code());
							 if(!ObjectUtils.isEmpty(ret_msg)){
								 //跳过白名单词汇
								 pageContentCapture =  crawlingUtils.JumpLinkWhiteWord(ret_msg,record.getMainUrl(),pageContentCapture);
								 //保存错词信息
								 //linkOrWordSaveUtils.saveLinkCaptureErrorMessage(LinkCaptureErrorLogId,pageContentCapture);
								 Document parse1 = Jsoup.parse(pageContentCapture.getRetMsg());
								 Elements elements1 = parse1.select("span.proofreadSignClass.errorWordMark");
								 pageContentCapture.setSensitiveList(elements1.toString());
								 pageContentCapture.setSensitiveCount(0);
								 pageContentCapture.setSensitiveCount(elements1.size());
								 if(elements1.size() > 0){
									 pageContentCapture.setCheckErrorCount(elements1.size());
									 pageContentCapture.setErrorCount(1);
									 pageContentCapture.setModifyState("1");
								 }
							 }
							 pageContentCapture.setRetCode(jsonObject.getRet_code());
							 pageContentCapture.setHeavyCount(jsonObject.getHeavyCount());
						 }
						 //错敏词校验-----结束
					 }
					 pageContentCapture.setIsIgnore("2");
					 String id = pageContentCapture.getId();
					 PageContentCapture byId = iPageContentCaptureService.getById(id);
					 if(!ObjectUtils.isEmpty(byId)){
						 Integer numberScans = byId.getNumberScans();
						 if(!ObjectUtils.isEmpty(numberScans)){
							 numberScans = numberScans + 1;
							 pageContentCapture.setNumberScans(numberScans);
							 pageContentCapture.setCreateTime(byId.getCreateTime());
						 }
						 pageContentCapture.setIsIgnore(byId.getIsIgnore());
					 }else{
						 pageContentCapture.setNumberScans(1);
					 }
					 pageContentCapture.setCheckState("2");
					 if(!ObjectUtils.isEmpty(pageContentCapture))
					 {
						 pageContentCapture.setTenantId(record.getTenantId());
						 //抓取对应的手机号，身份证号，银行卡号
						 crawlingPhoneIdNumberCardNumber.crawlingPhone(
								 mainSite.getId(),
								 mainSite.getMainSiteName(),
								 mainSite.getMainSiteUrl(),
								 pageContentCapture.getSource(),
								 pageContentCapture.getTitle(),
								 pageContentCapture.getArticleReleaseTime(),
								 pageContentCapture.getContent(),
								 pageContentCapture.getIsInvalid(),
								 String.valueOf(pageContentCapture.getTenantId())
						 );
					 }
				 }
			 }
		 }
	 }
	 /*
	  * 复核错链数据
	  * */
	 @RequestMapping(value = "/onHandleSpyderCheck")
	 public Result<String> onHandleSpyderCheck(HttpServletRequest request, LinkPersonalPhoneDetection linkPersonalPhoneDetection) {
		 String selections = request.getParameter("selections");
		 QueryWrapper<LinkPersonalPhoneDetection> queryWrapper = QueryGenerator.initQueryWrapper(linkPersonalPhoneDetection, request.getParameterMap());
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 queryWrapper.in("id",selectionList);
			 List<LinkPersonalPhoneDetection> exportList = linkPersonalPhoneDetectionService.list(queryWrapper);
			 checkPhone(exportList);
		 }else{
			 queryWrapper.eq("is_ignore","2");
			 //只统计错链
			 Long count =  linkPersonalPhoneDetectionService.count();
			 Integer pageSize = 100;
			 Integer pageNum = (int)Math.ceil((double)count/pageSize);
			 for(int i = 1; i <= pageNum;i+=1){
				 Page<LinkPersonalPhoneDetection> page = new Page<LinkPersonalPhoneDetection>(i, pageSize);
				 IPage<LinkPersonalPhoneDetection> pageList = linkPersonalPhoneDetectionService.page(page, queryWrapper);
				 checkPhone(pageList.getRecords());
			 }
		 }
		 try {
			 // 统计数据
			 List<MainSite> list = iMainSiteService.list();
			 for (MainSite mainSite : list) {
				 crawlingPhoneIdNumberCardNumber.saveLinkPersonalPhoneDetectionStatistics(mainSite.getId(),mainSite.getMainSiteName(),mainSite.getMainSiteUrl(),mainSite.getTenantId()+"","1");
			 }
		 }catch (Exception e){
			 e.printStackTrace();
		 }
		 return Result.OK("成功");
	 }

	 private void checkPhone(List<LinkPersonalPhoneDetection> linkPersonalPhoneDetections) {
		 for (LinkPersonalPhoneDetection linkPersonalPhoneDetection : linkPersonalPhoneDetections) {
			 crawlingPhoneIdNumberCardNumber.crawlingCheck(
					 linkPersonalPhoneDetection
			 );
		 }
	 }

	 /**
	 *   添加
	 *
	 * @param linkPersonalPhoneDetection
	 * @return
	 */
	@AutoLog(value = "个人信息手机号检测-添加")
	@ApiOperation(value="个人信息手机号检测-添加", notes="个人信息手机号检测-添加")
	@RequiresPermissions("linkpersonalphonedetection:link_personal_phone_detection:add")
	@PostMapping(value = "/add")
	public Result<String> add(@RequestBody LinkPersonalPhoneDetection linkPersonalPhoneDetection) {
		linkPersonalPhoneDetectionService.save(linkPersonalPhoneDetection);
		return Result.OK("添加成功！");
	}
	
	/**
	 *  编辑
	 *
	 * @param linkPersonalPhoneDetection
	 * @return
	 */
	@AutoLog(value = "个人信息手机号检测-编辑")
	@ApiOperation(value="个人信息手机号检测-编辑", notes="个人信息手机号检测-编辑")
	@RequiresPermissions("linkpersonalphonedetection:link_personal_phone_detection:edit")
	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> edit(@RequestBody LinkPersonalPhoneDetection linkPersonalPhoneDetection) {
		linkPersonalPhoneDetectionService.updateById(linkPersonalPhoneDetection);
		return Result.OK("编辑成功!");
	}
	
	/**
	 *   通过id删除
	 *
	 * @param id
	 * @return
	 */
	@AutoLog(value = "个人信息手机号检测-通过id删除")
	@ApiOperation(value="个人信息手机号检测-通过id删除", notes="个人信息手机号检测-通过id删除")
	@RequiresPermissions("linkpersonalphonedetection:link_personal_phone_detection:delete")
	@DeleteMapping(value = "/delete")
	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
		linkPersonalPhoneDetectionService.removeById(id);
		return Result.OK("删除成功!");
	}
	
	/**
	 *  批量删除
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "个人信息手机号检测-批量删除")
	@ApiOperation(value="个人信息手机号检测-批量删除", notes="个人信息手机号检测-批量删除")
	@RequiresPermissions("linkpersonalphonedetection:link_personal_phone_detection:deleteBatch")
	@DeleteMapping(value = "/deleteBatch")
	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
		this.linkPersonalPhoneDetectionService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}
	
	/**
	 * 通过id查询
	 * @param id
	 * @return
	 */
	@ApiOperation(value="个人信息手机号检测-通过id查询", notes="个人信息手机号检测-通过id查询")
	@GetMapping(value = "/queryById")
	public Result<LinkPersonalPhoneDetection> queryById(@RequestParam(name="id",required=true) String id) {
		LinkPersonalPhoneDetection linkPersonalPhoneDetection = linkPersonalPhoneDetectionService.getById(id);
		if(linkPersonalPhoneDetection==null) {
			return Result.error("未找到对应数据");
		}
		return Result.OK(linkPersonalPhoneDetection);
	}

	 @ApiOperation(value="个人信息手机号检测-通过id查询", notes="个人信息手机号检测-通过id查询")
	 @GetMapping(value = "/queryByIdModifyTrue")
	 public Result<LinkPersonalPhoneDetection> queryByIdModifyTrue(@RequestParam(name="id",required=true) String id) {
		 LinkPersonalPhoneDetection linkPersonalPhoneDetection = linkPersonalPhoneDetectionService.getById(id);
		 linkPersonalPhoneDetection.setIsRevise("2");
		 if(linkPersonalPhoneDetection==null) {
			 return Result.error("未找到对应数据");
		 }
		 linkPersonalPhoneDetectionService.updateById(linkPersonalPhoneDetection);
		 return Result.OK(linkPersonalPhoneDetection);
	 }

	 @ApiOperation(value="个人信息手机号检测-通过id查询", notes="个人信息手机号检测-通过id查询")
	 @GetMapping(value = "/queryByIdModifyFalse")
	 public Result<LinkPersonalPhoneDetection> queryByIdModifyFalse(@RequestParam(name="id",required=true) String id) {
		 LinkPersonalPhoneDetection linkPersonalPhoneDetection = linkPersonalPhoneDetectionService.getById(id);
		 linkPersonalPhoneDetection.setIsRevise("1");
		 if(linkPersonalPhoneDetection==null) {
			 return Result.error("未找到对应数据");
		 }
		 linkPersonalPhoneDetectionService.updateById(linkPersonalPhoneDetection);
		 return Result.OK(linkPersonalPhoneDetection);
	 }

    /**
    * 导出excel
    *
    * @param request
    * @param linkPersonalPhoneDetection
    */
    @RequiresPermissions("linkpersonalphonedetection:link_personal_phone_detection:exportXls")
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, LinkPersonalPhoneDetection linkPersonalPhoneDetection) {
        return super.exportXls(request, linkPersonalPhoneDetection, LinkPersonalPhoneDetection.class, "个人信息手机号检测");
    }
	 @Data
	 class PageContentCaptureTrueOrFalse{
		 private String wordName;
		 private String wordValue;
		 private boolean flag;
	 }

	 @GetMapping(value = "/queryByIdErrorList")
	 public Result<List<PageContentCaptureTrueOrFalse>> queryByIdErrorList(@RequestParam(name="id",required=true) String id) {
		 List<PageContentCaptureTrueOrFalse> list = new ArrayList<PageContentCaptureTrueOrFalse>();
		 LinkPersonalPhoneDetection linkPersonalPhoneDetection = linkPersonalPhoneDetectionService.getById(id);
		 if(linkPersonalPhoneDetection==null) {
			 return Result.error("未找到对应数据");
		 }
		 String phoneDetectionStrList = linkPersonalPhoneDetection.getStrList();
		 String[] split = phoneDetectionStrList.split(",");
		 for (String strPhone : split) {
			 PageContentCaptureTrueOrFalse captureTrueOrFalse = new PageContentCaptureTrueOrFalse();
			 captureTrueOrFalse.setWordName(strPhone);
			 captureTrueOrFalse.setWordValue(strPhone);
			 captureTrueOrFalse.setFlag(false);
			 QueryWrapper<LinkPersonalPhoneWhiteList> queryWrapper = new QueryWrapper<LinkPersonalPhoneWhiteList>();
			 queryWrapper.eq("white_content",strPhone);
			 Page<LinkPersonalPhoneWhiteList> page = new Page<LinkPersonalPhoneWhiteList>(1, 1);
			 IPage<LinkPersonalPhoneWhiteList> pageList = linkPersonalPhoneWhiteListService.page(page, queryWrapper);
			 List<LinkPersonalPhoneWhiteList> records = pageList.getRecords();
			 if(records.size() > 0){
				 captureTrueOrFalse.setFlag(true);
			 }else{
				 captureTrueOrFalse.setFlag(false);
			 }
			 list.add(captureTrueOrFalse);
		 }
		 return Result.OK(list);
	 }

	 @RequestMapping(value = "/ignore", method = {RequestMethod.PUT,RequestMethod.POST})
	 public Result<String> ignore(@RequestBody Params params) {
		 Page<MainSite> pageMainSite = new Page<MainSite>(1, 1);
		 IPage<MainSite> pageListMainSite = iMainSiteService.page(pageMainSite);
		 MainSite mainSite = null;
		 if(pageListMainSite.getRecords().size() >= 1){
			 mainSite = pageListMainSite.getRecords().get(0);
		 }
		 if(!ObjectUtils.isEmpty(mainSite) && params.getPlainOptions().length > 0){
			 for (String plainOption : params.getPlainOptions()) {
				 QueryWrapper<LinkPersonalPhoneWhiteList> phoneWhiteListQueryWrapper = new QueryWrapper<LinkPersonalPhoneWhiteList>();
				 phoneWhiteListQueryWrapper.eq("white_content",plainOption);
				 try {
					 linkPersonalPhoneWhiteListService.remove(phoneWhiteListQueryWrapper);
				 }catch (Exception e){
					 e.printStackTrace();
				 }
			 }
		 }
		 if(!ObjectUtils.isEmpty(mainSite) && params.getCheckedList().length > 0){
			 for (String plainOption : params.getCheckedList()) {
				 LinkPersonalPhoneWhiteList phoneWhiteList = new LinkPersonalPhoneWhiteList();
				 phoneWhiteList.setId(IdWorker.getIdStr());
				 phoneWhiteList.setMainSiteId(mainSite.getId());
				 phoneWhiteList.setMainSiteName(mainSite.getMainSiteName());
				 phoneWhiteList.setMainSiteUrl(mainSite.getMainSiteUrl());
				 phoneWhiteList.setTenantId(mainSite.getTenantId()+"");
				 phoneWhiteList.setWhiteContent(plainOption);
				 if(!ObjectUtils.isEmpty(plainOption) && plainOption != ""){
					 try {
						 linkPersonalPhoneWhiteListService.save(phoneWhiteList);
					 }catch (Exception e){
						 e.printStackTrace();
					 }
				 }
			 }
		 }
		 return Result.OK("编辑成功!");
	 }

	 @DeleteMapping(value = "/batchHAddWhiteLink")
	 public Result<String> ignoreAllBatch(@RequestParam(name="ids",required=true) String ids) {
		 Page<MainSite> pageMainSite = new Page<MainSite>(1, 1);
		 IPage<MainSite> pageListMainSite = iMainSiteService.page(pageMainSite);
		 MainSite mainSite = null;
		 if(pageListMainSite.getRecords().size() >= 1){
			 mainSite = pageListMainSite.getRecords().get(0);
		 }
		 String[] split = ids.split(",");
		 if(split.length > 0){
			 for (String id : split) {
				 LinkPersonalPhoneDetection linkPersonalPhoneDetection = linkPersonalPhoneDetectionService.getById(id);
				 String phoneDetectionStrList = linkPersonalPhoneDetection.getStrList();
				 String[] split1 = phoneDetectionStrList.split(",");
				 for (String phone : split1) {
					 QueryWrapper<LinkPersonalPhoneWhiteList> phoneWhiteListQueryWrapper = new QueryWrapper<LinkPersonalPhoneWhiteList>();
					 phoneWhiteListQueryWrapper.eq("white_content",phone);
					 try {
						 linkPersonalPhoneWhiteListService.remove(phoneWhiteListQueryWrapper);
					 }catch (Exception e){
						 e.printStackTrace();
					 }
					 LinkPersonalPhoneWhiteList phoneWhiteList = new LinkPersonalPhoneWhiteList();
					 phoneWhiteList.setId(IdWorker.getIdStr());
					 phoneWhiteList.setMainSiteId(mainSite.getId());
					 phoneWhiteList.setMainSiteName(mainSite.getMainSiteName());
					 phoneWhiteList.setMainSiteUrl(mainSite.getMainSiteUrl());
					 phoneWhiteList.setTenantId(mainSite.getTenantId()+"");
					 phoneWhiteList.setWhiteContent(phone);
					 if(!ObjectUtils.isEmpty(phone) && phone != ""){
						 try {
							 linkPersonalPhoneWhiteListService.save(phoneWhiteList);
						 }catch (Exception e){
							 e.printStackTrace();
						 }
					 }
				 }
			 }
		 }else{
			 Result.error("没有选择任何内容!");
		 }
		 return Result.OK("编辑成功!");
	 }

	 @DeleteMapping(value = "/batchHRemoveWhiteLink")
	 public Result<String> ignoreAllBatchCancell(@RequestParam(name="ids",required=true) String ids) {
		 Page<MainSite> pageMainSite = new Page<MainSite>(1, 1);
		 IPage<MainSite> pageListMainSite = iMainSiteService.page(pageMainSite);
		 MainSite mainSite = null;
		 if(pageListMainSite.getRecords().size() >= 1){
			 mainSite = pageListMainSite.getRecords().get(0);
		 }
		 String[] split = ids.split(",");
		 if(split.length > 0){
			 for (String id : split) {
				 LinkPersonalPhoneDetection linkPersonalPhoneDetection = linkPersonalPhoneDetectionService.getById(id);
				 String phoneDetectionStrList = linkPersonalPhoneDetection.getStrList();
				 String[] split1 = phoneDetectionStrList.split(",");
				 for (String phone : split1) {
					 QueryWrapper<LinkPersonalPhoneWhiteList> phoneWhiteListQueryWrapper = new QueryWrapper<LinkPersonalPhoneWhiteList>();
					 phoneWhiteListQueryWrapper.eq("white_content",phone);
					 try {
						 linkPersonalPhoneWhiteListService.remove(phoneWhiteListQueryWrapper);
					 }catch (Exception e){
						 e.printStackTrace();
					 }
				 }
			 }
		 }else{
			 Result.error("没有选择任何内容!");
		 }
		 return Result.OK("编辑成功!");
	 }


	 @ApiOperation(value="个人信息手机号检测-通过id查询", notes="个人信息手机号检测-通过id查询")
	 @GetMapping(value = "/queryByIdIgnoreTrue")
	 public Result<LinkPersonalPhoneDetection> queryByIdIgnoreTrue(@RequestParam(name="id",required=true) String id) {
		 LinkPersonalPhoneDetection linkPersonalPhoneDetection = linkPersonalPhoneDetectionService.getById(id);
		 linkPersonalPhoneDetection.setIsIgnore("1");
		 if(linkPersonalPhoneDetection==null) {
			 return Result.error("未找到对应数据");
		 }
		 linkPersonalPhoneDetectionService.updateById(linkPersonalPhoneDetection);
		 return Result.OK(linkPersonalPhoneDetection);
	 }

	 @ApiOperation(value="个人信息手机号检测-通过id查询", notes="个人信息手机号检测-通过id查询")
	 @GetMapping(value = "/queryByIdIgnoreFalse")
	 public Result<LinkPersonalPhoneDetection> queryByIdIgnoreFalse(@RequestParam(name="id",required=true) String id) {
		 LinkPersonalPhoneDetection linkPersonalPhoneDetection = linkPersonalPhoneDetectionService.getById(id);
		 linkPersonalPhoneDetection.setIsIgnore("2");
		 if(linkPersonalPhoneDetection==null) {
			 return Result.error("未找到对应数据");
		 }
		 linkPersonalPhoneDetectionService.updateById(linkPersonalPhoneDetection);
		 return Result.OK(linkPersonalPhoneDetection);
	 }


	 @DeleteMapping(value = "/batchHModifyTrue")
	 public Result<String> batchHModifyTrue(@RequestParam(name="ids",required=true) String ids) {
		 Page<MainSite> pageMainSite = new Page<MainSite>(1, 1);
		 IPage<MainSite> pageListMainSite = iMainSiteService.page(pageMainSite);
		 MainSite mainSite = null;
		 if(pageListMainSite.getRecords().size() >= 1){
			 mainSite = pageListMainSite.getRecords().get(0);
		 }
		 String[] split = ids.split(",");
		 if(split.length > 0){
			 for (String id : split) {
				 try {
					 LinkPersonalPhoneDetection byId = linkPersonalPhoneDetectionService.getById(id);
					 byId.setIsRevise("2");
					 linkPersonalPhoneDetectionService.updateById(byId);
				 }catch (Exception e){
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.OK("编辑成功!");
	 }

	 @DeleteMapping(value = "/batchHModifyFalse")
	 public Result<String> batchHModifyFalse(@RequestParam(name="ids",required=true) String ids) {
		 Page<MainSite> pageMainSite = new Page<MainSite>(1, 1);
		 IPage<MainSite> pageListMainSite = iMainSiteService.page(pageMainSite);
		 MainSite mainSite = null;
		 if(pageListMainSite.getRecords().size() >= 1){
			 mainSite = pageListMainSite.getRecords().get(0);
		 }
		 String[] split = ids.split(",");
		 if(split.length > 0){
			 for (String id : split) {
				 try {
					 LinkPersonalPhoneDetection byId = linkPersonalPhoneDetectionService.getById(id);
					 byId.setIsRevise("1");
					 linkPersonalPhoneDetectionService.updateById(byId);
				 }catch (Exception e){
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.OK("编辑成功!");
	 }

	 @DeleteMapping(value = "/batchHIgnoreHandle")
	 public Result<String> batchHIgnoreHandle(@RequestParam(name="ids",required=true) String ids) {
		 Page<MainSite> pageMainSite = new Page<MainSite>(1, 1);
		 IPage<MainSite> pageListMainSite = iMainSiteService.page(pageMainSite);
		 MainSite mainSite = null;
		 if(pageListMainSite.getRecords().size() >= 1){
			 mainSite = pageListMainSite.getRecords().get(0);
		 }
		 String[] split = ids.split(",");
		 if(split.length > 0){
			 for (String id : split) {
				 try {
					 LinkPersonalPhoneDetection byId = linkPersonalPhoneDetectionService.getById(id);
					 byId.setIsIgnore("1");
					 linkPersonalPhoneDetectionService.updateById(byId);
				 }catch (Exception e){
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.OK("编辑成功!");
	 }

	 @DeleteMapping(value = "/batchHIgnoreHandleDelete")
	 public Result<String> batchHIgnoreHandleDelete(@RequestParam(name="ids",required=true) String ids) {
		 Page<MainSite> pageMainSite = new Page<MainSite>(1, 1);
		 IPage<MainSite> pageListMainSite = iMainSiteService.page(pageMainSite);
		 MainSite mainSite = null;
		 if(pageListMainSite.getRecords().size() >= 1){
			 mainSite = pageListMainSite.getRecords().get(0);
		 }
		 String[] split = ids.split(",");
		 if(split.length > 0){
			 for (String id : split) {
				 try {
					 LinkPersonalPhoneDetection byId = linkPersonalPhoneDetectionService.getById(id);
					 byId.setIsIgnore("2");
					 linkPersonalPhoneDetectionService.updateById(byId);
				 }catch (Exception e){
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.OK("编辑成功!");
	 }
 }
