Browse Source

Merge branch 'dev' of chenweida/patient-co-management into dev

chenweida 7 years ago
parent
commit
3be55fe9e7

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

@ -0,0 +1,500 @@
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());
            zyIvDiagnoseDictDao.save(zyIvDiagnoseDicts);
        }
        logger.info("synchronized zy_iv_diagnose_dict end");
    }
    @Transactional
    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());
            zyIvSubjectClassDictDao.save(zyIvSubjectClassDicts);
            logger.info("synchronized zy_iv_subject_class_dict end");
        }
    }
    @Transactional
    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());
            zyIvStaffRegTypeAllotDictDao.save(zyIvStaffRegTypeAllotDicts);
            logger.info("synchronized zy_iv_staff_reg_type_allot_dict end");
        }
    }
    @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");
        }
    }
    @Transactional
    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());
            zyIvPhysicDictDao.save(zyIvPhysicDicts);
            logger.info("synchronized zy_iv_physic_dict end");
        }
    }
    @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());
            zyIvOrgPhysicAllotDictDao.save(zyIvOrgPhysicAllotDicts);
        }
        logger.info("synchronized zy_iv_org_physic_allot_dict end");
    }
    @Transactional
    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());
            zyIvDiagnoseClassDictDao.save(zIvDiagnoseClassDicts);
        }
        logger.info("synchronized zy_iv_diagnose_class_dict end");
    }
    @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());
            zyIvDeptStaffAllotDictDao.save(syIvDeptStaffAllotDictz);
        }
        logger.info("synchronized zy_iv_dept_staff_allot_dict end");
    }
    @Transactional
    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());
                zyCommonDictDao.save(zyCommonDictz);
            }
        }
        logger.info("synchronized zy_common_dict end");
    }
    @Transactional
    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());
            zyIvDeptDictDao.save(zyIvDeptDicts);
        }
        logger.info("synchronized zy_iv_dept_dict end");
    }
    /**
     * 得到单个字典
     *
     * @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();
        }
    }
}

+ 22 - 512
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/web/ZyDictController.java

@ -1,30 +1,17 @@
package com.yihu.wlyy.web;
import com.yihu.wlyy.entity.zydict.*;
import com.yihu.wlyy.repository.zydict.*;
import com.yihu.wlyy.service.third.jw.JwPrescriptionService;
import com.yihu.wlyy.service.third.jw.ZyDictService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
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.
 */
@ -32,31 +19,10 @@ import java.util.regex.Pattern;
@RequestMapping(value = "/zydict/")
@Api(description = "同步智业字典")
public class ZyDictController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(ZyDictController.class);
    @Autowired
    private ZyCommonDictDao zyCommonDictDao;
    @Autowired
    private ZyIvDeptDictDao zyIvDeptDictDao;
    @Autowired
    private ZyIvDeptStaffAllotDictDao zyIvDeptStaffAllotDictDao;
    @Autowired
    private ZyIvDiagnoseClassDictDao zyIvDiagnoseClassDictDao;
    @Autowired
    private ZyIvDiagnoseDictDao zyIvDiagnoseDictDao;
    @Autowired
    private ZyIvOrgPhysicAllotDictDao zyIvOrgPhysicAllotDictDao;
    @Autowired
    private ZyIvPhysicDictDao zyIvPhysicDictDao;
    @Autowired
    private ZyIvStaffDictDao zyIvStaffDictDao;
    @Autowired
    private ZyIvStaffRegTypeAllotDictDao zyIvStaffRegTypeAllotDictDao;
    @Autowired
    private ZyIvSubjectClassDictDao zyIvSubjectClassDictDao;
    @Autowired
    private JwPrescriptionService jwPrescriptionService;
    private ZyDictService zyDictService;
    @ApiOperation("同步智业字典")
@ -64,36 +30,36 @@ public class ZyDictController extends BaseController {
    public String synchronousDict(
            @ApiParam(name = "dictName", value = "字典名称", defaultValue = "") @RequestParam(value = "dictName", required = true) String dictName) {
        try {
            if (TableName.zy_common_dict.getDict().equals(dictName)) {
            if (ZyDictService.TableName.zy_common_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_common_dict");
                synchronizeZyCommonDict();
            } else if (TableName.zy_iv_dept_dict.getDict().equals(dictName)) {
                zyDictService.synchronizeZyCommonDict();
            } else if (ZyDictService.TableName.zy_iv_dept_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_dept_dict");
                synchronizeZy_iv_dept_dict();
            } else if (TableName.zy_iv_dept_staff_allot_dict.getDict().equals(dictName)) {
                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");
                synchronizeZy_iv_dept_staff_allot_dict();
            } else if (TableName.zy_iv_diagnose_dict.getDict().equals(dictName)) {
                zyDictService.synchronizeZy_iv_dept_staff_allot_dict();
            } else if (ZyDictService.TableName.zy_iv_diagnose_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_diagnose_dict");
                synchronizeZy_iv_diagnose_dict();
            } else if (TableName.zy_iv_diagnose_class_dict.getDict().equals(dictName)) {
                zyDictService.synchronizeZy_iv_diagnose_dict();
            } else if (ZyDictService.TableName.zy_iv_diagnose_class_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_diagnose_class_dict");
                synchronizeZy_iv_diagnose_class_dict();
            } else if (TableName.zy_iv_org_physic_allot_dict.getDict().equals(dictName)) {
                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");
                synchronizeZy_iv_org_physic_allot_dict();
            } else if (TableName.zy_iv_physic_dict.getDict().equals(dictName)) {
                zyDictService.synchronizeZy_iv_org_physic_allot_dict();
            } else if (ZyDictService.TableName.zy_iv_physic_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_physic_dict");
                synchronizeZy_iv_physic_dict();
            } else if (TableName.zy_iv_staff_dict.getDict().equals(dictName)) {
                zyDictService.synchronizeZy_iv_physic_dict();
            } else if (ZyDictService.TableName.zy_iv_staff_dict.getDict().equals(dictName)) {
                logger.info("同步 zy_iv_staff_dict");
                synchronizeZ_iv_staff_dict();  //birthday    Date(529084800000+0800) 无法解析
            } else if (TableName.zy_iv_staff_reg_type_allot_dict.getDict().equals(dictName)) {
                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");
                synchronizeZy_iv_staff_reg_type_allot_dict();
            } else if (TableName.zy_iv_subject_class_dict.getDict().equals(dictName)) {
                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");
                synchronizeZy_iv_subject_class_dict();
                zyDictService.synchronizeZy_iv_subject_class_dict();
            }
            return success("同步成功");
        } catch (Exception e) {
@ -102,461 +68,5 @@ public class ZyDictController extends BaseController {
        }
    }
    private 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());
            zyIvDiagnoseDictDao.save(zyIvDiagnoseDicts);
        }
        logger.info("synchronized zy_iv_diagnose_dict end");
    }
    @Transactional
    private 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());
            zyIvSubjectClassDictDao.save(zyIvSubjectClassDicts);
            logger.info("synchronized zy_iv_subject_class_dict end");
        }
    }
    @Transactional
    private 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());
            zyIvStaffRegTypeAllotDictDao.save(zyIvStaffRegTypeAllotDicts);
            logger.info("synchronized zy_iv_staff_reg_type_allot_dict end");
        }
    }
    @Transactional
    private 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");
        }
    }
    @Transactional
    private 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());
            zyIvPhysicDictDao.save(zyIvPhysicDicts);
            logger.info("synchronized zy_iv_physic_dict end");
        }
    }
    @Transactional
    private 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());
            zyIvOrgPhysicAllotDictDao.save(zyIvOrgPhysicAllotDicts);
        }
        logger.info("synchronized zy_iv_org_physic_allot_dict end");
    }
    @Transactional
    private 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());
            zyIvDiagnoseClassDictDao.save(zIvDiagnoseClassDicts);
        }
        logger.info("synchronized zy_iv_diagnose_class_dict end");
    }
    @Transactional
    private 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());
            zyIvDeptStaffAllotDictDao.save(syIvDeptStaffAllotDictz);
        }
        logger.info("synchronized zy_iv_dept_staff_allot_dict end");
    }
    @Transactional
    private 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());
                zyCommonDictDao.save(zyCommonDictz);
            }
        }
        logger.info("synchronized zy_common_dict end");
    }
    @Transactional
    private 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());
            zyIvDeptDictDao.save(zyIvDeptDicts);
        }
        logger.info("synchronized zy_iv_dept_dict end");
    }
    /**
     * 得到单个字典
     *
     * @param clazz    class
     * @param dictName 字典名称
     */
    private 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;
        }
        private String name;
        private 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 {
        private 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();
        }
        private 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();
        }
        public static void main(String[] args) {
            String lineToHump = lineToHump("f_parent_no_leader");
            System.out.println(lineToHump);//fParentNoLeader
            System.out.println(humpToLine(lineToHump));//f_parent_no_leader
            System.out.println(humpToLine2(lineToHump));//f_parent_no_leader
        }
    }
}