37701066157f88751118e76b7a3293d7852853ae.svn-base 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. package com.sinosoft.lz.system.userFriend.service;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import javax.ws.rs.POST;
  5. import javax.ws.rs.Path;
  6. import javax.ws.rs.ProduceMime;
  7. import org.apache.log4j.Logger;
  8. import com.formaction.Parameter;
  9. import com.formaction.Utils;
  10. import com.formaction.vo.Msg;
  11. import com.sinosoft.lz.system.userFriend.dao.SendMsgDao;
  12. import com.sinosoft.lz.system.userFriend.vo.MsgInfo;
  13. import com.system.push.MessagePush;
  14. @Path("/SendMsgService/")
  15. public class SendMsgService{
  16. private Logger log = Logger.getLogger(this.getClass());
  17. @ProduceMime("application/json")
  18. @POST
  19. @Path("/dwrMsg")
  20. public String dwrMsg(String params){
  21. String msg = Utils.getParameter("msg", params) == null ? "" : Utils.getParameter(
  22. "msg", params);
  23. String method=Utils.getParameter("method", params) == null ? "" : Utils.getParameter(
  24. "method", params);
  25. String url= Utils.getParameter("url", params) == null ? "" : Utils.getParameter(
  26. "url", params);
  27. //"sendMessage"
  28. MessagePush.showMsg(null,null,"<a href=\"javascript:void(0)\" onclick=\"openZ("+url+")\">"+msg+"</a>",method);
  29. return "{}";
  30. }
  31. @SuppressWarnings("unused")
  32. @ProduceMime("application/json")
  33. @POST
  34. @Path("/sendMsg")
  35. public Msg sendMsg(String params) throws ClassNotFoundException {
  36. log.info("params===" + params);
  37. String sendId = Utils.getParameter("sendId", params) == null ? "" : Utils.getParameter(
  38. "sendId", params);
  39. log.info("sendId===" + sendId);
  40. String recivedId = Utils.getParameter("recivedId", params) == null ? "" : Utils
  41. .getParameter("recivedId", params);
  42. log.info("recivedId===" + recivedId);
  43. String msg = Utils.getParameter("msg", params) == null ? "" : Utils.getParameter("msg",
  44. params);
  45. log.info("msg===" + msg);
  46. List<String> recid = new ArrayList<String>();
  47. String[] arr = recivedId.split(";");
  48. for (int i = 0; i < arr.length; i++) {
  49. recid.add(arr[i]);
  50. }
  51. Msg saveMsg = new Msg();
  52. if("".equals(recivedId.trim())){
  53. saveMsg.setInfo("recived");
  54. return saveMsg;
  55. }
  56. if("".equals(msg.trim())){
  57. //saveMsg.setSucsess(new Boolean(true).toString());
  58. saveMsg.setInfo("msg");
  59. return saveMsg;
  60. }
  61. MsgInfo mg = new MsgInfo();
  62. mg.setSendUser(sendId);
  63. mg.setRecivedUser(recid);
  64. mg.setSendMsg(msg);
  65. mg.setFlag("1");
  66. SendMsgDao sd = null;
  67. try {
  68. sd = new SendMsgDao();
  69. } catch (Exception e) {
  70. e.printStackTrace();
  71. }
  72. saveMsg = sd.saveMsg(mg);
  73. boolean addRecentFri = sd.addRecentUser(sendId, recivedId);
  74. return saveMsg;
  75. }
  76. // @ProduceMime("application/json")
  77. // @POST
  78. // @Path("/getRecMsgList")
  79. @ProduceMime("application/json")
  80. @POST
  81. @Path("/getRecMsgList")
  82. public String recivedMsgList(String params) {
  83. log.info("recivedMsgList开始执行");
  84. String userId = Utils.getParameter("userId", params) == null ? "" : Utils.getParameter(
  85. "userId", params);
  86. String query = com.sinosoft.lz.system.Utils.getParameter("userName", params) == null ? ""
  87. : Utils.getParameter("userName", params);
  88. String page = com.sinosoft.lz.system.Utils.getParameter("pager.pageNo", params) == null ? "0"
  89. : Utils.getParameter("pager.pageNo", params);
  90. String pageSize = com.sinosoft.lz.system.Utils.getParameter("pager.pageSize", params) == null ? "10"
  91. : Utils.getParameter("pager.pageSize", params);
  92. log.info("===================" + query);
  93. SendMsgDao smd = new SendMsgDao();
  94. String result = smd.getRecMsgList(userId, query,Integer.parseInt(page),Integer.parseInt(pageSize));
  95. return result;
  96. }
  97. @ProduceMime("application/json")
  98. @POST
  99. @Path("/getRecMsgInfo")
  100. public String recivedMsgInfo(String params) {
  101. log.info("recivedMsgInfo开始执行");
  102. String userId = Utils.getParameter("userId", params) == null ? "" : Utils.getParameter(
  103. "userId", params);
  104. String objectId = Utils.getParameter("objectID", params) == null ? "" : Utils.getParameter(
  105. "objectID", params);
  106. SendMsgDao smd = new SendMsgDao();
  107. String result = smd.getRecMsgInfo(userId, objectId);
  108. log.info("result===" + result);
  109. return result;
  110. }
  111. @ProduceMime("application/json")
  112. @POST
  113. @Path("/PlanInfo")
  114. public String PlanInfo(String params) {
  115. String result="";
  116. log.info("recivedMsgInfo开始执行");
  117. String file_id = Utils.getParameter("file_id", params) == null ? "" : Utils.getParameter(
  118. "file_id", params);
  119. String grade_type = Utils.getParameter("grade_type", params) == null ? "" : Utils.getParameter(
  120. "grade_type", params);
  121. String dept_type = Utils.getParameter("dept_type", params) == null ? "" : Utils.getParameter(
  122. "dept_type", params);
  123. SendMsgDao smd = new SendMsgDao();
  124. result = smd.getPlanInfo(file_id, grade_type,dept_type);
  125. log.info("result===" + result);
  126. return result;
  127. }
  128. @ProduceMime("application/json")
  129. @POST
  130. @Path("/getZhuanxiangPlan")
  131. public String getZhuanxiangPlan(String params) {
  132. String result="";
  133. log.info("recivedMsgInfo开始执行");
  134. String parent_id = Utils.getParameter("parent_id", params) == null ? "" : Utils.getParameter(
  135. "parent_id", params);
  136. String grade_type = Utils.getParameter("grade_type", params) == null ? "" : Utils.getParameter(
  137. "grade_type", params);
  138. SendMsgDao smd = new SendMsgDao();
  139. result = smd.getZhuanxiang(parent_id, grade_type);
  140. log.info("result===" + result);
  141. return result;
  142. }
  143. //取应急组织联系人的JSON
  144. @ProduceMime("application/json")
  145. @POST
  146. @Path("/getOrgLinkInfo")
  147. public String getOrgLinkInfo(String params) {
  148. String result="";
  149. log.info("recivedMsgInfo开始执行");
  150. String file_id = Utils.getParameter("file_id", params) == null ? "" : Utils.getParameter(
  151. "file_id", params);
  152. String grade_type = Utils.getParameter("grade_type", params) == null ? "" : Utils.getParameter(
  153. "grade_type", params);
  154. SendMsgDao smd = new SendMsgDao();
  155. result = smd.getOrgLinkInfo(file_id, grade_type);
  156. log.info("result===" + result);
  157. return result;
  158. }
  159. @POST
  160. @ProduceMime("application/json")
  161. @Path("/PlanInfoEM")
  162. public String PlanInfoEM(String params) {
  163. String result="";
  164. log.info("recivedMsgInfo开始执行");
  165. String file_id = Utils.getParameter("file_id", params) == null ? "" : Utils.getParameter("file_id", params);//预案ID【表214的fd_id】
  166. String grade_type = Utils.getParameter("grade_type", params) == null ? "" : Utils.getParameter("grade_type", params);
  167. SendMsgDao smd = new SendMsgDao();
  168. result = smd.getPlanInfoEM(file_id, grade_type);
  169. log.info("result===" + result);
  170. return result;
  171. }
  172. /**
  173. * 获取突发事件类型中绑定的报表和填报时间
  174. * @param params
  175. * @return
  176. */
  177. @POST
  178. @ProduceMime("application/json")
  179. @Path("/getReportAndPlanTime")
  180. public String getReportAndPlanTime(String params) {
  181. String result="";
  182. String event_type_id = Utils.getParameter("event_type_id", params) == null ? "" : Utils.getParameter("event_type_id", params);//预案ID【表214的fd_id】
  183. String event_level = Utils.getParameter("event_level", params) == null ? "" : Utils.getParameter("event_level", params);
  184. String comp_id = Utils.getParameter("comp_id", params) == null ? "" : Utils.getParameter("comp_id", params);
  185. SendMsgDao smd = new SendMsgDao();
  186. result = smd.getReportAndPlanTime(event_type_id, event_level, comp_id);
  187. log.info("result===" + result);
  188. return result;
  189. }
  190. @ProduceMime("application/json")
  191. @POST
  192. @Path("/getSendMsgList")
  193. public String sendMsgList(String params) {
  194. log.info("sendMsgList开始执行");
  195. String userId = Utils.getParameter("userId", params) == null ? "" : Utils.getParameter(
  196. "userId", params);
  197. String userName = Utils.getParameter("userName", params) == null ? "" : Utils.getParameter(
  198. "userName", params);
  199. String page = Utils.getParameter("pager.pageNo", params) == null ? "0" : Utils.getParameter(
  200. "pager.pageNo", params);
  201. String pageSize = Utils.getParameter("pager.pageSize", params) == null ? "10" : Utils.getParameter(
  202. "pager.pageSize", params);
  203. SendMsgDao smd = new SendMsgDao();
  204. String result = smd.getSendMsgList(userId, userName,Integer.parseInt(page),Integer.parseInt(pageSize));
  205. return result;
  206. }
  207. @ProduceMime("application/json")
  208. @POST
  209. @Path("/getSendMsgInfo")
  210. public String sendMsgInfo(String params) {
  211. log.info("sendMsgInfo开始执行");
  212. String userId = Utils.getParameter("userId", params) == null ? "" : Utils.getParameter(
  213. "userId", params);
  214. String objectId = Utils.getParameter("objectID", params) == null ? "" : Utils.getParameter(
  215. "objectID", params);
  216. SendMsgDao smd = new SendMsgDao();
  217. String result = smd.getSendMsgInfo(userId, objectId);
  218. log.info("result===" + result);
  219. return result;
  220. }
  221. @ProduceMime("application/json")
  222. @POST
  223. @Path("/deleteMsg")
  224. public Msg deleteMsg(String params) {
  225. log.info("删除消息开始执行");
  226. String stat = Utils.getParameter("stat", params) == null ? "" : Utils.getParameter("stat",
  227. params);
  228. String objectId = Utils.getParameter("objectID", params) == null ? "" : Utils.getParameter(
  229. "objectID", params);
  230. Msg result = new Msg();
  231. log.info("stat===" + stat);
  232. log.info("objectid===" + objectId);
  233. if((!"".equals(stat))&&(!"".equals(objectId))){
  234. SendMsgDao smd = new SendMsgDao();
  235. try {
  236. result = smd.deleteMsg(stat, objectId);
  237. return result;
  238. } catch (ClassNotFoundException e) {
  239. e.printStackTrace();
  240. result.setSucsess(new Boolean(false).toString());
  241. result.setInfo(Parameter.DELETE_FAILURE);
  242. return result;
  243. }
  244. }else{
  245. result.setSucsess(new Boolean(false).toString());
  246. result.setInfo(Parameter.DELETE_FAILURE);
  247. return result;
  248. }
  249. }
  250. @SuppressWarnings("unused")
  251. public String hisSend(String param) {
  252. String user = "";
  253. return null;
  254. }
  255. @ProduceMime("application/text")
  256. @POST
  257. @Path("/getReadedCount")
  258. public String getReadedCount(String params){
  259. int num =0;
  260. String userId = Utils.getParameter("userId", params) == null ? "" : Utils.getParameter("userId",
  261. params);
  262. SendMsgDao dao = new SendMsgDao();
  263. try {
  264. num = dao.getReadedCount(userId);
  265. } catch (ClassNotFoundException e) {
  266. // TODO Auto-generated catch block
  267. e.printStackTrace();
  268. }
  269. String result = ""+num;
  270. return result;
  271. }
  272. }