|
|
@@ -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);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|