|
@@ -0,0 +1,485 @@
|
|
|
+package com.zskk.control;
|
|
|
+
|
|
|
+import java.io.BufferedOutputStream;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileInputStream;
|
|
|
+import java.io.FileNotFoundException;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+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.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.aliyun.oss.OSS;
|
|
|
+import com.aliyun.oss.OSSClientBuilder;
|
|
|
+import com.jfinal.core.Controller;
|
|
|
+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.OracleDialect;
|
|
|
+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 okhttp3.FormBody;
|
|
|
+import okhttp3.MediaType;
|
|
|
+import okhttp3.OkHttpClient;
|
|
|
+import okhttp3.Request;
|
|
|
+import okhttp3.RequestBody;
|
|
|
+import okhttp3.Response;
|
|
|
+
|
|
|
+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语句
|
|
|
+ */
|
|
|
+ public void executeSql() {
|
|
|
+ try {
|
|
|
+ List<Record> d = Db.use("connected").find(this.getPara("sqlstr"));
|
|
|
+ this.renderJson(d);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO: handle exception
|
|
|
+ this.renderText(e.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 在被连接数据库执行sql语句
|
|
|
+ */
|
|
|
+ public void executeSqlprint() {
|
|
|
+ try {
|
|
|
+ List<Record> d = Db.use("print").find(this.getPara("sqlstr"));
|
|
|
+ this.renderJson(d);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO: handle exception
|
|
|
+ this.renderText(e.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 在被连接数据库执行sql语句
|
|
|
+ */
|
|
|
+ public void executeSqlUpdate() {
|
|
|
+ try {
|
|
|
+ Integer d = Db.use("connected").update(this.getPara("sqlstr"));
|
|
|
+ this.renderText(d.toString());
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO: handle exception
|
|
|
+ this.renderText(e.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void testConn() {
|
|
|
+ try {
|
|
|
+ DruidPlugin druidPluginConnected = createConnectedDruidPlugin();
|
|
|
+ druidPluginConnected.start();
|
|
|
+ // 配置ActiveRecord插件
|
|
|
+ ActiveRecordPlugin arpConnected = new ActiveRecordPlugin("connected", druidPluginConnected);
|
|
|
+ arpConnected.setDialect(new OracleDialect());
|
|
|
+ arpConnected.start();
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO: handle exception
|
|
|
+ this.renderText(e.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //调阅记录
|
|
|
+ public void dyjl2pacs() {
|
|
|
+ try {
|
|
|
+ DataService dService = ServiceFactory.getService(DataService.class);
|
|
|
+ JSONArray jsonArray = dService.getBindList(this.getPara("sdate"),this.getPara("edate"));
|
|
|
+ for (Object object : jsonArray) {
|
|
|
+ try {
|
|
|
+ JSONObject jsonObject = JSON.parseObject(object.toString());
|
|
|
+ String source = "";
|
|
|
+ String[] sources = jsonObject.getString("source").split(",");
|
|
|
+ for (int i = 0; i < sources.length; i++) {
|
|
|
+ switch (sources[i]) {
|
|
|
+ case "1":
|
|
|
+ String sp1 = i==0?"":",";
|
|
|
+ source = source + sp1+ "数字影像云公众号";
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "2":
|
|
|
+ String sp2 = i==0?"":",";
|
|
|
+ source = source +sp2+ "集成链接";
|
|
|
+ break;
|
|
|
+
|
|
|
+ case "3":
|
|
|
+ String sp3 = i==0?"":",";
|
|
|
+ source = source +sp3+ "推送短信";
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Record recordei = Db.use("connected").findFirst("select * from examinfo where studyuid=?", jsonObject.getString("studyuid"));
|
|
|
+ Record recordrc = Db.use("connected").findFirst("select * from reportcheck where studyuid=?", jsonObject.getString("studyuid"));
|
|
|
+ Record recordri = Db.use("connected").findFirst("select * from reportinfo where studyuid=?", jsonObject.getString("studyuid"));
|
|
|
+ if (recordei==null && recordrc==null && recordri==null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (recordei!=null) {
|
|
|
+ Db.use("connected").update("update examinfo set ViewFlag='1',ViewTime=?,ViewName=? where studyuid=?",jsonObject.getString("createdAt"),source,jsonObject.getString("studyuid"));
|
|
|
+ }
|
|
|
+ if (recordrc!=null) {
|
|
|
+ Db.use("connected").update("update reportcheck set ViewFlag='1',ViewTime=?,ViewName=? where studyuid=?",jsonObject.getString("createdAt"),source,jsonObject.getString("studyuid"));
|
|
|
+ }
|
|
|
+ if (recordri!=null) {
|
|
|
+
|
|
|
+ Db.use("connected").update("update reportinfo set ViewFlag='1',ViewTime=?,ViewName=? where studyuid=?",jsonObject.getString("createdAt"),source,jsonObject.getString("studyuid"));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO: handle exception
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ renderJson(jsonArray);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO: handle exception
|
|
|
+ renderText(e.toString());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ public void sdtb() {
|
|
|
+ try {
|
|
|
+
|
|
|
+ List<Record> records = Db.use("connected").find("select * from V_EXAM_INFO where 最后更新时间 > ?",parseStringToDate1());
|
|
|
+
|
|
|
+
|
|
|
+ renderJson(records);
|
|
|
+
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO: handle exception
|
|
|
+ renderText(e.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //胶片匹配
|
|
|
+ public void jppp() {
|
|
|
+ DataService dService = ServiceFactory.getService(DataService.class);
|
|
|
+ List<Record> records = Db.use("print").find("select * from IMAGEVIEW where ADDTIME >? order by ADDTIME asc",this.getPara("time"));
|
|
|
+ for (Record record : records) {
|
|
|
+ try {
|
|
|
+ if (record == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map<String, String> annex_params = new HashMap<>();
|
|
|
+ annex_params.put("institution_id", PropKit.get("institution_id"));
|
|
|
+ annex_params.put("type", "2");
|
|
|
+ annex_params.put("code", record.getStr("CHECKID"));
|
|
|
+ //附件类型1.mp4 2.pdf 3.jpeg 4.png
|
|
|
+ annex_params.put("annex_class_code", "4");
|
|
|
+ annex_params.put("exam_datetime", parseStringToDate2(record.getStr("ADDTIME")));
|
|
|
+ dService.saveAnnex(annex_params, record.getStr("IMGURL"));
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO: handle exception
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ renderText(records.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ //报告匹配
|
|
|
+ public void bgpp() {
|
|
|
+ DataService dService = ServiceFactory.getService(DataService.class);
|
|
|
+ List<Record> records = Db.use("connected").find("select * from reportcheck where checktime >? order by checktime asc",this.getPara("time"));
|
|
|
+ for (Record record : records) {
|
|
|
+ try {
|
|
|
+ if (record == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (record.getStr("impression").isBlank() || record.getStr("description").isBlank()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
+ // 1:exam_id 2:patient_num 3:accession_num 4:study_uid
|
|
|
+ params.put("type", "4");
|
|
|
+
|
|
|
+ params.put("institution_id", PropKit.get("institution_id"));
|
|
|
+
|
|
|
+ params.put("code", record.getStr("studyuid"));
|
|
|
+ // 报告医生姓名
|
|
|
+ params.put("report_doctor_name", record.getStr("reportdoctor"));
|
|
|
+ // 报告时间
|
|
|
+ params.put("report_datetime", record.getStr("reportdate"));
|
|
|
+ // 审核医生姓名
|
|
|
+ params.put("review_doctor_name",
|
|
|
+ record.getStr("reviewdoctor") == null ? "" : record.getStr("reviewdoctor"));
|
|
|
+ // 审核时间
|
|
|
+ params.put("review_datetime", record.getStr("checktime"));
|
|
|
+ // 确认医生姓名
|
|
|
+ params.put("confirm_doctor_name",
|
|
|
+ record.getStr("reviewdoctor") == null ? "" : record.getStr("reviewdoctor"));
|
|
|
+ // 确认时间
|
|
|
+ params.put("confirm_datetime", record.getStr("checktime"));
|
|
|
+ // 意见建议
|
|
|
+ params.put("impression", record.getStr("impression"));
|
|
|
+ // 影像所见
|
|
|
+ params.put("description", record.getStr("description"));
|
|
|
+ // exams表
|
|
|
+ // 申请科室
|
|
|
+ params.put("application_department", record.getStr("department") == null ? "" : record.getStr("department"));
|
|
|
+ // 申请医生
|
|
|
+ params.put("application_doctor", record.getStr("clinicaldoctor") == null ? "" : record.getStr("clinicaldoctor"));
|
|
|
+ // 临床诊断
|
|
|
+ params.put("clin_diag", record.getStr("diagnosis") == null ? "" : record.getStr("diagnosis"));
|
|
|
+ // 症状
|
|
|
+ params.put("clin_symp", record.getStr("symptom") == null ? "" : record.getStr("symptom"));
|
|
|
+ // patient_infos表
|
|
|
+ // 患者姓名
|
|
|
+ params.put("name", record.getStr("patientname"));
|
|
|
+ // 患者手机号
|
|
|
+ params.put("phone", record.getStr("phone") == null ? "" : record.getStr("phone"));
|
|
|
+ // 患者身份证号
|
|
|
+ params.put("card_num", record.getStr("idcard") == null ? "" : record.getStr("idcard"));
|
|
|
+ // 检查结果1阴2阳
|
|
|
+ params.put("report_result", "0");
|
|
|
+ // 门诊号住院号
|
|
|
+ params.put("hopitalized_no", "");
|
|
|
+ params.put("exam_project", record.getStr("JianchaMingcheng") == null ? "" : record.getStr("JianchaMingcheng"));
|
|
|
+ params.put("exam_method", record.getStr("JianchaFangfa") == null ? "" : record.getStr("JianchaFangfa"));
|
|
|
+ ThreadPoolService tService = ServiceFactory.getService(ThreadPoolService.class);
|
|
|
+ tService.execute(() -> {
|
|
|
+ dService.saveReport(params);
|
|
|
+ });
|
|
|
+ Map<String, String> annex_params = new HashMap<>();
|
|
|
+ annex_params.put("institution_id", PropKit.get("institution_id"));
|
|
|
+ annex_params.put("type", "4");
|
|
|
+ annex_params.put("code", record.getStr("studyuid"));
|
|
|
+ //附件类型1.mp4 2.pdf 3.jpeg
|
|
|
+ annex_params.put("annex_class_code", "3");
|
|
|
+ dService.saveAnnex(annex_params, record.getStr("reportpath"));
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO: handle exception
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ renderText(records.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ //打印数量匹配
|
|
|
+ public void dypp() {
|
|
|
+ DataService dService = ServiceFactory.getService(DataService.class);
|
|
|
+ List<Record> records = Db.use("print").find("select * from IMAGEVIEW where PRINTED=? and PRINTTIME >?","true",this.getPara("time"));
|
|
|
+ for (Record record : records) {
|
|
|
+ try {
|
|
|
+ if (record == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //2ct 3ct 4mr
|
|
|
+ if (record.getStr("IAET").equals("4")) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map<String, String> annex_params = new HashMap<>();
|
|
|
+ annex_params.put("institution_id", PropKit.get("institution_id"));
|
|
|
+ annex_params.put("type", "2");
|
|
|
+ annex_params.put("code", record.getStr("CHECKID"));
|
|
|
+ annex_params.put("print_time", record.getStr("PRINTTIME"));
|
|
|
+ dService.savePrint(annex_params);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO: handle exception
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ renderText(records.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 日期字符串格式转换
|
|
|
+ * @param dateStr
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String parseStringToDate3(String dateStr) {
|
|
|
+ if (dateStr == null) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
|
|
+ Date date = null;
|
|
|
+ String timeString = null;
|
|
|
+ try {
|
|
|
+ date = sdf.parse(dateStr);
|
|
|
+ SimpleDateFormat sdf2= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+
|
|
|
+ timeString = sdf2.format(date);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return timeString;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 日期字符串格式转换
|
|
|
+ *
|
|
|
+ * @param dateStr
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String parseStringToDate1() {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ Date date = new Date();
|
|
|
+ String timeString = null;
|
|
|
+ Long i = date.getTime();
|
|
|
+ Long j = i - 600000;
|
|
|
+ Date newdate = new Date(j);
|
|
|
+ timeString = sdf.format(newdate);
|
|
|
+ return timeString;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 日期字符串格式转换
|
|
|
+ * @param dateStr
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String parseStringToDate2(String dateStr) {
|
|
|
+ if (dateStr == null) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
|
|
+ Date date = null;
|
|
|
+ String timeString = null;
|
|
|
+ try {
|
|
|
+ date = sdf.parse(dateStr);
|
|
|
+ SimpleDateFormat sdf2= new SimpleDateFormat("yyyyMMdd");
|
|
|
+
|
|
|
+ timeString = sdf2.format(date);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return timeString;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static String getFileWithUrl(String url, String filename) {
|
|
|
+
|
|
|
+ Request request = new Request.Builder().url(url).build();
|
|
|
+ try (Response response = OKHTTP_CLIENT.newCall(request).execute()) {
|
|
|
+ if (!response.isSuccessful())
|
|
|
+ throw new IOException("Unexpected code " + response);
|
|
|
+ InputStream inputStream = response.body().source().inputStream();
|
|
|
+ // 本地文件夹目录(下载位置)
|
|
|
+ String folder = PropKit.get("oss_localPath");
|
|
|
+ // 下载文件保存位置
|
|
|
+ String savepath = folder + "/" + filename;
|
|
|
+ BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(new File(savepath)));
|
|
|
+ byte[] data = new byte[1024];
|
|
|
+ int len;
|
|
|
+ int available = inputStream.available();
|
|
|
+ while ((len = inputStream.read(data)) != -1) {
|
|
|
+ bufferedOutputStream.write(data, 0, len);
|
|
|
+ }
|
|
|
+ bufferedOutputStream.flush();
|
|
|
+ bufferedOutputStream.close();
|
|
|
+ inputStream.close();
|
|
|
+
|
|
|
+ return savepath;
|
|
|
+
|
|
|
+ } catch (IOException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ return e.toString();
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void testdld() {
|
|
|
+ try {
|
|
|
+ String filePath = "http://200.200.200.163:8090/X-0-202208261038400267000310351.PNG";
|
|
|
+ String fileNameStr[] = filePath.split("/");
|
|
|
+ String fileName = fileNameStr[fileNameStr.length - 1];
|
|
|
+ String fileStorePath = getFileWithUrl(filePath, fileName);
|
|
|
+ renderText(fileStorePath);
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO: handle exception
|
|
|
+ renderText(e.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static DruidPlugin createConnectedDruidPlugin() {
|
|
|
+
|
|
|
+ return new DruidPlugin(PropKit.get("jdbcUrl_connected"), PropKit.get("user_connected"),PropKit.get("password_connected").trim());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 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));
|
|
|
+ }
|
|
|
+
|
|
|
+ RequestBody formBody = builder.build();
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 日期字符串格式转换
|
|
|
+ * @param dateStr
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private 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(dateStr);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return date;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String parseStringToDate() {
|
|
|
+ SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date date = new Date();
|
|
|
+ String timeString = sdf.format(date);
|
|
|
+ return timeString;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|