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

import java.util.*;
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.externalinternalsite.service.IExternalInternalSiteService;
import org.jeecg.modules.demo.linkanchorlist.entity.LinkAnchorList;
import org.jeecg.modules.demo.linkanchorlist.service.ILinkAnchorListService;
import org.jeecg.modules.demo.linkpersonalbankcarddetection.entity.LinkPersonalBankCardDetection;
import org.jeecg.modules.demo.linkpersonalbankcarddetection.entity.LinkPersonalBankCardDetectionVo;
import org.jeecg.modules.demo.linkpersonalbankcarddetection.service.ILinkPersonalBankCardDetectionService;

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.linkpersonalbankcarddetection.service.ILinkPersonalBankCardDetectionVoService;
import org.jeecg.modules.demo.linkpersonalbankcardwhitelist.entity.LinkPersonalBankCardWhiteList;
import org.jeecg.modules.demo.linkpersonalbankcardwhitelist.service.ILinkPersonalBankCardWhiteListService;
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-23
 * @Version: V1.0
 */
@Api(tags="个人信息银行卡号检测")
@RestController
@RequestMapping("/linkpersonalbankcarddetection/linkPersonalBankCardDetection")
@Slf4j
public class LinkPersonalBankCardDetectionController extends JeecgController<LinkPersonalBankCardDetection, ILinkPersonalBankCardDetectionService> {
	@Autowired
	private ILinkPersonalBankCardDetectionService linkPersonalBankCardDetectionService;

	 @Autowired
	 private CrawlingPhoneIdNumberCardNumber crawlingPhoneIdNumberCardNumber;

	 @Autowired
	 private ILinkAnchorListService iLinkAnchorListService;

	 @Autowired
	 private IMainSiteService iMainSiteService;

	 @Autowired
	 private IPageContentCaptureService iPageContentCaptureService;

	 @Autowired
	 private IExternalInternalSiteService externalInternalSiteService;

	 @Autowired
	 private TrendsSpyder trendsSpyder;

	 @Autowired
	 private JsoupUtils jsoupUtils;

	 @Autowired
	 private CrawlingUtils crawlingUtils;

	 @Autowired
	 private FangCunUtils fangCunUtils;

	 @Autowired
	 private LinkOrWordSaveUtils linkOrWordSaveUtils;

	 @Autowired
	 private ILinkPersonalBankCardWhiteListService iLinkPersonalBankCardWhiteListService;

	 @Autowired
	 private ILinkPersonalBankCardDetectionVoService iLinkPersonalBankCardDetectionVoService;

	 @Data
	 class PageContentCaptureTrueOrFalse{
		 private String wordName;
		 private String wordValue;
		 private boolean flag;
	 }

	 @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<LinkPersonalBankCardWhiteList> bankCardWhiteListQueryWrapper = new QueryWrapper<LinkPersonalBankCardWhiteList>();
				 bankCardWhiteListQueryWrapper.eq("white_content",plainOption);
				 try {
					 iLinkPersonalBankCardWhiteListService.remove(bankCardWhiteListQueryWrapper);
				 }catch (Exception e){
					 e.printStackTrace();
				 }
			 }
		 }
		 if(!ObjectUtils.isEmpty(mainSite) && params.getCheckedList().length > 0){
			 for (String plainOption : params.getCheckedList()) {
				 LinkPersonalBankCardWhiteList linkPersonalBankCardWhiteList = new LinkPersonalBankCardWhiteList();
				 linkPersonalBankCardWhiteList.setId(IdWorker.getIdStr());
				 linkPersonalBankCardWhiteList.setMainSiteId(mainSite.getId());
				 linkPersonalBankCardWhiteList.setMainSiteName(mainSite.getMainSiteName());
				 linkPersonalBankCardWhiteList.setMainSiteUrl(mainSite.getMainSiteUrl());
				 linkPersonalBankCardWhiteList.setTenantId(mainSite.getTenantId()+"");
				 linkPersonalBankCardWhiteList.setWhiteContent(plainOption);
				 if(!ObjectUtils.isEmpty(plainOption) && plainOption != ""){
					 try {
						 iLinkPersonalBankCardWhiteListService.save(linkPersonalBankCardWhiteList);
					 }catch (Exception e){
						 e.printStackTrace();
					 }
				 }
			 }
		 }
		 return Result.OK("编辑成功!");
	 }





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


	 @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) {
				 LinkPersonalBankCardDetection linkPersonalBankCardDetection = linkPersonalBankCardDetectionService.getById(id);
				 String bankCardDetectionStrList = linkPersonalBankCardDetection.getStrList();
				 String[] split1 = bankCardDetectionStrList.split(",");
				 for (String phone : split1) {
					 QueryWrapper<LinkPersonalBankCardWhiteList> bankCardWhiteListQueryWrapper = new QueryWrapper<LinkPersonalBankCardWhiteList>();
					 bankCardWhiteListQueryWrapper.eq("white_content",phone);
					 try {
						 iLinkPersonalBankCardWhiteListService.remove(bankCardWhiteListQueryWrapper);
					 }catch (Exception e){
						 e.printStackTrace();
					 }
					 LinkPersonalBankCardWhiteList bankCardWhiteList = new LinkPersonalBankCardWhiteList();
					 bankCardWhiteList.setId(IdWorker.getIdStr());
					 bankCardWhiteList.setMainSiteId(mainSite.getId());
					 bankCardWhiteList.setMainSiteName(mainSite.getMainSiteName());
					 bankCardWhiteList.setMainSiteUrl(mainSite.getMainSiteUrl());
					 bankCardWhiteList.setTenantId(mainSite.getTenantId()+"");
					 bankCardWhiteList.setWhiteContent(phone);
					 if(!ObjectUtils.isEmpty(phone) && phone != ""){
						 try {
							 iLinkPersonalBankCardWhiteListService.save(bankCardWhiteList);
						 }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) {
				 LinkPersonalBankCardDetection linkPersonalBankCardDetection = linkPersonalBankCardDetectionService.getById(id);
				 String phoneDetectionStrList = linkPersonalBankCardDetection.getStrList();
				 String[] split1 = phoneDetectionStrList.split(",");
				 for (String phone : split1) {
					 QueryWrapper<LinkPersonalBankCardWhiteList> bankCardWhiteListQueryWrapper = new QueryWrapper<LinkPersonalBankCardWhiteList>();
					 bankCardWhiteListQueryWrapper.eq("white_content",phone);
					 try {
						 iLinkPersonalBankCardWhiteListService.remove(bankCardWhiteListQueryWrapper);
					 }catch (Exception e){
						 e.printStackTrace();
					 }
				 }
			 }
		 }else{
			 Result.error("没有选择任何内容!");
		 }
		 return Result.OK("编辑成功!");
	 }


	 @RequestMapping(value = "/onHandleSpyderCheck")
	 public Result<String> onHandleSpyderCheck(HttpServletRequest request, LinkPersonalBankCardDetection linkPersonalBankCardDetection) {
		 String selections = request.getParameter("selections");
		 QueryWrapper<LinkPersonalBankCardDetection> queryWrapper = QueryGenerator.initQueryWrapper(linkPersonalBankCardDetection, request.getParameterMap());
		 if (oConvertUtils.isNotEmpty(selections)) {
			 List<String> selectionList = Arrays.asList(selections.split(","));
			 queryWrapper.in("id",selectionList);
			 List<LinkPersonalBankCardDetection> exportList = linkPersonalBankCardDetectionService.list(queryWrapper);
			 checkBankCard(exportList);
		 }else{
			 queryWrapper.eq("is_ignore","2");
			 //只统计错链
			 Long count =  linkPersonalBankCardDetectionService.count();
			 Integer pageSize = 100;
			 Integer pageNum = (int)Math.ceil((double)count/pageSize);
			 for(int i = 1; i <= pageNum;i+=1){
				 Page<LinkPersonalBankCardDetection> page = new Page<LinkPersonalBankCardDetection>(i, pageSize);
				 IPage<LinkPersonalBankCardDetection> pageList = linkPersonalBankCardDetectionService.page(page, queryWrapper);
				 checkBankCard(pageList.getRecords());
			 }
		 }
		 try {
			 // 统计数据
			 List<MainSite> list = iMainSiteService.list();
			 for (MainSite mainSite : list) {
				 crawlingPhoneIdNumberCardNumber.saveLinkPersonalBankCardDetectionStatistics(mainSite.getId(),mainSite.getMainSiteName(),mainSite.getMainSiteUrl(),mainSite.getTenantId()+"","2");
			 }
		 }catch (Exception e){
			 e.printStackTrace();
		 }
		 return Result.OK("成功");
	 }

	 private void checkBankCard(List<LinkPersonalBankCardDetection> linkPersonalBankCardDetections) {
		 for (LinkPersonalBankCardDetection linkPersonalBankCardDetection : linkPersonalBankCardDetections) {
			 crawlingPhoneIdNumberCardNumber.crawlingCheckBankCard(
					 linkPersonalBankCardDetection
			 );
		 }
	 }


	 @ApiOperation(value="页面抓取以及错敏词校验", notes="页面抓取以及错敏词校验-分页列表查询")
	 @GetMapping(value = "/listCrawling")
	 public Result<String> queryPageListCrawling(
	 ) throws Exception {
		 //如果没有选择任何内容，对所有内容进行校验
		 List<MainSite> list = iMainSiteService.list();
		 for (MainSite mainSite : list) {
			 crawlingContentCapture(mainSite);
			 crawlingPhoneIdNumberCardNumber.saveLinkPersonalBankCardDetectionStatistics(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 sStr = randUrl();
					 record.setSource(sStr);
					 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.crawlingBankCard(
								 mainSite.getId(),
								 mainSite.getMainSiteName(),
								 mainSite.getMainSiteUrl(),
								 pageContentCapture.getSource(),
								 pageContentCapture.getTitle(),
								 pageContentCapture.getArticleReleaseTime(),
								 pageContentCapture.getContent(),
								 pageContentCapture.getIsInvalid(),
								 String.valueOf(pageContentCapture.getTenantId())
						 );
					 }
				 }
			 }
		 }
	 }


	 public String randUrl(){
		 String url[]= {
				 "http://192.168.1.5/a1/index.html" ,
				 "http://192.168.1.5/b1/index.html" ,
				 "http://192.168.1.5/c1/index.html" ,
				 "http://192.168.1.5/d1/index.html" ,
				 "http://192.168.1.5/e1/index.html" ,
				 "http://192.168.1.5/f1/index.html" ,
				 "http://192.168.1.5/g1/index.html" ,
				 "http://192.168.1.5/h1/index.html" ,
				 "http://192.168.1.5/i1/index.html" ,
				 "http://192.168.1.5/f1/index.html" ,
				 "http://192.168.1.5/j1/index.html" ,
		 };
		 Random random = new Random();
		 int i = random.nextInt(url.length);
		 return url[i];
	 }
	/**
	 * 分页列表查询
	 *
	 * @param linkPersonalBankCardDetection
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	//@AutoLog(value = "个人信息银行卡号检测-分页列表查询")
	@ApiOperation(value="个人信息银行卡号检测-分页列表查询", notes="个人信息银行卡号检测-分页列表查询")
	@GetMapping(value = "/list")
	public Result<IPage<LinkPersonalBankCardDetection>> queryPageList(LinkPersonalBankCardDetection linkPersonalBankCardDetection,
								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								   HttpServletRequest req) {
		QueryWrapper<LinkPersonalBankCardDetection> queryWrapper = QueryGenerator.initQueryWrapper(linkPersonalBankCardDetection, req.getParameterMap());
		Page<LinkPersonalBankCardDetection> page = new Page<LinkPersonalBankCardDetection>(pageNo, pageSize);
		IPage<LinkPersonalBankCardDetection> pageList = linkPersonalBankCardDetectionService.page(page, queryWrapper);
		for (LinkPersonalBankCardDetection 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);
	}
	 //@AutoLog(value = "个人信息银行卡号检测-分页列表查询")
	 @ApiOperation(value="个人信息银行卡号检测-分页列表查询", notes="个人信息银行卡号检测-分页列表查询")
	 @GetMapping(value = "/listVo")
	 public Result<IPage<LinkPersonalBankCardDetectionVo>> queryPageListVo(LinkPersonalBankCardDetectionVo linkPersonalBankCardDetectionVo,
																		   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
																		   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
																		   HttpServletRequest req) {
		 QueryWrapper<LinkPersonalBankCardDetectionVo> queryWrapper = QueryGenerator.initQueryWrapper(linkPersonalBankCardDetectionVo, req.getParameterMap());
		 Page<LinkPersonalBankCardDetectionVo> page = new Page<LinkPersonalBankCardDetectionVo>(pageNo, pageSize);
		 IPage<LinkPersonalBankCardDetectionVo> pageList = iLinkPersonalBankCardDetectionVoService.page(page, queryWrapper);
		 for (LinkPersonalBankCardDetectionVo 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);
	 }

	 /**
	 *   添加
	 *
	 * @param linkPersonalBankCardDetection
	 * @return
	 */
	@AutoLog(value = "个人信息银行卡号检测-添加")
	@ApiOperation(value="个人信息银行卡号检测-添加", notes="个人信息银行卡号检测-添加")
	@RequiresPermissions("linkpersonalbankcarddetection:link_personal_bank_card_detection:add")
	@PostMapping(value = "/add")
	public Result<String> add(@RequestBody LinkPersonalBankCardDetection linkPersonalBankCardDetection) {
		linkPersonalBankCardDetectionService.save(linkPersonalBankCardDetection);
		return Result.OK("添加成功！");
	}
	
	/**
	 *  编辑
	 *
	 * @param linkPersonalBankCardDetection
	 * @return
	 */
	@AutoLog(value = "个人信息银行卡号检测-编辑")
	@ApiOperation(value="个人信息银行卡号检测-编辑", notes="个人信息银行卡号检测-编辑")
	@RequiresPermissions("linkpersonalbankcarddetection:link_personal_bank_card_detection:edit")
	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
	public Result<String> edit(@RequestBody LinkPersonalBankCardDetection linkPersonalBankCardDetection) {
		linkPersonalBankCardDetectionService.updateById(linkPersonalBankCardDetection);
		return Result.OK("编辑成功!");
	}
	
	/**
	 *   通过id删除
	 *
	 * @param id
	 * @return
	 */
	@AutoLog(value = "个人信息银行卡号检测-通过id删除")
	@ApiOperation(value="个人信息银行卡号检测-通过id删除", notes="个人信息银行卡号检测-通过id删除")
	@RequiresPermissions("linkpersonalbankcarddetection:link_personal_bank_card_detection:delete")
	@DeleteMapping(value = "/delete")
	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
		linkPersonalBankCardDetectionService.removeById(id);
		return Result.OK("删除成功!");
	}
	
	/**
	 *  批量删除
	 *
	 * @param ids
	 * @return
	 */
	@AutoLog(value = "个人信息银行卡号检测-批量删除")
	@ApiOperation(value="个人信息银行卡号检测-批量删除", notes="个人信息银行卡号检测-批量删除")
	@RequiresPermissions("linkpersonalbankcarddetection:link_personal_bank_card_detection:deleteBatch")
	@DeleteMapping(value = "/deleteBatch")
	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
		this.linkPersonalBankCardDetectionService.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<LinkPersonalBankCardDetection> queryById(@RequestParam(name="id",required=true) String id) {
		LinkPersonalBankCardDetection linkPersonalBankCardDetection = linkPersonalBankCardDetectionService.getById(id);
		if(linkPersonalBankCardDetection==null) {
			return Result.error("未找到对应数据");
		}
		return Result.OK(linkPersonalBankCardDetection);
	}

    /**
    * 导出excel
    *
    * @param request
    * @param linkPersonalBankCardDetection
    */
    @RequiresPermissions("linkpersonalbankcarddetection:link_personal_bank_card_detection:exportXls")
    @RequestMapping(value = "/exportXls")
    public ModelAndView exportXls(HttpServletRequest request, LinkPersonalBankCardDetection linkPersonalBankCardDetection) {
        return super.exportXls(request, linkPersonalBankCardDetection, LinkPersonalBankCardDetection.class, "个人信息银行卡号检测");
    }

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


	 @GetMapping(value = "/queryByIdModifyTrue")
	 public Result<LinkPersonalBankCardDetection> queryByIdModifyTrue(@RequestParam(name="id",required=true) String id) {
		 LinkPersonalBankCardDetection linkPersonalBankCardDetection = linkPersonalBankCardDetectionService.getById(id);
		 linkPersonalBankCardDetection.setIsRevise("2");
		 if(linkPersonalBankCardDetection==null) {
			 return Result.error("未找到对应数据");
		 }
		 linkPersonalBankCardDetectionService.updateById(linkPersonalBankCardDetection);
		 return Result.OK(linkPersonalBankCardDetection);
	 }

	 @GetMapping(value = "/queryByIdModifyFalse")
	 public Result<LinkPersonalBankCardDetection> queryByIdModifyFalse(@RequestParam(name="id",required=true) String id) {
		 LinkPersonalBankCardDetection linkPersonalBankCardDetection = linkPersonalBankCardDetectionService.getById(id);
		 linkPersonalBankCardDetection.setIsRevise("1");
		 if(linkPersonalBankCardDetection==null) {
			 return Result.error("未找到对应数据");
		 }
		 linkPersonalBankCardDetectionService.updateById(linkPersonalBankCardDetection);
		 return Result.OK(linkPersonalBankCardDetection);
	 }

	 @GetMapping(value = "/queryByIdIgnoreTrue")
	 public Result<LinkPersonalBankCardDetection> queryByIdIgnoreTrue(@RequestParam(name="id",required=true) String id) {
		 LinkPersonalBankCardDetection linkPersonalBankCardDetection = linkPersonalBankCardDetectionService.getById(id);
		 linkPersonalBankCardDetection.setIsIgnore("1");
		 if(linkPersonalBankCardDetection==null) {
			 return Result.error("未找到对应数据");
		 }
		 linkPersonalBankCardDetectionService.updateById(linkPersonalBankCardDetection);
		 return Result.OK(linkPersonalBankCardDetection);
	 }

	 @GetMapping(value = "/queryByIdIgnoreFalse")
	 public Result<LinkPersonalBankCardDetection> queryByIdIgnoreFalse(@RequestParam(name="id",required=true) String id) {
		 LinkPersonalBankCardDetection linkPersonalBankCardDetection = linkPersonalBankCardDetectionService.getById(id);
		 linkPersonalBankCardDetection.setIsIgnore("2");
		 if(linkPersonalBankCardDetection==null) {
			 return Result.error("未找到对应数据");
		 }
		 linkPersonalBankCardDetectionService.updateById(linkPersonalBankCardDetection);
		 return Result.OK(linkPersonalBankCardDetection);
	 }



	 @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 {
					 LinkPersonalBankCardDetection byId = linkPersonalBankCardDetectionService.getById(id);
					 byId.setIsRevise("2");
					 linkPersonalBankCardDetectionService.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 {
					 LinkPersonalBankCardDetection byId = linkPersonalBankCardDetectionService.getById(id);
					 byId.setIsRevise("1");
					 linkPersonalBankCardDetectionService.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 {
					 LinkPersonalBankCardDetection byId = linkPersonalBankCardDetectionService.getById(id);
					 byId.setIsIgnore("1");
					 linkPersonalBankCardDetectionService.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 {
					 LinkPersonalBankCardDetection byId = linkPersonalBankCardDetectionService.getById(id);
					 byId.setIsIgnore("2");
					 linkPersonalBankCardDetectionService.updateById(byId);
				 }catch (Exception e){
					 e.printStackTrace();
				 }
			 }
		 }
		 return Result.OK("编辑成功!");
	 }
 }
