浏览代码

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

chenweida 8 年之前
父节点
当前提交
28ef482e93

+ 98 - 10
patient-co/patient-co-wlyy-job/src/main/java/com/yihu/wlyy/job/ZyDictJob.java

@ -16,7 +16,8 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * Created by chenweida on 2017/8/10.
@ -87,6 +88,7 @@ public class ZyDictJob implements Job {
            //清空表
            zyIvDiagnoseDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_diagnose_dict  ,size:" + zyIvDiagnoseDicts.size());
            zyIvDiagnoseDictDao.save(zyIvDiagnoseDicts);
        }
        logger.info("synchronized zy_iv_diagnose_dict end");
@ -104,6 +106,7 @@ public class ZyDictJob implements Job {
            //清空表
            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");
        }
@ -116,10 +119,10 @@ public class ZyDictJob implements Job {
        List<ZyIvStaffRegTypeAllotDict> zyIvStaffRegTypeAllotDicts = new ArrayList<>();
        //得到list
        commonGetOneDict(zyIvStaffRegTypeAllotDicts, ZyIvStaffRegTypeAllotDict.class, dictName);
        //清空表
        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");
    }
@ -134,6 +137,7 @@ public class ZyDictJob implements Job {
        //清空表
        zyIvStaffDictDao.deleteAll();
        //新增数据
        logger.info("save table zy_iv_staff_dict  ,size:" + zyIvStaffDicts.size());
        zyIvStaffDictDao.save(zyIvStaffDicts);
        logger.info("synchronized zy_iv_staff_dict end");
    }
@ -145,10 +149,10 @@ public class ZyDictJob implements Job {
        List<ZyIvPhysicDict> zyIvPhysicDicts = new ArrayList<>();
        //得到list
        commonGetOneDict(zyIvPhysicDicts, ZyIvPhysicDict.class, dictName);
        //清空表
        zyIvPhysicDictDao.deleteAll();
        //新增数据
        logger.info("save table zy_iv_physic_dict  ,size:" + zyIvPhysicDicts.size());
        zyIvPhysicDictDao.save(zyIvPhysicDicts);
        logger.info("synchronized zy_iv_physic_dict end");
    }
@ -164,6 +168,7 @@ public class ZyDictJob implements Job {
            //清空表
            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");
@ -180,6 +185,8 @@ public class ZyDictJob implements Job {
            //清空表
            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");
@ -197,6 +204,7 @@ public class ZyDictJob implements Job {
            //清空表
            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");
@ -222,16 +230,34 @@ public class ZyDictJob implements Job {
                    throw new Exception("zy dict error status not 200");
                }
                if (returnJson.containsKey("data")) {
                    JSONArray dataJSONArray = returnJson.getJSONObject("data").getJSONArray("returnData");
                    String dataString = returnJson.getString("data");
                    JSONArray dataJSONArray = JSONObject.fromObject(dataString).getJSONArray("returnData");
                    logger.info("zy dict data size " + dataJSONArray.size() + ",dictname:" + dictName);
                    if (dataJSONArray.size() == 0) {
                        throw new Exception("zy dict error data size 0");
                        continue;
                    }
                    ZyCommonDict[] zyCommonDictArrays = (ZyCommonDict[]) JSONArray.toArray(dataJSONArray, ZyCommonDict.class);
                    //下划线转驼峰
                    JSONArray newJA = new JSONArray();
                    JSONArray jsonArrayTemp = dataJSONArray.getJSONArray(0);
                    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);
@ -245,6 +271,7 @@ public class ZyDictJob implements Job {
                //清空表
                zyCommonDictDao.deleteAll();
                //新增数据
                logger.info("save table zy_common_dict  ,size:" + zyCommonDictz.size());
                zyCommonDictDao.save(zyCommonDictz);
            }
        }
@ -263,6 +290,7 @@ public class ZyDictJob implements Job {
            //清空表
            zyIvDeptDictDao.deleteAll();
            //新增数据
            logger.info("save table zy_iv_dept_dict  ,size:" + zyIvDeptDicts.size());
            zyIvDeptDictDao.save(zyIvDeptDicts);
        }
        logger.info("synchronized zy_iv_dept_dict end");
@ -285,11 +313,24 @@ public class ZyDictJob implements Job {
                throw new Exception("zy dict error status not 200");
            }
            if (returnJson.containsKey("data")) {
                JSONArray dataJSONArray = returnJson.getJSONObject("data").getJSONArray("returnData");
                if (dataJSONArray.size() == 0) {
                    throw new Exception("zy dict error data size 0");
                JSONArray dataJSONArray = JSONObject.fromObject(returnJson.getString("data")).getJSONArray("returnData");
                logger.info("zy dict data size " + dataJSONArray.size() + ",dictname:" + dictName);
                //下划线转驼峰
                JSONArray newJA = new JSONArray();
                for (int i = 0; i < dataJSONArray.getJSONArray(0).size(); i++) {
                    JSONObject jo = dataJSONArray.getJSONArray(0).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);
                }
                tList.addAll(Arrays.asList(JSONArray.toArray(dataJSONArray, clazz)));
                tList.addAll(Arrays.asList(JSONArray.toArray(newJA, clazz)));
            } else {
                throw new Exception("zy dict error no contain data");
            }
@ -434,4 +475,51 @@ public class ZyDictJob implements Job {
        }
        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
        }
    }
}

+ 6 - 6
patient-co/patient-co-wlyy/src/main/resources/wechat/weixin_menu_jimei.txt

@ -59,6 +59,11 @@
   {
	  "name":"我的",
	  "sub_button":[
		{
		   "type":"view",
		   "name":"专属服务",
		   "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fdist%2fhtml%2fexclusive-service.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		},
		{
		   "type":"view",
		   "name":"我的资料",
@ -74,14 +79,9 @@
		   "name":"我的设备",
		   "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fwdsb%2fhtml%2fmy-equipments.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
		},
        {
         	"type":"click",
         	"name":"操作说明",
         	"key":"caozuoshuoming"
        },
        {
        	 "type":"view",
        	 "name":"集美反馈",
        	 "name":"意见反馈",
        	 "url":"https://open.weixin.qq.com/connect/oauth2/authorize?appid=appId&redirect_uri=server_url%2fwx%2fhtml%2fyjfk%2fhtml%2ffeedback.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
        }
	 ]