From fa132afa3a6942a48002c8e36e9ee47de13ee005 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期三, 26 三月 2025 18:44:45 +0800
Subject: [PATCH] 代码提交

---
 smartor/src/main/java/com/smartor/domain/PatArchiveReq.java                               |   15 +
 smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java            |  158 +++++++++++++++--
 smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java                 |   13 
 ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java |    6 
 smartor/src/main/java/com/smartor/domain/PatArchive.java                                  |   17 +
 smartor/src/main/java/com/smartor/domain/PatArchiveOthreInfo.java                         |   12 +
 smartor/src/main/java/com/smartor/domain/ExternalInHospPatientInfo.java                   |    8 
 smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml                            |   70 ++++++-
 smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml                          |    8 
 ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java                              |    4 
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java          |    1 
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceExternalController.java |    2 
 ruoyi-admin/src/main/resources/application-druid.yml                                      |   21 +-
 smartor/src/main/java/com/smartor/domain/ExternalOperationDetail.java                     |    9 +
 smartor/src/main/resources/mapper/smartor/PatArchivecontactMapper.xml                     |  118 ++++++++-----
 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java          |   20 +
 smartor/src/main/java/com/smartor/domain/PatArchivecontact.java                           |    6 
 17 files changed, 375 insertions(+), 113 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceExternalController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceExternalController.java
index 084de70..5509b78 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceExternalController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceExternalController.java
@@ -50,7 +50,7 @@
             aBoolean = serviceExternalService.generalInterface(dataMap);
         } catch (Exception e) {
             e.printStackTrace();
-            log.error("serviceExternal---addDeptInfo鍑哄紓甯镐簡锛歿}", e.getMessage());
+            log.error("serviceExternal---generalInterface鍑哄紓甯镐簡锛歿}", e.getMessage());
             aBoolean = false;
         }
         return returnParam(aBoolean, dataMap);
diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml
index 8466ffb..71db201 100644
--- a/ruoyi-admin/src/main/resources/application-druid.yml
+++ b/ruoyi-admin/src/main/resources/application-druid.yml
@@ -18,16 +18,16 @@
 #        password: Smartor.2023
 #        driverClassName: com.mysql.cj.jdbc.Driver
         #        # 鏂板崕
-#        url: jdbc:mysql://192.168.191.181:3308/smartor?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
-#        username: smartor
-#        password: Smartor.2023
-#        driverClassName: com.mysql.cj.jdbc.Driver
+      #        url: jdbc:mysql://192.168.191.181:3308/smartor?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+      #        username: smartor
+      #        password: Smartor.2023
+      #        driverClassName: com.mysql.cj.jdbc.Driver
 
-        #        #  鍏徃浜�
-        url: jdbc:mysql://116.62.18.175:6002/smartor_lisui?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
-        username: hxsoft
-        password: Hxerp2000
-        driverClassName: com.mysql.cj.jdbc.Driver
+      #        #        #  鍏徃浜�
+              url: jdbc:mysql://116.62.18.175:6002/smartor_lisui?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+              username: hxsoft
+              password: Hxerp2000
+              driverClassName: com.mysql.cj.jdbc.Driver
 
 
       # 浠庡簱鏁版嵁婧�
@@ -218,3 +218,6 @@
 
 #鏄惁闇�瑕佹牴鎹柧鐥呭缓绔嬪嚭闄㈡偅鑰呴殢璁�
 createIcd10Visit: false
+
+#admin绠$悊鍛榰serId
+isAdmin: 1,2,3,4,5,6,7,8,9,10,11,12,13
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java
index 2d59c39..e9704bf 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java
@@ -41,17 +41,17 @@
         if (StringUtils.isNull(user))
         {
             log.info("鐧诲綍鐢ㄦ埛锛歿} 涓嶅瓨鍦�.", username);
-            throw new ServiceException("鐧诲綍鐢ㄦ埛锛�" + username + " 涓嶅瓨鍦�");
+            throw new ServiceException("鐧诲綍鐢ㄦ埛锛�" + split[0] + " 涓嶅瓨鍦�,鎴栨満鏋勪笉姝g‘锛岃妫�鏌ュ悗閲嶆柊鐧婚檰");
         }
         else if (UserStatus.DELETED.getCode().equals(user.getDelFlag()))
         {
             log.info("鐧诲綍鐢ㄦ埛锛歿} 宸茶鍒犻櫎.", username);
-            throw new ServiceException("瀵逛笉璧凤紝鎮ㄧ殑璐﹀彿锛�" + username + " 宸茶鍒犻櫎");
+            throw new ServiceException("瀵逛笉璧凤紝鎮ㄧ殑璐﹀彿锛�" + split[0] + " 宸茶鍒犻櫎");
         }
         else if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
         {
             log.info("鐧诲綍鐢ㄦ埛锛歿} 宸茶鍋滅敤.", username);
-            throw new ServiceException("瀵逛笉璧凤紝鎮ㄧ殑璐﹀彿锛�" + username + " 宸插仠鐢�");
+            throw new ServiceException("瀵逛笉璧凤紝鎮ㄧ殑璐﹀彿锛�" + split[0] + " 宸插仠鐢�");
         }else if(!user.getOrgid().equals(split[1])){
             log.info("鐧诲綍鐢ㄦ埛锛歿} 涓嶆槸鏈櫌甯愬彿锛歿}", username,split[1]);
             throw new ServiceException("瀵逛笉璧凤紝鎮ㄧ殑璐﹀彿锛�" + split[0] + " 涓嶆槸鏈櫌鐨�");
diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
index 2553e2c..63b3176 100644
--- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
+++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
@@ -220,7 +220,7 @@
     public void dealHisData2() {
         //灏嗘偅鑰呬俊鎭�佸嚭闄€�侀棬璇婃暟鎹叏閮ㄩ噰闆�
         // 鎸囧畾鐨勫紑濮嬫棩鏈�
-        LocalDate endDate = LocalDate.of(2024, 9, 1);
+        LocalDate endDate = LocalDate.of(2025, 3, 3);
         // 褰撳墠鏃ユ湡
         LocalDate currentDate = LocalDate.now();
         // 瀹氫箟鏃ユ湡鏍煎紡
@@ -600,7 +600,7 @@
         String filename = null;
         if (cry.equals("0")) filename = "鍏ラ櫌淇℃伅" + System.currentTimeMillis();
         if (cry.equals("1")) filename = "鍑洪櫌淇℃伅" + System.currentTimeMillis();
-        File file = new File("D:\\public\\鍗庡崜闆嗘垚骞冲彴鏁版嵁\\" + filename);
+        File file = new File("D:\\public\\HIS鏁版嵁閲囬泦\\" + filename);
         if (!file.exists()) {
             // 濡傛灉鏂囦欢涓嶅瓨鍦紝鍒欏垱寤烘柊鏂囦欢
             try {
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java
index 7e584f2..383e61e 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java
@@ -12,6 +12,7 @@
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.constant.UserConstants;
@@ -47,6 +48,10 @@
     @Autowired
     private SysRoleMenuMapper roleMenuMapper;
 
+
+    @Value("${isAdmin}")
+    private List<Long> isAdmin;
+
     /**
      * 鏍规嵁鐢ㄦ埛鏌ヨ绯荤粺鑿滃崟鍒楄〃
      *
@@ -71,7 +76,7 @@
         if (SysUser.isAdmin(userId)) {
             menuList = menuMapper.selectMenuList(menu);
         } else {
-            menu.getParams().put("userId" , userId);
+            menu.getParams().put("userId", userId);
             menuList = menuMapper.selectMenuListByUserId(menu);
         }
         return menuList;
@@ -122,7 +127,8 @@
     @Override
     public List<SysMenu> selectMenuTreeByUserId(Long userId) {
         List<SysMenu> menus = null;
-        if (SecurityUtils.isAdmin(userId)) {
+//        if (SecurityUtils.isAdmin(userId)) {
+        if (userId != null && isAdmin.contains(userId)) {
             menus = menuMapper.selectMenuTreeAll();
         } else {
             menus = menuMapper.selectMenuTreeByUserId(userId);
@@ -150,7 +156,7 @@
      */
     @Override
     public List<RouterVo> buildMenus(List<SysMenu> menus) {
-        log.error("buildMenus鐨勫叆鍙備负锛歿}",menus);
+        log.error("buildMenus鐨勫叆鍙備负锛歿}", menus);
         List<RouterVo> routers = new LinkedList<RouterVo>();
         for (SysMenu menu : menus) {
             RouterVo router = new RouterVo();
@@ -159,7 +165,7 @@
             router.setPath(getRouterPath(menu));
             router.setComponent(getComponent(menu));
             router.setQuery(menu.getQuery());
-            router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1" , menu.getIsCache()), menu.getPath()));
+            router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
             List<SysMenu> cMenus = menu.getChildren();
             if (!cMenus.isEmpty() && cMenus.size() > 0 && UserConstants.TYPE_DIR.equals(menu.getMenuType())) {
                 router.setAlwaysShow(true);
@@ -172,7 +178,7 @@
                 children.setPath(menu.getPath());
                 children.setComponent(menu.getComponent());
                 children.setName(StringUtils.capitalize(menu.getPath()));
-                children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1" , menu.getIsCache()), menu.getPath()));
+                children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
                 children.setQuery(menu.getQuery());
                 childrenList.add(children);
                 router.setChildren(childrenList);
@@ -191,7 +197,7 @@
             }
             routers.add(router);
         }
-        log.error("----------routers鐨勫叆鍙備负锛歿}",routers);
+        log.error("----------routers鐨勫叆鍙備负锛歿}", routers);
         for (RouterVo routerVo : routers) {
             List<String> childName = new ArrayList<>();
             List<RouterVo> childrens = routerVo.getChildren();
@@ -478,6 +484,6 @@
      * @return 鏇挎崲鍚庣殑鍐呴摼鍩熷悕
      */
     public String innerLinkReplaceEach(String path) {
-        return StringUtils.replaceEach(path, new String[]{Constants.HTTP, Constants.HTTPS, Constants.WWW, "."}, new String[]{"" , "" , "" , "/"});
+        return StringUtils.replaceEach(path, new String[]{Constants.HTTP, Constants.HTTPS, Constants.WWW, "."}, new String[]{"", "", "", "/"});
     }
 }
diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
index 5560354..e71efa3 100644
--- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
+++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
@@ -161,6 +161,7 @@
     public SysUser selectUserByUserName2(String userName) {
         String[] split = userName.split("&");
         SysUser sysUser = userMapper.selectUserByUserNameByCondition(split[0], split[1]);
+        if (Objects.isNull(sysUser)) return sysUser;
         List<SysDept> sysDepts = null;
         if (StringUtils.isNotEmpty(split[0]) && split[0].equals("admin")) {
             SysDept dept = new SysDept();
diff --git a/smartor/src/main/java/com/smartor/domain/ExternalInHospPatientInfo.java b/smartor/src/main/java/com/smartor/domain/ExternalInHospPatientInfo.java
index 5a65409..cc4dacc 100644
--- a/smartor/src/main/java/com/smartor/domain/ExternalInHospPatientInfo.java
+++ b/smartor/src/main/java/com/smartor/domain/ExternalInHospPatientInfo.java
@@ -7,6 +7,7 @@
 import lombok.Data;
 
 import java.util.Date;
+import java.util.List;
 
 /**
  * @author 鎺ユ敹绗笁鏂瑰叆闄㈡偅鑰呬俊鎭�
@@ -66,10 +67,10 @@
     private String XingBieMC;
 
     @ApiModelProperty(value = "鍑虹敓鏃ユ湡")
-    private Date ChuShengRQ;
+    private String ChuShengRQ;
 
     @ApiModelProperty(value = "骞撮緞")
-    private Long NianLing;
+    private String NianLing;
 
     @ApiModelProperty(value = "骞撮緞鍗曚綅")
     private String NianLingDW;
@@ -162,4 +163,7 @@
     @ApiModelProperty(value = "浜у鏍囧織")
     private String ChanFuBZ;
 
+    @ApiModelProperty(value = "鑱旂郴浜轰俊鎭�")
+    List<ExternalInHospPatientLiaisonInfo> externalInHospPatientLiaisonInfos;
+
 }
diff --git a/smartor/src/main/java/com/smartor/domain/ExternalOperationDetail.java b/smartor/src/main/java/com/smartor/domain/ExternalOperationDetail.java
index 3c8418b..047016c 100644
--- a/smartor/src/main/java/com/smartor/domain/ExternalOperationDetail.java
+++ b/smartor/src/main/java/com/smartor/domain/ExternalOperationDetail.java
@@ -40,4 +40,13 @@
     @ApiModelProperty(value = "鎵嬫湳閮ㄤ綅")
     private String ShouShuBW;
 
+    @ApiModelProperty(value = "鏍囧噯绁ㄥ弸")
+    private String BiaoZhunBM;
+
+    @ApiModelProperty(value = "鎵嬫湳鍚嶇ОQZ")
+    private String ShouShuMCQZ;
+
+    @ApiModelProperty(value = "鎵嬫湳鍚嶇ОHZ")
+    private String ShouShuMCHZ;
+
 }
diff --git a/smartor/src/main/java/com/smartor/domain/PatArchive.java b/smartor/src/main/java/com/smartor/domain/PatArchive.java
index 776397e..fc0b617 100644
--- a/smartor/src/main/java/com/smartor/domain/PatArchive.java
+++ b/smartor/src/main/java/com/smartor/domain/PatArchive.java
@@ -255,6 +255,9 @@
     @ApiModelProperty("鏍囩闆嗗悎")
     private List<PatArchivetag> tagList;
 
+    @ApiModelProperty("浜插睘闆嗗悎")
+    private List<PatArchivecontact> patArchivecontactList;
+
     /**
      * 鏍囩
      */
@@ -363,4 +366,18 @@
     @Excel(name = "涓昏鐓ф姢浜哄勾榫�")
     private String casePersonAge;
 
+    /**
+     * 骞撮緞
+     */
+    @ApiModelProperty("骞撮緞")
+    @Excel(name = " 绗簩骞撮緞 ")
+    private Long age2;
+
+    /**
+     * 骞撮緞
+     */
+    @ApiModelProperty("骞撮緞鍗曚綅")
+    @Excel(name = " 绗簩骞撮緞鍗曚綅 ")
+    private String ageUnit2;
+
 }
diff --git a/smartor/src/main/java/com/smartor/domain/PatArchiveOthreInfo.java b/smartor/src/main/java/com/smartor/domain/PatArchiveOthreInfo.java
index 35f086e..d375c31 100644
--- a/smartor/src/main/java/com/smartor/domain/PatArchiveOthreInfo.java
+++ b/smartor/src/main/java/com/smartor/domain/PatArchiveOthreInfo.java
@@ -186,6 +186,18 @@
     @ApiModelProperty("骞撮緞鍗曚綅")
     @Excel(name = " 骞撮緞鍗曚綅 ")
     private String ageUnit;
+    /**
+     * 骞撮緞
+     */
+    @ApiModelProperty("骞撮緞")
+    @Excel(name = " 骞撮緞 ")
+    private Long age2;
+    /**
+     * 骞撮緞
+     */
+    @ApiModelProperty("骞撮緞鍗曚綅")
+    @Excel(name = " 骞撮緞鍗曚綅 ")
+    private String ageUnit2;
 
     /**
      * 寤烘。鏃堕棿
diff --git a/smartor/src/main/java/com/smartor/domain/PatArchiveReq.java b/smartor/src/main/java/com/smartor/domain/PatArchiveReq.java
index 82bf80d..05ef4c7 100644
--- a/smartor/src/main/java/com/smartor/domain/PatArchiveReq.java
+++ b/smartor/src/main/java/com/smartor/domain/PatArchiveReq.java
@@ -169,13 +169,24 @@
     /**
      * 鐥呭尯缂栧彿
      */
-    @ApiModelProperty(value = "鐥呭尯缂栧彿")
+    @ApiModelProperty(value = "绂婚櫌鐥呭尯缂栧彿")
     private List<String> leavehospitaldistrictcodes;
+
+    /**
+     * 绉戝缂栫爜
+     */
+    @ApiModelProperty(value = "绂婚櫌绉戝缂栫爜")
+    private List<String> leaveldeptcodes;
+    /**
+     * 鐥呭尯缂栧彿
+     */
+    @ApiModelProperty(value = "鐥呭尯缂栧彿")
+    private List<String> hospitaldistrictcodes;
 
     /**
      * 绉戝缂栫爜
      */
     @ApiModelProperty(value = "绉戝缂栫爜")
     @Excel(name = " 绉戝缂栫爜 ")
-    private List<String> leaveldeptcodes;
+    private List<String> deptcodes;
 }
diff --git a/smartor/src/main/java/com/smartor/domain/PatArchivecontact.java b/smartor/src/main/java/com/smartor/domain/PatArchivecontact.java
index a82eab5..d645191 100644
--- a/smartor/src/main/java/com/smartor/domain/PatArchivecontact.java
+++ b/smartor/src/main/java/com/smartor/domain/PatArchivecontact.java
@@ -28,10 +28,10 @@
     private Long id;
 
     /**
-     * 鑱旂郴鏂瑰紡ID
+     * 鍏宠仈鎮h�匢D
      */
-    @Excel(name = " 鑱旂郴鏂瑰紡ID ")
-    @ApiModelProperty(value = "鑱旂郴鏂瑰紡ID")
+    @Excel(name = " 鍏宠仈鎮h�匢D ")
+    @ApiModelProperty(value = "鍏宠仈鎮h�匢D")
     private Long patid;
 
     /**
diff --git a/smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java
index b5d3963..27b10b8 100644
--- a/smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/PatArchiveServiceImpl.java
@@ -7,10 +7,7 @@
 import com.ruoyi.common.utils.DtoConversionUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.smartor.domain.*;
-import com.smartor.mapper.BaseTagMapper;
-import com.smartor.mapper.PatArchiveMapper;
-import com.smartor.mapper.PatArchivetagMapper;
-import com.smartor.mapper.ServiceSubtaskMapper;
+import com.smartor.mapper.*;
 import com.smartor.service.IPatArchiveService;
 import com.smartor.service.IPatMedInhospService;
 import com.smartor.service.IPatMedOuthospService;
@@ -62,7 +59,7 @@
     private IPatMedInhospService patMedInhospService;
 
     @Autowired
-    private IPatMedOuthospService patMedOuthospService;
+    private PatArchivecontactMapper patArchivecontactMapper;
 
     @Autowired
     private IPatMedPhysicalService patMedPhysicalService;
@@ -605,6 +602,12 @@
             patArchive1.setTagList(stringList.stream().collect(Collectors.toList()));
             patArchives.add(patArchive1);
         }
+        //缁欐偅鑰呰仈绯讳汉璧嬪��
+        for (PatArchive pa : patArchives) {
+            PatArchivecontact patArchivecontact = new PatArchivecontact();
+            patArchivecontact.setPatid(pa.getId());
+            pa.setPatArchivecontactList(patArchivecontactMapper.selectPatArchivecontactList(patArchivecontact));
+        }
 
         return patArchives;
     }
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 2b2cc4e..9fd46d8 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceExternalServiceImpl.java
@@ -7,18 +7,21 @@
 import com.smartor.domain.*;
 import com.smartor.mapper.*;
 import com.smartor.service.IServiceExternalService;
-import com.smartor.service.IServiceSubtaskService;
-import org.springframework.beans.factory.annotation.Value;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.Period;
+import java.time.ZoneId;
+import java.time.temporal.ChronoUnit;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -42,6 +45,8 @@
     private BaseOrganizationMapper baseOrganizationMapper;
     @Autowired
     private PatArchiveMapper patArchiveMapper;
+    @Autowired
+    private PatArchivecontactMapper patArchivecontactMapper;
     @Autowired
     private PatMedInhospMapper patMedInhospMapper;
     @Autowired
@@ -218,6 +223,7 @@
             info.setGuanXiMC((String) map.get("GuanXiMC"));
             return info;
         }).collect(Collectors.toList());
+        externalInHospPatientInfo.setExternalInHospPatientLiaisonInfos(epli2);
 
         List<ExternalInHospPatientDiagnoseInfo> hospPatientDiagnoseInfos2 = hospPatientDiagnoseInfos.stream().map(map -> {
             ExternalInHospPatientDiagnoseInfo info = new ExternalInHospPatientDiagnoseInfo();
@@ -244,7 +250,7 @@
         Map<String, Object> BingRenXX = (Map<String, Object>) yeWuXX.get("BingRenXX");
         ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true);
         PatMedInhosp patMedInhosp = new PatMedInhosp();
-        patMedInhosp.setInhospno(externalInHospPatientInfo.getZhuYuanHao());
+        patMedInhosp.setInhospno(externalInHospPatientInfo.getBingAnHao());
         List<PatMedInhosp> patMedInhospList = patMedInhospMapper.selectPatMedInhospList(patMedInhosp);
         for (PatMedInhosp patMedInhosp1 : patMedInhospList) {
             String tagname = patMedInhospMapper.getTagnameBypatid(patMedInhosp1.getPatid());
@@ -311,7 +317,7 @@
         PatArchive patArchive = addPatArchive(externalInHospPatientInfo, externalInHospPatientAddrInfo, externalInHospPatientLiaisonInfo);
 
         PatMedInhosp patMedInhosp = new PatMedInhosp();
-        patMedInhosp.setInhospno(externalInHospPatientInfo.getZhuYuanHao());
+        patMedInhosp.setInhospno(externalInHospPatientInfo.getBingAnHao());
         List<PatMedInhosp> patMedInhospList = patMedInhospMapper.selectPatMedInhospList(patMedInhosp);
         for (PatMedInhosp patMedInhosp1 : patMedInhospList) {
             String tagname = patMedInhospMapper.getTagnameBypatid(patMedInhosp1.getPatid());
@@ -329,6 +335,11 @@
         patMedInhosp1.setOperator(JiuZhenXX.get("CaoZuoRXM").toString());
         patMedInhosp1.setOperatorId(JiuZhenXX.get("CaoZuoRID").toString());
         patMedInhosp1.setUpdateTime(new Date());
+        patMedInhosp1.setDrname(ObjectUtils.isNotEmpty(JiuZhenXX.get("ZhuZhiYSXM")) ? JiuZhenXX.get("ZhuZhiYSXM").toString() : null);
+        patMedInhosp1.setDrcode(ObjectUtils.isNotEmpty(JiuZhenXX.get("ZhuZhiYSID")) ? JiuZhenXX.get("ZhuZhiYSID").toString() : null);
+        patMedInhosp1.setNurseName(ObjectUtils.isNotEmpty(JiuZhenXX.get("ZeRenHSXM")) ? JiuZhenXX.get("ZeRenHSXM").toString() : null);
+        patMedInhosp1.setNurseId(ObjectUtils.isNotEmpty(JiuZhenXX.get("ZeRenHSID")) ? JiuZhenXX.get("ZeRenHSID").toString() : null);
+        patMedInhosp1.setBedNo(ObjectUtils.isNotEmpty(JiuZhenXX.get("DangQianCWMC")) ? JiuZhenXX.get("DangQianCWMC").toString() : null);
         patMedInhosp1.setTelcode(patArchive.getTelcode());
         patMedInhosp1.setLeavehospitaldistrictcode(externalInHospPatientInfo.getDangQianBQID());
         patMedInhosp1.setLeavehospitaldistrictname(externalInHospPatientInfo.getDangQianBQMC());
@@ -346,7 +357,7 @@
         patMedInhosp1.setLeaveicd10code(StringUtils.isNotEmpty(patMedInhosp1.getLeaveicd10code()) ? patMedInhosp1.getLeaveicd10code() + "," + hospPatientDiagnoseInfos2.get(0).getZhenDuanID() : hospPatientDiagnoseInfos2.get(0).getZhenDuanID());
         patMedInhosp1.setLeavediagname(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) ? patMedInhosp1.getLeavediagname() + "," + hospPatientDiagnoseInfos2.get(0).getZhenDuanMC() : hospPatientDiagnoseInfos2.get(0).getZhenDuanMC());
         patMedInhosp1.setDiagname(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) ? patMedInhosp1.getLeavediagname() + "," + hospPatientDiagnoseInfos2.get(0).getZhenDuanMC() : hospPatientDiagnoseInfos2.get(0).getZhenDuanMC());
-        patMedInhosp1.setIcd10code(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) ? patMedInhosp1.getLeavediagname() + "," + hospPatientDiagnoseInfos2.get(0).getZhenDuanMC() : hospPatientDiagnoseInfos2.get(0).getZhenDuanMC());
+        //     patMedInhosp1.setIcd10code(StringUtils.isNotEmpty(patMedInhosp1.getLeavediagname()) ? patMedInhosp1.getLeavediagname() + "," + hospPatientDiagnoseInfos2.get(0).getZhenDuanMC() : hospPatientDiagnoseInfos2.get(0).getZhenDuanMC());
         patMedInhosp1.setInhospstate("1");
         if (CollectionUtils.isNotEmpty(patMedInhospList)) {
             patMedInhosp1.setUpdateTime(new Date());
@@ -362,7 +373,7 @@
             patMedInhosp1.setPatname(patArchive.getName());
             patMedInhosp1.setOrgid(BingRenXX.get("ZuZhiJGID").toString());
             patMedInhosp1.setPatno(BingRenXX.get("BingRenID").toString());
-            patMedInhosp1.setInhospno(BingRenXX.get("ZhuYuanHao").toString());
+            patMedInhosp1.setInhospno(BingRenXX.get("BingAnHao").toString());
             patMedInhosp1.setSerialnum(BingRenXX.get("BingAnHao").toString());
             patMedInhosp1.setCreateTime(new Date());
             int i = patMedInhospMapper.insertPatMedInhosp(patMedInhosp1);
@@ -378,7 +389,7 @@
         Map<String, Object> BingRenXX = (Map<String, Object>) yeWuXX.get("BingRenXX");
         ExternalInHospPatientInfo externalInHospPatientInfo = BeanUtil.mapToBean(BingRenXX, ExternalInHospPatientInfo.class, true);
         PatMedInhosp patMedInhosp = new PatMedInhosp();
-        patMedInhosp.setInhospno(externalInHospPatientInfo.getZhuYuanHao());
+        patMedInhosp.setInhospno(externalInHospPatientInfo.getBingAnHao());
         List<PatMedInhosp> patMedInhospList = patMedInhospMapper.selectPatMedInhospList(patMedInhosp);
         for (PatMedInhosp patMedInhosp1 : patMedInhospList) {
             String tagname = patMedInhospMapper.getTagnameBypatid(patMedInhosp1.getPatid());
@@ -602,7 +613,7 @@
         patMedOperation.setPatname(externalInHospPatientInfo.getXingMing());
         patMedOperation.setVisitid(null);
         patMedOperation.setSerialnum(externalInHospPatientInfo.getZhuYuanHao());
-        patMedOperation.setInhospno(externalInHospPatientInfo.getZhuYuanHao());
+        patMedOperation.setInhospno(externalInHospPatientInfo.getBingAnHao());
         patMedOperation.setHospitalname(externalInHospPatientInfo.getZuZhiJGMC());
         patMedOperation.setHospitalcode(externalInHospPatientInfo.getZuZhiJGID());
         patMedOperation.setDeptid(externalOperationInfo.getShouShuKSID());
@@ -625,13 +636,33 @@
                 patMedOperation.setDelFlag("1");
                 //鍚屾椂鍘绘煡璇紝鏄惁鍦╯ubtask涓敓鎴愪换鍔★紝濡傛灉鐢熸垚鍑哄緱绔嬮┈鍒犻櫎
             }
+            patMedOperation.setUpdateTime(new Date());
             patMedOperationMapper.updatePatMedOperation(patMedOperation);
-        } else patMedOperationMapper.insertPatMedOperation(patMedOperation);
+        } else {
+            patMedOperation.setCreateTime(new Date());
+            patMedOperationMapper.insertPatMedOperation(patMedOperation);
+        }
         log.error("-----patMedOperation鐨勪富閿甶d涓猴細{}", patMedOperation.getId());
 
         if (ObjectUtils.isNotEmpty(ssxx)) {
-            Map<String, Object> ShouShuMXList = (Map<String, Object>) ssxx.get("ShouShuMXList");
-            List<ExternalOperationDetail> externalOperationDetails = BeanUtil.mapToBean(ShouShuMXList, List.class, true);
+            List<HashMap<String, Object>> ShouShuMXList = (List<HashMap<String, Object>>) ssxx.get("ShouShuMXList");
+
+            List<ExternalOperationDetail> externalOperationDetails = ShouShuMXList.stream().map(map -> {
+                ExternalOperationDetail info = new ExternalOperationDetail();
+                info.setShouShuMCID((String) map.get("ShouShuMCID"));
+                info.setShouShuMC((String) map.get("ShouShuMC"));
+                info.setZhuShouSBZ((String) map.get("ZhuShouSBZ"));
+                info.setQieKouLBDM((String) map.get("QieKouLBDM"));
+                info.setQieKouLBMC((String) map.get("QieKouLBMC"));
+                info.setShouShuJBDM((String) map.get("ShouShuJBDM"));
+                info.setShouShuJBMC((String) map.get("ShouShuJBMC"));
+                info.setShouShuBW((String) map.get("ShouShuBW"));
+                info.setBiaoZhunBM((String) map.get("BiaoZhunBM"));
+                info.setShouShuMCQZ((String) map.get("ShouShuMCQZ"));
+                info.setShouShuMCHZ((String) map.get("ShouShuMCHZ"));
+                return info;
+            }).collect(Collectors.toList());
+
             //addMianTableFalg鏄惁闇�瑕佸皢涓绘墜鏈殑淇℃伅鏀惧埌PatMedOperation琛ㄤ腑锛堝彧鏈夌涓�涓富鎵嬫湳淇℃伅闇�瑕佹斁锛屽悗闈㈢殑閮戒笉闇�瑕佹斁浜嗭紝涔熷氨鏄锛岀涓�涓斁瀹屽悗锛屽氨瑕佹妸杩欎釜flag鏀规垚false锛�
             Boolean addMianTableFalg = true;
             for (ExternalOperationDetail externalOperationDetail : externalOperationDetails) {
@@ -651,10 +682,11 @@
                     patMedOperation.setOpcode(externalOperationDetail.getShouShuMCID());
                     patMedOperation.setOpdesc(externalOperationDetail.getShouShuMC());
 //                    patMedOperation.setOpid(externalOperationDetail.getShouShuJBDM());
+                    patMedOperation.setUpdateTime(new Date());
                     patMedOperationMapper.updatePatMedOperation(patMedOperation);
                     addMianTableFalg = false;
                 }
-
+                patMedOperationItem.setCreateTime(new Date());
                 patMedOperationItemMapper.insertPatMedOperationItem(patMedOperationItem);
             }
         }
@@ -663,12 +695,22 @@
 
     //鏂板鎮h�呭熀鏈俊鎭�
     private PatArchive addPatArchive(ExternalInHospPatientInfo externalInHospPatientInfo, ExternalInHospPatientAddrInfo externalInHospPatientAddrInfo, ExternalInHospPatientLiaisonInfo externalInHospPatientLiaisonInfo) {
+        Date parse = null;
+        String chuShengRQ = externalInHospPatientInfo.getChuShengRQ();
+        if (StringUtils.isNotEmpty(chuShengRQ)) {
+            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
+            try {
+                parse = simpleDateFormat.parse(chuShengRQ);
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+        }
         PatArchive patArchive = new PatArchive();
         patArchive.setIdcardno(externalInHospPatientInfo.getZhengJianHM());
         patArchive.setOrgid(externalInHospPatientInfo.getZuZhiJGID());
         List<PatArchive> patArchives = patArchiveMapper.selectPatArchiveList(patArchive);
         patArchive.setPatientno(externalInHospPatientInfo.getJiuZhenKH());
-        patArchive.setBirthdate(externalInHospPatientInfo.getChuShengRQ());
+        patArchive.setBirthdate(parse);
         patArchive.setPatidHis(externalInHospPatientInfo.getBingRenID());
         patArchive.setSourcefrom(1);
         patArchive.setPattype("2");
@@ -687,9 +729,16 @@
             patArchive.setPlaceOfResidence(por.replace("null", ""));
             patArchive.setBirthplace(por.replace("null", ""));
         }
-        patArchive.setBirthdate(externalInHospPatientInfo.getChuShengRQ());
-        patArchive.setAge(externalInHospPatientInfo.getNianLing());
-        patArchive.setAgeUnit(externalInHospPatientInfo.getNianLingDW());
+
+        if (ObjectUtils.isNotEmpty(parse)) {
+            Map<String, String> map = calculateAge(parse.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), LocalDate.now());
+            patArchive.setAge(ObjectUtils.isNotEmpty(map.get("age")) ? Long.valueOf(map.get("age")) : null);
+            patArchive.setAgeUnit(map.get("ageUnit"));
+            patArchive.setAge2(ObjectUtils.isNotEmpty(map.get("age2")) ? Long.valueOf(map.get("age2")) : null);
+            patArchive.setAgeUnit2(map.get("ageUnit2"));
+
+        }
+
         patArchive.setTelcode(externalInHospPatientInfo.getLianXiDH());
         if (StringUtils.isEmpty(externalInHospPatientInfo.getLianXiDH()))
             patArchive.setTelcode(externalInHospPatientInfo.getLianXiRDH());
@@ -697,7 +746,7 @@
         patArchive.setGuid(externalInHospPatientInfo.getZuZhiJGID());
         if (ObjectUtils.isNotEmpty(externalInHospPatientLiaisonInfo))
             patArchive.setRelativetelcode(externalInHospPatientLiaisonInfo.getLianXiRDH());
-        patArchive.setInhospno(externalInHospPatientInfo.getZhuYuanHao());
+        patArchive.setInhospno(externalInHospPatientInfo.getBingAnHao());
         patArchive.setCreateTime(new Date());
         patArchive.setIdcardtype(externalInHospPatientInfo.getZhengJianLXMC());
         if (CollectionUtils.isNotEmpty(patArchives)) {
@@ -711,6 +760,26 @@
             }
         }
         patArchiveMapper.insertPatArchiveSingle(patArchive);
+        //鏂板睘淇℃伅
+        if (ObjectUtils.isNotEmpty(externalInHospPatientInfo.getExternalInHospPatientLiaisonInfos())) {
+            for (ExternalInHospPatientLiaisonInfo external : externalInHospPatientInfo.getExternalInHospPatientLiaisonInfos()) {
+                PatArchivecontact patArchivecontact = new PatArchivecontact();
+                patArchivecontact.setPatid(patArchive.getId());
+                patArchivecontact.setContactname(external.getLianXiRXM());
+                patArchivecontact.setOrgid(patArchive.getOrgid());
+                List<PatArchivecontact> patArchivecontacts = patArchivecontactMapper.selectPatArchivecontactList(patArchivecontact);
+                patArchivecontact.setContactway(external.getLianXiRDH());
+                patArchivecontact.setRelation(external.getGuanXiMC());
+                if (CollectionUtils.isEmpty(patArchivecontacts))
+                    patArchivecontactMapper.insertPatArchivecontact(patArchivecontact);
+                else {
+                    patArchivecontact.setId(patArchivecontacts.get(0).getId());
+                    patArchivecontactMapper.updatePatArchivecontact(patArchivecontact);
+                }
+            }
+        }
+
+
         return patArchive;
     }
 
@@ -718,7 +787,8 @@
     private Boolean addPadInhospInfo(ExternalInHospPatientInfo externalInHospPatientInfo, PatArchive patArchive, ExternalInHospPatientDiagnoseInfo externalInHospPatientDiagnoseInfo) {
         PatMedInhosp patMedInhosp = new PatMedInhosp();
         if (ObjectUtils.isNotEmpty(externalInHospPatientInfo)) {
-            patMedInhosp.setInhospno(externalInHospPatientInfo.getZhuYuanHao());
+            //鍖婚櫌閭h竟璇磋鐢ㄧ梾妗堝彿锛屼笉瑕佺敤浣忛櫌鍙�
+            patMedInhosp.setInhospno(externalInHospPatientInfo.getBingAnHao());
             patMedInhosp.setSerialnum(externalInHospPatientInfo.getZhuYuanHao());
             patMedInhosp.setHospitalname(externalInHospPatientInfo.getZuZhiJGMC());
             patMedInhosp.setHospitalcode(externalInHospPatientInfo.getZuZhiJGID());
@@ -884,4 +954,56 @@
         return true;
     }
 
+    public Map<String, String> calculateAge(LocalDate birthdate, LocalDate today) {
+        if (birthdate == null || today.isBefore(birthdate)) {
+            return null;
+        }
+        Map<String, String> ageMap = new HashMap<>();
+
+        Period period = Period.between(birthdate, today);
+        long totalDays = ChronoUnit.DAYS.between(birthdate, today);
+        long totalMonths = ChronoUnit.MONTHS.between(birthdate, today);
+
+        int years = period.getYears();
+        int months = period.getMonths();
+        int days = period.getDays();
+
+        String ageUnit;
+        Integer age;
+        String ageUnit2 = null;
+        Integer age2 = null;
+
+        if (totalDays < 30) {
+            // 灏忎簬 1 涓湀锛屾寜澶╄绠�
+            ageUnit = "澶�";
+            age = (int) totalDays;
+            ageMap.put("age", age != null ? age.toString() : null);
+            ageMap.put("ageUnit", ageUnit);
+            ageMap.put("age2", null);
+            ageMap.put("ageUnit2", null);
+        } else if (totalMonths < 12) {
+            // 灏忎簬 1 骞达紝鎸夋湀 + 澶╄绠�
+            ageUnit = "鏈�";
+            age = (int) totalMonths;
+            ageUnit2 = "澶�";
+            age2 = days;
+            ageMap.put("age", age != null ? age.toString() : null);
+            ageMap.put("ageUnit", ageUnit);
+            ageMap.put("age2", age2 != null ? age2.toString() : null);
+            ageMap.put("ageUnit2", ageUnit2);
+        } else {
+            // 澶т簬 1 骞达紝鎸夊勾 + 鏈堣绠�
+            ageUnit = "宀�";
+            age = years;
+            ageUnit2 = "鏈�";
+            age2 = months;
+            ageMap.put("age", age != null ? age.toString() : null);
+            ageMap.put("ageUnit", ageUnit);
+            ageMap.put("age2", age2 != null ? age2.toString() : null);
+            ageMap.put("ageUnit2", ageUnit2);
+        }
+
+        return ageMap;
+    }
+
 }
diff --git a/smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml b/smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml
index ecb1f0f..ca1e06f 100644
--- a/smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatArchiveMapper.xml
@@ -23,6 +23,7 @@
         <result property="idcardno" column="idcardno"/>
         <result property="birthdate" column="birthdate"/>
         <result property="age" column="age"/>
+        <result property="age2" column="age2"/>
         <result property="sourcefrom" column="sourcefrom"/>
         <result property="archivetime" column="archivetime"/>
         <result property="archiveby" column="archiveby"/>
@@ -47,6 +48,7 @@
         <result property="bedNo" column="bedno"/>
         <result property="inhosptime" column="inhosptime"/>
         <result property="ageUnit" column="age_unit"/>
+        <result property="ageUnit2" column="age_unit2"/>
         <result property="leavehospitaldistrictname" column="leavehospitaldistrictname"/>
         <result property="leavehospitaldistrictcode" column="leavehospitaldistrictcode"/>
         <result property="careFacilities" column="care_facilities"/>
@@ -80,6 +82,7 @@
         <result property="idcardno" column="idcardno"/>
         <result property="birthdate" column="birthdate"/>
         <result property="age" column="age"/>
+        <result property="age2" column="age2"/>
         <result property="sourcefrom" column="sourcefrom"/>
         <result property="archivetime" column="archivetime"/>
         <result property="archiveby" column="archiveby"/>
@@ -105,6 +108,7 @@
         <result property="starttime" column="starttime"/>
         <result property="endtime" column="endtime"/>
         <result property="ageUnit" column="age_unit"/>
+        <result property="ageUnit2" column="age_unit2"/>
         <result property="inhospno" column="inhospno"/>
         <result property="nurseId" column="nurse_id"/>
         <result property="nurseName" column="nurse_name"/>
@@ -122,12 +126,14 @@
                patientno,
                patid_his,
                age_unit,
+               age_unit2,
                sd_flag,
                name,
                sex,
                idcardno,
                birthdate,
                age,
+               age2,
                nation,
                native_place,
                place_of_residence,
@@ -179,6 +185,9 @@
             <if test="patidHis != null ">and patid_his = #{patidHis}</if>
             <if test="sdFlag != null ">and sd_flag = #{sdFlag}</if>
             <if test="ageUnit != null ">and age_unit = #{ageUnit}</if>
+            <if test="age != null ">and age = #{age}</if>
+            <if test="age2 != null ">and age2 = #{age2}</if>
+            <if test="ageUnit2 != null ">and age_unit2 = #{ageUnit2}</if>
             <if test="notrequiredFlag != null ">and notrequired_flag = #{notrequiredFlag}</if>
             <if test="notrequiredreason != null ">and notrequiredreason = #{notrequiredreason}</if>
             <if test="careFacilities != null ">and care_facilities = #{careFacilities}</if>
@@ -197,6 +206,7 @@
         select
         a.id,
         a.age_unit,
+        a.age_unit2,
         a.notrequired_flag,
         a.notrequiredreason,
         a.patientno,
@@ -208,6 +218,7 @@
         a.idcardtype,
         a.idcardno,
         a.age,
+        a.age2,
         a.telcode,
         a.create_time,
         a.update_time,
@@ -262,6 +273,7 @@
             <if test="guid != null">guid,</if>
             <if test="birthdate != null">birthdate,</if>
             <if test="age != null">age,</if>
+            <if test="age2 != null">age2,</if>
             <if test="sourcefrom != null">sourcefrom,</if>
             <if test="archivetime != null">archivetime,</if>
             <if test="archiveby != null">archiveby,</if>
@@ -278,6 +290,7 @@
             <if test="isupload != null">isupload,</if>
             <if test="uploadTime != null">upload_time,</if>
             <if test="ageUnit != null">age_unit,</if>
+            <if test="ageUnit2 != null">age_unit2,</if>
             <if test="notrequiredFlag != null ">notrequired_flag,</if>
             <if test="notrequiredreason != null ">notrequiredreason,</if>
             <if test="careFacilities != null ">care_facilities,</if>
@@ -307,6 +320,7 @@
             <if test="guid != null">#{guid},</if>
             <if test="birthdate != null">#{birthdate},</if>
             <if test="age != null">#{age},</if>
+            <if test="age2 != null">#{age2},</if>
             <if test="sourcefrom != null">#{sourcefrom},</if>
             <if test="archivetime != null">#{archivetime},</if>
             <if test="archiveby != null">#{archiveby},</if>
@@ -323,6 +337,7 @@
             <if test="isupload != null">#{isupload},</if>
             <if test="uploadTime != null">#{uploadTime},</if>
             <if test="ageUnit != null">#{ageUnit},</if>
+            <if test="ageUnit2 != null">#{ageUnit2},</if>
             <if test="notrequiredFlag != null ">#{notrequiredFlag},</if>
             <if test="notrequiredreason != null ">#{notrequiredreason},</if>
             <if test="careFacilities != null ">#{careFacilities},</if>
@@ -338,15 +353,15 @@
 
     <insert id="insertPatArchive">
         insert into
-        pat_archive(name,viptype,sex,idcardno,birthdate,place_of_residence,age,sourcefrom,archivetime,archiveby,telcode,relativetelcode,idcardtype,orgid,openid,dduserid,update_by,update_time
-        ,create_by,create_time,isupload,upload_time,pattype,nation,birthplace,native_place,patientno,patid_his,sd_flag,age_unit,notrequired_flag,notrequiredreason,care_facilities,case_path,
+        pat_archive(name,viptype,sex,idcardno,birthdate,place_of_residence,age,age2,sourcefrom,archivetime,archiveby,telcode,relativetelcode,idcardtype,orgid,openid,dduserid,update_by,update_time
+        ,create_by,create_time,isupload,upload_time,pattype,nation,birthplace,native_place,patientno,patid_his,sd_flag,age_unit,age_unit2,notrequired_flag,notrequiredreason,care_facilities,case_path,
         degree_of_education,marital_status,income,medicare_type,care_person,case_person_age)
         values
         <foreach item="item" index="index" collection="list" separator=",">
-            (#{item.name},#{item.viptype},#{item.sex},#{item.idcardno},#{item.birthdate},#{item.placeOfResidence},#{item.age},#{item.sourcefrom},#{item.archivetime},#{item.archiveby}
+            (#{item.name},#{item.viptype},#{item.sex},#{item.idcardno},#{item.birthdate},#{item.placeOfResidence},#{item.age},#{item.age2},#{item.sourcefrom},#{item.archivetime},#{item.archiveby}
             ,#{item.telcode},#{item.archiveby},#{item.idcardtype},#{item.orgid},#{item.openid},#{item.dduserid},#{item.updateBy},
             #{item.updateTime},#{item.createBy},#{item.createTime},#{item.isupload},#{item.uploadTime},#{item.pattype},#{item.nation},#{item.birthplace},#{item.nativePlace},#{item.patientno},
-            #{item.patidHis},#{item.sdFlag},#{item.ageUnit},#{item.notrequiredFlag},#{item.notrequiredreason}
+            #{item.patidHis},#{item.sdFlag},#{item.ageUnit},#{item.ageUnit2},#{item.notrequiredFlag},#{item.notrequiredreason}
             ,#{item.careFacilities},#{item.casePath},#{item.degreeOfEducation},#{item.maritalStatus},#{item.income},#{item.medicareType},#{item.carePerson},#{item.casePersonAge})
         </foreach>
     </insert>
@@ -361,6 +376,7 @@
             <if test="placeOfResidence != null">place_of_residence = #{placeOfResidence},</if>
             <if test="birthplace != null">birthplace = #{birthplace},</if>
             <if test="age != null">age = #{age},</if>
+            <if test="age2 != null">age2 = #{age2},</if>
             <if test="sourcefrom != null">sourcefrom = #{sourcefrom},</if>
             <if test="archivetime != null">archivetime = #{archivetime},</if>
             <if test="archiveby != null">archiveby = #{archiveby},</if>
@@ -381,6 +397,7 @@
             <if test="viptype != null">patid_his = #{patidHis},</if>
             <if test="viptype != null">sd_flag = #{sdFlag},</if>
             <if test="ageUnit != null">age_unit = #{ageUnit},</if>
+            <if test="ageUnit2 != null">age_unit2 = #{ageUnit2},</if>
             <if test="notrequiredFlag != null ">notrequired_flag = #{notrequiredFlag},</if>
             <if test="notrequiredreason != null ">notrequiredreason = #{notrequiredreason},</if>
             <if test="careFacilities != null ">care_facilities = #{careFacilities},</if>
@@ -396,18 +413,20 @@
         where id = #{id}
     </update>
 
-    <delete id="deletePatArchiveByPatid" parameterType="Long">
-        delete
-        from pat_archive
+    <update id="deletePatArchiveByPatid" parameterType="Long">
+        update pat_archive
+        <trim prefix="SET" suffixOverrides=",">
+            del_flag =1
+        </trim>
         where id = #{id}
-    </delete>
+    </update>
 
-    <delete id="deletePatArchiveByPatids" parameterType="String">
-        delete from pat_archive where id in
+    <update id="deletePatArchiveByPatids" parameterType="String">
+        update pat_archive set del_flag =1 where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
-    </delete>
+    </update>
 
     <select id="selectPatArchiveInfoByAllhosp" parameterType="com.smartor.domain.PatArchiveReq"
             resultMap="PatArchiveOthreInfoResult">
@@ -415,6 +434,7 @@
         SELECT
         a.id,
         a.age_unit,
+        a.age_unit2,
         a.patid_his,
         a.notrequired_flag,
         a.notrequiredreason,
@@ -428,6 +448,7 @@
         a.birthplace,
         a.idcardno,
         a.birthdate,
+        a.age2,
         a.age,
         a.sourcefrom,
         a.archivetime,
@@ -476,6 +497,7 @@
         select
         a.id,
         a.age_unit,
+        a.age_unit2,
         a.inhospno,
         a.notrequired_flag,
         a.notrequiredreason,
@@ -495,6 +517,7 @@
         a.idcardno,
         a.birthdate,
         a.age,
+        a.age2,
         a.sourcefrom,
         a.archivetime,
         a.archiveby,
@@ -577,6 +600,21 @@
                     #{leaveldeptcode}
                 </foreach>
             </if>
+
+            <if test="hospitaldistrictcodes != null and hospitaldistrictcodes.size()>0">
+                AND d.hospitaldistrictcode IN
+                <foreach collection="hospitaldistrictcodes" item="hospitaldistrictcode" open="(" separator=","
+                         close=")">
+                    #{hospitaldistrictcode}
+                </foreach>
+            </if>
+            <if test="deptcodes != null and deptcodes.size() > 0">
+                AND d.deptcode IN
+                <foreach collection="deptcodes" item="deptcode" open="(" separator=","
+                         close=")">
+                    #{deptcode}
+                </foreach>
+            </if>
             <if test="pids != null">
                 AND a.id NOT IN
                 <foreach collection="pids" item="pid" open="(" separator="," close=")">
@@ -596,6 +634,7 @@
         select
         a.id,
         a.age_unit,
+        a.age_unit2,
         a.patid_his,
         a.sd_flag,
         a.patientno,
@@ -614,6 +653,7 @@
         a.idcardno,
         a.birthdate,
         a.age,
+        a.age2,
         a.viptype,
         a.sourcefrom,
         a.archivetime,
@@ -680,6 +720,7 @@
         select
         a.id,
         a.age_unit,
+        a.age_unit2,
         a.name,
         a.notrequired_flag,
         a.notrequiredreason,
@@ -699,6 +740,7 @@
         a.idcardno,
         a.birthdate,
         a.age,
+        a.age2,
         a.sourcefrom,
         a.archivetime,
         a.archiveby,
@@ -766,6 +808,7 @@
         distinct a.idcardno,
         a.id,
         a.age_unit,
+        a.age_unit2,
         a.inhospno,
         a.notrequired_flag,
         a.notrequiredreason,
@@ -784,6 +827,7 @@
         a.birthplace,
         a.birthdate,
         a.age,
+        a.age2,
         a.sourcefrom,
         a.archivetime,
         a.archiveby,
@@ -885,6 +929,7 @@
         distinct a.idcardno,
         a.id,
         a.age_unit,
+        a.age_unit2,
         a.patid_his,
         a.sd_flag,
         a.patientno,
@@ -902,6 +947,7 @@
         a.birthplace,
         a.birthdate,
         a.age,
+        a.age2,
         a.viptype,
         a.sourcefrom,
         a.archivetime,
@@ -969,6 +1015,7 @@
         distinct a.idcardno,
         a.id,
         a.age_unit,
+        a.age_unit2,
         a.name,
         a.notrequired_flag,
         a.notrequiredreason,
@@ -987,6 +1034,7 @@
         a.viptype,
         a.birthdate,
         a.age,
+        a.age2,
         a.sourcefrom,
         a.archivetime,
         a.archiveby,
diff --git a/smartor/src/main/resources/mapper/smartor/PatArchivecontactMapper.xml b/smartor/src/main/resources/mapper/smartor/PatArchivecontactMapper.xml
index 9b82638..e2d6121 100644
--- a/smartor/src/main/resources/mapper/smartor/PatArchivecontactMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatArchivecontactMapper.xml
@@ -1,56 +1,78 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.smartor.mapper.PatArchivecontactMapper">
-    
+
     <resultMap type="com.smartor.domain.PatArchivecontact" id="PatArchivecontactResult">
-        <result property="id"    column="id"    />
-        <result property="patid"    column="patid"    />
-        <result property="contactway"    column="contactway"    />
-        <result property="relation"    column="relation"    />
-        <result property="datasource"    column="datasource"    />
-        <result property="isdefault"    column="isdefault"    />
-        <result property="orgid"    column="orgid"    />
-        <result property="delFlag"    column="del_flag"    />
-        <result property="updateBy"    column="update_by"    />
-        <result property="updateTime"    column="update_time"    />
-        <result property="createBy"    column="create_by"    />
-        <result property="createTime"    column="create_time"    />
-        <result property="isupload"    column="isupload"    />
-        <result property="uploadTime"    column="upload_time"    />
-        <result property="contactname"    column="contactname"    />
-        <result property="pid"    column="pid"    />
-        <result property="guid"    column="guid"    />
+        <result property="id" column="id"/>
+        <result property="patid" column="patid"/>
+        <result property="contactway" column="contactway"/>
+        <result property="relation" column="relation"/>
+        <result property="datasource" column="datasource"/>
+        <result property="isdefault" column="isdefault"/>
+        <result property="orgid" column="orgid"/>
+        <result property="delFlag" column="del_flag"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="isupload" column="isupload"/>
+        <result property="uploadTime" column="upload_time"/>
+        <result property="contactname" column="contactname"/>
+        <result property="pid" column="pid"/>
+        <result property="guid" column="guid"/>
     </resultMap>
 
     <sql id="selectPatArchivecontactVo">
-        select id, patid, contactway, relation, datasource, isdefault, orgid, del_flag, update_by, update_time, create_by, create_time, isupload, upload_time, contactname, pid, guid from pat_archivecontact
+        select id,
+               patid,
+               contactway,
+               relation,
+               datasource,
+               isdefault,
+               orgid,
+               del_flag,
+               update_by,
+               update_time,
+               create_by,
+               create_time,
+               isupload,
+               upload_time,
+               contactname,
+               pid,
+               guid
+        from pat_archivecontact
     </sql>
 
-    <select id="selectPatArchivecontactList" parameterType="com.smartor.domain.PatArchivecontact" resultMap="PatArchivecontactResult">
+    <select id="selectPatArchivecontactList" parameterType="com.smartor.domain.PatArchivecontact"
+            resultMap="PatArchivecontactResult">
         <include refid="selectPatArchivecontactVo"/>
-        <where>  
-            <if test="patid != null "> and patid = #{patid}</if>
-            <if test="contactway != null  and contactway != ''"> and contactway = #{contactway}</if>
-            <if test="relation != null "> and relation = #{relation}</if>
-            <if test="datasource != null "> and datasource = #{datasource}</if>
-            <if test="isdefault != null "> and isdefault = #{isdefault}</if>
-            <if test="orgid != null  and orgid != ''"> and orgid = #{orgid}</if>
-            <if test="isupload != null "> and isupload = #{isupload}</if>
-            <if test="uploadTime != null "> and upload_time = #{uploadTime}</if>
-            <if test="contactname != null  and contactname != ''"> and contactname like concat('%', #{contactname}, '%')</if>
-            <if test="pid != null "> and pid = #{pid}</if>
-            <if test="guid != null  and guid != ''"> and guid = #{guid}</if>
+        <where>
+            del_flag=0
+            <if test="patid != null ">and patid = #{patid}</if>
+            <if test="contactway != null  and contactway != ''">and contactway = #{contactway}</if>
+            <if test="relation != null ">and relation = #{relation}</if>
+            <if test="datasource != null ">and datasource = #{datasource}</if>
+            <if test="isdefault != null ">and isdefault = #{isdefault}</if>
+            <if test="orgid != null  and orgid != ''">and orgid = #{orgid}</if>
+            <if test="isupload != null ">and isupload = #{isupload}</if>
+            <if test="uploadTime != null ">and upload_time = #{uploadTime}</if>
+            <if test="contactname != null  and contactname != ''">and contactname like concat('%', #{contactname},
+                '%')
+            </if>
+            <if test="pid != null ">and pid = #{pid}</if>
+            <if test="guid != null  and guid != ''">and guid = #{guid}</if>
         </where>
     </select>
-    
+
     <select id="selectPatArchivecontactById" parameterType="Long" resultMap="PatArchivecontactResult">
         <include refid="selectPatArchivecontactVo"/>
         where id = #{id}
     </select>
-        
-    <insert id="insertPatArchivecontact" parameterType="com.smartor.domain.PatArchivecontact" useGeneratedKeys="true" keyProperty="id">
+
+    <insert id="insertPatArchivecontact" parameterType="com.smartor.domain.PatArchivecontact" useGeneratedKeys="true"
+            keyProperty="id">
         insert into pat_archivecontact
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="patid != null">patid,</if>
@@ -69,7 +91,7 @@
             <if test="contactname != null">contactname,</if>
             <if test="pid != null">pid,</if>
             <if test="guid != null">guid,</if>
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="patid != null">#{patid},</if>
             <if test="contactway != null">#{contactway},</if>
@@ -87,7 +109,7 @@
             <if test="contactname != null">#{contactname},</if>
             <if test="pid != null">#{pid},</if>
             <if test="guid != null">#{guid},</if>
-         </trim>
+        </trim>
     </insert>
 
     <update id="updatePatArchivecontact" parameterType="com.smartor.domain.PatArchivecontact">
@@ -113,14 +135,18 @@
         where id = #{id}
     </update>
 
-    <delete id="deletePatArchivecontactById" parameterType="Long">
-        delete from pat_archivecontact where id = #{id}
-    </delete>
+    <update id="deletePatArchivecontactById" parameterType="Long">
+        update pat_archivecontact
+        <trim prefix="SET" suffixOverrides=",">
+            del_flag =1
+        </trim>
+        where id = #{id}
+    </update>
 
-    <delete id="deletePatArchivecontactByIds" parameterType="String">
-        delete from pat_archivecontact where id in 
+    <update id="deletePatArchivecontactByIds" parameterType="String">
+        update pat_archivecontact set del_flag =1 where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
-    </delete>
-</mapper>
\ No newline at end of file
+    </update>
+</mapper>
diff --git a/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml b/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
index 9a114e5..963bbe2 100644
--- a/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
@@ -189,18 +189,18 @@
             AND b.del_flag = 0
             AND a.idcardno IS NOT NULL
             <if test="startOutHospTime != null">
-                AND TO_DATE(b.endtime,'YYYY-MM-DD') &gt;= TO_DATE(#{startOutHospTime},'YYYY-MM-DD')
+                AND STR_TO_DATE(b.endtime,'%Y-%m-%d') &gt;= STR_TO_DATE(#{startOutHospTime},'%Y-%m-%d')
             </if>
             <if test="endOutHospTime != null">
-                AND TO_DATE(b.endtime,'YYYY-MM-DD') &lt;= TO_DATE(#{endOutHospTime},'YYYY-MM-DD')
+                AND STR_TO_DATE(b.endtime,'%Y-%m-%d') &lt;= STR_TO_DATE(#{endOutHospTime},'%Y-%m-%d')
             </if>
             <if test="tagname != null  and tagname != ''">and c.tagname like concat('%', #{tagname}, '%')</if>
 
             <if test="startInHospTime != null">
-                AND TO_DATE(b.starttime, 'YYYY-MM-DD') >= TO_DATE(#{startInHospTime}, 'YYYY-MM-DD')
+                AND STR_TO_DATE(b.starttime, '%Y-%m-%d') >= STR_TO_DATE(#{startInHospTime}, '%Y-%m-%d')
             </if>
             <if test="endInHospTime != null">
-                AND TO_DATE(b.starttime, 'YYYY-MM-DD') &lt;= TO_DATE(#{startInHospTime}, 'YYYY-MM-DD')
+                AND STR_TO_DATE(b.starttime, '%Y-%m-%d') &lt;= STR_TO_DATE(#{startInHospTime}, '%Y-%m-%d')
             </if>
             <if test="hospitalname != null  and hospitalname != ''">and hospitalname like concat('%', #{hospitalname},
                 '%')

--
Gitblit v1.9.3