package com.chinaweal.aiccs.aiccs.abnormal.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chinaweal.aiccs.aiccs.abnormal.entity.TSAbnList;
import com.chinaweal.aiccs.aiccs.abnormal.entity.TSBizRemList;
import com.chinaweal.aiccs.aiccs.abnormal.entity.TSBizSpeList;
import com.chinaweal.aiccs.aiccs.abnormal.entity.TSWrit;
import com.chinaweal.aiccs.aiccs.abnormal.service.*;
import com.chinaweal.aiccs.aiccs.auditing.entity.TSOpinion;
import com.chinaweal.aiccs.aiccs.auditing.service.TSOpinionService;
import com.chinaweal.aiccs.aiccs.business.entity.TSTaskList;
import com.chinaweal.aiccs.aiccs.business.service.TSTaskListService;
import com.chinaweal.aiccs.aiccs.system.entity.TRBaseCode;
import com.chinaweal.aiccs.aiccs.system.service.TRBaseCodeService;
import com.chinaweal.aiccs.aiceps.annual.entity.TREntBaseInfoSplit;
import com.chinaweal.aiccs.aiceps.annual.service.TREntBaseInfoSplitService;
import com.chinaweal.aiccs.common.base.controller.BaseController;
import com.chinaweal.aiccs.common.constant.Constant;
import com.chinaweal.aiccs.common.util.*;
import com.chinaweal.aiccs.crgs.moveinDetails.entity.EAlterRecoder;
import com.chinaweal.aiccs.crgs.moveinDetails.entity.EGtAlterRecoder;
import com.chinaweal.aiccs.crgs.moveinDetails.service.EAlterRecoderService;
import com.chinaweal.aiccs.crgs.moveinDetails.service.EGtAlterRecoderService;
import com.chinaweal.aicorg.model.AICUser;
import com.chinaweal.youfool.framework.springboot.exception.custom.BusinessException;
import com.chinaweal.youfool.framework.springboot.mybatis.plus.page.PageRequestDto;
import com.chinaweal.youfool.framework.springboot.rest.RestResult;
import com.chinaweal.youfool.framework.springboot.util.AssertUtils;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.collections.CollectionUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.io.ByteArrayOutputStream;
import java.lang.reflect.Method;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;

/**
 * @author <a href="https://blog.lroyia.top">lroyia</a>
 * @since 2021/1/26 15:05
 **/
@RestController
@RequestMapping("/abnList")
public class AbnListController extends BaseController {
    @Autowired
    private TSAbnListService tsAbnListService;
    @Autowired
    private TSTaskListService taskListService;
    @Autowired
    private TSBizSpeListService tsBizSpeListService;
    @Autowired
    private TSOpinionService opinionService;
    @Autowired
    private TSWritService tsWritService;
    @Autowired
    private TRBaseCodeService baseCodeService;
    @Autowired
    private TSBizRemListService tsBizRemListService;
    @Lazy
    @Autowired
    private IGzaiccodeService gzaiccodeService;
    @Autowired
    private TREntBaseInfoSplitService trEntBaseInfoSplitService;
    @Autowired
    private EGtAlterRecoderService eGtAlterRecoderService;
    @Autowired
    private EAlterRecoderService eAlterRecoderService;


    /**
     * 异常名录 文书打印查询
     */
    @RequestMapping(value = "/searchab_tstaskList2.do", method = RequestMethod.POST)
    @ResponseBody
    public RestResult<?> searchabTstaskList2(HttpServletRequest request,
                                              TSTaskList tsTaskListModel, int rows, int page) {
//        AICUser aicUser = (AICUser) request.getSession().getAttribute(ConstantsUtil.USER_SESSION_NAME);
        AICUser aicUser = getLoginUser(request);
        if(aicUser==null) throw new BusinessException("登录超时，请重新登录");
        String decorg = aicUser.getRegionID();//只查 本机构做出决定的记录
        String flag = "abnormal";//标识 区分严重违法失信
        IPage<TSTaskList> tsTaskListModelDataGrid = taskListService.searchTstaskByPage(new Page<>(page, rows), tsTaskListModel, flag, decorg);
        return RestResult.ok(tsTaskListModelDataGrid);
    }

    /**
     * 异常名录 异议查询
     */
    @RequestMapping(value = "/selectTSAbnList.do", method = RequestMethod.POST)
    @ResponseBody
    public RestResult<?> selectTSAbnList(HttpServletRequest request, TSAbnList tsAbnListModel,
                                               int rows, int page, String entertype) {
        AICUser aicUser = getLoginUser(request);
        if(aicUser==null) throw new BusinessException("登录超时，请重新登录");
        if(StringUtils.isNotBlank(aicUser.getRegionID())){//只查询属于本机构做出决定的 异常名录主体
            tsAbnListModel.setIntoDecorg(aicUser.getRegionID());
        }
        IPage<TSAbnList> tsEntBaseModelDataGrid = tsAbnListService.selectTSAbnByPageList(new Page<>(page, rows), tsAbnListModel, entertype);
        return RestResult.ok(tsEntBaseModelDataGrid);
    }

    /**
     * 异常名录统计 查询
     */
    @RequestMapping(value = "/removeselectbnlist.do")
    public RestResult<?> removeselectbnlist(HttpServletRequest request,TSAbnList tsAbnListModel, int rows, int page, String entertype) {
        AICUser aicUser = getLoginUser(request);
        if(aicUser==null) throw new BusinessException("登录超时，请重新登录");
        /*2018-11-06前端已有选择本机构及以下的机构*/
//        if(!WebUtil.isEmpty(aicUser.getRegionID())){//只统计属于本机构做出决定的 异常名录主体
//            tsAbnListModel.setDecorg(aicUser.getRegionID());
//        }
        return RestResult.ok(tsAbnListService.removeselectByPagebnlist(new Page<>(page, rows), tsAbnListModel, entertype));
    }

    /**
     * 打印文书页面
     */
    @RequestMapping(value = "/printTSWrit.do")
    public RestResult<?> printTSWrit(Model model, String printstatus, TSBizSpeList tsBizSpeListModel, String workflowid){
        //获取当前时间
        Calendar ca = Calendar.getInstance();
        Map<String, Object> resultMap = new HashMap<>();
        if (printstatus.equals("1")) {
            tsBizSpeListModel = tsBizSpeListService.getById(tsBizSpeListModel.getSpelistid());
            TSWrit writQueryModel = new TSWrit();//文书号
            writQueryModel.setWritstype(WorkNoUtil.WORKNOTYPE_11);
            writQueryModel.setPripid(tsBizSpeListModel.getPripid());
            writQueryModel.setBizseq(tsBizSpeListModel.getBizseq());
            List<TSWrit> tsWritQueryModels = tsWritService.listTswrit(writQueryModel);
            if (CollectionUtils.isNotEmpty(tsWritQueryModels)) {
                resultMap.put("wrirsno", tsWritQueryModels.get(0).getWritsno());
            }
            resultMap.put("specause", tsBizSpeListModel.getSpecausestring());
            resultMap.put("tsBizSpeListModel", tsBizSpeListModel);
            resultMap.put("ReconsiderationOrg", tsBizSpeListModel.getReconsiderationOrg());
//            resultMap.put("LitiOrg", tsBizSpeListModel.getLitiOrg());
            resultMap.put("nowTime", ca.getTime());
            return RestResult.ok(resultMap);

         } else if (printstatus.equals("3")) {
            TSTaskList taskListModel = taskListService.selectByWorkflowID(workflowid);
            StringBuilder regno = new StringBuilder();
            StringBuilder ename = new StringBuilder();
            TSBizSpeList paramModel =new TSBizSpeList();
            paramModel.setBizseq(taskListModel.getBizseqid());
            List<TSBizSpeList> list = tsBizSpeListService.selectBSPexptlist(paramModel);
            if (CollectionUtils.size(list) > 5) {
                for (TSBizSpeList tsBizSpeListModel1 : list) {
                    if (StringUtils.isNotBlank(regno)) {
                        regno.append(",");
                    }
                    regno.append(tsBizSpeListModel1.getRegno());
                    if (StringUtils.isNotBlank(ename)) {
                        ename.append(",");
                    }
                    ename.append(tsBizSpeListModel1.getEntname());
                }
                regno.append("等");
                ename.append("等");
            } else {
                for (TSBizSpeList tsBizSpeListModel1 : list) {
                    if (StringUtils.isNotBlank(regno)) {
                        regno.append(",");
                    }
                    regno.append(tsBizSpeListModel1.getRegno());
                    if (StringUtils.isNotBlank(ename)) {
                        ename.append(",");
                    }
                    ename.append(tsBizSpeListModel1.getEntname());
                }
            }
            List<TSOpinion> opinionList = opinionService.selectByAuditingID(workflowid);
            resultMap.put("opinionList", opinionList);
            resultMap.put("regno", regno);
            resultMap.put("ename", ename);
            resultMap.put("spereasons", list.get(0).getSpereasons());
            resultMap.put("ReconsiderationOrg", list.get(0).getReconsiderationOrg());
            resultMap.put("GovernmentOrg", list.get(0).getGovernmentOrg());
            resultMap.put("LitiOrg", list.get(0).getLitiOrg());
            resultMap.put("list",list);
            return RestResult.ok(resultMap);
        }
        return RestResult.ok(resultMap);
    }


    @RequestMapping("/exportExcplistGetUp.do")
    public RestResult<?> exportGetUp(HttpServletRequest request, String regno, String entname, String abntime, String entertype,
                                              String endabntime, String specause, String decorg, @RequestHeader("User-Agent") String userAgent) throws Exception {

        AICUser userInfo = getLoginUser(request);

        int tempStart = StringUtils.isBlank(request.getParameter("formMap[start]"))?0:Integer.valueOf(request.getParameter("formMap[start]"));
        int tempEnd = StringUtils.isBlank(request.getParameter("formMap[end]"))?0:Integer.valueOf(request.getParameter("formMap[end]"));
        int total = StringUtils.isBlank(request.getParameter("formMap[total]"))?0:Integer.valueOf(request.getParameter("formMap[total]"));


        /*导出项*/
        String property = request.getParameter("formMap[propertys]");
        String[] propertys = property.split(",");
        /*导出数据*/
        List<TSAbnList> result;
        // 获取字段描述信息
        Map<String, String> fieldmap = ExportUtils.getExportFieldExptList();

        TSAbnList abnListModel = new TSAbnList();
        if(StringUtils.isNotBlank(regno)){
            abnListModel.setRegno(regno);
        }
        if(StringUtils.isNotBlank(entname)){
            abnListModel.setEntname(entname);
        }
        if(StringUtils.isNotBlank(abntime)){
            abnListModel.setAbntime(LocalDate.parse(abntime, DateTimeFormatter.ofPattern(DateUtils.DATE_DEFAULT_FORMAT)));
        }
        if(StringUtils.isNotBlank(endabntime)){
            abnListModel.setEndabntime(LocalDate.parse(endabntime, DateTimeFormatter.ofPattern(DateUtils.DATE_DEFAULT_FORMAT)));
        }
        if(StringUtils.isNotBlank(specause)){
            abnListModel.setSpecause(specause);
        }
        if(StringUtils.isNotBlank(decorg)){
            abnListModel.setIntoDecorg(decorg);
        }

        IPage<TSAbnList> tempLists = tsAbnListService.removeselectByPagebnlist(new Page<>(1, total), abnListModel, entertype);

        if(tempLists != null){
            result = tempLists.getRecords();
        }else {
            return null;
        }
        result = result.subList(tempStart-1,tempEnd);

        String sheetInfo = null;
        if ("enterprise".equals(entertype)) {
            sheetInfo = "企业经营异常名录统计信息导出";
        }
        if ("individual".equals(entertype)) {
            sheetInfo = "个体工商户经营异常名录统计信息导出";
        }
        if ("farmer".equals(entertype)){
            sheetInfo = "农民专业合作社经营异常名录统计信息导出";
        }
        try(ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
            /**导出数据到Excel*/
            HSSFWorkbook workbook = new HSSFWorkbook();
            // sheet页命名赋值
            HSSFSheet excel = workbook.createSheet(sheetInfo);
            /**表头行*/
            HSSFRow headrow = excel.createRow(0);
            /**设置表头*/
            for (int i = 0; i < propertys.length; i++) {
                String pro = propertys[i];
                HSSFCell cell = headrow.createCell(i);
                cell.setCellValue(fieldmap.get(pro));
            }
            /**填值*/
            for (int i = 0; i < result.size(); i++) {
                TSAbnList model = result.get(i);
                HSSFRow row = excel.createRow(i + 1);
                for (int j = 0; j < propertys.length; j++) {
                    HSSFCell cell = row.createCell(j);
                    String pro = propertys[j];
                    // 数据库存的编码转换页面上显示的内容
                    if("enttype".equals(pro)){
                        pro += "String";
                    }
                    if ("enterprise".equals(entertype)) {
                        if ("specause".equals(pro)|| "remexcpres".equals(pro)) {
                            pro += "Enter";
                        }
                    }
                    if ("farmer".equals(entertype)){
                        if ("specause".equals(pro)|| "remexcpres".equals(pro)) {
                            pro += "Farmer";
                        }
                    }
                    if ("individual".equals(entertype)) {
                        if ("specause".equals(pro)|| "remexcpres".equals(pro)) {
                            pro += "Individual";
                        }
                    }
                    String methodString = "get" + pro.replaceFirst(pro.substring(0, 1), pro.substring(0, 1).toUpperCase());
                    Method method = model.getClass().getMethod(methodString);
                    Object value = method.invoke(model);
                    if(value instanceof Date){
                        String datetString = DateUtils.getDateFormat((Date)value,DateUtils.DATE_DEFAULT_FORMAT);
                        cell.setCellValue(datetString);
                    } else{
                        cell.setCellValue(value != null ? value.toString() : "");
                    }
                }
            }
            String fileName = ExportUtils.createFileNmae("xls");
            workbook.write(bos);
            byte[] bytes = bos.toByteArray();
            fileName = WebUtil.encodeDownloadFileName(WebUtil.isMSIE(userAgent), fileName);
            HttpHeaders headers = new HttpHeaders();
            request.getSession().setAttribute("isFinished", "true");
            headers.setContentDispositionFormData("attachment", fileName);
            headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
//            return new ResponseEntity<byte[]>(bytes, headers, HttpStatus.OK);
            return OK;
        }
        /*int size=50000;
        int page=(tempEnd-tempStart)/size+1;
        if(property!=null&&tempEnd!=0&&total!=0){
            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
            ZipOutputStream zipOutputStream=null;
            response.setContentType("application/octet-stream");
            response.setHeader("content-disposition", "attachment;filename=" + URLEncoder.encode(sdf.format(new Date()) +".zip", "UTF-8"));
            zipOutputStream=new ZipOutputStream(response.getOutputStream());
            for(int i=1;i<=page;i++){
                int start=(i-1)*size+tempStart;
                int end=start+size>tempEnd?(tempEnd+1):start+size;
                List<String> headInfo= Arrays.asList(property.split(","));
                List<Map<String,Object>> list=null;
                if(status.endsWith("0")){
                    list=entBaseInfoService.notPresentReportYear(status,regorg,reportyear,start,end,estDateNode);
                }else{
                    list=entBaseInfoService.presentReportYear(status,regorg,reportyear,start,end,estDateNode);
                }
                //list = list.subList(start-1,end);
                HSSFWorkbook workbook=ExcelUtil.createExcel("65",headInfo,list);
                zipOutputStream.putNextEntry(new ZipEntry(start+"~"+end+".xls"));
                workbook.write(zipOutputStream);
                zipOutputStream.flush();
            }
            zipOutputStream.close();
            // return "success";
            // return "redirect:/entPriseType/selectannualreport_open.do?regorg="+regorg+"&reportyear="+reportyear+"&start="+start;

        }else{
            // return "redirect:/entPriseType/selectannualreport_open.do?regorg="+regorg+"&reportyear="+reportyear+"&start="+start;
        }*/
    }

    /**
     * 按列入原因与主体类型分类，统计我的待办数量
     * @param request   请求
     * @return  统计结果
     * @author lroyia
     * @since  2021年4月20日 10:38:28
     */
    @ApiOperation("按列入原因与主体类型分类，统计我的待办数量")
    @PostMapping("statisticMyTaskGroupBySpeCause")
    public RestResult<?> statisticMyTaskGroupBySpeCause(HttpServletRequest request){
        Map<String, Object> paramMap = new HashMap<>();
        AICUser curUser = getLoginUser(request);
        paramMap.put("curUserId", curUser.getPrimaryKey());
        paramMap.put("nodeId", "exptlistEnter");
        return RestResult.ok(tsAbnListService.statisticSpeCauseAndEntType(paramMap));
    }

    /**
     * 按业务类型分类，统计我的待办数量
     * @param request   请求
     * @return  统计结果
     * @author lroyia
     * @since  2021年4月20日 10:38:28
     */
    @ApiOperation("按业务类型分类，统计我的待办数量")
    @PostMapping("statisticAbnormalTaskCount")
    public RestResult<?> statisticAbnormalTaskCount(HttpServletRequest request){
        Map<String, Object> paramMap = new HashMap<>();
        AICUser curUser = getLoginUser(request);
        paramMap.put("curUserId", curUser.getPrimaryKey());
        return RestResult.ok(tsAbnListService.statisticAbnormalTaskCount(paramMap));
    }

    /**
     * 获取主体移出记录
     *
     * @param bizseq 业务号
     * @return
     * @author Lee
     * @since  2021年5月25日 11:08:20
     */
    @GetMapping("getBizRemoveRecordList")
    public RestResult<?> getBizRemoveRecordList(String bizseq) {
        List<TSBizRemList> bizSpeList = tsBizRemListService.list(new LambdaQueryWrapper<TSBizRemList>().eq(TSBizRemList::getBizseq, bizseq));
        List<TSAbnList> list = new ArrayList<>();
        if(CollectionUtils.isNotEmpty(bizSpeList)){
            TSBizRemList bizRemList = bizSpeList.get(0);
            String pripid = bizRemList.getPripid();
            LambdaQueryWrapper<TSAbnList> wrapper = new LambdaQueryWrapper<>();
            wrapper.eq(TSAbnList::getPripid,pripid)
                    .isNotNull(TSAbnList::getRemdate)
                    .orderByDesc(TSAbnList::getLauptime);
            list = tsAbnListService.list(wrapper);
            // 处理移出原因
            if (CollectionUtils.isNotEmpty(list)){
                for (TSAbnList tsAbnList : list) {
                    String enttype = tsAbnList.getEnttype();
                    String remexcpres = tsAbnList.getRemexcpres();
                    String reas = null;
                    if("9100".equals(enttype) || "9200".equals(enttype)){ // 农合
                        Map<String, TRBaseCode> remCodeMap = baseCodeService.getBaseCodeMapFormCache("CD78");
                        TRBaseCode code = remCodeMap.get(remexcpres);
                        if(code != null) {
                            reas = code.getName();
                        }
                    }else if("9910".equals(enttype)){// 个体
                        Map<String, TRBaseCode> remCodeMap = baseCodeService.getBaseCodeMapFormCache("CD76");
                        TRBaseCode code = remCodeMap.get(remexcpres);
                        if(code != null) {
                            reas = code.getName();
                        }
                    }else {// 企业
                        Map<String, TRBaseCode> remCodeMap = baseCodeService.getBaseCodeMapFormCache("CD72");
                        TRBaseCode code = remCodeMap.get(remexcpres);
                        if(code != null) {
                            reas = code.getName();
                        }
                    }
                    //设置移出机关中文
                    String remDecorgCn = StringUtils.isNotEmpty(tsAbnList.getRemDecorg())
                            ? tsAbnList.getRemDecorg() : gzaiccodeService.getNameByCode(tsAbnList.getReDecorg());
                    tsAbnList.setRemDecorgCn(remDecorgCn);
                    //设置移出原因中文
                    tsAbnList.setRemexcpresCn(StringUtils.isNotEmpty(tsAbnList.getRemreasons())
                            ? tsAbnList.getRemreasons() : reas);
                }
            }
        }
        return RestResult.ok(list);
    }

    /**
     * 获取异常名录待办分页
     * @param request 请求
     * @param pageRequestDto    分页请求
     * @return  获取结果
     * @author lroyia
     * @since 2021年4月20日 10:49:11
     */
    @ApiOperation("获取异常名录待办分页")
    @PostMapping("getAbnormalTaskListPage")
    public RestResult<?> getAbnormalTaskListPage(HttpServletRequest request, @RequestBody PageRequestDto pageRequestDto){
        AssertUtils.isNotNull(pageRequestDto);
        pageRequestDto.checkDefault(1, 10, null);
        Map<String, Object> paramMap = pageRequestDto.getParamMap();
        if(paramMap == null){
            paramMap = new HashMap<>();
        }
        return RestResult.ok(tsAbnListService.getAbnormalTaskListPage(new Page<>(pageRequestDto.getCurPage(), pageRequestDto.getPageSize()), paramMap));
    }


    /**
     * 查询主体列入经营异常名录记录
     * @param pripid 数据pripid
     * @return  查询结果
     * @author lroyia
     * @since  2021年4月21日 14:45:34
     */
    @ApiOperation("查询主体列入经营异常名录记录")
    @GetMapping("listAbnormalRecord")
    public RestResult<?> listAbnormalRecord(@ApiParam("主体pripid") String pripid){
        AssertUtils.isNotBlank(pripid);
        List<TSAbnList> list = tsAbnListService.list(new LambdaQueryWrapper<TSAbnList>().eq(TSAbnList::getPripid, pripid).orderByDesc(TSAbnList::getAbntime));
        // 补充码值信息
        if(CollectionUtils.isNotEmpty(list)){
            Map<String, TRBaseCode> moveInRea = baseCodeService.getBaseCodeMapFormCache("CD71");
            Map<String, TRBaseCode> moveOutRea = baseCodeService.getBaseCodeMapFormCache("CD72");
            for (TSAbnList each : list) {
                if(StringUtils.isNotBlank(each.getSpecause())){
                    TRBaseCode code = moveInRea.get(each.getSpecause());
                    if(code != null){
                        each.setSpecauseCn(code.getName());
                    }
                }
                if(StringUtils.isNotBlank(each.getRemexcpres())){
                    TRBaseCode code = moveOutRea.get(each.getRemexcpres());
                    if(code != null){
                        each.setRemexcpresCn(code.getName());
                    }
                }
            }
        }
        //查询文书号
        for (TSAbnList tsAbnList : list) {
            if (StringUtils.isNotBlank(tsAbnList.getIntowritid())) {
                TSWrit tsWritLR = tsWritService.getById(tsAbnList.getIntowritid());
                if(tsWritLR != null) tsAbnList.setIntowritno(tsWritLR.getWritsno());
            }
            if (StringUtils.isNotBlank(tsAbnList.getRemwritid())) {
                TSWrit tsWritYC = tsWritService.getById(tsAbnList.getRemwritid());
                if(tsWritYC != null) tsAbnList.setRemwritidno(tsWritYC.getWritsno());
            }
        }
        return RestResult.ok(list);
    }

    @RequestMapping("queryAbnListOne")
    public RestResult<?> queryAbnListOne(String pripid) {
        TSAbnList tsAbnList = tsAbnListService.queryOneByPripid(pripid);
        return RestResult.ok(tsAbnList);
    }

    /**
     *
     * @param bizseq 业务号
     * @return
     * 获取已年报记录
     * @author lwd
     * @since  2024年4月8日 14:08:21
     */
    @GetMapping("getaicepsYbList")
    public RestResult<?> getaicepsYbList(String bizseq) {
        List<TREntBaseInfoSplit> list = new ArrayList<>();

        List<TSBizRemList> bizSpeList = tsBizRemListService.list(new LambdaQueryWrapper<TSBizRemList>().eq(TSBizRemList::getBizseq, bizseq));
        try {
            list = trEntBaseInfoSplitService.getYbList(bizSpeList.get(0).getPripid());
//            list = trEntBaseInfoSplitService.getYbList("440106106022020121450821");
        }catch (Exception e) {
            e.printStackTrace();
        }
        return RestResult.ok(list);
    }

    /**
     *
     * @param bizseq 业务号
     * @return
     * @author lwd
     * @since  2024年4月8日 14:27:29
     */
    @GetMapping("geteGtAlterRecoderList")
    public RestResult<?> geteGtAlterRecoderList(String bizseq) {
        List<EGtAlterRecoder> list = new ArrayList<>();
        List<EAlterRecoder> list1 = new ArrayList<>();

        List<TSBizRemList> bizSpeList = tsBizRemListService.list(new LambdaQueryWrapper<TSBizRemList>().eq(TSBizRemList::getBizseq, bizseq));
        TSAbnList tsAbnList = tsAbnListService.selectTsAbnById(bizSpeList.get(0).getAbnlistid());
        try {

            if ("individual".equals(bizSpeList.get(0).getType())) {
                list = eGtAlterRecoderService.lambdaQuery().eq(EGtAlterRecoder::getPripid, bizSpeList.get(0).getPripid())
                        .eq(EGtAlterRecoder::getAltitem,"02")
                        .gt(EGtAlterRecoder::getAltdate, tsAbnList.getAbntime())
                        .list();

            }else {
                list1 = eAlterRecoderService.lambdaQuery().eq(EAlterRecoder::getPripid, bizSpeList.get(0).getPripid())
                        .eq(EAlterRecoder::getAltitem,"02")
                        .gt(EAlterRecoder::getAltdate, tsAbnList.getAbntime())
                        .list();
            }
//            list = eGtAlterRecoderService.lambdaQuery().eq(EGtAlterRecoder::getPripid, "440105003092008121501185").list();


        }catch (Exception e) {
            e.printStackTrace();
        }
        if (list1.size() > 0) {
            return RestResult.ok(list1);
        }
        if (list.size() > 0) {
            return RestResult.ok(list);
        }
        return RestResult.ok(list);
    }
}
