From 60b7a9849e957872203ef78b99e7a0ee8e533e94 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期二, 13 十月 2026 17:53:13 +0800
Subject: [PATCH] 【丽水】专科档案生成配置

---
 smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java |  114 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 114 insertions(+), 0 deletions(-)

diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
index 1bb31fa..f672d26 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
@@ -1,6 +1,9 @@
 package com.smartor.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
 import com.ruoyi.common.core.domain.entity.SysDept;
@@ -11,9 +14,12 @@
 import com.ruoyi.common.utils.DtoConversionUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.http.HttpUtils;
+import com.ruoyi.system.service.ISysConfigService;
 import com.smartor.domain.*;
 import com.smartor.domain.entity.ServiceSubtaskEntity;
 import com.smartor.mapper.*;
+import com.smartor.service.IPatChildArchiveService;
+import com.smartor.service.IPatMaternityArchiveService;
 import com.smartor.service.IPatMedOuthospService;
 import com.smartor.service.IServiceExternalService;
 import lombok.extern.slf4j.Slf4j;
@@ -70,6 +76,12 @@
     private Icd10Mapper icd10Mapper;
     @Autowired
     private IPatMedOuthospService patMedOuthospService;
+    @Autowired
+    private ISysConfigService configService;
+    @Autowired
+    private IPatMaternityArchiveService patMaternityArchiveService;
+    @Autowired
+    private IPatChildArchiveService patChildArchiveService;
     @Autowired
     private PatMedOuthospMapper patMedOuthospMapper;
     @Autowired
@@ -1312,6 +1324,8 @@
             patMedOuthospService.dealPatMedOuthosp(patMedOuthosp, visitTimeNum);
         }
 
+        genePatSpecificArchive(patMedOuthosp, patArchive);
+
         if (i > 0) {
             return true;
         }
@@ -1842,6 +1856,7 @@
         Map yeWuXX = (Map) dataMap.get("YeWuXX");
         Map<String, Object> BingRenXX = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("BingRenXX") : null;
         Map<String, Object> JianChaSQ = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("JianChaSQ") : null;
+        Map<String, Object> JianChaBG = ObjectUtils.isNotEmpty(yeWuXX) ? (Map<String, Object>) yeWuXX.get("JianChaBG") : null;
         List<HashMap<String, Object>> JianChaBWList = ObjectUtils.isNotEmpty(JianChaSQ) ? (List<HashMap<String, Object>>) JianChaSQ.get("JianChaBWList") : null;
         List<HashMap<String, Object>> ZhenDuanList = ObjectUtils.isNotEmpty(JianChaSQ) ? (List<HashMap<String, Object>>) JianChaSQ.get("ZhenDuanList") : null;
         List<HashMap<String, Object>> epai = ObjectUtils.isNotEmpty(BingRenXX) ? (List<HashMap<String, Object>>) BingRenXX.get("DiZhiXXList") : null;
@@ -1935,6 +1950,9 @@
                     e.printStackTrace();
                 }
             }
+        }
+        if (ObjectUtils.isNotEmpty(JianChaBG)) {
+            patMedInspection.setAppliyid(ObjectUtils.isNotEmpty(JianChaBG.get("ShenQingDID")) ? JianChaBG.get("ShenQingDID").toString() : null);
         }
         if (CollectionUtils.isNotEmpty(JianChaBWList)) {
             List<ExternalInspectionJC> externalInspectionJC = JianChaBWList.stream().map(map -> {
@@ -2323,4 +2341,100 @@
         }
         return 1;
     }
+
+    //鏂板鎮h�呬笓绉戞。妗堝熀鏈俊鎭�
+    private void genePatSpecificArchive(PatMedOuthosp patMedOuthosp, PatArchive patArchive) {
+        String deptCategory = judgeDeptCategory(patMedOuthosp.getDeptcode(), patMedOuthosp.getOrgid());
+
+        boolean isGynecology = "1".equals(deptCategory);  // 鏄惁濡囩
+        boolean isPediatrics = "2".equals(deptCategory);  // 鏄惁鍎跨
+
+        if (isGynecology) {
+            // 璧板绉戞。妗堢敓鎴愰�昏緫
+            PatMaternityArchiveDetail patMaternityArchiveDetail
+                    = DtoConversionUtils.sourceToTarget(patMedOuthosp, PatMaternityArchiveDetail.class);
+            patMaternityArchiveDetail.setSourceType("1");
+            patMaternityArchiveDetail.setPhone(patArchive.getTelcode());
+            patMaternityArchiveDetail.setPatid(patArchive.getId());
+            patMaternityArchiveDetail.setPatname(patArchive.getName());
+            patMaternityArchiveDetail.setBirthdate(patArchive.getBirthdate());
+            patMaternityArchiveDetail.setSex(patArchive.getSex());
+            patMaternityArchiveDetail.setAddress(patArchive.getPlaceOfResidence());
+            patMaternityArchiveDetail.setOuthospno(patMedOuthosp.getOuthospno());
+            patMaternityArchiveDetail.setSerialnum(patMedOuthosp.getSerialnum());
+            patMaternityArchiveDetail.setIcd10code(patMedOuthosp.getIcd10code());
+            patMaternityArchiveDetail.setDeptcode(patMedOuthosp.getDeptcode());
+            patMaternityArchiveDetail.setDeptname(patMedOuthosp.getDeptname());
+            patMaternityArchiveDetail.setDoctorName(patMedOuthosp.getDrname());
+            patMaternityArchiveDetail.setDoctorCode(patMedOuthosp.getDrcode());
+            patMaternityArchiveDetail.setManagementDoctorName(patMedOuthosp.getDrname());
+            patMaternityArchiveDetail.setManagementDoctorCode(patMedOuthosp.getDrcode());
+            patMaternityArchiveDetail.setOrgid(patMedOuthosp.getOrgid());
+            patMaternityArchiveDetail.setCampusid(patMedOuthosp.getCampusid());
+            patMaternityArchiveService.insertOrUpdateMaternityArchive(patMaternityArchiveDetail);
+        } else if (isPediatrics) {
+            // 璧板効绉戞。妗堢敓鎴愰�昏緫
+            PatChildArchiveDetail patChildArchiveDetail
+                    = DtoConversionUtils.sourceToTarget(patMedOuthosp, PatChildArchiveDetail.class);
+            patChildArchiveDetail.setSourceType("1");
+            patChildArchiveDetail.setPhone(patArchive.getTelcode());
+            patChildArchiveDetail.setPatid(patArchive.getId());
+            patChildArchiveDetail.setPatname(patArchive.getName());
+            patChildArchiveDetail.setBirthdate(patArchive.getBirthdate());
+            patChildArchiveDetail.setSex(patArchive.getSex());
+//            patChildArchiveDetail.setAddress(patArchive.getPlaceOfResidence());
+            patChildArchiveDetail.setOuthospno(patMedOuthosp.getOuthospno());
+            patChildArchiveDetail.setSerialnum(patMedOuthosp.getSerialnum());
+            patChildArchiveDetail.setIcd10code(patMedOuthosp.getIcd10code());
+            patChildArchiveDetail.setDeptcode(patMedOuthosp.getDeptcode());
+            patChildArchiveDetail.setDeptname(patMedOuthosp.getDeptname());
+            patChildArchiveDetail.setDoctorName(patMedOuthosp.getDrname());
+            patChildArchiveDetail.setDoctorCode(patMedOuthosp.getDrcode());
+            patChildArchiveDetail.setManagementDoctorName(patMedOuthosp.getDrname());
+            patChildArchiveDetail.setManagementDoctorCode(patMedOuthosp.getDrcode());
+            patChildArchiveDetail.setOrgid(patMedOuthosp.getOrgid());
+            patChildArchiveDetail.setCampusid(patMedOuthosp.getCampusid());
+            patChildArchiveService.insertOrUpdateChildArchive(patChildArchiveDetail);
+        } else {
+            // 鏈懡涓厤缃紝涓嶇敓鎴愭。妗�
+        }
+    }
+
+    /**
+     * 鍒ゆ柇褰撳墠绉戝灞炰簬濡囩杩樻槸鍎跨
+     *
+     * @param deptCode 褰撳墠绉戝/鐥呭尯 Code锛屽 "D004"
+     * @param orgid    鍖婚櫌鏈烘瀯ID
+     * @return deptCategory锛�1-濡囩 2-鍎跨锛沶ull-鏈厤缃垨鏈懡涓�
+     */
+    public String judgeDeptCategory(String deptCode, String orgid) {
+        if (StringUtils.isEmpty(deptCode)) {
+            return null;
+        }
+
+        // 浼樺厛鍙栨満鏋勭骇閰嶇疆锛屽彇涓嶅埌鍐嶅彇鍏ㄥ眬閰嶇疆
+        String configValue = configService.selectConfigByKey("sys.dept.category",
+                orgid);
+        if (StringUtils.isEmpty(configValue)) {
+            configValue = configService.selectConfigByKey("sys.dept.category");
+        }
+        if (StringUtils.isEmpty(configValue)) {
+            return null;
+        }
+
+        JSONArray configs = JSON.parseArray(configValue);
+        if (configs == null || configs.isEmpty()) {
+            return null;
+        }
+
+        for (int i = 0; i < configs.size(); i++) {
+            JSONObject cfg = configs.getJSONObject(i);
+            JSONArray deptCodes = cfg.getJSONArray("deptCodes");
+            if (deptCodes != null && deptCodes.contains(deptCode)) {
+                return cfg.getString("deptCategory");
+            }
+        }
+        return null;
+    }
+
 }

--
Gitblit v1.9.3