|
@@ -1,5 +1,13 @@
|
|
package com.zskk.control;
|
|
package com.zskk.control;
|
|
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.text.ParseException;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
import com.jfinal.core.Controller;
|
|
import com.jfinal.core.Controller;
|
|
import com.jfinal.kit.PropKit;
|
|
import com.jfinal.kit.PropKit;
|
|
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
|
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
|
@@ -11,139 +19,68 @@ import com.zskk.model.Doctors;
|
|
import com.zskk.model.Exams;
|
|
import com.zskk.model.Exams;
|
|
import com.zskk.model.PatientInfos;
|
|
import com.zskk.model.PatientInfos;
|
|
import com.zskk.model.Report;
|
|
import com.zskk.model.Report;
|
|
-import com.zskk.model.Studies;
|
|
|
|
import com.zskk.service.ServiceFactory;
|
|
import com.zskk.service.ServiceFactory;
|
|
import com.zskk.service.WeixinService;
|
|
import com.zskk.service.WeixinService;
|
|
-
|
|
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
|
|
+import okhttp3.FormBody;
|
|
|
|
+import okhttp3.MediaType;
|
|
|
|
+import okhttp3.OkHttpClient;
|
|
|
|
+import okhttp3.Request;
|
|
|
|
+import okhttp3.RequestBody;
|
|
|
|
+import okhttp3.Response;
|
|
|
|
|
|
public class ViewController extends Controller {
|
|
public class ViewController extends Controller {
|
|
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ private static final MediaType JSON_CODE = MediaType.get("application/json; charset=utf-8");
|
|
|
|
+
|
|
|
|
+ private static final OkHttpClient OKHTTP_CLIENT = new OkHttpClient();
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 在被连接数据库执行sql语句
|
|
* 在被连接数据库执行sql语句
|
|
*/
|
|
*/
|
|
public void executeSql() {
|
|
public void executeSql() {
|
|
- try {
|
|
|
|
- List<Record> d = Db.use("connected").find("select * from (select * from reportinfo order by REPORTDATE desc) where rownum <= 20");
|
|
|
|
- this.renderJson(d);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- // TODO: handle exception
|
|
|
|
- this.renderText(e.toString());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public void executeSql2() {
|
|
|
|
- try {
|
|
|
|
- String sqlString = this.getPara("str");
|
|
|
|
- List<Record> d = Db.use("connected").find(sqlString);
|
|
|
|
- this.renderJson(d);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- // TODO: handle exception
|
|
|
|
- this.renderText(e.toString());
|
|
|
|
- }
|
|
|
|
|
|
+ List<Record> d = Db.use("connected").find(this.getPara("sqlstr"));
|
|
|
|
+ this.renderJson(d);
|
|
}
|
|
}
|
|
- public void executeSql3() {
|
|
|
|
- try {
|
|
|
|
- DruidPlugin druidPluginConnected = createConnectedDruidPlugin();
|
|
|
|
- druidPluginConnected.start();
|
|
|
|
- // 配置ActiveRecord插件
|
|
|
|
- ActiveRecordPlugin arpConnected = new ActiveRecordPlugin("connected", druidPluginConnected);
|
|
|
|
- arpConnected.setDialect(new SqlServerDialect());
|
|
|
|
- arpConnected.start();
|
|
|
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- // TODO: handle exception
|
|
|
|
- this.renderText(e.toString());
|
|
|
|
|
|
+ /**
|
|
|
|
+ * post请求
|
|
|
|
+ * @param url-请求地址
|
|
|
|
+ * @param map-参数集合
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private static String doPost(String url, Map<String, String> map) {
|
|
|
|
+ FormBody.Builder builder = new FormBody.Builder();
|
|
|
|
+ for (String key : map.keySet()) {
|
|
|
|
+ builder.add(key, map.get(key));
|
|
}
|
|
}
|
|
- }
|
|
|
|
- public static DruidPlugin createConnectedDruidPlugin() {
|
|
|
|
|
|
|
|
- return new DruidPlugin(PropKit.get("jdbcUrl_connected"), PropKit.get("user_connected"),PropKit.get("password_connected").trim());
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public void testTask() {
|
|
|
|
- try {
|
|
|
|
- List<Exams> exams = Exams.dao.use("zskk").find("SELECT * FROM pacsonline.exams where exam_status=3 and institution_id=81069902 order by createdAt desc limit 30");
|
|
|
|
- for (Exams exams2 : exams) {
|
|
|
|
- try {
|
|
|
|
- Studies studies = Studies.dao.use("zskk").findById(exams2.getStudyId());
|
|
|
|
- Record record = Db.use("connected").findFirst("select * from PACSONLINE_Interface where STUDYUID=?",studies.getStudyuid());
|
|
|
|
- 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("telephone"));
|
|
|
|
- patientInfos.setCardNum(record.getStr("IDCARD"));
|
|
|
|
- patientInfos.update();
|
|
|
|
- exams2.setExamStatus(9);
|
|
|
|
- exams2.setApplicationDepartment(record.getStr("DEPARTMENT"));
|
|
|
|
- exams2.setApplicationDoctor(record.getStr("CLINICALDOCTOR"));
|
|
|
|
- exams2.update();
|
|
|
|
- WeixinService wService = ServiceFactory.getService(WeixinService.class);
|
|
|
|
- wService.requestWeixinQrcode(report.getId());
|
|
|
|
-
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- // TODO: handle exception
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ RequestBody formBody = builder.build();
|
|
|
|
|
|
- }
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- // TODO: handle exception
|
|
|
|
- this.renderText(e.toString());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private 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) {
|
|
|
|
|
|
+ Request request = new Request.Builder().url(url).post(formBody).build();
|
|
|
|
+
|
|
|
|
+ try (Response response = OKHTTP_CLIENT.newCall(request).execute()) {
|
|
|
|
+ if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
|
|
|
|
+ String content = response.body().string();
|
|
|
|
+ return content;
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ // TODO Auto-generated catch block
|
|
|
|
+ e.printStackTrace();
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
- Doctors doctors = Doctors.dao.use("zskk").findFirst("SELECT * FROM doctors where instr(?,realname) and institution_id=81069902 and realname<>''", name);
|
|
|
|
- if (doctors == null) {
|
|
|
|
- Doctors newDoctors = new Doctors().use("zskk");
|
|
|
|
- newDoctors.setId(creatId());
|
|
|
|
- newDoctors.setUsername("none");
|
|
|
|
- newDoctors.setRealname(name);
|
|
|
|
- newDoctors.setPassword("123456");
|
|
|
|
- newDoctors.setInstitutionId("81069902");
|
|
|
|
- newDoctors.setCreatedAt(new Date());
|
|
|
|
- newDoctors.setUpdatedAt(new Date());
|
|
|
|
- newDoctors.save();
|
|
|
|
- return newDoctors.getId();
|
|
|
|
- }
|
|
|
|
- return doctors.getId();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 日期字符串格式转换
|
|
|
|
+ * @param dateStr
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
private Date parseStringToDate(String dateStr) {
|
|
private Date parseStringToDate(String dateStr) {
|
|
if (dateStr == null) {
|
|
if (dateStr == null) {
|
|
return new Date();
|
|
return new Date();
|
|
@@ -158,5 +95,13 @@ public class ViewController extends Controller {
|
|
}
|
|
}
|
|
return date;
|
|
return date;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ 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);
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|