123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- package com.sinosoft.em.baobiao.rcbb.dao;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.List;
- import java.util.Map;
- import org.apache.log4j.Logger;
- import org.quartz.Job;
- import org.quartz.JobExecutionContext;
- import org.quartz.JobExecutionException;
- import com.persistence.service.PersistenceFactory;
- import com.persistence.service.SysPersistence;
- import com.persistence.service.exception.PersistenceException;
- import com.sinosoft.lz.system.sms.dao.SmsDao;
- import com.sinosoft.lz.system.userFriend.dao.SendMsgDao;
- import com.sinosoft.lz.system.userFriend.vo.MsgInfo;
- import com.sysmodel.datamodel.xmlmodel.ModelFactory;
- import com.sysmodel.datamodel.xmlmodel.able.SysModel;
- public class RCReportPlanMonitor implements Job{
- private Logger log = Logger.getLogger(this.getClass());
- public void getList(){
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- List<String>List=new ArrayList<String>();
- RCReportPlanDao rpd=new RCReportPlanDao();
- try {
- // String sql="select name from sys_department_0827 where id='"+list.get(i)+"'";
- String sql="select project_name,report_dept,fill_in_schedule,temporary_time,COMP_ID,updatedate from ECM_EM_RC_SCHEDULE where send_stat='1'";
- List<String[]> tempList;
- tempList = persistence.getSearchResult(99, sql.toString());
-
- log.info("tempList.size===="+tempList.size());
- for(int i=0;i<tempList.size();i++){
- String[]arr=tempList.get(i);
- String project_name=arr[0];
- String report_dept=arr[1];
- String fill_in_schedule=arr[2];
- String temporary_time=arr[3];
- String tableName=project_name.split("_")[0];
- String[]deptArr=report_dept.split(",");
- List<String> telList = new ArrayList<String>();
- List<String> idList = new ArrayList<String>();
- List<String[]> list= getMsg(report_dept);
- if(list==null||list.size()==0){
-
- }else{
-
- for(int k=0;k<list.size();k++){
- telList.add(list.get(k)[0]);
- idList.add(list.get(k)[1]);
- }
- }
- MsgInfo msg = new MsgInfo();
- msg.setRecivedUser(idList);
- msg.setSendUser("zkradmin");
- SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
- SimpleDateFormat sdf1=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- String curent_date=sdf.format(new Date());
- String[] progressTime = rpd.judgeTime( fill_in_schedule, temporary_time).split("[|]");
- String pro_date=progressTime[1];
- if(curent_date.equals(sdf.format(sdf.parse(pro_date).getTime()- 1*24*60*60*1000))){
- for(int j=0;j<deptArr.length;j++){
- if(checkReport(deptArr[j], progressTime[0], progressTime[2], tableName)){
- SmsDao sd=new SmsDao();
- SendMsgDao smd=new SendMsgDao();
- msg.setSendMsg(project_name+"报表填报时间还有一天就到期,请尽快填报");
- sd.saveSms("", telList, sdf1.format(new Date()), project_name+"报表填报时间还有一天就到期,请尽快填报", "zkradmin");
- smd.saveMsg(msg);
- log.info("提前一天催报--"+project_name+"--"+deptArr[j]);
- }
- }
- }else if(curent_date.equals(sdf.format(sdf.parse(pro_date).getTime()+ 1*24*60*60*1000))){
- for(int j=0;j<deptArr.length;j++){
- if(checkReport(deptArr[j], progressTime[0], progressTime[2], tableName)){
- SmsDao sd=new SmsDao();
- SendMsgDao smd=new SendMsgDao();
- msg.setSendMsg(project_name+"报表填报时间已超时一小时,请尽快填报");
- sd.saveSms("", telList, sdf1.format(new Date()), project_name+"报表填报时间已超时一小时,请尽快填报", "zkradmin");
- smd.saveMsg(msg);
- log.info("超时一个小时催报--"+project_name+"--"+deptArr[j]);
- }
- }
- }
- }
- }catch(Exception e){
- this.log.error(e.getMessage(), e);
- }
- }
- @Override
- public void execute(JobExecutionContext arg0) throws JobExecutionException {
- // TODO Auto-generated method stub
- // getList();
- }
-
- public boolean checkReport(String deptId,String preproTime,String currprogressTimeE,String report_type){
- boolean flag=false;
- String sql="";
- if(preproTime.length()==4){
- 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 "+
- "a.COMP_ID='"+deptId+"'"+
- " 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";
- }else{
- 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 "+
- "a.COMP_ID='"+deptId+"'"+
- " 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";
- }
- log.info("checkReport_sql:"+sql);
- try {
- List<Map<String, String>> list1 = PersistenceFactory.getInstance(ModelFactory.getSysmodel())
- .getSearchResultToMap(99, sql);
- if(list1==null||list1.size()==0){
- flag=true;
- }else{
- flag= false;
- }
- } catch (PersistenceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return flag;
- }
-
- public String getTypeByName(String report_id){
- String result="";
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- String sql="select report_type from BM_MAPFORREPORT where report_name='"+report_id+"'";
- try {
- List<String[]>tempList= persistence.getSearchResult(99, sql.toString());
- if(tempList==null||tempList.size()==0){
- }else{
- result=tempList.get(0)[0];
- log.info("report_type===="+result);
- }
- } catch (PersistenceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return result;
- }
- return result;
- }
-
- public String getNameByType(String report_id){
- String result="";
- SysModel sysmodel = ModelFactory.getSysmodel();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- String sql="select report_name from BM_MAPFORREPORT where report_type='"+report_id+"'";
- try {
- List<String[]>tempList= persistence.getSearchResult(99, sql.toString());
- if(tempList==null||tempList.size()==0){
- }else{
- result=tempList.get(0)[0];
- log.info("report_name===="+result);
- }
- } catch (PersistenceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- return result;
- }
- return result;
- }
-
-
- // public List<String[]> getMsg(String report_type,String comp_id ){
- // SysModel sysmodel = ModelFactory.getSysmodel();
- // SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- // String sql = "select a.mobile ,a.user_id from sys_user_info a , sys_dept_user b , sys_department c where "
- // + " 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"
- // + " report_type='"+report_type+"')) and c.dept_id ='"+comp_id+"'";
- // log.info(sql+"===========getMsgsql");
- // List<String[]> telList = new ArrayList<String[]>();
- // try {
- // List<String[]>tempList= persistence.getSearchResult(99, sql.toString());
- // if(tempList==null||tempList.size()==0){
- // }else{
- // for(int i=0;i<tempList.size();i++){
- // telList.add(tempList.get(i));
- // }
- // }
- // } catch (Exception e) {
- // e.printStackTrace();
- // }
- // return telList;
- // }
-
- public List<String[]> getMsg(String report_dept){
- StringBuffer sb=new StringBuffer();
- String[]arr=report_dept.split(",");
- for(int i=0;i<arr.length;i++){
- sb.append("'"+arr[i]+"',");
- }
- if (sb.lastIndexOf(",") > -1) {
- sb.deleteCharAt(sb.lastIndexOf(","));
- }
- List<String[]>tempList=new ArrayList<String[]>();
- SysModel sysmodel = ModelFactory.getSysmodel();
- // List<String[]>tempList=new ArrayList<String[]>();
- SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
- String sql = "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 ='R002105430213') and b.dept_id in(select dept_id from sys_department where CORP_ID in("+sb+")) and a.mobile is not null";
- log.info(sql+"===========getMsgsql");
- // List<String[]> telList = new ArrayList<String[]>();
- try {
- tempList= persistence.getSearchResult(99, sql.toString());
- if(tempList==null||tempList.size()==0){
- }else{
- return tempList;
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return tempList;
- }
-
- public List<String>getChildList(String comp_id){
- List<String>list=new ArrayList<String>();
- String sql="select dept_id from sys_department where parent_id='"+comp_id+"' and dept_type='DEPT'";
- try {
- List<String[]> tempList = PersistenceFactory.getInstance(ModelFactory.getSysmodel()).getSearchResult(99, sql.toString());
- if(tempList!=null&&tempList.size()>0){
- for(int i=0;i<tempList.size();i++){
- list.add(tempList.get(i)[0]);
- }
- // list.add(t)
- }
- } catch (PersistenceException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return list;
- }
-
- }
-
|