123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- package com.zskk.control;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
- import java.util.UUID;
- import com.jfinal.core.Controller;
- import com.jfinal.plugin.activerecord.Db;
- import com.jfinal.plugin.activerecord.Record;
- import com.zskk.model.Doctors;
- import com.zskk.model.Exams;
- import com.zskk.model.PatientInfos;
- import com.zskk.model.Report;
- import com.zskk.model.Studies;
- import com.zskk.service.ServiceFactory;
- import com.zskk.service.WeixinService;
- public class ViewController extends Controller {
-
- /**
- * 在被连接数据库执行sql语句
- */
- 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());
- }
- }
-
- public void testTask() {
- try {
- //List<Record> d = Db.use("connected").find(this.getPara("sqlStr"));
- // List<Exams> examsd = new ArrayList<Exams>();
- List<Exams> exams = Exams.dao.use("zskk").find("SELECT * FROM pacsonline.exams where exam_status=3 and institution_id=44000003 order by createdAt desc limit 100");
- for (Exams exams2 : exams) {
- Studies studies = Studies.dao.use("zskk").findById(exams2.getStudyId());
- Record recordTemp = Db.use("connected").findFirst("select * from v_all_img_idx@PACSINTERFACE where F_STU_UID=?",studies.getStudyuid());
- if (recordTemp == null) {
- continue;
- }
- Record record = Db.use("connected").findFirst("select * from yxjK where STUDYUID=?",recordTemp.getStr("F_STU_NO"));
- 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.setApplicationDepartment(record.getStr("DEPATMENT"));
- // exams2.setApplicationDoctor(record.getStr("CLINICALDOCTOR"));
- // exams2.setExamStatus(9);
- // exams2.update();
- // WeixinService wService = ServiceFactory.getService(WeixinService.class);
- // wService.requestWeixinQrcode(report.getId());
- // examsd.add(exams2);
- }
- this.renderJson(exams);
- } catch (Exception e) {
- // TODO: handle exception
- String aaString = "";
- StackTraceElement[] stackTraceElements=Thread.currentThread().getStackTrace();
- System.out.println("The stackTraceElements length:"+stackTraceElements.length);
- for(int i=0;i<stackTraceElements.length;i++){
- int d = stackTraceElements[i].getLineNumber();
- aaString = aaString + String.valueOf(d)+"***"+stackTraceElements[i].getMethodName()+"****";
- }
- this.renderText(aaString+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) {
- return "1";
- }
- Doctors doctors = Doctors.dao.use("zskk").findFirst("SELECT * FROM doctors where instr(?,realname) and institution_id=44000003",name);
- if (doctors == null) {
- return "1";
- }
- return doctors.getId();
- }
-
- 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;
- }
-
- }
|