刘韬 %!s(int64=6) %!d(string=hai) anos
pai
achega
1c38e81778

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

@@ -44,37 +44,18 @@ public class ViewController extends Controller {
 	
 	public 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<>();
+			List<Exams> exams = Exams.dao.use("zskk").find("SELECT * FROM pacsonline.exams where exam_status=7 or exam_status=9 and institution_id=74300003 order by createdAt desc limit 100");
 			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());
-				if (record == null) {
+				Report report = Report.dao.use("zskk").findFirst("select * from report where exam_id = ?",exams2.getId());
+				if (report == 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");
+				if (report.getReportDoctorId() == null) {
+					Record record = Db.use("connected").findFirst("select * from reportinfo where patientid=?",exams2.getPatientNum());
+					report.setReportDoctorId(getDoctorIdByName(record.getStr("reportDoctor")));
+					report.update();
 				}
-				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.save();
-				PatientInfos patientInfos = PatientInfos.dao.use("zskk").findById(exams2.getPatientId());
-				patientInfos.setName(record.getStr("PATIENTNAME"));
-//				patientInfos.update();
 			}
-			this.renderJson(examds);
 		} catch (Exception e) {
 			// TODO: handle exception
 			this.renderText(e.toString());

+ 29 - 2
DataFusion/src/com/zskk/task/UpdateTask.java

@@ -1,15 +1,42 @@
 package com.zskk.task;
 
+import java.util.List;
+
+import com.jfinal.plugin.activerecord.Db;
+import com.jfinal.plugin.activerecord.Record;
 import com.jfinal.plugin.cron4j.ITask;
+import com.zskk.model.Doctors;
+import com.zskk.model.Exams;
+import com.zskk.model.Report;
 
 public class UpdateTask implements ITask {
 
 	@Override
 	public void run() {
 		// TODO Auto-generated method stub
-
+		List<Exams> exams = Exams.dao.use("zskk").find("SELECT * FROM pacsonline.exams where exam_status=7 or exam_status=9 and institution_id=74300003 order by createdAt desc limit 100");
+		for (Exams exams2 : exams) {
+			Report report = Report.dao.use("zskk").findFirst("select * from report where exam_id = ?",exams2.getId());
+			if (report == null) {
+				continue;
+			}
+			if (report.getReportDoctorId() == null) {
+				Record record = Db.use("connected").findFirst("select * from reportinfo where patientid=?",exams2.getPatientNum());
+				report.setReportDoctorId(getDoctorIdByName(record.getStr("reportDoctor")));
+				report.update();
+			}
+		}
+	}
+	private String getDoctorIdByName(String name) {
+		if (name == null) {
+			return null;
+		}
+		Doctors doctors = Doctors.dao.use("zskk").findFirst("SELECT * FROM doctors where instr(?,realname) and institution_id=74300003",name);
+		if (doctors == null) {
+			return null;
+		}
+		return doctors.getId();
 	}
-
 	@Override
 	public void stop() {
 		// TODO Auto-generated method stub