浏览代码

Merge branch 'master' into 'master'

新增技术档案检索与导出

See merge request lighter/web-server!100
huangshuhua 1 年之前
父节点
当前提交
7053bbf664

+ 17 - 0
src/main/java/thyyxxk/webserver/controller/technologyArchives/TechnologyArchivesController.java

@@ -25,8 +25,10 @@ import thyyxxk.webserver.entity.technologyArchives.TechnologyArchives7;
 import thyyxxk.webserver.entity.technologyArchives.TechnologyArchives8;
 import thyyxxk.webserver.entity.technologyArchives.TechnologyArchives9;
 import thyyxxk.webserver.entity.technologyArchives.TechnologyArchivesMain;
+import thyyxxk.webserver.entity.technologyArchives.TechnologyArchivesVo;
 import thyyxxk.webserver.service.technologyArchives.TechnologyArchivesService;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 import java.util.Map;
 
@@ -288,4 +290,19 @@ public class TechnologyArchivesController {
         return service.delTechnologyArchives15ByCode(socialNo, id);
     }
 
+    @GetMapping("/selectTechnologyArchivesType")
+    public ResultVo<Map<String, Object>> selectTechnologyArchivesType(@RequestParam("type") String type){
+        return service.selectTechnologyArchivesType(type);
+    }
+
+    @PostMapping("/selectTechnologyArchivesInfo")
+    public ResultVo<Map<String, Object>> selectTechnologyArchivesInfo(@RequestBody @Validated TechnologyArchivesVo vo){
+        return service.selectTechnologyArchivesInfo(vo);
+    }
+
+    @PostMapping("/exportTechnologyArchivesInfo")
+    public ResultVo<Map<String, Object>> exportTechnologyArchivesInfo(HttpServletResponse response, @RequestBody @Validated TechnologyArchivesVo vo){
+        return service.exportTechnologyArchivesInfo(response, vo);
+    }
+
 }

+ 38 - 1
src/main/java/thyyxxk/webserver/dao/his/technologyArchives/TechnologyArchivesDao.java

@@ -1,12 +1,15 @@
 package thyyxxk.webserver.dao.his.technologyArchives;
 
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import thyyxxk.webserver.entity.dictionary.CodeName;
 import thyyxxk.webserver.entity.technologyArchives.TechnologyArchivesMain;
+import thyyxxk.webserver.entity.technologyArchives.TechnologyArchivesType;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @ClassName TechnologyArchivesDao
@@ -16,7 +19,7 @@ import java.util.List;
  * @Description 技术档案管理
  **/
 @Mapper
-public interface TechnologyArchivesDao {
+public interface TechnologyArchivesDao extends BaseMapper<TechnologyArchivesType> {
 
     @Select(" select top 1 rtrim(mi.name) as name, rtrim(mi.sex_code) as sex, rtrim(mi.social_no) as socialNo, " +
             "   rtrim(mi.phone_no) as phone, convert(varchar(7), mi.birth_date, 23) as birthday, rtrim(mi.code) as account " +
@@ -42,4 +45,38 @@ public interface TechnologyArchivesDao {
     @Select("select rtrim(code) as code, rtrim(name) as name from zd_education_code with(nolock)")
     List<CodeName> getEducation();
 
+    @Select("select rtrim(code) as code, rtrim(name) as name from technology_archives_type where type = #{type} order by sort ")
+    List<Map<String, Object>> selectTechnologyArchivesType(@Param("type") String type);
+
+    @Select("select count(1) from sys_parameters where code = 'technologyArchivesCode' and name like '%${code}%' ")
+    int selectTechnologyArchivesTypeQx(@Param("code") String code);
+
+    @Select("select * from technology_archives_type where code = #{code} ")
+    TechnologyArchivesType selectTechnologyArchivesTypeInfo(@Param("code") String code);
+
+    @Select("<script>" +
+            " select b.name as xm, a.* from ${tableName} as a, technology_archives_main as b " +
+            " where a.social_no = b.social_no " +
+            "<if test=\"code != null and code != '' \">" +
+            " and a.account = #{code} " +
+            "</if>" +
+            "</script>")
+    List<Map<String, Object>> selectTechnologyArchivesInfo(@Param("tableName") String tableName, @Param("code") String code);
+
+    @Select("<script>" +
+            " select * from ${tableName} where 1 = 1 " +
+            "<if test=\"code != null and code != '' \">" +
+            " account = #{code} " +
+            "</if>" +
+            "</script>")
+    List<Map<String, Object>> selectTechnologyArchivesMainInfo(@Param("tableName") String tableName, @Param("code") String code);
+
+    @Select("<script>" +
+            " ${sql} where 1 = 1 " +
+            "<if test=\"code != null and code != '' \">" +
+            " and account = #{code} " +
+            "</if>" +
+            "</script>")
+    List<Map<String, Object>> selectTechnologyArchivesInfoBySql(@Param("sql") String sql, @Param("code") String code);
+
 }

+ 7 - 0
src/main/java/thyyxxk/webserver/entity/HeadInfo.java

@@ -13,9 +13,16 @@ import java.util.List;
 @Data
 public class HeadInfo {
 
+    // 展示字段名称
     private String display;
+    // 展示字段属性
     private String name;
+    // 展示顺序
     private Integer sort;
+    // 宽度
+    private String width;
+    // 值太长隐藏部分并鼠标悬浮是否显示
+    private boolean show;
     private List<HeadInfo> columns;
 
 }

+ 57 - 0
src/main/java/thyyxxk/webserver/entity/technologyArchives/TechnologyArchivesType.java

@@ -0,0 +1,57 @@
+package thyyxxk.webserver.entity.technologyArchives;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+/**
+ * @ClassName TechnologyArchivesType
+ * @Author hsh
+ * @Date 2024/8/1 16:39
+ * @Version 1.0
+ * @Description 技术档案分类
+ **/
+@Data
+@TableName("technology_archives_type")
+public class TechnologyArchivesType {
+
+    /**
+     *  档案类型编码
+     */
+    @TableId(value = "code", type = IdType.NONE)
+    private String code;
+    /**
+     *  档案类型名称
+     */
+    private String name;
+    /**
+     *  档案类型(1:Ⅰ类  2:Ⅱ类)
+     */
+    private String type;
+    /**
+     *  档案类型排序
+     */
+    private String sort;
+    /**
+     *  档案类型表名
+     */
+    private String tableName;
+    /**
+     *  档案类型页面显示字段值属性集合(用,拼接)
+     */
+    private String tableProp;
+    /**
+     *  档案类型页面显示字段值名称集合(用,拼接)
+     */
+    private String tableLabel;
+    /**
+     *  档案类型页面显示不全允许鼠标悬浮显示全部信息字段属性集合
+     */
+    private String showLabel;
+    /**
+     *  档案类型统计sql(用于页面显示编码转义)
+     */
+    private String tableSql;
+
+}

+ 19 - 0
src/main/java/thyyxxk/webserver/entity/technologyArchives/TechnologyArchivesVo.java

@@ -0,0 +1,19 @@
+package thyyxxk.webserver.entity.technologyArchives;
+
+import lombok.Data;
+
+/**
+ * @ClassName TechnologyArchivesVo
+ * @Author hsh
+ * @Date 2024/8/9 10:40
+ * @Version 1.0
+ * @Description 技术档案查询vo
+ **/
+@Data
+public class TechnologyArchivesVo {
+
+    private String text;
+    private String textType;
+    private String exportName;
+
+}

+ 0 - 1
src/main/java/thyyxxk/webserver/service/targetmanagement/TargetManagementService.java

@@ -439,7 +439,6 @@ public class TargetManagementService {
             resultMap.put("cg", "保存指标sql以及报表成功!");
             return ResultVoUtil.success(resultMap);
         } catch (Exception e) {
-            e.printStackTrace();
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "保存指标sql以及报表失败!");
         }
 

+ 219 - 0
src/main/java/thyyxxk/webserver/service/technologyArchives/TechnologyArchivesService.java

@@ -1,6 +1,7 @@
 package thyyxxk.webserver.service.technologyArchives;
 
 import lombok.extern.slf4j.Slf4j;
+import org.jetbrains.annotations.NotNull;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
@@ -21,6 +22,7 @@ import thyyxxk.webserver.dao.his.technologyArchives.TechnologyArchives8Dao;
 import thyyxxk.webserver.dao.his.technologyArchives.TechnologyArchives9Dao;
 import thyyxxk.webserver.dao.his.technologyArchives.TechnologyArchivesDao;
 import thyyxxk.webserver.dao.his.technologyArchives.TechnologyArchivesMainDao;
+import thyyxxk.webserver.entity.HeadInfo;
 import thyyxxk.webserver.entity.ResultVo;
 import thyyxxk.webserver.entity.dictionary.CodeName;
 import thyyxxk.webserver.entity.login.UserInfo;
@@ -40,13 +42,21 @@ import thyyxxk.webserver.entity.technologyArchives.TechnologyArchives7;
 import thyyxxk.webserver.entity.technologyArchives.TechnologyArchives8;
 import thyyxxk.webserver.entity.technologyArchives.TechnologyArchives9;
 import thyyxxk.webserver.entity.technologyArchives.TechnologyArchivesMain;
+import thyyxxk.webserver.entity.technologyArchives.TechnologyArchivesType;
+import thyyxxk.webserver.entity.technologyArchives.TechnologyArchivesVo;
 import thyyxxk.webserver.service.redislike.RedisLikeService;
+import thyyxxk.webserver.utils.ExcelUtil;
 import thyyxxk.webserver.utils.ResultVoUtil;
 import thyyxxk.webserver.utils.StringUtil;
 
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @ClassName TechnologyArchivesService
@@ -1465,4 +1475,213 @@ public class TechnologyArchivesService {
             return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "删除医疗安全行为记录失败!");
         }
     }
+
+    /**
+     * @Description 查询技术档案种类
+     * @Author hsh
+     * @param type 类型
+     * @return map
+     * @Date 2024/8/1 15:26
+     */
+    public ResultVo<Map<String, Object>> selectTechnologyArchivesType(String type) {
+        Map<String, Object> map = new HashMap<>();
+        List<Map<String, Object>> list = dao.selectTechnologyArchivesType(type);
+        map.put("taList", list);
+        return ResultVoUtil.success(map);
+    }
+
+    /**
+     * @Description 根据文档类型查询技术文档信息
+     * @Author hsh
+     * @param vo (textType 文档类型 text 关键字)
+     * @return map
+     * @Date 2024/8/7 16:30
+     */
+    public ResultVo<Map<String, Object>> selectTechnologyArchivesInfo(TechnologyArchivesVo vo) {
+        if(StringUtil.isBlank(vo.getTextType())){
+            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "没有找到文档类型,请检查!");
+        }
+        UserInfo user = redisLikeService.getUserInfoByToken();
+        int dd = dao.selectTechnologyArchivesTypeQx(user.getCode().trim());
+        Map<String, Object> map = new HashMap<>();
+        List<Map<String, Object>> list;
+        TechnologyArchivesType t = dao.selectTechnologyArchivesTypeInfo(vo.getTextType());
+        String sql = t.getTableSql();
+        if(dd == 0){
+            // 没有审核权限,只能查询自己的记录
+            if(t.getTableName().endsWith("main")){
+                if(StringUtil.notBlank(sql)){
+                    list = dao.selectTechnologyArchivesInfoBySql(sql, user.getCode());
+                } else {
+                    list = dao.selectTechnologyArchivesMainInfo(t.getTableName(), user.getCode());
+                }
+            } else {
+                if(StringUtil.notBlank(sql)){
+                    list = dao.selectTechnologyArchivesInfoBySql(sql, user.getCode());
+                } else {
+                    list = dao.selectTechnologyArchivesInfo(t.getTableName(), user.getCode());
+                }
+            }
+        } else {
+            // 查询所有的文档
+            TechnologyArchivesMain main = new TechnologyArchivesMain();
+            if(StringUtil.notBlank(vo.getText())){
+                main = dao.selectEmployeeInfo(vo.getText());
+            }
+            if(t.getTableName().endsWith("main")){
+                if(StringUtil.notBlank(sql)){
+                    list = dao.selectTechnologyArchivesInfoBySql(sql, main.getAccount());
+                } else {
+                    list = dao.selectTechnologyArchivesMainInfo(sql, main.getAccount());
+                }
+            } else {
+                if(StringUtil.notBlank(sql)){
+                    list = dao.selectTechnologyArchivesInfoBySql(sql, main.getAccount());
+                } else {
+                    list = dao.selectTechnologyArchivesInfo(t.getTableName(), main.getAccount());
+                }
+            }
+        }
+        // 拼接展示的字段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);
+    }
+
+    /**
+     * @Description 组装表头信息
+     * @Author hsh
+     * @param propList 显示的字段属性集合
+     * @param i 序号
+     * @param labelList 显示的字段名称集合
+     * @param showList 是否需要鼠标悬停显示全部信息
+     * @return HeadInfo 一个表头信息
+     * @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;
+    }
+
+    /**
+     * @Description 组成数据(备注:|,:,/需要按顺序拼接,否则会导致表格显示错误, 基本信息name一栏不用配置显示字段且所有字段属性不能出现xm)
+     * @Author hsh
+     * @param showList 需要显示字段集合
+     * @param info 第一层显示数据(存在子级目录的话)
+     * @param o 序号
+     * @param infoChild 第二层显示数据(存在子级目录的话)或者第一层显示数据(不存在子级目录的话)
+     * @param prop 显示字段属性(可能带|,:符号 其中|表示后面拼接子级目录,:表示子级目录显示字典属性拼接)
+     * @param label 显示字段名称(可能带|,:,/符号 其中|表示后面拼接子级目录,:表示子级目录显示字典名称拼接,/表示后面拼接字段显示宽度)
+     * @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);
+    }
+
+    /**
+     * @Description 导出技术档案信息
+     * @Author hsh
+     * @param dto (textType 文档类型 text 关键字)
+     * @return map
+     * @Date 2024/8/9 11:03
+     */
+    public ResultVo<Map<String, Object>> exportTechnologyArchivesInfo(HttpServletResponse response, TechnologyArchivesVo dto){
+        Map<String, Object> map = new HashMap<>();
+        ResultVo<Map<String, Object>> resultVo = selectTechnologyArchivesInfo(dto);
+        Map<String, Object> data = resultVo.getData();
+        // 数据
+        List<Map<String, Object>> list = (List<Map<String, Object>>) data.get("taData");
+
+        if(null == list || list.isEmpty()){
+            map.put("code", 1);
+            map.put("massage", "查询数据为空,导出失败!");
+            return ResultVoUtil.success(map);
+        }
+
+        // 导出标题
+        String exportName = dto.getExportName();
+
+        // 组装表头
+        List<HeadInfo> headInfoList = (List<HeadInfo>) data.get("displayData");
+        List<HeadInfo> sortHeadInfo = headInfoList.stream().sorted(Comparator.comparing(HeadInfo::getSort)).collect(Collectors.toList());
+
+        // 导出
+        ExcelUtil.exportExcelReport(response, list, sortHeadInfo, exportName);
+
+        map.put("code", 0);
+        map.put("massage", "导出成功!");
+        return ResultVoUtil.success(map);
+    }
+
+
 }