123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- package com.sinosoft.nwyj.integration.hessian;
- import java.util.ArrayList;
- import java.util.List;
- import org.apache.log4j.Logger;
- import org.aspectj.lang.JoinPoint;
- import org.aspectj.lang.annotation.After;
- import org.aspectj.lang.annotation.Aspect;
- import org.aspectj.lang.annotation.Before;
- import org.springframework.stereotype.Component;
- import com.formaction.Utils;
- import com.persistence.service.PersistenceFactory;
- import com.persistence.service.exception.PersistenceException;
- import com.sinosoft.em.baobiao.xianlutingyun.dao.WaitDoDao;
- import com.sysmodel.datamodel.xmlmodel.ModelFactory;
- import com.system.push.MessagePush;
- @Aspect
- @Component
- public class WaitDoRefreshService {
- private final Logger log = Logger.getLogger(getClass());
- @After("execution(* com.sinosoft.em.baobiao.xianlutingyun.service.XianlutingyunService.send(..))")
- public void ReportSendTask(JoinPoint joinPoint) {
- String params = (String) joinPoint.getArgs()[0];
- String user_id = Utils.getParameter("userId", params) == null ? ""
- : Utils.getParameter("userId", params);
- 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='"
- + user_id + "'";
- List<String[]> list = new ArrayList<String[]>();
- try {
- list = PersistenceFactory.getInstance(ModelFactory.getSysmodel())
- .getSearchResult(99, sql);
- String roles="";
- if (list != null && list.size() > 0) {
- for(int i=0;i<list.size();i++){
- roles+=list.get(i)[1]+",";
- }
- String[] arr = list.get(0);
- WaitDoDao wd = new WaitDoDao();
- String result = wd.getDBNum(arr[0], roles, getDept(arr[0]));
- log.info("daiban===" + result);
- MessagePush.showMsg(null, arr[0], result, "getDbMsg");
- }
- } catch (Exception e) {
- log.error(e.getMessage());
- }
- }
- @After("execution(* com.formaction.service.CRUDServiceImpl.updateWarning(..))")
- public void WarningTask(JoinPoint joinPoint) {
- String params = (String) joinPoint.getArgs()[0];
- String user_id = Utils.getParameter("userId", params) == null ? ""
- : Utils.getParameter("userId", params);
- String netx_id = Utils.getParameter("netx_id", params) == null ? ""
- : Utils.getParameter("netx_id", params);
- String isRole = Utils.getParameter("isRole", params) == null ? ""
- : Utils.getParameter("isRole", params);
- String comp_id = Utils.getParameter("company_id", params) == null ? ""
- : Utils.getParameter("company_id", params);
- String role_id = Utils.getParameter("role_id", params) == null ? ""
- : Utils.getParameter("role_id", params);
- if ("1".equals(isRole)) {
- String[] arr = comp_id.split(",");
- for (int i = 0; i < arr.length; i++) {
- 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 ='"
- + role_id
- + "' ) and ( b.dept_id ='"
- + arr[i]
- + "' or b.dept_id in ( select dept_id from sys_department where CORP_ID='"
- + arr[i] + "' and dept_type='DEPT' ) )";
- try {
- List<String[]> tempList = PersistenceFactory.getInstance(
- ModelFactory.getSysmodel()).getSearchResult(99,
- roleSql.toString());
- if (tempList != null && tempList.size() > 0) {
- for (int j = 0; j < tempList.size(); j++) {
- String num = new WaitDoDao().getDBNum(tempList.get(j)[1], role_id,
- comp_id) + "";
- MessagePush.showMsg(null, tempList.get(j)[1], num,
- "getDbMsg");
- }
- }
- } catch (PersistenceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- } else {
- 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='"
- + user_id + "'";
- List<String[]> list = new ArrayList<String[]>();
- try {
- list = PersistenceFactory.getInstance(
- ModelFactory.getSysmodel()).getSearchResult(99, sql);
- if (list != null && list.size() > 0) {
- String[] arr = list.get(0);
- WaitDoDao wd = new WaitDoDao();
- String result = wd
- .getDBNum(arr[0], arr[1], getDept(arr[0]));
- log.info("daiban===" + result);
- MessagePush.showMsg(null, arr[0], result, "getDbMsg");
- }
- } catch (Exception e) {
- log.error(e.getMessage());
- }
- }
- }
- @After("execution(* com.sinosoft.em.baobiao.xianlutingyun.service.XianlutingyunService.SendPoretPlan(..))")
- public void ReportPlanTask(JoinPoint joinPoint){
- String params = (String) joinPoint.getArgs()[0];
- String fd_id=Utils.getParameter("fd_id", params)==null?"":Utils.getParameter("fd_id", params);
- String role_id=Utils.getParameter("role_id", params)==null?"":Utils.getParameter("role_id", params);
- String sql="select report_dept,comp_id,role_id from report_schedule where fd_objectid ='"+fd_id+"'";
- try {
- List<String[]>list = PersistenceFactory.getInstance(ModelFactory.getSysmodel())
- .getSearchResult(99, sql);
- if(list!=null&&list.size()>0){
- String report_dept=list.get(0)[0];
- String comp_id=list.get(0)[1];
- String role_ids=list.get(0)[2];
- if(report_dept.startsWith("应急办")){
- String[]arr=report_dept.split(":")[1].split("[|]");
- List<String>roleList=new ArrayList<String>();
- for(int j=0;j<arr.length;j++){
- roleList.add(arr[j].split(";")[0]);
- }
- for (int i = 0; i < roleList.size(); i++) {
- 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 ='"
- + roleList.get(i)
- + "' ) and ( b.dept_id ='"
- + comp_id
- + "' or b.dept_id in ( select dept_id from sys_department where CORP_ID='"
- + comp_id + "' and dept_type='DEPT' ) )";
- try {
- List<String[]> tempList = PersistenceFactory.getInstance(
- ModelFactory.getSysmodel()).getSearchResult(99,
- roleSql.toString());
- if (tempList != null && tempList.size() > 0) {
- for (int j = 0; j < tempList.size(); j++) {
- String num = new WaitDoDao().getDBNum(tempList.get(j)[1], roleList.get(i),
- comp_id) + "";
- MessagePush.showMsg(null, tempList.get(j)[1], num,
- "getDbMsg");
- }
- }
- } catch (PersistenceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }else{
- //String[]arr=report_dept.split(":")[1].split("[|]");
- String[] type=report_dept.split(":")[1].split(";")[0].split(",");
- String[]dept=report_dept.split(":")[1].split(";")[1].split(",");
- String types="";
- for(int i=0;i<type.length;i++){
- if(i==0){
- types="'"+type[i]+"'";
- }else{
- types=types+",'"+type[i]+"'";
- }
- }
- // String rolsSql="select distinct role_id from BM_MAPFORREPORT where report_type in("+types+")";
- // List<String[]> tempList = PersistenceFactory.getInstance(
- // ModelFactory.getSysmodel()).getSearchResult(99,
- // rolsSql.toString());
- // if(tempList!=null&&tempList.size()>0){
- // for(int j=0;j<tempList.size();j++){
- // roleList.add(tempList.get(j)[0]);
- // }
- // }
- for(int k=0;k<dept.length;k++){
- // for(int m=0;m<roleList.size();m++){
- 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 ='"
- + role_ids
- + "' ) and ( b.dept_id ='"
- + dept[k]
- + "' or b.dept_id in ( select dept_id from sys_department where CORP_ID='"
- + dept[k] + "' and dept_type='DEPT' ) )";
- try {
- List<String[]> tempList1 = PersistenceFactory.getInstance(
- ModelFactory.getSysmodel()).getSearchResult(99,
- roleSql.toString());
- if (tempList1 != null && tempList1.size() > 0) {
- for (int j = 0; j < tempList1.size(); j++) {
- String num = new WaitDoDao().getDBNum(tempList1.get(j)[1], role_ids,
- comp_id) + "";
- MessagePush.showMsg(null, tempList1.get(j)[1], num,
- "getDbMsg");
- }
- }
- } catch (PersistenceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- // }
- }
- }
- }
- } catch (PersistenceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public String getDept(String userId) {
- String result = "";
- 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='"
- + userId + "'";
- List<String[]> list = new ArrayList<String[]>();
- try {
- list = PersistenceFactory.getInstance(ModelFactory.getSysmodel())
- .getSearchResult(99, sql);
- if (list != null && list.size() > 0) {
- String[] arr = list.get(0);
- // if ("CORP".equals(arr[1])) {
- result = arr[0];
- // } else if ("DEPT".equals(arr[1])) {
- // result = getComp(arr[0]);
- // }
- }
- } catch (Exception e) {
- log.error(e.getMessage());
- }
- return result;
- }
- public String getComp(String dept_id) {
- String result = "";
- 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='"
- + dept_id + "'";
- List<String[]> list = new ArrayList<String[]>();
- try {
- list = PersistenceFactory.getInstance(ModelFactory.getSysmodel())
- .getSearchResult(99, sql);
- if (list != null && list.size() > 0) {
- String[] arr = list.get(0);
- if ("CORP".equals(arr[1])) {
- result = arr[0];
- } else if ("DEPT".equals(arr[1])) {
- getComp(arr[0]);
- }
- }
- } catch (Exception e) {
- log.error(e.getMessage());
- }
- return result;
- }
- }
|