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

import java.util.*;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

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.linkpersonalbankcarddetection.controller.LinkPersonalBankCardDetectionController;
import org.jeecg.modules.demo.linkpersonalbankcarddetection.entity.LinkPersonalBankCardDetection;
import org.jeecg.modules.demo.linkpersonalbankcardwhitelist.entity.LinkPersonalBankCardWhiteList;
import org.jeecg.modules.demo.linkwechatbankcarddetection.entity.LinkWechatBankCardDetection;
import org.jeecg.modules.demo.linkwechatbankcarddetection.service.ILinkWechatBankCardDetectionService;
import org.jeecg.modules.demo.linkwechatbankcarddetectionlog.entity.LinkWechatBankCardDetectionLog;
import org.jeecg.modules.demo.linkwechatbankcarddetectionlog.service.ILinkWechatBankCardDetectionLogService;
import org.jeecg.modules.demo.linkwechatbankcarddetectionstatistics.entity.LinkWechatBankCardDetectionStatistics;
import org.jeecg.modules.demo.linkwechatbankcarddetectionstatistics.service.ILinkWechatBankCardDetectionStatisticsService;
import org.jeecg.modules.demo.linkwechaterrorwordwhitelist.entity.LinkWechatErrorWordWhiteList;
import org.jeecg.modules.demo.linkwechaterrorwordwhitelist.service.ILinkWechatErrorWordWhiteListService;
import org.jeecg.modules.demo.linkwechatidnumberdetection.entity.LinkWechatIdNumberDetection;
import org.jeecg.modules.demo.linkwechatidnumberdetection.service.ILinkWechatIdNumberDetectionService;
import org.jeecg.modules.demo.linkwechatidnumberdetectionlog.entity.LinkWechatIdNumberDetectionLog;
import org.jeecg.modules.demo.linkwechatidnumberdetectionlog.service.ILinkWechatIdNumberDetectionLogService;
import org.jeecg.modules.demo.linkwechatpersonaliddetectionstatistics.entity.LinkWechatPersonalIdDetectionStatistics;
import org.jeecg.modules.demo.linkwechatpersonaliddetectionstatistics.service.ILinkWechatPersonalIdDetectionStatisticsService;
import org.jeecg.modules.demo.linkwechatphonedetection.entity.LinkWechatPhoneDetection;
import org.jeecg.modules.demo.linkwechatphonedetection.service.ILinkWechatPhoneDetectionService;
import org.jeecg.modules.demo.linkwechatphonedetectionlog.entity.LinkWechatPhoneDetectionLog;
import org.jeecg.modules.demo.linkwechatphonedetectionlog.service.ILinkWechatPhoneDetectionLogService;
import org.jeecg.modules.demo.linkwechatphonedetectionstatistics.entity.LinkWechatPhoneDetectionStatistics;
import org.jeecg.modules.demo.linkwechatphonedetectionstatistics.service.ILinkWechatPhoneDetectionStatisticsService;
import org.jeecg.modules.demo.linkweibobankcarddetection.entity.LinkWeiboBankCardDetection;
import org.jeecg.modules.demo.linkweibobankcarddetection.service.ILinkWeiboBankCardDetectionService;
import org.jeecg.modules.demo.linkweibobankcarddetectionlog.entity.LinkWeiboBankCardDetectionLog;
import org.jeecg.modules.demo.linkweibobankcarddetectionstatistics.entity.LinkWeiboBankCardDetectionStatistics;
import org.jeecg.modules.demo.linkweiboerrorwordwhitelist.entity.LinkWeiboErrorWordWhiteList;
import org.jeecg.modules.demo.linkweiboidnumberdetection.entity.LinkWeiboIdNumberDetection;
import org.jeecg.modules.demo.linkweibopersonaliddetectionstatistics.entity.LinkWeiboPersonalIdDetectionStatistics;
import org.jeecg.modules.demo.linkweibophonedetection.entity.LinkWeiboPhoneDetection;
import org.jeecg.modules.demo.linkweibophonedetectionstatistics.entity.LinkWeiboPhoneDetectionStatistics;
import org.jeecg.modules.demo.linkwhiteword.entity.LinkWhiteWord;
import org.jeecg.modules.demo.mainsite.entity.MainSite;
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.wechaterrorwordstatistics.entity.WechatErrorWordStatistics;
import org.jeecg.modules.demo.wechaterrorwordstatistics.service.IWechatErrorWordStatisticsService;
import org.jeecg.modules.demo.wechatposts.entity.WechatPosts;
import org.jeecg.modules.demo.wechatposts.service.IWechatPostsService;
import org.jeecg.modules.demo.wechatpostsword.entity.WechatPostsWord;
import org.jeecg.modules.demo.wechatpostsword.service.IWechatPostsWordService;

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.wechatpostswordlog.entity.WechatPostsWordLog;
import org.jeecg.modules.demo.wechatpostswordlog.service.IWechatPostsWordLogService;
import org.jeecg.modules.demo.wechatprofiles.entity.WechatProfiles;
import org.jeecg.modules.demo.wechatprofiles.service.IWechatProfilesService;
import org.jeecg.modules.demo.weibo.entity.Weibo;
import org.jeecg.modules.demo.weibocontentcapture.controller.WeiboContentCaptureController;
import org.jeecg.modules.demo.weibocontentcapture.entity.WeiboContentCapture;
import org.jeecg.modules.demo.weibocontentcapturelog.entity.WeiboContentCaptureLog;
import org.jeecg.modules.demo.weiboerrorwordstatistics.service.IWeiboErrorWordStatisticsService;
import org.jeecg.modules.demo.weibouser.entity.WeiboUser;
import org.jeecg.modules.spyderUtils.SpyderUtils;
import org.jeecg.modules.spyderUtils.spider.FangCunUtils;
import org.jeecg.modules.spyderUtils.spider.JsoupReturn;
import org.jeecg.modules.spyderUtils.spider.JsoupUtilsService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
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.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
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-22
 * @Version: V1.0
 */
@Api(tags="微信公众号文章错敏词")
@RestController
@RequestMapping("/wechatpostsword/wechatPostsWord")
@Slf4j
public class WechatPostsWordController extends JeecgController<WechatPostsWord, IWechatPostsWordService> {
	@Autowired
	private IWechatPostsWordService wechatPostsWordService;

	@Autowired
	private IWechatPostsService iWechatPostsService;

	@Autowired
	private SpyderUtils spyderUtils;

	@Autowired
	private JsoupUtilsService jsoupUtilsService;

	@Autowired
	private FangCunUtils fangCunUtils;

	@Autowired
	private IWechatErrorWordStatisticsService iWechatErrorWordStatisticsService;

	@Autowired
	private IWechatPostsWordLogService iWechatPostsWordLogService;

	@Autowired
	private IWechatProfilesService iWechatProfilesService;

	@Autowired
	private IWechatPostsWordService iWechatPostsWordService;

	@Autowired
	private ILinkWechatIdNumberDetectionService iLinkWechatIdNumberDetectionService;


	@Autowired
	private ILinkWechatPhoneDetectionService iLinkWechatPhoneDetectionService;

	@Autowired
	private ILinkWechatBankCardDetectionService iLinkWechatBankCardDetectionService;

	@Autowired
	private ILinkWeiboBankCardDetectionService iLinkWeiboBankCardDetectionService;

	@Autowired
	private ILinkWechatPersonalIdDetectionStatisticsService idDetectionStatisticsService;


	@Autowired
	private ILinkWechatPhoneDetectionStatisticsService iLinkWechatPhoneDetectionStatisticsService;

	@Autowired
	private ILinkWechatBankCardDetectionStatisticsService iLinkWechatBankCardDetectionStatisticsService;

	@Autowired
	private ILinkWechatIdNumberDetectionLogService iLinkWechatIdNumberDetectionLogService;

	@Autowired
	private ILinkWechatPhoneDetectionLogService iLinkWechatPhoneDetectionLogService;

	@Autowired
	private ILinkWechatBankCardDetectionLogService iLinkWechatBankCardDetectionLogService;


	@Autowired
	private ILinkWechatErrorWordWhiteListService iLinkWechatErrorWordWhiteListService;

	/**
	 * 分页列表查询
	 *
	 * @param wechatPostsWord
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	//@AutoLog(value = "微信公众号文章错敏词-分页列表查询")
	@ApiOperation(value="微信公众号文章错敏词-分页列表查询", notes="微信公众号文章错敏词-分页列表查询")
	@GetMapping(value = "/list")
	public Result<IPage<WechatPostsWord>> queryPageList(WechatPostsWord wechatPostsWord,
								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								   HttpServletRequest req) {
		QueryWrapper<WechatPostsWord> queryWrapper = QueryGenerator.initQueryWrapper(wechatPostsWord, req.getParameterMap());
		Page<WechatPostsWord> page = new Page<WechatPostsWord>(pageNo, pageSize);
		IPage<WechatPostsWord> pageList = wechatPostsWordService.page(page, queryWrapper);
		return Result.OK(pageList);
	}

	 @ApiOperation(value="微信公众号文章错敏词-分页列表查询", notes="微信公众号文章错敏词-分页列表查询")
	 @GetMapping(value = "/listError")
	 public Result<IPage<WechatPostsWord>> queryPageListError(WechatPostsWord wechatPostsWord,
														 @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
														 @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
														 HttpServletRequest req) {


		 QueryWrapper<WechatPostsWord> queryWrapper = QueryGenerator.initQueryWrapper(wechatPostsWord, req.getParameterMap());
		 Page<WechatPostsWord> page = new Page<WechatPostsWord>(pageNo, pageSize);
		 IPage<WechatPostsWord> pageList = wechatPostsWordService.page(page, queryWrapper);

		 for (WechatPostsWord record : pageList.getRecords()) {
			 Document parse1 = Jsoup.parse(record.getSensitiveList());
			 Elements elements1 = parse1.select("span.proofreadSignClass.errorWordMark");
			 String sensitiveErrorList = "";
			 String errorMessage = "";
			 for(Element element : elements1){
				 String title = element.attr("title")+"<br>";
				 errorMessage += Jsoup.parse(title).text() +"<br>";
				 String stringError = element.toString();
				 int i = record.getRetMsg().indexOf(stringError);
				 String t1 = "";
				 String t2 = "";
				 try {
					 t1 = record.getRetMsg().substring(i-20,i);
					 t2 = record.getRetMsg().substring(i+(stringError.length()),i+(stringError.length())+20);
				 }catch (Exception e){
					 e.printStackTrace();
				 }
				 sensitiveErrorList += t1 + stringError +t2+"<br>";
			 }
			 record.setErrorMessage(errorMessage);
			 record.setSensitiveErrorList(sensitiveErrorList);
			 //查询对应微信公众号名称
			 String msgBiz = record.getMsgBiz();
			 WechatProfiles wechatProfiles = null;
			 try {
				 QueryWrapper<WechatProfiles> wechatProfilesQueryWrapper = new QueryWrapper<WechatProfiles>();
				 wechatProfilesQueryWrapper.eq("msg_biz",msgBiz);
				 Page<WechatProfiles> pageWechatPosts = new Page<WechatProfiles>(1, 1);
				 IPage<WechatProfiles> wechatPostsIPage = iWechatProfilesService.page(pageWechatPosts, wechatProfilesQueryWrapper);
				 if(wechatPostsIPage.getRecords().size() >= 1){
					 wechatProfiles = wechatPostsIPage.getRecords().get(0);
				 }
			 }catch (Exception e){
				e.printStackTrace();
			 }
			 if(!ObjectUtils.isEmpty(wechatProfiles)){
				 record.setWechatPostsName(wechatProfiles.getTitle());
			 }
		 }
		 return Result.OK(pageList);
	 }
	/**
	 *   添加
	 *
	 * @param wechatPostsWord
	 * @return
	 */
	@AutoLog(value = "微信公众号文章错敏词-添加")
	@ApiOperation(value="微信公众号文章错敏词-添加", notes="微信公众号文章错敏词-添加")
	@RequiresPermissions("wechatpostsword:wechat_posts_word:add")
	@PostMapping(value = "/add")
	public Result<String> add(@RequestBody WechatPostsWord wechatPostsWord) {
		wechatPostsWordService.save(wechatPostsWord);
		return Result.OK("添加成功！");
	}
	
	/**
	 *  编辑
	 *
	 * @param wechatPostsWord
	 * @return
	 */
	@AutoLog(value = "微信公众号文章错敏词-编辑")
	@ApiOperation(value="微信公众号文章错敏词-编辑", notes="微信公众号文章错敏词-编辑")
	@RequiresPermissions("wechatpostsword:wechat_posts_word:edit")
	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> edit(@RequestBody WechatPostsWord wechatPostsWord) {
		wechatPostsWordService.updateById(wechatPostsWord);
		return Result.OK("编辑成功!");
	}
	
	/**
	 *   通过id删除
	 *
	 * @param id
	 * @return
	 */
	@AutoLog(value = "微信公众号文章错敏词-通过id删除")
	@ApiOperation(value="微信公众号文章错敏词-通过id删除", notes="微信公众号文章错敏词-通过id删除")
	@RequiresPermissions("wechatpostsword:wechat_posts_word:delete")
	@DeleteMapping(value = "/delete")
	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
		wechatPostsWordService.removeById(id);
		return Result.OK("删除成功!");
	}
	
	/**
	 *  批量删除
	 *
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "微信公众号文章错敏词-批量删除")
	@ApiOperation(value="微信公众号文章错敏词-批量删除", notes="微信公众号文章错敏词-批量删除")
	@RequiresPermissions("wechatpostsword:wechat_posts_word:deleteBatch")
	@DeleteMapping(value = "/deleteBatch")
	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
		this.wechatPostsWordService.removeByIds(Arrays.asList(ids.split(",")));
		return Result.OK("批量删除成功!");
	}
	
	/**
	 * 通过id查询
	 *
	 * @param id
	 * @return
	 */
	//@AutoLog(value = "微信公众号文章错敏词-通过id查询")
	@ApiOperation(value="微信公众号文章错敏词-通过id查询", notes="微信公众号文章错敏词-通过id查询")
	@GetMapping(value = "/queryById")
	public Result<WechatPostsWord> queryById(@RequestParam(name="id",required=true) String id) {
		WechatPostsWord wechatPostsWord = wechatPostsWordService.getById(id);
		if(wechatPostsWord==null) {
			return Result.error("未找到对应数据");
		}
		return Result.OK(wechatPostsWord);
	}

    /**
    * 导出excel
    *
    * @param request
    * @param wechatPostsWord
    */
    @RequiresPermissions("wechatpostsword:wechat_posts_word:exportXls")
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, WechatPostsWord wechatPostsWord) {
        return super.exportXls(request, wechatPostsWord, WechatPostsWord.class, "微信公众号文章错敏词");
    }

     /**
     * 通过excel导入数据
     *
     * @param request
     * @param response
     * @return
     */
     @RequiresPermissions("wechatpostsword:wechat_posts_word:importExcel")
     @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
     public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
        return super.importExcel(request, response, WechatPostsWord.class);
    }

	 @ApiOperation(value="页面内容抓取-通过id查询", notes="页面内容抓取-通过id查询")
	 @GetMapping(value = "/queryByIdModifyTrue")
	 public Result<WechatPostsWord> queryByIdModifyTrue(@RequestParam(name="id",required=true) String id) {
		 WechatPostsWord wechatPostsWord = wechatPostsWordService.getById(id);
		 if(wechatPostsWord==null) {
			 return Result.error("未找到对应数据");
		 }
		 wechatPostsWord.setModifyState("2");
		 wechatPostsWordService.updateById(wechatPostsWord);
		 return Result.OK(wechatPostsWord);
	 }

	 @ApiOperation(value="页面内容抓取-通过id查询", notes="页面内容抓取-通过id查询")
	 @GetMapping(value = "/queryByIdModifyFalse")
	 public Result<WechatPostsWord> queryByIdModifyFalse(@RequestParam(name="id",required=true) String id) {
		 WechatPostsWord wechatPostsWord = wechatPostsWordService.getById(id);
		 if(wechatPostsWord==null) {
			 return Result.error("未找到对应数据");
		 }
		 wechatPostsWord.setModifyState("1");
		 wechatPostsWordService.updateById(wechatPostsWord);
		 return Result.OK(wechatPostsWord);
	 }

	 @ApiOperation(value="页面内容抓取-通过id查询", notes="页面内容抓取-通过id查询")
	 @GetMapping(value = "/queryWhetherToIgnore")
	 public Result<WechatPostsWord> queryWhetherToIgnore(@RequestParam(name="id",required=true) String id) {
		 WechatPostsWord WechatPostsWord = wechatPostsWordService.getById(id);
		 if(WechatPostsWord==null) {
			 return Result.error("未找到对应数据");
		 }
		 WechatPostsWord.setIsIgnore("1");
		 wechatPostsWordService.updateById(WechatPostsWord);
		 return Result.OK(WechatPostsWord);
	 }

	 @ApiOperation(value="页面内容抓取-通过id查询", notes="页面内容抓取-通过id查询")
	 @GetMapping(value = "/queryWhetherToIgnoreCancel")
	 public Result<WechatPostsWord> queryWhetherToIgnoreCancel(@RequestParam(name="id",required=true) String id) {
		 WechatPostsWord WechatPostsWord = wechatPostsWordService.getById(id);
		 if(WechatPostsWord==null) {
			 return Result.error("未找到对应数据");
		 }
		 WechatPostsWord.setIsIgnore("2");
		 wechatPostsWordService.updateById(WechatPostsWord);
		 return Result.OK(WechatPostsWord);
	 }

	 @DeleteMapping(value = "/ModifyTrueBatchDelete")
	 public Result<String> ModifyTrueBatchDelete(@RequestParam(name="ids",required=true) String ids) {

		 String[] split = ids.split(",");
		 if(split.length > 0){
			 for (String id : split) {
				 try {
					 WechatPostsWord byId = wechatPostsWordService.getById(id);
					 byId.setModifyState("2");
					 wechatPostsWordService.updateById(byId);
				 }catch (Exception e){
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.OK("编辑成功!");
	 }

	 @DeleteMapping(value = "/ModifyFalseBatchDelete")
	 public Result<String> ModifyFalseBatchDelete(@RequestParam(name="ids",required=true) String ids) {
		 String[] split = ids.split(",");
		 if(split.length > 0){
			 for (String id : split) {
				 try {
					 WechatPostsWord byId = wechatPostsWordService.getById(id);
					 byId.setModifyState("1");
					 wechatPostsWordService.updateById(byId);
				 }catch (Exception e){
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.OK("编辑成功!");
	 }

	 @DeleteMapping(value = "/whetherIgnoreAll")
	 public Result<String> whetherIgnoreAll(@RequestParam(name="ids",required=true) String ids) {

		 String[] split = ids.split(",");
		 if(split.length > 0){
			 for (String id : split) {
				 try {
					 WechatPostsWord byId = wechatPostsWordService.getById(id);
					 byId.setIsIgnore("1");
					 wechatPostsWordService.updateById(byId);
				 }catch (Exception e){
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.OK("编辑成功!");
	 }

	 @DeleteMapping(value = "/whetherIgnoreAllCancell")
	 public Result<String> whetherIgnoreAllCancell(@RequestParam(name="ids",required=true) String ids) {
		 String[] split = ids.split(",");
		 if(split.length > 0){
			 for (String id : split) {
				 try {
					 WechatPostsWord byId = wechatPostsWordService.getById(id);
					 byId.setIsIgnore("2");
					 wechatPostsWordService.updateById(byId);
				 }catch (Exception e){
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.OK("编辑成功!");
	 }

	 //抓取微信信息
	 /*
	  * 错敏词扫描
	  */
	 @GetMapping(value = "/listCrawling")
	 public Result<String> queryPageListCrawling() throws Exception {
		 long count = iWechatPostsService.count();
		 Integer pageNo = 1;
		 Integer pageSize = 100;
		 Integer pageNum = (int)Math.ceil((double)count/pageSize);
		 for (Integer i = 1; i <= pageNum; i++) {
			 Page<WechatPosts> page = new Page<WechatPosts>(i, pageSize);
			 QueryWrapper<WechatPosts> queryWrapperWechatPosts = new QueryWrapper<WechatPosts>();
			 queryWrapperWechatPosts.orderByDesc("create_time");
			 IPage<WechatPosts> pageList = iWechatPostsService.page(page,queryWrapperWechatPosts);
			 for (WechatPosts record : pageList.getRecords()) {
				 WechatPostsWord wechatPostsWord = new WechatPostsWord();
				 wechatPostsWord.setId(wechatPostsWord.getId());
				 wechatPostsWord.setCreateBy(wechatPostsWord.getCreateBy());
				 wechatPostsWord.setCreateTime(wechatPostsWord.getCreateTime());
				 wechatPostsWord.setUpdateTime(wechatPostsWord.getUpdateTime());
				 wechatPostsWord.setUpdateBy(wechatPostsWord.getUpdateBy());
				 wechatPostsWord.setWechatPostsId(record.getWechatPostsId());
				 wechatPostsWord.setMsgBiz(record.getMsgBiz());
				 wechatPostsWord.setMsgIdx(record.getMsgIdx());
				 wechatPostsWord.setMsgMid(record.getMsgMid());
				 wechatPostsWord.setContentV(record.getContentV());
				 wechatPostsWord.setAuthor(record.getAuthor());
				 wechatPostsWord.setCopyrightstat(record.getCopyrightstat());
				 wechatPostsWord.setCover(record.getCover());
				 wechatPostsWord.setCreateAt(new Date());
				 wechatPostsWord.setDigest(record.getDigest());
				 wechatPostsWord.setLink(record.getLink());
				 wechatPostsWord.setPublishAt(record.getPublishAt());
				 wechatPostsWord.setSourceUrl(record.getSourceUrl());
				 wechatPostsWord.setTitle(record.getTitle());
				 wechatPostsWord.setUpdateAt(record.getUpdateAt());
				 wechatPostsWord.setWechatId(record.getWechatId());
				 wechatPostsWord.setContent(record.getContent());
				 wechatPostsWord.setLikeNum(record.getLikeNum());
				 wechatPostsWord.setLikeNum2(record.getLikeNum2());
				 wechatPostsWord.setReadNum(record.getReadNum());
				 wechatPostsWord.setUpdateNumAt(record.getUpdateNumAt());
				 String link = record.getLink();
				 if(ObjectUtils.isEmpty(link)){
					 continue;
				 }
				 String spyderGetHTMLByUrl = spyderUtils.getSpyderGetHTMLByUrl(link, null, "2");
				 Element js_article = Jsoup.parse(spyderGetHTMLByUrl).getElementById("js_article");
				 if(!ObjectUtils.isEmpty(js_article)){
					 spyderGetHTMLByUrl = js_article.toString();
					 log.info(spyderGetHTMLByUrl);
				 }
				 //错敏词校验-----开始
				 JsResult jsonObject = fangCunUtils.getJsResult(spyderGetHTMLByUrl);
				 String ret_msg = jsonObject.getRet_msg();
				 wechatPostsWord.setErrorCount(jsonObject.getErrorCount());
				 wechatPostsWord.setRetMsg(jsonObject.getRet_msg());
				 wechatPostsWord.setRetCode(jsonObject.getRet_code()+"");
				 if(!ObjectUtils.isEmpty(ret_msg)){
					 Document parse1 = Jsoup.parse(wechatPostsWord.getRetMsg());
					 Elements elements1 = parse1.select("span.proofreadSignClass.errorWordMark");
					 if(elements1.size() >= 1){
						 wechatPostsWord.setSensitiveList(elements1.toString());
						 wechatPostsWord.setSensitiveCount(elements1.size());
						 wechatPostsWord.setModifyState("1");
						 wechatPostsWord.setRetCode(jsonObject.getRet_code()+"");
						 wechatPostsWord.setHeavyCount(jsonObject.getHeavyCount());
						 String id = wechatPostsWord.getId();
						 wechatPostsWord.setIsIgnore("2");
						 wechatPostsWord.setTenantId(record.getTenantId());
						 wechatPostsWord.setCheckState("2");
						 WechatPostsWord byId = wechatPostsWordService.getById(id);
						 if(!ObjectUtils.isEmpty(byId)){
							 Integer numberScans = byId.getNumberScans();
							 if(!ObjectUtils.isEmpty(numberScans)){
								 numberScans = numberScans + 1;
								 wechatPostsWord.setNumberScans(numberScans);
								 String isIgnore = byId.getIsIgnore();
								 if(isIgnore.equals("1")){
									 continue;
								 }
							 }
							 wechatPostsWord.setIsIgnore(byId.getIsIgnore());
						 } else {
							 wechatPostsWord.setNumberScans(1);
						 }
						 wechatPostsWordService.saveOrUpdate(wechatPostsWord);
					 }
				 }
				 record.setContent(spyderGetHTMLByUrl);
				 iWechatPostsService.updateById(record);
				 try {
					 WechatProfiles wechatProfiles = null;
					 try {
						 QueryWrapper<WechatProfiles> wechatProfilesQueryWrapper = new QueryWrapper<WechatProfiles>();
						 wechatProfilesQueryWrapper.eq("msg_biz",record.getMsgBiz());
						 Page<WechatProfiles> pageWechatPosts = new Page<WechatProfiles>(1, 1);
						 IPage<WechatProfiles> wechatPostsIPage = iWechatProfilesService.page(pageWechatPosts, wechatProfilesQueryWrapper);
						 if(wechatPostsIPage.getRecords().size() >= 1){
							 wechatProfiles = wechatPostsIPage.getRecords().get(0);
						 }
					 }catch (Exception e){
						 e.printStackTrace();
					 }
					 if(!ObjectUtils.isEmpty(wechatProfiles)){
						 getPhone(record,spyderGetHTMLByUrl,wechatProfiles);
						 getIdNumber(record,spyderGetHTMLByUrl,wechatProfiles);
						 getBack(record,spyderGetHTMLByUrl,wechatProfiles);
					 }
				 }catch (Exception e){

				 }
			 }
		 }
		 //统计信息
		 try {
			 List<WechatProfiles> list = iWechatProfilesService.list();
			 for (WechatProfiles wechatProfiles : list) {
				 try {
					 savePhoneStatisticsWechat("1",wechatProfiles);
					 saveBankStatisticsWechat("1",wechatProfiles);
					 saveIdNumberStatisticsWechat("1",wechatProfiles);
				 }catch (Exception e){
					 e.printStackTrace();
				 }
			 }
		 }catch (Exception e){
			 e.printStackTrace();
		 }
		 saveIWeiboErrorWordStatisticsService("1");
		 return Result.OK("抓取成功");
	 }


	 @RequestMapping(value = "/onHandleCheck")
	 public Result<String> onHandleCheck(HttpServletRequest request, WechatPostsWord wechatPostsWord) {
		 QueryWrapper<WechatPostsWord> queryWrapper = QueryGenerator.initQueryWrapper(wechatPostsWord, request.getParameterMap());
		 queryWrapper.isNotNull("sensitive_list");
		 queryWrapper.ne("sensitive_list","");
		 queryWrapper.eq("is_ignore","2");
		 queryWrapper.gt("error_count",0);
		 String selections = request.getParameter("selections");
		 //如果选择了对应的内容只对对应内容进行校验
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 queryWrapper.in("id",selectionList);
			 List<WechatPostsWord> exportList = wechatPostsWordService.list(queryWrapper);
			 for (WechatPostsWord postsWord : exportList)
			 {
				 checkWechatPostsWord(postsWord);
			 }
		 }else{
			 long count = wechatPostsWordService.count();
			 Integer pageSize = 100;
			 Integer pageNum = (int)Math.ceil((double)count/pageSize);
			 for (Integer i = 1; i <= pageNum; i++) {
				 Page<WechatPostsWord> page = new Page<WechatPostsWord>(i, pageSize);
				 QueryWrapper<WechatPostsWord> queryWrapperWechatPosts = new QueryWrapper<WechatPostsWord>();
				 queryWrapperWechatPosts.orderByDesc("create_time");
				 IPage<WechatPostsWord> pageList = wechatPostsWordService.page(page, queryWrapperWechatPosts);
				 for (WechatPostsWord postsWord : pageList.getRecords()) {
					 checkWechatPostsWord(postsWord);
				 }
			 }
		 }
		 //扫描结束对信息进行统计
		 saveIWeiboErrorWordStatisticsService("2");
		 return Result.OK("完成");
	 }

	 @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>();
		 WechatPostsWord weiboContentCapture = wechatPostsWordService.getById(id);
		 if(weiboContentCapture==null) {
			 return Result.error("未找到对应数据");
		 }
		 String sensitiveList = weiboContentCapture.getSensitiveList();
		 Document parseHtml = Jsoup.parse(sensitiveList);
		 Elements elements = parseHtml.select("span.proofreadSignClass.errorWordMark");
		 for (Element element : elements) {
			 PageContentCaptureTrueOrFalse captureTrueOrFalse = new PageContentCaptureTrueOrFalse();
			 String text = element.text();
			 QueryWrapper<LinkWechatErrorWordWhiteList> queryWrapper = new QueryWrapper<LinkWechatErrorWordWhiteList>();
			 queryWrapper.eq("white_content",text);
			 Page<LinkWechatErrorWordWhiteList> page = new Page<LinkWechatErrorWordWhiteList>(1, 1);
			 Page<LinkWechatErrorWordWhiteList> page1 = iLinkWechatErrorWordWhiteListService.page(page, queryWrapper);
			 if(page1.getRecords().size() > 0){
				 captureTrueOrFalse.setFlag(true);
				 captureTrueOrFalse.setWordName(text);
				 captureTrueOrFalse.setWordValue(element.toString());
				 list.add(captureTrueOrFalse);
			 }else{
				 captureTrueOrFalse.setFlag(false);
				 captureTrueOrFalse.setWordName(text);
				 captureTrueOrFalse.setWordValue(element.toString());
				 list.add(captureTrueOrFalse);
			 }
		 }
		 return Result.OK(list);
	 }

	 /**
	  *  编辑
	  * @return
	  */
	 @RequestMapping(value = "/ignore", method = {RequestMethod.PUT,RequestMethod.POST})
	 public Result<String> ignore(@RequestBody Params params) {
		 String weiboId = params.getWeiboId();
		 System.out.println("=================="+weiboId);
		 if(!ObjectUtils.isEmpty(params) && weiboId != ""){
			 WechatPostsWord byId = wechatPostsWordService.getById(weiboId);
			 for (String plainOption : params.getPlainOptions()) {
				 QueryWrapper<LinkWechatErrorWordWhiteList> whiteWordQueryWrapper = new QueryWrapper<LinkWechatErrorWordWhiteList>();
				 whiteWordQueryWrapper.eq("white_content",plainOption);
				 try {
					 iLinkWechatErrorWordWhiteListService.remove(whiteWordQueryWrapper);
				 }catch (Exception e){
					 e.printStackTrace();
				 }
			 }
			 for (String plainOption : params.getCheckedList()) {
				 LinkWechatErrorWordWhiteList linkWhiteWord = new LinkWechatErrorWordWhiteList();
				 linkWhiteWord.setId(IdWorker.getIdStr());
				 String id = byId.getId();
				 if(!ObjectUtils.isEmpty(id)){
					 linkWhiteWord.setMainSiteId(id);
				 }
				 String wechatId = byId.getWechatId();
				 if(!ObjectUtils.isEmpty(wechatId)){
					 linkWhiteWord.setMainSiteName(wechatId);
				 }
				 linkWhiteWord.setMainSiteUrl(byId.getSourceUrl());
				 linkWhiteWord.setTenantId(byId.getTenantId()+"");
				 linkWhiteWord.setWhiteContent(plainOption);
				 if(!ObjectUtils.isEmpty(plainOption) && plainOption != ""){
					 try {
						 iLinkWechatErrorWordWhiteListService.save(linkWhiteWord);
					 }catch (Exception e){
						 e.printStackTrace();
					 }
				 }
			 }
		 }else{
			 return Result.error("编辑失败!");
		 }
		 return Result.OK("编辑成功!");
	 }

	 /**
	  * 批量忽略
	  * @param ids
	  * @return
	  */
	 @DeleteMapping(value = "/ignoreAll")
	 public Result<String> ignoreAllBatch(@RequestParam(name="ids",required=true) String ids) {
		 String[] split = ids.split(",");
		 if(split.length > 0){
			 for (String id : split) {
				 WechatPostsWord weiboContentCapture = wechatPostsWordService.getById(id);
				 try {
					 String sensitiveList = weiboContentCapture.getSensitiveList();
					 Document parseHtml = Jsoup.parse(sensitiveList);
					 Elements elements = parseHtml.select("span.proofreadSignClass.errorWordMark");
					 for (Element element : elements) {
						 String text = element.text();
						 if(!ObjectUtils.isEmpty(text)){
							 QueryWrapper<LinkWechatErrorWordWhiteList> whiteWordQueryWrapper = new QueryWrapper<LinkWechatErrorWordWhiteList>();
							 whiteWordQueryWrapper.eq("white_content",text);
							 try {
								 iLinkWechatErrorWordWhiteListService.remove(whiteWordQueryWrapper);
							 }catch (Exception e){
								 e.printStackTrace();
							 }
							 LinkWechatErrorWordWhiteList linkWhiteWord = new LinkWechatErrorWordWhiteList();
							 linkWhiteWord.setId(IdWorker.getIdStr());
							 String idS = weiboContentCapture.getId();
							 if(!ObjectUtils.isEmpty(idS)){
								 linkWhiteWord.setMainSiteId(idS);
							 }
							 String wechatId = weiboContentCapture.getWechatId();
							 if(!ObjectUtils.isEmpty(wechatId)){
								 linkWhiteWord.setMainSiteName(wechatId);
							 }
							 linkWhiteWord.setMainSiteUrl(weiboContentCapture.getSourceUrl());
							 linkWhiteWord.setTenantId(weiboContentCapture.getTenantId()+"");
							 linkWhiteWord.setWhiteContent(text);
							 if(!ObjectUtils.isEmpty(text) && text != ""){
								 try {
									 iLinkWechatErrorWordWhiteListService.save(linkWhiteWord);
								 }catch (Exception e){
									 e.printStackTrace();
								 }
							 }
						 }
					 }
				 }catch (Exception e){
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.OK("编辑成功!");
	 }
	 /**
	  * 批量取消忽略
	  * @param ids
	  * @return
	  */
	 @DeleteMapping(value = "/ignoreAllCancell")
	 public Result<String> ignoreAllCancell(@RequestParam(name="ids",required=true) String ids) {
		 String[] split = ids.split(",");
		 if(split.length > 0){
			 for (String id : split) {
				 WechatPostsWord weiboContentCapture = wechatPostsWordService.getById(id);
				 try {
					 String sensitiveList = weiboContentCapture.getSensitiveList();
					 Document parseHtml = Jsoup.parse(sensitiveList);
					 Elements elements = parseHtml.select("span.proofreadSignClass.errorWordMark");
					 for (Element element : elements) {
						 String text = element.text();
						 if(!ObjectUtils.isEmpty(text)){
							 QueryWrapper<LinkWechatErrorWordWhiteList> whiteWordQueryWrapper = new QueryWrapper<LinkWechatErrorWordWhiteList>();
							 whiteWordQueryWrapper.eq("white_content",text);
							 try {
								 iLinkWechatErrorWordWhiteListService.remove(whiteWordQueryWrapper);
							 }catch (Exception e){
								 e.printStackTrace();
							 }
						 }
					 }
				 }catch (Exception e){
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.OK("编辑成功!");
	 }


	 private void checkWechatPostsWord(WechatPostsWord postsWord) {
		 String link = postsWord.getLink();
		 String spyderGetHTMLByUrl = spyderUtils.getSpyderGetHTMLByUrl(link, null, "2");
		 Element js_article = Jsoup.parse(spyderGetHTMLByUrl).getElementById("js_article");
		 if(!ObjectUtils.isEmpty(js_article)){
			 spyderGetHTMLByUrl = js_article.toString();
			 log.info(spyderGetHTMLByUrl);
		 }
		 //错敏词校验-----开始
		 JsResult jsonObject = fangCunUtils.getJsResult(spyderGetHTMLByUrl);
		 String ret_msg = jsonObject.getRet_msg();
		 if(!ObjectUtils.isEmpty(ret_msg)){
			 Document parse1 = Jsoup.parse(postsWord.getRetMsg());
			 Elements elements1 = parse1.select("span.proofreadSignClass.errorWordMark");
			 System.out.println(elements1.size());
			 if(elements1.size() >= 1){
				 postsWord.setSensitiveList(elements1.toString());
				 postsWord.setCheckErrorCount(elements1.size());
				 postsWord.setSensitiveCount(elements1.size());
				 postsWord.setCheckTime(new Date());
				 postsWord.setModifyState("1");
				 postsWord.setRetCode(jsonObject.getRet_code()+"");
				 postsWord.setHeavyCount(jsonObject.getHeavyCount());
				 String id = postsWord.getId();
				 postsWord.setTenantId(postsWord.getTenantId());
				 WechatPostsWord byId = wechatPostsWordService.getById(id);
				 saveWechatPostsWordLog(byId);
				 if(!ObjectUtils.isEmpty(byId)){
					 Integer numberScans = byId.getNumberScans();
					 if(!ObjectUtils.isEmpty(numberScans)){
						 numberScans = numberScans + 1;
						 postsWord.setNumberScans(numberScans);
					 }
					 postsWord.setIsIgnore(byId.getIsIgnore());
				 }else{
					 postsWord.setNumberScans(1);
				 }
			 }else{
				 postsWord.setModifyState("2");
			 }
		 }
		 postsWord.setCheckState("1");
		 postsWord.setContent(spyderGetHTMLByUrl);
		 wechatPostsWordService.updateById(postsWord);
		 saveWechatPostsWordLog(postsWord);
	 }

	 //统计信息
	 public void saveIWeiboErrorWordStatisticsService(String type){
		 //查询所有账号对应的数据信息，分别统计
		 log.info("查询所有账号对应的数据信息，分别统计");
		 long count = iWechatProfilesService.count();
		 Integer pageNo = 1;
		 Integer pageSize = 100;
		 Integer pageNum = (int)Math.ceil((double)count/pageSize);
		 for (Integer i = 1; i <= pageNum; i++) {
			 Page<WechatProfiles> page = new Page<WechatProfiles>(i, pageSize);
			 QueryWrapper<WechatProfiles> queryWrapperWechatPosts = new QueryWrapper<WechatProfiles>();
			 IPage<WechatProfiles> pageList = iWechatProfilesService.page(page, queryWrapperWechatPosts);
			 for (WechatProfiles record : pageList.getRecords()) {
				 //分别统计各个，没有修改，没有忽略的数量
			     String wexintId = record.getWexintId();
				 //统计错词数量的总和
				 Integer errorSumCount = iWechatPostsWordService.getSumSensitiveCount(wexintId);
				 if(ObjectUtils.isEmpty(errorSumCount)){
					 errorSumCount = 0;
				 }
				 //保存到统计信息当中
				 WechatErrorWordStatistics wechatErrorWordStatistics = new WechatErrorWordStatistics();
				 wechatErrorWordStatistics.setWechatid(record.getWechatId());
				 wechatErrorWordStatistics.setUsername(record.getUsername());
				 wechatErrorWordStatistics.setTestType(type);
				 wechatErrorWordStatistics.setErrorWordCount(errorSumCount);
				 try {
					 wechatErrorWordStatistics.setScanTime(new Date());
					 wechatErrorWordStatistics.setTenantId(Integer.parseInt(record.getTenantId()));
				 }catch (Exception e){
					 e.printStackTrace();
				 }
				 if(!ObjectUtils.isEmpty(record.getWechatId()) && !ObjectUtils.isEmpty(record.getUsername())
				 ){
					 iWechatErrorWordStatisticsService.save(wechatErrorWordStatistics);
				 }
			 }
		 }
	 }
	 //保存日志信息
	 public void saveWechatPostsWordLog(WechatPostsWord wechatPostsWord){
		try {
			WechatPostsWordLog wechatPostsWordLog = new WechatPostsWordLog();
			wechatPostsWordLog.setId(IdWorker.getIdStr());
			wechatPostsWordLog.setCreateTime(wechatPostsWord.getCreateTime());
			wechatPostsWordLog.setCreateBy(wechatPostsWord.getCreateBy());
			wechatPostsWordLog.setUpdateTime(wechatPostsWord.getUpdateTime());
			wechatPostsWordLog.setUpdateBy(wechatPostsWord.getUpdateBy());
			wechatPostsWordLog.setWechatPostsId(wechatPostsWord.getWechatPostsId());
			wechatPostsWordLog.setMsgBiz(wechatPostsWord.getMsgBiz());
			wechatPostsWordLog.setMsgIdx(wechatPostsWord.getMsgIdx());
			wechatPostsWordLog.setMsgMid(wechatPostsWord.getMsgMid());
			wechatPostsWordLog.setContentV(wechatPostsWord.getContentV());
			wechatPostsWordLog.setAuthor(wechatPostsWord.getAuthor());
			wechatPostsWordLog.setCopyrightstat(wechatPostsWord.getCopyrightstat());
			wechatPostsWordLog.setCover(wechatPostsWord.getCover());
			wechatPostsWordLog.setCreateAt(wechatPostsWord.getCreateAt());
			wechatPostsWordLog.setDigest(wechatPostsWord.getDigest());
			wechatPostsWordLog.setLink(wechatPostsWord.getLink());
			wechatPostsWordLog.setPublishAt(wechatPostsWord.getPublishAt());
			wechatPostsWordLog.setSourceUrl(wechatPostsWord.getSourceUrl());
			wechatPostsWordLog.setTitle(wechatPostsWord.getTitle());
			wechatPostsWordLog.setUpdateAt(wechatPostsWord.getUpdateAt());
			wechatPostsWordLog.setWechatId(wechatPostsWord.getWechatId());
			wechatPostsWordLog.setContent(wechatPostsWord.getContent());
			wechatPostsWordLog.setLikeNum(wechatPostsWord.getLikeNum());
			wechatPostsWordLog.setLikeNum2(wechatPostsWord.getLikeNum2());
			wechatPostsWordLog.setReadNum(wechatPostsWord.getReadNum());
			wechatPostsWordLog.setUpdateNumAt(wechatPostsWord.getUpdateNumAt());
			wechatPostsWordLog.setRetMsg(wechatPostsWord.getRetMsg());
			wechatPostsWordLog.setErrorCount(wechatPostsWord.getErrorCount());
			wechatPostsWordLog.setSensitiveCount(wechatPostsWord.getSensitiveCount());
			wechatPostsWordLog.setSensitiveList(wechatPostsWord.getSensitiveList());
			wechatPostsWordLog.setHeavyCount(wechatPostsWord.getHeavyCount());
			wechatPostsWordLog.setCheckState(wechatPostsWord.getCheckState());
			wechatPostsWordLog.setCheckErrorCount(wechatPostsWord.getCheckErrorCount());
			wechatPostsWordLog.setNumberScans(wechatPostsWord.getNumberScans());
			wechatPostsWordLog.setModifyState(wechatPostsWord.getModifyState());
			wechatPostsWordLog.setIsIgnore(wechatPostsWord.getIsIgnore());
			wechatPostsWordLog.setRetCode(wechatPostsWord.getRetCode());
			wechatPostsWordLog.setCheckTime(wechatPostsWord.getCheckTime());
			wechatPostsWordLog.setTenantId(wechatPostsWord.getTenantId());
			iWechatPostsWordLogService.save(wechatPostsWordLog);
		}catch (Exception e){
			e.printStackTrace();
		}
	}


	 public void getIdNumber(WechatPosts wechatPosts, String text, WechatProfiles wechatProfiles){
		 String IdNumberId = "";
		 //从正文当中提取身份证号
		 log.info("============从正文当中提取身份证号=================");
		 JsoupReturn phone = jsoupUtilsService.getIdNumber(text,wechatProfiles.getTenantId());
		 LinkWechatIdNumberDetection linkWechatIdNumberDetection = new LinkWechatIdNumberDetection();
		 linkWechatIdNumberDetection.setCreateTime(new Date());
		 linkWechatIdNumberDetection.setUpdateTime(new Date());
		 linkWechatIdNumberDetection.setMsgBiz(wechatProfiles.getMsgBiz());
		 IdNumberId += wechatProfiles.getMsgBiz();
		 linkWechatIdNumberDetection.setWechatTitle(wechatProfiles.getUsername());
		 IdNumberId += wechatProfiles.getUsername();
		 linkWechatIdNumberDetection.setSource(wechatPosts.getLink());
		 IdNumberId += wechatPosts.getLink();
		 linkWechatIdNumberDetection.setTitle(wechatPosts.getTitle());
		 IdNumberId += wechatPosts.getTitle();
		 linkWechatIdNumberDetection.setArticleReleaseTime(wechatPosts.getPublishAt());
		 linkWechatIdNumberDetection.setContent(wechatPosts.getContent());
		 linkWechatIdNumberDetection.setRetMsg(phone.getHtml());
		 linkWechatIdNumberDetection.setErrorCount(phone.getHtmlList().size());
		 try {
			 String HtmlListStr = "";
			 List<String> htmlList = phone.getHtmlList();
			 for (String sH : htmlList) {
				 HtmlListStr += sH;
			 }
			 linkWechatIdNumberDetection.setHtmlList(HtmlListStr);
		 }catch (Exception e){
			 e.printStackTrace();
		 }
		 try {
			 String strListStr = "";
			 List<String> strList = phone.getStrList();
			 for (String sH : strList) {
				 strListStr += sH +",";
			 }
			 linkWechatIdNumberDetection.setStrList(strListStr);
		 }catch (Exception e){
			 e.printStackTrace();
		 }
		 try {
			 String strListA = "";
			 List<String> strList = phone.getAList();
			 for (String sH : strList) {
				 strListA += sH +",";
			 }
			 linkWechatIdNumberDetection.setAhtmlList(strListA);
		 }catch (Exception e){
			 e.printStackTrace();
		 }
		 linkWechatIdNumberDetection.setIsInvalid("2");
		 linkWechatIdNumberDetection.setIsRevise("1");
		 linkWechatIdNumberDetection.setIsIgnore("2");
		 linkWechatIdNumberDetection.setCheckTime(new Date());
		 linkWechatIdNumberDetection.setCheckState("2");
		 linkWechatIdNumberDetection.setNumberScans(1);
		 linkWechatIdNumberDetection.setTenantId(wechatPosts.getTenantId()+"");
		 linkWechatIdNumberDetection.setId(DigestUtils.md5DigestAsHex((IdNumberId).getBytes()));
		 String idNumberId = linkWechatIdNumberDetection.getId();
		 LinkWechatIdNumberDetection linkWechatIdNumber = iLinkWechatIdNumberDetectionService.getById(idNumberId);
		 if(!ObjectUtils.isEmpty(linkWechatIdNumber)){
			 linkWechatIdNumberDetection.setIsInvalid(linkWechatIdNumber.getIsInvalid());
			 linkWechatIdNumberDetection.setIsRevise(linkWechatIdNumber.getIsRevise());
			 linkWechatIdNumberDetection.setIsIgnore(linkWechatIdNumber.getIsIgnore());
			 linkWechatIdNumberDetection.setCheckTime(new Date());
			 linkWechatIdNumberDetection.setCheckState(linkWechatIdNumber.getCheckState());
			 Integer numberScans = linkWechatIdNumber.getNumberScans();
			 if(!ObjectUtils.isEmpty(numberScans)){
				 linkWechatIdNumberDetection.setNumberScans( 1 + numberScans);
			 }
		 }
		 if(phone.getAList().size() > 0){
			 iLinkWechatIdNumberDetectionService.saveOrUpdate(linkWechatIdNumberDetection);
			 saveLinkWechatIdNumberDetection(linkWechatIdNumberDetection);
		 }

	 }

	 public void saveLinkWechatIdNumberDetection(LinkWechatIdNumberDetection linkWechatIdNumberDetection) {
		 LinkWechatIdNumberDetectionLog linkWechatIdNumberDetectionLog = new LinkWechatIdNumberDetectionLog();
		 linkWechatIdNumberDetectionLog.setId(IdWorker.getIdStr());
		 linkWechatIdNumberDetectionLog.setCreateBy(linkWechatIdNumberDetection.getCreateBy());
		 linkWechatIdNumberDetectionLog.setCreateTime(linkWechatIdNumberDetection.getCreateTime());
		 linkWechatIdNumberDetectionLog.setUpdateBy(linkWechatIdNumberDetection.getUpdateBy());
		 linkWechatIdNumberDetectionLog.setUpdateTime(linkWechatIdNumberDetection.getUpdateTime());
		 linkWechatIdNumberDetectionLog.setMsgBiz(linkWechatIdNumberDetection.getMsgBiz());
		 linkWechatIdNumberDetectionLog.setWechatTitle(linkWechatIdNumberDetection.getWechatTitle());
		 linkWechatIdNumberDetectionLog.setSource(linkWechatIdNumberDetection.getSource());
		 linkWechatIdNumberDetectionLog.setTitle(linkWechatIdNumberDetection.getTitle());
		 linkWechatIdNumberDetectionLog.setArticleReleaseTime(linkWechatIdNumberDetection.getArticleReleaseTime());
		 linkWechatIdNumberDetectionLog.setContent(linkWechatIdNumberDetection.getContent());
		 linkWechatIdNumberDetectionLog.setRetMsg(linkWechatIdNumberDetection.getRetMsg());
		 linkWechatIdNumberDetectionLog.setErrorCount(linkWechatIdNumberDetection.getErrorCount());
		 linkWechatIdNumberDetectionLog.setHtmlList(linkWechatIdNumberDetection.getHtmlList());
		 linkWechatIdNumberDetectionLog.setStrList(linkWechatIdNumberDetection.getStrList());
		 linkWechatIdNumberDetectionLog.setAhtmlList(linkWechatIdNumberDetection.getAhtmlList());
		 linkWechatIdNumberDetectionLog.setIsInvalid(linkWechatIdNumberDetection.getIsInvalid());
		 linkWechatIdNumberDetectionLog.setIsRevise(linkWechatIdNumberDetection.getIsRevise());
		 linkWechatIdNumberDetectionLog.setIsIgnore(linkWechatIdNumberDetection.getIsIgnore());
		 linkWechatIdNumberDetectionLog.setCheckTime(linkWechatIdNumberDetection.getCheckTime());
		 linkWechatIdNumberDetectionLog.setCheckState(linkWechatIdNumberDetection.getCheckState());
		 linkWechatIdNumberDetectionLog.setCheckErrorCount(linkWechatIdNumberDetection.getCheckErrorCount());
		 linkWechatIdNumberDetectionLog.setCheckMessage(linkWechatIdNumberDetection.getCheckMessage());
		 linkWechatIdNumberDetectionLog.setNumberScans(linkWechatIdNumberDetection.getNumberScans());
		 linkWechatIdNumberDetectionLog.setTenantId(linkWechatIdNumberDetection.getTenantId());
		 iLinkWechatIdNumberDetectionLogService.save(linkWechatIdNumberDetectionLog);

	 }

	 // 获取手机号
	 public void getPhone(WechatPosts wechatPosts, String text, WechatProfiles wechatProfiles){
		 String IdNumberId = "";
		 //从正文当中提取手机号
		 log.info("============从正文当中提取手机号=================");
		 JsoupReturn phone = jsoupUtilsService.getPhone(text,wechatProfiles.getTenantId());
		 LinkWechatPhoneDetection linkWechatPhoneDetection = new LinkWechatPhoneDetection();
		 linkWechatPhoneDetection.setCreateTime(new Date());
		 linkWechatPhoneDetection.setUpdateTime(new Date());
		 linkWechatPhoneDetection.setMsgBiz(wechatProfiles.getMsgBiz());
		 IdNumberId += wechatProfiles.getMsgBiz();
		 linkWechatPhoneDetection.setWechatTitle(wechatProfiles.getUsername());
		 IdNumberId += wechatProfiles.getUsername();
		 linkWechatPhoneDetection.setSource(wechatPosts.getLink());
		 IdNumberId += wechatPosts.getLink();
		 linkWechatPhoneDetection.setTitle(wechatPosts.getTitle());
		 IdNumberId += wechatPosts.getTitle();
		 linkWechatPhoneDetection.setArticleReleaseTime(wechatPosts.getPublishAt());
		 linkWechatPhoneDetection.setContent(wechatPosts.getContent());
		 linkWechatPhoneDetection.setRetMsg(phone.getHtml());
		 linkWechatPhoneDetection.setErrorCount(phone.getHtmlList().size());
		 try {
			 String HtmlListStr = "";
			 List<String> htmlList = phone.getHtmlList();
			 for (String sH : htmlList) {
				 HtmlListStr += sH;
			 }
			 linkWechatPhoneDetection.setHtmlList(HtmlListStr);
		 }catch (Exception e){
			 e.printStackTrace();
		 }
		 try {
			 String strListStr = "";
			 List<String> strList = phone.getStrList();
			 for (String sH : strList) {
				 strListStr += sH +",";
			 }
			 linkWechatPhoneDetection.setStrList(strListStr);
		 }catch (Exception e){
			 e.printStackTrace();
		 }
		 try {
			 String strListA = "";
			 List<String> strList = phone.getAList();
			 for (String sH : strList) {
				 strListA += sH +",";
			 }
			 linkWechatPhoneDetection.setAhtmlList(strListA);
		 }catch (Exception e){
			 e.printStackTrace();
		 }
		 linkWechatPhoneDetection.setIsInvalid("2");
		 linkWechatPhoneDetection.setIsRevise("1");
		 linkWechatPhoneDetection.setIsIgnore("2");
		 linkWechatPhoneDetection.setCheckTime(new Date());
		 linkWechatPhoneDetection.setCheckState("2");
		 linkWechatPhoneDetection.setNumberScans(1);
		 linkWechatPhoneDetection.setTenantId(wechatPosts.getTenantId()+"");
		 linkWechatPhoneDetection.setId(DigestUtils.md5DigestAsHex((IdNumberId).getBytes()));
		 String phoneId = linkWechatPhoneDetection.getId();
		 LinkWechatPhoneDetection linkWechatPhone = iLinkWechatPhoneDetectionService.getById(phoneId);
		 if(!ObjectUtils.isEmpty(linkWechatPhone)){
			 linkWechatPhoneDetection.setIsInvalid(linkWechatPhone.getIsInvalid());
			 linkWechatPhoneDetection.setIsRevise(linkWechatPhone.getIsRevise());
			 linkWechatPhoneDetection.setIsIgnore(linkWechatPhone.getIsIgnore());
			 linkWechatPhoneDetection.setCheckTime(new Date());
			 linkWechatPhoneDetection.setCheckState(linkWechatPhone.getCheckState());
			 Integer numberScans = linkWechatPhone.getNumberScans();
			 if(!ObjectUtils.isEmpty(numberScans)){
				 linkWechatPhoneDetection.setNumberScans( 1 + numberScans);
			 }
		 }
		 if(phone.getAList().size() > 0){
			 iLinkWechatPhoneDetectionService.saveOrUpdate(linkWechatPhoneDetection);
			 saveLinkWechatPhoneDetectionLog(linkWechatPhoneDetection);
		 }
	 }

	 public void saveLinkWechatPhoneDetectionLog(LinkWechatPhoneDetection linkWechatPhoneDetection){
		 LinkWechatPhoneDetectionLog linkWechatPhoneDetectionLog = new LinkWechatPhoneDetectionLog();
		 linkWechatPhoneDetectionLog.setId(IdWorker.getIdStr());
		 linkWechatPhoneDetectionLog.setCreateBy(linkWechatPhoneDetection.getCreateBy());
		 linkWechatPhoneDetectionLog.setCreateTime(linkWechatPhoneDetection.getCreateTime());
		 linkWechatPhoneDetectionLog.setUpdateBy(linkWechatPhoneDetection.getUpdateBy());
		 linkWechatPhoneDetectionLog.setUpdateTime(linkWechatPhoneDetection.getUpdateTime());
		 linkWechatPhoneDetectionLog.setMsgBiz(linkWechatPhoneDetection.getMsgBiz());
		 linkWechatPhoneDetectionLog.setWechatTitle(linkWechatPhoneDetection.getWechatTitle());
		 linkWechatPhoneDetectionLog.setSource(linkWechatPhoneDetection.getSource());
		 linkWechatPhoneDetectionLog.setTitle(linkWechatPhoneDetection.getTitle());
		 linkWechatPhoneDetectionLog.setArticleReleaseTime(linkWechatPhoneDetection.getArticleReleaseTime());
		 linkWechatPhoneDetectionLog.setContent(linkWechatPhoneDetection.getContent());
		 linkWechatPhoneDetectionLog.setRetMsg(linkWechatPhoneDetection.getRetMsg());
		 linkWechatPhoneDetectionLog.setErrorCount(linkWechatPhoneDetection.getErrorCount());
		 linkWechatPhoneDetectionLog.setHtmlList(linkWechatPhoneDetection.getHtmlList());
		 linkWechatPhoneDetectionLog.setStrList(linkWechatPhoneDetection.getStrList());
		 linkWechatPhoneDetectionLog.setAhtmlList(linkWechatPhoneDetection.getAhtmlList());
		 linkWechatPhoneDetectionLog.setIsInvalid(linkWechatPhoneDetection.getIsInvalid());
		 linkWechatPhoneDetectionLog.setIsRevise(linkWechatPhoneDetection.getIsRevise());
		 linkWechatPhoneDetectionLog.setIsIgnore(linkWechatPhoneDetection.getIsIgnore());
		 linkWechatPhoneDetectionLog.setCheckTime(linkWechatPhoneDetection.getCheckTime());
		 linkWechatPhoneDetectionLog.setCheckState(linkWechatPhoneDetection.getCheckState());
		 linkWechatPhoneDetectionLog.setCheckErrorCount(linkWechatPhoneDetection.getCheckErrorCount());
		 linkWechatPhoneDetectionLog.setCheckMessage(linkWechatPhoneDetection.getCheckMessage());
		 linkWechatPhoneDetectionLog.setNumberScans(linkWechatPhoneDetection.getNumberScans());
		 linkWechatPhoneDetectionLog.setTenantId(linkWechatPhoneDetection.getTenantId());
		 iLinkWechatPhoneDetectionLogService.saveOrUpdate(linkWechatPhoneDetectionLog);
	 }


	 // 获取银行卡号
	 public void getBack(WechatPosts wechatPosts, String text, WechatProfiles wechatProfiles){
		 String IdNumberId = "";
		 //从正文当中提取手机号
		 log.info("============从正文当中提取手机号=================");
		 JsoupReturn phone = jsoupUtilsService.getBankCardNumber(text,wechatProfiles.getTenantId());
		 LinkWechatBankCardDetection linkWechatBankCardDetection = new LinkWechatBankCardDetection();
		 linkWechatBankCardDetection.setCreateTime(new Date());
		 linkWechatBankCardDetection.setUpdateTime(new Date());
		 linkWechatBankCardDetection.setMsgBiz(wechatProfiles.getMsgBiz());
		 IdNumberId += wechatProfiles.getMsgBiz();
		 linkWechatBankCardDetection.setWechatTitle(wechatProfiles.getUsername());
		 IdNumberId += wechatProfiles.getUsername();
		 linkWechatBankCardDetection.setSource(wechatPosts.getLink());
		 IdNumberId += wechatPosts.getLink();
		 linkWechatBankCardDetection.setTitle(wechatPosts.getTitle());
		 IdNumberId += wechatPosts.getTitle();
		 linkWechatBankCardDetection.setArticleReleaseTime(wechatPosts.getPublishAt());
		 linkWechatBankCardDetection.setContent(wechatPosts.getContent());
		 linkWechatBankCardDetection.setRetMsg(phone.getHtml());
		 linkWechatBankCardDetection.setErrorCount(phone.getHtmlList().size());
		 try {
			 String HtmlListStr = "";
			 List<String> htmlList = phone.getHtmlList();
			 for (String sH : htmlList) {
				 HtmlListStr += sH;
			 }
			 linkWechatBankCardDetection.setHtmlList(HtmlListStr);
		 }catch (Exception e){
			 e.printStackTrace();
		 }
		 try {
			 String strListStr = "";
			 List<String> strList = phone.getStrList();
			 for (String sH : strList) {
				 strListStr += sH +",";
			 }
			 linkWechatBankCardDetection.setStrList(strListStr);
		 }catch (Exception e){
			 e.printStackTrace();
		 }
		 try {
			 String strListA = "";
			 List<String> strList = phone.getAList();
			 for (String sH : strList) {
				 strListA += sH +",";
			 }
			 linkWechatBankCardDetection.setAhtmlList(strListA);
		 }catch (Exception e){
			 e.printStackTrace();
		 }
		 linkWechatBankCardDetection.setIsInvalid("2");
		 linkWechatBankCardDetection.setIsRevise("1");
		 linkWechatBankCardDetection.setIsIgnore("2");
		 linkWechatBankCardDetection.setCheckTime(new Date());
		 linkWechatBankCardDetection.setCheckState("2");
		 linkWechatBankCardDetection.setNumberScans(1);
		 linkWechatBankCardDetection.setTenantId(wechatPosts.getTenantId()+"");
		 linkWechatBankCardDetection.setId(DigestUtils.md5DigestAsHex((IdNumberId).getBytes()));
		 String phoneId = linkWechatBankCardDetection.getId();
		 LinkWechatBankCardDetection linkWechatBank = iLinkWechatBankCardDetectionService.getById(phoneId);
		 if(!ObjectUtils.isEmpty(linkWechatBank)){
			 linkWechatBankCardDetection.setIsInvalid(linkWechatBank.getIsInvalid());
			 linkWechatBankCardDetection.setIsRevise(linkWechatBank.getIsRevise());
			 linkWechatBankCardDetection.setIsIgnore(linkWechatBank.getIsIgnore());
			 linkWechatBankCardDetection.setCheckTime(new Date());
			 linkWechatBankCardDetection.setCheckState(linkWechatBank.getCheckState());
			 Integer numberScans = linkWechatBank.getNumberScans();
			 if(!ObjectUtils.isEmpty(numberScans)){
				 linkWechatBankCardDetection.setNumberScans( 1 + numberScans);
			 }
		 }
		 if(phone.getAList().size() > 0){
			 iLinkWechatBankCardDetectionService.saveOrUpdate(linkWechatBankCardDetection);
			 saveLinkWeiboBankCardDetectionLog(linkWechatBankCardDetection);
		 }
	 }

	 public void saveLinkWeiboBankCardDetectionLog(LinkWechatBankCardDetection linkWechatBankCardDetection){
		 LinkWechatBankCardDetectionLog linkWechatBankCardDetectionLog = new LinkWechatBankCardDetectionLog();
		 linkWechatBankCardDetectionLog.setId(IdWorker.getIdStr());
		 linkWechatBankCardDetectionLog.setCreateBy(linkWechatBankCardDetection.getCreateBy());
		 linkWechatBankCardDetectionLog.setCheckTime(linkWechatBankCardDetection.getCheckTime());
		 linkWechatBankCardDetectionLog.setUpdateBy(linkWechatBankCardDetection.getUpdateBy());
		 linkWechatBankCardDetectionLog.setUpdateTime(linkWechatBankCardDetection.getUpdateTime());
		 linkWechatBankCardDetectionLog.setMsgBiz(linkWechatBankCardDetection.getMsgBiz());
		 linkWechatBankCardDetectionLog.setWechatTitle(linkWechatBankCardDetection.getWechatTitle());
		 linkWechatBankCardDetectionLog.setSource(linkWechatBankCardDetection.getSource());
		 linkWechatBankCardDetectionLog.setTitle(linkWechatBankCardDetection.getTitle());
		 linkWechatBankCardDetectionLog.setArticleReleaseTime(linkWechatBankCardDetection.getArticleReleaseTime());
		 linkWechatBankCardDetectionLog.setContent(linkWechatBankCardDetection.getContent());
		 linkWechatBankCardDetectionLog.setRetMsg(linkWechatBankCardDetection.getRetMsg());
		 linkWechatBankCardDetectionLog.setErrorCount(linkWechatBankCardDetection.getErrorCount());
		 linkWechatBankCardDetectionLog.setHtmlList(linkWechatBankCardDetection.getHtmlList());
		 linkWechatBankCardDetectionLog.setStrList(linkWechatBankCardDetection.getStrList());
		 linkWechatBankCardDetectionLog.setAhtmlList(linkWechatBankCardDetection.getAhtmlList());
		 linkWechatBankCardDetectionLog.setIsInvalid(linkWechatBankCardDetection.getIsInvalid());
		 linkWechatBankCardDetectionLog.setIsIgnore(linkWechatBankCardDetection.getIsIgnore());
		 linkWechatBankCardDetectionLog.setCheckTime(linkWechatBankCardDetection.getCheckTime());
		 linkWechatBankCardDetectionLog.setCheckState(linkWechatBankCardDetection.getCheckState());
		 linkWechatBankCardDetectionLog.setCheckErrorCount(linkWechatBankCardDetection.getCheckErrorCount());
		 linkWechatBankCardDetectionLog.setCheckMessage(linkWechatBankCardDetection.getCheckMessage());
		 linkWechatBankCardDetectionLog.setNumberScans(linkWechatBankCardDetection.getNumberScans());
		 linkWechatBankCardDetectionLog.setTenantId(linkWechatBankCardDetection.getTenantId());
		 iLinkWechatBankCardDetectionLogService.save(linkWechatBankCardDetectionLog);
	 }

	 private void saveBankStatisticsWechat(String type, WechatProfiles wechatProfiles) {
		 try {
			 LinkWechatBankCardDetectionStatistics wechatBankCardDetectionStatistics = new LinkWechatBankCardDetectionStatistics();
			 wechatBankCardDetectionStatistics.setId(IdWorker.getIdStr());
			 wechatBankCardDetectionStatistics.setMsgBiz(wechatProfiles.getMsgBiz());
			 wechatBankCardDetectionStatistics.setWechatTitle(wechatProfiles.getUsername());
			 wechatBankCardDetectionStatistics.setTestType(type);
			 wechatBankCardDetectionStatistics.setScanTime(new Date());
			 try {
				 wechatBankCardDetectionStatistics.setTenantId(Integer.parseInt(wechatProfiles.getTenantId()));
			 }catch (Exception e){
				 e.printStackTrace();
			 }
			 Integer sumAll  = iLinkWechatBankCardDetectionService.getSumStatistics(wechatProfiles.getMsgBiz());
			 if(ObjectUtils.isEmpty(sumAll)){
				 sumAll = 0;
			 }
			 wechatBankCardDetectionStatistics.setBankCardCount(sumAll);
			 iLinkWechatBankCardDetectionStatisticsService.save(wechatBankCardDetectionStatistics);
		 }catch (Exception e){
		 }
	 }

	 private void savePhoneStatisticsWechat(String type, WechatProfiles wechatProfiles) {
		 try {
			 LinkWechatPhoneDetectionStatistics weiboPhoneDetectionStatistics = new LinkWechatPhoneDetectionStatistics();
			 weiboPhoneDetectionStatistics.setId(IdWorker.getIdStr());
			 weiboPhoneDetectionStatistics.setMsgBiz(wechatProfiles.getMsgBiz());
			 weiboPhoneDetectionStatistics.setWechatTitle(wechatProfiles.getUsername());
			 weiboPhoneDetectionStatistics.setTestType(type);
			 weiboPhoneDetectionStatistics.setScanTime(new Date());
			 try {
				 weiboPhoneDetectionStatistics.setTenantId(Integer.parseInt(wechatProfiles.getTenantId()));
			 }catch (Exception e){
				 e.printStackTrace();
			 }
			 Integer sumAll  = iLinkWechatPhoneDetectionService.getSumStatistics(wechatProfiles.getMsgBiz());
			 if(ObjectUtils.isEmpty(sumAll)){
				 sumAll = 0;
			 }
			 weiboPhoneDetectionStatistics.setPersonalPhoneCount(sumAll);
			 iLinkWechatPhoneDetectionStatisticsService.save(weiboPhoneDetectionStatistics);
		 }catch (Exception e){
		 }
	 }

	 private void saveIdNumberStatisticsWechat(String type, WechatProfiles wechatProfiles) {
		 try {
			 LinkWechatPersonalIdDetectionStatistics wechatPersonalIdDetectionStatistics = new LinkWechatPersonalIdDetectionStatistics();
			 wechatPersonalIdDetectionStatistics.setId(IdWorker.getIdStr());
			 wechatPersonalIdDetectionStatistics.setMsgBiz(wechatProfiles.getMsgBiz());
			 wechatPersonalIdDetectionStatistics.setWechatTitle(wechatProfiles.getUsername());
			 wechatPersonalIdDetectionStatistics.setTestType(type);
			 wechatPersonalIdDetectionStatistics.setScanTime(new Date());
			 try {
				 wechatPersonalIdDetectionStatistics.setTenantId(Integer.parseInt(wechatProfiles.getTenantId()));
			 }catch (Exception e){
				 e.printStackTrace();
			 }
			 Integer sumAll  = iLinkWechatIdNumberDetectionService.getSumStatistics(wechatProfiles.getMsgBiz());
			 if(ObjectUtils.isEmpty(sumAll)){
				 sumAll = 0;
			 }
			 wechatPersonalIdDetectionStatistics.setPersonalIdCount(sumAll);
			 idDetectionStatisticsService.save(wechatPersonalIdDetectionStatistics);
		 }catch (Exception e){
		 }
	 }
 }
