package thyyxxk.webserver.service.technologyArchives;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import thyyxxk.webserver.config.exception.ExceptionEnum;
import thyyxxk.webserver.dao.his.technologyArchives.*;
import thyyxxk.webserver.entity.ComplexSheetData;
import thyyxxk.webserver.entity.HeadInfo;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.dictionary.CodeName;
import thyyxxk.webserver.entity.login.UserInfo;
import thyyxxk.webserver.entity.technologyArchives.*;
import thyyxxk.webserver.service.archive.ArchiveServer;
import thyyxxk.webserver.service.hutoolcache.UserCache;
import thyyxxk.webserver.utils.ExcelUtil;
import thyyxxk.webserver.utils.ResultVoUtil;
import thyyxxk.webserver.utils.StringUtil;

import javax.servlet.http.HttpServletResponse;
import java.util.*;

/**
 * @ClassName HLTechnologyArchivesService
 * @Author XU
 * @Date 2025/4/2
 * @Version 1.0
 * @Description 护理技术档案管理
 **/
@Service
@Slf4j
@RequiredArgsConstructor
public class HLTechnologyArchivesService {

    private final TechnologyArchivesDao dao;

    private final UserCache userCache;

    private final ArchiveServer archiveServer;

    private final TechnologyArchivesHLMainDao hlMainDao;

    private final TechnologyArchivesHL1Dao hl1Dao;

    private final TechnologyArchivesHL2Dao hl2Dao;

    private final TechnologyArchivesHL3Dao hl3Dao;

    private final TechnologyArchivesHL4Dao hl4Dao;

    private final TechnologyArchivesHL5Dao hl5Dao;

    private final TechnologyArchivesHL6Dao hl6Dao;

    private final TechnologyArchivesHL7Dao hl7Dao;

    private final TechnologyArchivesHL9Dao hl9Dao;

    private final TechnologyArchives5Dao fifthDao;

    private final TechnologyArchives7Dao seventhDao;

    private final TechnologyArchives10Dao tenthDao;

    private final TechnologyArchives12Dao twelfthDao;

    private final TechnologyArchives13Dao thirteenthDao;

    private final TechnologyArchives14Dao fourteenthDao;
    @Value("${is-prod}")
    private boolean isProd;
    public String uploadUrl = "http://172.16.32.197:8077/upload";

    /**
     * @param text 工号或者身份证号或姓名
     * @return TechnologyArchivesHLMain
     * @Description 根据工号或者身份证号或姓名查询护理档案基本信息
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<TechnologyArchivesHLMain> selectHLEmployeeInfo(String text) {
        if (StringUtil.notBlank(text) && text.length() >= 5) {
            TechnologyArchivesHLMain main = hlMainDao.selectTechnologyArchivesHLMainBySocialNo(text);
            if (null != main) {
                return ResultVoUtil.success(main);
            }
        }
        TechnologyArchivesHLMain m = dao.selectHLEmployeeInfo(text);
        if (null == m) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "查不到护理基本信息！");
        }
        TechnologyArchivesHLMain m1 = hlMainDao.selectTechnologyArchivesHLMainBySocialNo(m.getSocialNo());
        if (null != m1) {
            return ResultVoUtil.success(m1);
        }
        TechnologyArchivesHLMain m2 = hlMainDao.selectTechnologyArchivesHLMainBySocialNo(m.getAccount());
        if (null != m2) {
            return ResultVoUtil.success(m2);
        }
        //添加姓名搜索
        TechnologyArchivesHLMain m3 =hlMainDao.selectTechnologyArchivesHLMainBySocialNo(m.getName());
        if (null != m3) {
            return ResultVoUtil.success(m3);
        }
        return ResultVoUtil.success(m);
    }

    /**
     * @return map
     * @Description 查询基本信息需要的字典信息
     * @Author hsh
     * @Date 2024/7/8 12:50
     */
    public ResultVo<Map<String, Object>> selectDictInfo() {
        Map<String, Object> resultMap = new HashMap<>();
        // 性别
        List<CodeName> sex = dao.getSexCode();
        resultMap.put("sex", sex);
        // 民族
        List<CodeName> nation = dao.getNation();
        resultMap.put("nation", nation);
        // 籍贯（市）
        List<CodeName> city = dao.getCity();
        resultMap.put("city", city);
        // 政治面貌
        List<CodeName> political = dao.getPolitical();
        resultMap.put("political", political);
        // 专业职称
        List<CodeName> title = dao.getTitle();
        resultMap.put("title", title);
        // 文化程度
        List<CodeName> education = dao.getEducation();
        resultMap.put("education", education);
        List<CodeName> education1 = dao.getEducation();
        resultMap.put("education1", education1);
        return ResultVoUtil.success(resultMap);
    }

    /**
     * @param hltam 基本信息
     * @return map
     * @Description 更新护理文档基本信息
     * @Author XU
     * @Date 2025/4/2
     */

    public ResultVo<Map<String, Object>> saveTechnologyArchivesHLMain(TechnologyArchivesHLMain hltam) {
        Map<String, Object> resultMap = new HashMap<>();

        if (null == hltam || null == hltam.getSocialNo()) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "护理技术文档基本信息不存在或者缺少身份证号，请检查！");
        }

        TechnologyArchivesHLMain main = hlMainDao.selectTechnologyArchivesHLMainBySocialNo(hltam.getSocialNo());

        // 入库或更新操作
        int n;
        if (null == main) {
            UserInfo user = userCache.getUserInfoByToken();
            hltam.setAccount(user.getCodeRs());
            n = hlMainDao.insert(hltam);
        } else {
            UpdateWrapper<TechnologyArchivesHLMain> updateWrapper = new UpdateWrapper<>();
            updateWrapper.eq("social_no",hltam.getSocialNo());
            n = hlMainDao.update(hltam, updateWrapper);
//            n = hlMainDao.updateTechnologyArchivesHLMainBySocialNo(hltam);
        }
        if (n <= 0) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存指标结果失败！");
        }
        resultMap.put("cg", "保存指标结果成功");
        return ResultVoUtil.success(resultMap);
    }


    /**
     * @param socialNo  身份证号
     * @return map
     * @Description 根据身份证查询基本信息个人图片
     * @Author XU
     * @Date 2025/4/2
     */
    //查找图片
    public ResultVo<Map<String, Object>> selectHLImage1(String socialNo) {
        Map<String, Object> map = new HashMap<>();
        Map<String, Object> imgMap = hlMainDao.selectHLImage1(socialNo);
        map.put("data", imgMap);
        return ResultVoUtil.success(map);
    }
    public ResultVo<Map<String, Object>> putPersonalImage(MultipartFile file) {
        UserInfo user = userCache.getUserInfoByToken();
        String code = user.getCodeRs();
        String uploadDir = "/uploadimage/hltechnology/personalImage/" + code;
        Map<String, Object> map = new HashMap<>();
        map.put("data",archiveServer.uploadFile(file,uploadDir,!isProd));
        return ResultVoUtil.success(map);
    }

    /**
     * @param socialNo  身份证号  url 图片链接
     * @Description 根据身份证号来保存上传图片
     * @return map
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<Map<String, Object>> setHLImage(String url, String socialNo) {
        Map<String, Object> map = new HashMap<>();
        String url1 = uploadUrl + url;
        System.out.println(url1);
        int imgMap = hlMainDao.updatePersonalImage(url1, socialNo);
        map.put("data", imgMap);
        return ResultVoUtil.success(map);
    }

    /**
     * @return list
     * @Description 查询所有护理档案类人员主要信息(账号 ， 身份证号 ， 姓名)
     * @Author XU
     * @Date 2025/4/2
     */

    public ResultVo<List<Map<String, Object>>> selectTechnologyArchivesHLMainDict() {
        List<Map<String, Object>> list = hlMainDao.selectTechnologyArchivesHLMainDict();
        return ResultVoUtil.success(list);
    }

    /**
     * @return TechnologyArchivesHL1
     * @Description 根据工号查询专业技术资格证书取得情况
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<List<TechnologyArchivesHL1>> selectTechnologyArchivesHL1() {
        UserInfo user = userCache.getUserInfoByToken();
        QueryWrapper<TechnologyArchivesHL1> querywrapper = new QueryWrapper<>();
        querywrapper.eq("account",user.getCodeRs());
        List<TechnologyArchivesHL1> list = hl1Dao.selectList(querywrapper);
//        List<TechnologyArchivesHL1> list = hl1Dao.selectHL1ListByCode(null, user.getCodeRs());
        return ResultVoUtil.success(list);
    }

    /**
     * @param socialNo  身份证号  geTime 获取时间
     * @Description 根据身份证号和获取时间来查询证书图片
     * @return map
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<Map<String, Object>> selectHL1Image(String socialNo, String getTime) {
        Map<String, Object> map = new HashMap<>();
        Map<String, Object> imgMap = hl1Dao.selectHL1Image(socialNo, getTime);
        map.put("data", imgMap);
        return ResultVoUtil.success(map);
    }

    /**
     * @param hl1 专业技术资格证书取得情况
     * @return map
     * @Description 更新专业技术资格证书取得情况
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<Map<String, Object>> saveTechnologyArchivesHL1(TechnologyArchivesHL1 hl1) {

        if (null == hl1 || hl1.getSocialNo() == null || hl1.getGetTime() == null) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "专业技术资格证书取得情况信息不全，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        String socialNo = hl1.getSocialNo();
        String getTime = hl1.getGetTime();
        TechnologyArchivesHL1 tahl1 = hl1Dao.selectTechnologyArchivesHL1ByGetTime(socialNo, getTime);

        int num;
        try {
            if (null != tahl1) {
                UpdateWrapper<TechnologyArchivesHL1> updateWrapper = new UpdateWrapper<>();
                updateWrapper.eq("social_no",hl1.getSocialNo());
                updateWrapper.eq("get_time",hl1.getGetTime());
                num = hl1Dao.update(hl1, updateWrapper);
//                num = hl1Dao.updateTechnologyArchivesHL1ByGetTime(hl1);
            } else {
                UserInfo user = userCache.getUserInfoByToken();
                hl1.setAccount(user.getCodeRs());
                num = hl1Dao.insert(hl1);
            }
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存专业技术资格证书取得情况失败！");
            }
            resultMap.put("cg", "保存专业技术资格证书取得情况成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存专业技术资格证书取得情况失败！");
        }
    }

    /**
     * @param files 上传文件   title 证书名称
     * @Description 上传图片
     * @return map
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<Map<String, Object>> putHL1CertificateImage(MultipartFile[] files, String title) {
        UserInfo user = userCache.getUserInfoByToken();
        String code = user.getCodeRs();
        String uploadDir = "/uploadimage/hltechnology/certificateImage/" + code + "/" + title;
        Map<String, Object> map = new HashMap<>();
        List<String> urls = new ArrayList<>();
        System.out.println(Arrays.toString(files));
        for (MultipartFile file : files){
            urls.add(archiveServer.uploadFile(file, uploadDir, !isProd).getPath());
        }
        map.put("urls",urls);
        return ResultVoUtil.success(map);
    }

    /**
     * @param socialNo  身份证号  getTime 批准时间 url 图片链接
     * @Description 根据身份证号, 批准时间来保存上传图片
     * @return map
     * @Date 2025/4/2
     */
    public ResultVo<Map<String, Object>> setHL1Image(String socialNo, String getTime, String url) {
        Map<String, Object> map = new HashMap<>();
        int imgMap = hl1Dao.updateHL1CertificateImage(url, socialNo, getTime);
        map.put("data", imgMap);
        return ResultVoUtil.success(map);
    }

    /**
     * @param socialNo 身份证号 getTime 批准时间
     * @return map
     * @Description 根据身份证号, 批准时间删除专业技术资格证书取得情况
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<Map<String, Object>> delTechnologyArchivesHL1ByCode(String socialNo, String getTime) {
        if (StringUtil.isBlank(socialNo) || StringUtil.isBlank(getTime)) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有身份证号或者批准时间，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        try {
            int num = hl1Dao.delTechnologyArchivesHL1ByCode(socialNo, getTime);
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除专业技术职称晋升情况失败！");
            }
            resultMap.put("cg", "删除专业技术职称晋升情况成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除专业技术职称晋升情况失败！");
        }
    }

    /**
     * @return TechnologyArchivesHL2 工作经历
     * @Description 查询工作经历
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<List<TechnologyArchivesHL2>> selectTechnologyArchivesHL2() {
        UserInfo user = userCache.getUserInfoByToken();
        QueryWrapper<TechnologyArchivesHL2> querywrapper = new QueryWrapper<>();
        querywrapper.eq("account",user.getCodeRs());
        List<TechnologyArchivesHL2> list = hl2Dao.selectList(querywrapper);
//        List<TechnologyArchivesHL2> list = hl2Dao.selectHL2ListByCode(null, user.getCodeRs());
        return ResultVoUtil.success(list);
    }

    /**
     * @param HL2
     * @return map
     * @Description 根据身份证号更新工作经历
     * @Author XU
     * @Date 2025/4/2
     */

    public ResultVo<Map<String, Object>> saveTechnologyArchivesHL2(TechnologyArchivesHL2 HL2) {

        if (null == HL2 || HL2.getSocialNo() == null) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "信息不全，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        String socialNo = HL2.getSocialNo();
        Integer id = HL2.getId();
        TechnologyArchivesHL2 taHL2 = hl2Dao.selectTechnologyArchivesHL2ById(socialNo, id);

        int num;
        try {
            if (null != taHL2) {
                String oldSocialNo = HL2.getOldSocialNo();
                if (StringUtil.notBlank(oldSocialNo)) {
                    TechnologyArchivesHL2 oldTaHL2 = hl2Dao.selectTechnologyArchivesHL2ById(oldSocialNo, id);
                    oldTaHL2.setSocialNo(socialNo);
                    int maxId = hl2Dao.selectTechnologyArchivesHL2MaxId(socialNo);
                    oldTaHL2.setId(maxId + 1);
                    num = hl2Dao.insert(oldTaHL2);
                    hl2Dao.delTechnologyArchivesHL2ByCode(oldSocialNo, id);
                } else {
                    UpdateWrapper<TechnologyArchivesHL2> updateWrapper = new UpdateWrapper<>();
                    updateWrapper.eq("social_no",HL2.getSocialNo());
                    updateWrapper.eq("id",HL2.getId());
                    num = hl2Dao.update(HL2, updateWrapper);
//                    num = hl2Dao.updateTechnologyArchivesHL2ById(HL2);
                }
            } else {
                UserInfo user = userCache.getUserInfoByToken();
                int maxId = hl2Dao.selectTechnologyArchivesHL2MaxId(socialNo);
                HL2.setAccount(user.getCodeRs());
                HL2.setId(maxId + 1);
                num = hl2Dao.insert(HL2);
            }
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存工作经历失败！");
            }
            resultMap.put("cg", "保存工作经历成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存工作经历失败！");
        }
    }
    /**
     * @param socialNo 身份证号  id
     * @return map
     * @Description 根据身份证号, id删除工作经历
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<Map<String, Object>> delTechnologyArchivesHL2ByCode(String socialNo, Integer id) {
        if (StringUtil.isBlank(socialNo)) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有身份证号，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        try {
            int num = hl2Dao.delTechnologyArchivesHL2ByCode(socialNo, id);
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除工作经历失败！");
            }
            resultMap.put("cg", "删除工作经历成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除工作经历失败！");
        }
    }
    
    /**
     * @return TechnologyArchivesHL3 教育经历
     * @Description 查询学习经历
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<List<TechnologyArchivesHL3>> selectTechnologyArchivesHL3() {
        UserInfo user = userCache.getUserInfoByToken();
        QueryWrapper<TechnologyArchivesHL3> querywrapper = new QueryWrapper<>();
        querywrapper.eq("account",user.getCodeRs());
        List<TechnologyArchivesHL3> list = hl3Dao.selectList(querywrapper);
//        List<TechnologyArchivesHL3> list = hl3Dao.selectHL3ByCode(null, user.getCodeRs());
        return ResultVoUtil.success(list);
    }

    /**
     * @param HL3
     * @return map
     * @Description 根据身份证号更新教育经历
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<Map<String, Object>> saveTechnologyArchivesHL3(TechnologyArchivesHL3 HL3) {

        if (null == HL3 || HL3.getSocialNo() == null) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "信息不全，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        String socialNo = HL3.getSocialNo();
        Integer id = HL3.getId();
        TechnologyArchivesHL3 taHL3 = hl3Dao.selectTechnologyArchivesHL3ById(socialNo, id);

        int num;
        try {
            if (null != taHL3) {
                String oldSocialNo = HL3.getOldSocialNo();
                if (StringUtil.notBlank(oldSocialNo)) {
                    TechnologyArchivesHL3 oldTaHL3 = hl3Dao.selectTechnologyArchivesHL3ById(oldSocialNo, id);
                    oldTaHL3.setSocialNo(socialNo);
                    int maxId = hl3Dao.selectTechnologyArchivesHL3MaxId(socialNo);
                    oldTaHL3.setId(maxId + 1);
                    num = hl3Dao.insert(oldTaHL3);
                    hl3Dao.delTechnologyArchivesHL3ByCode(oldSocialNo, id);
                } else {
                    UpdateWrapper<TechnologyArchivesHL3> updateWrapper = new UpdateWrapper<>();
                    updateWrapper.eq("social_no",HL3.getSocialNo());
                    updateWrapper.eq("id",HL3.getId());
                    num = hl3Dao.update(HL3, updateWrapper);
//                    num = hl3Dao.updateTechnologyArchivesHL3ById(HL3);
                }
            } else {
                UserInfo user = userCache.getUserInfoByToken();
                int maxId = hl3Dao.selectTechnologyArchivesHL3MaxId(socialNo);
                HL3.setAccount(user.getCodeRs());
                HL3.setId(maxId + 1);
                num = hl3Dao.insert(HL3);
            }
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存教育经历失败！");
            }
            resultMap.put("cg", "保存教育经历成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存教育经历失败！");
        }
    }

    /**
     * @param socialNo 身份证号  id
     * @return map
     * @Description 根据身份证号, id删除教育经历
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<Map<String, Object>> delTechnologyArchivesHL3ByCode(String socialNo, Integer id) {
        if (StringUtil.isBlank(socialNo)) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有身份证号，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        try {
            int num = hl3Dao.delTechnologyArchivesHL3ByCode(socialNo, id);
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除教育经历失败！");
            }
            resultMap.put("cg", "删除教育经历成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除教育经历失败！");
        }
    }

    /**
     * @return TechnologyArchivesHL4 培训经历
     * @Description 查询培训经历
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<List<TechnologyArchivesHL4>> selectTechnologyArchivesHL4() {
        UserInfo user = userCache.getUserInfoByToken();
        QueryWrapper<TechnologyArchivesHL4> querywrapper = new QueryWrapper<>();
        querywrapper.eq("account",user.getCodeRs());
        List<TechnologyArchivesHL4> list = hl4Dao.selectList(querywrapper);
//        List<TechnologyArchivesHL4> list = hl4Dao.selectHL4ByCode(null, user.getCodeRs());
        return ResultVoUtil.success(list);
    }

    //查找图片
    public ResultVo<Map<String, Object>> selectHL4Image(String socialNo, Integer id) {
        Map<String, Object> map = new HashMap<>();
        Map<String, Object> imgMap = hl4Dao.selectHL4Image(socialNo, id);
        map.put("data", imgMap);
        return ResultVoUtil.success(map);
    }

    public ResultVo<Map<String, Object>> putHL4CertificateImage(MultipartFile[] files,String name) {
        UserInfo user = userCache.getUserInfoByToken();
        String code = user.getCodeRs();
        String uploadDir = "/uploadimage/hltechnology/trainingcertificateImage/" + code + "/" + name;
        Map<String, Object> map = new HashMap<>();
        List<String> urls = new ArrayList<>();
        System.out.println(Arrays.toString(files));
        for (MultipartFile file : files){
            urls.add(archiveServer.uploadFile(file, uploadDir, !isProd).getPath());
        }
        map.put("urls",urls);
        return ResultVoUtil.success(map);
    }

    /**
     * @param HL4
     * @return map
     * @Description 根据身份证号更新培训经历
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<Map<String, Object>> saveTechnologyArchivesHL4(TechnologyArchivesHL4 HL4) {

        if (null == HL4 || HL4.getSocialNo() == null) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "信息不全，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        String socialNo = HL4.getSocialNo();
        Integer id = HL4.getId();
        TechnologyArchivesHL4 taHL4 = hl4Dao.selectTechnologyArchivesHL4ById(socialNo, id);

        int num;
        try {
            if (null != taHL4) {
                String oldSocialNo = HL4.getOldSocialNo();
                if (StringUtil.notBlank(oldSocialNo)) {
                    TechnologyArchivesHL4 oldTaHL4 = hl4Dao.selectTechnologyArchivesHL4ById(oldSocialNo, id);
                    oldTaHL4.setSocialNo(socialNo);
                    int maxId = hl4Dao.selectTechnologyArchivesHL4MaxId(socialNo);
                    oldTaHL4.setId(maxId + 1);
                    num = hl4Dao.insert(oldTaHL4);
                    hl4Dao.delTechnologyArchivesHL4ByCode(oldSocialNo, id);
                } else {
                    UpdateWrapper<TechnologyArchivesHL4> updateWrapper = new UpdateWrapper<>();
                    updateWrapper.eq("social_no",HL4.getSocialNo());
                    updateWrapper.eq("id",HL4.getId());
                    num = hl4Dao.update(HL4, updateWrapper);
//                    num = hl4Dao.updateTechnologyArchivesHL4ById(HL4);
                }
            } else {
                UserInfo user = userCache.getUserInfoByToken();
                int maxId = hl4Dao.selectTechnologyArchivesHL4MaxId(socialNo);
                HL4.setAccount(user.getCodeRs());
                HL4.setId(maxId + 1);
                num = hl4Dao.insert(HL4);
            }
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存培训经历失败！");
            }
            resultMap.put("cg", "保存培训经历成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存培训经历失败！");
        }
    }

    /**
     * @param socialNo  身份证号  id 序号 url 图片链接
     * @Description 根据身份证号, 序号来保存上传图片
     * @return map
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<Map<String, Object>> setHL4Image(String socialNo, String beginTime, String url) {
        Map<String, Object> map = new HashMap<>();
        int imgMap = hl4Dao.updateHL4Image(socialNo, beginTime, url);
        map.put("data", imgMap);
        return ResultVoUtil.success(map);
    }

    /**
     * @param socialNo 身份证号  id
     * @return map
     * @Description 根据身份证号, id删除培训经历
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<Map<String, Object>> delTechnologyArchivesHL4ByCode(String socialNo, Integer id) {
        if (StringUtil.isBlank(socialNo)) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有身份证号，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        try {
            int num = hl4Dao.delTechnologyArchivesHL4ByCode(socialNo, id);
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除培训经历失败！");
            }
            resultMap.put("cg", "删除培训经历成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除培训经历失败！");
        }
    }


    /**
     * @return TechnologyArchivesHL5 轮科记录
     * @Description 查询轮科记录
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<List<TechnologyArchivesHL5>> selectTechnologyArchivesHL5() {
        UserInfo user = userCache.getUserInfoByToken();
        QueryWrapper<TechnologyArchivesHL5> querywrapper = new QueryWrapper<>();
        querywrapper.eq("account",user.getCodeRs());
        List<TechnologyArchivesHL5> list = hl5Dao.selectList(querywrapper);
//        List<TechnologyArchivesHL5> list = hl5Dao.selectHL5ByCode(null, user.getCodeRs());
        return ResultVoUtil.success(list);
    }

    /**
     * @param HL5
     * @return map
     * @Description 根据身份证号更新轮科记录
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<Map<String, Object>> saveTechnologyArchivesHL5(TechnologyArchivesHL5 HL5) {

        if (null == HL5 || HL5.getSocialNo() == null) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "信息不全，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        String socialNo = HL5.getSocialNo();
        Integer id = HL5.getId();
        TechnologyArchivesHL5 taHL5 = hl5Dao.selectTechnologyArchivesHL5ById(socialNo, id);

        int num;
        try {
            if (null != taHL5) {
                String oldSocialNo = HL5.getOldSocialNo();
                if (StringUtil.notBlank(oldSocialNo)) {
                    TechnologyArchivesHL5 oldTaHL5 = hl5Dao.selectTechnologyArchivesHL5ById(oldSocialNo, id);
                    oldTaHL5.setSocialNo(socialNo);
                    int maxId = hl5Dao.selectTechnologyArchivesHL5MaxId(socialNo);
                    oldTaHL5.setId(maxId + 1);
                    num = hl5Dao.insert(oldTaHL5);
                    hl5Dao.delTechnologyArchivesHL5ByCode(oldSocialNo, id);
                } else {
                    UpdateWrapper<TechnologyArchivesHL5> updateWrapper = new UpdateWrapper<>();
                    updateWrapper.eq("social_no",HL5.getSocialNo());
                    updateWrapper.eq("id",HL5.getId());
                    num = hl5Dao.update(HL5, updateWrapper);
//                    num = hl5Dao.updateTechnologyArchivesHL5ById(HL5);
                }
            } else {
                UserInfo user = userCache.getUserInfoByToken();
                int maxId = hl5Dao.selectTechnologyArchivesHL5MaxId(socialNo);
                HL5.setAccount(user.getCodeRs());
                HL5.setId(maxId + 1);
                num = hl5Dao.insert(HL5);
            }
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存轮科记录失败！");
            }
            resultMap.put("cg", "保存轮科记录成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存轮科记录失败！");
        }
    }

    /**
     * @param socialNo 身份证号  id
     * @return map
     * @Description 根据身份证号, id删除轮科记录
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<Map<String, Object>> delTechnologyArchivesHL5ByCode(String socialNo, Integer id) {
        if (StringUtil.isBlank(socialNo)) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有身份证号，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        try {
            int num = hl5Dao.delTechnologyArchivesHL5ByCode(socialNo, id);
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除轮科记录失败！");
            }
            resultMap.put("cg", "删除轮科记录成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除轮科记录失败！");
        }
    }

    /**
     * @return TechnologyArchivesHL6 科室调动记录
     * @Description 查询科室调动记录
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<List<TechnologyArchivesHL6>> selectTechnologyArchivesHL6() {
        UserInfo user = userCache.getUserInfoByToken();
        QueryWrapper<TechnologyArchivesHL6> querywrapper = new QueryWrapper<>();
        querywrapper.eq("account",user.getCodeRs());
        List<TechnologyArchivesHL6> list = hl6Dao.selectList(querywrapper);
//        List<TechnologyArchivesHL6> list = hl6Dao.selectHL6ByCode(null, user.getCodeRs());
        return ResultVoUtil.success(list);
    }

    /**
     * @param HL6
     * @return map
     * @Description 根据身份证号更新科室调动记录
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<Map<String, Object>> saveTechnologyArchivesHL6(TechnologyArchivesHL6 HL6) {

        if (null == HL6 || HL6.getSocialNo() == null) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "信息不全，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        String socialNo = HL6.getSocialNo();
        Integer id = HL6.getId();
        TechnologyArchivesHL6 taHL6 = hl6Dao.selectTechnologyArchivesHL6ById(socialNo, id);

        int num;
        try {
            if (null != taHL6) {
                String oldSocialNo = HL6.getOldSocialNo();
                if (StringUtil.notBlank(oldSocialNo)) {
                    TechnologyArchivesHL6 oldTaHL6 = hl6Dao.selectTechnologyArchivesHL6ById(oldSocialNo, id);
                    oldTaHL6.setSocialNo(socialNo);
                    int maxId = hl6Dao.selectTechnologyArchivesHL6MaxId(socialNo);
                    oldTaHL6.setId(maxId + 1);
                    num = hl6Dao.insert(oldTaHL6);
                    hl6Dao.delTechnologyArchivesHL6ByCode(oldSocialNo, id);
                } else {
                    UpdateWrapper<TechnologyArchivesHL6> updateWrapper = new UpdateWrapper<>();
                    updateWrapper.eq("social_no",HL6.getSocialNo());
                    updateWrapper.eq("id",HL6.getId());
                    num = hl6Dao.update(HL6, updateWrapper);
//                    num = hl6Dao.updateTechnologyArchivesHL6ById(HL6);
                }
            } else {
                UserInfo user = userCache.getUserInfoByToken();
                int maxId = hl6Dao.selectTechnologyArchivesHL6MaxId(socialNo);
                HL6.setAccount(user.getCodeRs());
                HL6.setId(maxId + 1);
                num = hl6Dao.insert(HL6);
            }
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存科室调动记录失败！");
            }
            resultMap.put("cg", "保存科室调动记录成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存科室调动记录失败！");
        }
    }

    /**
     * @param socialNo 身份证号  id
     * @return map
     * @Description 根据身份证号, id删除科室调动记录
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<Map<String, Object>> delTechnologyArchivesHL6ByCode(String socialNo, Integer id) {
        if (StringUtil.isBlank(socialNo)) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有身份证号，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        try {
            int num = hl6Dao.delTechnologyArchivesHL6ByCode(socialNo, id);
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除科室调动记录失败！");
            }
            resultMap.put("cg", "删除科室调动记录成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除科室调动记录失败！");
        }
    }

    /**
     * @return TechnologyArchivesHL7 休假记录
     * @Description 查询休假记录
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<List<TechnologyArchivesHL7>> selectTechnologyArchivesHL7() {
        UserInfo user = userCache.getUserInfoByToken();
        QueryWrapper<TechnologyArchivesHL7> querywrapper = new QueryWrapper<>();
        querywrapper.eq("account",user.getCodeRs());
        List<TechnologyArchivesHL7> list = hl7Dao.selectList(querywrapper);
//        List<TechnologyArchivesHL7> list = hl7Dao.selectHL7ByCode(null, user.getCodeRs());
        return ResultVoUtil.success(list);
    }

    //查找图片
    public ResultVo<Map<String, Object>> selectHL7Image(String socialNo, Integer id) {
        Map<String, Object> map = new HashMap<>();
        Map<String, Object> imgMap = hl7Dao.selectHL7Image(socialNo, id);
        map.put("data", imgMap);
        return ResultVoUtil.success(map);
    }

    public ResultVo<Map<String, Object>> putHL7CertificateImage(MultipartFile[] files,String approvalTime) {
        UserInfo user = userCache.getUserInfoByToken();
        String code = user.getCodeRs();
        String uploadDir = "/uploadimage/hltechnology/holidaycertificateImage/" + code + "/" + approvalTime;
        Map<String, Object> map = new HashMap<>();
        List<String> urls = new ArrayList<>();
        System.out.println(Arrays.toString(files));
        for (MultipartFile file : files){
            urls.add(archiveServer.uploadFile(file, uploadDir, !isProd).getPath());
        }
        map.put("urls",urls);
        return ResultVoUtil.success(map);
    }
    /**
     * @param HL7
     * @return map
     * @Description 根据身份证号更新休假记录
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<Map<String, Object>> saveTechnologyArchivesHL7(TechnologyArchivesHL7 HL7) {

        if (null == HL7 || HL7.getSocialNo() == null) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "信息不全，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        String socialNo = HL7.getSocialNo();
        Integer id = HL7.getId();
        String approvalTime = HL7.getApprovalTime();
        TechnologyArchivesHL7 taHL7 = hl7Dao.selectTechnologyArchivesHL7ById(socialNo, id);

        int num;
        try {
            if (null != taHL7) {
                String oldSocialNo = HL7.getOldSocialNo();
                if (StringUtil.notBlank(oldSocialNo)) {
                    TechnologyArchivesHL7 oldTaHL7 = hl7Dao.selectTechnologyArchivesHL7ById(oldSocialNo, id);
                    oldTaHL7.setSocialNo(socialNo);
                    int maxId = hl7Dao.selectTechnologyArchivesHL7MaxId(socialNo);
                    oldTaHL7.setId(maxId + 1);
                    num = hl7Dao.insert(oldTaHL7);
                    hl7Dao.delTechnologyArchivesHL7ByCode(oldSocialNo,approvalTime);
                } else {
                    UpdateWrapper<TechnologyArchivesHL7> updateWrapper = new UpdateWrapper<>();
                    updateWrapper.eq("social_no",HL7.getSocialNo());
                    updateWrapper.eq("id",HL7.getId());
                    num = hl7Dao.update(HL7, updateWrapper);
//                    num = hl7Dao.updateTechnologyArchivesHL7ById(HL7);
                }
            } else {
                UserInfo user = userCache.getUserInfoByToken();
                int maxId = hl7Dao.selectTechnologyArchivesHL7MaxId(socialNo);
                HL7.setAccount(user.getCodeRs());
                HL7.setId(maxId + 1);
                num = hl7Dao.insert(HL7);
            }
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存休假记录失败！");
            }
            resultMap.put("cg", "保存休假记录成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存休假记录失败！");
        }
    }

    /**
     * @param socialNo  身份证号  approvalTime 批准时间 url 图片链接
     * @Description 根据身份证号, 批准时间来保存上传图片
     * @return map
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<Map<String, Object>> setHL7Image(String socialNo, String approvalTime, String url) {
        Map<String, Object> map = new HashMap<>();
        int imgMap = hl7Dao.updateHL7Image(socialNo, approvalTime, url);
        map.put("data", imgMap);
        return ResultVoUtil.success(map);
    }

    /**
     * @param socialNo 身份证号  id
     * @return map
     * @Description 根据身份证号, id删除休假记录
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<Map<String, Object>> delTechnologyArchivesHL7ByCode(String socialNo, String approvalTime) {
        if (StringUtil.isBlank(socialNo)) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有身份证号，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        try {
            int num = hl7Dao.delTechnologyArchivesHL7ByCode(socialNo, approvalTime);
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除休假记录失败！");
            }
            resultMap.put("cg", "删除休假记录成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除休假记录失败！");
        }
    }

    /**
     * @return TechnologyArchives9 培训考试考核情况
     * @Description 查询培训考试考核情况
     * @Author hsh
     * @Date 2024/7/12 15:41
     */
    public ResultVo<List<TechnologyArchivesHL9>> selectTechnologyArchivesHL9() {
        UserInfo user = userCache.getUserInfoByToken();
        QueryWrapper<TechnologyArchivesHL9> querywrapper = new QueryWrapper<>();
        querywrapper.eq("account",user.getCodeRs());
        List<TechnologyArchivesHL9> list = hl9Dao.selectList(querywrapper);
//        List<TechnologyArchivesHL9> list = hl9Dao.selectHL9ListByCode(null, user.getCodeRs());
        return ResultVoUtil.success(list);
    }

    /**
     * @param HL9 开展新技术情况
     * @return map
     * @Description 根据身份证号更新开展新技术情况
     * @Author hsh
     * @Date 2024/7/12 15:43
     */
    public ResultVo<Map<String, Object>> saveTechnologyArchivesHL9(TechnologyArchivesHL9 HL9) {

        if (null == HL9 || HL9.getSocialNo() == null) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "培训考试考核情况信息不全，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        String socialNo = HL9.getSocialNo();
        Integer id = HL9.getId();
        TechnologyArchivesHL9 HLta9 = hl9Dao.selectTechnologyArchivesHL9ById(socialNo, id);

        int num;
        try {
            if (null != HLta9) {
                String oldSocialNo = HL9.getOldSocialNo();
                if (StringUtil.notBlank(oldSocialNo)) {
                    TechnologyArchivesHL9 oldTa9 = hl9Dao.selectTechnologyArchivesHL9ById(oldSocialNo, id);
                    oldTa9.setSocialNo(socialNo);
                    int maxId = hl9Dao.selectTechnologyArchivesHL9MaxId(socialNo);
                    oldTa9.setId(maxId + 1);
                    num = hl9Dao.insert(oldTa9);
                    hl9Dao.delTechnologyArchivesHL9ByCode(oldSocialNo, id);
                } else {
                    UpdateWrapper<TechnologyArchivesHL9> updateWrapper = new UpdateWrapper<>();
                    updateWrapper.eq("social_no",HL9.getSocialNo());
                    updateWrapper.eq("id",HL9.getId());
                    num = hl9Dao.update(HL9, updateWrapper);
//                    num = hl9Dao.updateTechnologyArchivesHL9ById(HL9);
                }
            } else {
                UserInfo user = userCache.getUserInfoByToken();
                int maxId = hl9Dao.selectTechnologyArchivesHL9MaxId(socialNo);
                HL9.setAccount(user.getCodeRs());
                HL9.setId(maxId + 1);
                num = hl9Dao.insert(HL9);
            }
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存培训考试考核情况失败！");
            }
            resultMap.put("cg", "保存培训考试考核情况成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存培训考试考核情况失败！");
        }
    }

    /**
     * @param socialNo 身份证号 id
     * @return map
     * @Description 根据身份证号, id删除开展新技术情况
     * @Author hsh
     * @Date 2024/7/12 15:44
     */
    public ResultVo<Map<String, Object>> delTechnologyArchivesHL9ByCode(String socialNo, Integer id) {
        if (StringUtil.isBlank(socialNo)) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有身份证号，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        try {
            int num = hl9Dao.delTechnologyArchivesHL9ByCode(socialNo, id);
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除开展新技术情况失败！");
            }
            resultMap.put("cg", "删除开展新技术情况成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除开展新技术情况失败！");
        }
    }
    /**
     * @return TechnologyArchives5 发表论文与专著情况
     * @Description 查询发表论文与专著情况
     * @Author hsh
     * @Date 2024/7/12 10:00
     */
    public ResultVo<List<TechnologyArchives5>> selectTechnologyArchives5() {
        UserInfo user = userCache.getUserInfoByToken();
        QueryWrapper<TechnologyArchives5> querywrapper = new QueryWrapper<>();
        querywrapper.eq("account",user.getCodeRs());
        List<TechnologyArchives5> list = fifthDao.selectList(querywrapper);
        return ResultVoUtil.success(list);
    }

    /**
     * @param fifth 发表论文与专著情况
     * @return map
     * @Description 更新发表论文与专著情况
     * @Author hsh
     * @Date 2024/7/12 10:06
     */
    public ResultVo<Map<String, Object>> saveTechnologyArchives5(TechnologyArchives5 fifth) {

        if (null == fifth || fifth.getSocialNo() == null || fifth.getTime() == null) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "发表论文与专著情况信息不全，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        String socialNo = fifth.getSocialNo();
        String time = fifth.getTime();
        TechnologyArchives5 ta5 = fifthDao.selectTechnologyArchives5ByTime(socialNo, time);

        int num;
        try {
            if (null != ta5) {
                UpdateWrapper<TechnologyArchives5> updateWrapper = new UpdateWrapper<>();
                updateWrapper.eq("social_no",fifth.getSocialNo());
                updateWrapper.eq("time",fifth.getTime());
                num = fifthDao.update(fifth, updateWrapper);
//                num = fifthDao.updateTechnologyArchives5ByTime(fifth);
            } else {
                UserInfo user = userCache.getUserInfoByToken();
                fifth.setAccount(user.getCodeRs());
                num = fifthDao.insert(fifth);
            }
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存发表论文与专著情况失败！");
            }
            resultMap.put("cg", "保存发表论文与专著情况成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存发表论文与专著情况失败！");
        }
    }

    /**
     * @param socialNo 身份证号 time 发表时间
     * @return map
     * @Description 根据身份证号, 发表时间删除发表论文与专著情况
     * @Author hsh
     * @Date 2024/7/12 10:07
     */
    public ResultVo<Map<String, Object>> delTechnologyArchives5ByCode(String socialNo, String time) {
        if (StringUtil.isBlank(socialNo) || StringUtil.isBlank(time)) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有身份证号或者发表时间，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        try {
            int num = fifthDao.delTechnologyArchives5ByCode(socialNo, time);
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除发表论文与专著情况失败！");
            }
            resultMap.put("cg", "删除发表论文与专著情况成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除发表论文与专著情况失败！");
        }
    }

    /**
     * @return TechnologyArchives7 开展新技术情况
     * @Description 查询开展新技术情况
     * @Author hsh
     * @Date 2024/7/12 15:42
     */
    public ResultVo<List<TechnologyArchives7>> selectTechnologyArchives7() {
        UserInfo user = userCache.getUserInfoByToken();
        QueryWrapper<TechnologyArchives7> querywrapper = new QueryWrapper<>();
        querywrapper.eq("account",user.getCodeRs());
        List<TechnologyArchives7> list = seventhDao.selectList(querywrapper);
        return ResultVoUtil.success(list);
    }

    /**
     * @param seventh 开展新技术情况
     * @return map
     * @Description 根据身份证号更新开展新技术情况
     * @Author hsh
     * @Date 2024/7/12 15:43
     */
    public ResultVo<Map<String, Object>> saveTechnologyArchives7(TechnologyArchives7 seventh) {

        if (null == seventh || seventh.getSocialNo() == null) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "开展新技术情况信息不全，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        String socialNo = seventh.getSocialNo();
        Integer id = seventh.getId();
        TechnologyArchives7 ta7 = seventhDao.selectTechnologyArchives7ById(socialNo, id);

        int num;
        try {
            if (null != ta7) {
                String oldSocialNo = seventh.getOldSocialNo();
                if (StringUtil.notBlank(oldSocialNo)) {
                    TechnologyArchives7 oldTa7 = seventhDao.selectTechnologyArchives7ById(oldSocialNo, id);
                    oldTa7.setSocialNo(socialNo);
                    int maxId = seventhDao.selectTechnologyArchives7MaxId(socialNo);
                    oldTa7.setId(maxId + 1);
                    num = seventhDao.insert(oldTa7);
                    seventhDao.delTechnologyArchives7ByCode(oldSocialNo, id);
                } else {
                    UpdateWrapper<TechnologyArchives7> updateWrapper = new UpdateWrapper<>();
                    updateWrapper.eq("social_no",seventh.getSocialNo());
                    updateWrapper.eq("id",seventh.getId());
                    num = seventhDao.update(seventh, updateWrapper);
//                    num = seventhDao.updateTechnologyArchives7ById(seventh);
                }
            } else {
                UserInfo user = userCache.getUserInfoByToken();
                int maxId = seventhDao.selectTechnologyArchives7MaxId(socialNo);
                seventh.setAccount(user.getCodeRs());
                seventh.setId(maxId + 1);
                num = seventhDao.insert(seventh);
            }
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存开展新技术情况失败！");
            }
            resultMap.put("cg", "保存开展新技术情况成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存开展新技术情况失败！");
        }
    }

    /**
     * @param socialNo 身份证号 id
     * @return map
     * @Description 根据身份证号, id删除开展新技术情况
     * @Author hsh
     * @Date 2024/7/12 15:44
     */
    public ResultVo<Map<String, Object>> delTechnologyArchives7ByCode(String socialNo, Integer id) {
        if (StringUtil.isBlank(socialNo)) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有身份证号，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        try {
            int num = seventhDao.delTechnologyArchives7ByCode(socialNo, id);
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除开展新技术情况失败！");
            }
            resultMap.put("cg", "删除开展新技术情况成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除开展新技术情况失败！");
        }
    }

    /**
     * @return TechnologyArchives10 各种医疗活动记录
     * @Description 查询各种医疗活动记录
     * @Author hsh
     * @Date 2024/7/16 9:49
     */
    public ResultVo<List<TechnologyArchives10>> selectTechnologyArchives10() {
        UserInfo user = userCache.getUserInfoByToken();
        QueryWrapper<TechnologyArchives10> querywrapper = new QueryWrapper<>();
        querywrapper.eq("account",user.getCodeRs());
        List<TechnologyArchives10> list = tenthDao.selectList(querywrapper);
        return ResultVoUtil.success(list);
    }

    /***
     * @Description 根据身份证号更新各种医疗活动记录
     * @Author hsh
     * @param tenth 各种医疗活动记录
     * @return map
     * @Date 2024/7/16 9:50
     */
    public ResultVo<Map<String, Object>> saveTechnologyArchives10(TechnologyArchives10 tenth) {

        if (null == tenth || tenth.getSocialNo() == null) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "各种医疗活动记录信息不全，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        String socialNo = tenth.getSocialNo();
        Integer id = tenth.getId();
        TechnologyArchives10 ta10 = tenthDao.selectTechnologyArchives10ById(socialNo, id);

        int num;
        try {
            if (null != ta10) {
                String oldSocialNo = tenth.getOldSocialNo();
                if (StringUtil.notBlank(oldSocialNo)) {
                    TechnologyArchives10 oldTa10 = tenthDao.selectTechnologyArchives10ById(oldSocialNo, id);
                    oldTa10.setSocialNo(socialNo);
                    int maxId = tenthDao.selectTechnologyArchives10MaxId(socialNo);
                    oldTa10.setId(maxId + 1);
                    num = tenthDao.insert(oldTa10);
                    tenthDao.delTechnologyArchives10ByCode(oldSocialNo, id);
                } else {
                    UpdateWrapper<TechnologyArchives10> updateWrapper = new UpdateWrapper<>();
                    updateWrapper.eq("social_no",tenth.getSocialNo());
                    updateWrapper.eq("id",tenth.getId());
                    num = tenthDao.update(tenth, updateWrapper);
                }
            } else {
                UserInfo user = userCache.getUserInfoByToken();
                int maxId = tenthDao.selectTechnologyArchives10MaxId(socialNo);
                tenth.setAccount(user.getCodeRs());
                tenth.setId(maxId + 1);
                num = tenthDao.insert(tenth);
            }
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存各种医疗活动记录失败！");
            }
            resultMap.put("cg", "保存各种医疗活动记录成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存各种医疗活动记录失败！");
        }
    }

    /**
     * @param socialNo 身份证号  id
     * @return map
     * @Description 根据身份证号, id删除各种医疗活动记录
     * @Author hsh
     * @Date 2024/7/16 9:51
     */
    public ResultVo<Map<String, Object>> delTechnologyArchives10ByCode(String socialNo, Integer id) {
        if (StringUtil.isBlank(socialNo)) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有身份证号，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        try {
            int num = tenthDao.delTechnologyArchives10ByCode(socialNo, id);
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除各种医疗活动记录失败！");
            }
            resultMap.put("cg", "删除各种医疗活动记录成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除各种医疗活动记录失败！");
        }
    }

    /**
     * @return TechnologyArchives12 奖惩情况
     * @Description 查询奖惩情况
     * @Author hsh
     * @Date 2024/7/16 14:59
     */
    public ResultVo<List<TechnologyArchives12>> selectTechnologyArchives12() {
        UserInfo user = userCache.getUserInfoByToken();
        QueryWrapper<TechnologyArchives12> querywrapper = new QueryWrapper<>();
        querywrapper.eq("account",user.getCodeRs());
        List<TechnologyArchives12> list = twelfthDao.selectList(querywrapper);
        return ResultVoUtil.success(list);
    }

    /**
     * @param twelfth 奖惩情况
     * @return map
     * @Description 根据身份证号更新奖惩情况
     * @Author hsh
     * @Date 2024/7/16 15:00
     */
    public ResultVo<Map<String, Object>> saveTechnologyArchives12(TechnologyArchives12 twelfth) {

        if (null == twelfth || twelfth.getSocialNo() == null) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "奖惩情况信息不全，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        String socialNo = twelfth.getSocialNo();
        Integer id = twelfth.getId();
        TechnologyArchives12 ta12 = twelfthDao.selectTechnologyArchives12ById(socialNo, id);

        int num;
        try {
            if (null != ta12) {
                String oldSocialNo = twelfth.getOldSocialNo();
                if (StringUtil.notBlank(oldSocialNo)) {
                    TechnologyArchives12 oldTa12 = twelfthDao.selectTechnologyArchives12ById(oldSocialNo, id);
                    oldTa12.setSocialNo(socialNo);
                    int maxId = twelfthDao.selectTechnologyArchives12MaxId(socialNo);
                    oldTa12.setId(maxId + 1);
                    num = twelfthDao.insert(oldTa12);
                    twelfthDao.delTechnologyArchives12ByCode(oldSocialNo, id);
                } else {
                    UpdateWrapper<TechnologyArchives12> updateWrapper = new UpdateWrapper<>();
                    updateWrapper.eq("social_no",twelfth.getSocialNo());
                    updateWrapper.eq("id",twelfth.getId());
                    num = twelfthDao.update(twelfth, updateWrapper);
//                    num = twelfthDao.updateTechnologyArchives12ById(twelfth);
                }
            } else {
                UserInfo user = userCache.getUserInfoByToken();
                int maxId = twelfthDao.selectTechnologyArchives12MaxId(socialNo);
                twelfth.setAccount(user.getCodeRs());
                twelfth.setId(maxId + 1);
                num = twelfthDao.insert(twelfth);
            }
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存奖惩情况失败！");
            }
            resultMap.put("cg", "保存奖惩情况成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存奖惩情况失败！");
        }
    }

    /**
     * @param socialNo 身份证号  id
     * @return map
     * @Description 根据身份证号, id删除奖惩情况
     * @Author hsh
     * @Date 2024/7/16 15:02
     */
    public ResultVo<Map<String, Object>> delTechnologyArchives12ByCode(String socialNo, Integer id) {
        if (StringUtil.isBlank(socialNo)) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有身份证号，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        try {
            int num = twelfthDao.delTechnologyArchives12ByCode(socialNo, id);
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除奖惩情况失败！");
            }
            resultMap.put("cg", "删除奖惩情况成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除奖惩情况失败！");
        }
    }

    /**
     * @return TechnologyArchives13 专业学会任职情况
     * @Description 查询专业学会任职情况
     * @Author hsh
     * @Date 2024/7/16 16:48
     */
    public ResultVo<List<TechnologyArchives13>> selectTechnologyArchives13() {
        UserInfo user = userCache.getUserInfoByToken();
        QueryWrapper<TechnologyArchives13> querywrapper = new QueryWrapper<>();
        querywrapper.eq("account",user.getCodeRs());
        List<TechnologyArchives13> list = thirteenthDao.selectList(querywrapper);
        return ResultVoUtil.success(list);
    }


    /**
     * @param socialNo 身份证号 name 专业学会名称
     * @return map
     * @Description 通过身份证号以及专业学会名称查找委任聘书图片
     * @Author XU
     * @Date 2025/4/17 15:00
     */

    public ResultVo<Map<String, Object>> selectAppointmentImage(String socialNo, String name) {
        Map<String, Object> map = new HashMap<>();
        Map<String, Object> imgMap = thirteenthDao.selectAppointmentImage(socialNo, name);
        map.put("data", imgMap);
        return ResultVoUtil.success(map);
    }
    public ResultVo<Map<String, Object>> putAppointmentImage(MultipartFile[] files, String name) {
        UserInfo user = userCache.getUserInfoByToken();
        String code = user.getCodeRs();
        String uploadDir = "/uploadimage/appoinmentImage/" + code + "/" + name;
        Map<String, Object> map = new HashMap<>();
        List<String> urls = new ArrayList<>();
        System.out.println(Arrays.toString(files));
        for (MultipartFile file : files){
            urls.add(archiveServer.uploadFile(file, uploadDir, !isProd).getPath());
        }
        map.put("urls",urls);
        return ResultVoUtil.success(map);
    }

    /**
     * @param socialNo 身份证号 name 专业学会名称 url 图片链接
     * @return map
     * @Description 通过身份证号以及专业学会名称设定委任聘书
     * @Author XU
     * @Date 2025/4/17 14:58
     */

    public ResultVo<Map<String, Object>> setAppointmentImage(String socialNo, String name, String url) {
        Map<String, Object> map = new HashMap<>();
        int imgMap = thirteenthDao.updateAppointmentImage(url, socialNo, name);
        map.put("data", imgMap);
        return ResultVoUtil.success(map);
    }

    /**
     * @param thirteenth 专业学会任职情况
     * @return map
     * @Description 根据身份证号更新专业学会任职情况
     * @Author hsh
     * @Date 2024/7/16 16:49
     */
    public ResultVo<Map<String, Object>> saveTechnologyArchives13(TechnologyArchives13 thirteenth) {

        if (null == thirteenth || thirteenth.getSocialNo() == null) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "专业学会任职情况信息不全，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        String socialNo = thirteenth.getSocialNo();
        Integer id = thirteenth.getId();
        TechnologyArchives13 ta13 = thirteenthDao.selectTechnologyArchives13ById(socialNo, id);

        int num;
        try {
            if (null != ta13) {
                String oldSocialNo = thirteenth.getOldSocialNo();
                if (StringUtil.notBlank(oldSocialNo)) {
                    TechnologyArchives13 oldTa13 = thirteenthDao.selectTechnologyArchives13ById(oldSocialNo, id);
                    oldTa13.setSocialNo(socialNo);
                    int maxId = thirteenthDao.selectTechnologyArchives13MaxId(socialNo);
                    oldTa13.setId(maxId + 1);
                    num = thirteenthDao.insert(oldTa13);
                    thirteenthDao.delTechnologyArchives13ByCode(oldSocialNo, id);
                } else {
                    UpdateWrapper<TechnologyArchives13> updateWrapper = new UpdateWrapper<>();
                    updateWrapper.eq("social_no",thirteenth.getSocialNo());
                    updateWrapper.eq("id",thirteenth.getId());
                    num = thirteenthDao.update(thirteenth, updateWrapper);
//                    num = thirteenthDao.updateTechnologyArchives13ById(thirteenth);
                }
            } else {
                UserInfo user = userCache.getUserInfoByToken();
                int maxId = thirteenthDao.selectTechnologyArchives13MaxId(socialNo);
                thirteenth.setAccount(user.getCodeRs());
                thirteenth.setId(maxId + 1);
                num = thirteenthDao.insert(thirteenth);
            }
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存专业学会任职情况失败！");
            }
            resultMap.put("cg", "保存专业学会任职情况成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存专业学会任职情况失败！");
        }
    }

    /**
     * @param socialNo 身份证号  id
     * @return map
     * @Description 根据身份证号, id删除专业学会任职情况
     * @Author hsh
     * @Date 2024/7/16 16:56
     */
    public ResultVo<Map<String, Object>> delTechnologyArchives13ByCode(String socialNo, Integer id) {
        if (StringUtil.isBlank(socialNo)) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有身份证号，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        try {
            int num = thirteenthDao.delTechnologyArchives13ByCode(socialNo, id);
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除专业学会任职情况失败！");
            }
            resultMap.put("cg", "删除专业学会任职情况成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除专业学会任职情况失败！");
        }
    }

    /**
     * @return TechnologyArchives14 继续教育学分获得情况
     * @Description 查询继续教育学分获得情况
     * @Author hsh
     * @Date 2024/7/17 9:48
     */
    public ResultVo<List<TechnologyArchives14>> selectTechnologyArchives14() {
        UserInfo user = userCache.getUserInfoByToken();
        QueryWrapper<TechnologyArchives14> querywrapper = new QueryWrapper<>();
        querywrapper.eq("account",user.getCodeRs());
        List<TechnologyArchives14> list = fourteenthDao.selectList(querywrapper);
        return ResultVoUtil.success(list);
    }

    /**
     * @param fourteenth 继续教育学分获得情况
     * @return map
     * @Description 根据身份证号更新继续教育学分获得情况
     * @Author hsh
     * @Date 2024/7/17 9:49
     */
    public ResultVo<Map<String, Object>> saveTechnologyArchives14(TechnologyArchives14 fourteenth) {

        if (null == fourteenth || fourteenth.getSocialNo() == null) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "继续教育学分获得情况信息不全，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        String socialNo = fourteenth.getSocialNo();
        Integer id = fourteenth.getId();
        TechnologyArchives14 ta14 = fourteenthDao.selectTechnologyArchives14ById(socialNo, id);

        int num;
        try {
            if (null != ta14) {
                String oldSocialNo = fourteenth.getOldSocialNo();
                if (StringUtil.notBlank(oldSocialNo)) {
                    TechnologyArchives14 oldTa14 = fourteenthDao.selectTechnologyArchives14ById(oldSocialNo, id);
                    oldTa14.setSocialNo(socialNo);
                    int maxId = fourteenthDao.selectTechnologyArchives14MaxId(socialNo);
                    oldTa14.setId(maxId + 1);
                    num = fourteenthDao.insert(oldTa14);
                    fourteenthDao.delTechnologyArchives14ByCode(oldSocialNo, id);
                } else {
                    UpdateWrapper<TechnologyArchives14> updateWrapper = new UpdateWrapper<>();
                    updateWrapper.eq("social_no",fourteenth.getSocialNo());
                    updateWrapper.eq("id",fourteenth.getId());
                    num = fourteenthDao.update(fourteenth, updateWrapper);
                }
            } else {
                UserInfo user = userCache.getUserInfoByToken();
                int maxId = fourteenthDao.selectTechnologyArchives14MaxId(socialNo);
                fourteenth.setAccount(user.getCodeRs());
                fourteenth.setId(maxId + 1);
                num = fourteenthDao.insert(fourteenth);
            }
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存继续教育学分获得情况失败！");
            }
            resultMap.put("cg", "保存继续教育学分获得情况成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存继续教育学分获得情况失败！");
        }
    }

    /**
     * @param socialNo 身份证号  id
     * @return map
     * @Description 根据身份证号, id删除继续教育学分获得情况
     * @Author hsh
     * @Date 2024/7/17 9:49
     */
    public ResultVo<Map<String, Object>> delTechnologyArchives14ByCode(String socialNo, Integer id) {
        if (StringUtil.isBlank(socialNo)) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有身份证号，请检查！");
        }

        Map<String, Object> resultMap = new HashMap<>();
        try {
            int num = fourteenthDao.delTechnologyArchives14ByCode(socialNo, id);
            if (num == 0) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除继续教育学分获得情况失败！");
            }
            resultMap.put("cg", "删除继续教育学分获得情况成功！");
            return ResultVoUtil.success(resultMap);
        } catch (Exception e) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除继续教育学分获得情况失败！");
        }
    }
    /**
     * @param type 类型
     * @return map
     * @Description 查询技术档案种类
     * @Author hsh
     * @Date 2024/8/1 15:26
     */
    public ResultVo<Map<String, Object>> selectTechnologyArchivesHLType(String type) {
        Map<String, Object> map = new HashMap<>();
        List<Map<String, Object>> list;
        if ("all".equals(type)) {
            list = dao.selectTechnologyArchivesHLTypeAll();
        } else {
            list = dao.selectTechnologyArchivesHLType(type);
        }
        map.put("taList", list);
        return ResultVoUtil.success(map);
    }

    /**
     * @param vo (textType 文档类型 text 关键字)
     * @return map
     * @Description 根据文档类型查询护理技术文档信息
     * @Author hsh
     * @Date 2024/8/7 16:30
     */
    public ResultVo<Map<String, Object>> selectHLTechnologyArchivesInfo(TechnologyArchivesVo vo) {
        if (StringUtil.isBlank(vo.getTextType())) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到文档类型，请检查！");
        }
        UserInfo user = userCache.getUserInfoByToken();
        int dd = dao.selectHLTechnologyArchivesTypeQx(user.getCode().trim());
        Map<String, Object> map = new HashMap<>();
        List<Map<String, Object>> list;
        TechnologyArchivesHLType t = dao.selectTechnologyArchivesHLTypeInfo(vo.getTextType());
        if (t == null) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有检索到登录者的技术档案。");
        }
        String sql = t.getTableSql();
        if (dd == 0) {
            // 没有审核权限，只能查询自己的记录
            String sfz;
            if (null == user.getSocialNo() || StringUtil.isBlank(user.getSocialNo())) {
                TechnologyArchivesHLMain mainSelf = hlMainDao.selectTechnologyArchivesHLMainBySocialNo(user.getCode().trim());
                sfz = mainSelf.getSocialNo();
            } else {
                sfz = user.getSocialNo().trim();
            }
            if (StringUtil.isBlank(sfz)) {
                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有检索到登录者技术档案的身份证信息，请检查！");
            }
            if (t.getTableName().endsWith("main")) {
                if (StringUtil.notBlank(sql)) {
                    list = dao.selectTechnologyArchivesInfoBySql(sql, null, sfz);
                } else {
                    list = dao.selectTechnologyArchivesHLMainInfo(t.getTableName(), null, sfz);
                }
            } else {
                if (StringUtil.notBlank(sql)) {
                    list = dao.selectTechnologyArchivesInfoBySql(sql, null, sfz);
                } else {
                    list = dao.selectTechnologyArchivesHLInfo(t.getTableName(), null, sfz);
                }
            }
        } else {
            // 查询所有的文档
            String sfz = null;
            String xm = null;
            if (StringUtil.notBlank(vo.getText())) {
                TechnologyArchivesHLMain mainSelf = hlMainDao.selectTechnologyArchivesHLMainBySocialNo(vo.getText());
                if (null == mainSelf || StringUtil.isBlank(mainSelf.getSocialNo())) {
                    TechnologyArchivesHLMain main = dao.selectHLEmployeeInfo(vo.getText());
                    if (null != main && StringUtil.notBlank(main.getSocialNo())) {
                        sfz = main.getSocialNo().trim();
                    }
                } else {
                    sfz = mainSelf.getSocialNo();
                }
                if (StringUtil.isBlank(sfz)) {
                    return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有检索到查询技术档案的身份证信息，请检查！");
                }

            }
            if (t.getTableName().endsWith("main")) {
                if (StringUtil.notBlank(sql)) {
                    list = dao.selectTechnologyArchivesInfoBySql(sql, null, StringUtil.notBlank(vo.getText()) ? sfz : null);
                } else {
                    list = dao.selectTechnologyArchivesHLMainInfo(t.getTableName(), null, StringUtil.notBlank(vo.getText()) ? sfz : null);
                }
            } else {
                if (StringUtil.notBlank(sql)) {
                    list = dao.selectTechnologyArchivesInfoBySql(sql, null, StringUtil.notBlank(vo.getText()) ? sfz : null);
                } else {
                    list = dao.selectTechnologyArchivesHLInfo(t.getTableName(), null, StringUtil.notBlank(vo.getText()) ? sfz : null);
                }
            }
        }

        // 拼接展示的字段prop以及字段label
        String tableProp = t.getTableProp();
        String tableLabel = t.getTableLabel();
        String showLabel = t.getShowLabel();
        if (StringUtil.isBlank(tableProp)) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, t.getName() + "没有配置显示字段prop，请联系管理员！");
        }
        if (StringUtil.isBlank(tableLabel)) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, t.getName() + "没有配置显示字段label，请联系管理员！");
        }
        List<String> propList = Arrays.asList(tableProp.split(","));
        List<String> labelList = Arrays.asList(tableLabel.split(","));
        List<String> showList = new ArrayList<>();
        if (StringUtil.notBlank(showLabel)) {
            showList = Arrays.asList(showLabel.split(","));
        }
        if (propList.size() != labelList.size()) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, t.getName() + "配置显示字段display和label数量不一致，请联系管理员！");
        }

        List<HeadInfo> display = new ArrayList<>();
        // 文档资料都需要显示姓名
        HeadInfo h = new HeadInfo();
        h.setDisplay("姓名");
        h.setName("xm");
        h.setWidth("100");
        h.setSort(1);
        display.add(h);
        for (int i = 0; i < propList.size(); i++) {
            HeadInfo info = getHeadInfo(propList, i, labelList, showList);
            display.add(info);
        }

        map.put("taData", list);
        map.put("displayData", display);
        return ResultVoUtil.success(map);
    }

    /**
     * @param propList  显示的字段属性集合
     * @param i         序号
     * @param labelList 显示的字段名称集合
     * @param showList  是否需要鼠标悬停显示全部信息
     * @return HeadInfo 一个表头信息
     * @Description 组装表头信息
     * @Author hsh
     * @Date 2024/8/7 17:04
     */
    @NotNull
    private static HeadInfo getHeadInfo(List<String> propList, int i, List<String> labelList, List<String> showList) {
        HeadInfo info = new HeadInfo();
        String p = propList.get(i);
        String l = labelList.get(i);
        if (p.contains("|")) {
            String f1 = p.split("\\|")[0];
            String c1 = p.split("\\|")[1];
            String f2 = l.split("\\|")[0];
            String c2 = l.split("\\|")[1];
            List<HeadInfo> displaysC = new ArrayList<>();
            // 添加二级表头的标记（以“-t”结尾）
            setShowInfo(showList, info, i, info, f1, f2);
            List<String> propListC = Arrays.asList(c1.split(":"));
            List<String> labelListC = Arrays.asList(c2.split(":"));
            for (int j = 0; j < propListC.size(); j++) {
                HeadInfo infoC = new HeadInfo();
                String dc = propListC.get(j);
                String lc = labelListC.get(j);
                setShowInfo(showList, info, j, infoC, dc, lc);
                displaysC.add(infoC);
            }
            info.setColumns(displaysC);
        } else {
            setShowInfo(showList, info, i, info, p, l);
        }
        return info;
    }

    /**
     * @param showList  需要显示字段集合
     * @param info      第一层显示数据（存在子级目录的话）
     * @param o         序号
     * @param infoChild 第二层显示数据（存在子级目录的话）或者第一层显示数据（不存在子级目录的话）
     * @param prop      显示字段属性（可能带|，:符号 其中|表示后面拼接子级目录，:表示子级目录显示字典属性拼接）
     * @param label     显示字段名称（可能带|，:，/符号 其中|表示后面拼接子级目录，:表示子级目录显示字典名称拼接，/表示后面拼接字段显示宽度）
     * @Description 组成数据（备注：|，:，/需要按顺序拼接，否则会导致表格显示错误, 基本信息name一栏不用配置显示字段且所有字段属性不能出现xm）
     * @Author hsh
     * @Date 2024/8/7 18:33
     */
    private static void setShowInfo(List<String> showList, HeadInfo info, int o, HeadInfo infoChild, String prop, String label) {
        infoChild.setName(prop);
        if (!showList.isEmpty()) {
            for (String str : showList) {
                if (prop.equals(str)) {
                    info.setShow(true);
                    break;
                }
            }
        }
        String[] l = label.split("/");
        infoChild.setDisplay(l[0]);
        if (l.length == 2) {
            infoChild.setWidth(l[1]);
        }
        infoChild.setSort(o + 2);
    }
    /**
     * @param  exportVo (ExportTypes 文档类型 ExportNames 关键字)
     * @return map
     * @Description 导出所有护理档案的信息
     * @Author XU
     * @Date 2025/4/2
     */
    public ResultVo<Map<String, Object>> exportMultiTechnologyArchives(HttpServletResponse response, TechnologyArchivesMultiVo exportVo) {
        Map<String, Object> map = new HashMap<>();
        List<ComplexSheetData> sheets = new ArrayList<>();

        // 参数校验
        if (exportVo.getExportTypes() == null || exportVo.getExportTypes().isEmpty()) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "请选择要导出的文档类型");
        }
        if (exportVo.getExportNames() == null || exportVo.getExportNames().size() != exportVo.getExportTypes().size()) {
            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "每个导出类型必须对应一个名称");
        }
        String text = exportVo.getText();
        // 遍历类型和名称
        for (int i = 0; i < exportVo.getExportTypes().size(); i++) {
            String textType = exportVo.getExportTypes().get(i);
            String exportName = exportVo.getExportNames().get(i); // 获取自定义名称

            TechnologyArchivesVo vo = new TechnologyArchivesVo();
            vo.setText(text);
            vo.setTextType(textType);
            vo.setExportName(exportName); // 设置当前Sheet的名称

            ResultVo<Map<String, Object>> result = selectHLTechnologyArchivesInfo(vo);
            if (!result.isSuccess()) continue;

            ComplexSheetData sheet = new ComplexSheetData();
            sheet.setSheetName(exportName); // 直接使用自定义名称，无需拼接
            sheet.setHeaders((List<HeadInfo>) result.getData().get("displayData"));
            sheet.setData((List<Map<String, Object>>) result.getData().get("taData"));
            sheets.add(sheet);
        }

        if (null == sheets || sheets.isEmpty()) {
            map.put("code", 1);
            map.put("massage", "查询数据为空，导出失败！");
            return ResultVoUtil.success(map);
        }

        if (true) {
            ExcelUtil.exportMultiSheetReport(response, sheets, "护理技术档案汇总报告.xls");
            return null;
        }

        map.put("code", 0);
        map.put("massage", "导出成功！");
        return ResultVoUtil.success(map);
    }



}
