81,091
社区成员
发帖
与我相关
我的任务
分享
配置文件
<bean id="jobDetailBean" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass">
<value>com.dne.cn.framework.report.timmer.TimerTask</value>
</property>
</bean>
<bean id="cronReportTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="jobDetailBean" />
<property name="cronExpression">
<value>0 02 13 ? * WED </value>
</property>
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronReportTrigger" />
</list>
</property>
</bean>
public class TimerTask extends QuartzJobBean {
@Autowired
private IUserService userService;
@Autowired
private ISmsInventoryInfoService smsInventoryInfoServic;
public void setUserService(IUserService userService) {
this.userService = userService;
}
public void setSmsInventoryInfoServic(
ISmsInventoryInfoService smsInventoryInfoServic) {
this.smsInventoryInfoServic = smsInventoryInfoServic;
}
@Override
protected void executeInternal(JobExecutionContext arg0)
throws JobExecutionException {
List<Long> tpsIds = smsInventoryInfoServic.getAllTps();
UserModel um = null;
List<Long> tmList = new ArrayList<Long>();
List<Long> crmList = new ArrayList<Long>();
for (Long tpsId : tpsIds) {
try {
List<String> emailAddresses = getEmail(tpsId);
um = userService.getEntityById(tpsId);// 查询出tm
if (um != null) {
String path = smsInventoryInfoServic.createExcel(um, null,
null);
if (um != null && !tmList.contains(um.getParentId()))
tmList.add(um.getParentId());
um = userService.getEntityById(um.getParentId());// crm
if (um != null && !crmList.contains(um.getParentId()))
crmList.add(um.getParentId());
// sendMail.send(emailAddresses, path, "一周报告", "一周报告");
// Thread.sleep(1000 * 20);
}
} catch (Exception e) {
e.printStackTrace();
continue;
}
}
}
private List<String> getEmail(Long tpsId) {
List<String> emailAddresses = new ArrayList<String>();
UserModel um = userService.getEntityById(tpsId);
if (um != null && um.getUserEmail() != null)
emailAddresses.add(um.getUserEmail());
return emailAddresses;
}
}