package org.jeecg.modules.demo.linkweibophonedetection.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.linkpersonalphonedetection.controller.LinkPersonalPhoneDetectionController;
import org.jeecg.modules.demo.linkpersonalphonedetection.entity.LinkPersonalPhoneDetection;
import org.jeecg.modules.demo.linkpersonalphonewhitelist.entity.LinkPersonalPhoneWhiteList;
import org.jeecg.modules.demo.linkweibophonedetection.entity.LinkWeiboPhoneDetection;
import org.jeecg.modules.demo.linkweibophonedetection.entity.LinkWeiboPhoneDetectionVo;
import org.jeecg.modules.demo.linkweibophonedetection.service.ILinkWeiboPhoneDetectionService;

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.linkweibophonedetection.service.ILinkWeiboPhoneDetectionVoService;
import org.jeecg.modules.demo.linkweibophonedetectionstatistics.entity.LinkWeiboPhoneDetectionStatistics;
import org.jeecg.modules.demo.linkweibophonedetectionstatistics.service.ILinkWeiboPhoneDetectionStatisticsService;
import org.jeecg.modules.demo.linkweibophonewhitelist.entity.LinkWeiboPhoneWhiteList;
import org.jeecg.modules.demo.linkweibophonewhitelist.service.ILinkWeiboPhoneWhiteListService;
import org.jeecg.modules.demo.mainsite.entity.MainSite;
import org.jeecg.modules.demo.pagecontentcapture.controller.Params;
import org.jeecg.modules.demo.pagecontentcapture.entity.PageContentCapture;
import org.jeecg.modules.demo.weibo.entity.Weibo;
import org.jeecg.modules.demo.weibo.service.IWeiboService;
import org.jeecg.modules.demo.weibocontentcapture.entity.WeiboContentCapture;
import org.jeecg.modules.demo.weibouser.entity.WeiboUser;
import org.jeecg.modules.demo.weibouser.service.IWeiboUserService;
import org.jeecg.modules.spyderUtils.SpyderUtils;
import org.jeecg.modules.spyderUtils.spider.JsoupReturn;
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.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-07-03
 * @Version: V1.0
 */
@Api(tags="微博手机号检测")
@RestController
@RequestMapping("/linkweibophonedetection/linkWeiboPhoneDetection")
@Slf4j
public class LinkWeiboPhoneDetectionController extends JeecgController<LinkWeiboPhoneDetection, ILinkWeiboPhoneDetectionService> {
	 @Autowired
	 private ILinkWeiboPhoneDetectionService linkWeiboPhoneDetectionService;

	 @Autowired
	 private ILinkWeiboPhoneWhiteListService iLinkWeiboPhoneWhiteListService;
	 @Autowired
	 private ILinkWeiboPhoneDetectionStatisticsService iLinkWeiboPhoneDetectionStatisticsService;
	 @Autowired
	 private IWeiboUserService iWeiboUserService;

	 @Autowired
	 private IWeiboService iWeiboService;

	 @Autowired
	 private SpyderUtils spyderUtils;

	 @Autowired
	 private ILinkWeiboPhoneDetectionVoService iLinkWeiboPhoneDetectionVoService;
	/**
	 * 分页列表查询
	 *
	 * @param linkWeiboPhoneDetection
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	//@AutoLog(value = "微博手机号检测-分页列表查询")
	@ApiOperation(value="微博手机号检测-分页列表查询", notes="微博手机号检测-分页列表查询")
	@GetMapping(value = "/list")
	public Result<IPage<LinkWeiboPhoneDetection>> queryPageList(LinkWeiboPhoneDetection linkWeiboPhoneDetection,
								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								   HttpServletRequest req) {
		QueryWrapper<LinkWeiboPhoneDetection> queryWrapper = QueryGenerator.initQueryWrapper(linkWeiboPhoneDetection, req.getParameterMap());
		Page<LinkWeiboPhoneDetection> page = new Page<LinkWeiboPhoneDetection>(pageNo, pageSize);
		IPage<LinkWeiboPhoneDetection> pageList = linkWeiboPhoneDetectionService.page(page, queryWrapper);
		return Result.OK(pageList);
	}

	 @ApiOperation(value="微博手机号检测-分页列表查询", notes="微博手机号检测-分页列表查询")
	 @GetMapping(value = "/listVo")
	 public Result<IPage<LinkWeiboPhoneDetectionVo>> queryPageListVo(LinkWeiboPhoneDetectionVo linkWeiboPhoneDetectionVo,
																   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
																   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
																   HttpServletRequest req) {
		 QueryWrapper<LinkWeiboPhoneDetectionVo> queryWrapper = QueryGenerator.initQueryWrapper(linkWeiboPhoneDetectionVo, req.getParameterMap());
		 Page<LinkWeiboPhoneDetectionVo> page = new Page<LinkWeiboPhoneDetectionVo>(pageNo, pageSize);
		 IPage<LinkWeiboPhoneDetectionVo> pageList = iLinkWeiboPhoneDetectionVoService.page(page, queryWrapper);
		 return Result.OK(pageList);
	 }
	 /**
	 *   添加
	 *
	 * @param linkWeiboPhoneDetection
	 * @return
	 */
	@AutoLog(value = "微博手机号检测-添加")
	@ApiOperation(value="微博手机号检测-添加", notes="微博手机号检测-添加")
	@RequiresPermissions("linkweibophonedetection:link_weibo_phone_detection:add")
	@PostMapping(value = "/add")
	public Result<String> add(@RequestBody LinkWeiboPhoneDetection linkWeiboPhoneDetection) {
		linkWeiboPhoneDetectionService.save(linkWeiboPhoneDetection);
		return Result.OK("添加成功！");
	}
	
	/**
	 *  编辑
	 *
	 * @param linkWeiboPhoneDetection
	 * @return
	 */
	@AutoLog(value = "微博手机号检测-编辑")
	@ApiOperation(value="微博手机号检测-编辑", notes="微博手机号检测-编辑")
	@RequiresPermissions("linkweibophonedetection:link_weibo_phone_detection:edit")
	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> edit(@RequestBody LinkWeiboPhoneDetection linkWeiboPhoneDetection) {
		linkWeiboPhoneDetectionService.updateById(linkWeiboPhoneDetection);
		return Result.OK("编辑成功!");
	}
	
	/**
	 *   通过id删除
	 *
	 * @param id
	 * @return
	 */
	@AutoLog(value = "微博手机号检测-通过id删除")
	@ApiOperation(value="微博手机号检测-通过id删除", notes="微博手机号检测-通过id删除")
	@RequiresPermissions("linkweibophonedetection:link_weibo_phone_detection:delete")
	@DeleteMapping(value = "/delete")
	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
		linkWeiboPhoneDetectionService.removeById(id);
		return Result.OK("删除成功!");
	}
	
	/**
	 *  批量删除
	 *
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "微博手机号检测-批量删除")
	@ApiOperation(value="微博手机号检测-批量删除", notes="微博手机号检测-批量删除")
	@RequiresPermissions("linkweibophonedetection:link_weibo_phone_detection:deleteBatch")
	@DeleteMapping(value = "/deleteBatch")
	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
		this.linkWeiboPhoneDetectionService.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<LinkWeiboPhoneDetection> queryById(@RequestParam(name="id",required=true) String id) {
		LinkWeiboPhoneDetection linkWeiboPhoneDetection = linkWeiboPhoneDetectionService.getById(id);
		if(linkWeiboPhoneDetection==null) {
			return Result.error("未找到对应数据");
		}
		return Result.OK(linkWeiboPhoneDetection);
	}

    /**
    * 导出excel
    *
    * @param request
    * @param linkWeiboPhoneDetection
    */
    @RequiresPermissions("linkweibophonedetection:link_weibo_phone_detection:exportXls")
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, LinkWeiboPhoneDetection linkWeiboPhoneDetection) {
        return super.exportXls(request, linkWeiboPhoneDetection, LinkWeiboPhoneDetection.class, "微博手机号检测");
    }

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


	 @RequestMapping(value = "/onHandleCheck")
	 public Result<String> onHandleCheck(HttpServletRequest request, LinkWeiboPhoneDetection linkWeiboPhoneDetection) {
		 String tenantId = request.getHeader("X-Tenant-Id");
		 QueryWrapper<LinkWeiboPhoneDetection> queryWrapper = QueryGenerator.initQueryWrapper(linkWeiboPhoneDetection, 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");
		 System.out.println(selections);
		 //如果选择了对应的内容只对对应内容进行校验
		 String mainSiteUrl = null;
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 queryWrapper.in("id",selectionList);
			 List<LinkWeiboPhoneDetection> exportList = linkWeiboPhoneDetectionService.list(queryWrapper);
			 for (LinkWeiboPhoneDetection contentCapture : exportList)
			 {
				 mainSiteUrl = contentCapture.getSource();
			 }
		 }else{
		 }
		 return Result.OK("完成");
	 }


	 @DeleteMapping(value = "/batchHModifyTrue")
	 public Result<String> batchHModifyTrue(@RequestParam(name="ids",required=true) String ids) {
		 String[] split = ids.split(",");
		 for (String sId : split) {
			 try {
				 LinkWeiboPhoneDetection weiboContentCapture = linkWeiboPhoneDetectionService.getById(sId);
				 weiboContentCapture.setIsRevise("2");
				 linkWeiboPhoneDetectionService.updateById(weiboContentCapture);
			 }catch (Exception e){
				 e.printStackTrace();
			 }
		 }
		 return Result.OK("批量设置成功!");
	 }


	 @DeleteMapping(value = "/batchHModifyFalse")
	 public Result<String> batchHModifyFalse(@RequestParam(name="ids",required=true) String ids) {
		 String[] split = ids.split(",");
		 for (String sId : split) {
			 try {
				 LinkWeiboPhoneDetection weiboContentCapture = linkWeiboPhoneDetectionService.getById(sId);
				 weiboContentCapture.setIsRevise("1");
				 linkWeiboPhoneDetectionService.updateById(weiboContentCapture);
			 }catch (Exception e){
				 e.printStackTrace();
			 }
		 }
		 return Result.OK("批量设置成功!");
	 }

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

	 @ApiOperation(value="个人信息手机号检测-通过id查询", notes="个人信息手机号检测-通过id查询")
	 @GetMapping(value = "/queryByIdModifyFalse")
	 public Result<LinkWeiboPhoneDetection> queryByIdModifyFalse(@RequestParam(name="id",required=true) String id) {
		 LinkWeiboPhoneDetection linkPersonalPhoneDetection = linkWeiboPhoneDetectionService.getById(id);
		 linkPersonalPhoneDetection.setIsRevise("1");
		 if(linkPersonalPhoneDetection==null) {
			 return Result.error("未找到对应数据");
		 }
		 linkWeiboPhoneDetectionService.updateById(linkPersonalPhoneDetection);
		 return Result.OK(linkPersonalPhoneDetection);
	 }
	 @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>();
		 LinkWeiboPhoneDetection linkPersonalPhoneDetection = linkWeiboPhoneDetectionService.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<LinkWeiboPhoneWhiteList> queryWrapper = new QueryWrapper<LinkWeiboPhoneWhiteList>();
			 queryWrapper.eq("white_content",strPhone);
			 Page<LinkWeiboPhoneWhiteList> page = new Page<LinkWeiboPhoneWhiteList>(1, 1);
			 IPage<LinkWeiboPhoneWhiteList> pageList = iLinkWeiboPhoneWhiteListService.page(page, queryWrapper);
			 List<LinkWeiboPhoneWhiteList> 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) {
		 String weiboId = params.getWeiboId();
		 LinkWeiboPhoneDetection byId = linkWeiboPhoneDetectionService.getById(weiboId);
		 System.out.println(byId);
		 if(!ObjectUtils.isEmpty(params) && weiboId != ""){
			 if(params.getPlainOptions().length > 0){
				 for (String plainOption : params.getPlainOptions()) {
					 QueryWrapper<LinkWeiboPhoneWhiteList> phoneWhiteListQueryWrapper = new QueryWrapper<LinkWeiboPhoneWhiteList>();
					 phoneWhiteListQueryWrapper.eq("white_content",plainOption);
					 try {
						 iLinkWeiboPhoneWhiteListService.remove(phoneWhiteListQueryWrapper);
					 }catch (Exception e){
						 e.printStackTrace();
					 }
				 }
			 }
			 if(params.getCheckedList().length > 0){
				 for (String plainOption : params.getCheckedList()) {
					 LinkWeiboPhoneWhiteList phoneWhiteList = new LinkWeiboPhoneWhiteList();
					 phoneWhiteList.setId(IdWorker.getIdStr());
					 phoneWhiteList.setMainSiteId(byId.getUserId());
					 phoneWhiteList.setMainSiteName(byId.getScreenName());
					 phoneWhiteList.setMainSiteUrl("https://m.weibo.cn/u/"+byId.getUserId());
					 phoneWhiteList.setTenantId(byId.getTenantId()+"");
					 phoneWhiteList.setWhiteContent(plainOption);
					 if(!ObjectUtils.isEmpty(plainOption) && plainOption != ""){
						 try {
							 iLinkWeiboPhoneWhiteListService.save(phoneWhiteList);
						 }catch (Exception e){
							 e.printStackTrace();
						 }
					 }
				 }
			 }
		 }
		 return Result.OK("编辑成功!");
	 }


	 @DeleteMapping(value = "/batchHAddWhitePhone")
	 public Result<String> ignoreAllBatch(@RequestParam(name="ids",required=true) String ids) {
		 String[] split = ids.split(",");
		 if(split.length > 0){
			 for (String id : split) {
				 LinkWeiboPhoneDetection linkWeiboPhoneDetection = linkWeiboPhoneDetectionService.getById(id);
				 String phoneDetectionStrList = linkWeiboPhoneDetection.getStrList();
				 String[] split1 = phoneDetectionStrList.split(",");
				 for (String phone : split1) {
					 QueryWrapper<LinkWeiboPhoneWhiteList> phoneWhiteListQueryWrapper = new QueryWrapper<LinkWeiboPhoneWhiteList>();
					 phoneWhiteListQueryWrapper.eq("white_content",phone);
					 try {
						 iLinkWeiboPhoneWhiteListService.remove(phoneWhiteListQueryWrapper);
					 }catch (Exception e){
						 e.printStackTrace();
					 }
					 LinkWeiboPhoneWhiteList phoneWhiteList = new LinkWeiboPhoneWhiteList();
					 phoneWhiteList.setId(IdWorker.getIdStr());
					 phoneWhiteList.setMainSiteId(linkWeiboPhoneDetection.getUserId());
					 phoneWhiteList.setMainSiteName(linkWeiboPhoneDetection.getScreenName());
					 phoneWhiteList.setMainSiteUrl(linkWeiboPhoneDetection.getUserId());
					 phoneWhiteList.setTenantId(linkWeiboPhoneDetection.getTenantId()+"");
					 phoneWhiteList.setWhiteContent(phone);
					 if(!ObjectUtils.isEmpty(phone) && phone != ""){
						 try {
							 iLinkWeiboPhoneWhiteListService.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) {
		 String[] split = ids.split(",");
		 if(split.length > 0){
			 for (String id : split) {
				 LinkWeiboPhoneDetection linkWeiboPhoneDetection = linkWeiboPhoneDetectionService.getById(id);
				 String phoneDetectionStrList = linkWeiboPhoneDetection.getStrList();
				 String[] split1 = phoneDetectionStrList.split(",");
				 for (String phone : split1) {
					 QueryWrapper<LinkWeiboPhoneWhiteList> phoneWhiteListQueryWrapper = new QueryWrapper<LinkWeiboPhoneWhiteList>();
					 phoneWhiteListQueryWrapper.eq("white_content",phone);
					 try {
						 iLinkWeiboPhoneWhiteListService.remove(phoneWhiteListQueryWrapper);
					 }catch (Exception e){
						 e.printStackTrace();
					 }
				 }
			 }
		 }else{
			 Result.error("没有选择任何内容!");
		 }
		 return Result.OK("编辑成功!");
	 }


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

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


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

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

	 @GetMapping(value = "/onHandleCheckWeiboContentCapture")
	 public Result<String> onHandleCheckWeiboContentCapture(HttpServletRequest request, LinkWeiboPhoneDetection linkWeiboPhoneDetection) {
		 String selections = request.getParameter("selections");
		 QueryWrapper<LinkWeiboPhoneDetection> queryWrapper = QueryGenerator.initQueryWrapper(linkWeiboPhoneDetection, request.getParameterMap());
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 queryWrapper.in("id",selectionList);
			 List<LinkWeiboPhoneDetection> exportList = linkWeiboPhoneDetectionService.list(queryWrapper);
			 checkWeiboContentCapture(exportList);
		 }else{
			 queryWrapper.isNotNull("sensitive_list");
			 queryWrapper.ne("sensitive_list","");
			 queryWrapper.gt("sensitive_count",0);
			 Long count =  linkWeiboPhoneDetectionService.count(queryWrapper);
			 Integer pageSize = 100;
			 Integer pageNum = (int)Math.ceil((double)count/pageSize);
			 for(int i = 1; i <= pageNum;i+=1){
				 Page<LinkWeiboPhoneDetection> page = new Page<LinkWeiboPhoneDetection>(i, pageSize);
				 IPage<LinkWeiboPhoneDetection> pageList = linkWeiboPhoneDetectionService.page(page, queryWrapper);
				 checkWeiboContentCapture(pageList.getRecords());
			 }
		 }
		 return Result.OK("成功");
	 }

	 private void checkWeiboContentCapture(List<LinkWeiboPhoneDetection> records) {

		 for (LinkWeiboPhoneDetection record : records) {
			 String content = record.getContent();
			 String userId = record.getUserId();
			 QueryWrapper<Weibo> weiboQueryWrapper = new QueryWrapper<Weibo>();
			 weiboQueryWrapper.eq("user_id",userId);
			 Page<Weibo> page = new Page<Weibo>(1, 1);
			 IPage<Weibo> pageList = iWeiboService.page(page, weiboQueryWrapper);
			 Weibo weibo = null;
			if(!ObjectUtils.isEmpty(pageList)){
				if(pageList.getRecords().size() >= 1){
					weibo = pageList.getRecords().get(0);
				}
			}
			 WeiboUser weiboUser = iWeiboUserService.getById(userId);
			 if(!ObjectUtils.isEmpty(weibo) && !ObjectUtils.isEmpty(weiboUser)){
				 getPhone(weibo,content,weiboUser);
			}

		 }


	 }

	 public void getPhone(Weibo record, String text, WeiboUser weiboUser){
		 String url = "https://m.weibo.cn/detail/"+record.getId();
		 String WeiboPhoneId = "";
		 //从正文当中提取手机号
		 log.info("============从正文当中提取手机号=================");
		 JsoupReturn phone = spyderUtils.getPhone(text);
		 LinkWeiboPhoneDetection linkWeiboPhoneDetection = new LinkWeiboPhoneDetection();
		 linkWeiboPhoneDetection.setCreateTime(new Date());
		 linkWeiboPhoneDetection.setUpdateTime(new Date());
		 linkWeiboPhoneDetection.setUserId(record.getUserId());
		 WeiboPhoneId += record.getId();
		 linkWeiboPhoneDetection.setScreenName(record.getScreenName());
		 linkWeiboPhoneDetection.setSource(record.getArticleUrl());
		 linkWeiboPhoneDetection.setTitle(record.getScreenName());
		 linkWeiboPhoneDetection.setArticleReleaseTime(record.getCreatedAt());
		 linkWeiboPhoneDetection.setContent(record.getText());
		 linkWeiboPhoneDetection.setRetMsg(phone.getHtml());
		 linkWeiboPhoneDetection.setErrorCount(phone.getHtmlList().size());

		 try {
			 String HtmlListStr = "";
			 List<String> htmlList = phone.getHtmlList();
			 for (String sH : htmlList) {
				 HtmlListStr += sH;
			 }
			 linkWeiboPhoneDetection.setHtmlList(HtmlListStr);
		 }catch (Exception e){
			 e.printStackTrace();
		 }
		 try {
			 String strListStr = "";
			 List<String> strList = phone.getStrList();
			 for (String sH : strList) {
				 strListStr += sH;
			 }
			 linkWeiboPhoneDetection.setStrList(strListStr);
		 }catch (Exception e){
			 e.printStackTrace();
		 }
		 try {
			 String strListA = "";
			 List<String> strList = phone.getAList();
			 for (String sH : strList) {
				 strListA += sH;
			 }
			 linkWeiboPhoneDetection.setAhtmlList(strListA);
		 }catch (Exception e){
			 e.printStackTrace();
		 }
		 linkWeiboPhoneDetection.setIsInvalid("2");
		 linkWeiboPhoneDetection.setIsRevise("1");
		 linkWeiboPhoneDetection.setIsIgnore("2");
		 linkWeiboPhoneDetection.setCheckTime(new Date());
		 linkWeiboPhoneDetection.setCheckState("1");
		 linkWeiboPhoneDetection.setNumberScans(1);
		 linkWeiboPhoneDetection.setTenantId(record.getTenantId()+"");
		 linkWeiboPhoneDetection.setId(WeiboPhoneId);
		 String idWeiboPhone = linkWeiboPhoneDetection.getId();
		 LinkWeiboPhoneDetection byIdWeiboPhoneDetection = linkWeiboPhoneDetectionService.getById(idWeiboPhone);
		 if(!ObjectUtils.isEmpty(byIdWeiboPhoneDetection)){
			 linkWeiboPhoneDetection.setIsInvalid(byIdWeiboPhoneDetection.getIsInvalid());
			 linkWeiboPhoneDetection.setIsRevise(byIdWeiboPhoneDetection.getIsRevise());
			 linkWeiboPhoneDetection.setIsIgnore(byIdWeiboPhoneDetection.getIsIgnore());
			 linkWeiboPhoneDetection.setCheckTime(new Date());
			 linkWeiboPhoneDetection.setCheckState(byIdWeiboPhoneDetection.getCheckState());
			 Integer numberScans = byIdWeiboPhoneDetection.getNumberScans();
			 if(!ObjectUtils.isEmpty(numberScans)){
				 linkWeiboPhoneDetection.setNumberScans( 1 + numberScans);
			 }
		 }
		 linkWeiboPhoneDetection.setSource(url);
		 if(phone.getAList().size() > 0){
			 linkWeiboPhoneDetectionService.saveOrUpdate(linkWeiboPhoneDetection);
		 }
		 //统计手机号信息
		 try {
			 savePhoneStatistics("1",weiboUser);
		 }catch (Exception e){
			 e.printStackTrace();
		 }
	 }

	 public void savePhoneStatistics(String type,WeiboUser weiboUser){
		 try {
			 LinkWeiboPhoneDetectionStatistics weiboPhoneDetectionStatistics = new LinkWeiboPhoneDetectionStatistics();
			 weiboPhoneDetectionStatistics.setId(IdWorker.getIdStr());
			 weiboPhoneDetectionStatistics.setUserId(weiboUser.getId());
			 weiboPhoneDetectionStatistics.setScreenName(weiboUser.getScreenName());
			 weiboPhoneDetectionStatistics.setTestType(type);
			 weiboPhoneDetectionStatistics.setScanTime(new Date());
			 weiboPhoneDetectionStatistics.setTenantId(weiboUser.getTenantId());
			 Integer sumAll  = linkWeiboPhoneDetectionService.getSumStatistics(weiboUser.getId());
			 if(ObjectUtils.isEmpty(sumAll)){
				 sumAll = 0;
			 }
			 weiboPhoneDetectionStatistics.setPersonalPhoneCount(sumAll);

			 iLinkWeiboPhoneDetectionStatisticsService.save(weiboPhoneDetectionStatistics);
		 }catch (Exception e){
		 }
	 }
 }
