Parcourir la source

Merge remote-tracking branch 'origin/2.0' into 2.0

suqinyi il y a 3 mois
Parent
commit
6bc54f0025

+ 15 - 6
common/common-entity/src/db/2024.sql

@ -131,9 +131,6 @@ CREATE TABLE `wlyy_doctor_scheme_blood_sugger` (
) ENGINE=InnoDB AUTO_INCREMENT=113 DEFAULT CHARSET=utf8mb4 COMMENT='医生-血糖监测方案表';
INSERT INTO `base`.`oauth_wlyy_config`(`id`, `app_id`, `app_secret`, `token_url`, `url`, `remark`)
VALUES ('getChronicDiseaseData', '019bd04d-3cb2-433f-a530-03f0cdb083e5', '08cc3ec2-736b-4732-a8f0-f99eb6f9d311', 'https://ehr.yihu.com/wlyy/gc/accesstoken', 'https://ehr.yihu.com/wlyy/wlyygc/tongan/hospital/getChronicDiseaseData', '获取同安签约慢病数据');
CREATE TABLE `base_patient_doctor_relation` (
  `id` int NOT NULL AUTO_INCREMENT,
  `patient_id` varchar(100) DEFAULT NULL COMMENT '患者id',
@ -214,30 +211,42 @@ INSERT INTO `base`.`oauth_wlyy_config` (`id`, `app_id`, `app_secret`, `token_url
CREATE TABLE `wlyy_sign` (
   `id` int NOT NULL AUTO_INCREMENT,
   `patient` varchar(50) DEFAULT NULL,
   `idcard` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '身份证',
   `mobile` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '手机号',
   `ssc` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '社保卡',
   `sex` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '性别',
   `birthday` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '初生日期',
   `admin_team_id` int DEFAULT NULL COMMENT '签约团队',
   `name` varchar(50) DEFAULT NULL COMMENT '姓名',
   `address` varchar(50) DEFAULT NULL COMMENT '地址',
   `address` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '地址',
   `hospital_name` varchar(50) DEFAULT NULL COMMENT '签约社区',
   `doctor_name` varchar(50) DEFAULT NULL COMMENT '全科医生',
   `health_doctor_name` varchar(50) DEFAULT NULL COMMENT '健管师',
   `begin` varchar(10) DEFAULT NULL COMMENT '签约开始时间',
   `end` varchar(10) DEFAULT NULL COMMENT '签约结束时间',
   `sign_year` varchar(1) DEFAULT NULL COMMENT '签约年限',
   `sign_year` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '签约年度',
   `year_num` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '签约年限',
   `status` varchar(4) DEFAULT NULL COMMENT '状态',
   `sign_source` varchar(1) DEFAULT NULL COMMENT '签约类型',
   `disease_condition` varchar(5) DEFAULT NULL COMMENT '病情',
   `sys_time` varchar(30) DEFAULT NULL COMMENT '同步时间',
   `health_ijk` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT 'i健康健康情况',
   `disease_ijk` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT 'i健康疾病类型',
   `is_ncd` tinyint(1) DEFAULT NULL COMMENT '是否慢病 1是0否',
   `create_time` datetime DEFAULT NULL COMMENT '创建时间',
   PRIMARY KEY (`id`),
   UNIQUE KEY `index5` (`idcard`,`is_ncd`) USING BTREE,
   KEY `index2` (`admin_team_id`),
   KEY `index3` (`sys_time`),
   KEY `index4` (`hospital_name`,`doctor_name`,`health_doctor_name`),
   KEY `index1` (`patient`,`idcard`) USING BTREE
   KEY `index1` (`patient`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `wlyy_patient_aim_blood_pressure` (
      `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id主键,与业务逻辑无关',
      `code` varchar(50) NOT NULL COMMENT '业务主键UUID',

+ 76 - 67
svr/svr-internet-hospital-job/src/main/java/com/yihu/jw/service/channel/SyncWlyyHospitalService.java

@ -131,77 +131,86 @@ public class SyncWlyyHospitalService {
    //同步签约信息
    public void synSign(){
        try {
            String configId = "commonGet";
            String param = "?type=2";
            JSONObject re = wlyyHttpService.sendWlyyMesGet(configId, "findSignAll" + param);
            if(re!=null&&re.getInteger("status")==200){
                List<WlyySign> list = wlyySignDao.findAll();
                Map<String,WlyySign> signMap = list.stream().collect(Collectors.toMap(WlyySign::getIdcard, v -> v, (o1, o2) -> o1));
                List<WlyySign> signList = new ArrayList<>(list.size());
                JSONArray jsonArray = re.getJSONArray("data");
                if(jsonArray.size()>0){
                    String sysTime = DateUtil.getStringDate();
                    Date createTime = new Date();
                    for (int i=0;i<jsonArray.size();i++){
                        logger.info("i="+i);
                        JSONObject json = jsonArray.getJSONObject(i);
                        String idcard = json.getString("idcard");
                        WlyySign sign = signMap.get(idcard);
                        if(sign!=null){
                            sign.setStatus(json.getString("status"));
                            sign.setYearNum(json.getString("year_num"));
                            sign.setHospitalName(json.getString("hospital_name"));
                            sign.setDoctorName(json.getString("doctor_name"));
                            sign.setHealthDoctorName(json.getString("doctor_health_name"));
                            sign.setBegin(json.getString("begin"));
                            sign.setEnd(json.getString("end"));
                            sign.setSignYear(json.getString("sign_year"));
                            sign.setSignSource(json.getString("sign_source"));
                            sign.setDiseaseCondition(json.getString("disease_condition"));
                            sign.setAdminTeamId(json.getString("admin_team_id"));
                            sign.setSysTime(sysTime);
                        }else {
                            //新增
                            sign = new WlyySign();
                            sign.setIsNcd(0);
                            sign.setIdcard(json.getString("idcard"));
                            sign.setSsc(json.getString("ssc"));
                            sign.setSex(json.getString("sex"));
                            sign.setBirthday(json.getString("birthday"));
                            sign.setMobile(json.getString("mobile"));
                            sign.setName(json.getString("name"));
                            sign.setAddress(json.getString("address"));
                            sign.setSysTime(sysTime);
                            sign.setCreateTime(createTime);
                            sign.setStatus(json.getString("status"));
                            sign.setYearNum(json.getString("year_num"));
                            sign.setHospitalName(json.getString("hospital_name"));
                            sign.setDoctorName(json.getString("doctor_name"));
                            sign.setHealthDoctorName(json.getString("doctor_health_name"));
                            sign.setBegin(json.getString("begin"));
                            sign.setEnd(json.getString("end"));
                            sign.setSignYear(json.getString("sign_year"));
                            sign.setSignSource(json.getString("sign_source"));
                            sign.setDiseaseCondition(json.getString("disease_condition"));
                            sign.setAdminTeamId(json.getString("admin_team_id"));
            //查询所有数据量太大 接口返回容易失败,改成按社区查询
            String sql = "SELECT code from dm_hospital WHERE town='350212' and del=1 and LENGTH(code)=10";
            List<String> hospitalList = jdbcTemplate.queryForList(sql,String.class);
            List<WlyySign> list = wlyySignDao.findAll();
            Map<String,WlyySign> signMap = list.stream().collect(Collectors.toMap(WlyySign::getIdcard, v -> v, (o1, o2) -> o1));
            for (String code:hospitalList){
                try {
                    String configId = "commonGet";
                    String param = "?type=2&hospital="+code;
                    JSONObject re = wlyyHttpService.sendWlyyMesGet(configId, "findSignAll" + param);
                    if(re!=null&&re.getInteger("status")==200){
                        List<WlyySign> signList = new ArrayList<>(list.size());
                        JSONArray jsonArray = re.getJSONArray("data");
                        if(jsonArray.size()>0){
                            String sysTime = DateUtil.getStringDate();
                            Date createTime = new Date();
                            for (int i=0;i<jsonArray.size();i++){
                                logger.info("i="+i);
                                JSONObject json = jsonArray.getJSONObject(i);
                                String idcard = json.getString("idcard");
                                WlyySign sign = signMap.get(idcard);
                                if(sign!=null){
                                    sign.setStatus(json.getString("status"));
                                    sign.setYearNum(json.getString("year_num"));
                                    sign.setHospitalName(json.getString("hospital_name"));
                                    sign.setDoctorName(json.getString("doctor_name"));
                                    sign.setHealthDoctorName(json.getString("doctor_health_name"));
                                    sign.setBegin(json.getString("begin"));
                                    sign.setEnd(json.getString("end"));
                                    sign.setSignYear(json.getString("sign_year"));
                                    sign.setSignSource(json.getString("sign_source"));
                                    sign.setDiseaseCondition(json.getString("disease_condition"));
                                    sign.setAdminTeamId(json.getString("admin_team_id"));
                                    sign.setSysTime(sysTime);
                                }else {
                                    //新增
                                    sign = new WlyySign();
                                    sign.setIsNcd(0);
                                    sign.setIdcard(json.getString("idcard"));
                                    sign.setSsc(json.getString("ssc"));
                                    sign.setSex(json.getString("sex"));
                                    sign.setBirthday(json.getString("birthday"));
                                    sign.setMobile(json.getString("mobile"));
                                    sign.setName(json.getString("name"));
                                    sign.setAddress(json.getString("address"));
                                    sign.setSysTime(sysTime);
                                    sign.setCreateTime(createTime);
                                    sign.setStatus(json.getString("status"));
                                    sign.setYearNum(json.getString("year_num"));
                                    sign.setHospitalName(json.getString("hospital_name"));
                                    sign.setDoctorName(json.getString("doctor_name"));
                                    sign.setHealthDoctorName(json.getString("doctor_health_name"));
                                    sign.setBegin(json.getString("begin"));
                                    sign.setEnd(json.getString("end"));
                                    sign.setSignYear(json.getString("sign_year"));
                                    sign.setSignSource(json.getString("sign_source"));
                                    sign.setDiseaseCondition(json.getString("disease_condition"));
                                    sign.setAdminTeamId(json.getString("admin_team_id"));
                                }
                                signList.add(sign);
                            }
                            wlyySignDao.saveAll(signList);
                        }
                        signList.add(sign);
                        signList = null;
                    }
                    wlyySignDao.saveAll(signList);
                    //更新居民id
                    String updateSql1 = "UPDATE base_patient p,wlyy_sign s set s.patient=p.id WHERE p.idcard=s.idcard and p.del='1' and s.patient is null ";
                    jdbcTemplate.execute(updateSql1);
                    //更新病情
                    String updateSql2 = "UPDATE base_patient p,wlyy_sign s set p.disease_condition=s.disease_condition" +
                            " WHERE p.id=s.patient and p.del='1' ";
                    jdbcTemplate.execute(updateSql2);
                    re = null;
                }catch (Exception e){
                    e.printStackTrace();
                }
                list = null;
                signMap = null;
                signList = null;
            }
            re = null;
            //更新居民id
            String updateSql1 = "UPDATE base_patient p,wlyy_sign s set s.patient=p.id WHERE p.idcard=s.idcard and p.del='1' and s.patient is null ";
            jdbcTemplate.execute(updateSql1);
            //更新病情
            String updateSql2 = "UPDATE base_patient p,wlyy_sign s set p.disease_condition=s.disease_condition" +
                    " WHERE p.id=s.patient and p.del='1' ";
            jdbcTemplate.execute(updateSql2);
            list = null;
            signMap = null;
        }catch (Exception e){
            e.printStackTrace();
        }