123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- package com.zskk.control;
- import java.io.File;
- 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.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.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());
- }
- }
- public void testConn() {
- 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());
- }
- }
-
- public void testtime() {
- SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date date = new Date();
- long dInteger =date.getTime()-360000;
- String daString = sdf.format(new Date(dInteger));
- this.renderText(daString);
- }
-
-
- public void name() {
- try {
- List<Record> record = Db.use("connected").find("select * from tjpacs.V_ZSKK_WEBPACS_IMAGE where STUDYID=?","1832510");
- for (Record record2 : record) {
- Request request = new Request.Builder()
- .url(record2.getStr("HTTP_URL"))
- .build();
- String fileName = record2.getStr("INSUID");
- // String fileName = "aaaa";
- try (Response response = OKHTTP_CLIENT.newCall(request).execute()) {
- if (!response.isSuccessful())
- throw new IOException("Unexpected code " + response);
- String dirName = "/home/zskk/桌面/DICOM_URL";
- File file = new File(dirName);
- if (!file.exists()) {
- file.mkdir();
- }
- if (response != null) {
- InputStream is = response.body().byteStream();
- FileOutputStream fos = new FileOutputStream(new File(dirName + "/" + fileName));
- int len = 0;
- byte[] buffer = new byte[2048];
- while (-1 != (len = is.read(buffer))) {
- fos.write(buffer, 0, len);
- }
-
- fos.flush();
- fos.close();
- is.close();
- File filen2 = new File(dirName + "/" + fileName);
- File filen = new File(dirName + "/" + fileName+".dcm");
- filen2.renameTo(filen);
- }
-
- } catch (IOException e) {
- // TODO Auto-generated catch block
- this.renderText("1*"+e.toString());
- }
- }
- } catch (Exception e) {
- // TODO: handle exception
- this.renderText(e.toString());
- }
- this.renderText("succ");
- }
-
- //报告匹配
- public void sdtb() {
- DataService dService = ServiceFactory.getService(DataService.class);
- List<Record> records = Db.use("connected").find("SELECT *FROM zskk_reportinfo WHERE REVIEWDATE >TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')AND REVIEWDATE <= TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')",this.getPara("from"),this.getPara("to"));
- for (Record record : records) {
- try {
- if (record.getStr("IMPRESSION") == null && record.getStr("DESCRIPTION") == null) {
- continue;
- }
- Map<String, String> params = new HashMap<>();
- // 1:exam_id 2:patient_num 3:accession_num 4:study_uid
- params.put("type", "3");
- params.put("institution_id", PropKit.get("institution_id"));
- params.put("code", record.getStr("ACCESSIONNUMBER"));
- //报告医生姓名
- params.put("report_doctor_name", record.getStr("REPORTDOCTER"));
- //报告时间
- params.put("report_datetime", record.getStr("REPORTDATE"));
- //审核医生姓名
- params.put("review_doctor_name", record.getStr("REVIEWDOCTOR"));
- //审核时间
- params.put("review_datetime", record.getStr("REVIEWDATE"));
- //确认医生姓名
- params.put("confirm_doctor_name", record.getStr("REVIEWDOCTOR"));
- //确认时间
- params.put("confirm_datetime", record.getStr("REVIEWDATE"));
- //意见建议
- 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", "");
- //临床诊断
- params.put("clin_diag", record.getStr("DIAGNOSIS")==null?"":record.getStr("DIAGNOSIS"));
- //症状
- params.put("clin_symp", "");
- //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", record.getStr("RESULT").equals("1")?"2":"1");
- params.put("hopitalized_no", record.getStr("PATIENTID"));
-
- dService.saveReport(params);
-
- } catch (Exception e) {
- // TODO: handle exception
- continue;
- }
- }
- renderText(records.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 String parseStringToDate() {
- SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date date = new Date();
- long dInteger =date.getTime()-65000;
- String daString = sdf.format(new Date(dInteger));
- return daString;
-
- }
- 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);
- }
- }
|