package com.ruoyi.system.service.impl;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.TypeReference;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.http.HttpClientUtils;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.mapper.*;
import com.ruoyi.system.service.IUserInfoService;
import com.ruoyi.system.service.OdsQssHsjcxxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.io.IOException;
import java.net.URLDecoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static com.ruoyi.common.utils.SecurityUtils.getLoginUser;

/**
 * 导入人员信息Service业务层处理
 *
 * @author ruoyi
 * @date 2022-08-11
 */
@Service
public class UserInfoServiceImpl implements IUserInfoService {
    @Autowired
    private UserInfoMapper userInfoMapper;
    @Autowired
    private OdsQssHsjcxxService qdsQssHsjcxxService;
    @Autowired
    private UserNucleicTimeMapper userNucleicTimeMapper;
    @Autowired
    private UserInfoOneMapper userInfoOneMapper;
    @Autowired
    private KeyPeopleInfoMapper keyPeopleInfoMapper;

    /**
     * 查询导入人员信息
     *
     * @param id 导入人员信息主键
     * @return 导入人员信息
     */
    @Override
    public UserInfo selectUserInfoById(Long id) {
        return userInfoMapper.selectUserInfoById(id);
    }

    /**
     * 查询导入人员信息列表
     *
     * @param userInfo 导入人员信息
     * @return 导入人员信息
     */
    @Override
    public List<UserInfo> selectUserInfoList(UserInfo userInfo) {
        SysUser user = getLoginUser().getUser();
        userInfo.setDeptId(String.valueOf(user.getDeptId()));
        return userInfoMapper.selectUserInfoList(userInfo);
    }


    /**
     * 新增导入人员信息
     *
     * @param userInfo 导入人员信息
     * @return 结果
     */
    @Override
    public int insertUserInfo(UserInfo userInfo) {
        userInfo.setCreateTime(DateUtils.getNowDate());
        return userInfoMapper.insertUserInfo(userInfo);
    }

    /**
     * 修改导入人员信息
     *
     * @param userInfo 导入人员信息
     * @return 结果
     */
    @Override
    public int updateUserInfo(UserInfo userInfo) {
        userInfo.setUpdateTime(DateUtils.getNowDate());
        return userInfoMapper.updateUserInfo(userInfo);
    }

    /**
     * 批量删除导入人员信息
     *
     * @param ids 需要删除的导入人员信息主键
     * @return 结果
     */
    @Override
    public int deleteUserInfoByIds(Long[] ids) {
        return userInfoMapper.deleteUserInfoByIds(ids);
    }

    /**
     * 删除导入人员信息信息
     *
     * @param id 导入人员信息主键
     * @return 结果
     */
    @Override
    public int deleteUserInfoById(Long id) {
        return userInfoMapper.deleteUserInfoById(id);
    }


    @Override
    @Transactional(rollbackFor = Exception.class)
    @Async
    public String date(UserInfo userInfoP,SysUser user) throws Exception {


        System.out.println("接口开始========");
        long start1 = System.currentTimeMillis();

        //获取人员信息
        KeyPeopleInfo keyPeopleInfo = new KeyPeopleInfo();
        keyPeopleInfo.setDeptId(user.getDeptId().toString());
        List<KeyPeopleInfo> keyPeopleInfoList = keyPeopleInfoMapper.selectKeyPeopleInfoList(keyPeopleInfo);
        if(keyPeopleInfoList==null || keyPeopleInfoList.size()<=0){
            return "请先上传该部门重点人员";
        }
        String startTime = userInfoP.getStartTime();
        String endTime = userInfoP.getEndTime();
        String detectionNumber = userInfoP.getDetectionNumber();

        //计算开始时间结束时间相隔天数
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date date1 = simpleDateFormat.parse(startTime);
        Date date2 = simpleDateFormat.parse(endTime);
        String detectionScope = String.valueOf(DateUtils.differentDaysByMillisecond(date1, date2));
        userInfoP.setDetectionScope(detectionScope);

        List<String> idCardList = keyPeopleInfoList.stream().map(KeyPeopleInfo::getIdCard).collect(Collectors.toList());
        //从第三方数据库查询人员核酸计录
        List<OdsQssHsjcxx> OdsQssHsjcxxList = qdsQssHsjcxxService.thirdNucleicAcid(startTime, endTime, idCardList);

        Map<String, List<OdsQssHsjcxx>> OdsQssHsjcxxMapSorted = new HashMap<>();
        if (OdsQssHsjcxxList != null && OdsQssHsjcxxList.size() > 0) {
            OdsQssHsjcxxMapSorted = OdsQssHsjcxxList.stream().sorted(Comparator.comparing(OdsQssHsjcxx::getCjsj).reversed()).collect(Collectors.groupingBy(OdsQssHsjcxx::getSfzhm));
        }
        //把采集时间降序
        List<UserNucleicTime> UserNucleicTimeList = new ArrayList<>();


        int index = 0;
        int count = 0;
        List<UserInfo> userList = new ArrayList<>();

        for (KeyPeopleInfo peopleInfo : keyPeopleInfoList) {
            UserInfo userInfo = new UserInfo();
            userInfo.setDeptId(user.getDeptId().toString());
            userInfo.setPhoneNum(peopleInfo.getPhoneNum());
            userInfo.setName(peopleInfo.getName());
            userInfo.setIdCard(peopleInfo.getIdCard());

            //采集地点
            StringBuilder collectPlace = new StringBuilder();
            //核酸采集时间
            StringBuilder nucleicCollectTime = new StringBuilder();
            //核酸结果时间
            StringBuilder nucleicResultsTime = new StringBuilder();
            //核酸结果
            StringBuilder nucleicResults = new StringBuilder();


            userInfo.setJobStyle(userInfoP.getJobStyle());
            userInfo.setFocusCrowdStyle(userInfoP.getFocusCrowdStyle());
            userInfo.setDetectionFrequency(detectionNumber + "/" + detectionScope);
            userInfo.setDetectionNumber(detectionNumber);
            userInfo.setDetectionScope(detectionScope);
            userInfo.setStartTime(startTime);
            userInfo.setEndTime(endTime);
            //判断结果是否合格,默认合格
            Boolean bl = true;

            index = 0;
            count = 0;
            String PhoneNum = "";
            if (OdsQssHsjcxxMapSorted.size() > 0) {
                //身份证号码
                String idCard = userInfo.getIdCard();
                List<OdsQssHsjcxx> odsQssHsjcxxes = OdsQssHsjcxxMapSorted.get(idCard);
                if (odsQssHsjcxxes != null && odsQssHsjcxxes.size() > 0) {
                    //String time = null;

                    for (OdsQssHsjcxx odsQssHsjcxx : odsQssHsjcxxes) {


                        if(StringUtils.isEmpty(PhoneNum)){
                            PhoneNum = odsQssHsjcxx.getSjhm();
                        }

                        if (StringUtils.isNotEmpty(collectPlace.toString())) {
                            collectPlace.append("<br>");
                        }
                        collectPlace.append(odsQssHsjcxx.getJcdd());

                        if (StringUtils.isNotEmpty(nucleicCollectTime.toString())) {
                            nucleicCollectTime.append("<br>");
                        }
                        nucleicCollectTime.append(odsQssHsjcxx.getCjsj());

                        if (StringUtils.isNotEmpty(nucleicResultsTime.toString())) {
                            nucleicResultsTime.append("<br>");
                        }
                        nucleicResultsTime.append(odsQssHsjcxx.getJgcjss());

                        if (StringUtils.isNotEmpty(nucleicResults.toString())) {
                            nucleicResults.append("<br>");
                        }
                        if(StringUtils.isEmpty(odsQssHsjcxx.getJcjg())){
                            nucleicResults.append(odsQssHsjcxx.getJcjg());
                        }else if("0".equals(odsQssHsjcxx.getJcjg()) || "negative".equals(odsQssHsjcxx.getJcjg())){
                            nucleicResults.append("阴性");
                        }else if("1".equals(odsQssHsjcxx.getJcjg()) || "positive".equals(odsQssHsjcxx.getJcjg())){
                            nucleicResults.append("阳性");
                        }else{
                            nucleicResults.append(odsQssHsjcxx.getJcjg());
                        }

                    }
                    index = odsQssHsjcxxes.size();
                }


            }
            if (index < Integer.parseInt(detectionNumber)) {
                bl = false;
            }

            userInfo.setPhoneNum(PhoneNum);
            userInfo.setCollectPlace(collectPlace.toString());
            userInfo.setNucleicCollectTime(nucleicCollectTime.toString());
            userInfo.setNucleicResultsTime(nucleicResultsTime.toString());
            userInfo.setNucleicResults(nucleicResults.toString());
            userInfo.setDetectionProgress(index + "/" + detectionNumber);
            PhoneNum = "";
            if (bl) {
                userInfo.setDetectionResult("正常");
            } else {
                userInfo.setDetectionResult("异常");
            }

            userList.add(userInfo);
        }
        if (OdsQssHsjcxxList != null && OdsQssHsjcxxList.size() > 0) {
            for (OdsQssHsjcxx odsQssHsjcxx : OdsQssHsjcxxList) {
                for (UserInfo userInfo : userList) {
                    if (userInfo.getIdCard().equals(odsQssHsjcxx.getSfzhm())) {
                        UserNucleicTime userNucleicTime = new UserNucleicTime();
                        userNucleicTime.setInfoId(userInfo.getId());
                        userNucleicTime.setIdCard(odsQssHsjcxx.getSfzhm());
                        userNucleicTime.setCollectPlace(odsQssHsjcxx.getJcdd());
                        userNucleicTime.setNucleicCollectTime(odsQssHsjcxx.getCjsj());
                        userNucleicTime.setNucleicResultsTime(odsQssHsjcxx.getJgcjss());
                        userNucleicTime.setJobStyle(userInfoP.getJobStyle());
                        userNucleicTime.setFocusCrowdStyle(userInfoP.getFocusCrowdStyle());
                        userNucleicTime.setName(userInfo.getName());
                        userNucleicTime.setPhoneNum(userInfo.getPhoneNum());
                        userNucleicTime.setDeptId(user.getDeptId().toString());
                        UserNucleicTimeList.add(userNucleicTime);
                        userNucleicTime.setDateSource("批量导入");
                    }
                }
            }
        }

        //批量保存
        userInfoMapper.insertUserInfoList(userList);
        userNucleicTimeMapper.insertUserNucleicTimeList(UserNucleicTimeList);

        long end1 = System.currentTimeMillis();
        System.out.println("---------------接口耗时" + (end1 - start1) + "---------------");

        return "操作成功";
    }


    /**
     * 核酸比对人员导入
     *
     * @param jobStyle        职业类别
     * @param focusCrowdStyle 重点人群分类
     * @param detectionNumber 检测频次（次数）
     * @param detectionScope  检测频次（时间范围）
     * @param startTime       比对开始时间
     * @param endTime         比对结束时间
     * @return
     * @throws Exception
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    @Async
    public String importUser(List<UserInfo> userList, String jobStyle, String focusCrowdStyle, String detectionNumber,
                             String detectionScope, String startTime, String endTime, SysUser user) throws Exception {

        if (userList == null) {
            return "表格格式错误，请按照表格模板格式上传人员名单";
        }

        System.out.println("接口开始========");
        long start1 = System.currentTimeMillis();

        StringBuilder sb = new StringBuilder();
        for (UserInfo userInfo : userList) {
            if (userInfo == null) {
                return "表格格式错误，请按照表格模板格式上传人员名单";
            }
            if (userInfo.getIdCard().indexOf('x') != -1) { //判断是不是有X
                //如果有X，就改成统一的大写X
                userInfo.setIdCard(userInfo.getIdCard().replace("x", "X"));
            }
            userInfo.setIdCard((userInfo.getIdCard()).replaceAll("\\s*|\r|\n|\t",""));
            if (userInfo.getIdCard().length() != 18) {
                sb.append(userInfo.getName()).append(",");
            }
        }

        if (StringUtils.isNotEmpty(sb.toString())) {
            return "操作失败,以下人员身份证格式错误【" + sb.toString() + "】";
        }

        //计算开始时间结束时间相隔天数
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date date1 = simpleDateFormat.parse(startTime);
        Date date2 = simpleDateFormat.parse(endTime);
        detectionScope = String.valueOf(DateUtils.differentDaysByMillisecond(date1, date2));

        //获取上传名单的所有身份证号
        List<String> idCardList = userList.stream().map(UserInfo::getIdCard).collect(Collectors.toList());

        //从第三方数据库查询人员核酸计录
        List<OdsQssHsjcxx> OdsQssHsjcxxList = qdsQssHsjcxxService.thirdNucleicAcid(startTime, endTime, idCardList);

        Map<String, List<OdsQssHsjcxx>> OdsQssHsjcxxMapSorted = new HashMap<>();
        if (OdsQssHsjcxxList != null && OdsQssHsjcxxList.size() > 0) {
            OdsQssHsjcxxMapSorted = OdsQssHsjcxxList.stream().sorted(Comparator.comparing(OdsQssHsjcxx::getCjsj).reversed()).collect(Collectors.groupingBy(OdsQssHsjcxx::getSfzhm));
        }
        //把采集时间降序
        List<UserNucleicTime> UserNucleicTimeList = new ArrayList<>();

        int index = 0;
        int count = 0;
        String PhoneNum = "";
        for (UserInfo userInfo : userList) {

            System.out.println("我在循环");
            userInfo.setDeptId(user.getDeptId().toString());
            //采集地点
            StringBuilder collectPlace = new StringBuilder();
            //核酸采集时间
            StringBuilder nucleicCollectTime = new StringBuilder();
            //核酸结果时间
            StringBuilder nucleicResultsTime = new StringBuilder();
            //核酸结果
            StringBuilder nucleicResults = new StringBuilder();


            userInfo.setJobStyle(jobStyle);
            userInfo.setFocusCrowdStyle(focusCrowdStyle);
            userInfo.setDetectionFrequency(detectionNumber + "/" + detectionScope);
            userInfo.setDetectionNumber(detectionNumber);
            userInfo.setDetectionScope(detectionScope);
            userInfo.setStartTime(startTime);
            userInfo.setEndTime(endTime);
            userInfo.setCreateBy(user.getUserName());
            userInfo.setUpdateBy(user.getUserName());
            //判断结果是否合格,默认合格
            Boolean bl = true;

            index = 0;
            count = 0;
            if (OdsQssHsjcxxMapSorted.size() > 0) {
                //身份证号码
                String idCard = userInfo.getIdCard();
                List<OdsQssHsjcxx> odsQssHsjcxxes = OdsQssHsjcxxMapSorted.get(idCard);
                if (odsQssHsjcxxes != null && odsQssHsjcxxes.size() > 0) {
                    //String time = null;

                    for (OdsQssHsjcxx odsQssHsjcxx : odsQssHsjcxxes) {

                        /*if(StringUtils.isEmpty(time)){
                            time = odsQssHsjcxx.getCjsj();
                            index++;
                        }else{
                            Long hours = DateUtils.getDateHour(odsQssHsjcxx.getCjsj(),time);
                            if(hours>=24){
                                index++;
                            }
                        }*/
                        if(StringUtils.isEmpty(PhoneNum)){
                            PhoneNum = odsQssHsjcxx.getSjhm();
                        }


                        if (StringUtils.isNotEmpty(collectPlace.toString())) {
                            collectPlace.append("<br>");
                        }
                        collectPlace.append(odsQssHsjcxx.getJcdd());

                        if (StringUtils.isNotEmpty(nucleicCollectTime.toString())) {
                            nucleicCollectTime.append("<br>");
                        }
                        nucleicCollectTime.append(odsQssHsjcxx.getCjsj());

                        if (StringUtils.isNotEmpty(nucleicResultsTime.toString())) {
                            nucleicResultsTime.append("<br>");
                        }
                        nucleicResultsTime.append(odsQssHsjcxx.getJgcjss());

                        if (StringUtils.isNotEmpty(nucleicResults.toString())) {
                            nucleicResults.append("<br>");
                        }
                        if(StringUtils.isEmpty(odsQssHsjcxx.getJcjg())){
                            nucleicResults.append(odsQssHsjcxx.getJcjg());
                        }else if("0".equals(odsQssHsjcxx.getJcjg()) || "negative".equals(odsQssHsjcxx.getJcjg())){
                            nucleicResults.append("阴性");
                        }else if("1".equals(odsQssHsjcxx.getJcjg()) || "positive".equals(odsQssHsjcxx.getJcjg())){
                            nucleicResults.append("阳性");
                        }else{
                            nucleicResults.append(odsQssHsjcxx.getJcjg());
                        }

                    }
                    index = odsQssHsjcxxes.size();
                }


            }
            if (index < Integer.parseInt(detectionNumber)) {
                bl = false;
            }
            userInfo.setPhoneNum(PhoneNum);
            userInfo.setCollectPlace(collectPlace.toString());
            userInfo.setNucleicCollectTime(nucleicCollectTime.toString());
            userInfo.setNucleicResultsTime(nucleicResultsTime.toString());
            userInfo.setNucleicResults(nucleicResults.toString());
            userInfo.setDetectionProgress(index + "/" + detectionNumber);
            PhoneNum = "";

            if (bl) {
                userInfo.setDetectionResult("正常");
            } else {
                userInfo.setDetectionResult("异常");
            }

        }

        if (OdsQssHsjcxxList != null && OdsQssHsjcxxList.size() > 0) {
            for (OdsQssHsjcxx odsQssHsjcxx : OdsQssHsjcxxList) {
                for (UserInfo userInfo : userList) {
                    if (userInfo.getIdCard().equals(odsQssHsjcxx.getSfzhm())) {
                        UserNucleicTime userNucleicTime = new UserNucleicTime();
                        userNucleicTime.setInfoId(userInfo.getId());
                        userNucleicTime.setIdCard(odsQssHsjcxx.getSfzhm());
                        userNucleicTime.setCollectPlace(odsQssHsjcxx.getJcdd());
                        userNucleicTime.setNucleicCollectTime(odsQssHsjcxx.getCjsj());
                        userNucleicTime.setNucleicResultsTime(odsQssHsjcxx.getJgcjss());
                        userNucleicTime.setJobStyle(jobStyle);
                        userNucleicTime.setFocusCrowdStyle(focusCrowdStyle);
                        userNucleicTime.setName(userInfo.getName());
                        userNucleicTime.setPhoneNum(userInfo.getPhoneNum());
                        userNucleicTime.setDeptId(user.getDeptId().toString());
                        UserNucleicTimeList.add(userNucleicTime);
                        userNucleicTime.setDateSource("批量导入");
                    }
                }
            }
        }

        //批量保存
        userInfoMapper.insertUserInfoList(userList);
        userNucleicTimeMapper.insertUserNucleicTimeList(UserNucleicTimeList);

        long end1 = System.currentTimeMillis();
        System.out.println("---------------接口耗时" + (end1 - start1) + "---------------");

        return "操作成功";
    }

    @Override
    public AjaxResult oneDate(UserInfo userInfo) throws Exception {
        if (StringUtils.isEmpty(userInfo.getIdCard())) {
            return AjaxResult.error("请填写身份证号");
        }
        if (StringUtils.isEmpty(userInfo.getStartTime()) || StringUtils.isEmpty(userInfo.getEndTime()) ||
                StringUtils.isEmpty(userInfo.getDetectionNumber())) {
            return AjaxResult.error("请将参数填写完整后查询");
        }

        SysUser user = getLoginUser().getUser();

        String startTime = userInfo.getStartTime();
        String endTime = userInfo.getEndTime();
        String detectionNumber = userInfo.getDetectionNumber();


        //计算开始时间结束时间相隔天数
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date date1 = simpleDateFormat.parse(startTime);
        Date date2 = simpleDateFormat.parse(endTime);
        String detectionScope = String.valueOf(DateUtils.differentDaysByMillisecond(date1, date2));
        userInfo.setDetectionScope(detectionScope);


        List<String> idCardList = new ArrayList<>();
        idCardList.add(userInfo.getIdCard());
        //从第三方数据库查询人员核酸计录
        List<OdsQssHsjcxx> OdsQssHsjcxxList = qdsQssHsjcxxService.thirdNucleicAcid(userInfo.getStartTime(), userInfo.getEndTime(), idCardList);
        if (OdsQssHsjcxxList == null || OdsQssHsjcxxList.size() <= 0) {
            return AjaxResult.success("暂无数据");
        }

        userInfo.setName(OdsQssHsjcxxList.get(0).getXm());
        userInfo.setPhoneNum(OdsQssHsjcxxList.get(0).getSjhm());
        userInfo.setDetectionFrequency(detectionNumber + "/" + detectionScope);

        int index = 0;

        //采集地点
        StringBuilder collectPlace = new StringBuilder();
        //核酸采集时间
        StringBuilder nucleicCollectTime = new StringBuilder();
        //核酸结果时间
        StringBuilder nucleicResultsTime = new StringBuilder();
        //核酸结果
        StringBuilder nucleicResults = new StringBuilder();

        //判断结果是否合格,默认合格
        Boolean bl = true;


        index = 0;
        for (OdsQssHsjcxx odsQssHsjcxx : OdsQssHsjcxxList) {
            //判断 核酸采集时间是不是在 startTime和date之间
            if (userInfo.getIdCard().equals(odsQssHsjcxx.getSfzhm())) {

                if (StringUtils.isNotEmpty(collectPlace.toString())) {
                    collectPlace.append("<br>");
                }
                collectPlace.append(odsQssHsjcxx.getJcdd());

                if (StringUtils.isNotEmpty(nucleicCollectTime.toString())) {
                    nucleicCollectTime.append("<br>");
                }
                nucleicCollectTime.append(odsQssHsjcxx.getCjsj());

                if (StringUtils.isNotEmpty(nucleicResultsTime.toString())) {
                    nucleicResultsTime.append("<br>");
                }
                nucleicResultsTime.append(odsQssHsjcxx.getJgcjss());

                if (StringUtils.isNotEmpty(nucleicResults.toString())) {
                    nucleicResults.append("<br>");
                }
                if(StringUtils.isEmpty(odsQssHsjcxx.getJcjg())){
                    nucleicResults.append(odsQssHsjcxx.getJcjg());
                }else if("0".equals(odsQssHsjcxx.getJcjg()) || "negative".equals(odsQssHsjcxx.getJcjg())){
                    nucleicResults.append("阴性");
                }else if("1".equals(odsQssHsjcxx.getJcjg()) || "positive".equals(odsQssHsjcxx.getJcjg())) {
                    nucleicResults.append("阳性");
                }else{
                    nucleicResults.append(odsQssHsjcxx.getJcjg());
                }

                index++;
            }
        }
        if (index < Integer.parseInt(detectionNumber)) {
            bl = false;
        }
        userInfo.setDeptId(user.getDeptId().toString());
        userInfo.setCollectPlace(collectPlace.toString());
        userInfo.setNucleicCollectTime(nucleicCollectTime.toString());
        userInfo.setNucleicResultsTime(nucleicResultsTime.toString());
        userInfo.setNucleicResults(nucleicResults.toString());
        userInfo.setDetectionProgress(index + "/" + detectionNumber);
        if (bl) {
            userInfo.setDetectionResult("正常");
        } else {
            userInfo.setDetectionResult("异常");
        }
        List<UserInfo> userList = new ArrayList<>();

        userList.add(userInfo);

        List<UserNucleicTime> UserNucleicTimeList = new ArrayList<>();
        if (OdsQssHsjcxxList != null && OdsQssHsjcxxList.size() > 0) {
            for (OdsQssHsjcxx odsQssHsjcxx : OdsQssHsjcxxList) {
                if (userInfo.getIdCard().equals(odsQssHsjcxx.getSfzhm())) {
                    UserNucleicTime userNucleicTime = new UserNucleicTime();
                    userNucleicTime.setInfoId(userInfo.getId());
                    userNucleicTime.setIdCard(odsQssHsjcxx.getSfzhm());
                    userNucleicTime.setCollectPlace(odsQssHsjcxx.getJcdd());
                    userNucleicTime.setNucleicCollectTime(odsQssHsjcxx.getCjsj());
                    userNucleicTime.setNucleicResultsTime(odsQssHsjcxx.getJgcjss());
                    userNucleicTime.setName(userInfo.getName());
                    userNucleicTime.setPhoneNum(userInfo.getPhoneNum());
                    userNucleicTime.setDeptId(user.getDeptId().toString());
                    userNucleicTime.setDateSource("单人");
                    UserNucleicTimeList.add(userNucleicTime);
                }
            }
        }


        //批量保存
        userInfoMapper.insertUserInfoOne(userInfo);
        userNucleicTimeMapper.insertUserNucleicTimeList(UserNucleicTimeList);


        return AjaxResult.success("操作成功", userList);
    }

    @Override
    public List<UserInfoOne> oneDateList(UserInfoOne userInfoOne) {
        SysUser user = getLoginUser().getUser();
        userInfoOne.setDeptId(String.valueOf(user.getDeptId()));
        return userInfoOneMapper.selectUserInfoOneList(userInfoOne);
    }

    @Override
    public int deleteUserInfoOneByIds(Long[] ids) {
        return userInfoOneMapper.deleteUserInfoOneByIds(ids);
    }


}
