刘韬 2 years ago
parent
commit
3ee780ee15

+ 211 - 7
DataFusion/src/com/zskk/control/ViewController.java

@@ -7,6 +7,10 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.jfinal.core.Controller;
 import com.jfinal.kit.PropKit;
 import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
@@ -14,6 +18,16 @@ import com.jfinal.plugin.activerecord.Db;
 import com.jfinal.plugin.activerecord.Record;
 import com.jfinal.plugin.activerecord.dialect.SqlServerDialect;
 import com.jfinal.plugin.druid.DruidPlugin;
+import com.zskk.service.DataService;
+import com.zskk.service.ServiceFactory;
+import com.zskk.service.ThreadPoolService;
+
+import net.sourceforge.pinyin4j.PinyinHelper;
+import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
+import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
+import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
+import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType;
+import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;
 import okhttp3.FormBody;
 import okhttp3.MediaType;
 import okhttp3.OkHttpClient;
@@ -40,6 +54,82 @@ public class ViewController extends Controller {
 		}
 		
 	}
+	
+	public void sdtb() {
+		DataService dService = ServiceFactory.getService(DataService.class);
+		JSONArray jsonArray = dService.getExamList(this.getParaToInt("num"));
+		for (Object object : jsonArray) {
+			try {
+				JSONObject jsonObject = JSON.parseObject(object.toString());
+				Record record = Db.use("connected").findFirst("select * from v_Yyx where accnum=?",
+						jsonObject.getString("patient_num"));
+				if (record == null) {
+					List<Record> lists = Db.use("connected").find(
+							"select * from v_Yyx where name=? and examdatetime>? and examdatetime<?",
+							jsonObject.getString("name"),
+							parseStringToDateg(jsonObject.getString("exam_datetime")) + " 00:00:00",
+							parseStringToDateg(jsonObject.getString("exam_datetime")) + " 23:59:59");
+					if (lists.size() != 0) {
+						for (Record list : lists) {
+							if (list.getStr("project").contains("心电图")) {
+								continue;
+							}
+							record = list;
+						}
+					}
+				}
+				if (record == null) {
+					List<Record> lists = Db.use("connected").find(
+							"select * from v_Yyx where examdatetime>? and examdatetime<?",
+							parseStringToDateg(jsonObject.getString("exam_datetime")) + " 00:00:00",
+							parseStringToDateg(jsonObject.getString("exam_datetime")) + " 23:59:59");
+					if (lists.size() != 0) {
+						for (Record list : lists) {
+							if (list.getStr("project").contains("心电图")) {
+								continue;
+							}
+							if (getAllPinyin(list.getStr("name")).equals(jsonObject.getString("name")) || getAllPinyin2(list.getStr("name")).equals(jsonObject.getString("name"))) {
+								record = list;
+							}
+						}
+					}
+				}
+				if (record == null) {
+					 continue;
+				}
+				
+				Map<String, String> params = new HashMap<>();
+				params.put("exam_id", jsonObject.getString("id"));
+				// exams表
+				// 申请科室
+				params.put("application_department", "");
+				// 申请医生
+				params.put("application_doctor", "");
+				// 临床诊断
+				params.put("clin_diag", "");
+				// 症状
+				params.put("clin_symp", "");
+				// patient_infos表
+				// 患者姓名
+				params.put("name", record.getStr("name"));
+				// 患者手机号
+				params.put("phone", "");
+				// 患者身份证号
+				params.put("card_num", "");
+				// 门诊号住院号
+				params.put("hopitalized_no", "");
+				params.put("exam_project", record.getStr("project"));
+
+				ThreadPoolService tService = ServiceFactory.getService(ThreadPoolService.class);
+				tService.execute(() -> {
+					dService.updatePatientInfo(params);
+				});
+			} catch (Exception e) {
+				// TODO: handle exception
+				continue;
+			}
+		}
+	}
 
 	public void testConn() {
 		try {
@@ -107,13 +197,127 @@ public class ViewController extends Controller {
 		}
         return date;
 	}
+	
+	/**
+	 * 日期字符串格式转换
+	 * @param dateStr
+	 * @return
+	 */
+	private String parseStringToDateg(String dateStr) {
+		if (dateStr == null) {
+			return "";
+		}
+		SimpleDateFormat sdf= new SimpleDateFormat("yyyyMMdd");
+	    Date date = null;
+	    String timeString = null;
+		try {
+			date = sdf.parse(dateStr);
+			SimpleDateFormat sdf2= new SimpleDateFormat("yyyy-MM-dd");
 
-	public static void main(String[] args) {
-        Map<String,String> paramsMap=new HashMap<String,String>();
-        paramsMap.put("institution_id", "44100001");
-
-		String contentString = doPost("https://risserver3.pacsonline.cn/butt/getExam/butt/getExam", paramsMap);
-		System.out.println(contentString);
-
+			timeString = sdf2.format(date);
+		} catch (ParseException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+        return timeString;
 	}
+	
+	 public static String getAllPinyin(String hanzi) {
+	        //输出格式设置
+	        HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
+	        /**
+	         * 输出大小写设置
+	         *
+	         * LOWERCASE:输出小写
+	         * UPPERCASE:输出大写
+	         */
+	        format.setCaseType(HanyuPinyinCaseType.UPPERCASE);
+	 
+	        /**
+	         * 输出音标设置
+	         *
+	         * WITH_TONE_MARK:直接用音标符(必须设置WITH_U_UNICODE,否则会抛出异常)
+	         * WITH_TONE_NUMBER:1-4数字表示音标
+	         * WITHOUT_TONE:没有音标
+	         */
+	        format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
+	 
+	        /**
+	         * 特殊音标ü设置
+	         *
+	         * WITH_V:用v表示ü
+	         * WITH_U_AND_COLON:用"u:"表示ü
+	         * WITH_U_UNICODE:直接用ü
+	         */
+	        format.setVCharType(HanyuPinyinVCharType.WITH_V);
+	 
+	        char[] hanYuArr = hanzi.trim().toCharArray();
+	        StringBuilder pinYin = new StringBuilder();
+	 
+	        try {
+	            for (int i = 0, len = hanYuArr.length; i < len; i++) {
+	                //匹配是否是汉字
+	                if (Character.toString(hanYuArr[i]).matches("[\\u4E00-\\u9FA5]+")) {
+	                    //如果是多音字,返回多个拼音,这里只取第一个
+	                    String[] pys = PinyinHelper.toHanyuPinyinStringArray(hanYuArr[i], format);
+	                    pinYin.append(pys[0]).append(" ");
+	                } else {
+	                    pinYin.append(hanYuArr[i]).append(" ");
+	                }
+	            }
+	        } catch (BadHanyuPinyinOutputFormatCombination badHanyuPinyinOutputFormatCombination) {
+	            badHanyuPinyinOutputFormatCombination.printStackTrace();
+	        }
+	        return pinYin.toString();
+	    }
+	 
+	 public static String getAllPinyin2(String hanzi) {
+	        //输出格式设置
+	        HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
+	        /**
+	         * 输出大小写设置
+	         *
+	         * LOWERCASE:输出小写
+	         * UPPERCASE:输出大写
+	         */
+	        format.setCaseType(HanyuPinyinCaseType.LOWERCASE);
+	 
+	        /**
+	         * 输出音标设置
+	         *
+	         * WITH_TONE_MARK:直接用音标符(必须设置WITH_U_UNICODE,否则会抛出异常)
+	         * WITH_TONE_NUMBER:1-4数字表示音标
+	         * WITHOUT_TONE:没有音标
+	         */
+	        format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
+	 
+	        /**
+	         * 特殊音标ü设置
+	         *
+	         * WITH_V:用v表示ü
+	         * WITH_U_AND_COLON:用"u:"表示ü
+	         * WITH_U_UNICODE:直接用ü
+	         */
+	        format.setVCharType(HanyuPinyinVCharType.WITH_V);
+	 
+	        char[] hanYuArr = hanzi.trim().toCharArray();
+	        StringBuilder pinYin = new StringBuilder();
+	 
+	        try {
+	            for (int i = 0, len = hanYuArr.length; i < len; i++) {
+	                //匹配是否是汉字
+	                if (Character.toString(hanYuArr[i]).matches("[\\u4E00-\\u9FA5]+")) {
+	                    //如果是多音字,返回多个拼音,这里只取第一个
+	                    String[] pys = PinyinHelper.toHanyuPinyinStringArray(hanYuArr[i], format);
+	                    pinYin.append(pys[0]).append(" ");
+	                } else {
+	                    pinYin.append(hanYuArr[i]).append(" ");
+	                }
+	            }
+	        } catch (BadHanyuPinyinOutputFormatCombination badHanyuPinyinOutputFormatCombination) {
+	            badHanyuPinyinOutputFormatCombination.printStackTrace();
+	        }
+	        return pinYin.toString();
+	    }
+
 }

+ 43 - 43
DataFusion/src/com/zskk/task/UpdateTask.java

@@ -20,46 +20,46 @@ public class UpdateTask implements ITask {
 	public void run() {
 		// TODO Auto-generated method stub
 		DataService dService = ServiceFactory.getService(DataService.class);
-        JSONArray jsonArray = dService.getExamList(30);
-        for (Object object : jsonArray) {
-        	try {
-			JSONObject jsonObject = JSON.parseObject(object.toString());
-			Record record = Db.use("connected").findFirst("select * from v_Yyx where accnum=?", jsonObject.getString("patient_num"));
-			if (record == null) {
-				record = Db.use("connected").findFirst("select * from v_Yyx where name=? and ", jsonObject.getString("name"),jsonObject.getString("exam_datetime"));
-;
-			}
-			Map<String, String> params = new HashMap<>();
-			params.put("exam_id", jsonObject.getString("id"));
-			//exams表
-			//申请科室
-			params.put("application_department", "");
-			//申请医生
-			params.put("application_doctor", "");
-			//临床诊断
-			params.put("clin_diag", "");
-			//症状
-			params.put("clin_symp", "");
-			//patient_infos表
-			//患者姓名
-			params.put("name", record.getStr("name"));
-			//患者手机号
-			params.put("phone", "");
-			//患者身份证号
-			params.put("card_num", "");
-			//门诊号住院号
-			params.put("hopitalized_no", "");
-			params.put("exam_project", record.getStr("project"));
+		JSONArray jsonArray = dService.getExamList(30);
+		for (Object object : jsonArray) {
+			try {
+				JSONObject jsonObject = JSON.parseObject(object.toString());
+				Record record = Db.use("connected").findFirst("select * from v_Yyx where accnum=?",
+						jsonObject.getString("patient_num"));
+				if (record == null) {
+					continue;
+				}
+				Map<String, String> params = new HashMap<>();
+				params.put("exam_id", jsonObject.getString("id"));
+				// exams表
+				// 申请科室
+				params.put("application_department", "");
+				// 申请医生
+				params.put("application_doctor", "");
+				// 临床诊断
+				params.put("clin_diag", "");
+				// 症状
+				params.put("clin_symp", "");
+				// patient_infos表
+				// 患者姓名
+				params.put("name", record.getStr("name"));
+				// 患者手机号
+				params.put("phone", "");
+				// 患者身份证号
+				params.put("card_num", "");
+				// 门诊号住院号
+				params.put("hopitalized_no", "");
+				params.put("exam_project", record.getStr("project"));
 
-			ThreadPoolService tService = ServiceFactory.getService(ThreadPoolService.class);
-			tService.execute(() -> {
-				dService.updatePatientInfo(params);
-			});	
-        	} catch (Exception e) {
+				ThreadPoolService tService = ServiceFactory.getService(ThreadPoolService.class);
+				tService.execute(() -> {
+					dService.updatePatientInfo(params);
+				});
+			} catch (Exception e) {
 				// TODO: handle exception
-        		continue;
+				continue;
 			}
-        }
+		}
 	}
 
 	@Override
@@ -67,18 +67,18 @@ public class UpdateTask implements ITask {
 		// TODO Auto-generated method stub
 
 	}
-	
+
 	/**
 	 * 日期字符串格式转换
+	 * 
 	 * @param dateStr
 	 * @return
 	 */
 	private String parseStringToDate() {
-		SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-	    Date date = new Date();
-	    String timeString = sdf.format(date);
-	    return timeString;
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+		Date date = new Date();
+		String timeString = sdf.format(date);
+		return timeString;
 	}
 
-
 }