Browse Source

Merge branch 'i_15700002' of http://code.pacsonline.cn/lt/data_fusion into i_15700002

# Conflicts:
#	DataFusion/WebRoot/WEB-INF/classes/com/zskk/model/_DataDictionary.txt
zhangzhanping 5 years ago
parent
commit
69af085a33

+ 12 - 6
DataFusion/.classpath

@@ -2,7 +2,12 @@
 <classpath>
 	<classpathentry kind="src" path="src"/>
 	<classpathentry kind="src" path="res"/>
-	<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-codec-1.9.jar"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
+		<attributes>
+			<attribute name="module" value="true"/>
+			<attribute name="owner.project.facets" value="java"/>
+		</attributes>
+	</classpathentry>
 	<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-io-2.5.jar"/>
 	<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-lang3-3.4.jar"/>
 	<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-logging-1.2.jar"/>
@@ -28,10 +33,11 @@
 	<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/jaxb-api-2.3.0.jar"/>
 	<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/jaxb-core-2.3.0.jar"/>
 	<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/jaxb-impl-2.3.0.jar"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
-		<attributes>
-			<attribute name="owner.project.facets" value="java"/>
-		</attributes>
-	</classpathentry>
+	<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/commons-codec-1.9.jar"/>
+	<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/annotations-13.0.jar"/>
+	<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/kotlin-stdlib-1.3.50.jar"/>
+	<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/kotlin-stdlib-common-1.3.50.jar"/>
+	<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/okhttp-4.2.2.jar"/>
+	<classpathentry kind="lib" path="WebRoot/WEB-INF/lib/okio-2.2.2.jar"/>
 	<classpathentry kind="output" path="WebRoot/WEB-INF/classes"/>
 </classpath>

BIN
DataFusion/WebRoot/WEB-INF/lib/annotations-13.0.jar


BIN
DataFusion/WebRoot/WEB-INF/lib/kotlin-stdlib-1.3.50.jar


BIN
DataFusion/WebRoot/WEB-INF/lib/kotlin-stdlib-common-1.3.50.jar


BIN
DataFusion/WebRoot/WEB-INF/lib/okhttp-4.2.2.jar


BIN
DataFusion/WebRoot/WEB-INF/lib/okio-2.2.2.jar


+ 1 - 1
DataFusion/src/com/zskk/config/ZskkConfig.java

@@ -79,7 +79,7 @@ public class ZskkConfig extends JFinalConfig {
 		me.add(arpConnected);
 
 		Cron4jPlugin cpData = new Cron4jPlugin();
-		cpData.addTask("*/15 * * * *", new DataTask());
+		cpData.addTask("*/5 * * * *", new DataTask());
 		me.add(cpData);
 
 //		Cron4jPlugin cp2 = new Cron4jPlugin();

+ 296 - 35
DataFusion/src/com/zskk/control/ViewController.java

@@ -1,15 +1,31 @@
 package com.zskk.control;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.jfinal.core.Controller;
+import com.jfinal.kit.HashKit;
 import com.jfinal.kit.PropKit;
 import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
 import com.jfinal.plugin.activerecord.Db;
 import com.jfinal.plugin.activerecord.Record;
+import com.jfinal.plugin.activerecord.dialect.MysqlDialect;
 import com.jfinal.plugin.activerecord.dialect.SqlServerDialect;
 import com.jfinal.plugin.druid.DruidPlugin;
+import com.jfinal.plugin.redis.RedisPlugin;
 import com.zskk.model.*;
+
+import okhttp3.FormBody;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+
 import org.apache.commons.codec.digest.DigestUtils;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
 import java.text.ParseException;
@@ -17,7 +33,18 @@ import java.text.SimpleDateFormat;
 import java.util.*;
 
 public class ViewController extends Controller {
+	private static final OkHttpClient OKHTTP_CLIENT = new OkHttpClient();
 
+	static{
+		PropKit.use("config.properties");
+		DruidPlugin plugin = new DruidPlugin(PropKit.get("jdbcUrl_zskk"), PropKit.get("user_zskk"), PropKit.get("password_zskk").trim());
+		ActiveRecordPlugin arp = new ActiveRecordPlugin(plugin); 		
+		_MappingKit.mapping(arp);
+		plugin.start();
+		arp.start();
+
+	}
+	
 	/**
 	 * 在被连接数据库执行sql语句
 	 */
@@ -61,76 +88,310 @@ public class ViewController extends Controller {
 
 		return new DruidPlugin(PropKit.get("jdbcUrl_connected"), PropKit.get("user_connected"),PropKit.get("password_connected").trim());
 	}
-	public void testTask() {
+	public static DruidPlugin createZskkDruidPlugin() {
+
+		return new DruidPlugin("jdbc:mysql://47.104.6.21:3306/pacsonline?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false", "pacs","ZSKK@2017~!@#");
+	}
+	public static void testTask() {
+
 		try {
-			//List<Record>  d =  Db.use("connected").find(this.getPara("sqlStr"));
-			List<Exams> exams = Exams.dao.use("zskk").find("SELECT * FROM pacsonline.exams where exam_status=3 and institution_id=73090001 order by createdAt desc limit 50");
-			List<Record> examds = new ArrayList<>();
+			String string = "here";
+			String jString = "{\"birthdate\":\"1961-12-09 00:00:00\",\"modality\":\"CR\",\"patientid\":\"030244257\",\"patientsex\":\"女\",\"reportPaperNum\":736933,\"reportdate\":\"2019-12-29 10:03:12\",\"diagnosis\":\"宫颈癌\",\"accessionNumber\":\"141235\",\"patientname\":\"郭俊香\",\"symptom\":\"宫颈癌病史,放射性肠炎,灌肠,腹部疼痛,复查\",\"clinicaldoctor\":\"王微美\",\"phone\":\"15174686117\",\"DESCRIPTION\":\"所示胸腰椎及骨盆未见骨质异常;\\r\\n双侧膈下可见新月形气体影;\\r\\n腹部肠管内见积气影;未见明显液平;\\r\\n腰大肌影清晰;腹壁软组织影未见异常;\\r\\n胆囊区、肾区、输尿管区、膀胱区未见阳性结石影;\\r\\n双肾轮廓显影欠清;隐约可见;未见明显形态改变;\\r\\n腹部未见异常软组织团块影,未见异常钙化影。\\r\\n\",\"printreport\":false,\"idcard\":\"231083196112095123\",\"patientage\":\"58岁\",\"impression\":\"1、双侧膈下游离气体影:请结合临床\\r\\n2、腹部肠管内积气,请结合临床。\\r\\n\",\"regPaperNum\":\"890248\",\"reviewdoctor\":\"刘寅赫\",\"department\":\"放疗三科\",\"studyuid\":\"141235\",\"printfilm\":true,\"reportdoctor\":\"刘寅赫\"}";
+			List<Exams> exams = Exams.dao.find("SELECT * FROM pacsonline.exams where id='116f51b2313f5fda'");
 			for (Exams exams2 : exams) {
-				Studies studies = Studies.dao.use("zskk").findById(exams2.getStudyId());
-				Record record = Db.use("connected").findFirst("select * from caller where STUDYUID=?",studies.getStudyuid());
+				//Studies studies = Studies.dao.use("zskk").findById(exams2.getStudyId());
+//				Record record = Db.use("connected").findFirst("select * from zskk where accessionNumber=?",exams2.getAccessionNum());
+//				Record record = (Record)JSON.parse(jString);
+				JSONObject record = JSON.parseObject(jString);
 				if (record == null) {
 					continue;
 				}
-				examds.add(record);
-				Report report = new Report().use("zskk");
-				report.setId(creatId());
-				report.setReportDatetime(aaa(record.getStr("REPORTDATE")));
-				report.setImpression(record.getStr("IMPRESSION"));
-				report.setDescription(record.getStr("DESCRIPTION"));
-				report.setExamId(exams2.getId());
-				report.setCreatedAt(new Date());
-				if (record.getStr("FITEM_RESULT_CODE") != null) {
-					//report.setReportResult(record.getStr("FITEM_RESULT_CODE").contains("阴")?"1":"2");
-				}
-				report.setReportDoctorId(getDoctorIdByName(record.getStr("REPORTDOCTOR")));
-				report.setReviewDoctorId(getDoctorIdByName(record.getStr("REVIEWDOCTOR")));
-				report.setReviewDatetime(aaa(record.getStr("REPORTDATE")));
-				report.setConfirmDoctorId(getDoctorIdByName(record.getStr("REVIEWDOCTOR")));
-				report.setConfirmDatetime(aaa(record.getStr("REPORTDATE")));
+//				Report report = new Report().use("zskk");
+//				report.setId(creatId());
+//				report.setReportDatetime(parseStringToDate(record.getStr("reportdate")));
+//				if (record.getStr("impression") == null && record.getStr("DESCRIPTION") == null) {
+//					continue;
+//				}
+//				report.setImpression(record.getStr("impression"));
+//				report.setDescription(record.getStr("DESCRIPTION"));
+//				report.setExamId(exams2.getId());
+//				report.setCreatedAt(new Date());
+//				report.setReportDoctorId(getDoctorIdByName(record.getStr("reportdoctor")));
+//				report.setReviewDoctorId(getDoctorIdByName(record.getStr("reviewdoctor")));
+//				report.setReviewDatetime(parseStringToDate(record.getStr("reportdate")));
+//				report.setConfirmDoctorId(getDoctorIdByName(record.getStr("reviewdoctor")));
+//				report.setConfirmDatetime(parseStringToDate(record.getStr("reportdate")));
 //				report.save();
-				PatientInfos patientInfos = PatientInfos.dao.use("zskk").findById(exams2.getPatientId());
-				patientInfos.setName(record.getStr("PATIENTNAME"));
+				PatientInfos patientInfos = PatientInfos.dao.findById(exams2.getPatientId());
+//				patientInfos.setName(record.getStr("patientname"));
+//				patientInfos.setPhone(record.getStr("phone"));
+//				patientInfos.setCardNum(record.getStr("idcard"));
 //				patientInfos.update();
+//				exams2.setExamStatus(9);
+//                exams2.setClinDoctors(record.getStr("clinicaldoctor"));
+//                exams2.setApplicationDepartment(record.getStr("department"));
+//                exams2.setApplicationDoctor(record.getStr("clinicaldoctor"));
+//                exams2.setClinDiag(record.getStr("diagnosis"));
+//				exams2.update();
+				//传云医康 数据
+                Map<String, String> data = new HashMap<String, String>();
+                //获取data数据
+                //医院id
+                data.put("hospital_id","15700002");
+                //影像所见
+                data.put("description",record.getString("DESCRIPTION"));
+                //意见建议
+                data.put("impression",record.getString("impression"));
+                //检查id
+                data.put("exam_id",exams2.getId());
+                //患者id
+                data.put("patient_id",exams2.getPatientId());
+                data.put("study_id",exams2.getStudyId());
+
+                //患者姓名
+                data.put("patient_name",record.getString("patientname"));
+                //患者性别
+                data.put("patient_sex",record.getString("patientsex").equals("女")?"F":"M");
+                //身份证号
+                data.put("card_num","");
+                //手机号
+                data.put("phone","");
+                //患者生日
+                data.put("birthday",returnSecondTimestamp(record.getString("birthdate")));
+                //患者检查时年龄
+                data.put("patient_age",patientInfos.getAge());
+                //阴阳性 1阴性 2阳性
+                data.put("report_result","");
+                //报告时间 10位时间戳
+                data.put("report_datetime",returnSecondTimestamp(record.getString("reportdate")));
+                //报告医生id
+                data.put("report_doctor_id",record.getString("reportdoctor"));
+                //报告医生姓名
+                data.put("report_doctor_name",record.getString("reportdoctor"));
+                //审核时间
+                data.put("review_datetime",returnSecondTimestamp(record.getString("reportdate")));
+                //审核医生id
+                data.put("review_doctor_id",record.getString("reviewdoctor"));
+                //审核姓名
+                data.put("review_doctor_name",record.getString("reviewdoctor"));
+                //确认时间
+                data.put("confirm_datetime", returnSecondTimestamp(record.getString("reportdate")));
+                //确认医生id
+                data.put("confirm_doctor_id", record.getString("reviewdoctor"));
+                //确认医生姓名
+                data.put("confirm_doctor_name",record.getString("reviewdoctor"));
+//                System.out.println(data);
+                //调用接口
+//               String s = post(null, data);
+////               string = string+s;
+//                String ssString = data.toString();
+//
+////        		String ssString = "{\"birthday\":\"-937382400\",\"review_datetime\":\"1577608513\",\"review_doctor_name\":\"王宪\",\"confirm_doctor_id\":\"王宪\",\"description\":\"所示胸腰椎及骨盆未见骨质异常;rn双侧膈下见气体密度影;rn腹部肠管内积气伴局部扩张;rn腰大肌影清晰;腹壁软组织影未见异常;rn胆囊区、肾区、输尿管区、膀胱区未见阳性结石影;rn双肾轮廓显影欠清;隐约可见;未见明显形态改变;rn腹部未见异常软组织团块影,未见异常钙化影。rn\",\"study_id\":\"116f50c27d705e37\",\"hospital_id\":\"15700002\",\"confirm_datetime\":\"1577608513\",\"card_num\":\"\",\"patient_sex\":\"M\",\"phone\":\"\",\"report_doctor_id\":\"王宪\",\"patient_id\":\"116f50c27d46d081\",\"report_doctor_name\":\"王宪\",\"patient_name\":\"赵清标\",\"impression\":\"1、膈下游离气体,考虑气腹,请结合临床rn2、腹部肠管扩张、积气,请结合临床。rn\",\"review_doctor_id\":\"王宪\",\"report_datetime\":\"1577608513\",\"patient_age\":\"79岁\",\"report_result\":\"\",\"confirm_doctor_name\":\"王宪\",\"exam_id\":\"116f50c27d8a1bc5\"}";
+//           	 Map maps = (Map)JSON.parse(ssString);  
+//             System.out.println(ssString);
+                String ssString=JSON.toJSONString(data);
+                System.out.println(ssString);
+                ssString = ssString.replace("\\","");
+           	 Map maps = (Map)JSON.parse(ssString);  
+
+                post(null, maps);
 			}
-			this.renderJson(examds);
+            System.out.println(string);
+//			this.renderText(string);
 		} catch (Exception e) {
 			// TODO: handle exception
-			this.renderText(e.toString());
+//			this.renderText(e.toString());
+            System.out.println(e.toString());
+
 		}
 	}
 	
-	private String creatId() {
+	 public static  String getSign(Map<String, String> param, String key) {
+	        return DigestUtils.md5Hex(Ksort(param) + key);
+	    }
+	 
+	public static String getSecondTimestamp(Date date) {
+        if (null == date) {
+            return "参数为空";
+        }
+        String timestamp = String.valueOf(date.getTime());
+        int length = timestamp.length();
+        if (length > 3) {
+            return String.valueOf(timestamp.substring(0, length - 3));
+        } else {
+            return "参数不足3位数";
+        }
+    }
+	
+	private static String creatId() {
 		UUID id = UUID.randomUUID();
         String[] idd= id.toString().split("-");
 		return idd[0]+idd[1]+idd[2];
 	}
 	
-	private String getDoctorIdByName(String name) {
-		if (name == null) {
-			return "1";
+	private static String getDoctorIdByName(String name) {
+		if (name == null || name.isBlank()) {
+			return null;
 		}
-		Doctors doctors = Doctors.dao.use("zskk").findFirst("SELECT * FROM doctors where instr(?,realname) and institution_id=73090001",name);
+		name = name.replace(" ", "");
+		Doctors doctors = Doctors.dao.use("zskk").findFirst("SELECT * FROM doctors where instr(?,realname) and institution_id=15700002 and realname is not null",name);
 		if (doctors == null) {
-			return "1";
+			Doctors newDoctors = new Doctors().use("zskk");
+			newDoctors.setId(creatId());
+			newDoctors.setUsername("none");
+			newDoctors.setRealname(name);
+			newDoctors.setPassword("123456");
+			newDoctors.setInstitutionId("15700002");
+			newDoctors.setCreatedAt(new Date());
+			newDoctors.setUpdatedAt(new Date());
+			newDoctors.save();
+			return newDoctors.getId();
 		}
 		return doctors.getId();
 	}
 	
-	private Date aaa(String timestr) {
-		if (timestr == null) {
+	private static Date parseStringToDate(String dateStr) {
+		if (dateStr == null) {
 			return new Date();
 		}
 		SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 	    Date date = null;
 		try {
-			date = sdf.parse(timestr);
+			date = sdf.parse(dateStr);
 		} catch (ParseException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
         return date;
 	}
+	
+	public static String sendPost(String url, Map<String, String> parameters) {
+        String result = "";// 返回的结果
+        BufferedReader in = null;// 读取响应输入流
+        PrintWriter out = null;
+        StringBuffer sb = new StringBuffer();// 处理请求参数
+        String params = "";// 编码之后的参数
+        try {
+            // 编码请求参数
+            if (parameters.size() == 1) {
+                for (String name : parameters.keySet()) {
+                    sb.append(name).append("=").append(
+                            java.net.URLEncoder.encode(parameters.get(name),
+                                    "UTF-8"));
+                }
+                params = sb.toString();
+            } else {
+                for (String name : parameters.keySet()) {
+                    sb.append(name).append("=").append(
+                            java.net.URLEncoder.encode(parameters.get(name),
+                                    "UTF-8")).append("&");
+                }
+                String temp_params = sb.toString();
+                params = temp_params.substring(0, temp_params.length() - 1);
+            }
+            // 创建URL对象
+            java.net.URL connURL = new java.net.URL(url);
+            // 打开URL连接
+            java.net.HttpURLConnection httpConn = (java.net.HttpURLConnection) connURL
+                    .openConnection();
+            // 设置通用属性
+            httpConn.setRequestProperty("Accept", "*/*");
+            httpConn.setRequestProperty("Connection", "Keep-Alive");
+            httpConn.setRequestProperty("User-Agent",
+                    "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
+            // 设置POST方式
+            httpConn.setDoInput(true);
+            httpConn.setDoOutput(true);
+            // 获取HttpURLConnection对象对应的输出流
+            out = new PrintWriter(httpConn.getOutputStream());
+            // 发送请求参数
+            out.write(params);
+            // flush输出流的缓冲
+            out.flush();
+            // 定义BufferedReader输入流来读取URL的响应,设置编码方式
+            in = new BufferedReader(new InputStreamReader(httpConn
+                    .getInputStream(), "UTF-8"));
+            String line;
+            // 读取返回的内容
+            while ((line = in.readLine()) != null) {
+                result += line;
+            }
+            System.out.println(result);
+            return result;
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                if (out != null) {
+                    out.close();
+                }
+                if (in != null) {
+                    in.close();
+                }
+            } catch (IOException ex) {
+                ex.printStackTrace();
+            }
+        }
+        return result;
+    }
+
+	private static void post(String url, Map<String, String> map) throws IOException {
+		RequestBody formBody = new FormBody.Builder()
+		        .add("timestamp", String.valueOf(getSecondTimestamp(new Date())))
+		        .add("signature", Ksort(map))
+		        .add("data", JSON.toJSONString(map))
+		        .build();
+
+		 System.out.println(String.valueOf(getSecondTimestamp(new Date())));
+	      System.out.println(Ksort(map));
+	      System.out.println(JSON.toJSONString(map));
+		    Request request = new Request.Builder()
+		        .url("http://39.106.136.96/pacs/zskk/writePatientReport")
+		        .post(formBody)
+		        .build();
+
+		    try (Response response = OKHTTP_CLIENT.newCall(request).execute()) {
+		      if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
+
+		      System.out.println(response.body().string());
+//			  return response.body().string();
+
+		    }
+	  }  
+	public static String Ksort(Map<String, String> map){
+		String sb = "";
+		String[] key = new String[map.size()];
+		int index = 0;
+		for (String k : map.keySet()) {
+		key[index] = k;
+		index++;
+		}
+		Arrays.sort(key);
 
+		for (String s : key) {
+		sb += s + "=" + map.get(s) + "&";
+		}
+		sb = sb.substring(0, sb.length() - 1);
+		System.out.println("***"+sb);
+
+		try {
+		sb = URLEncoder.encode(sb, "UTF-8");
+		} catch (UnsupportedEncodingException e) {
+		e.printStackTrace();
+		}// 使用常见的UTF-8编码
+		sb = sb.replace("%3D", "=").replace("%26", "&");
 
+		System.out.println("**"+sb);
+		String resultString = HashKit.md5(sb+"YgpxjVeIx0yoK6Atz413IAj7hU9dygH4");
+		return resultString;
+	}
+	
+	public static  String returnSecondTimestamp(String data) throws ParseException {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+        return String.valueOf(sdf.parse(data).getTime()/1000);
+    }
+	public static void main(String[] args) {
+			testTask();
+	}
 }

+ 48 - 8
DataFusion/src/com/zskk/service/WeixinService.java

@@ -1,5 +1,7 @@
 package com.zskk.service;
 
+import java.util.List;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpGet;
@@ -7,17 +9,22 @@ import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
 
+import com.jfinal.kit.PropKit;
+import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
+import com.jfinal.plugin.druid.DruidPlugin;
+import com.zskk.model.Doctors;
+import com.zskk.model.Report;
+import com.zskk.model._MappingKit;
+
 
 public class WeixinService {
 	static {
-//		PropKit.use("config.txt");
-//		ServiceFactory.init();
-//		DruidPlugin plugin = new DruidPlugin(PropKit.get("jdbcUrl"), PropKit.get("user"), PropKit.get("password").trim());
-//		ActiveRecordPlugin arp = new ActiveRecordPlugin(plugin); 		
-//		_MappingKit.mapping(arp);
-//		plugin.start();
-//		arp.start();
-
+		PropKit.use("config.properties");
+		DruidPlugin plugin = new DruidPlugin(PropKit.get("jdbcUrl_zskk"), PropKit.get("user_zskk"), PropKit.get("password_zskk").trim());
+		ActiveRecordPlugin arp = new ActiveRecordPlugin(plugin); 		
+		_MappingKit.mapping(arp);
+		plugin.start();
+		arp.start();
 	}
 	private static final PoolingHttpClientConnectionManager POOL_CM = new PoolingHttpClientConnectionManager();
 
@@ -67,4 +74,37 @@ public class WeixinService {
 		return content;
 	}
 
+	public static void main(String[] args) {
+		List<Doctors> doctors = Doctors.dao.find("SELECT * FROM doctors where realname='王振宇' and username='none' and institution_id='15700002' and id <>'8cfe556ca64f49e3'");
+		for (Doctors doctors2 : doctors) {
+			List<Report> reports = Report.dao.find("SELECT * FROM report where report_doctor_id=? or review_doctor_id=? or confirm_doctor_id=?",doctors2.getId(),doctors2.getId(),doctors2.getId());
+			if (reports.size() == 0) {
+				System.out.println("删除医生"+doctors2.getId());
+				doctors2.delete();
+			}else {
+				for (Report report3 : reports) {
+					String docString = "8cfe556ca64f49e3";
+					if (report3.getReportDoctorId().equals(doctors2.getId())) {
+						System.out.println("更改报告医生"+doctors2.getId());
+						report3.setReportDoctorId(docString);	
+					}
+					if (report3.getReviewDoctorId().equals(doctors2.getId())) {
+						System.out.println("更改审核医生"+doctors2.getId());
+						report3.setReviewDoctorId(docString);	
+					}
+					if (report3.getConfirmDoctorId().equals(doctors2.getId())) {
+						System.out.println("更改确认医生"+doctors2.getId());
+						report3.setConfirmDoctorId(docString);	
+					}
+					report3.update();
+					doctors2.delete();
+				}
+			}
+		}
+
+//		System.out.println("d"+doctors);
+
+
+	}
+
 }

+ 145 - 112
DataFusion/src/com/zskk/task/DataTask.java

@@ -1,6 +1,7 @@
 package com.zskk.task;
 
 import com.alibaba.fastjson.JSON;
+import com.jfinal.kit.HashKit;
 import com.jfinal.plugin.activerecord.Db;
 import com.jfinal.plugin.activerecord.Record;
 import com.jfinal.plugin.cron4j.ITask;
@@ -10,6 +11,13 @@ import com.zskk.model.PatientInfos;
 import com.zskk.model.Report;
 import com.zskk.service.ServiceFactory;
 import com.zskk.service.WeixinService;
+
+import okhttp3.FormBody;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+
 import org.apache.commons.codec.digest.DigestUtils;
 
 import java.io.*;
@@ -21,6 +29,7 @@ import java.util.*;
 
 
 public class DataTask implements ITask {
+	private static final OkHttpClient OKHTTP_CLIENT = new OkHttpClient();
 
 	@Override
 	public void run() {
@@ -28,95 +37,95 @@ public class DataTask implements ITask {
 		try {
 			List<Exams> exams = Exams.dao.use("zskk").find("SELECT * FROM pacsonline.exams where exam_status=3 and institution_id=15700002 order by createdAt desc limit 30");
 			for (Exams exams2 : exams) {
-				//Studies studies = Studies.dao.use("zskk").findById(exams2.getStudyId());
-				Record record = Db.use("connected").findFirst("select * from zskk where accessionNumber=?",exams2.getAccessionNum());
-				if (record == null) {
-					continue;
-				}
-				Report report = new Report().use("zskk");
-				report.setId(creatId());
-				report.setReportDatetime(parseStringToDate(record.getStr("reportdate")));
-				if (record.getStr("impression") == null && record.getStr("description") == null) {
+				try {
+					//Studies studies = Studies.dao.use("zskk").findById(exams2.getStudyId());
+					Record record = Db.use("connected").findFirst("select * from zskk where accessionNumber=?",exams2.getAccessionNum());
+					if (record == null) {
+						continue;
+					}
+					Report report = new Report().use("zskk");
+					report.setId(creatId());
+					report.setReportDatetime(parseStringToDate(record.getStr("reportdate")));
+					if (record.getStr("impression") == null && record.getStr("description") == null) {
+						continue;
+					}
+					report.setImpression(record.getStr("impression"));
+					report.setDescription(record.getStr("DESCRIPTION"));
+					report.setExamId(exams2.getId());
+					report.setCreatedAt(new Date());
+					report.setReportDoctorId(getDoctorIdByName(record.getStr("reportdoctor")));
+					report.setReviewDoctorId(getDoctorIdByName(record.getStr("reviewdoctor")));
+					report.setReviewDatetime(parseStringToDate(record.getStr("reportdate")));
+					report.setConfirmDoctorId(getDoctorIdByName(record.getStr("reviewdoctor")));
+					report.setConfirmDatetime(parseStringToDate(record.getStr("reportdate")));
+					report.save();
+					PatientInfos patientInfos = PatientInfos.dao.use("zskk").findById(exams2.getPatientId());
+					patientInfos.setName(record.getStr("patientname"));
+					patientInfos.setPhone(record.getStr("phone"));
+					patientInfos.setCardNum(record.getStr("idcard"));
+					patientInfos.update();
+					exams2.setExamStatus(9);
+	                exams2.setClinDoctors(record.getStr("clinicaldoctor"));
+	                exams2.setApplicationDepartment(record.getStr("department"));
+	                exams2.setApplicationDoctor(record.getStr("clinicaldoctor"));
+	                exams2.setClinDiag(record.getStr("diagnosis"));
+					exams2.update();
+					//传云医康 数据
+	                Map<String, String> data = new HashMap<String, String>();
+	                //获取data数据
+	                //医院id
+	                data.put("hospital_id","15700002");
+	                //影像所见
+	                data.put("description",record.getStr("DESCRIPTION"));
+	                //意见建议
+	                data.put("impression",record.getStr("impression"));
+	                //检查id
+	                data.put("exam_id",exams2.getId());
+	                data.put("study_id",exams2.getStudyId());
+	                //患者id
+	                data.put("patient_id",exams2.getPatientId());
+	                //患者姓名
+	                data.put("patient_name",record.getStr("patientname"));
+	                //患者性别
+	                data.put("patient_sex",record.getStr("patientsex").equals("女")?"F":"M");
+	                //身份证号
+	                data.put("card_num","");
+	                //手机号
+	                data.put("phone","");
+	                //患者生日
+	                data.put("birthday",returnSecondTimestamp(record.getStr("birthdate")));
+	                //患者检查时年龄
+	                data.put("patient_age",record.getStr("patientage"));
+	                //阴阳性 1阴性 2阳性
+	                data.put("report_result","");
+	                //报告时间 10位时间戳
+	                data.put("report_datetime",returnSecondTimestamp(record.getStr("reportdate")));
+	                //报告医生id
+	                data.put("report_doctor_id",record.getStr("reportdoctor"));
+	                //报告医生姓名
+	                data.put("report_doctor_name",record.getStr("reportdoctor"));
+	                //审核时间
+	                data.put("review_datetime",returnSecondTimestamp(record.getStr("reportdate")));
+	                //审核医生id
+	                data.put("review_doctor_id",record.getStr("reviewdoctor"));
+	                //审核姓名
+	                data.put("review_doctor_name",record.getStr("reviewdoctor"));
+	                //确认时间
+	                data.put("confirm_datetime", returnSecondTimestamp(record.getStr("reportdate")));
+	                //确认医生id
+	                data.put("confirm_doctor_id", record.getStr("reviewdoctor"));
+	                //确认医生姓名
+	                data.put("confirm_doctor_name",record.getStr("reviewdoctor"));
+
+	                String dadaString=JSON.toJSONString(data);
+	                dadaString = dadaString.replace("\\","");
+	           	    Map maps = (Map)JSON.parse(dadaString);  
+	                post(null, maps);
+				} catch (Exception e) {
+					// TODO: handle exception
 					continue;
 				}
-				report.setImpression(record.getStr("impression"));
-				report.setDescription(record.getStr("DESCRIPTION"));
-				report.setExamId(exams2.getId());
-				report.setCreatedAt(new Date());
-				report.setReportDoctorId(getDoctorIdByName(record.getStr("reportdoctor")));
-				report.setReviewDoctorId(getDoctorIdByName(record.getStr("reviewdoctor")));
-				report.setReviewDatetime(parseStringToDate(record.getStr("reportdate")));
-				report.setConfirmDoctorId(getDoctorIdByName(record.getStr("reviewdoctor")));
-				report.setConfirmDatetime(parseStringToDate(record.getStr("reportdate")));
-				report.save();
-				PatientInfos patientInfos = PatientInfos.dao.use("zskk").findById(exams2.getPatientId());
-				patientInfos.setName(record.getStr("patientname"));
-				patientInfos.setPhone(record.getStr("phone"));
-				patientInfos.setCardNum(record.getStr("idcard"));
-				patientInfos.update();
-				exams2.setExamStatus(9);
-                exams2.setClinDoctors(record.getStr("clinicaldoctor"));
-                exams2.setApplicationDepartment(record.getStr("department"));
-                exams2.setApplicationDoctor(record.getStr("clinicaldoctor"));
-                exams2.setClinDiag(record.getStr("diagnosis"));
-				exams2.update();
-				//传云医康 数据
-                Map<String, String> params = new HashMap<>(10);
-                Map<String, String> data = new HashMap<>(22);
-                //获取data数据
-                //医院id
-                data.put("hospital_id","15700002");
-                //影像所见
-                data.put("description",record.getStr("DESCRIPTION"));
-                //意见建议
-                data.put("impression",record.getStr("impression"));
-                //检查id
-                data.put("exam_id",exams2.getId());
-                //患者id
-                data.put("patient_id",exams2.getPatientId());
-                //患者姓名
-                data.put("patient_name",record.getStr("patientname"));
-                //患者性别
-                data.put("patient_sex",record.getStr("patientsex"));
-                //身份证号
-                data.put("card_num",record.getStr("idcard"));
-                //手机号
-                data.put("phone",record.getStr("phone"));
-                //患者生日
-                data.put("birthday",record.getStr("birthdate"));
-                //患者检查时年龄
-                data.put("patient_age",record.getStr("patientage"));
-                //阴阳性 1阴性 2阳性
-                //data.put("report_result","");
-                //报告时间 10位时间戳
-                data.put("report_datetime",returnSecondTimestamp(record.getStr("reportdate")));
-                //报告医生id
-                //data.put("report_doctor_id",);
-                //报告医生姓名
-                data.put("report_doctor_name",record.getStr("reportdoctor"));
-                //审核时间
-                data.put("review_datetime",returnSecondTimestamp(record.getStr("reportdate")));
-                //审核医生id
-                //data.put("review_doctor_id",);
-                //审核姓名
-                data.put("review_doctor_name",record.getStr("reviewdoctor"));
-                //确认时间
-                data.put("confirm_datetime", returnSecondTimestamp(record.getStr("reportdate")));
-                //确认医生id
-                //data.put("confirm_doctor_id", );
-                //确认医生姓名
-                data.put("confirm_doctor_name",record.getStr("clinicaldoctor"));
-                //时间戳
-                params.put("timestamp", String.valueOf(getSecondTimestamp(new Date())));
-                //signature
-                params.put("signature", getSign(data, "YgpxjVeIx0yoK6Atz413IAj7hU9dygH4"));
-                //datajson字符串
-                params.put("data", JSON.toJSONString(data));
-                //System.out.println(params);
-                //调用接口
-                sendPost("http://39.106.136.96/pacs/zskk/writePatientReport", params);
-				WeixinService wService = ServiceFactory.getService(WeixinService.class);
-				wService.requestWeixinQrcode(report.getId());;
+				
 			}
 		} catch (Exception e) {
 			// TODO: handle exception
@@ -124,6 +133,26 @@ public class DataTask implements ITask {
 		
 	}
 
+	private static void post(String url, Map<String, String> map) throws IOException {
+		RequestBody formBody = new FormBody.Builder()
+		        .add("timestamp", String.valueOf(getSecondTimestamp(new Date())))
+		        .add("signature", Ksort(map))
+		        .add("data", JSON.toJSONString(map))
+		        .build();
+
+		    Request request = new Request.Builder()
+		        .url("http://39.106.136.96/pacs/zskk/writePatientReport")
+		        .post(formBody)
+		        .build();
+
+		    try (Response response = OKHTTP_CLIENT.newCall(request).execute()) {
+		      if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
+
+		      System.out.println(response.body().string());
+//			  return response.body().string();
+
+		    }
+	  }  
     /**
      *
      * 功能描述: 获取当前时间戳(秒)
@@ -133,7 +162,7 @@ public class DataTask implements ITask {
      * @auther: zzp
      * @date: 2019/12/26 18:26
      */
-    public String getSecondTimestamp(Date date) {
+    public static String getSecondTimestamp(Date date) {
         if (null == date) {
             return "参数为空";
         }
@@ -154,26 +183,29 @@ public class DataTask implements ITask {
      * @auther: zzp
      * @date: 2019/12/26 19:21
      */
-    public  String Ksort(Map<String, String> map) {
-        String sb = "";
-        String[] key = new String[map.size()];
-        int index = 0;
-        for (String k : map.keySet()) {
-            key[index] = k;
-            index++;
-        }
-        Arrays.sort(key);
-        for (String s : key) {
-            sb += s + "=" + map.get(s) + "&";
-        }
-        sb = sb.substring(0, sb.length() - 1);
-        try {
-            sb = URLEncoder.encode(sb, "UTF-8");
-        } catch (UnsupportedEncodingException e) {
-            e.printStackTrace();
-        }// 使用常见的UTF-8编码
-        return sb.replace("%3D", "=").replace("%26", "&");
-    }
+    public static String Ksort(Map<String, String> map){
+		String sb = "";
+		String[] key = new String[map.size()];
+		int index = 0;
+		for (String k : map.keySet()) {
+		key[index] = k;
+		index++;
+		}
+		Arrays.sort(key);
+
+		for (String s : key) {
+		sb += s + "=" + map.get(s) + "&";
+		}
+		sb = sb.substring(0, sb.length() - 1);
+		try {
+		sb = URLEncoder.encode(sb, "UTF-8");
+		} catch (UnsupportedEncodingException e) {
+		e.printStackTrace();
+		}// 使用常见的UTF-8编码
+		sb = sb.replace("%3D", "=").replace("%26", "&");
+		String resultString = HashKit.md5(sb+"YgpxjVeIx0yoK6Atz413IAj7hU9dygH4");
+		return resultString;
+	}
     /**
      *
      * 功能描述:生成signature
@@ -183,7 +215,7 @@ public class DataTask implements ITask {
      * @auther: zzp
      * @date: 2019/12/24 15:28
      */
-    public  String getSign(Map<String, String> param, String key) {
+    public static  String getSign(Map<String, String> param, String key) {
         return DigestUtils.md5Hex(Ksort(param) + key);
     }
     /**
@@ -215,10 +247,11 @@ public class DataTask implements ITask {
 	}
 	
 	private String getDoctorIdByName(String name) {
-		if (name == null) {
+		if (name == null || name.isBlank()) {
 			return null;
 		}
-		Doctors doctors = Doctors.dao.use("zskk").findFirst("SELECT * FROM doctors where instr(?,realname) and institution_id=15700002 and realname<>null",name);
+		name = name.replace(" ", "");
+		Doctors doctors = Doctors.dao.use("zskk").findFirst("SELECT * FROM doctors where instr(?,realname) and institution_id=15700002 and realname is not null",name);
 		if (doctors == null) {
 			Doctors newDoctors = new Doctors().use("zskk");
 			newDoctors.setId(creatId());
@@ -307,6 +340,7 @@ public class DataTask implements ITask {
             while ((line = in.readLine()) != null) {
                 result += line;
             }
+            System.out.println(result);
         } catch (Exception e) {
             e.printStackTrace();
         } finally {
@@ -323,5 +357,4 @@ public class DataTask implements ITask {
         }
         return result;
     }
-	
 }