Jelajahi Sumber

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

zd_123 7 tahun lalu
induk
melakukan
5c565a63de

+ 1 - 1
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/SignFamily.java

@ -50,7 +50,7 @@ public class SignFamily extends IdEntity {
    private String signType;//1 用户自己申请  2医生手工带签  3.医生发起邀请
    private String familyCode;//签约code
    private Double expenses;//签约费用
    private String expensesStatus;//扣费状态【0未扣费 1已扣费 2已退费】
    private String expensesStatus;//扣费状态【0未扣费 1已扣费 2已退费 3医保取消】
    private String signSource;// 签约来源【1 社区签约 2 移动签约】
    private String signDoctorCode;//簽約人code
    private String signDoctorName;//簽約人銘

+ 5 - 5
patient-co/patient-co-statistics/src/main/java/com/yihu/wlyy/statistics/service/JobService.java

@ -164,7 +164,7 @@ public class JobService {
                params.put("yesterday", getYesterday(0 - i));
                if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
                    quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
                    Thread.sleep(30000L);
                    Thread.sleep(60000L);
                }
            }
        }
@ -206,7 +206,7 @@ public class JobService {
            params.put("yesterday", yesterday);
            if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
                quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
                Thread.sleep(30000L);
                Thread.sleep(60000L);
            }
        }
@ -252,7 +252,7 @@ public class JobService {
        params.put("yesterday", yesterday);
        if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
            quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
            Thread.sleep(30000L);
            Thread.sleep(60000L);
        }
    }
@ -283,7 +283,7 @@ public class JobService {
            params.put("yesterday", getYesterday(0 - i));
            if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
                quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
                Thread.sleep(30000L);
                Thread.sleep(60000L);
            }
        }
    }
@ -418,7 +418,7 @@ public class JobService {
        params.put("now", yesterday);
        params.put("yesterday", day);
        quartzHelper.startNow(HealthMessageJob.class, HealthMessageJob.jobKey + UUID.randomUUID().toString().replace("-", ""), params);
        Thread.sleep(30000L);
        Thread.sleep(60000L);
    }
    public void productHealthDataByDayToDay(String start, String end) throws Exception {

+ 2 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/config/SwaggerConfig.java

@ -101,7 +101,8 @@ public class SwaggerConfig {
                        regex("/login/.*"),
                        regex("/qrcode/.*"),
                        regex("/onepay/.*"),
                        regex("/wlyy_service/.*")
                        regex("/wlyy_service/.*"),
                        regex("/zydict/.*")
                ))
                .build()
                .apiInfo(otherApiInfo());

+ 1 - 1
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/event/ApplicationEvent.java

@ -84,7 +84,7 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
            //同步智业字典 每晚1点同步
            if (!quartzHelper.isExistJob("zy_dict_job")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("zy_dict_job");
                quartzHelper.addJob(ZyDictJob.class, trigger, "zy_dict_job", new HashMap<String, Object>());
               // quartzHelper.addJob(ZyDictJob.class, trigger, "zy_dict_job", new HashMap<String, Object>());
                logger.info("zy_dict_job job success");
            } else {
                logger.info("zy_dict_job job exist");

+ 610 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/service/third/jw/ZyDictService.java

@ -0,0 +1,610 @@
package com.yihu.wlyy.service.third.jw;
import com.yihu.wlyy.entity.zydict.*;
import com.yihu.wlyy.repository.zydict.*;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * Created by chenweida on 2017/9/30.
 */
@Service
public class ZyDictService {
    public Logger logger = LoggerFactory.getLogger(ZyDictService.class);
    @Autowired
    public ZyCommonDictDao zyCommonDictDao;
    @Autowired
    public ZyIvDeptDictDao zyIvDeptDictDao;
    @Autowired
    public ZyIvDeptStaffAllotDictDao zyIvDeptStaffAllotDictDao;
    @Autowired
    public ZyIvDiagnoseClassDictDao zyIvDiagnoseClassDictDao;
    @Autowired
    public ZyIvDiagnoseDictDao zyIvDiagnoseDictDao;
    @Autowired
    public ZyIvOrgPhysicAllotDictDao zyIvOrgPhysicAllotDictDao;
    @Autowired
    public ZyIvPhysicDictDao zyIvPhysicDictDao;
    @Autowired
    public ZyIvStaffDictDao zyIvStaffDictDao;
    @Autowired
    public ZyIvStaffRegTypeAllotDictDao zyIvStaffRegTypeAllotDictDao;
    @Autowired
    public ZyIvSubjectClassDictDao zyIvSubjectClassDictDao;
    @Autowired
    public JwPrescriptionService jwPrescriptionService;
    public void synchronizeZy_iv_diagnose_dict() {
        logger.info("synchronized zy_iv_diagnose_dict start");
        String dictName = this.IV_DIAGNOSE_DICT;
        List<ZyIvDiagnoseDict> zyIvDiagnoseDicts = new ArrayList<>();
        //得到list
        zyIvDiagnoseDicts = commonGetOneDict(ZyIvDiagnoseDict.class, dictName);
        if (zyIvDiagnoseDicts != null && zyIvDiagnoseDicts.size() > 0) {
            //清空表
            zyIvDiagnoseDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_diagnose_dict  ,size:" + zyIvDiagnoseDicts.size());
            List<ZyIvDiagnoseDict> zyIvDiagnoseDictTemp = new ArrayList<>();
            for (int i = 0; i < zyIvDiagnoseDicts.size(); i++) {
                zyIvDiagnoseDictTemp.add(zyIvDiagnoseDicts.get(i));
                //批量提交
                if (((zyIvDiagnoseDictTemp.size() % 2000) == 0) || (zyIvDiagnoseDictTemp.size() == i)) {
                    saveZy_iv_diagnose_dict(zyIvDiagnoseDictTemp);
                    zyIvDiagnoseDictTemp = new ArrayList<>();
                }
            }
        }
        logger.info("synchronized zy_iv_diagnose_dict end");
    }
    @Transactional
    private void saveZy_iv_diagnose_dict(List<ZyIvDiagnoseDict> zyIvDiagnoseDictTemp) {
        zyIvDiagnoseDictDao.save(zyIvDiagnoseDictTemp);
    }
    public void synchronizeZy_iv_subject_class_dict() {
        logger.info("synchronized zy_iv_subject_class_dict start");
        String dictName = this.IV_SUBJECT_CLASS_DICT;
        List<ZyIvSubjectClassDict> zyIvSubjectClassDicts = new ArrayList<>();
        //得到list
        zyIvSubjectClassDicts = commonGetOneDict(ZyIvSubjectClassDict.class, dictName);
        if (zyIvSubjectClassDicts.size() > 0) {
            //清空表
            zyIvSubjectClassDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_subject_class_dict  ,size:" + zyIvSubjectClassDicts.size());
            List<ZyIvSubjectClassDict> zyIvSubjectClassDictTemp = new ArrayList<>();
            for (int i = 0; i < zyIvSubjectClassDicts.size(); i++) {
                zyIvSubjectClassDictTemp.add(zyIvSubjectClassDicts.get(i));
                //批量提交
                if (((zyIvSubjectClassDictTemp.size() % 2000) == 0) || (zyIvSubjectClassDictTemp.size() == i)) {
                    saveZy_iv_subject_class_dict(zyIvSubjectClassDictTemp);
                    zyIvSubjectClassDictTemp = new ArrayList<>();
                }
            }
            logger.info("synchronized zy_iv_subject_class_dict end");
        }
    }
    @Transactional
    private void saveZy_iv_subject_class_dict(List<ZyIvSubjectClassDict> zyIvSubjectClassDictTemp) {
        zyIvSubjectClassDictDao.save(zyIvSubjectClassDictTemp);
    }
    public void synchronizeZy_iv_staff_reg_type_allot_dict() {
        logger.info("synchronized zy_iv_staff_reg_type_allot_dict start");
        String dictName = this.IV_STAFF_REG_TYPE_ALLOT_DICT;
        List<ZyIvStaffRegTypeAllotDict> zyIvStaffRegTypeAllotDicts = new ArrayList<>();
        //得到list
        zyIvStaffRegTypeAllotDicts = commonGetOneDict(ZyIvStaffRegTypeAllotDict.class, dictName);
        if (zyIvStaffRegTypeAllotDicts != null && zyIvStaffRegTypeAllotDicts.size() > 0) {
            //清空表
            zyIvStaffRegTypeAllotDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_staff_reg_type_allot_dict  ,size:" + zyIvStaffRegTypeAllotDicts.size());
            List<ZyIvStaffRegTypeAllotDict> zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
            for (int i = 0; i < zyIvStaffRegTypeAllotDicts.size(); i++) {
                zyIvStaffRegTypeAllotDictTemp.add(zyIvStaffRegTypeAllotDicts.get(i));
                //批量提交
                if (((zyIvStaffRegTypeAllotDictTemp.size() % 2000) == 0) || (zyIvStaffRegTypeAllotDictTemp.size() == i)) {
                    saveZy_iv_staff_reg_type_allot_dict(zyIvStaffRegTypeAllotDictTemp);
                    zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
                }
            }
            logger.info("synchronized zy_iv_staff_reg_type_allot_dict end");
        }
    }
    @Transactional
    private void saveZy_iv_staff_reg_type_allot_dict(List<ZyIvStaffRegTypeAllotDict> zyIvStaffRegTypeAllotDictTemp) {
        zyIvStaffRegTypeAllotDictDao.save(zyIvStaffRegTypeAllotDictTemp);
    }
    @Transactional
    public void synchronizeZ_iv_staff_dict() {
        logger.info("synchronized zy_iv_staff_dict start");
        String dictName = this.IV_STAFF_DICT;
        List<ZyIvStaffDict> zyIvStaffDicts = new ArrayList<>();
        //得到list
        zyIvStaffDicts = commonGetOneDict(ZyIvStaffDict.class, dictName);
        //清空表
        if (zyIvStaffDicts != null && zyIvStaffDicts.size() > 0) {
            zyIvStaffDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_staff_dict  ,size:" + zyIvStaffDicts.size());
            zyIvStaffDictDao.save(zyIvStaffDicts);
            logger.info("synchronized zy_iv_staff_dict end");
        }
    }
    public void synchronizeZy_iv_physic_dict() {
        logger.info("synchronized zy_iv_physic_dict start");
        String dictName = this.IV_PHYSIC_DICT;
        List<ZyIvPhysicDict> zyIvPhysicDicts = new ArrayList<>();
        //得到list
        zyIvPhysicDicts = commonGetOneDict(ZyIvPhysicDict.class, dictName);
        if (zyIvPhysicDicts != null && zyIvPhysicDicts.size() > 0) {
            //清空表
            zyIvPhysicDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_physic_dict  ,size:" + zyIvPhysicDicts.size());
            List<ZyIvPhysicDict> zyIvPhysicDictsTemp = new ArrayList<>();
            for (int i = 0; i < zyIvPhysicDicts.size(); i++) {
                zyIvPhysicDictsTemp.add(zyIvPhysicDicts.get(i));
                //批量提交
                if (((zyIvPhysicDictsTemp.size() % 2000) == 0) || (zyIvPhysicDictsTemp.size() == i)) {
                    saveObPhysicDict(zyIvPhysicDictsTemp);
                    zyIvPhysicDictsTemp = new ArrayList<>();
                }
            }
            logger.info("synchronized zy_iv_physic_dict end");
        }
    }
    @Transactional
    private void saveObPhysicDict(List<ZyIvPhysicDict> zyIvPhysicDictsTemp) {
        zyIvPhysicDictDao.save(zyIvPhysicDictsTemp);
    }
    @Transactional
    public void synchronizeZy_iv_org_physic_allot_dict() {
        logger.info("synchronized zy_iv_org_physic_allot_dict start");
        String dictName = this.IV_ORG_PHYSIC_ALLOT_DICT;
        List<ZyIvOrgPhysicAllotDict> zyIvOrgPhysicAllotDicts = new ArrayList<>();
        //得到list
        zyIvOrgPhysicAllotDicts = commonGetOneDict(ZyIvOrgPhysicAllotDict.class, dictName);
        if (zyIvOrgPhysicAllotDicts != null && zyIvOrgPhysicAllotDicts.size() > 0) {
            //清空表
            zyIvOrgPhysicAllotDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_org_physic_allot_dict  ,size:" + zyIvOrgPhysicAllotDicts.size());
            List<ZyIvOrgPhysicAllotDict> zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
            for (int i = 0; i < zyIvOrgPhysicAllotDicts.size(); i++) {
                zyIvStaffRegTypeAllotDictTemp.add(zyIvOrgPhysicAllotDicts.get(i));
                //批量提交
                if (((zyIvStaffRegTypeAllotDictTemp.size() % 2000) == 0) || (zyIvStaffRegTypeAllotDictTemp.size() == i)) {
                    saveZy_iv_org_physic_allot_dict(zyIvStaffRegTypeAllotDictTemp);
                    zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
                }
            }
            logger.info("synchronized zy_iv_org_physic_allot_dict end");
        }
    }
    @Transactional
    private void saveZy_iv_org_physic_allot_dict(List<ZyIvOrgPhysicAllotDict> zyIvOrgPhysicAllotDicts) {
        zyIvOrgPhysicAllotDictDao.save(zyIvOrgPhysicAllotDicts);
    }
    public void synchronizeZy_iv_diagnose_class_dict() {
        logger.info("synchronized zy_iv_diagnose_class_dict start");
        String dictName = this.IV_DIAGNOSE_CLASS_DICT;
        List<ZyIvDiagnoseClassDict> zIvDiagnoseClassDicts = new ArrayList<>();
        //得到list
        zIvDiagnoseClassDicts = commonGetOneDict(ZyIvDiagnoseClassDict.class, dictName);
        if (zIvDiagnoseClassDicts != null && zIvDiagnoseClassDicts.size() > 0) {
            //清空表
            zyIvDiagnoseClassDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_diagnose_class_dict  ,size:" + zIvDiagnoseClassDicts.size());
            List<ZyIvDiagnoseClassDict> zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
            for (int i = 0; i < zIvDiagnoseClassDicts.size(); i++) {
                zyIvStaffRegTypeAllotDictTemp.add(zIvDiagnoseClassDicts.get(i));
                //批量提交
                if (((zyIvStaffRegTypeAllotDictTemp.size() % 2000) == 0) || (zyIvStaffRegTypeAllotDictTemp.size() == i)) {
                    saveZy_iv_diagnose_class_dict(zyIvStaffRegTypeAllotDictTemp);
                    zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
                }
            }
            logger.info("synchronized zy_iv_diagnose_class_dict end");
        }
    }
    @Transactional
    private void saveZy_iv_diagnose_class_dict(List<ZyIvDiagnoseClassDict> zIvDiagnoseClassDicts) {
        zyIvDiagnoseClassDictDao.save(zIvDiagnoseClassDicts);
    }
    @Transactional
    public void synchronizeZy_iv_dept_staff_allot_dict() {
        logger.info("synchronized zy_iv_dept_staff_allot_dict start");
        String dictName = this.IV_DEPT_STAFF_ALLOT_DICT;
        List<ZyIvDeptStaffAllotDict> syIvDeptStaffAllotDictz = new ArrayList<>();
        //得到list
        syIvDeptStaffAllotDictz = commonGetOneDict(ZyIvDeptStaffAllotDict.class, dictName);
        if (syIvDeptStaffAllotDictz != null && syIvDeptStaffAllotDictz.size() > 0) {
            //清空表
            zyIvDeptStaffAllotDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_dept_staff_allot_dict  ,size:" + syIvDeptStaffAllotDictz.size());
            List<ZyIvDeptStaffAllotDict> zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
            for (int i = 0; i < syIvDeptStaffAllotDictz.size(); i++) {
                zyIvStaffRegTypeAllotDictTemp.add(syIvDeptStaffAllotDictz.get(i));
                //批量提交
                if (((zyIvStaffRegTypeAllotDictTemp.size() % 2000) == 0) || (zyIvStaffRegTypeAllotDictTemp.size() == i)) {
                    saveZy_iv_dept_staff_allot_dict(zyIvStaffRegTypeAllotDictTemp);
                    zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
                }
            }
            logger.info("synchronized zy_iv_dept_staff_allot_dict end");
        }
    }
    private void saveZy_iv_dept_staff_allot_dict(List<ZyIvDeptStaffAllotDict> syIvDeptStaffAllotDictz) {
        zyIvDeptStaffAllotDictDao.save(syIvDeptStaffAllotDictz);
    }
    public void synchronizeZyCommonDict() {
        logger.info("synchronized zy_common_dict start");
        String[] dictNames = new String[]{
                this.IV_PHYSIC_FORM_DICT, this.IV_PHYSIC_INJECT_PLACE_DICT, this.IV_PHYSIC_SKIN_TEST_DICT,
                this.IV_RATE_TYPE_DICT, this.IV_RECIPE_FREQUENCY_DICT, this.IV_RECIPE_USAGE_DICT,
                this.IV_SEX_DICT, this.IV_PHYSIC_TOXICOLOGY_TYPE_DICT, this.IV_MEASURE_UNIT_DICT,
                this.IV_DEPT_TYPE_DICT};
        List<ZyCommonDict> zyCommonDictz = new ArrayList<>();
        Boolean isFlush = true;
        for (String dictName : dictNames) {
            String json = null;
            try {
                //调用智业的接口得到字典
                json = jwPrescriptionService.getDictForI(dictName);
                JSONObject returnJson = JSONObject.fromObject(json);
                if (returnJson.getInt("status") != 200) {
                    throw new Exception("zy dict error status not 200");
                }
                if (returnJson.containsKey("data")) {
                    String dataString = returnJson.getString("data");
                    JSONArray dataJSONArray = JSONObject.fromObject(dataString).getJSONArray("returnData");
                    if (dataJSONArray.size() == 0) {
                        logger.info("zy dict data size " + dataJSONArray.size() + ",dictname:" + dictName);
                        continue;
                    }
                    //下划线转驼峰
                    JSONArray newJA = new JSONArray();
                    JSONArray jsonArrayTemp = dataJSONArray.getJSONArray(0);
                    logger.info("zy dict data size " + jsonArrayTemp.size() + ",dictname:" + dictName);
                    for (int i = 0; i < jsonArrayTemp.size(); i++) {
                        JSONObject jo = jsonArrayTemp.getJSONObject(i);
                        JSONObject newJO = new JSONObject();
                        jo.keySet().stream().forEach(key -> {
                            Object value = jo.get(key);
                            String newKey = Tool.lineToHump(key.toString());
                            newJO.put(newKey, value);
                        });
                        newJA.add(newJO);
                    }
                    ZyCommonDict[] zyCommonDictArrays = (ZyCommonDict[]) JSONArray.toArray(newJA, ZyCommonDict.class);
                    zyCommonDictz.addAll(Arrays.asList(zyCommonDictArrays));
                } else {
                    throw new Exception("zy dict error no contain data");
                }
            } catch (Exception e) {
                e.printStackTrace();
                isFlush = false; //设置状态不能更新
                logger.error("dictName:" + dictName);
                logger.error("returnJson:" + json);
                logger.error(e.getMessage());
            }
        }
        //判断是否可以更新
        if (isFlush) {
            // 判断返回的数据是否大于0
            if (zyCommonDictz.size() > 0) {
                //清空表
                zyCommonDictDao.deleteAll();
                //新增数据
                logger.info("save table zy_common_dict  ,size:" + zyCommonDictz.size());
                List<ZyCommonDict> zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
                for (int i = 0; i < zyCommonDictz.size(); i++) {
                    zyIvStaffRegTypeAllotDictTemp.add(zyCommonDictz.get(i));
                    //批量提交
                    if (((zyIvStaffRegTypeAllotDictTemp.size() % 2000) == 0) || (zyIvStaffRegTypeAllotDictTemp.size() == i)) {
                        saveZyCommonDict(zyIvStaffRegTypeAllotDictTemp);
                        zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
                    }
                }
                logger.info("synchronized zy_common_dict end");
            }
        }
    }
    @Transactional
    private void saveZyCommonDict(List<ZyCommonDict> zyCommonDictz) {
        zyCommonDictDao.save(zyCommonDictz);
    }
    public void synchronizeZy_iv_dept_dict() {
        logger.info("synchronized zy_iv_dept_dict start");
        String dictName = this.IV_DEPT_DICT;
        List<ZyIvDeptDict> zyIvDeptDicts = new ArrayList<>();
        //得到list
        zyIvDeptDicts = commonGetOneDict(ZyIvDeptDict.class, dictName);
        if (zyIvDeptDicts != null && zyIvDeptDicts.size() > 0) {
            //清空表
            zyIvDeptDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_dept_dict  ,size:" + zyIvDeptDicts.size());
            List<ZyIvDeptDict> zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
            for (int i = 0; i < zyIvDeptDicts.size(); i++) {
                zyIvStaffRegTypeAllotDictTemp.add(zyIvDeptDicts.get(i));
                //批量提交
                if (((zyIvStaffRegTypeAllotDictTemp.size() % 2000) == 0) || (zyIvStaffRegTypeAllotDictTemp.size() == i)) {
                    saveZy_iv_dept_dict(zyIvStaffRegTypeAllotDictTemp);
                    zyIvStaffRegTypeAllotDictTemp = new ArrayList<>();
                }
            }
            logger.info("synchronized zy_iv_dept_dict end");
        }
    }
    @Transactional
    private void saveZy_iv_dept_dict(List<ZyIvDeptDict> zyIvDeptDicts) {
        zyIvDeptDictDao.save(zyIvDeptDicts);
    }
    /**
     * 得到单个字典
     *
     * @param clazz    class
     * @param dictName 字典名称
     */
    public List commonGetOneDict(Class clazz, String dictName) {
        String json = null;
        try {
            //调用智业的接口得到字典
            json = jwPrescriptionService.getDictForI(dictName);
            JSONObject returnJson = JSONObject.fromObject(json);
            if (returnJson.getInt("status") != 200) {
                throw new Exception("zy dict error status not 200");
            }
            if (returnJson.containsKey("data")) {
                String dataJSONStr = returnJson.getString("data");
                JSONObject joTemp = JSONObject.fromObject(dataJSONStr);
                JSONArray dataJSONArray = joTemp.getJSONArray("returnData");
                if (dataJSONArray.size() == 0) {
                    logger.info("zy dict data size " + dataJSONArray.size() + ",dictname:" + dictName);
                    return null;
                } else {
                    dataJSONArray = dataJSONArray.getJSONArray(0);
                }
                logger.info("zy dict data size " + dataJSONArray.size() + ",dictname:" + dictName);
                //下划线转驼峰
                JSONArray newJA = new JSONArray();
                for (int i = 0; i < dataJSONArray.size(); i++) {
                    JSONObject jo = dataJSONArray.getJSONObject(i);
                    JSONObject newJO = new JSONObject();
                    jo.keySet().stream().forEach(key -> {
                        Object value = jo.get(key);
                        String newKey = Tool.lineToHump(key.toString());
                        newJO.put(newKey, value);
                    });
                    newJA.add(newJO);
                }
                return (List) JSONArray.toCollection(newJA, clazz);
            } else {
                throw new Exception("zy dict error no contain data");
            }
        } catch (Exception e) {
            logger.error("dictName:" + dictName);
            logger.error("returnJson:" + json);
            logger.error(e.getMessage());
        }
        return null;
    }
    /**
     * 智业的字典
     */
    public static final String IV_MEASURE_UNIT_DICT = "IV_MEASURE_UNIT_DICT";//("计量单位字典", "IV_MEASURE_UNIT_DICT"),
    public static final String IV_PHYSIC_FORM_DICT = "IV_PHYSIC_FORM_DICT";//("药品剂型字典", "IV_PHYSIC_FORM_DICT"),
    public static final String IV_PHYSIC_INJECT_PLACE_DICT = "IV_PHYSIC_INJECT_PLACE_DICT";//"计量单位字典", "IV_PHYSIC_INJECT_PLACE_DICT"),
    public static final String IV_PHYSIC_SKIN_TEST_DICT = "IV_PHYSIC_SKIN_TEST_DICT";//("皮试类型字典", "IV_PHYSIC_SKIN_TEST_DICT"),
    public static final String IV_RATE_TYPE_DICT = "IV_RATE_TYPE_DICT";//("费别字典", "IV_RATE_TYPE_DICT"),
    public static final String IV_RECIPE_FREQUENCY_DICT = "IV_RECIPE_FREQUENCY_DICT";//("频次字典", "IV_RECIPE_FREQUENCY_DICT"),
    public static final String IV_RECIPE_USAGE_DICT = "IV_RECIPE_USAGE_DICT";//("用药方法字典", "IV_RECIPE_USAGE_DICT"),
    public static final String IV_SEX_DICT = "IV_SEX_DICT";//("性别字典", "IV_SEX_DICT"),
    public static final String IV_PHYSIC_DICT = "IV_PHYSIC_DICT";//("药品字典", "IV_PHYSIC_DICT"),
    public static final String IV_ORG_PHYSIC_ALLOT_DICT = "IV_ORG_PHYSIC_ALLOT_DICT";//("机构药品分发字典", "IV_ORG_PHYSIC_ALLOT_DICT "),
    public static final String IV_SUBJECT_CLASS_DICT = "IV_SUBJECT_CLASS_DICT";//("科目类别字典", "IV_SUBJECT_CLASS_DICT"),
    public static final String IV_PHYSIC_TOXICOLOGY_TYPE_DICT = "IV_PHYSIC_TOXICOLOGY_TYPE_DICT";//("药品毒理分类字典", "IV_PHYSIC_TOXICOLOGY_TYPE_DICT"),
    public static final String IV_DEPT_DICT = "IV_DEPT_DICT";//("科室字典", "IV_DEPT_DICT"),
    public static final String IV_DEPT_TYPE_DICT = "IV_DEPT_TYPE_DICT";//("科室类型字典", "IV_DEPT_TYPE_DICT"),
    public static final String IV_DIAGNOSE_DICT = "IV_DIAGNOSE_DICT";//("诊断字典", "IV_DIAGNOSE_DICT"),
    public static final String IV_DIAGNOSE_CLASS_DICT = "IV_DIAGNOSE_CLASS_DICT";//("诊断类别字典", "IV_DIAGNOSE_CLASS_DICT"),
    public static final String IV_STAFF_DICT = "IV_STAFF_DICT";//("员工字典", "IV_STAFF_DICT"),
    public static final String IV_STAFF_REG_TYPE_ALLOT_DICT = "IV_STAFF_REG_TYPE_ALLOT_DICT";//("员工挂号类型配置字典", "IV_STAFF_REG_TYPE_ALLOT_DICT"),
    public static final String IV_DEPT_STAFF_ALLOT_DICT = "IV_DEPT_STAFF_ALLOT_DICT";//("科室员工配置字典", "IV_DEPT_STAFF_ALLOT_DICT");
    /**
     * 字典表的枚举类
     */
    public enum TableName {
        zy_common_dict("通用字典", "zy_common_dict"),
        zy_iv_dept_dict("科室字典", "zy_iv_dept_dict"),
        zy_iv_dept_staff_allot_dict("科室员工配置字典", "zy_iv_dept_staff_allot_dict"),
        zy_iv_diagnose_class_dict("诊断类别字典", "zy_iv_diagnose_class_dict"),
        zy_iv_diagnose_dict("诊断字典表", "zy_iv_diagnose_dict"),
        zy_iv_org_physic_allot_dict("机构药品分发字典", "zy_iv_org_physic_allot_dict"),
        zy_iv_physic_dict("药品字典", "zy_iv_physic_dict"),
        zy_iv_staff_dict("员工字典", "zy_iv_staff_dict"),
        zy_iv_staff_reg_type_allot_dict("员工挂号类型配置字典", "zy_iv_staff_reg_type_allot_dict"),
        zy_iv_subject_class_dict("科目类别字典", "zy_iv_subject_class_dict");
        TableName(String name, String dict) {
            this.name = name;
            this.dict = dict;
        }
        public String name;
        public String dict;
        public String getName() {
            return name;
        }
        public void setName(String name) {
            this.name = name;
        }
        public String getDict() {
            return dict;
        }
        public void setDict(String dict) {
            this.dict = dict;
        }
    }
    /**
     * 根据字典获取表名
     *
     * @param dictName
     * @return
     */
    public String getTableName(String dictName) {
        switch (dictName) {
            case IV_PHYSIC_FORM_DICT: {
                return TableName.zy_common_dict.getDict();
            }
            case IV_PHYSIC_INJECT_PLACE_DICT: {
                return TableName.zy_common_dict.getDict();
            }
            case IV_PHYSIC_SKIN_TEST_DICT: {
                return TableName.zy_common_dict.getDict();
            }
            case IV_RATE_TYPE_DICT: {
                return TableName.zy_common_dict.getDict();
            }
            case IV_RECIPE_FREQUENCY_DICT: {
                return TableName.zy_common_dict.getDict();
            }
            case IV_RECIPE_USAGE_DICT: {
                return TableName.zy_common_dict.getDict();
            }
            case IV_SEX_DICT: {
                return TableName.zy_common_dict.getDict();
            }
            case IV_PHYSIC_TOXICOLOGY_TYPE_DICT: {
                return TableName.zy_common_dict.getDict();
            }
            case IV_MEASURE_UNIT_DICT: {
                return TableName.zy_common_dict.getDict();
            }
            case IV_DEPT_TYPE_DICT: {
                return TableName.zy_common_dict.getDict();
            }
            case IV_PHYSIC_DICT: {
                return TableName.zy_iv_physic_dict.getDict();
            }
            case IV_ORG_PHYSIC_ALLOT_DICT: {
                return TableName.zy_iv_org_physic_allot_dict.getDict();
            }
            case IV_SUBJECT_CLASS_DICT: {
                return TableName.zy_iv_subject_class_dict.getDict();
            }
            case IV_DIAGNOSE_DICT: {
                return TableName.zy_iv_diagnose_dict.getDict();
            }
            case IV_DIAGNOSE_CLASS_DICT: {
                return TableName.zy_iv_diagnose_class_dict.getDict();
            }
            case IV_STAFF_DICT: {
                return TableName.zy_iv_staff_dict.getDict();
            }
            case IV_STAFF_REG_TYPE_ALLOT_DICT: {
                return TableName.zy_iv_staff_reg_type_allot_dict.getDict();
            }
            case IV_DEPT_STAFF_ALLOT_DICT: {
                return TableName.zy_iv_dept_staff_allot_dict.getDict();
            }
            case IV_DEPT_DICT: {
                return TableName.zy_iv_dept_dict.getDict();
            }
        }
        return "";
    }
    public static class Tool {
        public static Pattern linePattern = Pattern.compile("_(\\w)");
        /**
         * 下划线转驼峰
         */
        public static String lineToHump(String str) {
            str = str.toLowerCase();
            Matcher matcher = linePattern.matcher(str);
            StringBuffer sb = new StringBuffer();
            while (matcher.find()) {
                matcher.appendReplacement(sb, matcher.group(1).toUpperCase());
            }
            matcher.appendTail(sb);
            return sb.toString();
        }
        /**
         * 驼峰转下划线(简单写法,效率低于{@link #humpToLine2(String)})
         */
        public static String humpToLine(String str) {
            return str.replaceAll("[A-Z]", "_$0").toLowerCase();
        }
        public static Pattern humpPattern = Pattern.compile("[A-Z]");
        /**
         * 驼峰转下划线,效率比上面高
         */
        public static String humpToLine2(String str) {
            Matcher matcher = humpPattern.matcher(str);
            StringBuffer sb = new StringBuffer();
            while (matcher.find()) {
                matcher.appendReplacement(sb, "_" + matcher.group(0).toLowerCase());
            }
            matcher.appendTail(sb);
            return sb.toString();
        }
    }
}

+ 72 - 0
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/ZyDictController.java

@ -0,0 +1,72 @@
package com.yihu.wlyy.web;
import com.yihu.wlyy.service.third.jw.ZyDictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
/**
 * Created by chenweida on 2017/9/30.
 */
@Controller
@RequestMapping(value = "/zydict/")
@Api(description = "同步智业字典")
public class ZyDictController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(ZyDictController.class);
    @Autowired
    private ZyDictService zyDictService;
    @ApiOperation("同步智业字典")
    @RequestMapping(value = "/synchronousDict", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    public String synchronousDict(
            @ApiParam(name = "dictName", value = "字典名称", defaultValue = "") @RequestParam(value = "dictName", required = true) String dictName) {
        try {
            if (ZyDictService.TableName.zy_common_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_common_dict");
                zyDictService.synchronizeZyCommonDict();
            } else if (ZyDictService.TableName.zy_iv_dept_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_dept_dict");
                zyDictService.synchronizeZy_iv_dept_dict();
            } else if (ZyDictService.TableName.zy_iv_dept_staff_allot_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_dept_staff_allot_dict");
                zyDictService.synchronizeZy_iv_dept_staff_allot_dict();
            } else if (ZyDictService.TableName.zy_iv_diagnose_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_diagnose_dict");
                zyDictService.synchronizeZy_iv_diagnose_dict();
            } else if (ZyDictService.TableName.zy_iv_diagnose_class_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_diagnose_class_dict");
                zyDictService.synchronizeZy_iv_diagnose_class_dict();
            } else if (ZyDictService.TableName.zy_iv_org_physic_allot_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_org_physic_allot_dict");
                zyDictService.synchronizeZy_iv_org_physic_allot_dict();
            } else if (ZyDictService.TableName.zy_iv_physic_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_physic_dict");
                zyDictService.synchronizeZy_iv_physic_dict();
            } else if (ZyDictService.TableName.zy_iv_staff_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_staff_dict");
                zyDictService.synchronizeZ_iv_staff_dict();  //birthday    Date(529084800000+0800) 无法解析
            } else if (ZyDictService.TableName.zy_iv_staff_reg_type_allot_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_staff_reg_type_allot_dict");
                zyDictService.synchronizeZy_iv_staff_reg_type_allot_dict();
            } else if (ZyDictService.TableName.zy_iv_subject_class_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_subject_class_dict");
                zyDictService.synchronizeZy_iv_subject_class_dict();
            }
            return success("同步成功");
        } catch (Exception e) {
            logger.error(e.getMessage());
            return invalidUserException(e, -1, "同步失败");
        }
    }
}

+ 1 - 1
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignFamilyServiceService.java

@ -169,7 +169,7 @@ public class SignFamilyServiceService {
                "   wlyy_service_item s, " +
                "   wlyy_sign_family_service_item si " +
                " WHERE " +
                "   s.`code` = si.service_item_code and si.del=1 ");
                "   s.`code` = si.service_item_code and si.del=1 and s.del=1");
        if (!StringUtils.isEmpty(patient)) {
            sql.append(" and si.patient = '" + patient + "'");
        }