232 lines
10 KiB
Java
232 lines
10 KiB
Java
package com.zcloud.util;
|
||
|
||
import java.util.ArrayList;
|
||
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.CheckRecordService;
|
||
import com.zcloud.service.bus.CorpInfoService;
|
||
import com.zcloud.service.bus.ListManagerService;
|
||
import com.zcloud.service.bus.MSMLoginService;
|
||
import com.zcloud.service.bus.PersonObtainEvidenceService;
|
||
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 DxtzQuartzJob extends BaseController{
|
||
@Autowired
|
||
private PersonObtainEvidenceService personobtainevidenceService;
|
||
|
||
@Autowired
|
||
private SMSManagementService smsmanagementService;
|
||
@Autowired
|
||
private ListManagerService listmanagerService;
|
||
|
||
@Autowired
|
||
private CheckRecordService checkrecordService;
|
||
@Autowired
|
||
private UsersService usersService;
|
||
@Autowired
|
||
private CorpInfoService corpInfoService;
|
||
|
||
@Autowired
|
||
private MSMLoginService msmloginService;
|
||
|
||
@Scheduled(cron ="0 0 8 ? * *")
|
||
// @Scheduled(cron ="0 */1 * * * ?")
|
||
public void scheduled(){
|
||
System.out.println("进来了");
|
||
try {
|
||
System.out.println( "============定时查询人员证件到期==========");
|
||
PageData pd = new PageData();
|
||
try {
|
||
List<PageData> varList = listmanagerService.listAllByCorpMsm(pd); //列出ListManager列表
|
||
if(varList != null && varList.size() > 0) {
|
||
for (PageData list : varList) {
|
||
String cycle = list.getString("PERIOD");
|
||
if(list.getString("TYPE").equals("listType0005")) {
|
||
if(DateUtil.timeCalendar(new Date(),DateUtil.fomatDateTime(list.getString("START_DATE")+" 00:00:00"),DateUtil.fomatDateTime(list.getString("END_DATE")+" 23:59:59"))){
|
||
PageData type = new PageData();
|
||
type.put("LISTMANAGER_ID", list.get("LISTMANAGER_ID"));
|
||
type.put("IS_XUN", 1);
|
||
type.put("FINISHED", '1');
|
||
type.put("BEGINTIME", list.getString("START_DATE")+" 00:00:00");
|
||
type.put("ENDTIME", list.getString("END_DATE")+" 23:59:59");
|
||
List<PageData> records = checkrecordService.listAll(type);
|
||
list.put("checkCount", records==null?0:records.size());
|
||
}
|
||
continue;
|
||
}
|
||
if(cycle.equals("checkPeriod0001")) {// 每日
|
||
PageData type = new PageData();
|
||
type.put("LISTMANAGER_ID", list.get("LISTMANAGER_ID"));
|
||
type.put("IS_DAY", 1);
|
||
type.put("FINISHED", '1');
|
||
List<PageData> records = checkrecordService.listAll(type);
|
||
list.put("checkCount", records==null?0:records.size());
|
||
// if(records!=null && records.size()>0) {
|
||
// PageData record = new PageData();
|
||
// record.put("CHECKRECORD_ID", records.get(0).get("CHECKRECORD_ID"));
|
||
// List<PageData> checkedList = recordItemService.listAll(record);
|
||
// list.put("checkedItem", checkedList==null?0:checkedList.size());
|
||
// }
|
||
} else if(cycle.equals("checkPeriod0002")) {// 每周
|
||
PageData type = new PageData();
|
||
type.put("LISTMANAGER_ID", list.get("LISTMANAGER_ID"));
|
||
type.put("IS_WEEK", 1);
|
||
type.put("FINISHED", '1');
|
||
List<PageData> records = checkrecordService.listAll(type);
|
||
list.put("checkCount", records==null?0:records.size());
|
||
}else if(cycle.equals("checkPeriod0003")) {// 每旬
|
||
//1-10
|
||
if(DateUtil.timeCalendar(new Date(),DateUtil.fomatDateTime(DateUtil.getYear()+"-"+DateUtil.getMonth()+"-"+"01 00:00:00"),DateUtil.fomatDateTime(DateUtil.getYear()+"-"+DateUtil.getMonth()+"-"+"10 23:59:59"))){
|
||
PageData type = new PageData();
|
||
type.put("LISTMANAGER_ID", list.get("LISTMANAGER_ID"));
|
||
type.put("IS_XUN", 1);
|
||
type.put("FINISHED", '1');
|
||
type.put("BEGINTIME", DateUtil.getYear()+"-"+DateUtil.getMonth()+"-"+"01 00:00:00");
|
||
type.put("ENDTIME",DateUtil.getYear()+"-"+DateUtil.getMonth()+"-"+"10 23:59:59");
|
||
List<PageData> records = checkrecordService.listAll(type);
|
||
list.put("checkCount", records==null?0:records.size());
|
||
}
|
||
//10-20
|
||
if(DateUtil.timeCalendar(new Date(),DateUtil.fomatDateTime(DateUtil.getYear()+"-"+DateUtil.getMonth()+"-"+"11 00:00:00"),DateUtil.fomatDateTime(DateUtil.getYear()+"-"+DateUtil.getMonth()+"-"+"20 23:59:59"))){
|
||
PageData type = new PageData();
|
||
type.put("LISTMANAGER_ID", list.get("LISTMANAGER_ID"));
|
||
type.put("IS_XUN", 1);
|
||
type.put("FINISHED", '1');
|
||
type.put("BEGINTIME", DateUtil.getYear()+"-"+DateUtil.getMonth()+"-"+"11 00:00:00");
|
||
type.put("ENDTIME",DateUtil.getYear()+"-"+DateUtil.getMonth()+"-"+"20 23:59:59");
|
||
List<PageData> records = checkrecordService.listAll(type);
|
||
list.put("checkCount", records==null?0:records.size());
|
||
}
|
||
//20-月底
|
||
if(DateUtil.timeCalendar(new Date(),DateUtil.fomatDateTime(DateUtil.getYear()+"-"+DateUtil.getMonth()+"-"+"21 00:00:00"),DateUtil.fomatDateTime(DateUtil.getMonthEndDay()+ " 23:59:59"))){
|
||
PageData type = new PageData();
|
||
type.put("LISTMANAGER_ID", list.get("LISTMANAGER_ID"));
|
||
type.put("IS_XUN", 1);
|
||
type.put("FINISHED", '1');
|
||
type.put("BEGINTIME", DateUtil.getYear()+"-"+DateUtil.getMonth()+"-"+"21 00:00:00");
|
||
type.put("ENDTIME", DateUtil.getMonthEndDay() + " 23:59:59");
|
||
List<PageData> records = checkrecordService.listAll(type);
|
||
list.put("checkCount", records==null?0:records.size());
|
||
}
|
||
|
||
}else if(cycle.equals("checkPeriod0004")) {// 每月
|
||
PageData type = new PageData();
|
||
type.put("LISTMANAGER_ID", list.get("LISTMANAGER_ID"));
|
||
type.put("IS_MONTH", 1);
|
||
type.put("FINISHED", '1');
|
||
List<PageData> records = checkrecordService.listAll(type);
|
||
list.put("checkCount", records==null?0:records.size());
|
||
}else if(cycle.equals("checkPeriod0005")) {// 每季
|
||
PageData type = new PageData();
|
||
type.put("LISTMANAGER_ID", list.get("LISTMANAGER_ID"));
|
||
type.put("IS_QUARTER", 1);
|
||
type.put("FINISHED", '1');
|
||
List<PageData> records = checkrecordService.listAll(type);
|
||
list.put("checkCount", records==null?0:records.size());
|
||
}else if(cycle.equals("checkPeriod0007")) {// 每半年
|
||
PageData type = new PageData();
|
||
type.put("LISTMANAGER_ID", list.get("LISTMANAGER_ID"));
|
||
type.put("IS_HALFYEAR", 1);
|
||
type.put("FINISHED", '1');
|
||
List<PageData> records = checkrecordService.listAll(type);
|
||
list.put("checkCount", records==null?0:records.size());
|
||
}else if(cycle.equals("checkPeriod0006")) {// 每年
|
||
PageData type = new PageData();
|
||
type.put("LISTMANAGER_ID", list.get("LISTMANAGER_ID"));
|
||
type.put("IS_YEAR", 1);
|
||
type.put("FINISHED", '1');
|
||
List<PageData> records = checkrecordService.listAll(type);
|
||
list.put("checkCount", records==null?0:records.size());
|
||
}
|
||
|
||
}
|
||
// 用户合集
|
||
Map<String, PageData> varMap = new HashMap<String, PageData>();
|
||
for(int i = 0;i<varList.size();i++) {
|
||
// 查询未检查清单,并按userid分组
|
||
if(Integer.parseInt(varList.get(i).get("checkCount").toString()) == 0) {
|
||
if(!varMap.containsKey(varList.get(i).get("USER_ID").toString())) {// 用户不存在时,向合集中加入该用户
|
||
PageData user = new PageData();
|
||
user.put("USER_ID", varList.get(i).get("USER_ID"));
|
||
user.put("USER_NAME", varList.get(i).get("USER_NAME"));
|
||
user.put("PHONE", varList.get(i).get("PHONE"));
|
||
user.put("NUM", 1);
|
||
varMap.put(varList.get(i).get("USER_ID").toString(), user);
|
||
} else {
|
||
PageData uData = varMap.get(varList.get(i).get("USER_ID").toString());
|
||
uData.put("NUM", Integer.valueOf(uData.get("NUM").toString())+1);
|
||
varMap.put(varList.get(i).get("USER_ID").toString(), uData);
|
||
}
|
||
}
|
||
}
|
||
// 短信集合
|
||
List<PageData> msmList = new ArrayList<PageData>(varMap.values());
|
||
int i=0;
|
||
for(PageData m:msmList) {
|
||
PageData lpd = new PageData();
|
||
lpd.put("STATE", "OK");
|
||
lpd.put("CORPINFO_ID", m.getString("CORPINFO_ID"));
|
||
List<PageData> lList =msmloginService.listAll(lpd);
|
||
PageData sms = new PageData();
|
||
sms.put("CORPINFO_ID", m.getString("CORPINFO_ID"));
|
||
sms.put("ISENABLE", "1");
|
||
sms.put("SMSTYPE", "SMS_215796875");
|
||
List<PageData> sList =smsmanagementService.listAll(sms);
|
||
if(Integer.parseInt(m.getString("SMS_COUNT"))-lList.size()>0&&sList.size()>0) {
|
||
Map<String,Object> mes = new HashMap<String,Object>();
|
||
// String code=getCode();
|
||
mes.put("phone", m.getString("PHONE"));
|
||
mes.put("templateCode", "SMS_215796875");
|
||
mes.put("investigate", m.getString("NUM"));
|
||
mes.put("day", DateUtil.getDay());
|
||
mes.put("type", "7");
|
||
// mes.put("code", code);
|
||
System.out.println("发送成功!----------------"+i++);
|
||
// SendSmsResponse ssms= AliSmsUtil.sendSms(mes);
|
||
// msmloginService.addForAliSmsUtil(mes, "工作提醒", ssms);
|
||
}
|
||
}
|
||
|
||
}
|
||
} catch (Exception e) {
|
||
try {
|
||
//shutdownJob(context,pd,parameter);
|
||
} catch (Exception e1) {
|
||
e1.printStackTrace();
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
|
||
}
|