qa-prevention-gwj/src/main/java/com/zcloud/util/QtBackupQuartzJob.java

233 lines
9.6 KiB
Java
Raw Normal View History

2023-11-07 09:32:12 +08:00
package com.zcloud.util;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.zcloud.controller.base.BaseController;
import com.zcloud.entity.PageData;
import com.zcloud.service.bus.CorpInfoService;
import com.zcloud.service.bus.MSMLoginService;
import com.zcloud.service.bus.QualificationsService;
import com.zcloud.service.bus.SMSManagementService;
import com.zcloud.service.fhdb.BRdbService;
import com.zcloud.service.system.UsersService;
import com.zcloud.util.AliSmsUtil;
import com.zcloud.util.DateUtil;
import com.zcloud.util.DbFH;
import com.zcloud.util.FileUtil;
import com.zcloud.util.SpringUtil;
import com.zcloud.util.Tools;
@Configuration //1.主要用于标记配置类兼备Component的效果。
public class QtBackupQuartzJob extends BaseController{
@Autowired
private QualificationsService qualificationsService;
@Autowired
private SMSManagementService smsmanagementService;
@Autowired
private UsersService usersService;
@Autowired
private CorpInfoService corpInfoService;
@Autowired
private MSMLoginService msmloginService;
@Scheduled(cron ="0 0 12 * * ?")
// @Scheduled(cron ="0 */5 * * * ?")
public void scheduled(){
System.out.println("进来了");
try {
System.out.println( "============定时查询企业证件到期==========");
PageData pd = new PageData();
try {
List<PageData> qList =qualificationsService.listAll(pd);
for(PageData q:qList) {
long a=DateUtil.getDaySub(q.getString("VALIDITYTIME"),DateUtil.getDay());
PageData corpinfo=corpInfoService.findById(q);
PageData lpd = new PageData();
lpd.put("STATE", "OK");
lpd.put("CORPINFO_ID", pd.getString("CORPINFO_ID"));
int usedCount = msmloginService.msUsedCount(lpd);
if(a==90) {
q.put("ISNEAREXPIRATION", "1");
qualificationsService.edit(q);
if(corpinfo.getString("ISRECEIVE").equals("1")&&Integer.parseInt(corpinfo.getString("SMS_COUNT"))-usedCount>0) {
Map<String,Object> mes = new HashMap<String,Object>();
// String code=getCode();
mes.put("phone", corpinfo.getString("LR_MOBILE"));
mes.put("templateCode", "SMS_215790824");
mes.put("corpname", corpinfo.getString("CORP_NAME"));
mes.put("qname", q.getString("NAME"));
mes.put("month", "三");
mes.put("time", q.getString("VALIDITYTIME"));
mes.put("type", "3");
// mes.put("code", code);
SendSmsResponse ssms= AliSmsUtil.sendSms(mes);
msmloginService.addForAliSmsUtil(mes, corpinfo.getString("CORPINFO_ID"), ssms);
//System.out.println(ssms.getCode());
PageData sms = new PageData();
sms.put("CORPINFO_ID", corpinfo.getString("CORPINFO_ID"));
sms.put("ISENABLE", "1");
sms.put("SMSTYPE", "SMS_215790824");
List<PageData> sList =smsmanagementService.listAll(sms);
if(sList.size()>0) {
String[] uid=sList.get(0).getString("ADDRESSEE").split(",");
for(int i=0;i<uid.length;i++) {
PageData suser = new PageData();
suser.put("USER_ID", uid[i].toString());
suser = usersService.findById(suser);
if(suser.get("USERNAME") != null && Tools.notEmpty(suser.get("USERNAME").toString())) {
String uphone=suser.get("USERNAME").toString();
Map<String,Object> umes = new HashMap<String,Object>();
umes.put("phone", uphone);
umes.put("templateCode", "SMS_215790824");
umes.put("corpname", corpinfo.getString("CORP_NAME"));
umes.put("qname", q.getString("NAME"));
umes.put("month", "三");
umes.put("time", q.getString("VALIDITYTIME"));
umes.put("type", "3");
PageData ewpd = new PageData();
ewpd.put("STATE", "OK");
ewpd.put("CORPINFO_ID", pd.getString("CORPINFO_ID"));
int ewusedCount = msmloginService.msUsedCount(lpd);
if(Integer.parseInt(corpinfo.getString("SMS_COUNT"))-ewusedCount>0) {
SendSmsResponse ussms= AliSmsUtil.sendSms(umes);
msmloginService.addForAliSmsUtil(umes, corpinfo.getString("CORPINFO_ID"), ussms);
}
}
}
}
}
}else if(a==30){
if(corpinfo.getString("ISRECEIVE").equals("1")&&Integer.parseInt(corpinfo.getString("SMS_COUNT"))-usedCount>0) {
Map<String,Object> mes = new HashMap<String,Object>();
// String code=getCode();
mes.put("phone", corpinfo.getString("LR_MOBILE"));
mes.put("templateCode", "SMS_215790824");
mes.put("corpname", corpinfo.getString("CORP_NAME"));
mes.put("qname", q.getString("NAME"));
mes.put("month", "一");
mes.put("time", q.getString("VALIDITYTIME"));
mes.put("type", "3");
SendSmsResponse ssms= AliSmsUtil.sendSms(mes);
msmloginService.addForAliSmsUtil(mes, corpinfo.getString("CORPINFO_ID"), ssms);
//System.out.println(ssms.getCode());
PageData sms = new PageData();
sms.put("CORPINFO_ID", corpinfo.getString("CORPINFO_ID"));
sms.put("ISENABLE", "1");
sms.put("SMSTYPE", "SMS_215790824");
List<PageData> sList =smsmanagementService.listAll(sms);
if(sList.size()>0) {
String[] uid=sList.get(0).getString("ADDRESSEE").split(",");
for(int i=0;i<uid.length;i++) {
PageData suser = new PageData();
suser.put("USER_ID", uid[i].toString());
suser = usersService.findById(suser);
if(suser.get("USERNAME") != null && Tools.notEmpty(suser.get("USERNAME").toString())) {
String uphone=suser.get("USERNAME").toString();
Map<String,Object> umes = new HashMap<String,Object>();
umes.put("phone", uphone);
umes.put("templateCode", "SMS_215790824");
umes.put("corpname", corpinfo.getString("CORP_NAME"));
umes.put("qname", q.getString("NAME"));
umes.put("month", "半");
umes.put("time", q.getString("VALIDITYTIME"));
umes.put("type", "3");
PageData ewpd = new PageData();
ewpd.put("STATE", "OK");
ewpd.put("CORPINFO_ID", pd.getString("CORPINFO_ID"));
int ewusedCount = msmloginService.msUsedCount(lpd);
if(Integer.parseInt(corpinfo.getString("SMS_COUNT"))-ewusedCount>0) {
SendSmsResponse ussms= AliSmsUtil.sendSms(umes);
msmloginService.addForAliSmsUtil(umes, corpinfo.getString("CORPINFO_ID"), ussms);
}
}
}
}
}
}else if(a==15){
if(corpinfo.getString("ISRECEIVE").equals("1")&&Integer.parseInt(corpinfo.getString("SMS_COUNT"))-usedCount>0) {
Map<String,Object> mes = new HashMap<String,Object>();
// String code=getCode();
mes.put("phone", corpinfo.getString("LR_MOBILE"));
mes.put("templateCode", "SMS_215790824");
mes.put("corpname", corpinfo.getString("CORP_NAME"));
mes.put("qname", q.getString("NAME"));
mes.put("month", "半");
mes.put("time", q.getString("VALIDITYTIME"));
mes.put("type", "3");
// mes.put("code", code);
SendSmsResponse ssms= AliSmsUtil.sendSms(mes);
msmloginService.addForAliSmsUtil(mes, corpinfo.getString("CORPINFO_ID"), ssms);
//System.out.println(ssms.getCode());
PageData sms = new PageData();
sms.put("CORPINFO_ID", corpinfo.getString("CORPINFO_ID"));
sms.put("ISENABLE", "1");
sms.put("SMSTYPE", "SMS_215790824");
List<PageData> sList =smsmanagementService.listAll(sms);
if(sList.size()>0) {
String[] uid=sList.get(0).getString("ADDRESSEE").split(",");
for(int i=0;i<uid.length;i++) {
PageData suser = new PageData();
suser.put("USER_ID", uid[i].toString());
suser = usersService.findById(suser);
if(suser.get("USERNAME") != null && Tools.notEmpty(suser.get("USERNAME").toString())) {
String uphone=suser.get("USERNAME").toString();
Map<String,Object> umes = new HashMap<String,Object>();
umes.put("phone", uphone);
umes.put("templateCode", "SMS_215790824");
umes.put("corpname", corpinfo.getString("CORP_NAME"));
umes.put("qname", q.getString("NAME"));
umes.put("month", "半");
umes.put("time", q.getString("VALIDITYTIME"));
umes.put("type", "3");
PageData ewpd = new PageData();
ewpd.put("STATE", "OK");
ewpd.put("CORPINFO_ID", pd.getString("CORPINFO_ID"));
int ewusedCount = msmloginService.msUsedCount(lpd);
if(Integer.parseInt(corpinfo.getString("SMS_COUNT"))-ewusedCount>0) {
SendSmsResponse ussms= AliSmsUtil.sendSms(umes);
msmloginService.addForAliSmsUtil(umes, corpinfo.getString("CORPINFO_ID"), ussms);
}
}
}
}
}
}
}
} catch (Exception e) {
try {
//shutdownJob(context,pd,parameter);
} catch (Exception e1) {
e1.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}