Преглед изворни кода

Merge remote-tracking branch 'origin/master'

wangfeng пре 5 година
родитељ
комит
ff48b979ba

+ 1 - 0
src/main/java/com/diagbot/config/ResourceServerConfigurer.java

@@ -35,6 +35,7 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
                 .antMatchers("/oauth/token").permitAll()
                 .antMatchers("/oauth/check_token").permitAll()
                 .antMatchers("/qc/behospitalInfo/analyze").permitAll()
+                .antMatchers("/cache/clear").permitAll()
                 .antMatchers("/**").authenticated();
 //                .antMatchers("/**").permitAll();
     }

+ 1 - 0
src/main/java/com/diagbot/config/security/UrlAccessDecisionManager.java

@@ -87,6 +87,7 @@ public class UrlAccessDecisionManager implements AccessDecisionManager {
                 || matchers("/oauth/token", request)
                 || matchers("/oauth/check_token", request)
                 || matchers("/qc/behospitalInfo/analyze", request)
+                || matchers("/cache/clear", request)
                 || matchers("/", request)) {
             return true;
         }

+ 5 - 0
src/main/java/com/diagbot/dto/BehospitalInfoDTO.java

@@ -98,4 +98,9 @@ public class BehospitalInfoDTO implements Serializable {
      */
     private String gradeType;
 
+    /**
+     * 评分时间
+     */
+    private Date gradeTime;
+
 }

+ 5 - 0
src/main/java/com/diagbot/entity/QcresultInfo.java

@@ -47,6 +47,11 @@ public class QcresultInfo implements Serializable {
      */
     private Integer gradeType;
 
+    /**
+     * 页面数据
+     */
+    private String pageData;
+
     /**
      * 最后得分
      */

+ 119 - 17
src/main/java/com/diagbot/facade/BehospitalInfoFacade.java

@@ -1,5 +1,6 @@
 package com.diagbot.facade;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.client.QcServiceClient;
@@ -20,6 +21,7 @@ import com.diagbot.service.impl.BehospitalInfoServiceImpl;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ListUtil;
+import com.diagbot.util.MapUtil;
 import com.diagbot.util.SysUserUtils;
 import com.diagbot.vo.AlgorithmVO;
 import com.diagbot.vo.AnalyzeVO;
@@ -68,6 +70,8 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
     @Autowired
     private AlgorithmFacade algorithmFacade;
     @Autowired
+    SysDictionaryFacade sysDictionaryFacade;
+    @Autowired
     private QcresultInfoFacade qcresultInfoFacade;
 
     public IPage<BehospitalInfoDTO> pageFac(BehospitalPageVO behospitalPageVO) {
@@ -92,7 +96,8 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
         // 获取质控条目
         List<QcCasesEntryDTO> qcCasesEntryDTOList = qcCasesEntryFacade.getQcCasesEntry(analyzeVO);
 
-        // TODO 获取病历所有数据
+        // 获取病历所有数据
+        Map<Long, Map<String, String>> dicMap = sysDictionaryFacade.getDictionaryWithKey(); // 获取字典信息
         // 获取文书信息
         RecordContentVO recordContentVO = new RecordContentVO();
         BeanUtil.copyProperties(analyzeVO, recordContentVO);
@@ -113,16 +118,18 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
                 .eq("behospital_code", analyzeVO.getBehospitalCode()), false
         );
 
+        List<HomeDiagnoseInfo> homePageList = new ArrayList<>();
+        List<HomeOperationInfo> homeOperationInfoList = new ArrayList<>();
         if (homePage != null) {
             // 获取首页出院诊断、病理诊断
-            List<HomeDiagnoseInfo> homePageList = homeDiagnoseInfoFacade.list(new QueryWrapper<HomeDiagnoseInfo>()
+            homePageList = homeDiagnoseInfoFacade.list(new QueryWrapper<HomeDiagnoseInfo>()
                     .eq("is_deleted", IsDeleteEnum.N.getKey())
                     .eq("hospital_id", hospitalId)
                     .eq("home_page_id", homePage.getHomePageId())
             );
 
             // 获取首页手术信息
-            List<HomeOperationInfo> homeOperationInfoList = homeOperationInfoFacade.list(new QueryWrapper<HomeOperationInfo>()
+             homeOperationInfoList = homeOperationInfoFacade.list(new QueryWrapper<HomeOperationInfo>()
                     .eq("is_deleted", IsDeleteEnum.N.getKey())
                     .eq("hospital_id", hospitalId)
                     .eq("home_page_id", homePage.getHomePageId())
@@ -147,6 +154,7 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
         addData("死亡病例讨论记录", recMap, medrecVoList);
         addData("死亡记录", recMap, medrecVoList);
         addData("危急值记录", recMap, medrecVoList);
+        addData("出院小结", recMap, medrecVoList);
 
         // 会诊记录
         addDataWithKey("会诊记录", recMap, medrecVoList,
@@ -157,11 +165,14 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
                 Arrays.asList("术后首次病程及谈话记录", "手术记录",
                         "术前讨论、术前小结", "手术知情同意书", "手术安全核查表"));
 
-
         // 医嘱
+        addDataWithKeyConvert("医嘱信息", doctorAdviceList, medrecVoList, dicMap.get(1));
 
+        // 病案首页
+        addDataWithFirstPage("病案首页",  homePage, medrecVoList, dicMap,
+                homePageList, homeOperationInfoList);
 
-        queryVo.setMedrec(medrecVoList); // 设置
+        queryVo.setMedrec(medrecVoList);
 
         //  调用质控接口
         Response<OutputInfo> response = qcServiceClient.extract(queryVo);
@@ -184,7 +195,7 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
         algorithmVO.setQcResultAlgVOList(qcResultAlgVOList);
         AlgorithmDTO algorithmDTO = algorithmFacade.getAlgorithmRes(algorithmVO);
         //保存
-        qcresultInfoFacade.saveQcResult(algorithmDTO, algorithmVO, analyzeVO);
+        qcresultInfoFacade.saveQcResult(algorithmDTO, algorithmVO, analyzeVO, outputInfo.getPageData().toString());
         return null;
     }
 
@@ -237,23 +248,114 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
         }
     }
 
+
     /**
-     * 拼接医嘱数据
+     * 拼接数据(医嘱),从数据字典获取信息转换
      *
      * @param key
-     * @param doctorAdviceList
+     * @param list
      * @param medrecVoList
+     * @param map
      */
-    public void addDataWithDocAdv(String key, List<DoctorAdvice> doctorAdviceList, List<MedrecVo> medrecVoList) {
-        if (ListUtil.isNotEmpty(doctorAdviceList)) {
-            MedrecVo medrecVo = new MedrecVo();
-            medrecVo.setTitle(key);
-            Map<String, Object> content = new HashMap<>();
-            // TODO 医嘱信息
-            //            content.put("content", list.stream().map(r -> r.getContentText()).collect(Collectors.toList()));
-            medrecVo.setContent(content);
-            medrecVoList.add(medrecVo);
+    public void addDataWithKeyConvert(String key,  List<DoctorAdvice> list,
+                               List<MedrecVo> medrecVoList, Map<String, String> map) {
+        MedrecVo medrecVo = new MedrecVo();
+        medrecVo.setTitle(key);
+
+        Map<String, Object> content = new HashMap<>();
+        List<String> contents = new ArrayList<>();
+
+        for (DoctorAdvice doctorAdvice : list) {
+            try {
+                Map<String, String> res = new HashMap<>();
+                Map<String, Object> objectMap = MapUtil.objectToMap(doctorAdvice);
+                for (String objKey : objectMap.keySet()) {
+                    if (map.get(objKey) != null) {
+                        res.put(map.get(objKey), String.valueOf(objectMap.get(objKey)));
+                    }
+                }
+                String jsonStr = JSON.toJSONString(res);
+                contents.add(jsonStr);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+
+        }
+
+        content.put("content", contents);
+        medrecVo.setContent(content);
+        medrecVoList.add(medrecVo);
+    }
+
+
+    /**
+     * 拼接数据(病案首页),从数据字典获取信息转换
+     * @param key
+     * @param homePage
+     * @param medrecVoList
+     * @param dicMap
+     * @param homeDiagnoseInfoList
+     * @param homeOperationInfoList
+     */
+    public void addDataWithFirstPage(String key,  HomePage homePage, List<MedrecVo> medrecVoList, Map<Long, Map<String, String>> dicMap,
+                                     List<HomeDiagnoseInfo> homeDiagnoseInfoList, List<HomeOperationInfo> homeOperationInfoList) {
+        MedrecVo medrecVo = new MedrecVo();
+        medrecVo.setTitle(key);
+
+        Map<String, String> map = dicMap.get(2L); // 病案首页
+        Map<String, Object> content = new HashMap<>();
+        try {
+            Map<String, Object> objectMap = MapUtil.objectToMap(homePage);
+            for (String objKey : objectMap.keySet()) {
+                if (map.get(objKey) != null) {
+                    content.put(map.get(objKey), String.valueOf(objectMap.get(objKey)));
+                }
+            }
+
+            // 病案首页手术信息
+            if (ListUtil.isNotEmpty(homeOperationInfoList)) {
+                Map<String, String> dic3 = dicMap.get(3L); // 病案首页手术信息
+                List<Map> mapList = new ArrayList<>();
+                for (HomeOperationInfo homeOperationInfo : homeOperationInfoList) {
+                    try {
+                        Map<String, Object> objectMapOpe = MapUtil.objectToMap(homeOperationInfo);
+                        for (String objKey : objectMapOpe.keySet()) {
+                            if (dic3.get(objKey) != null) {
+                                objectMapOpe.put(dic3.get(objKey) ,objectMapOpe.remove(objKey)); // 替换
+                            }
+                        }
+                        mapList.add(objectMapOpe);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+                content.put("手术信息", JSON.toJSONString(mapList));
+            }
+
+            // 病案首页诊断信息
+            if (ListUtil.isNotEmpty(homeDiagnoseInfoList)) {
+                Map<String, String> dic4 = dicMap.get(4L); // 病案首页诊断信息
+                List<Map> mapList = new ArrayList<>();
+                for (HomeDiagnoseInfo homeDiagnoseInfo : homeDiagnoseInfoList) {
+                    try {
+                        Map<String, Object> objectMapDiag = MapUtil.objectToMap(homeDiagnoseInfo);
+                        for (String objKey : objectMapDiag.keySet()) {
+                            if (dic4.get(objKey) != null) {
+                                objectMapDiag.put(dic4.get(objKey) ,objectMapDiag.remove(objKey)); // 替换
+                            }
+                        }
+                        mapList.add(objectMapDiag);
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                    }
+                }
+                content.put("出院诊断", JSON.toJSONString(mapList));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
         }
+        medrecVo.setContent(content);
+        medrecVoList.add(medrecVo);
     }
 
 

+ 23 - 0
src/main/java/com/diagbot/facade/CacheFacade.java

@@ -0,0 +1,23 @@
+package com.diagbot.facade;
+
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Description:
+ * @Author:zhoutg
+ * @time: 2018/11/23 11:37
+ */
+@Component
+public class CacheFacade {
+
+    /**
+     * 清除缓存信息
+     *
+     * @return
+     */
+    @CacheEvict(value = "cache", allEntries = true)
+    public void clear() {
+
+    }
+}

+ 23 - 12
src/main/java/com/diagbot/facade/QcresultInfoFacade.java

@@ -68,11 +68,11 @@ public class QcresultInfoFacade extends QcresultInfoServiceImpl {
         AnalyzeVO analyzeVO = new AnalyzeVO();
         analyzeVO.setHospitalId(qcresultVO.getHospitalId());
         analyzeVO.setBehospitalCode(qcresultVO.getBehospitalCode());
-        this.saveQcResult(algorithmDTO, algorithmVO, analyzeVO);
+        this.saveQcResult(algorithmDTO, algorithmVO, analyzeVO,null);
         return true;
     }
 
-    public Boolean saveQcResult(AlgorithmDTO algorithmDTO, AlgorithmVO algorithmVO, AnalyzeVO analyzeVO) {
+    public Boolean saveQcResult(AlgorithmDTO algorithmDTO, AlgorithmVO algorithmVO, AnalyzeVO analyzeVO, String pageData) {
         //更新质控评分结果信息
         Long useId = Long.valueOf(SysUserUtils.getCurrentPrincipleID());
         Date now = DateUtil.now();
@@ -83,20 +83,31 @@ public class QcresultInfoFacade extends QcresultInfoServiceImpl {
                         .eq("is_deleted", IsDeleteEnum.N.getKey())
                         .eq("hospital_id", analyzeVO.getHospitalId())
                         .eq("behospital_code", analyzeVO.getBehospitalCode()));
-        //逻辑删除记录
-        this.update(new UpdateWrapper<QcresultInfo>()
-                .eq("is_deleted", IsDeleteEnum.N.getKey())
-                .eq("hospital_id", analyzeVO.getHospitalId())
-                .eq("behospital_code", analyzeVO.getBehospitalCode())
-                .set("is_deleted", IsDeleteEnum.Y.getKey())
-                .set("modifier", useId)
-                .set("gmt_modified", now));
-        //新增记录
-        if (null == qcresultInfo){
+        if (null == qcresultInfo) {
             qcresultInfo = new QcresultInfo();
+        } else {
+            //逻辑删除记录
+            this.update(new UpdateWrapper<QcresultInfo>()
+                    .eq("is_deleted", IsDeleteEnum.N.getKey())
+                    .eq("hospital_id", analyzeVO.getHospitalId())
+                    .eq("behospital_code", analyzeVO.getBehospitalCode())
+                    .set("is_deleted", IsDeleteEnum.Y.getKey())
+                    .set("modifier", useId)
+                    .set("gmt_modified", now));
         }
+        //新增记录
+        qcresultInfo.setBehospitalCode(analyzeVO.getBehospitalCode());
+        qcresultInfo.setHospitalId(analyzeVO.getHospitalId());
         qcresultInfo.setScoreRes(algorithmDTO.getScore());
         qcresultInfo.setLevel(algorithmDTO.getLevel());
+        if (algorithmVO.getType().equals(0)) {
+            qcresultInfo.setGradeType(1);
+        } else {
+            qcresultInfo.setGradeType(2);
+        }
+        if (StringUtil.isNotBlank(pageData)){
+            qcresultInfo.setPageData(pageData);
+        }
         qcresultInfo.setGmtCreate(now);
         qcresultInfo.setCreator(useId.toString());
         qcresultInfo.setGmtModified(now);

+ 26 - 0
src/main/java/com/diagbot/facade/SysDictionaryFacade.java

@@ -8,8 +8,10 @@ import com.diagbot.service.impl.SysDictionaryInfoServiceImpl;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ListUtil;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Component;
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -34,4 +36,28 @@ public class SysDictionaryFacade extends SysDictionaryInfoServiceImpl {
         List<SysDictionaryInfoDTO> listRes = BeanUtil.listCopyTo(list, SysDictionaryInfoDTO.class);
         return EntityUtil.makeEntityListMap(listRes, "groupType");
     }
+
+
+    /**
+     * 返回字典信息
+     *
+     * @return
+     */
+    @Cacheable(value = "cache", key = "'qcdict'")
+    public Map<Long, Map<String, String>> getDictionaryWithKey() {
+        Map<Long, Map<String, String>> res = new HashMap<>();
+        List<SysDictionaryInfo> list = this.list(new QueryWrapper<SysDictionaryInfo>()
+                .in("return_type", ListUtil.arrayToList(new Long[] { 0L, 2L }))
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .orderByAsc("group_type", "order_no"));
+        Map<Long, List<SysDictionaryInfo>> mapSource = EntityUtil.makeEntityListMap(list, "groupType");
+        for (Long group : mapSource.keySet()) {
+            Map<String, String> m = new HashMap<>();
+            for (SysDictionaryInfo dic : mapSource.get(group)) {
+                m.put(dic.getName(), dic.getVal());
+            }
+            res.put(group, m);
+        }
+        return res;
+    }
 }

+ 39 - 0
src/main/java/com/diagbot/web/CacheController.java

@@ -0,0 +1,39 @@
+package com.diagbot.web;
+
+import com.diagbot.annotation.SysLogger;
+import com.diagbot.dto.RespDTO;
+import com.diagbot.facade.CacheFacade;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ * 缓存 前端控制器
+ * </p>
+ *
+ * @author zhoutg
+ * @since 2018-12-25
+ */
+@RequestMapping("/cache")
+@RestController
+@SuppressWarnings("unchecked")
+@Api(value = "缓存API", tags = { "缓存API" })
+public class CacheController {
+
+
+    @Autowired
+    CacheFacade cacheFacade;
+
+    @ApiOperation(value = "清除缓存[by:zhoutg]",
+            notes = "")
+    @PostMapping("/clear")
+    @SysLogger("clear")
+    public RespDTO<Boolean> clear() {
+        cacheFacade.clear();
+        return RespDTO.onSuc(true);
+    }
+}

+ 1 - 1
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -32,7 +32,7 @@
     </resultMap>
 
     <select id="getPage" resultType="com.diagbot.dto.BehospitalInfoDTO">
-        select * from med_behospital_info a LEFT JOIN med_qcresult_info b
+        select a.*, b.level, b.grade_type, b.score_res, b.gmt_create as grade_time from med_behospital_info a LEFT JOIN med_qcresult_info b
         on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
         where a.is_deleted = 'N'
         <if test="name != null and name != ''">