b13d7d8076bc347b1ac6445056ef0d4c3e25af8e.svn-base 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. package com.sinosoft.em.baobiao.rcbb.dao;
  2. import java.text.SimpleDateFormat;
  3. import java.util.ArrayList;
  4. import java.util.Date;
  5. import java.util.List;
  6. import java.util.Map;
  7. import org.apache.log4j.Logger;
  8. import org.quartz.Job;
  9. import org.quartz.JobExecutionContext;
  10. import org.quartz.JobExecutionException;
  11. import com.persistence.service.PersistenceFactory;
  12. import com.persistence.service.SysPersistence;
  13. import com.persistence.service.exception.PersistenceException;
  14. import com.sinosoft.lz.system.sms.dao.SmsDao;
  15. import com.sinosoft.lz.system.userFriend.dao.SendMsgDao;
  16. import com.sinosoft.lz.system.userFriend.vo.MsgInfo;
  17. import com.sysmodel.datamodel.xmlmodel.ModelFactory;
  18. import com.sysmodel.datamodel.xmlmodel.able.SysModel;
  19. public class RCReportPlanMonitor implements Job{
  20. private Logger log = Logger.getLogger(this.getClass());
  21. public void getList(){
  22. SysModel sysmodel = ModelFactory.getSysmodel();
  23. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  24. List<String>List=new ArrayList<String>();
  25. RCReportPlanDao rpd=new RCReportPlanDao();
  26. try {
  27. // String sql="select name from sys_department_0827 where id='"+list.get(i)+"'";
  28. String sql="select project_name,report_dept,fill_in_schedule,temporary_time,COMP_ID,updatedate from ECM_EM_RC_SCHEDULE where send_stat='1'";
  29. List<String[]> tempList;
  30. tempList = persistence.getSearchResult(99, sql.toString());
  31. log.info("tempList.size===="+tempList.size());
  32. for(int i=0;i<tempList.size();i++){
  33. String[]arr=tempList.get(i);
  34. String project_name=arr[0];
  35. String report_dept=arr[1];
  36. String fill_in_schedule=arr[2];
  37. String temporary_time=arr[3];
  38. String tableName=project_name.split("_")[0];
  39. String[]deptArr=report_dept.split(",");
  40. List<String> telList = new ArrayList<String>();
  41. List<String> idList = new ArrayList<String>();
  42. List<String[]> list= getMsg(report_dept);
  43. if(list==null||list.size()==0){
  44. }else{
  45. for(int k=0;k<list.size();k++){
  46. telList.add(list.get(k)[0]);
  47. idList.add(list.get(k)[1]);
  48. }
  49. }
  50. MsgInfo msg = new MsgInfo();
  51. msg.setRecivedUser(idList);
  52. msg.setSendUser("zkradmin");
  53. SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
  54. SimpleDateFormat sdf1=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  55. String curent_date=sdf.format(new Date());
  56. String[] progressTime = rpd.judgeTime( fill_in_schedule, temporary_time).split("[|]");
  57. String pro_date=progressTime[1];
  58. if(curent_date.equals(sdf.format(sdf.parse(pro_date).getTime()- 1*24*60*60*1000))){
  59. for(int j=0;j<deptArr.length;j++){
  60. if(checkReport(deptArr[j], progressTime[0], progressTime[2], tableName)){
  61. SmsDao sd=new SmsDao();
  62. SendMsgDao smd=new SendMsgDao();
  63. msg.setSendMsg(project_name+"报表填报时间还有一天就到期,请尽快填报");
  64. sd.saveSms("", telList, sdf1.format(new Date()), project_name+"报表填报时间还有一天就到期,请尽快填报", "zkradmin");
  65. smd.saveMsg(msg);
  66. log.info("提前一天催报--"+project_name+"--"+deptArr[j]);
  67. }
  68. }
  69. }else if(curent_date.equals(sdf.format(sdf.parse(pro_date).getTime()+ 1*24*60*60*1000))){
  70. for(int j=0;j<deptArr.length;j++){
  71. if(checkReport(deptArr[j], progressTime[0], progressTime[2], tableName)){
  72. SmsDao sd=new SmsDao();
  73. SendMsgDao smd=new SendMsgDao();
  74. msg.setSendMsg(project_name+"报表填报时间已超时一小时,请尽快填报");
  75. sd.saveSms("", telList, sdf1.format(new Date()), project_name+"报表填报时间已超时一小时,请尽快填报", "zkradmin");
  76. smd.saveMsg(msg);
  77. log.info("超时一个小时催报--"+project_name+"--"+deptArr[j]);
  78. }
  79. }
  80. }
  81. }
  82. }catch(Exception e){
  83. this.log.error(e.getMessage(), e);
  84. }
  85. }
  86. @Override
  87. public void execute(JobExecutionContext arg0) throws JobExecutionException {
  88. // TODO Auto-generated method stub
  89. // getList();
  90. }
  91. public boolean checkReport(String deptId,String preproTime,String currprogressTimeE,String report_type){
  92. boolean flag=false;
  93. String sql="";
  94. if(preproTime.length()==4){
  95. sql = "SELECT a.FD_OBJECTID,a.REPORT_TIME,a.REPORTER_ID,UPDATEDATE,a.REPORT_TYPE,a.comp_id FROM ECM_EM_REPORT_RECORDS a,bm_mapforrcreport b WHERE "+
  96. "a.COMP_ID='"+deptId+"'"+
  97. " AND a.IS_DEL=0 AND a.appear_stat=1 and a.report_type=b.report_type AND a.year='"+preproTime+"' AND a.season='"+currprogressTimeE+"' and b.report_name='"+report_type+"' order by updatedate";
  98. }else{
  99. sql = "SELECT a.FD_OBJECTID,a.REPORT_TIME,a.REPORTER_ID,UPDATEDATE,a.REPORT_TYPE,a.comp_id FROM ECM_EM_REPORT_RECORDS a,bm_mapforrcreport b WHERE "+
  100. "a.COMP_ID='"+deptId+"'"+
  101. " AND a.IS_DEL=0 AND a.appear_stat=1 and a.report_type=b.report_type AND UPDATEDATE BETWEEN '"+preproTime+"' AND '"+currprogressTimeE+"' and b.report_name='"+report_type+"' order by updatedate";
  102. }
  103. log.info("checkReport_sql:"+sql);
  104. try {
  105. List<Map<String, String>> list1 = PersistenceFactory.getInstance(ModelFactory.getSysmodel())
  106. .getSearchResultToMap(99, sql);
  107. if(list1==null||list1.size()==0){
  108. flag=true;
  109. }else{
  110. flag= false;
  111. }
  112. } catch (PersistenceException e) {
  113. // TODO Auto-generated catch block
  114. e.printStackTrace();
  115. }
  116. return flag;
  117. }
  118. public String getTypeByName(String report_id){
  119. String result="";
  120. SysModel sysmodel = ModelFactory.getSysmodel();
  121. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  122. String sql="select report_type from BM_MAPFORREPORT where report_name='"+report_id+"'";
  123. try {
  124. List<String[]>tempList= persistence.getSearchResult(99, sql.toString());
  125. if(tempList==null||tempList.size()==0){
  126. }else{
  127. result=tempList.get(0)[0];
  128. log.info("report_type===="+result);
  129. }
  130. } catch (PersistenceException e) {
  131. // TODO Auto-generated catch block
  132. e.printStackTrace();
  133. return result;
  134. }
  135. return result;
  136. }
  137. public String getNameByType(String report_id){
  138. String result="";
  139. SysModel sysmodel = ModelFactory.getSysmodel();
  140. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  141. String sql="select report_name from BM_MAPFORREPORT where report_type='"+report_id+"'";
  142. try {
  143. List<String[]>tempList= persistence.getSearchResult(99, sql.toString());
  144. if(tempList==null||tempList.size()==0){
  145. }else{
  146. result=tempList.get(0)[0];
  147. log.info("report_name===="+result);
  148. }
  149. } catch (PersistenceException e) {
  150. // TODO Auto-generated catch block
  151. e.printStackTrace();
  152. return result;
  153. }
  154. return result;
  155. }
  156. // public List<String[]> getMsg(String report_type,String comp_id ){
  157. // SysModel sysmodel = ModelFactory.getSysmodel();
  158. // SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  159. // String sql = "select a.mobile ,a.user_id from sys_user_info a , sys_dept_user b , sys_department c where "
  160. // + " a.user_id = b.user_id and b.dept_id = c.dept_id and a.user_id in (select user_id from sys_user_role_rel where role_id in (select role_id from bm_mapforreport where"
  161. // + " report_type='"+report_type+"')) and c.dept_id ='"+comp_id+"'";
  162. // log.info(sql+"===========getMsgsql");
  163. // List<String[]> telList = new ArrayList<String[]>();
  164. // try {
  165. // List<String[]>tempList= persistence.getSearchResult(99, sql.toString());
  166. // if(tempList==null||tempList.size()==0){
  167. // }else{
  168. // for(int i=0;i<tempList.size();i++){
  169. // telList.add(tempList.get(i));
  170. // }
  171. // }
  172. // } catch (Exception e) {
  173. // e.printStackTrace();
  174. // }
  175. // return telList;
  176. // }
  177. public List<String[]> getMsg(String report_dept){
  178. StringBuffer sb=new StringBuffer();
  179. String[]arr=report_dept.split(",");
  180. for(int i=0;i<arr.length;i++){
  181. sb.append("'"+arr[i]+"',");
  182. }
  183. if (sb.lastIndexOf(",") > -1) {
  184. sb.deleteCharAt(sb.lastIndexOf(","));
  185. }
  186. List<String[]>tempList=new ArrayList<String[]>();
  187. SysModel sysmodel = ModelFactory.getSysmodel();
  188. // List<String[]>tempList=new ArrayList<String[]>();
  189. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  190. String sql = "select a.mobile ,a.user_id,a.real_name from sys_user_info a , sys_dept_user b where "
  191. + " a.user_id = b.user_id and a.user_id in (select user_id from sys_user_role_rel where role_id ='R002105430213') and b.dept_id in(select dept_id from sys_department where CORP_ID in("+sb+")) and a.mobile is not null";
  192. log.info(sql+"===========getMsgsql");
  193. // List<String[]> telList = new ArrayList<String[]>();
  194. try {
  195. tempList= persistence.getSearchResult(99, sql.toString());
  196. if(tempList==null||tempList.size()==0){
  197. }else{
  198. return tempList;
  199. }
  200. } catch (Exception e) {
  201. e.printStackTrace();
  202. }
  203. return tempList;
  204. }
  205. public List<String>getChildList(String comp_id){
  206. List<String>list=new ArrayList<String>();
  207. String sql="select dept_id from sys_department where parent_id='"+comp_id+"' and dept_type='DEPT'";
  208. try {
  209. List<String[]> tempList = PersistenceFactory.getInstance(ModelFactory.getSysmodel()).getSearchResult(99, sql.toString());
  210. if(tempList!=null&&tempList.size()>0){
  211. for(int i=0;i<tempList.size();i++){
  212. list.add(tempList.get(i)[0]);
  213. }
  214. // list.add(t)
  215. }
  216. } catch (PersistenceException e) {
  217. // TODO Auto-generated catch block
  218. e.printStackTrace();
  219. }
  220. return list;
  221. }
  222. }