5c18228ad072de43b3aa2584d10a08b698eff225.svn-base 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. package com.sinosoft.em.baobiao.xianlutingyun.service;
  2. import java.io.UnsupportedEncodingException;
  3. import java.sql.Connection;
  4. import java.sql.PreparedStatement;
  5. import java.sql.ResultSet;
  6. import java.sql.SQLException;
  7. import java.text.ParseException;
  8. import java.text.SimpleDateFormat;
  9. import java.util.ArrayList;
  10. import java.util.Date;
  11. import java.util.List;
  12. import java.util.Map;
  13. import javax.ws.rs.POST;
  14. import javax.ws.rs.Path;
  15. import javax.ws.rs.ProduceMime;
  16. import org.apache.log4j.Logger;
  17. import com.formaction.Utils;
  18. import com.formaction.vo.Msg;
  19. import com.persistence.DbConnection;
  20. import com.sinosoft.em.baobiao.xianlutingyun.dao.ReportPlanDao;
  21. @Path("/getPlanRequireService/")
  22. public class GetPlanRequireServiceImpl implements GetPlanRequireService {
  23. private final Logger log = Logger.getLogger(getClass());
  24. @POST
  25. @ProduceMime("application/json")
  26. @Path("/getPlanRequire/")
  27. public String getPlanRequire(String params) {
  28. String warning_number = Utils.getParameter("warning_number", params) ==null ? "":Utils.getParameter("warning_number", params);
  29. log.info("warning_number========="+warning_number);
  30. String comp = Utils.getParameter("comp", params)==null ?"":Utils.getParameter("comp", params);
  31. //log.info(warning_number+"=========="+comp);
  32. Connection conn = null;
  33. PreparedStatement ps = null;
  34. ResultSet rs = null;
  35. DbConnection db = new DbConnection();
  36. //String sql = "select start_time,end_time,dept_name,fill_in_schedule, round_time,temporary_time from report_schedule where warning_number = ? and dept_id =?";
  37. String sql = "select start_time,end_time,report_dept,fill_in_schedule, round_time,temporary_time from report_schedule where fd_objectid ='"+warning_number+"'";
  38. log.info(sql+"=============sql");
  39. List<String> list = new ArrayList<String>();
  40. StringBuffer sb = new StringBuffer();
  41. try {
  42. conn = db.getConnection();
  43. ps = conn.prepareStatement(sql);
  44. //ps.setString(1, warning_number);
  45. //ps.setString(2, comp);
  46. //log.info(sql+"===========getPlanRequire.sql");
  47. rs = ps.executeQuery();
  48. while(rs.next()){
  49. sb.append("{");
  50. sb.append("\"START_TIME\""+":"+"\""+rs.getString("START_TIME")+"\""+",");
  51. sb.append("\"END_TIME\""+":"+"\""+rs.getString("END_TIME")+"\""+",");
  52. sb.append("\"DEPT_NAME\""+":"+"\""+rs.getString("REPORT_DEPT")+"\""+",");
  53. sb.append("\"FILL_IN_SCHEDULE\""+":"+"\""+rs.getString("FILL_IN_SCHEDULE")+"\""+",");
  54. sb.append("\"ROUND_TIME\""+":"+"\""+rs.getString("ROUND_TIME")+"\""+",");
  55. sb.append("\"TEMPORARY_TIME\""+":"+"\""+rs.getString("TEMPORARY_TIME")+"\"");
  56. sb.append("},");
  57. }
  58. if(sb.lastIndexOf(",")>-1){
  59. sb.deleteCharAt(sb.lastIndexOf(","));
  60. list.add(sb.toString());
  61. }
  62. } catch (ClassNotFoundException e) {
  63. log.error(e.getMessage());
  64. } catch (SQLException e) {
  65. log.error(e.getMessage());
  66. }finally{
  67. db.close(rs);
  68. db.close(ps);
  69. db.close(conn);
  70. }
  71. String result = "{\"rows\":"+list+"}";
  72. log.info(result+"========getPlanRequire");
  73. return result;
  74. }
  75. @POST
  76. @ProduceMime("application/json")
  77. @Path("/createPlanByAlert/")
  78. public Msg createPlanByAlert(String params){
  79. String WARNING_NUMBER = Utils.getParameter("WARNING_NUMBER", params) ==null ? "":Utils.getParameter("WARNING_NUMBER", params);
  80. /*SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  81. String nowDate=sdf.format(new Date());
  82. String START_TIME = nowDate;*/
  83. try {
  84. String params1 = java.net.URLDecoder.decode(params, "UTF-8");
  85. log.info(params1);
  86. } catch (UnsupportedEncodingException e1) {
  87. // TODO Auto-generated catch block
  88. e1.printStackTrace();
  89. }
  90. String START_TIME= Utils.getParameter("START_TIME", params) ==null ? "":Utils.getParameter("START_TIME", params);
  91. String FILL_IN_SCHEDULE = Utils.getParameter("FILL_IN_SCHEDULE", params) ==null ? "":Utils.getParameter("FILL_IN_SCHEDULE", params);
  92. String REPORT_DEPT = Utils.getParameter("REPORT_DEPT", params) ==null ? "":Utils.getParameter("REPORT_DEPT", params);
  93. String DEPT_ID = Utils.getParameter("DEPT_ID", params) ==null ? "":Utils.getParameter("DEPT_ID", params);
  94. String ROUND_TIME = Utils.getParameter("ROUND_TIME", params) ==null ? "":Utils.getParameter("ROUND_TIME", params);
  95. String TEMPORARY_TIME = Utils.getParameter("TEMPORARY_TIME", params) ==null ? "":Utils.getParameter("TEMPORARY_TIME", params);
  96. String USER_ID = Utils.getParameter("USER_ID", params) ==null ? "":Utils.getParameter("USER_ID", params);
  97. String ROLE_ID = Utils.getParameter("ROLE_ID", params) ==null ? "":Utils.getParameter("ROLE_ID", params);
  98. String deptName = Utils.getParameter("deptName", params) ==null ? "":Utils.getParameter("deptName", params);
  99. String real_name = Utils.getParameter("real_name", params) ==null ? "":Utils.getParameter("real_name", params);
  100. String alertName = Utils.getParameter("alertName", params) ==null ? "":Utils.getParameter("alertName", params);
  101. String areaId = Utils.getParameter("areaId", params) ==null ? "":Utils.getParameter("areaId", params);
  102. String areaName = Utils.getParameter("areaName", params) ==null ? "":Utils.getParameter("areaName", params);
  103. String isAlert = Utils.getParameter("isAlert", params) ==null ? "":Utils.getParameter("isAlert", params);
  104. String alertLevel = Utils.getParameter("alertLevel", params) ==null ? "":Utils.getParameter("alertLevel", params);
  105. String eventType = Utils.getParameter("eventType", params) ==null ? "":Utils.getParameter("eventType", params);
  106. String eventId = Utils.getParameter("eventId", params) ==null ? "":Utils.getParameter("eventId", params);
  107. Msg m=new Msg();
  108. ReportPlanDao rpd=new ReportPlanDao();
  109. try {
  110. m=rpd.createPlanByAlert(WARNING_NUMBER, START_TIME,FILL_IN_SCHEDULE,REPORT_DEPT,DEPT_ID,ROUND_TIME,TEMPORARY_TIME,USER_ID,ROLE_ID,deptName,real_name,alertName,areaId,areaName,isAlert,alertLevel,eventType,eventId);
  111. } catch (Exception e) {
  112. // TODO Auto-generated catch block
  113. e.printStackTrace();
  114. }
  115. return m;
  116. }
  117. /**
  118. * 生成报告填报要求
  119. * @param params
  120. * @return
  121. */
  122. @POST
  123. @ProduceMime("application/json")
  124. @Path("/createBGPlanByAlert/")
  125. public Msg createBGPlanByAlert(String params){
  126. String WARNING_NUMBER = Utils.getParameter("WARNING_NUMBER", params) ==null ? "":Utils.getParameter("WARNING_NUMBER", params);
  127. String START_TIME = Utils.getParameter("START_TIME", params) ==null ? "":Utils.getParameter("START_TIME", params);
  128. String FILL_IN_SCHEDULE = Utils.getParameter("FILL_IN_SCHEDULE", params) ==null ? "":Utils.getParameter("FILL_IN_SCHEDULE", params);
  129. String REPORT_DEPT = Utils.getParameter("REPORT_DEPT", params) ==null ? "":Utils.getParameter("REPORT_DEPT", params);
  130. String DEPT_ID = Utils.getParameter("DEPT_ID", params) ==null ? "":Utils.getParameter("DEPT_ID", params);
  131. String ROUND_TIME = Utils.getParameter("ROUND_TIME", params) ==null ? "":Utils.getParameter("ROUND_TIME", params);
  132. String TEMPORARY_TIME = Utils.getParameter("TEMPORARY_TIME", params) ==null ? "":Utils.getParameter("TEMPORARY_TIME", params);
  133. String USER_ID = Utils.getParameter("USER_ID", params) ==null ? "":Utils.getParameter("USER_ID", params);
  134. String ROLE_ID = Utils.getParameter("ROLE_ID", params) ==null ? "":Utils.getParameter("ROLE_ID", params);
  135. String deptName = Utils.getParameter("deptName", params) ==null ? "":Utils.getParameter("deptName", params);
  136. String real_name = Utils.getParameter("real_name", params) ==null ? "":Utils.getParameter("real_name", params);
  137. String alertName = Utils.getParameter("alertName", params) ==null ? "":Utils.getParameter("alertName", params);
  138. String areaId = Utils.getParameter("areaId", params) ==null ? "":Utils.getParameter("areaId", params);
  139. String areaName = Utils.getParameter("areaName", params) ==null ? "":Utils.getParameter("areaName", params);
  140. String isAlert = Utils.getParameter("isAlert", params) ==null ? "":Utils.getParameter("isAlert", params);
  141. String alertLevel = Utils.getParameter("alertLevel", params) ==null ? "":Utils.getParameter("alertLevel", params);
  142. Msg m=new Msg();
  143. ReportPlanDao rpd=new ReportPlanDao();
  144. try {
  145. m=rpd.createBGPlanByAlert(WARNING_NUMBER, START_TIME,FILL_IN_SCHEDULE,REPORT_DEPT,DEPT_ID,ROUND_TIME,TEMPORARY_TIME,USER_ID,ROLE_ID,deptName,real_name,alertName,areaId,areaName,isAlert,alertLevel);
  146. } catch (Exception e) {
  147. // TODO Auto-generated catch block
  148. e.printStackTrace();
  149. }
  150. return m;
  151. }
  152. /**
  153. * 生成临时性时间填报要求
  154. * @param params
  155. * @return
  156. */
  157. @POST
  158. @ProduceMime("application/json")
  159. @Path("/createTemporaryPlanByAlert/")
  160. public Msg createTemporaryPlanByAlert(String params){
  161. String WARNING_NUMBER = Utils.getParameter("WARNING_NUMBER", params) ==null ? "":Utils.getParameter("WARNING_NUMBER", params);
  162. String START_TIME = Utils.getParameter("START_TIME", params) ==null ? "":Utils.getParameter("START_TIME", params);
  163. String FILL_IN_SCHEDULE = Utils.getParameter("FILL_IN_SCHEDULE", params) ==null ? "":Utils.getParameter("FILL_IN_SCHEDULE", params);
  164. String REPORT_DEPT = Utils.getParameter("REPORT_DEPT", params) ==null ? "":Utils.getParameter("REPORT_DEPT", params);
  165. String DEPT_ID = Utils.getParameter("DEPT_ID", params) ==null ? "":Utils.getParameter("DEPT_ID", params);
  166. String ROUND_TIME = Utils.getParameter("ROUND_TIME", params) ==null ? "":Utils.getParameter("ROUND_TIME", params);
  167. String TEMPORARY_TIME = Utils.getParameter("TEMPORARY_TIME", params) ==null ? "":Utils.getParameter("TEMPORARY_TIME", params);
  168. String USER_ID = Utils.getParameter("USER_ID", params) ==null ? "":Utils.getParameter("USER_ID", params);
  169. String ROLE_ID = Utils.getParameter("ROLE_ID", params) ==null ? "":Utils.getParameter("ROLE_ID", params);
  170. String deptName = Utils.getParameter("deptName", params) ==null ? "":Utils.getParameter("deptName", params);
  171. String real_name = Utils.getParameter("real_name", params) ==null ? "":Utils.getParameter("real_name", params);
  172. String alertName = Utils.getParameter("alertName", params) ==null ? "":Utils.getParameter("alertName", params);
  173. String areaId = Utils.getParameter("areaId", params) ==null ? "":Utils.getParameter("areaId", params);
  174. String areaName = Utils.getParameter("areaName", params) ==null ? "":Utils.getParameter("areaName", params);
  175. String isAlert = Utils.getParameter("isAlert", params) ==null ? "":Utils.getParameter("isAlert", params);
  176. String alertLevel = Utils.getParameter("alertLevel", params) ==null ? "":Utils.getParameter("alertLevel", params);
  177. Msg m=new Msg();
  178. ReportPlanDao rpd=new ReportPlanDao();
  179. try {
  180. m=rpd.createTemporaryPlanByAlert(WARNING_NUMBER, START_TIME,FILL_IN_SCHEDULE,REPORT_DEPT,DEPT_ID,ROUND_TIME,TEMPORARY_TIME,USER_ID,ROLE_ID,deptName,real_name,alertName,areaId,areaName,isAlert,alertLevel);
  181. } catch (Exception e) {
  182. // TODO Auto-generated catch block
  183. e.printStackTrace();
  184. }
  185. return m;
  186. }
  187. /**
  188. * 发布报表填报计划
  189. * @param params
  190. * @return
  191. */
  192. @POST
  193. @ProduceMime("application/json")
  194. @Path("/updatePlan/")
  195. public Msg updatePlan(String params){
  196. Msg m=new Msg();
  197. String OLD_WARN = Utils.getParameter("OLD_WARN", params) ==null ? "":Utils.getParameter("OLD_WARN", params);
  198. String NEW_WARN = Utils.getParameter("NEW_WARN", params) ==null ? "":Utils.getParameter("NEW_WARN", params);
  199. String COMP_ID = Utils.getParameter("COMP_ID", params) ==null ? "":Utils.getParameter("COMP_ID", params);
  200. String IS_ALERT = Utils.getParameter("isAlert", params) ==null ? "":Utils.getParameter("isAlert", params);
  201. String circleTime = Utils.getParameter("circleTime", params) ==null ? "":Utils.getParameter("circleTime", params);
  202. String temporaryTime = Utils.getParameter("temporaryTime", params) ==null ? "":Utils.getParameter("temporaryTime", params);
  203. String alertName = Utils.getParameter("alertName", params) ==null ? "":Utils.getParameter("alertName", params);
  204. String areaId = Utils.getParameter("areaId", params) ==null ? "":Utils.getParameter("areaId", params);
  205. String areaName = Utils.getParameter("areaName", params) ==null ? "":Utils.getParameter("areaName", params);
  206. String alertLevel = Utils.getParameter("alertLevel", params) ==null ? "":Utils.getParameter("alertLevel", params);
  207. ReportPlanDao rpd=new ReportPlanDao();
  208. try {
  209. m=rpd.updatePlan(NEW_WARN, OLD_WARN, COMP_ID,IS_ALERT,circleTime,temporaryTime,alertName,areaId,areaName,alertLevel);
  210. } catch (ClassNotFoundException e) {
  211. // TODO Auto-generated catch block
  212. e.printStackTrace();
  213. }
  214. return m;
  215. }
  216. /**
  217. * 解除报告填报计划
  218. * @param params
  219. * @return
  220. */
  221. @POST
  222. @ProduceMime("application/json")
  223. @Path("/releasePlan/")
  224. public Msg releasePlan(String params){
  225. Msg m=new Msg();
  226. String WARNING_NUMBER = Utils.getParameter("WARNING_NUMBER", params) ==null ? "":Utils.getParameter("WARNING_NUMBER", params);//预警编号
  227. String COMP_ID = Utils.getParameter("COMP_ID", params) ==null ? "":Utils.getParameter("COMP_ID", params);//单位ID
  228. String IS_ALERT = Utils.getParameter("IS_ALERT", params) ==null ? "":Utils.getParameter("IS_ALERT", params);//预警-0或响应-1
  229. ReportPlanDao rpd=new ReportPlanDao();
  230. try {
  231. m=rpd.releasePlan(WARNING_NUMBER, COMP_ID,IS_ALERT);
  232. } catch (ClassNotFoundException e) {
  233. // TODO Auto-generated catch block
  234. e.printStackTrace();
  235. }
  236. return m;
  237. }
  238. /**
  239. * 解除报告填报计划
  240. * @param params
  241. * @return
  242. */
  243. @POST
  244. @ProduceMime("application/json")
  245. @Path("/updateCirclePlan/")
  246. public Msg updateCirclePlan(String params){
  247. Msg m=new Msg();
  248. String WARNING_NUMBER = Utils.getParameter("WARNING_NUMBER", params) ==null ? "":Utils.getParameter("WARNING_NUMBER", params);
  249. String COMP_ID = Utils.getParameter("COMP_ID", params) ==null ? "":Utils.getParameter("COMP_ID", params);
  250. String IS_ALERT = Utils.getParameter("IS_ALERT", params) ==null ? "":Utils.getParameter("IS_ALERT", params);
  251. String time = Utils.getParameter("time", params) ==null ? "":Utils.getParameter("time", params);
  252. ReportPlanDao rpd=new ReportPlanDao();
  253. try {
  254. m=rpd.updateCirclePlan(WARNING_NUMBER, COMP_ID,IS_ALERT,time);
  255. } catch (Exception e) {
  256. // TODO Auto-generated catch block
  257. e.printStackTrace();
  258. }
  259. return m;
  260. }
  261. }