abf822fbaba8ef6ff29d6ef309f688d17702fef4.svn-base 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*package com.synyi.edc.controller;
  2. import java.io.IOException;
  3. import java.io.PrintWriter;
  4. import java.util.ArrayList;
  5. import java.util.HashMap;
  6. import java.util.List;
  7. import java.util.Map;
  8. import javax.annotation.Resource;
  9. import javax.servlet.http.HttpServletRequest;
  10. import javax.servlet.http.HttpServletResponse;
  11. import org.springframework.stereotype.Controller;
  12. import org.springframework.ui.Model;
  13. import org.springframework.util.StringUtils;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import com.alibaba.fastjson.JSONObject;
  16. import com.synyi.edc.pojo.Parameter;
  17. import com.synyi.edc.pojo.User;
  18. import com.synyi.edc.service.IUserService;
  19. import com.synyi.edc.util.XmlUtils;
  20. @Controller
  21. @RequestMapping("/user")
  22. public class UserController {
  23. @Resource
  24. private IUserService userService;
  25. @RequestMapping("/showUser")
  26. public String toIndex(HttpServletRequest request,Model model){
  27. int userId = Integer.parseInt(request.getParameter("id"));
  28. User user = this.userService.getUserById(userId);
  29. model.addAttribute("user", user);
  30. System.out.println(XmlUtils.getMapString("orgCode.oneOrg"));
  31. return "showUser";
  32. }
  33. @RequestMapping("/toIndex")
  34. public String toJ(HttpServletRequest request,Model model){
  35. int userId = Integer.parseInt(request.getParameter("id"));
  36. User user = this.userService.getUserById(userId);
  37. model.addAttribute("user", user);
  38. return "index";
  39. }
  40. @RequestMapping("/getAllOrg")
  41. public String getAllOrg(HttpServletRequest request,Model model,HttpServletResponse res){
  42. Map map1 = new HashMap();
  43. map1.put("id", "488099744");
  44. map1.put("name", "福州一院");
  45. Map map2 = new HashMap();
  46. map2.put("id", "48809974x");
  47. map2.put("name", "福州儿院");
  48. Map map3 = new HashMap();
  49. map3.put("id", "488099743");
  50. map3.put("name", "福州中医院");
  51. Map map4 = new HashMap();
  52. map4.put("id", "488099757");
  53. map4.put("name", "福州传染病医院");
  54. List list = new ArrayList();
  55. list.add(map1);
  56. list.add(map2);
  57. list.add(map3);
  58. list.add(map4);
  59. String jsonString = JSONObject.toJSON(list).toString();
  60. res.setContentType("text/plain");
  61. res.setCharacterEncoding("utf-8");
  62. System.out.println(res);
  63. PrintWriter pw = null;
  64. try {
  65. pw = res.getWriter();
  66. pw.write(jsonString);
  67. } catch (IOException e) {
  68. e.printStackTrace();
  69. }finally{
  70. pw.flush();
  71. pw.close();
  72. }
  73. return null;
  74. }
  75. @RequestMapping("/generateSql")
  76. public String generateSql(HttpServletRequest request,Model model,Parameter param,HttpServletResponse res){
  77. List list = new ArrayList();
  78. if(StringUtils.isEmpty(param.getBeginDate())||StringUtils.isEmpty(param.getEndDate())||StringUtils.isEmpty(param.getOrgArray())){
  79. Map map = new HashMap();
  80. map.put("1", "请检查是否有为空的参数");
  81. list.add(map);
  82. printJson(res,list);
  83. }else{
  84. System.out.println(param);
  85. Map map = new HashMap();
  86. String resultSql = null ;
  87. if("visit.in".equals(param.getType())){
  88. resultSql = "select count(distinct patient_id) 人数,count(1) 人次 from visit.inpat_record where org_code in ("+param.getOrgArray()+") and is_valid=true"+
  89. " and in_time between to_date('"+param.getBeginDate()+"','yyyy-mm-dd') and to_date('"+param.getEndDate()+"','yyyy-mm-dd') ";
  90. }else if("visit.out".equals(param.getType())){
  91. resultSql = "select count(distinct patient_id) 人数,count(1) 人次 from visit.outpatient_record where org_code in ("+param.getOrgArray()+") and is_valid=true"+
  92. " and reg_time between to_date('"+param.getBeginDate()+"','yyyy-mm-dd') and to_date('"+param.getEndDate()+"','yyyy-mm-dd') ";
  93. }else if("visit.visit".equals(param.getType())){
  94. resultSql = "select count(distinct patient_id) 人数,count(1) 人次 from visit.visit_record where org_code in ("+param.getOrgArray()+") and is_valid=true"+
  95. " and visit_time between to_date('"+param.getBeginDate()+"','yyyy-mm-dd') and to_date('"+param.getEndDate()+"','yyyy-mm-dd') ";
  96. }
  97. map.put("sql", resultSql);
  98. list.add(map);
  99. printJson(res,list);
  100. }
  101. return null;
  102. }
  103. public void printJson(HttpServletResponse res,List list){
  104. String jsonString = JSONObject.toJSON(list).toString();
  105. res.setContentType("text/plain");
  106. res.setCharacterEncoding("utf-8");
  107. System.out.println(res);
  108. PrintWriter pw = null;
  109. try {
  110. pw = res.getWriter();
  111. pw.write(jsonString);
  112. } catch (IOException e) {
  113. e.printStackTrace();
  114. }finally{
  115. pw.flush();
  116. pw.close();
  117. }
  118. }
  119. }
  120. */