964b93dd3605ea944a6cc1f95972290c332805d7.svn-base 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. package com.sinosoft.nwyj.integration.hessian;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import org.apache.log4j.Logger;
  5. import org.aspectj.lang.JoinPoint;
  6. import org.aspectj.lang.annotation.After;
  7. import org.aspectj.lang.annotation.Aspect;
  8. import org.aspectj.lang.annotation.Before;
  9. import org.springframework.stereotype.Component;
  10. import com.formaction.Utils;
  11. import com.persistence.service.PersistenceFactory;
  12. import com.persistence.service.exception.PersistenceException;
  13. import com.sinosoft.em.baobiao.xianlutingyun.dao.WaitDoDao;
  14. import com.sysmodel.datamodel.xmlmodel.ModelFactory;
  15. import com.system.push.MessagePush;
  16. @Aspect
  17. @Component
  18. public class WaitDoRefreshService {
  19. private final Logger log = Logger.getLogger(getClass());
  20. @After("execution(* com.sinosoft.em.baobiao.xianlutingyun.service.XianlutingyunService.send(..))")
  21. public void ReportSendTask(JoinPoint joinPoint) {
  22. String params = (String) joinPoint.getArgs()[0];
  23. String user_id = Utils.getParameter("userId", params) == null ? ""
  24. : Utils.getParameter("userId", params);
  25. String sql = "select a.user_id,b.role_id from sys_user_info a,sys_user_role_rel b where a.user_id=b.user_id and a.user_id='"
  26. + user_id + "'";
  27. List<String[]> list = new ArrayList<String[]>();
  28. try {
  29. list = PersistenceFactory.getInstance(ModelFactory.getSysmodel())
  30. .getSearchResult(99, sql);
  31. String roles="";
  32. if (list != null && list.size() > 0) {
  33. for(int i=0;i<list.size();i++){
  34. roles+=list.get(i)[1]+",";
  35. }
  36. String[] arr = list.get(0);
  37. WaitDoDao wd = new WaitDoDao();
  38. String result = wd.getDBNum(arr[0], roles, getDept(arr[0]));
  39. log.info("daiban===" + result);
  40. MessagePush.showMsg(null, arr[0], result, "getDbMsg");
  41. }
  42. } catch (Exception e) {
  43. log.error(e.getMessage());
  44. }
  45. }
  46. @After("execution(* com.formaction.service.CRUDServiceImpl.updateWarning(..))")
  47. public void WarningTask(JoinPoint joinPoint) {
  48. String params = (String) joinPoint.getArgs()[0];
  49. String user_id = Utils.getParameter("userId", params) == null ? ""
  50. : Utils.getParameter("userId", params);
  51. String netx_id = Utils.getParameter("netx_id", params) == null ? ""
  52. : Utils.getParameter("netx_id", params);
  53. String isRole = Utils.getParameter("isRole", params) == null ? ""
  54. : Utils.getParameter("isRole", params);
  55. String comp_id = Utils.getParameter("company_id", params) == null ? ""
  56. : Utils.getParameter("company_id", params);
  57. String role_id = Utils.getParameter("role_id", params) == null ? ""
  58. : Utils.getParameter("role_id", params);
  59. if ("1".equals(isRole)) {
  60. String[] arr = comp_id.split(",");
  61. for (int i = 0; i < arr.length; i++) {
  62. String roleSql = "select a.mobile , a.user_id, a.real_name from sys_user_info a, sys_dept_user b where a.user_id = b.user_id and a.user_id in ( select user_id from sys_user_role_rel where role_id ='"
  63. + role_id
  64. + "' ) and ( b.dept_id ='"
  65. + arr[i]
  66. + "' or b.dept_id in ( select dept_id from sys_department where CORP_ID='"
  67. + arr[i] + "' and dept_type='DEPT' ) )";
  68. try {
  69. List<String[]> tempList = PersistenceFactory.getInstance(
  70. ModelFactory.getSysmodel()).getSearchResult(99,
  71. roleSql.toString());
  72. if (tempList != null && tempList.size() > 0) {
  73. for (int j = 0; j < tempList.size(); j++) {
  74. String num = new WaitDoDao().getDBNum(tempList.get(j)[1], role_id,
  75. comp_id) + "";
  76. MessagePush.showMsg(null, tempList.get(j)[1], num,
  77. "getDbMsg");
  78. }
  79. }
  80. } catch (PersistenceException e) {
  81. // TODO Auto-generated catch block
  82. e.printStackTrace();
  83. }
  84. }
  85. } else {
  86. String sql = "select a.user_id,b.role_id from sys_user_info a,sys_user_role_rel b where a.user_id=b.user_id and a.user_id='"
  87. + user_id + "'";
  88. List<String[]> list = new ArrayList<String[]>();
  89. try {
  90. list = PersistenceFactory.getInstance(
  91. ModelFactory.getSysmodel()).getSearchResult(99, sql);
  92. if (list != null && list.size() > 0) {
  93. String[] arr = list.get(0);
  94. WaitDoDao wd = new WaitDoDao();
  95. String result = wd
  96. .getDBNum(arr[0], arr[1], getDept(arr[0]));
  97. log.info("daiban===" + result);
  98. MessagePush.showMsg(null, arr[0], result, "getDbMsg");
  99. }
  100. } catch (Exception e) {
  101. log.error(e.getMessage());
  102. }
  103. }
  104. }
  105. @After("execution(* com.sinosoft.em.baobiao.xianlutingyun.service.XianlutingyunService.SendPoretPlan(..))")
  106. public void ReportPlanTask(JoinPoint joinPoint){
  107. String params = (String) joinPoint.getArgs()[0];
  108. String fd_id=Utils.getParameter("fd_id", params)==null?"":Utils.getParameter("fd_id", params);
  109. String role_id=Utils.getParameter("role_id", params)==null?"":Utils.getParameter("role_id", params);
  110. String sql="select report_dept,comp_id,role_id from report_schedule where fd_objectid ='"+fd_id+"'";
  111. try {
  112. List<String[]>list = PersistenceFactory.getInstance(ModelFactory.getSysmodel())
  113. .getSearchResult(99, sql);
  114. if(list!=null&&list.size()>0){
  115. String report_dept=list.get(0)[0];
  116. String comp_id=list.get(0)[1];
  117. String role_ids=list.get(0)[2];
  118. if(report_dept.startsWith("应急办")){
  119. String[]arr=report_dept.split(":")[1].split("[|]");
  120. List<String>roleList=new ArrayList<String>();
  121. for(int j=0;j<arr.length;j++){
  122. roleList.add(arr[j].split(";")[0]);
  123. }
  124. for (int i = 0; i < roleList.size(); i++) {
  125. String roleSql = "select a.mobile , a.user_id, a.real_name from sys_user_info a, sys_dept_user b where a.user_id = b.user_id and a.user_id in ( select user_id from sys_user_role_rel where role_id ='"
  126. + roleList.get(i)
  127. + "' ) and ( b.dept_id ='"
  128. + comp_id
  129. + "' or b.dept_id in ( select dept_id from sys_department where CORP_ID='"
  130. + comp_id + "' and dept_type='DEPT' ) )";
  131. try {
  132. List<String[]> tempList = PersistenceFactory.getInstance(
  133. ModelFactory.getSysmodel()).getSearchResult(99,
  134. roleSql.toString());
  135. if (tempList != null && tempList.size() > 0) {
  136. for (int j = 0; j < tempList.size(); j++) {
  137. String num = new WaitDoDao().getDBNum(tempList.get(j)[1], roleList.get(i),
  138. comp_id) + "";
  139. MessagePush.showMsg(null, tempList.get(j)[1], num,
  140. "getDbMsg");
  141. }
  142. }
  143. } catch (PersistenceException e) {
  144. // TODO Auto-generated catch block
  145. e.printStackTrace();
  146. }
  147. }
  148. }else{
  149. //String[]arr=report_dept.split(":")[1].split("[|]");
  150. String[] type=report_dept.split(":")[1].split(";")[0].split(",");
  151. String[]dept=report_dept.split(":")[1].split(";")[1].split(",");
  152. String types="";
  153. for(int i=0;i<type.length;i++){
  154. if(i==0){
  155. types="'"+type[i]+"'";
  156. }else{
  157. types=types+",'"+type[i]+"'";
  158. }
  159. }
  160. // String rolsSql="select distinct role_id from BM_MAPFORREPORT where report_type in("+types+")";
  161. // List<String[]> tempList = PersistenceFactory.getInstance(
  162. // ModelFactory.getSysmodel()).getSearchResult(99,
  163. // rolsSql.toString());
  164. // if(tempList!=null&&tempList.size()>0){
  165. // for(int j=0;j<tempList.size();j++){
  166. // roleList.add(tempList.get(j)[0]);
  167. // }
  168. // }
  169. for(int k=0;k<dept.length;k++){
  170. // for(int m=0;m<roleList.size();m++){
  171. String roleSql = "select a.mobile , a.user_id, a.real_name from sys_user_info a, sys_dept_user b where a.user_id = b.user_id and a.user_id in ( select user_id from sys_user_role_rel where role_id ='"
  172. + role_ids
  173. + "' ) and ( b.dept_id ='"
  174. + dept[k]
  175. + "' or b.dept_id in ( select dept_id from sys_department where CORP_ID='"
  176. + dept[k] + "' and dept_type='DEPT' ) )";
  177. try {
  178. List<String[]> tempList1 = PersistenceFactory.getInstance(
  179. ModelFactory.getSysmodel()).getSearchResult(99,
  180. roleSql.toString());
  181. if (tempList1 != null && tempList1.size() > 0) {
  182. for (int j = 0; j < tempList1.size(); j++) {
  183. String num = new WaitDoDao().getDBNum(tempList1.get(j)[1], role_ids,
  184. comp_id) + "";
  185. MessagePush.showMsg(null, tempList1.get(j)[1], num,
  186. "getDbMsg");
  187. }
  188. }
  189. } catch (PersistenceException e) {
  190. // TODO Auto-generated catch block
  191. e.printStackTrace();
  192. }
  193. // }
  194. }
  195. }
  196. }
  197. } catch (PersistenceException e) {
  198. // TODO Auto-generated catch block
  199. e.printStackTrace();
  200. }
  201. }
  202. public String getDept(String userId) {
  203. String result = "";
  204. String sql = "select b.corp_id from sys_user_info a,sys_department b where a.dept_id=b.dept_id and a.user_id='"
  205. + userId + "'";
  206. List<String[]> list = new ArrayList<String[]>();
  207. try {
  208. list = PersistenceFactory.getInstance(ModelFactory.getSysmodel())
  209. .getSearchResult(99, sql);
  210. if (list != null && list.size() > 0) {
  211. String[] arr = list.get(0);
  212. // if ("CORP".equals(arr[1])) {
  213. result = arr[0];
  214. // } else if ("DEPT".equals(arr[1])) {
  215. // result = getComp(arr[0]);
  216. // }
  217. }
  218. } catch (Exception e) {
  219. log.error(e.getMessage());
  220. }
  221. return result;
  222. }
  223. public String getComp(String dept_id) {
  224. String result = "";
  225. String sql = "select a.dept_id,a.dept_type from sys_department a,sys_department b where a.dept_id=b.parent_id and b.dept_id='"
  226. + dept_id + "'";
  227. List<String[]> list = new ArrayList<String[]>();
  228. try {
  229. list = PersistenceFactory.getInstance(ModelFactory.getSysmodel())
  230. .getSearchResult(99, sql);
  231. if (list != null && list.size() > 0) {
  232. String[] arr = list.get(0);
  233. if ("CORP".equals(arr[1])) {
  234. result = arr[0];
  235. } else if ("DEPT".equals(arr[1])) {
  236. getComp(arr[0]);
  237. }
  238. }
  239. } catch (Exception e) {
  240. log.error(e.getMessage());
  241. }
  242. return result;
  243. }
  244. }