|
|
@@ -3,9 +3,9 @@ package com.lc.ibps.platform.plan.job;
|
|
|
import com.lc.ibps.api.form.sql.util.BeanUtils;
|
|
|
import com.lc.ibps.base.core.util.AppUtil;
|
|
|
import com.lc.ibps.base.core.util.JacksonUtil;
|
|
|
-import com.lc.ibps.base.core.util.string.StringUtil;
|
|
|
import com.lc.ibps.base.framework.id.UniqueIdUtil;
|
|
|
import com.lc.ibps.base.framework.table.ICommonDao;
|
|
|
+import com.lc.ibps.cloud.message.util.MessageQueueProductorUtil;
|
|
|
import com.lc.ibps.common.api.INewsMgrService;
|
|
|
import com.lc.ibps.common.system.persistence.entity.NewsPo;
|
|
|
import com.lc.ibps.components.quartz.BaseJob2;
|
|
|
@@ -17,8 +17,8 @@ import org.quartz.JobExecutionContext;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
-import java.time.LocalDate;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
@@ -30,7 +30,6 @@ import java.util.Map;
|
|
|
public class PersonnelTrainJob extends BaseJob2 {
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(PersonnelTrainJob.class);
|
|
|
- public static final String PLAN_DATE = "plan-date";
|
|
|
|
|
|
private final ICommonDao<?> commonDao = AppUtil.getBean(ICommonDao.class);
|
|
|
private final INewsMgrService newsMgrService = AppUtil.getBean(INewsMgrService.class);
|
|
|
@@ -45,12 +44,6 @@ public class PersonnelTrainJob extends BaseJob2 {
|
|
|
context.getJobDetail().getKey().getName(),
|
|
|
context.getTrigger().getKey().getName());
|
|
|
logger.warn("jobDataMap=is {}.", JacksonUtil.toJsonString(dataMap.getWrappedMap()));
|
|
|
- LocalDate localDate = LocalDate.now();
|
|
|
- String planDateParam = dataMap.getString(PLAN_DATE);
|
|
|
- if(StringUtil.isNotBlank(planDateParam)){
|
|
|
- localDate = LocalDate.parse(planDateParam);
|
|
|
- }
|
|
|
- String planDate = localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
|
|
|
String sql = "select p.id_,p.bian_zhi_ren_,e.name_,p.bian_zhi_bu_men_,d.name_ as dept_name_,p.pei_xun_nei_rong_," +
|
|
|
"date_format(p.pei_xun_shi_jian_,'%Y-%m-%d') pei_xun_shi_jian_,date_format(p.pei_xun_jie_shu_s,'%Y-%m-%d') " +
|
|
|
@@ -64,82 +57,110 @@ public class PersonnelTrainJob extends BaseJob2 {
|
|
|
if (BeanUtils.isNotEmpty(pxList)){
|
|
|
for (Map<String, Object> train : pxList) {
|
|
|
String id = train.get("id_").toString();
|
|
|
- String userId = StringUtil.defaultString(train.get("bian_zhi_ren_").toString(),"");
|
|
|
- String userName = StringUtil.defaultString(train.get("name_").toString(),"");
|
|
|
- String deptName = StringUtil.defaultString(train.get("dept_name_").toString(),"");
|
|
|
-
|
|
|
- commonDao.execute("update t_rypxcjb set shi_fou_guo_shen_='未开始' where id_= '"+id+"'");
|
|
|
-
|
|
|
- String peiXunNeiRong = StringUtil.defaultString(train.get("pei_xun_nei_rong_").toString(),"");
|
|
|
- String starDate = StringUtil.defaultString(train.get("pei_xun_shi_jian_").toString(),"");
|
|
|
- String endDate = StringUtil.defaultString(train.get("pei_xun_jie_shu_s").toString(),"");
|
|
|
- String didian = StringUtil.defaultString(train.get("di_dian_").toString(),"");
|
|
|
- String peiXunDiDian = StringUtil.defaultString(train.get("pei_xun_di_dian_").toString(),"");
|
|
|
- String nameIds = StringUtil.defaultString(train.get("pei_xun_ren_yuan_").toString(),"");
|
|
|
- String teachIds = StringUtil.defaultString(train.get("pei_xun_lao_shi_").toString(),"");
|
|
|
- String bianZhiBuMen = StringUtil.defaultString(train.get("pei_xun_lao_shi_").toString(),"");
|
|
|
-
|
|
|
- if (BeanUtils.isNotEmpty(teachIds)){
|
|
|
- nameIds = nameIds + "," + teachIds;
|
|
|
+ String userId = train.get("bian_zhi_ren_").toString();
|
|
|
+ String userName = train.get("name_").toString();
|
|
|
+ String deptName = train.get("dept_name_").toString();
|
|
|
+ String starDate = train.get("pei_xun_shi_jian_").toString();
|
|
|
+ String peiXunNeiRong = train.get("pei_xun_nei_rong_").toString();
|
|
|
+
|
|
|
+ // 信息不全,发消息提醒 否则发公告
|
|
|
+ if (BeanUtils.isEmpty(train.get("pei_xun_jie_shu_s")) || BeanUtils.isEmpty(train.get("pei_xun_ren_yuan_"))
|
|
|
+ || BeanUtils.isEmpty(train.get("pei_xun_lao_shi_")) || BeanUtils.isEmpty(train.get("pei_xun_di_dian_"))){
|
|
|
+ List<String> receiver = new ArrayList<>();
|
|
|
+ // 提醒培训负责人
|
|
|
+ String fuzeren = train.get("bian_zhi_ren_").toString();
|
|
|
+ receiver.add(fuzeren);
|
|
|
+ String title = "培训准备通知";
|
|
|
+ String content = "您有一个主题为《"+peiXunNeiRong+"》的培训将于 "+starDate+" 开始,请及时前往培训管理页面完善培训信息!";
|
|
|
+ this.sendCalendarRemind(id,fuzeren,content,starDate,title);
|
|
|
+ MessageQueueProductorUtil.send("PersonnelTrainJob", "system" , "inner" , receiver,null , title, content, null, null, null);
|
|
|
}
|
|
|
- StringBuilder nameStr = new StringBuilder();
|
|
|
- String[] ids = nameIds.split(",");
|
|
|
- if (ids.length>1){
|
|
|
+
|
|
|
+ if (BeanUtils.isNotEmpty(train.get("pei_xun_jie_shu_s")) && BeanUtils.isNotEmpty(train.get("pei_xun_ren_yuan_"))
|
|
|
+ && BeanUtils.isNotEmpty(train.get("pei_xun_lao_shi_")) && BeanUtils.isNotEmpty(train.get("pei_xun_di_dian_"))){
|
|
|
+ String endDate = train.get("pei_xun_jie_shu_s").toString();
|
|
|
+ String didian = train.get("di_dian_").toString();
|
|
|
+ String peiXunDiDian = train.get("pei_xun_di_dian_").toString();
|
|
|
+ String nameIds = train.get("pei_xun_ren_yuan_").toString();
|
|
|
+ String teachIds = train.get("pei_xun_lao_shi_").toString();
|
|
|
+ String bianZhiBuMen = train.get("bian_zhi_bu_men_").toString();
|
|
|
+
|
|
|
+ if (BeanUtils.isNotEmpty(teachIds)){
|
|
|
+ nameIds = nameIds + "," + teachIds;
|
|
|
+ }
|
|
|
+ StringBuilder nameStr = new StringBuilder();
|
|
|
+ String[] ids = nameIds.split(",");
|
|
|
+ if (ids.length>1){
|
|
|
+ for (String str : ids){
|
|
|
+ String name = partyEmployeeRepository.get(str).getName();
|
|
|
+ nameStr.append(name).append(",");
|
|
|
+ }
|
|
|
+ nameStr.deleteCharAt(nameStr.length() - 1);
|
|
|
+ }else {
|
|
|
+ nameStr = new StringBuilder(partyEmployeeRepository.get(nameIds).getName());
|
|
|
+ }
|
|
|
+
|
|
|
for (String str : ids){
|
|
|
String name = partyEmployeeRepository.get(str).getName();
|
|
|
- nameStr.append(name).append(",");
|
|
|
+ this.sendCalendarByDone(id,str,name,peiXunNeiRong,starDate,endDate,peiXunDiDian,nameStr.toString());
|
|
|
}
|
|
|
- }else {
|
|
|
- nameStr = new StringBuilder(partyEmployeeRepository.get(nameIds).getName());
|
|
|
- }
|
|
|
|
|
|
- for (String str : ids){
|
|
|
- String name = partyEmployeeRepository.get(str).getName();
|
|
|
- sendCalendar(id,str,name,peiXunNeiRong,starDate,endDate,peiXunDiDian,nameStr.toString());
|
|
|
+ String content = "<p> " +
|
|
|
+ " " +
|
|
|
+ " <strong> 培训通知</strong></p >" +
|
|
|
+ "<p> <br/></p ><p><strong>一、培训主题:</strong></p><p> "+peiXunNeiRong+"</p >" +
|
|
|
+ "<p><strong>二、时间安排:</strong></p ><p> 开始时间:"+starDate+" </p >" +
|
|
|
+ "<p> 结束时间:"+endDate+"</p ><p><strong>三、培训地点:"+peiXunDiDian+"</strong></p >" +
|
|
|
+ "<p> "+peiXunDiDian+"</p ><p><strong>四、参加人员:</strong></p >" +
|
|
|
+ "<p> "+nameStr+"</p ><p><br style=\"text-wrap: wrap;\"/></p ><p><br/></p >";
|
|
|
+
|
|
|
+ NewsPo newsPo = new NewsPo();
|
|
|
+ newsPo.setAuthor(userName);
|
|
|
+ newsPo.setContent(content);
|
|
|
+ newsPo.setDepId(bianZhiBuMen);
|
|
|
+ newsPo.setDepName(deptName);
|
|
|
+ newsPo.setPublicDate(new Date());
|
|
|
+ newsPo.setPublicItem("notices");
|
|
|
+ newsPo.setPublic0("Y");
|
|
|
+ newsPo.setStatus("publish");
|
|
|
+ newsPo.setTitle("培训通知");
|
|
|
+ newsPo.setUserId(userId);
|
|
|
+ newsPo.setUserName(userName);
|
|
|
+ newsPo.setType(didian);
|
|
|
+ newsMgrService.save(newsPo);
|
|
|
+ commonDao.execute("update t_rypxcjb set shi_fou_guo_shen_='未开始' where id_= '"+id+"'");
|
|
|
}
|
|
|
-
|
|
|
- String content = "<p> " +
|
|
|
- " " +
|
|
|
- " <strong> 培训通知</strong></p >" +
|
|
|
- "<p> <br/></p ><p><strong>一、培训主题:</strong></p><p> "+peiXunNeiRong+"</p >" +
|
|
|
- "<p><strong>二、时间安排:</strong></p ><p> 开始时间:"+starDate+" </p >" +
|
|
|
- "<p> 结束时间:"+endDate+"</p ><p><strong>三、培训地点:</strong></p >" +
|
|
|
- "<p> "+peiXunDiDian+"</p ><p><strong>四、参加人员:</strong></p >" +
|
|
|
- "<p> "+nameStr+"</p ><p><br style=\"text-wrap: wrap;\"/></p ><p><br/></p >";
|
|
|
-
|
|
|
- NewsPo newsPo = new NewsPo();
|
|
|
- newsPo.setAuthor(userName);
|
|
|
- newsPo.setContent(content);
|
|
|
- newsPo.setDepId(bianZhiBuMen);
|
|
|
- newsPo.setDepName(deptName);
|
|
|
- newsPo.setPublicDate(new Date());
|
|
|
- newsPo.setPublicItem("notices");
|
|
|
- newsPo.setPublic0("Y");
|
|
|
- newsPo.setStatus("publish");
|
|
|
- newsPo.setTitle("培训通知");
|
|
|
- newsPo.setUserId(userId);
|
|
|
- newsPo.setUserName(userName);
|
|
|
- newsPo.setType(didian);
|
|
|
- newsMgrService.save(newsPo);
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 保存日历日程信息
|
|
|
- private void sendCalendar(String id,String userId,String userName,String peiXunNeiRong,String starDate,String endDate,String didian,String nameStr){
|
|
|
+ // 培训提醒
|
|
|
+ private void sendCalendarRemind(String id,String userId,String peiXunNeiRong,String starDate,String title){
|
|
|
+ PartyUserCalendarPo calendarPo = new PartyUserCalendarPo();
|
|
|
+ calendarPo.setDataSourceId(id);
|
|
|
+ calendarPo.setUserId(userId);
|
|
|
+ calendarPo.setTitle(title);
|
|
|
+ calendarPo.setContent(peiXunNeiRong);
|
|
|
+ calendarPo.setStartTime(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
|
|
|
+ calendarPo.setEndTime(starDate);
|
|
|
+ calendarPo.setEmergencyState("2");
|
|
|
+ calendarPo.setId(UniqueIdUtil.getId());
|
|
|
+ calendarPo.setCreateBy(userId);
|
|
|
+ calendarDao.create(calendarPo);
|
|
|
+ }
|
|
|
+
|
|
|
+ //培训通知
|
|
|
+ private void sendCalendarByDone(String id,String userId,String userName,String peiXunNeiRong,String starDate,String endDate,String didian,String nameStr){
|
|
|
PartyUserCalendarPo calendarPo = new PartyUserCalendarPo();
|
|
|
calendarPo.setDataSourceId(id);
|
|
|
calendarPo.setUserId(userId);
|
|
|
calendarPo.setUserName(userName);
|
|
|
calendarPo.setTitle("培训通知");
|
|
|
-
|
|
|
String neiRong = peiXunNeiRong+"培训通知:\n" +
|
|
|
" 1.培训主题: "+peiXunNeiRong+"\n" +
|
|
|
" 2.时间安排: 开始时间:"+starDate+" 结束时间:"+endDate+"\n" +
|
|
|
" 3.培训地点: "+didian+" \n" +
|
|
|
" 4.参加人员: "+nameStr;
|
|
|
-
|
|
|
calendarPo.setContent(neiRong);
|
|
|
calendarPo.setStartTime(starDate);
|
|
|
calendarPo.setEndTime(endDate);
|