package com.lantone.daqe.facade;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lantone.common.enums.IsDeleteEnum;
import com.lantone.common.exception.Asserts;
import com.lantone.common.util.BeanUtil;
import com.lantone.common.util.DateUtil;
import com.lantone.common.util.ListUtil;
import com.lantone.common.util.StringUtil;
import com.lantone.common.util.SysUserUtils;
import com.lantone.daqe.dto.GetByIdColumnResultDTO;
import com.lantone.daqe.dto.GetColumnResultNumberDTO;
import com.lantone.daqe.dto.GetColumnResultPageDTO;
import com.lantone.daqe.dto.GetRegular;
import com.lantone.daqe.dto.GetStandardvalueInfoDTO;
import com.lantone.daqe.dto.GetTableColumnInfoDTO;
import com.lantone.daqe.entity.BehospitalInfo;
import com.lantone.daqe.entity.ColumnInfo;
import com.lantone.daqe.entity.ColumnResult;
import com.lantone.daqe.entity.NonnullInfo;
import com.lantone.daqe.entity.NonnullResult;
import com.lantone.daqe.entity.RegularResult;
import com.lantone.daqe.entity.StandardvalueResult;
import com.lantone.daqe.enums.AuditStatusEnum;
import com.lantone.daqe.enums.ColumnResultTypeEnum;
import com.lantone.daqe.enums.ColumnTypeEnum;
import com.lantone.daqe.enums.ColumnVerifyTypeEnum;
import com.lantone.daqe.enums.ModeEnum;
import com.lantone.daqe.enums.NonnullStatusEnum;
import com.lantone.daqe.enums.SolvedStatusEnum;
import com.lantone.daqe.facade.base.BehospitalInfoFacade;
import com.lantone.daqe.facade.base.ColumnInfoFacade;
import com.lantone.daqe.facade.base.ColumnResultFacade;
import com.lantone.daqe.facade.base.NonnullInfoFacade;
import com.lantone.daqe.facade.base.NonnullResultFacade;
import com.lantone.daqe.facade.base.RegularMappingFacade;
import com.lantone.daqe.facade.base.RegularResultFacade;
import com.lantone.daqe.facade.base.StandardvalueInfoFacade;
import com.lantone.daqe.facade.base.StandardvalueResultFacade;
import com.lantone.daqe.service.impl.ColumnResultServiceImpl;
import com.lantone.daqe.service.impl.NonnullResultServiceImpl;
import com.lantone.daqe.service.impl.RegularResultServiceImpl;
import com.lantone.daqe.service.impl.StandardvalueResultServiceImpl;
import com.lantone.daqe.vo.DataCheckVO;
import com.lantone.daqe.vo.GetColumnResultNumberVO;
import com.lantone.daqe.vo.GetColumnResultPageVO;
import com.lantone.daqe.vo.GetRegularMappingVO;
import com.lantone.daqe.vo.GetStandardvalueInfoVO;
import com.lantone.daqe.vo.GetTableColumnInfoVO;
import com.lantone.daqe.vo.UpdateColumnResultVO;
import com.lantone.daqe.vo.GetByIdColumnResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * @Description: 字段校验问题明细维护API-业务处理类
 * @author： zhanghang
 * @time: 2022/3/8 14:49
 */
@Component
public class ColumnResultManagementFacade {
    @Autowired
    ColumnResultFacade columnResultFacade;
    @Autowired
    NonnullResultFacade nonnullResultFacade;
    @Autowired
    RegularResultFacade regularResultFacade;
    @Autowired
    StandardvalueResultFacade standardvalueResultFacade;
    @Autowired
    BehospitalInfoFacade behospitalInfoFacade;
    @Autowired
    NonnullInfoFacade nonnullInfoFacade;
    @Autowired
    RegularMappingFacade regularMappingFacade;
    @Autowired
    StandardvalueInfoFacade standardvalueInfoFacade;
    @Autowired
    ColumnInfoFacade columnInfoFacade;
    @Autowired
    ColumnResultServiceImpl columnResultServiceImpl;
    @Autowired
    RegularResultServiceImpl regularResultServiceImpl;
    @Autowired
    NonnullResultServiceImpl nonnullResultServiceImpl;
    @Autowired
    StandardvalueResultServiceImpl standardvalueResultServiceImpl;

    /**
     * 获取字段校验问题明细分页列表数据
     *
     * @param getColumnResultPageVO
     * @return: 字段校验问题明细分页列表数据
     */
    public IPage<GetColumnResultPageDTO> getColumnResultPage(GetColumnResultPageVO getColumnResultPageVO) {
        Page<GetColumnResultPageDTO> getColumnResultPageDTOPage = new Page<>();
        Long currentHospitalId = SysUserUtils.getCurrentHospitalId();
        getColumnResultPageVO.setHospitalId(currentHospitalId);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String startDate = null;
        String endDate = null;
        if (getColumnResultPageVO.getBehospitalStartDate() != null) {
            startDate = sdf.format(getColumnResultPageVO.getBehospitalStartDate());
        }
        if (getColumnResultPageVO.getBehospitalEndDate() != null) {
            endDate = sdf.format(getColumnResultPageVO.getBehospitalEndDate());
        }
        QueryWrapper<ColumnResult> columnResultQueryWrapper = new QueryWrapper<>();
        columnResultQueryWrapper.eq(getColumnResultPageVO.getHospitalId() != null, "hospital_id", getColumnResultPageVO.getHospitalId());
        columnResultQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey());
        columnResultQueryWrapper.eq(StringUtil.isNotBlank(getColumnResultPageVO.getType()), "type", getColumnResultPageVO.getType());
        columnResultQueryWrapper.eq(StringUtil.isNotBlank(getColumnResultPageVO.getIsSolved()), "is_solved", getColumnResultPageVO.getIsSolved());
        columnResultQueryWrapper.eq(StringUtil.isNotBlank(getColumnResultPageVO.getModeName()), "mode_name", getColumnResultPageVO.getModeName());
        columnResultQueryWrapper.ge(StringUtil.isNotBlank(startDate), "behospital_date", getColumnResultPageVO.getBehospitalStartDate());
        columnResultQueryWrapper.le(StringUtil.isNotBlank(endDate), "behospital_date", getColumnResultPageVO.getBehospitalEndDate());
        columnResultQueryWrapper.like(StringUtil.isNotBlank(getColumnResultPageVO.getBehospitalCode()), "behospital_code", getColumnResultPageVO.getBehospitalCode());
        columnResultQueryWrapper.like(StringUtil.isNotBlank(getColumnResultPageVO.getHosptialDatatmpCode()), "hosptial_datatmp_code", getColumnResultPageVO.getHosptialDatatmpCode());
        columnResultQueryWrapper.like(StringUtil.isNotBlank(getColumnResultPageVO.getHosptialDatatmpName()), "hosptial_datatmp_name", getColumnResultPageVO.getHosptialDatatmpName());
        columnResultQueryWrapper.orderByAsc("is_solved");
        columnResultQueryWrapper.orderByDesc("gmt_modified");
        columnResultQueryWrapper.orderByAsc("behospital_code");
        Page<ColumnResult> columnResultPage = new Page<>(getColumnResultPageVO.getCurrent(), getColumnResultPageVO.getSize());
        columnResultFacade.page(columnResultPage, columnResultQueryWrapper);
        BeanUtil.copyProperties(columnResultPage, getColumnResultPageDTOPage);
        List<GetColumnResultPageDTO> getRecordTemplatePageDTOList = BeanUtil.listCopyTo(columnResultPage.getRecords(), GetColumnResultPageDTO.class);

        getColumnResultPageDTOPage.setRecords(getRecordTemplatePageDTOList);
        return getColumnResultPageDTOPage;
    }

    /**
     * 获取字段校验问题明细数量
     *
     * @param getColumnResultNumberVO
     * @return: 字段校验问题明细数量
     */
    public GetColumnResultNumberDTO getColumnResultNumber(GetColumnResultNumberVO getColumnResultNumberVO) {
        Long currentHospitalId = SysUserUtils.getCurrentHospitalId();
        getColumnResultNumberVO.setHospitalId(currentHospitalId);
        return columnResultFacade.getBaseMapper().getColumnResultNumber(getColumnResultNumberVO);
    }

    /**
     * 修改字段校验问题明细
     *
     * @param updateColumnResultVO
     * @return: 是否成功
     */
    public Boolean updateColumnResult(UpdateColumnResultVO updateColumnResultVO) {
        Long principleId = SysUserUtils.getCurrentPrincipleId();
        ColumnResult columnResultFacadeById = columnResultFacade.getById(updateColumnResultVO.getId());
        if(columnResultFacadeById==null){
            Asserts.fail("规则已被删除，无法进行该操作。");
        }
        //先修改副表
        //非空校验结果表
        Long resultId = columnResultFacadeById.getResultId();
        String type = columnResultFacadeById.getType();
        if (ColumnVerifyTypeEnum.NONNULL_TYPE.getKey().equals(type)) {
            nonnullResultFacade.update(new UpdateWrapper<NonnullResult>()
                    .eq("is_deleted", IsDeleteEnum.N.getKey())
                    .eq("id", resultId)
                    .set("description", updateColumnResultVO.getDescription())
                    .set("gmt_modified", new Date())
                    .set("modifier", principleId == null ? "0" : principleId)
            );
        }
        //正则校验结果表
        if (ColumnVerifyTypeEnum.REGULAR_TYPE.getKey().equals(type)) {
            regularResultFacade.update(new UpdateWrapper<RegularResult>()
                    .eq("is_deleted", IsDeleteEnum.N.getKey())
                    .eq("id", resultId)
                    .set("description", updateColumnResultVO.getDescription())
                    .set("gmt_modified", new Date())
                    .set("modifier", principleId == null ? "0" : principleId)
            );
        }
        //关键字校验结果表
        if (ColumnVerifyTypeEnum.STANDARD_TYPE.getKey().equals(type)) {
            standardvalueResultFacade.update(new UpdateWrapper<StandardvalueResult>()
                    .eq("is_deleted", IsDeleteEnum.N.getKey())
                    .eq("id", resultId)
                    .set("description", updateColumnResultVO.getDescription())
                    .set("gmt_modified", new Date())
                    .set("modifier", principleId == null ? "0" : principleId)
            );
        }

        return columnResultFacade.update(new UpdateWrapper<ColumnResult>()
                .eq("is_deleted", IsDeleteEnum.N.getKey())
                .eq("id", updateColumnResultVO.getId())
                .set("description", updateColumnResultVO.getDescription())
                .set("gmt_modified", new Date())
                .set("modifier", principleId == null ? "0" : principleId)
        );
    }

    /**
     * 根据ID查看字段校验问题明细
     *
     * @param getByIdColumnResultVO
     * @return: 字段校验问题明细明细
     */
    public GetByIdColumnResultDTO getByIdColumnResult(GetByIdColumnResultVO getByIdColumnResultVO) {
        ColumnResult columnResult = columnResultFacade.getBaseMapper().selectById(getByIdColumnResultVO.getId());
        String type = columnResult.getType();
        GetByIdColumnResultDTO getByIdColumnResultDTO = new GetByIdColumnResultDTO();
        //非空校验
        if (ColumnVerifyTypeEnum.NONNULL_TYPE.getKey().equals(type)) {
            getByIdColumnResultDTO.setType(type);
            Long resultId = columnResult.getResultId();
            NonnullResult nonnullResult = nonnullResultFacade.getBaseMapper().selectOne(new QueryWrapper<NonnullResult>()
                    .eq("is_deleted", IsDeleteEnum.N.getKey())
                    .eq("id", resultId)
            );
            BeanUtil.copyProperties(nonnullResult, getByIdColumnResultDTO);
            return getByIdColumnResultDTO;
        }
        //正则校验结果表
        if (ColumnVerifyTypeEnum.REGULAR_TYPE.getKey().equals(type)) {
            getByIdColumnResultDTO.setType(type);
            Long resultId = columnResult.getResultId();
            RegularResult regularResult = regularResultFacade.getBaseMapper().selectOne(new QueryWrapper<RegularResult>()
                    .eq("is_deleted", IsDeleteEnum.N.getKey())
                    .eq("id", resultId)
            );
            BeanUtil.copyProperties(regularResult, getByIdColumnResultDTO);
            return getByIdColumnResultDTO;
        }
        //关键字校验结果表
        if (ColumnVerifyTypeEnum.STANDARD_TYPE.getKey().equals(type)) {
            getByIdColumnResultDTO.setType(type);
            Long resultId = columnResult.getResultId();
            StandardvalueResult standardvalueResult = standardvalueResultFacade.getBaseMapper().selectOne(new QueryWrapper<StandardvalueResult>()
                    .eq("is_deleted", IsDeleteEnum.N.getKey())
                    .eq("id", resultId)
            );
            BeanUtil.copyProperties(standardvalueResult, getByIdColumnResultDTO);
            return getByIdColumnResultDTO;
        }
        return getByIdColumnResultDTO;
    }

    /**
     * 获取枚举所有Name 也就是质控模块名称
     *
     * @param
     * @return:
     */
    public List<String> getModeName() {
        List<String> modeNameList = new ArrayList<>();
        for (ModeEnum value : ModeEnum.values()) {
            modeNameList.add(value.getName());
        }
        return modeNameList;
    }

    /**
     * 数据校验接口
     *
     * @param dataCheckVO
     * @return: 是否成功
     */
    public Boolean dataCheck(DataCheckVO dataCheckVO) {
        List<String> behospitalCodeList = new ArrayList<>();
        Long hospitalId = null;
        Long principleId = null;
        if (dataCheckVO.getHospitalId() == null) {
            hospitalId = SysUserUtils.getCurrentHospitalId();
            principleId = SysUserUtils.getCurrentPrincipleId();
        }
        //获取所有包含rec_id的表名
        List<String> recColumnTable = getRecColumnTable();
        dataCheckVO.setHospitalId(hospitalId);
        String behospitalCode = dataCheckVO.getBehospitalCode();
        //传入BehospitalCode 只针对单个病历进行校验
        if (StringUtil.isNotEmpty(behospitalCode)) {
            List<BehospitalInfo> behospitalInfos = behospitalInfoFacade.getBaseMapper().selectList(new QueryWrapper<BehospitalInfo>()
                    .eq("is_deleted", IsDeleteEnum.N.getKey())
                    .eq("behospital_code", dataCheckVO.getBehospitalCode())
                    .eq(hospitalId != null, "hospital_id", hospitalId)
            );
            if (ListUtil.isEmpty(behospitalInfos)) {
                Asserts.fail("该患者信息未查询到！");
            }
            behospitalCodeList.add(behospitalCode);
            //对于集合病历所有校验规则校验其表信息字段
            checkTableColumnVal(behospitalCodeList, hospitalId, principleId, recColumnTable);
        }
        //对于只传时间不传病历的情况
        //创建一个病历集合
        if (StringUtil.isEmpty(behospitalCode)) {
            List<BehospitalInfo> behospitalInfos = getBehospitalInfos(dataCheckVO.getDateStart(), dataCheckVO.getDateEnd(), hospitalId);
            if (ListUtil.isEmpty(behospitalInfos)) {
                Asserts.fail("该时间段无病历信息！");
            }
            for (BehospitalInfo behospitalInfo : behospitalInfos) {
                //获取时间段所有病历
                behospitalCodeList.add(behospitalInfo.getBehospitalCode());
            }
            //对于集合病历所有校验规则校验其表信息字段
            checkTableColumnVal(behospitalCodeList, hospitalId, principleId, recColumnTable);
        }
        return true;
    }


    /**
     * 对于集合病历所有校验规则校验其表信息字段
     *
     * @param behospitalCodeList
     * @return: 具体数据
     */
    public void checkTableColumnVal(List<String> behospitalCodeList, Long hospitalId, Long principleId, List<String> recColumnTable) {
        //先获取非空的所有字段校验规则
        List<NonnullInfo> nonnullInfos = getNonnullInfo();
        if (ListUtil.isNotEmpty(nonnullInfos)) {
            //调用校验非空规则方法
            checkNonnull(nonnullInfos, behospitalCodeList, hospitalId, principleId, recColumnTable);
        }
        //获取正则所有字段校验规则
        List<GetRegular> regularMappings = getRegularMapping();
        if (ListUtil.isNotEmpty(regularMappings)) {
            //调用校验正则规则
            checkRegular(regularMappings, behospitalCodeList, hospitalId, principleId, recColumnTable);
        }
        //获取字段校验的标准值规则
        List<GetStandardvalueInfoDTO> standardvalueInfo = getStandardvalueInfo();
        if (ListUtil.isNotEmpty(standardvalueInfo)) {
            checkStandardvalue(standardvalueInfo, behospitalCodeList, hospitalId, principleId, recColumnTable);
        }
    }

    /**
     * 对于当天有规则被修改，校验30天内所有病历中规则关联的数据
     *
     * @param
     * @return: 具体数据
     */
    public void taskCheckTableColumnVal(Long hospitalId) {
        Long principleId = null;
        List<NonnullInfo> nonnullInfoList = new ArrayList<>();
        List<GetRegular> regularList = new ArrayList<>();
        List<GetStandardvalueInfoDTO> standardvalueList = new ArrayList<>();
        List<String> behospitalCodeList = new ArrayList<>();
        Date startDate = DateUtil.addDate(DateUtil.now(), -1);
        //先获取非空的所有字段校验规则
        List<NonnullInfo> nonnullInfos = getNonnullInfo();
        if (ListUtil.isNotEmpty(nonnullInfos)) {
            //遍历所有规则
            for (NonnullInfo nonnullInfo : nonnullInfos) {
                Date gmtModified = nonnullInfo.getGmtModified();
                //判断修改时间是否为当天
                if (cn.hutool.core.date.DateUtil.isSameDay(startDate, gmtModified)) {
                    //如果是今天则将规则存入一个对象集合中待处理
                    nonnullInfoList.add(nonnullInfo);
                } else {
                    continue;
                }
            }
        }
        //获取正则所有字段校验规则
        List<GetRegular> regularMappings = getRegularMapping();
        if (ListUtil.isNotEmpty(regularMappings)) {
            //遍历所有规则
            for (GetRegular getRegular : regularMappings) {
                Date gmtModified = getRegular.getGmtModified();
                if (cn.hutool.core.date.DateUtil.isSameDay(startDate, gmtModified)) {
                    //如果是今天则将规则存入一个对象集合中待处理
                    regularList.add(getRegular);
                } else {
                    continue;
                }
            }
        }
        //获取字段校验的标准值规则
        List<GetStandardvalueInfoDTO> standardvalueInfo = getStandardvalueInfo();
        if (ListUtil.isNotEmpty(standardvalueInfo)) {
            //遍历所有规则
            for (GetStandardvalueInfoDTO standardvalueInfoDTO : standardvalueInfo) {
                Date gmtModified = standardvalueInfoDTO.getGmtModified();
                if (cn.hutool.core.date.DateUtil.isSameDay(startDate, gmtModified)) {
                    //如果是今天则将规则存入一个对象集合中待处理
                    standardvalueList.add(standardvalueInfoDTO);
                } else {
                    continue;
                }
            }
        }
        //先判断是否存在规则有修改
        if (ListUtil.isNotEmpty(nonnullInfoList) || ListUtil.isNotEmpty(standardvalueList) || ListUtil.isNotEmpty(regularList)) {
            //获取30天内所有病历
            List<BehospitalInfo> behospitalInfos = getBehospitalInfos(DateUtil.addDate(DateUtil.now(), -30), DateUtil.now(), hospitalId);
            if (ListUtil.isNotEmpty(behospitalInfos)) {
                for (BehospitalInfo behospitalInfo : behospitalInfos) {
                    behospitalCodeList.add(behospitalInfo.getBehospitalCode());
                }
            }
        }
        //获取所有包含rec_id的表名
        List<String> recColumnTable = getRecColumnTable();
        //非空校验规则今天有修改
        if (ListUtil.isNotEmpty(nonnullInfoList) && ListUtil.isNotEmpty(behospitalCodeList)) {
            //调用校验非空规则方法
            checkNonnull(nonnullInfoList, behospitalCodeList, hospitalId, principleId, recColumnTable);
        }
        //正则校验规则今天有修改
        if (ListUtil.isNotEmpty(regularList) && ListUtil.isNotEmpty(behospitalCodeList)) {
            //调用校验正则规则
            checkRegular(regularList, behospitalCodeList, hospitalId, principleId, recColumnTable);
        }
        //标准值校验规则今天有修改
        if (ListUtil.isNotEmpty(standardvalueList) && ListUtil.isNotEmpty(behospitalCodeList)) {
            //调用校验正则规则
            checkStandardvalue(standardvalueList, behospitalCodeList, hospitalId, principleId, recColumnTable);
        }
    }

    /**
     * 获取所有包含rec_id的表名
     *
     * @param
     * @return:
     */
    public List<String> getRecColumnTable() {
        //获取所有包含rec_id的表名
        List<ColumnInfo> columnInfoList = columnInfoFacade.getBaseMapper().selectList(new QueryWrapper<ColumnInfo>()
                .eq("is_deleted", IsDeleteEnum.N.getKey())
                .eq("column_ename", "rec_id")
        );
        List<String> recColumnTable = new ArrayList<>();
        if (ListUtil.isNotEmpty(columnInfoList)) {
            for (ColumnInfo columnInfo : columnInfoList) {
                recColumnTable.add(columnInfo.getTableEname());
            }
        }
        return recColumnTable;
    }

    /**
     * 获取时间段内所有病历
     *
     * @param startDate
     * @param endDate
     * @return:
     */
    public List<BehospitalInfo> getBehospitalInfos(Date startDate, Date endDate, Long hospitalId) {
        return behospitalInfoFacade.getBaseMapper().selectList(new QueryWrapper<BehospitalInfo>()
                .eq("is_deleted", IsDeleteEnum.N.getKey())
                .eq(hospitalId != null, "hospital_id", hospitalId)
                .ge("behospital_date", startDate)
                .le("behospital_date", endDate)
        );
    }

    /**
     * 获取非空校验所有规则
     *
     * @param
     * @return:
     */
    public List<NonnullInfo> getNonnullInfo() {
        return nonnullInfoFacade.getBaseMapper().selectList(new QueryWrapper<NonnullInfo>()
                .eq("is_deleted", IsDeleteEnum.N.getKey())
        );
    }

    /**
     * 获取正则校验所有规则
     *
     * @param
     * @return:
     */
    public List<GetRegular> getRegularMapping() {
        GetRegularMappingVO getRegularMappingVO = new GetRegularMappingVO();
        return regularMappingFacade.getBaseMapper().getRegularMapping(getRegularMappingVO);
    }

    /**
     * 获取关键值校验所有规则
     *
     * @param
     * @return:
     */
    public List<GetStandardvalueInfoDTO> getStandardvalueInfo() {
        GetStandardvalueInfoVO getStandardvalueInfoVO = new GetStandardvalueInfoVO();
        return standardvalueInfoFacade.getBaseMapper().getStandardvalueInfo(getStandardvalueInfoVO);
    }

    /**
     * 根据病历及规则校验非空规则
     *
     * @param nonnullInfos
     * @param behospitalCodeList
     * @param hospitalId
     * @return:
     */
    public void checkNonnull(List<NonnullInfo> nonnullInfos, List<String> behospitalCodeList, Long hospitalId, Long principleId, List<String> recColumnTable) {
        //查询出这段时间内总表病历所有的非空问题数据 behospitalCode+type
        List<ColumnResult> columnResultList = getColumnResultList(hospitalId, behospitalCodeList, ColumnResultTypeEnum.NONNULL_TYPE.getKey());
        //查询出这段时间内非空表病历所有的非空问题数据 behospitalCode+type
        List<NonnullResult> nonnullResultList = getNonnullResultList(hospitalId, behospitalCodeList);
        //新增集合
        List<NonnullResult> addNonnullResultList = new ArrayList<>();
        //修改集合
        List<NonnullResult> upNonnullResultList = new ArrayList<>();
        //新增集合
        List<ColumnResult> addColumnResultList = new ArrayList<>();
        //修改集合
        List<ColumnResult> upColumnResultList = new ArrayList<>();
        //删除集合
        List<Map<Long, List<Long>>> judgeTableColumnInfoListMap = new ArrayList<>();
        for (NonnullInfo nonnullInfo : nonnullInfos) {
            Long columnId = nonnullInfo.getColumnId();
            ColumnInfo columnInfo = columnInfoFacade.getBaseMapper().selectById(columnId);
            //塞入查数据需要的条件
            GetTableColumnInfoVO getTableColumnInfoVO = new GetTableColumnInfoVO();
            getTableColumnInfoVO.setColumnCname(columnInfo.getColumnCname());
            getTableColumnInfoVO.setColumnEname(columnInfo.getColumnEname());
            getTableColumnInfoVO.setTableCname(columnInfo.getTableCname());
            getTableColumnInfoVO.setTableEname(columnInfo.getTableEname());
            getTableColumnInfoVO.setBehospitalCodeList(behospitalCodeList);
            getTableColumnInfoVO.setHospitalId(hospitalId);
            String columnNumber = getColumnNumber(columnInfo.getTableCname());
            getTableColumnInfoVO.setNumberColumnCname(columnNumber);
            List<GetTableColumnInfoDTO> tableColumnVal = getTableColumnVal(getTableColumnInfoVO, recColumnTable);
            //获取需要删除的结果表数据
            Map<Long, List<Long>> judgeTableColumnInfoList = judgeNonnullList(tableColumnVal, nonnullResultList, nonnullInfo);
            if (judgeTableColumnInfoList != null) {
                judgeTableColumnInfoListMap.add(judgeTableColumnInfoList);
            }
            //枚举获取模块信息
            String modeId = ModeEnum.valueOf(columnInfo.getTableEname()).getKey();
            String modeName = ModeEnum.valueOf(columnInfo.getTableEname()).getName();
            for (GetTableColumnInfoDTO getTableColumnInfoDTO : tableColumnVal) {
                getTableColumnInfoDTO.setModeId(Long.valueOf(modeId));
                getTableColumnInfoDTO.setModeName(modeName);
                String val = getTableColumnInfoDTO.getVal();
                //是否存在于原本表中 返回库中原本数据
                ColumnResult columnResult = judgeColumnResultList(columnResultList, getTableColumnInfoDTO, columnId);
                NonnullResult nonnullResult = judgeNonnullResultList(nonnullResultList, getTableColumnInfoDTO, columnId);
                ColumnResult columnResultUp = null;
                NonnullResult nonnullResultUp = null;
                if (columnResult != null) {
                    columnResultUp = upColumnResult(columnResult, getTableColumnInfoDTO, principleId);
                }
                if (nonnullResult != null) {
                    nonnullResultUp = upNonnullResult(nonnullResult, getTableColumnInfoDTO, principleId);
                }
                //不是必填则判断是否已有数据存在于结果表中，若存在则修改
                if ((NonnullStatusEnum.NOT_NONNULL.getKey()).equals(nonnullInfo.getIsRequired())) {
                    if (columnResultUp != null) {
                        columnResultUp.setIsSolved(SolvedStatusEnum.IS_SOLVED.getKey());
                        nonnullResultUp.setIsSolved(SolvedStatusEnum.IS_SOLVED.getKey());
                        //加入修改集合
                        upColumnResultList.add(columnResultUp);
                        upNonnullResultList.add(nonnullResultUp);
                        //修改
                    } else {
                        continue;
                    }
                } else {
                    //符合非空情况则判断是否已有数据存在于结果表中，若存在则修改
                    if (StringUtil.isNotEmpty(val)) {
                        if (columnResult != null) {
                            columnResultUp.setIsSolved(SolvedStatusEnum.IS_SOLVED.getKey());
                            nonnullResultUp.setIsSolved(SolvedStatusEnum.IS_SOLVED.getKey());
                            //加入修改集合
                            upColumnResultList.add(columnResultUp);
                            upNonnullResultList.add(nonnullResultUp);
                        } else {
                            continue;
                        }
                    }
                    //符合非空情况则判断是否已有数据存在于结果表中，若存在则更新时间，否则则新增
                    if (StringUtil.isEmpty(val)) {
                        if (columnResult != null) {
                            columnResultUp.setIsSolved(SolvedStatusEnum.NOT_SOLVED.getKey());
                            nonnullResultUp.setIsSolved(SolvedStatusEnum.NOT_SOLVED.getKey());
                            //加入修改集合
                            upColumnResultList.add(columnResultUp);
                            upNonnullResultList.add(nonnullResultUp);
                        } else {
                            //新增
                            //为空加入非空校验结果表
                            NonnullResult nonnullResultAdd = new NonnullResult();
                            nonnullResultAdd.setHospitalId(getTableColumnInfoDTO.getHospitalId());
                            nonnullResultAdd.setBehospitalCode(getTableColumnInfoDTO.getBehospitalCode());
                            nonnullResultAdd.setModeId(getTableColumnInfoDTO.getModeId());
                            nonnullResultAdd.setModeName(getTableColumnInfoDTO.getModeName());
                            if (StringUtil.isNotEmpty(getTableColumnInfoDTO.getRecId())) {
                                nonnullResultAdd.setHosptialDatatmpCode(getTableColumnInfoDTO.getRecId());
                            }
                            if (StringUtil.isNotEmpty(getTableColumnInfoDTO.getRecTitle())) {
                                nonnullResultAdd.setHosptialDatatmpName(getTableColumnInfoDTO.getRecTitle());
                            }
                            nonnullResultAdd.setColumnId(nonnullInfo.getColumnId());
                            nonnullResultAdd.setBehospitalDate(getTableColumnInfoDTO.getBehospitalDate());
                            nonnullResultAdd.setTableCname(columnInfo.getTableCname());
                            nonnullResultAdd.setHospitalDataCode(getTableColumnInfoDTO.getNumberId());
                            nonnullResultAdd.setBehospitalDate(getTableColumnInfoDTO.getBehospitalDate());
                            nonnullResultAdd.setTableEname(columnInfo.getTableEname());
                            nonnullResultAdd.setColumnCname(columnInfo.getColumnCname());
                            nonnullResultAdd.setColumnEname(columnInfo.getColumnEname());
                            nonnullResultAdd.setTableVal(getTableColumnInfoDTO.getVal());
                            if (principleId != null) {
                                nonnullResultAdd.setCreator(principleId.toString());
                            }
                            nonnullResultAdd.setTableId(getTableColumnInfoDTO.getTableId());
                            nonnullResultAdd.setIsSolved(SolvedStatusEnum.NOT_SOLVED.getKey());
                            nonnullResultAdd.setSolveTime(new Date());
                            nonnullResultAdd.setIsAudited(AuditStatusEnum.NOT_AUDIT.getKey());
                            nonnullResultAdd.setGmtCreate(new Date());
                            nonnullResultAdd.setGmtModified(new Date());
                            addNonnullResultList.add(nonnullResultAdd);
                            //加入总结果表
                            ColumnResult columnResultAdd = addColumnResult(getTableColumnInfoDTO, columnInfo, columnId, ColumnResultTypeEnum.NONNULL_TYPE.getKey(), principleId);
                            addColumnResultList.add(columnResultAdd);
                        }

                    }
                }
            }
        }
        //调用修改接口
        if (ListUtil.isNotEmpty(upNonnullResultList)) {
            if (nonnullResultServiceImpl.saveOrUpdateBatch(upNonnullResultList)) {
                if (ListUtil.isNotEmpty(upColumnResultList)) {
                    columnResultServiceImpl.saveOrUpdateBatch(upColumnResultList);
                }
            }
        }
        //调用新增接口
        if (ListUtil.isNotEmpty(addNonnullResultList)) {
            if (nonnullResultServiceImpl.saveBatch(addNonnullResultList)) {
                if (ListUtil.isNotEmpty(addColumnResultList)) {
                    addColumnResultList = saveColumnResultNonnullId(addNonnullResultList, addColumnResultList);
                    //将id插入总表新增集合中
                    columnResultServiceImpl.saveBatch(addColumnResultList);
                }
            }
        }
        //调用删除接口
        if (ListUtil.isNotEmpty(judgeTableColumnInfoListMap)) {
            for (Map<Long, List<Long>> longListMap : judgeTableColumnInfoListMap) {
                for (Map.Entry<Long, List<Long>> longListEntry : longListMap.entrySet()) {
                    Long key = longListEntry.getKey();
                    List<Long> value = longListEntry.getValue();
                    if (ListUtil.isNotEmpty(value)) {
                        List<Long> ids = new ArrayList<>();
                        List<NonnullResult> nonnullResults = nonnullResultFacade.getBaseMapper().selectList(new QueryWrapper<NonnullResult>()
                                .eq("is_deleted", IsDeleteEnum.N.getKey())
                                .eq("column_id", key)
                                .in("table_id", value));
                        if (ListUtil.isNotEmpty(nonnullResults)) {
                            nonnullResults.stream().forEach(nonnullResult -> {
                                ids.add(nonnullResult.getId());
                            });
                        }
                        //删除
                        if (nonnullResultFacade.remove(new UpdateWrapper<NonnullResult>()
                                .eq("is_deleted", IsDeleteEnum.N.getKey())
                                .eq("column_id", key)
                                .in("table_id", value)
                        )) {
                            //删除总表
                            columnResultFacade.remove(new QueryWrapper<ColumnResult>()
                                    .eq("is_deleted", IsDeleteEnum.N.getKey())
                                    .eq("column_id", key)
                                    .in(ListUtil.isNotEmpty(ids), "result_id", ids)
                            );
                        }
                    }
                }
            }
        }
    }

    /**
     * 根据病历及规则校验正则规则
     *
     * @param regularMappings
     * @param behospitalCodeList
     * @param hospitalId
     * @return:
     */
    public void checkRegular(List<GetRegular> regularMappings, List<String> behospitalCodeList, Long hospitalId, Long principleId, List<String> recColumnTable) {
        //查询出这段时间内总表病历所有的正则问题数据 behospitalCode+type
        List<ColumnResult> columnResultList = getColumnResultList(hospitalId, behospitalCodeList, ColumnResultTypeEnum.REGULAR_TYPE.getKey());
        //查询出这段时间内正则表病历所有的正则问题数据 behospitalCode+type
        List<RegularResult> regularResultList = getRegularResultList(hospitalId, behospitalCodeList);
        //新增集合
        List<RegularResult> addRegularResultList = new ArrayList<>();
        //修改集合
        List<RegularResult> upRegularResultList = new ArrayList<>();
        //新增集合
        List<ColumnResult> addColumnResultList = new ArrayList<>();
        //修改集合
        List<ColumnResult> upColumnResultList = new ArrayList<>();
        //删除集合
        List<Map<Long, List<Long>>> judgeTableColumnInfoListMap = new ArrayList<>();
        for (GetRegular getRegular : regularMappings) {
            Long columnId = getRegular.getColumnId();
            ColumnInfo columnInfo = columnInfoFacade.getBaseMapper().selectById(columnId);
            GetTableColumnInfoVO getTableColumnInfoVO = new GetTableColumnInfoVO();
            getTableColumnInfoVO.setColumnCname(columnInfo.getColumnCname());
            getTableColumnInfoVO.setColumnEname(columnInfo.getColumnEname());
            getTableColumnInfoVO.setTableCname(columnInfo.getTableCname());
            getTableColumnInfoVO.setTableEname(columnInfo.getTableEname());
            getTableColumnInfoVO.setBehospitalCodeList(behospitalCodeList);
            getTableColumnInfoVO.setHospitalId(hospitalId);
            String columnNumber = getColumnNumber(columnInfo.getTableCname());
            getTableColumnInfoVO.setNumberColumnCname(columnNumber);
            List<GetTableColumnInfoDTO> tableColumnVal = getTableColumnVal(getTableColumnInfoVO, recColumnTable);
            String modeId = ModeEnum.valueOf(columnInfo.getTableEname()).getKey();
            String modeName = ModeEnum.valueOf(columnInfo.getTableEname()).getName();
            //获取需要删除的结果表数据
            Map<Long, List<Long>> judgeTableColumnInfoList = judgeRegularList(tableColumnVal, regularResultList, getRegular);
            if (judgeTableColumnInfoList != null) {
                judgeTableColumnInfoListMap.add(judgeTableColumnInfoList);
            }
            String regular = getRegular.getVal();
            for (GetTableColumnInfoDTO getTableColumnInfoDTO : tableColumnVal) {
                getTableColumnInfoDTO.setModeId(Long.valueOf(modeId));
                getTableColumnInfoDTO.setModeName(modeName);
                //是否存在于原本表中 返回库中原本数据
                ColumnResult columnResult = judgeColumnResultList(columnResultList, getTableColumnInfoDTO, columnId);
                RegularResult regularResultU = judgeRegularResultList(regularResultList, getTableColumnInfoDTO, columnId);
                ColumnResult columnResultUp = null;
                RegularResult regularResultUp = null;
                if (columnResult != null) {
                    columnResultUp = upColumnResult(columnResult, getTableColumnInfoDTO, principleId);
                }
                if (regularResultU != null) {
                    regularResultUp = upRegularResult(regularResultU, getTableColumnInfoDTO, principleId);
                }
                String val = getTableColumnInfoDTO.getVal();
                Boolean matches = judgeRegular(regular, val);
                //符合正则  原本存在数据则修改，否则跳过
                if (matches) {
                    if (columnResultUp != null) {
                        columnResultUp.setIsSolved(SolvedStatusEnum.IS_SOLVED.getKey());
                        regularResultUp.setIsSolved(SolvedStatusEnum.IS_SOLVED.getKey());
                        //加入修改集合
                        upColumnResultList.add(columnResultUp);
                        upRegularResultList.add(regularResultUp);
                    } else {
                        continue;
                    }
                }
                //不符合正则
                if (!matches) {
                    //不符合原本存在则修改否则新增
                    if (columnResultUp != null) {
                        columnResultUp.setIsSolved(SolvedStatusEnum.NOT_SOLVED.getKey());
                        regularResultUp.setIsSolved(SolvedStatusEnum.NOT_SOLVED.getKey());
                        //加入修改集合
                        upColumnResultList.add(columnResultUp);
                        upRegularResultList.add(regularResultUp);
                    } else {
                        //加入校验结果表
                        RegularResult regularResult = new RegularResult();
                        regularResult.setHospitalId(getTableColumnInfoDTO.getHospitalId());
                        regularResult.setBehospitalCode(getTableColumnInfoDTO.getBehospitalCode());
                        regularResult.setModeId(getTableColumnInfoDTO.getModeId());
                        regularResult.setModeName(getTableColumnInfoDTO.getModeName());
                        regularResult.setColumnId(columnId);
                        regularResult.setTableCname(columnInfo.getTableCname());
                        regularResult.setTableEname(columnInfo.getTableEname());
                        regularResult.setColumnCname(columnInfo.getColumnCname());
                        regularResult.setColumnEname(columnInfo.getColumnEname());
                        if (StringUtil.isNotEmpty(getTableColumnInfoDTO.getRecId())) {
                            regularResult.setHosptialDatatmpCode(getTableColumnInfoDTO.getRecId());
                        }
                        if (StringUtil.isNotEmpty(getTableColumnInfoDTO.getRecTitle())) {
                            regularResult.setHosptialDatatmpName(getTableColumnInfoDTO.getRecTitle());
                        }
                        regularResult.setBehospitalDate(getTableColumnInfoDTO.getBehospitalDate());
                        regularResult.setHospitalDataCode(getTableColumnInfoDTO.getNumberId());
                        regularResult.setRegularId(getRegular.getId());
                        if (principleId != null) {
                            regularResult.setCreator(principleId.toString());
                        }
                        regularResult.setRegularName(getRegular.getName());
                        regularResult.setTableVal(getTableColumnInfoDTO.getVal());
                        regularResult.setBehospitalDate(getTableColumnInfoDTO.getBehospitalDate());
                        regularResult.setRegularVal(getRegular.getVal());
                        regularResult.setRegularDes(getRegular.getDes());
                        regularResult.setTableId(getTableColumnInfoDTO.getTableId());
                        regularResult.setIsSolved(SolvedStatusEnum.NOT_SOLVED.getKey());
                        regularResult.setSolveTime(new Date());
                        regularResult.setIsAudited(AuditStatusEnum.NOT_AUDIT.getKey());
                        regularResult.setGmtCreate(new Date());
                        regularResult.setGmtModified(new Date());
                        addRegularResultList.add(regularResult);
                        //加入总结果表
                        ColumnResult columnResultAdd = addColumnResult(getTableColumnInfoDTO, columnInfo, columnId, ColumnResultTypeEnum.REGULAR_TYPE.getKey(), principleId);
                        addColumnResultList.add(columnResultAdd);
                    }
                }
            }
        }
        //调用修改接口
        if (ListUtil.isNotEmpty(upRegularResultList)) {
            if (regularResultServiceImpl.saveOrUpdateBatch(upRegularResultList)) {
                if (ListUtil.isNotEmpty(upColumnResultList)) {
                    columnResultServiceImpl.saveOrUpdateBatch(upColumnResultList);
                }
            }
        }
        //调用新增接口
        if (ListUtil.isNotEmpty(addRegularResultList)) {
            if (regularResultServiceImpl.saveBatch(addRegularResultList)) {
                if (ListUtil.isNotEmpty(addColumnResultList)) {
                    addColumnResultList = saveColumnResultRegularResultId(addRegularResultList, addColumnResultList);
                    //将id插入总表新增集合中
                    columnResultServiceImpl.saveBatch(addColumnResultList);
                }
            }
        }
        //调用删除接口
        if (ListUtil.isNotEmpty(judgeTableColumnInfoListMap)) {
            for (Map<Long, List<Long>> longListMap : judgeTableColumnInfoListMap) {
                for (Map.Entry<Long, List<Long>> longListEntry : longListMap.entrySet()) {
                    Long key = longListEntry.getKey();
                    List<Long> value = longListEntry.getValue();
                    if (ListUtil.isNotEmpty(value)) {
                        List<Long> ids = new ArrayList<>();
                        List<RegularResult> regularResults = regularResultFacade.getBaseMapper().selectList(new QueryWrapper<RegularResult>()
                                .eq("is_deleted", IsDeleteEnum.N.getKey())
                                .eq("column_id", key)
                                .in("table_id", value));
                        if (ListUtil.isNotEmpty(regularResults)) {
                            regularResults.stream().forEach(regularResult -> {
                                ids.add(regularResult.getId());
                            });
                        }
                        //删除
                        if (regularResultFacade.remove(new UpdateWrapper<RegularResult>()
                                .eq("is_deleted", IsDeleteEnum.N.getKey())
                                .eq("column_id", key)
                                .in("table_id", value)
                        )) {
                            //删除总表
                            columnResultFacade.remove(new QueryWrapper<ColumnResult>()
                                    .eq("is_deleted", IsDeleteEnum.N.getKey())
                                    .eq("column_id", key)
                                    .in(ListUtil.isNotEmpty(ids), "result_id", ids)
                            );
                        }
                    }
                }
            }
        }
    }

    /**
     * 根据病历及规则校验关键值规则
     *
     * @param standardvalueInfos
     * @param behospitalCodeList
     * @param hospitalId
     * @return:
     */
    public void checkStandardvalue(List<GetStandardvalueInfoDTO> standardvalueInfos, List<String> behospitalCodeList, Long hospitalId, Long principleId, List<String> recColumnTable) {
        //查询出这段时间内总表病历所有的正则问题数据 behospitalCode+type
        List<ColumnResult> columnResultList = getColumnResultList(hospitalId, behospitalCodeList, ColumnResultTypeEnum.STANDARD_TYPE.getKey());
        //查询出这段时间内正则表病历所有的标准值问题数据 behospitalCode+type
        List<StandardvalueResult> standardvalueInfoList = getStandardvalueResult(hospitalId, behospitalCodeList);
        //新增集合
        List<StandardvalueResult> addStandardvalueResultList = new ArrayList<>();
        //修改集合
        List<StandardvalueResult> upStandardvalueResultList = new ArrayList<>();
        //新增集合
        List<ColumnResult> addColumnResultList = new ArrayList<>();
        //修改集合
        List<ColumnResult> upColumnResultList = new ArrayList<>();
        //删除集合
        List<Map<Long, List<Long>>> judgeTableColumnInfoListMap = new ArrayList<>();
        for (GetStandardvalueInfoDTO standardvalueInfo : standardvalueInfos) {
            Long columnId = standardvalueInfo.getColumnId();
            ColumnInfo columnInfo = columnInfoFacade.getBaseMapper().selectById(columnId);
            GetTableColumnInfoVO getTableColumnInfoVO = new GetTableColumnInfoVO();
            getTableColumnInfoVO.setColumnCname(columnInfo.getColumnCname());
            getTableColumnInfoVO.setColumnEname(columnInfo.getColumnEname());
            getTableColumnInfoVO.setTableCname(columnInfo.getTableCname());
            getTableColumnInfoVO.setTableEname(columnInfo.getTableEname());
            getTableColumnInfoVO.setBehospitalCodeList(behospitalCodeList);
            getTableColumnInfoVO.setHospitalId(hospitalId);
            String columnNumber = getColumnNumber(columnInfo.getTableCname());
            getTableColumnInfoVO.setNumberColumnCname(columnNumber);
            List<GetTableColumnInfoDTO> tableColumnVal = getTableColumnVal(getTableColumnInfoVO, recColumnTable);
            String standardvalue = standardvalueInfo.getStandardvalue();
            String modeId = ModeEnum.valueOf(columnInfo.getTableEname()).getKey();
            String modeName = ModeEnum.valueOf(columnInfo.getTableEname()).getName();
            //获取需要删除的结果表数据
            Map<Long, List<Long>> judgeTableColumnInfoList = judgeStandardvalueList(tableColumnVal, standardvalueInfoList, standardvalueInfo);
            if (judgeTableColumnInfoList != null) {
                judgeTableColumnInfoListMap.add(judgeTableColumnInfoList);
            }
            for (GetTableColumnInfoDTO getTableColumnInfoDTO : tableColumnVal) {
                getTableColumnInfoDTO.setModeId(Long.valueOf(modeId));
                getTableColumnInfoDTO.setModeName(modeName);
                String val = getTableColumnInfoDTO.getVal();
                //是否存在于原本表中 返回库中原本数据
                ColumnResult columnResult = judgeColumnResultList(columnResultList, getTableColumnInfoDTO, columnId);
                StandardvalueResult standardvalueResultU = judgeStandardvalueResultList(standardvalueInfoList, getTableColumnInfoDTO, columnId);
                ColumnResult columnResultUp = null;
                StandardvalueResult StandardvalueResultUp = null;
                if (columnResult != null) {
                    columnResultUp = upColumnResult(columnResult, getTableColumnInfoDTO, principleId);
                }
                if (standardvalueResultU != null) {
                    StandardvalueResultUp = upStandardvalueResult(standardvalueResultU, getTableColumnInfoDTO, principleId);
                }
                //判断是否符合标准值
                Boolean contains = judgeStandardvalue(standardvalue, val);
                String standardvalueMapping = getStandardvalueMapping(standardvalue, hospitalId);
                //符合标准值，直接跳过
                if (contains) {
                    if (columnResultUp != null) {
                        columnResultUp.setIsSolved(SolvedStatusEnum.IS_SOLVED.getKey());
                        StandardvalueResultUp.setIsSolved(SolvedStatusEnum.IS_SOLVED.getKey());
                        //加入修改集合
                        upColumnResultList.add(columnResultUp);
                        upStandardvalueResultList.add(StandardvalueResultUp);
                    } else {
                        continue;
                    }
                }
                //不符合标准值  若原表存在则修改，若不存在则新增
                if (!contains) {
                    //原本存在则修改否则新增
                    if (columnResultUp != null) {
                        columnResultUp.setIsSolved(SolvedStatusEnum.NOT_SOLVED.getKey());
                        StandardvalueResultUp.setIsSolved(SolvedStatusEnum.NOT_SOLVED.getKey());
                        //加入修改集合
                        upColumnResultList.add(columnResultUp);
                        upStandardvalueResultList.add(StandardvalueResultUp);
                    } else {
                        //加入校验结果表
                        StandardvalueResult standardvalueResult = new StandardvalueResult();
                        standardvalueResult.setHospitalId(getTableColumnInfoDTO.getHospitalId());
                        standardvalueResult.setBehospitalCode(getTableColumnInfoDTO.getBehospitalCode());
                        standardvalueResult.setModeId(getTableColumnInfoDTO.getModeId());
                        standardvalueResult.setModeName(getTableColumnInfoDTO.getModeName());
                        standardvalueResult.setColumnId(columnId);
                        standardvalueResult.setMappings(standardvalueMapping);
                        standardvalueResult.setBehospitalDate(getTableColumnInfoDTO.getBehospitalDate());
                        if (StringUtil.isNotEmpty(getTableColumnInfoDTO.getRecId())) {
                            standardvalueResult.setHosptialDatatmpCode(getTableColumnInfoDTO.getRecId());
                        }
                        if (StringUtil.isNotEmpty(getTableColumnInfoDTO.getRecTitle())) {
                            standardvalueResult.setHosptialDatatmpName(getTableColumnInfoDTO.getRecTitle());
                        }
                        standardvalueResult.setTableCname(columnInfo.getTableCname());
                        standardvalueResult.setBehospitalDate(getTableColumnInfoDTO.getBehospitalDate());
                        standardvalueResult.setTableEname(columnInfo.getTableEname());
                        standardvalueResult.setColumnCname(columnInfo.getColumnCname());
                        standardvalueResult.setTableVal(getTableColumnInfoDTO.getVal());
                        standardvalueResult.setColumnEname(columnInfo.getColumnEname());
                        standardvalueResult.setHospitalDataCode(getTableColumnInfoDTO.getNumberId());
                        if (principleId != null) {
                            standardvalueResult.setCreator(principleId.toString());
                        }
                        standardvalueResult.setTableId(getTableColumnInfoDTO.getTableId());
                        standardvalueResult.setIsSolved(SolvedStatusEnum.NOT_SOLVED.getKey());
                        standardvalueResult.setSolveTime(new Date());
                        standardvalueResult.setIsAudited(AuditStatusEnum.NOT_AUDIT.getKey());
                        standardvalueResult.setGmtCreate(new Date());
                        standardvalueResult.setGmtModified(new Date());
                        addStandardvalueResultList.add(standardvalueResult);
                        //加入总结果表
                        ColumnResult columnResultAdd = addColumnResult(getTableColumnInfoDTO, columnInfo, columnId, ColumnResultTypeEnum.STANDARD_TYPE.getKey(), principleId);
                        addColumnResultList.add(columnResultAdd);
                    }
                }
            }
        }
        //调用修改接口
        if (ListUtil.isNotEmpty(upStandardvalueResultList)) {
            if (standardvalueResultServiceImpl.saveOrUpdateBatch(upStandardvalueResultList)) {
                if (ListUtil.isNotEmpty(upColumnResultList)) {
                    columnResultServiceImpl.saveOrUpdateBatch(upColumnResultList);
                }
            }
        }
        //调用新增接口
        if (ListUtil.isNotEmpty(addStandardvalueResultList)) {
            if (standardvalueResultServiceImpl.saveBatch(addStandardvalueResultList)) {
                if (ListUtil.isNotEmpty(addColumnResultList)) {
                    addColumnResultList = saveColumnResultStandardvalueResultId(addStandardvalueResultList, addColumnResultList);
                    //将id插入总表新增集合中
                    columnResultServiceImpl.saveBatch(addColumnResultList);
                }
            }
        }
        //调用删除接口
        if (ListUtil.isNotEmpty(judgeTableColumnInfoListMap)) {
            for (Map<Long, List<Long>> longListMap : judgeTableColumnInfoListMap) {
                for (Map.Entry<Long, List<Long>> longListEntry : longListMap.entrySet()) {
                    Long key = longListEntry.getKey();
                    List<Long> value = longListEntry.getValue();
                    if (ListUtil.isNotEmpty(value)) {
                        List<Long> ids = new ArrayList<>();
                        List<StandardvalueResult> standardvalueResults = standardvalueResultFacade.getBaseMapper().selectList(new QueryWrapper<StandardvalueResult>()
                                .eq("is_deleted", IsDeleteEnum.N.getKey())
                                .eq("column_id", key)
                                .in("table_id", value));
                        if (ListUtil.isNotEmpty(standardvalueResults)) {
                            standardvalueResults.stream().forEach(standardvalueResult -> {
                                ids.add(standardvalueResult.getId());
                            });
                        }
                        //删除
                        if (standardvalueResultFacade.remove(new UpdateWrapper<StandardvalueResult>()
                                .eq("is_deleted", IsDeleteEnum.N.getKey())
                                .eq("column_id", key)
                                .in("table_id", value)
                        )) {
                            //删除总表
                            columnResultFacade.remove(new QueryWrapper<ColumnResult>()
                                    .eq("is_deleted", IsDeleteEnum.N.getKey())
                                    .eq("column_id", key)
                                    .in(ListUtil.isNotEmpty(ids), "result_id", ids)
                            );
                        }
                    }
                }
            }
        }

    }


    /**
     * 修改结果总表对象
     *
     * @param columnResult
     * @param getTableColumnInfoDTO
     * @param principleId
     * @return:
     */
    public ColumnResult upColumnResult(ColumnResult columnResult, GetTableColumnInfoDTO getTableColumnInfoDTO, Long principleId) {
        columnResult.setSolveTime(new Date());
        columnResult.setGmtModified(new Date());
        if (principleId != null) {
            columnResult.setModifier(principleId.toString());
        }
        if (StringUtil.isNotEmpty(getTableColumnInfoDTO.getVal())) {
            columnResult.setTableVal(getTableColumnInfoDTO.getVal());
        }
        return columnResult;
    }

    /**
     * 修改结果非空表对象
     *
     * @param getTableColumnInfoDTO
     * @param principleId
     * @return:
     */
    public NonnullResult upNonnullResult(NonnullResult nonnullResult, GetTableColumnInfoDTO getTableColumnInfoDTO, Long principleId) {
        nonnullResult.setSolveTime(new Date());
        nonnullResult.setGmtModified(new Date());
        if (principleId != null) {
            nonnullResult.setModifier(principleId.toString());
        }
        if (StringUtil.isNotEmpty(getTableColumnInfoDTO.getVal())) {
            nonnullResult.setTableVal(getTableColumnInfoDTO.getVal());
        }
        return nonnullResult;
    }

    /**
     * 修改结果正则表对象
     *
     * @param getTableColumnInfoDTO
     * @param principleId
     * @return:
     */
    public RegularResult upRegularResult(RegularResult regularResult, GetTableColumnInfoDTO getTableColumnInfoDTO, Long principleId) {
        regularResult.setSolveTime(new Date());
        regularResult.setGmtModified(new Date());
        if (principleId != null) {
            regularResult.setModifier(principleId.toString());
        }
        if (StringUtil.isNotEmpty(getTableColumnInfoDTO.getVal())) {
            regularResult.setTableVal(getTableColumnInfoDTO.getVal());
        }
        return regularResult;
    }

    /**
     * 修改结果关键值表对象
     *
     * @param getTableColumnInfoDTO
     * @param principleId
     * @return:
     */
    public StandardvalueResult upStandardvalueResult(StandardvalueResult standardvalueResult, GetTableColumnInfoDTO getTableColumnInfoDTO, Long principleId) {
        standardvalueResult.setSolveTime(new Date());
        standardvalueResult.setGmtModified(new Date());
        if (principleId != null) {
            standardvalueResult.setModifier(principleId.toString());
        }
        if (StringUtil.isNotEmpty(getTableColumnInfoDTO.getVal())) {
            standardvalueResult.setTableVal(getTableColumnInfoDTO.getVal());
        }
        return standardvalueResult;
    }

    /**
     * 查询出这段时间内病历总表所有的问题数据
     *
     * @param hospitalId
     * @param behospitalCodeList
     * @param type
     * @return:
     */
    public List<ColumnResult> getColumnResultList(Long hospitalId, List<String> behospitalCodeList, String type) {
        //查询出这段时间内病历所有的问题数据 behospitalCode+type
        return columnResultFacade.getBaseMapper().selectList(new QueryWrapper<ColumnResult>()
                .eq("is_deleted", IsDeleteEnum.N.getKey())
                .eq(hospitalId != null, "hospital_id", hospitalId)
                .eq("type", type)
                .in(ListUtil.isNotEmpty(behospitalCodeList), "behospital_code", behospitalCodeList)
        );
    }

    /**
     * 查询出这段时间内病历非空表所有的问题数据
     *
     * @param hospitalId
     * @param behospitalCodeList
     * @return:
     */
    public List<NonnullResult> getNonnullResultList(Long hospitalId, List<String> behospitalCodeList) {
        //查询出这段时间内病历所有的问题数据 behospitalCode+type
        return nonnullResultFacade.getBaseMapper().selectList(new QueryWrapper<NonnullResult>()
                .eq("is_deleted", IsDeleteEnum.N.getKey())
                .eq(hospitalId != null, "hospital_id", hospitalId)
                .in(ListUtil.isNotEmpty(behospitalCodeList), "behospital_code", behospitalCodeList)
        );
    }

    /**
     * 查询出这段时间内病历正则表所有的问题数据
     *
     * @param hospitalId
     * @param behospitalCodeList
     * @return:
     */
    public List<RegularResult> getRegularResultList(Long hospitalId, List<String> behospitalCodeList) {
        //查询出这段时间内病历所有的问题数据 behospitalCode+type
        return regularResultFacade.getBaseMapper().selectList(new QueryWrapper<RegularResult>()
                .eq("is_deleted", IsDeleteEnum.N.getKey())
                .eq(hospitalId != null, "hospital_id", hospitalId)
                .in(ListUtil.isNotEmpty(behospitalCodeList), "behospital_code", behospitalCodeList)
        );
    }

    /**
     * 查询出这段时间内病历标准值表所有的问题数据
     *
     * @param hospitalId
     * @param behospitalCodeList
     * @return:
     */
    public List<StandardvalueResult> getStandardvalueResult(Long hospitalId, List<String> behospitalCodeList) {
        //查询出这段时间内病历所有的问题数据 behospitalCode+type
        return standardvalueResultFacade.getBaseMapper().selectList(new QueryWrapper<StandardvalueResult>()
                .eq("is_deleted", IsDeleteEnum.N.getKey())
                .eq(hospitalId != null, "hospital_id", hospitalId)
                .in(ListUtil.isNotEmpty(behospitalCodeList), "behospital_code", behospitalCodeList)
        );
    }

    /**
     * 判断总表是否存在该问题数据
     *
     * @param columnResultList
     * @param getTableColumnInfoDTO
     * @param columnId
     * @return:
     */
    public ColumnResult judgeColumnResultList(List<ColumnResult> columnResultList, GetTableColumnInfoDTO getTableColumnInfoDTO, Long columnId) {
        if (ListUtil.isEmpty(columnResultList)) {
            return null;
        }
        for (ColumnResult columnResult : columnResultList) {
            if (columnResult.getColumnId().longValue() == columnId.longValue()) {
                if ((columnResult.getBehospitalCode().equals(getTableColumnInfoDTO.getBehospitalCode())) && columnResult.getTableId().longValue() == getTableColumnInfoDTO.getTableId().longValue()) {
                    return columnResult;
                }
            }
        }
        return null;
    }

    /**
     * 判断全部数据是否存在该条非空数据
     *
     * @param tableColumnVal
     * @param nonnullResultList
     * @param nonnullInfo
     * @return:
     */
    public Map<Long, List<Long>> judgeNonnullList(List<GetTableColumnInfoDTO> tableColumnVal, List<NonnullResult> nonnullResultList, NonnullInfo nonnullInfo) {
        if (ListUtil.isEmpty(tableColumnVal) || ListUtil.isEmpty(nonnullResultList)) {
            return null;
        }
        Map<Long, List<Long>> longListMap = new HashMap<>();
        List<Long> arrayList = new ArrayList<>();
        //获取非空结果表属于该条规则的所有tableId
        List<Long> nonnullTableIdList = new ArrayList<>();
        List<Long> tableColumnValIdList = new ArrayList<>();
        nonnullResultList.stream().filter(nonnullResult -> nonnullResult.getColumnId().longValue() == nonnullInfo.getColumnId().longValue()).forEach(nonnullResult ->
                nonnullTableIdList.add(nonnullResult.getTableId()));
        tableColumnVal.stream().forEach(tableColumn ->
                tableColumnValIdList.add(tableColumn.getTableId()));
        for (Long aLong : nonnullTableIdList) {
            if (!tableColumnValIdList.contains(aLong)) {
                //需要删除的TableId
                arrayList.add(aLong);
            }
        }
        if (ListUtil.isEmpty(arrayList)) {
            return null;
        }
        longListMap.put(nonnullInfo.getColumnId(), arrayList);
        return longListMap;
    }

    /**
     * 判断全部数据是否存在该条正则数据
     *
     * @param tableColumnVal
     * @param regularResultList
     * @param getRegular
     * @return:
     */
    public Map<Long, List<Long>> judgeRegularList(List<GetTableColumnInfoDTO> tableColumnVal, List<RegularResult> regularResultList, GetRegular getRegular) {
        if (ListUtil.isEmpty(tableColumnVal) || ListUtil.isEmpty(regularResultList)) {
            return null;
        }
        Map<Long, List<Long>> longListMap = new HashMap<>();
        List<Long> arrayList = new ArrayList<>();
        //获取非空结果表属于该条规则的所有tableId
        List<Long> regularResultIdList = new ArrayList<>();
        List<Long> tableColumnValIdList = new ArrayList<>();
        regularResultList.stream().filter(regularResult -> regularResult.getColumnId().longValue() == getRegular.getColumnId().longValue()).forEach(regularResult ->
                regularResultIdList.add(regularResult.getTableId()));
        tableColumnVal.stream().forEach(tableColumn ->
                tableColumnValIdList.add(tableColumn.getTableId()));
        for (Long aLong : regularResultIdList) {
            if (!tableColumnValIdList.contains(aLong)) {
                //需要删除的TableId
                arrayList.add(aLong);
            }
        }
        if (ListUtil.isEmpty(arrayList)) {
            return null;
        }
        longListMap.put(getRegular.getColumnId(), arrayList);
        return longListMap;
    }

    /**
     * 判断全部数据是否存在该条标准值数据
     *
     * @param tableColumnVal
     * @param standardvalueResultList
     * @param standardvalueInfo
     * @return:
     */
    public Map<Long, List<Long>> judgeStandardvalueList(List<GetTableColumnInfoDTO> tableColumnVal, List<StandardvalueResult> standardvalueResultList, GetStandardvalueInfoDTO standardvalueInfo) {
        if (ListUtil.isEmpty(tableColumnVal) || ListUtil.isEmpty(standardvalueResultList)) {
            return null;
        }
        Map<Long, List<Long>> longListMap = new HashMap<>();
        List<Long> arrayList = new ArrayList<>();
        //获取非空结果表属于该条规则的所有tableId
        List<Long> standardvalueResultIdList = new ArrayList<>();
        List<Long> tableColumnValIdList = new ArrayList<>();
        standardvalueResultList.stream().filter(standardvalueResult -> standardvalueResult.getColumnId().longValue() == standardvalueInfo.getColumnId().longValue()).forEach(standardvalueResult ->
                standardvalueResultIdList.add(standardvalueResult.getTableId()));
        tableColumnVal.stream().forEach(tableColumn ->
                tableColumnValIdList.add(tableColumn.getTableId()));
        for (Long aLong : standardvalueResultIdList) {
            if (!tableColumnValIdList.contains(aLong)) {
                //需要删除的TableId
                arrayList.add(aLong);
            }
        }
        if (ListUtil.isEmpty(arrayList)) {
            return null;
        }
        longListMap.put(standardvalueInfo.getColumnId(), arrayList);
        return longListMap;
    }

    /**
     * 获取非空表存在该问题的数据
     *
     * @param nonnullResultList
     * @param getTableColumnInfoDTO
     * @param columnId
     * @return:
     */
    public NonnullResult judgeNonnullResultList(List<NonnullResult> nonnullResultList, GetTableColumnInfoDTO getTableColumnInfoDTO, Long columnId) {
        if (ListUtil.isEmpty(nonnullResultList)) {
            return null;
        }
        for (NonnullResult nonnullResult : nonnullResultList) {
            if (nonnullResult.getColumnId().longValue() == columnId.longValue()) {
                if ((nonnullResult.getBehospitalCode().equals(getTableColumnInfoDTO.getBehospitalCode())) && nonnullResult.getTableId().longValue() == getTableColumnInfoDTO.getTableId().longValue()) {
                    return nonnullResult;
                }
            }
        }
        return null;
    }

    /**
     * 获取正则表存在该问题的数据
     *
     * @param regularResultList
     * @param getTableColumnInfoDTO
     * @param columnId
     * @return:
     */
    public RegularResult judgeRegularResultList(List<RegularResult> regularResultList, GetTableColumnInfoDTO getTableColumnInfoDTO, Long columnId) {
        if (ListUtil.isEmpty(regularResultList)) {
            return null;
        }
        for (RegularResult regularResult : regularResultList) {
            if (regularResult.getColumnId().longValue() == columnId.longValue()) {
                if ((regularResult.getBehospitalCode().equals(getTableColumnInfoDTO.getBehospitalCode())) && regularResult.getTableId().longValue() == getTableColumnInfoDTO.getTableId().longValue()) {
                    return regularResult;
                }
            }
        }
        return null;
    }

    /**
     * 获取标准值表存在该问题的数据
     *
     * @param standardvalueResultList
     * @param getTableColumnInfoDTO
     * @param columnId
     * @return:
     */
    public StandardvalueResult judgeStandardvalueResultList(List<StandardvalueResult> standardvalueResultList, GetTableColumnInfoDTO getTableColumnInfoDTO, Long columnId) {
        if (ListUtil.isEmpty(standardvalueResultList)) {
            return null;
        }
        for (StandardvalueResult standardvalueResult : standardvalueResultList) {
            if (standardvalueResult.getColumnId().longValue() == columnId.longValue()) {
                if ((standardvalueResult.getBehospitalCode().equals(getTableColumnInfoDTO.getBehospitalCode())) && standardvalueResult.getTableId().longValue() == getTableColumnInfoDTO.getTableId().longValue()) {
                    return standardvalueResult;
                }
            }
        }
        return null;
    }

    /**
     * 新增总表插入非空子表id
     *
     * @return:
     */
    public List<ColumnResult> saveColumnResultNonnullId(List<NonnullResult> addNonnullResultList, List<ColumnResult> addColumnResultList) {
        ad:
        for (NonnullResult nonnullResult : addNonnullResultList) {
            for (ColumnResult columnResult : addColumnResultList) {
                if ((nonnullResult.getColumnId().longValue() == columnResult.getColumnId().longValue()) && (nonnullResult.getBehospitalCode().equals(columnResult.getBehospitalCode()))
                        && (nonnullResult.getTableId().longValue() == columnResult.getTableId().longValue())
                ) {
                    columnResult.setResultId(nonnullResult.getId());
                    continue ad;
                }
            }
        }
        return addColumnResultList;
    }

    /**
     * 新增总表插入正则子表id
     *
     * @return:
     */
    public List<ColumnResult> saveColumnResultRegularResultId(List<RegularResult> addRegularResultList, List<ColumnResult> addColumnResultList) {
        ad:
        for (RegularResult regularResult : addRegularResultList) {
            for (ColumnResult columnResult : addColumnResultList) {
                if ((regularResult.getColumnId().longValue() == columnResult.getColumnId().longValue()) && (regularResult.getBehospitalCode().equals(columnResult.getBehospitalCode()))
                        && (regularResult.getTableId().longValue() == columnResult.getTableId().longValue())
                ) {
                    columnResult.setResultId(regularResult.getId());
                    continue ad;
                }
            }
        }
        return addColumnResultList;
    }

    /**
     * 新增总表插入标准值子表id
     *
     * @return:
     */
    public List<ColumnResult> saveColumnResultStandardvalueResultId(List<StandardvalueResult> addStandardvalueResultList, List<ColumnResult> addColumnResultList) {
        ad:
        for (StandardvalueResult standardvalueResult : addStandardvalueResultList) {
            for (ColumnResult columnResult : addColumnResultList) {
                if ((standardvalueResult.getColumnId().longValue() == columnResult.getColumnId().longValue()) && (standardvalueResult.getBehospitalCode().equals(columnResult.getBehospitalCode()))
                        && (standardvalueResult.getTableId().longValue() == columnResult.getTableId().longValue())
                ) {
                    columnResult.setResultId(standardvalueResult.getId());
                    continue ad;
                }
            }
        }
        return addColumnResultList;
    }

    /**
     * 根据表名称字段名称获取具体数据
     *
     * @param getTableColumnInfoVO
     * @return: 具体数据
     */
    public List<GetTableColumnInfoDTO> getTableColumnVal(GetTableColumnInfoVO getTableColumnInfoVO, List<String> recColumnTable) {
        //判断此规则是否包含rec_id
        if (ListUtil.isNotEmpty(recColumnTable) && recColumnTable.contains(getTableColumnInfoVO.getTableEname())) {
            List<GetTableColumnInfoDTO> tableColumnVal = columnResultFacade.getBaseMapper().getRecSpecialTableColumnVal(getTableColumnInfoVO);
            return tableColumnVal;
        }
        List<GetTableColumnInfoDTO> tableColumnVal = columnResultFacade.getBaseMapper().getSpecialTableColumnVal(getTableColumnInfoVO);
        return tableColumnVal;
    }

    /**
     * 判断值是否属于标准值
     *
     * @param standardvalue
     * @param value
     * @return:
     */
    public Boolean judgeStandardvalue(String standardvalue, String value) {
        if (StringUtil.isEmpty(value)) {
            return false;
        } else {
            if (standardvalue.contains(value)) {
                return true;
            }
        }
        return false;
    }

    /**
     * 判断值是否属于正则
     *
     * @param regular
     * @param value
     * @return:
     */
    public Boolean judgeRegular(String regular, String value) {
        if (StringUtil.isEmpty(value)) {
            return false;
        } else {
            if (value.matches(regular)) {
                return true;
            }
        }
        return false;
    }

    /**
     * 新增校验结果总表信息
     *
     * @param getTableColumnInfoDTO
     * @param columnInfo
     * @param columnId
     * @param type
     * @return:
     */
    public ColumnResult addColumnResult(GetTableColumnInfoDTO getTableColumnInfoDTO, ColumnInfo columnInfo, Long columnId, String type, Long principleId) {
        ColumnResult columnResult = new ColumnResult();
        columnResult.setHospitalId(getTableColumnInfoDTO.getHospitalId());
        columnResult.setBehospitalCode(getTableColumnInfoDTO.getBehospitalCode());
        columnResult.setModeId(getTableColumnInfoDTO.getModeId());
        columnResult.setModeName(getTableColumnInfoDTO.getModeName());
        if (StringUtil.isNotEmpty(getTableColumnInfoDTO.getRecId())) {
            columnResult.setHosptialDatatmpCode(getTableColumnInfoDTO.getRecId());
        }
        if (StringUtil.isNotEmpty(getTableColumnInfoDTO.getRecTitle())) {
            columnResult.setHosptialDatatmpName(getTableColumnInfoDTO.getRecTitle());
        }
        columnResult.setHospitalDataCode(getTableColumnInfoDTO.getNumberId());
        columnResult.setColumnId(columnId);
        if (principleId != null) {
            columnResult.setCreator(principleId.toString());
        }
        columnResult.setBehospitalDate(getTableColumnInfoDTO.getBehospitalDate());
        columnResult.setTableCname(columnInfo.getTableCname());
        columnResult.setTableEname(columnInfo.getTableEname());
        columnResult.setColumnCname(columnInfo.getColumnCname());
        columnResult.setColumnEname(columnInfo.getColumnEname());
        columnResult.setTableId(getTableColumnInfoDTO.getTableId());
        columnResult.setTableVal(getTableColumnInfoDTO.getVal());
        //数据缺失
        if (ColumnResultTypeEnum.NONNULL_TYPE.getKey().equals(type)) {
            columnResult.setType(ColumnResultTypeEnum.NONNULL_TYPE.getKey());
        }
        //关键值
        if (ColumnResultTypeEnum.STANDARD_TYPE.getKey().equals(type)) {
            columnResult.setType(ColumnResultTypeEnum.STANDARD_TYPE.getKey());
        }
        //正则
        if (ColumnResultTypeEnum.REGULAR_TYPE.getKey().equals(type)) {
            columnResult.setType(ColumnResultTypeEnum.REGULAR_TYPE.getKey());
        }
        columnResult.setIsSolved(SolvedStatusEnum.NOT_SOLVED.getKey());
        columnResult.setSolveTime(new Date());
        columnResult.setIsAudited(AuditStatusEnum.NOT_AUDIT.getKey());
        columnResult.setGmtCreate(new Date());
        columnResult.setGmtModified(new Date());
        return columnResult;
    }


    /**
     * 根据表明获取该表的编号字段
     *
     * @param tableCname
     * @return:
     */
    public String getColumnNumber(String tableCname) {
        String columnEname = null;
        List<ColumnInfo> columnInfoList = columnInfoFacade.getBaseMapper().selectList(new QueryWrapper<ColumnInfo>()
                .eq("is_deleted", IsDeleteEnum.N.getKey())
                .eq("type", ColumnTypeEnum.FIELD_NUMBER.getKey())
        );
        for (ColumnInfo columnInfo : columnInfoList) {
            String tableCname1 = columnInfo.getTableCname();
            if (tableCname.equals(tableCname1)) {
                columnEname = columnInfo.getColumnEname();
            }
        }
        return columnEname;
    }

    /**
     * 获取关键值映射
     *
     * @param standardvalue
     * @param hospitalId
     * @return:
     */
    public String getStandardvalueMapping(String standardvalue, Long hospitalId) {
        String[] split = standardvalue.split(";");
        StringBuffer stringBuffer = new StringBuffer();
        for (String s : split) {
            stringBuffer = stringBuffer.append(hospitalId).append("-").append(s).append(",");
        }
        String toString = stringBuffer.deleteCharAt(stringBuffer.length() - 1).toString();
        return toString;
    }

}
