applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"
default-lazy-init="true">
<description>Spring</description>
<bean id="jdbcConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:jdbc.properties"/>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName">
<value>${jdbc.driverClassName}</value>
</property>
<property name="url">
<value>${jdbc.url}</value>
</property>
<property name="username">
<value>${jdbc.username}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
<property name="maxActive">
<value>300</value>
</property>
<property name="maxIdle">
<value>100</value>
</property>
<property name="maxWait">
<value>10000</value>
</property>
<property name="removeAbandoned">
<value>true</value>
</property>
<property name="removeAbandonedTimeout">
<value>100</value>
</property>
<property name="logAbandoned">
<value>true</value>
</property>
</bean>
<!-- JPA配置,读取persistence.xml中的PU -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="AppPU"/>
<property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml"/>
<property name="dataSource" ref="dataSource"/>
</bean>
<!-- 事务配置 -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<!-- 使用annotation定义事务 -->
<tx:annotation-driven transaction-manager="transactionManager"/>
<!-- 保证POJO中标注@Required的属性被注入 -->
<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor"/>
<!-- 导出用annotation注释的JMX POJO-->
<context:mbean-export/>
<bean id="sqlDepartmentDao" class="com.app.db.sqlmap.sqldriver.dao.SqlDepartmentDao" autowire="byName"/>
<bean id="departmentTree" class="com.app.db.sqlmap.sqldriver.tree.DepartmentTree" autowire="byName"/>
<!-- ifor的处理 -->
<bean id="ifFormtemplateDao" class="com.app.infor.dao.IfFormtemplateDao" autowire="byName"/>
<bean id="ifFormtemplateService" class="com.app.infor.service.IfFormtemplateService" autowire="byName"/>
<!-- applicationContext.xml会经常更新,为了方便 把各点可能存在差异的配置单独列一个xml -->
<import resource="applicationConfig.xml"/>
<import resource="com/app/base/context.xml"/>
<!-- 通讯录 -->
<import resource="com/app/AddrBook/context.xml"/>
<import resource="com/app/alonepages/context.xml"/>
<import resource="com/app/BusinessDic/context.xml"/>
<import resource="com/app/cluster/context.xml"/>
<import resource="com/app/Consign/context.xml"/>
<import resource="com/app/dexc/context.xml"/>
<import resource="com/app/extjsPortal/context.xml"/>
<import resource="com/app/filecenter/context.xml"/>
<import resource="com/app/forum/context.xml"/>
<!-- 信息采编发 -->
<import resource="com/app/igae/context.xml"/>
<import resource="com/app/infor/context.xml"/>
<import resource="com/app/ISO/context.xml"/>
<import resource="com/app/log/context.xml"/>
<import resource="com/app/login/context.xml"/>
<!-- 会议室管理 -->
<import resource="com/app/meeting/context.xml"/>
<!-- 资源管理模块 -->
<import resource="com/app/msg/context.xml"/>
<import resource="com/app/resource/context.xml"/>
<import resource="com/app/salary/context.xml"/>
<import resource="com/app/selectPerson/context.xml"/>
<import resource="com/app/system/context.xml"/>
<import resource="com/app/wf/context.xml"/>
<import resource="com/app/workflow/context.xml"/>
<import resource="com/app/webservice/applicationContext.xml"/>
<!-- 个人日程管理 -->
<import resource="com/app/schedule/context.xml"/>
<!-- 数据管理 (档案查询)-->
<import resource="com/app/datamanager/context.xml"/>
<!--功能分组-->
<import resource="com/app/functionGroup/context.xml"/>
<!--移动终端-->
<import resource="com/app/terminal/context.xml"/>
<!-- 归档信息 -->
<import resource="com/app/archive/context.xml"/>
<!-- solr -->
<import resource="com/app/solr/context.xml"/>
<!-- 邮件 -->
<import resource="com/app/mail/context.xml"/>
<!--权限系统(new)-->
<import resource="com/app/itsRoleManage/context.xml"/>
<!-- 领导周计划 -->
<import resource="com/app/plan/context.xml"/>
<import resource="com/app/commonFile/context.xml"/>
<!-- 档案管理
<import resource="com/app/document/context.xml"/>
-->
<!-- 在线订餐功能 -->
<import resource="com/app/modules/reservation/context.xml"/>
<!-- 短信通知 -->
<import resource="com/app/modules/notify/context.xml"/>
<!-- 在线聊天 -->
<import resource="com/app/modules/chat/context.xml"/>
<!-- 资产管理 -->
<import resource="com/app/modules/asset/context.xml"/>
<!-- 文件办理超时监控 -->
<import resource="com/app/workflow/performanceMonitor/context.xml"/>
<!-- 督查督办深圳版本 -->
<import resource="com/app/supervise/context.xml"/>
<!-- 部门绩效考核 -->
<import resource="com/app/modules/eval/context.xml"/>
<!-- 调查 -->
<import resource="com/app/modules/vote/context.xml"/>
<!-- 静态字典 -->
<import resource="com/app/modules/dict/context.xml"/>
<!-- 绩效定时器 -->
<import resource="com/app/modules/eval/timertask/context.xml"/>
<!-- 用户监控 -->
<import resource="com/app/modules/session/context.xml"/>
<!-- lotusDoc -->
<import resource="com/app/modules/lotus/context.xml"/>
<!-- 档案系统
<import resource="com/app/modules/arch/context.xml"/>
-->
<!-- 操作监控 -->
<import resource="com/app/modules/operationCurrent/context.xml"/>
<!-- 工资管理 -->
<import resource="com/app/modules/salary/context.xml"/>
<!-- 车辆统计 -->
<import resource="com/app/modules/car/context.xml"/>
<!-- 会议人员 -->
<import resource="com/app/modules/meeting/context.xml"/>
<!-- 分类管理 -->
<import resource="com/app/modules/workflow/context.xml"/>
<!-- 门户管理 -->
<import resource="com/app/modules/portal/context.xml"/>
<!-- 选择器 -->
<import resource="com/app/modules/tools/context.xml"/>
<!-- 图书管理 -->
<import resource="com/app/modules/book/context.xml"/>
<!-- 合同管理 -->
<import resource="com/app/modules/contract/context.xml"/>
<!-- 表单操作 (请休假通知/反馈) -->
<import resource="com/app/modules/form/context.xml"/>
<!-- 栏目管理 -->
<import resource="com/app/modules/columns/context.xml"/>
<!--内审员 -->
<import resource="com/app/modules/auditor/context.xml"/>
<!-- 意见箱 -->
<import resource="com/app/modules/opinionBox/context.xml"/>
<!--日历、节假日 -->
<import resource="com/app/modules/calendar/context.xml"/>
<!--物品管理 -->
<import resource="com/app/modules/goods/context.xml"/>
<!--商品台账-->
<import resource="com/app/modules/account/context.xml"/>
<!--值班管理 -->
<import resource="com/app/modules/watch/context.xml"/>
</beans>
context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"
default-lazy-init="true">
<bean id="performanceMonitorAction" class="com.app.workflow.performanceMonitor.action.PerformanceMonitorAction" autowire="byName" scope="prototype" />
<bean id="performanceMonitorService" class="com.app.workflow.performanceMonitor.service.PerformanceMonitorService" autowire="byName" >
<property name="dao" ref="performanceMonitorDao"></property>
<property name="instanceHandler" ref="WFInstanceHandler" />
</bean>
<bean id="performanceMonitorDao" class="com.app.workflow.performanceMonitor.dao.PerformanceMonitorDao" autowire="byName" />
<bean id="employeeService" class="com.app.wf.db.service.EmployeeService" autowire="byName" />
<!-- 定时扫描逾期文件 每天凌晨03:00执行 只需要一台服务器处理就可以 -->
<bean id="performanceMonitorQuartzSerivce" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="performanceMonitorService" />
<property name="targetMethod" value="createPerformanceMonitor" />
</bean>
</property>
<property name="cronExpression" value="0 0 3 * * ?" />
</bean>
<!-- 深圳局 超期未办结的文件标识为"超期办结" lenian 2017 11 03 -->
<bean id="szChaoQiBanJieQuartzSerivce" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="performanceMonitorService" />
<property name="targetMethod" value="msgToChaoQi" />
</bean>
</property>
<!-- <property name="cronExpression" value="0 * */2 * * ?" /> --><!-- 每两小时执行一次 -->
<!-- <property name="cronExpression" value="0 */10 * * * ?" /> --><!-- 每十分钟执行一次 -->
<property name="cronExpression" value="*/30 * * * * ?" /><!-- 每十秒钟执行一次 -->
</bean>
<!-- 深圳局 系统自动催办(收文) lenian 2018 01 08 -->
<bean id="szMsgToSendQuartzSerivce" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="performanceMonitorService" />
<property name="targetMethod" value="msgToSend" />
</bean>
</property>
<property name="cronExpression" value="0 * */2 * * ?" /><!-- 每两小时执行一次 -->
</bean>
<!-- 深圳局 超期提醒(提醒拟稿人超期未办结的文件需要重新拟稿) lenian 2018 01 10 -->
<bean id="szMsgToNeedQuartzSerivce" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="performanceMonitorService" />
<property name="targetMethod" value="msgToNeed" />
</bean>
</property>
<!-- <property name="cronExpression" value="*/30 * * * * ?" /> --><!-- 每三十秒钟执行一次 -->
<property name="cronExpression" value="0 */1 * * * ?" /><!-- 每一分钟执行一次 -->
</bean>
<bean id="szMsgUrgentQuartzSerivce" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
<property name="jobDetail">
<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="performanceMonitorService" />
<property name="targetMethod" value="msgUrgent" />
</bean>
</property>
<property name="startDelay" value="300000" />
<property name="repeatInterval" value="300000" />
</bean>
<!-- 定时发送测试 延迟5分钟执行 每5分钟调度一次
<bean id="performanceMonitorQuartzSerivceTest" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
<property name="jobDetail">
<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="performanceMonitorService" />
<property name="targetMethod" value="createPerformanceMonitor" />
</bean>
</property>
<property name="startDelay" value="300000" />
<property name="repeatInterval" value="300000" />
</bean>
-->
</beans>
applicationConfig.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"
default-lazy-init="true">
<description>Config Spring</description>
<!-- 此文件不会经常更新,为了方便 把各点可能存在差异的配置单独列在此处
CREATE BY : YANG CHUN WEI
CREATE DATE : 2016-11-18
-->
<bean id="springApplicationListener" class="com.app.spring.SpringApplicationListener">
<property name="isload" value="true"/>
</bean>
<!--集群服务器部署时,根据实际情况默认只会开启其中一台的定时器,如果需要每台都开启的请备注 -->
<bean name="quartzScheduler" lazy-init="false" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="SysLogQuartzSerivce"/> <!-- 日志每台都需要开启 -->
<ref bean="sysIcapclusterSerivce" /> <!-- 刷新缓存定时器-->
<!--
<ref bean="normCheckHandlerQuartzService" />
<ref bean="flowFormDealNoticeQuartzSerivce"/>
<ref bean="sendMailQuartzSerivce"/>
<ref bean="delMailQuartzSerivce"/>
<ref bean="JS_endToTwohoursSessionUser"/>
<ref bean="SolrQuartzSerivce"/>
<ref bean="UrgencyMsgQuartzSerivce"/>
<ref bean="icapInfoFocusnewsServiceQuartz"/>
<ref bean="messageQuartz"/>
<ref bean="tabArchiveContentServiceQuartz"/>
-->
<!-- 浙江启动推送消息的定时器
<ref bean="zjkx_quartzSerivce" />
-->
<!-- 定时扫描逾期文件 发催办提醒
<ref bean="performanceMonitorQuartzSerivce"/>
-->
<!-- 深圳局 超期未办结的文件标识为"超期办结" lenian 2017 11 03 -->
<!-- --><ref bean="szChaoQiBanJieQuartzSerivce"/>
<!-- 深圳局 自动催办:系统自动催办(收文) lenian 2018 01 08 -->
<!-- --><ref bean="szMsgToSendQuartzSerivce"/>
<!-- 深圳局 超期提醒(提醒拟稿人超期未办结的文件需要重新拟稿) lenian 2018 01 10 -->
<!-- --><ref bean="szMsgToNeedQuartzSerivce"/>
<!-- 绩效定时器
<ref bean="normQuartzService"/>
-->
</list>
</property>
<property name="configLocation" value="classpath:quartz.properties"/>
</bean>
</beans>
PerformanceMonitorService.java
package com.app.workflow.performanceMonitor.service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.app.base.service.WfNeeddoService;
import com.app.base.service.WfUrgencymsgService;
import com.app.db.model.WfNeeddo;
import com.app.db.model.WfUrgencymsg;
import com.app.db.model.WfWorkflowPerformencemonitor;
import com.app.db.service.BaseService;
import com.app.db.sqlmap.sqldriver.sqlKeyWord;
import com.app.forum.apply.service.ForumTipsService;
import com.app.system.service.SysConfigService;
import com.app.util.DBQueryUtil;
import com.app.util.DateUtil;
import com.app.util.GuidGen;
import com.app.wf.api.define.model.Node;
import com.app.wf.api.instance.InstanceHandler;
import com.app.wf.api.instance.model.User;
import com.app.wf.db.model.WFActionTrack;
import com.app.wf.db.model.WFInstance;
import com.app.wf.db.service.ActionTrackService;
import com.app.wf.db.service.InstanceService;
import com.app.workflow.performanceMonitor.dao.PerformanceMonitorDao;
public class PerformanceMonitorService extends BaseService<WfWorkflowPerformencemonitor> {
private PerformanceMonitorDao performanceMonitorDao;
private InstanceService WFInstanceService;
private SysConfigService sysConfigService;
public static String STATUS_DELETE="2";
public static String STATUS_CLOSE="1";
public static String STATUS_NO_CLOSE="0";
//超期办结 lenin 2017 11 13
private InstanceHandler WFInstanceHandler;
private WfUrgencymsgService wfUrgencymsgService;
private WfUrgencymsg wfurgencymsg = new WfUrgencymsg();
private ForumTipsService forumTipsService;
private ActionTrackService actionTrackService;
//深圳局【超期办结:从拟稿到办结】,系统定时扫描文件,将超期文件加上超期标识符 lenian 2017 12 29
//注:此处不用throws Exception目的是方便捕获异常,例如有些NullPointerException扔出去之后就看不到了
@Transactional
public void msgToChaoQi(){
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(">>进入定时扫描文件,将超期文件加上超期标识符的方法!"+ sdf2.format(new Date()));
//自动提醒的文件,参考mod_modeltype表(催办:发文、收文、签报、申办申购)
String SQL_TANCE =
"select distinct i.WORKFLOWINSTANCE_GUID,\n" +
" i.CREATOR,\n" + //发送人-拟稿人
" i.CURRENT_INSTANCENODE_GUID,\n" + //fromActionGuid
" i.CREATETIME,\n" + //创建日期
" i.DOTITLE,\n" + //文件名称
" i.INPARENTMODELID,\n" + //模块ID
" i.INPARENTMODELNAME,\n" + //所属模块名称
" i.INSTANCENO,\n" + //文号
" i.ISDEBUG,\n" +
" i.ISDELETED,\n" +
" i.ISEND,\n" + //是否已办结
" i.SONGDATIME,\n" + //发送时间
" i.URGENCYLEVEL,\n" + //缓急程度
" i.instancetype,\n" + //文件类型
" f.wff_text_enddate,\n" + //办结时间
" i.TXTIME\n" + //办结时间
" from WF_INSTANCE i, WF_FORMDATA f\n" +
" where i.workflowinstance_guid = f.workflowinstanceguid\n" +
" and i.instancetype in ('1000','1002','1003','1004')\n" +
" and i.ISDELETED = 0\n" +
" and i.ISEND = 0\n" +
" and i.creator <> '999'\n" +
// " and i.ISDEBUG = 0\n" +
// " and i.ischaoqi <> 1\n" +
" and i.ischaoqi is null\n" +
" order by i.SONGDATIME DESC";
List<Object> list = performanceMonitorDao.findNative(SQL_TANCE, 0, 0, null);
System.out.println("共"+list.size()+"条数据!");
for (int i = 0; i < list.size(); i++) {
Object obj[] = (Object[]) list.get(i);
String workflowinstanceguid = (String) obj[0];
WFInstance instance=WFInstanceHandler.getInstance(workflowinstanceguid);
// Date createTime = instance.getCreatetime(); //拟稿日期
String dt = sdf2.format(instance.getCreatetime());
Date createTime = sdf2.parse(dt);
String eve = (String) obj[12]; //缓急程度
String toDay = sdf.format(new Date());//当前时间(系统自动发送提醒的时间)
Calendar c = Calendar.getInstance();
c.setTime(createTime);
int day=c.get(Calendar.DATE);
Date dat = sdf.parse(toDay);
HashMap<String, Object> setmap = new HashMap<String, Object>();
//将当前日期作为提醒日期
setmap.put("ischaoQi", 1); //超期提醒时间
setmap.put("chaoqitime", sdf2.format(new Date())); //超期提醒时间
setmap.put("chaoqitext", "超期办结"); //超期办结标识符
String str = (String) obj[13];
String wfftextenddate = (String) obj[14];//办结时间
String txTime = (String) obj[15];//提醒时间
//局收文是根据办结时间来判断是否超期,其它则根据缓急程度来设定时间段
if (str.equals("1002")) {
//判断:1、提醒时间都不为空时,以提醒时间为准,过了这个时间视为超期
if (txTime != null && !"".equals(txTime)) {
Date tx = sdf.parse(txTime);
if (dat.getTime() > tx.getTime()) {
WFInstanceHandler.updateInstance(instance.getWorkflowinstanceGuid(), setmap);
}
}
//2、如果办结日期不为空、提醒时间为空的情况下,如果过了办结日期文件还未办结,系统将其视为超期
else if ((txTime == null || "".equals(txTime)) && (wfftextenddate != null && !"".equals(wfftextenddate))) {
Date endDt = sdf.parse(wfftextenddate);
if (dat.getTime() > endDt.getTime()) {
WFInstanceHandler.updateInstance(instance.getWorkflowinstanceGuid(), setmap);
}
}
//3、如果办结日期、提醒时间都为空,按照缓急来标识超期。以拟稿时间为节点,大于办结超限标识为超期
else if ((txTime == null || "".equals(txTime)) && (wfftextenddate == null || "".equals(wfftextenddate))) {
if (eve.equals("99")) {
c.set(Calendar.DATE,day+7);
String dayAfter = sdf.format(c.getTime());
Date after = sdf.parse(dayAfter);
if (dat.getTime() > after.getTime()) {
WFInstanceHandler.updateInstance(instance.getWorkflowinstanceGuid(), setmap);
}
}
if (eve.equals("0")) { //特提,一天要办完
c.set(Calendar.DATE,day+1);
String dayAfter = sdf.format(c.getTime());
Date after = sdf.parse(dayAfter);
if (dat.getTime() > after.getTime()) {
WFInstanceHandler.updateInstance(instance.getWorkflowinstanceGuid(), setmap);
}
}
if (eve.equals("1")) {
c.set(Calendar.DATE,day+2);
String dayAfter = sdf.format(c.getTime());
Date after = sdf.parse(dayAfter);
if (dat.getTime() > after.getTime()) {
WFInstanceHandler.updateInstance(instance.getWorkflowinstanceGuid(), setmap);
}
}
if (eve.equals("2")) {
c.set(Calendar.DATE,day+4);
String dayAfter = sdf.format(c.getTime());
Date after = sdf.parse(dayAfter);
if (dat.getTime() > after.getTime()) {
WFInstanceHandler.updateInstance(instance.getWorkflowinstanceGuid(), setmap);
}
}
}
} else if(!str.equals("1002")) { //判断:不是局收文时
if (eve.equals("99")) { //缓急程度:普通,办结期限是7天
//设置系统自动提醒时间
c.set(Calendar.DATE,day+7);
String dayAfter = sdf.format(c.getTime());
Date after = sdf.parse(dayAfter);
//原:toDay.equals(dayAfter) || dat.getTime() > after.getTime();现:过了办结期限视为超期
if (dat.getTime() > after.getTime()) {
//添加超期标识符
WFInstanceHandler.updateInstance(instance.getWorkflowinstanceGuid(), setmap);
}
}
if (eve.equals("0")) { //特提,一天要办完
//设置系统自动催办时间
c.set(Calendar.DATE,day+1);
String dayAfter = sdf.format(c.getTime());
Date after = sdf.parse(dayAfter);
//原:toDay.equals(dayAfter) || dat.getTime() > after.getTime();现:过了办结期限视为超期
if (dat.getTime() > after.getTime()) {
WFInstanceHandler.updateInstance(instance.getWorkflowinstanceGuid(), setmap);
}
}
if (eve.equals("1")) { //缓急程度:特急,办结期限是2天
//设置系统自动催办时间
c.set(Calendar.DATE,day+2);
String dayAfter = sdf.format(c.getTime());
Date after = sdf.parse(dayAfter);
//原:toDay.equals(dayAfter) || dat.getTime() > after.getTime();现:过了办结期限视为超期
if (dat.getTime() > after.getTime()) {
WFInstanceHandler.updateInstance(instance.getWorkflowinstanceGuid(), setmap);
}
}
if (eve.equals("2")) { //缓急程度:加急,办结期限是4天
//设置系统自动催办时间
c.set(Calendar.DATE,day+4);
String dayAfter = sdf.format(c.getTime());
Date after = sdf.parse(dayAfter);
//原:toDay.equals(dayAfter) || dat.getTime() > after.getTime();现:过了办结期限视为超期
if (dat.getTime() > after.getTime()) {
WFInstanceHandler.updateInstance(instance.getWorkflowinstanceGuid(), setmap);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
//深圳局 【超期提醒:系统自动提醒拟稿人重新拟稿】 lenian 2017 12 29
//注:此处不用throws Exception目的是方便捕获异常,例如有些NullPointerException扔出去之后就看不到了
@Transactional
public void msgToNeed(){
try {
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(">>进入自动提醒拟稿人拟稿的方法!"+ sdf2.format(new Date()));
String SQL_TANCE =
"select distinct i.WORKFLOWINSTANCE_GUID,\n" +
" i.CREATOR,\n" + //发送人-拟稿人
" i.CURRENT_INSTANCENODE_GUID,\n" + //fromActionGuid
" i.CREATETIME,\n" + //创建日期
" i.DOTITLE,\n" + //文件名称
" i.INPARENTMODELID,\n" + //模块ID
" i.INPARENTMODELNAME,\n" + //所属模块名称
" i.INSTANCENO,\n" + //文号
" i.ISDEBUG,\n" +
" i.ISDELETED,\n" +
" i.ISEND,\n" + //是否已办结
" i.SONGDATIME,\n" + //发送时间
" i.URGENCYLEVEL,\n" + //缓急程度
" i.instancetype,\n" + //文件类型
" i.wfftextenddate,\n" + //办结时间
" i.TXTIME\n" + //办结时间
" from WF_INSTANCE i\n" +
" where i.ISDELETED = 0\n" +
" and i.creator <> '999'\n" +
" and i.ischaoqi = '1'";
List<Object> list = performanceMonitorDao.findNative(SQL_TANCE, 0, 0, null);
System.out.println("共"+list.size()+"条数据!");
for (int i = 0; i < list.size(); i++) {
Object obj[] = (Object[]) list.get(i);
String workflowinstanceguid = (String) obj[0];
WFInstance instance=WFInstanceHandler.getInstance(workflowinstanceguid);
//****************给拟稿人发送提醒 start*******************//
String track_SQL =
"select w.actionintype, w.instanceaction_guid\n" +
" from WF_WORKFLOWACTIONTRACK w\n" +
" where w.workflowinstanceguid = '"+ instance.getWorkflowinstanceGuid() +"'";
List<Object> trackList = performanceMonitorDao.findNative(track_SQL);
Object track[] = (Object[]) trackList.get(0);
User user = forumTipsService.getUserById(instance.getCreator());
List<User> newlistUser = new ArrayList<User>();
String actionintype = (String) track[0];
String instanceactionGuid = (String) track[1];
if (actionintype != null && !"".equals(actionintype)) {
user.setEmployeeDealType(actionintype);
}
user.setActionGuid(instanceactionGuid);
newlistUser.add(user);
String msgc = "根据深圳局公文处理办法规定,您起草的《"+obj[4]+"》已超过办理期限,请重新拟稿!";
String tempstr = String.valueOf(msgc.replaceAll(" ", " ").replaceAll("\r\n", "<br/>"));
//****************给拟稿人发送提醒 end*******************//
wfUrgencymsgService.urgencyMsgChaoQi(newlistUser,instance, user.getEmployeeGuid(), "man",tempstr);
}
} catch (Exception e) {
e.printStackTrace();
}
}
//深圳局收文 自动催办 lenian 2018 01 08
//注:此处不用throws Exception目的是方便捕获异常,例如有些NullPointerException扔出去之后就看不到了
@Transactional
public void msgToSend() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(">>进入局收文自动催办的方法!"+ sdf2.format(new Date()));
try {
String SQL_TANCE =
"select distinct i.WORKFLOWINSTANCE_GUID,\n" +
" i.CREATOR,\n" + //发送人-拟稿人
" i.CURRENT_INSTANCENODE_GUID,\n" + //fromActionGuid
" i.CREATETIME,\n" + //创建日期
" i.DOTITLE,\n" + //文件名称
" i.INSTANCENO,\n" + //文号
" i.ISEND,\n" + //是否已办结
" i.SONGDATIME,\n" + //发送时间
" i.WFFTEXTENDDATE,\n" + //办结时间
" i.TXTIME,\n" + //发送时间
" i.URGENCYLEVEL\n" + //缓急程度
" from WF_INSTANCE i\n" +
" where instancetype = '1002'\n" +//参考mod_modeltype表(催办:发文、签报、申办申购)
" and i.ISDELETED = 0\n" +
" and i.ISEND = 0\n" +
" and i.creator <> '999'\n" +
" and i.ischaoqi is null\n" +
" order by i.SONGDATIME DESC";
List<Object> list = performanceMonitorDao.findNative(SQL_TANCE, 0, 0, null);
System.out.println("共"+list.size()+"条数据!");
for (int i = 0; i < list.size(); i++) {
Object obj[] = (Object[]) list.get(i);
//催办内容
String msgc = "您办理的《"+obj[4]+"》即将到达办结期限,请尽快办理!";
String eve = (String) obj[10]; //缓急程度
String userid = (String) obj[1]; //发送人-拟稿人
String workflowinstanceguid = (String) obj[0];
Date time = (Date) obj[3]; //拟稿时间
String createTime = sdf.format(time);
String endDate = (String) obj[8]; //办结日期,办结期限从拟稿时间起
String txTime = (String) obj[9]; //提醒时间
System.out.println("wfftextenddate: "+ endDate +"\ttxTime: "+ txTime +"\tcreateTime: "+ createTime);
String tempstr = String.valueOf(msgc.replaceAll(" ", " ").replaceAll("\r\n", "<br/>"));
String SQL_TRACK =
"select w.from_action_guid,\n" +
" w.instancenode_guid,\n" +
" w.currentactioner,\n" +
" w.actionintype\n" +
" from WF_WORKFLOWACTIONTRACK w\n" +
" where workflowinstanceguid = '"+ workflowinstanceguid +"'\n" +
" and w.actionstatus in ('read', 'unread')";
List<Object> workList = performanceMonitorDao.findNative(SQL_TRACK, null);
Object work[] = (Object[]) workList.get(0);//一步步办理,可查到一条未办理数据
String fromActionGuid = (String) work[0]; //来源动作
String nodeTrackGuid = (String) work[1];
String currentactioner = (String) work[2]; //待办人
//可能是以前在页面上选择催办人时可以多选,通过测试来看只能先一个人 lenian 2017 11 30
String[] usgpersion=currentactioner.split(",");
WFInstance instance=WFInstanceHandler.getInstance(workflowinstanceguid);
List<User> listUser = this.WFInstanceHandler.getCurrentNeedDealUser(instance, fromActionGuid, nodeTrackGuid);
List<User> newlistUser = new ArrayList<User>();
for (User user : listUser){
for (int j = 0; j < usgpersion.length; j++)
{
if (usgpersion[j] != null && !usgpersion[j].equals(""))
{
if (user.getEmployeeGuid().equals(usgpersion[j])){
newlistUser.add(user);
}
}
}
}
if (tempstr != null && !tempstr.equals("填写催办内容")){
wfurgencymsg.setUrgencymsgContent(tempstr);
} else{
wfurgencymsg.setUrgencymsgContent("");
}
/进入催办
String toDay = sdf.format(new Date());//当前时间(系统自动发送催办的时间)
Calendar c = Calendar.getInstance(); //Java Calendar 类时间操作
c.setTime(time);
int day=c.get(Calendar.DATE);
//判断:1、提醒时间都不为空时,以提醒时间为准,发送催办信息,过了这个时间视为超期
if (txTime != null && !"".equals(txTime)) {
//提醒时间,String => Date类型转换
Date date = sdf.parse(txTime);
c.setTime(date);
String dayAfter = sdf.format(c.getTime());
if (toDay.equals(dayAfter)) { //按照设置的提醒时间发送催办提醒
wfUrgencymsgService.sendUrgencymsg(newlistUser,instance, userid, "man",tempstr);
}
}
//2、如果办结日期不为空、提醒时间为空的情况下,根据不同缓急程度提前XXX天发送催办信息,如果过了办结日期文件还未办结,系统将其视为超期
else if ((txTime == null || "".equals(txTime)) && (endDate != null && !"".equals(endDate))) {
//办结日期,String => Date类型转换
Date date = sdf.parse(endDate);
c.setTime(date);
if (eve.equals("99")) {
c.set(Calendar.DATE,day-7);
String dayAfter = sdf.format(c.getTime());
if (toDay.equals(dayAfter)) {
wfUrgencymsgService.sendUrgencymsg(newlistUser,instance, userid, "man",tempstr);
}
}
if (eve.equals("0")) { //特提,一天要办完
c.set(Calendar.DATE,day-1);
String dayAfter = sdf.format(c.getTime());
if (toDay.equals(dayAfter)) {
wfUrgencymsgService.sendUrgencymsg(newlistUser,instance, userid, "man",tempstr);
}
}
if (eve.equals("1")) {
c.set(Calendar.DATE,day-2);
String dayAfter = sdf.format(c.getTime());
if (toDay.equals(dayAfter)) {
wfUrgencymsgService.sendUrgencymsg(newlistUser,instance, userid, "man",tempstr);
}
}
if (eve.equals("2")) {
c.set(Calendar.DATE,day-4);
String dayAfter = sdf.format(c.getTime());
if (toDay.equals(dayAfter)) {
wfUrgencymsgService.sendUrgencymsg(newlistUser,instance, userid, "man",tempstr);
}
}
}
//3、如果办结日期、提醒时间都为空,按照缓急来进行发送(类似发文)。以拟稿时间为节点,第xxx天时发送催办提醒【此种情况,控制在办结期限内】
else if ((txTime == null || "".equals(txTime)) && (endDate == null || "".equals(endDate))) {
//拟稿时间,String => Date类型转换
Date date = sdf.parse(createTime);
c.setTime(date);
if (eve.equals("99")) {
c.set(Calendar.DATE,day+7);
String dayAfter = sdf.format(c.getTime());
if (toDay.equals(dayAfter)) {
wfUrgencymsgService.sendUrgencymsg(newlistUser,instance, userid, "man",tempstr);
}
}
if (eve.equals("0")) { //特提,一天要办完
c.set(Calendar.DATE,day+1);
String dayAfter = sdf.format(c.getTime());
if (toDay.equals(dayAfter)) {
wfUrgencymsgService.sendUrgencymsg(newlistUser,instance, userid, "man",tempstr);
}
}
if (eve.equals("1")) {
c.set(Calendar.DATE,day+2);
String dayAfter = sdf.format(c.getTime());
if (toDay.equals(dayAfter)) {
wfUrgencymsgService.sendUrgencymsg(newlistUser,instance, userid, "man",tempstr);
}
}
if (eve.equals("2")) {
c.set(Calendar.DATE,day+4);
String dayAfter = sdf.format(c.getTime());
if (toDay.equals(dayAfter)) {
wfUrgencymsgService.sendUrgencymsg(newlistUser,instance, userid, "man",tempstr);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void msgUrgent() throws Exception {
//1、查询出需要催办的数据,并获取需要传递的参数
String SQL_TANCE =
"select distinct i.WORKFLOWINSTANCE_GUID,\n" +
" i.CREATOR,\n" + //发送人-拟稿人
" i.CURRENT_INSTANCENODE_GUID,\n" + //fromActionGuid
" i.CREATETIME,\n" + //创建日期
" i.DOTITLE,\n" + //文件名称
" i.INPARENTMODELID,\n" + //模块ID
" i.INPARENTMODELNAME,\n" + //所属模块名称
" i.INSTANCENO,\n" + //文号
" i.ISDEBUG,\n" +
" i.ISDELETED,\n" +
" i.ISEND,\n" + //是否已办结
" i.SONGDATIME,\n" + //发送时间
" i.URGENCYLEVEL,\n" + //缓急程度
" f.WFF_TEXT_TIXINGDATE, \n"+ // 提醒时间
" f.WFF_TEXT_A1 \n"+ // 设置提醒时间的前
" from WF_INSTANCE i,WF_FORMDATA F\n" +
" where i.instancetype = '1021' \n" +//参考mod_modeltype表 1021督察督办
" and i.ISDELETED = 0\n" +
" and i.ISEND = 0\n" +
" and i.creator <> '999'\n" +
" and i.ISDEBUG = 0\n" +
" and i.workflowinstance_guid =f.workflowinstanceguid\n" +
" order by i.SONGDATIME DESC";
List<Object> list = performanceMonitorDao.findNative(SQL_TANCE);
System.out.println("共"+list.size()+"条数据!");
for (int i = 0; i < list.size(); i++) {
Object obj[] = (Object[]) list.get(i);
//催办内容
String msgc = "您办理的《"+obj[4]+"》即将到达办结期限,请尽快办理!";
//缓急程度
String eve = (String) obj[12];
//发送人-拟稿人
String userid = (String) obj[1];
String workflowinstanceguid = (String) obj[0];
//提醒时间
String AlertsTime = (String) obj[13];
String tempstr = String.valueOf(msgc.replaceAll(" ", " ").replaceAll("\r\n", "<br/>"));
String SQL_TRACK =
"select w.from_action_guid,\n" +
" w.instancenode_guid,\n" +
" w.currentactioner,\n" +
" w.actionintype\n" +
" from WF_WORKFLOWACTIONTRACK w\n" +
" where workflowinstanceguid = '"+ obj[0] +"'\n" +
" and w.actionstatus in ('read', 'unread')";
List<Object> workList = performanceMonitorDao.findNative(SQL_TRACK, null);
Object work[] = (Object[]) workList.get(0);//一步步办理,可查到一条未办理数据
String fromActionGuid = (String) work[0]; //来源动作
String nodeTrackGuid = (String) work[1];
String currentactioner = (String) work[2]; //待办人
String[] usgpersion=currentactioner.split(",");
WFInstance instance=WFInstanceHandler.getInstance(workflowinstanceguid);
List<User> listUser = this.WFInstanceHandler.getCurrentNeedDealUser(instance, fromActionGuid, nodeTrackGuid);
List<User> newlistUser = new ArrayList<User>();
for (User user : listUser){
for (int j = 0; j < usgpersion.length; j++)
{
if (usgpersion[j] != null && !usgpersion[j].equals(""))
{
if (user.getEmployeeGuid().equals(usgpersion[j])){
newlistUser.add(user);
}
}
}
}
if (tempstr != null && !tempstr.equals("填写催办内容")){
wfurgencymsg.setUrgencymsgContent(tempstr);
} else{
wfurgencymsg.setUrgencymsgContent("");
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String toDay = sdf.format(new Date());//当前时间(系统自动发送催办的时间)
Calendar c = Calendar.getInstance();
Date date = sdf.parse(AlertsTime);
c.setTime(date);
String dayAfter = sdf.format(c.getTime());
System.out.println("toDay:"+toDay+"AlertsTime:"+AlertsTime);
if (toDay.equals(dayAfter)) {
wfUrgencymsgService.sendUrgencymsg(newlistUser,instance, userid, "man",tempstr);
}
}
}
/**
* 数据库配置 允许程序扫描处理逾期文件
* @return
*/
private boolean openPerformanceMonitor(){
if( "1".equals( sysConfigService.getValue("openPerformanceMonitor") ) ){
return true;
}
return false;
}
/**
* 根据接收时间 计算出需要完成的时间
* @param date
* @return
*/
public static Date getNeedDoDate(Date date){
if( null!=date ){
Calendar cal=Calendar.getInstance();
cal.setTime(date);
int weekNum = cal.get(Calendar.DAY_OF_WEEK);
if( 6==weekNum ){
if( cal.get(Calendar.HOUR_OF_DAY)>17 || ( cal.get(Calendar.HOUR_OF_DAY)==17 && cal.get(Calendar.MINUTE) >30) ){
return getNextMondayDate(date);
}
}else if( 7==weekNum || 1==weekNum ){
return getNextMondayDate(date);
}
return getNextDay(cal,1);
}
return null;
}
private static Date strToDate(Object o){
if( o!=null && StringUtils.isNotEmpty(o.toString())){
return DateUtil.strToDate(o.toString(), "yyyy-MM-dd HH:mm:ss");
}
return null;
}
public static Date getNextMondayDate(Date date){
Calendar cal=Calendar.getInstance();
cal.setTime(date);
Calendar cal2 = getNextMonday( cal);
return cal2.getTime();
}
public static Calendar getNextMonday(Calendar cal){
int week = cal.get(Calendar.DAY_OF_WEEK)-1;
if( week==0 ){
cal.add(Calendar.DAY_OF_WEEK, 1);
}else{
cal.add(Calendar.DAY_OF_WEEK, 7-week +1);
}
return cal;
}
public static Date getNextDay(Calendar cal,int num){
cal.add(Calendar.DAY_OF_YEAR, num);
return cal.getTime();
}
/**
* 获取两日期时间差 精确
* @param fDate
* @param oDate
* @return
*/
public static int getIntervalDays(Date fDate, Date oDate) {
if (null == fDate || null == oDate) {
return -1;
}
long intervalMilli = oDate.getTime() - fDate.getTime();
return (int) (intervalMilli / (24 * 60 * 60 * 1000));
}
/**
* 两日期相差天数
* @param fDate
* @param oDate
* @return
*/
public static int daysOfTwo(Date fDate, Date oDate) {
if(null!=oDate){
// Calendar aCalendar = Calendar.getInstance();
// aCalendar.setTime(fDate);
// int day1 = aCalendar.get(Calendar.DAY_OF_YEAR);
// aCalendar.setTime(oDate);
// int day2 = aCalendar.get(Calendar.DATE);
// return day2 - day1;
Long margin = oDate.getTime() - fDate.getTime();
Long longMargin = ( margin/(1000*60*60*24));
if( longMargin.intValue()==0 && margin.intValue()>0){
return 1;
}
return longMargin.intValue();
}
return 0;
}
public PerformanceMonitorDao getPerformanceMonitorDao() {
return performanceMonitorDao;
}
public void setPerformanceMonitorDao(PerformanceMonitorDao performanceMonitorDao) {
this.performanceMonitorDao = performanceMonitorDao;
}
public InstanceService getWFInstanceService() {
return WFInstanceService;
}
public void setWFInstanceService(InstanceService wFInstanceService) {
WFInstanceService = wFInstanceService;
}
public WfNeeddoService getWfNeeddoService() {
return wfNeeddoService;
}
public void setWfNeeddoService(WfNeeddoService wfNeeddoService) {
this.wfNeeddoService = wfNeeddoService;
}
public InstanceHandler getInstanceHandler() {
return instanceHandler;
}
public void setInstanceHandler(InstanceHandler instanceHandler) {
this.instanceHandler = instanceHandler;
}
public SysConfigService getSysConfigService() {
return sysConfigService;
}
public void setSysConfigService(SysConfigService sysConfigService) {
this.sysConfigService = sysConfigService;
}
public InstanceHandler getWFInstanceHandler() {
return WFInstanceHandler;
}
public void setWFInstanceHandler(InstanceHandler wFInstanceHandler) {
WFInstanceHandler = wFInstanceHandler;
}
public WfUrgencymsgService getWfUrgencymsgService() {
return wfUrgencymsgService;
}
public void setWfUrgencymsgService(WfUrgencymsgService wfUrgencymsgService) {
this.wfUrgencymsgService = wfUrgencymsgService;
}
public ForumTipsService getForumTipsService() {
return forumTipsService;
}
public void setForumTipsService(ForumTipsService forumTipsService) {
this.forumTipsService = forumTipsService;
}
public ActionTrackService getActionTrackService() {
return actionTrackService;
}
public void setActionTrackService(ActionTrackService actionTrackService) {
this.actionTrackService = actionTrackService;
}
public static void main(String[] s){
Calendar cal=Calendar.getInstance();
cal.setTime(strToDate("2014-04-25 17:32:01"));
System.out.println(cal.get(Calendar.DAY_OF_WEEK) + " "+cal.get(Calendar.HOUR_OF_DAY)+" ======= "+ cal.get(Calendar.MINUTE) );
cal.setTime(strToDate("2014-04-26 17:32:01"));
System.out.println(cal.get(Calendar.DAY_OF_WEEK) + " "+cal.get(Calendar.HOUR_OF_DAY)+" ======= "+ cal.get(Calendar.MINUTE) );
cal.setTime(strToDate("2014-04-27 17:32:01"));
System.out.println(cal.get(Calendar.DAY_OF_WEEK) + " "+cal.get(Calendar.HOUR_OF_DAY)+" ======= "+ cal.get(Calendar.MINUTE) );
Date d = getNeedDoDate(strToDate("2014-04-25 17:32:01"));
System.out.println(DateUtil.getDateToString(d) );
}
}