|
|
@@ -0,0 +1,97 @@
|
|
|
+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.common.api.INewsMgrService;
|
|
|
+import com.lc.ibps.common.system.persistence.entity.NewsPo;
|
|
|
+import com.lc.ibps.components.quartz.BaseJob2;
|
|
|
+import com.lc.ibps.org.party.persistence.dao.PartyUserCalendarDao;
|
|
|
+import com.lc.ibps.org.party.persistence.entity.PartyUserCalendarPo;
|
|
|
+import org.quartz.JobDataMap;
|
|
|
+import org.quartz.JobExecutionContext;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author gaozl
|
|
|
+ * @Description 人员培训通知
|
|
|
+ */
|
|
|
+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);
|
|
|
+ private final PartyUserCalendarDao calendarDao = AppUtil.getBean(PartyUserCalendarDao.class);
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void executeJob(JobExecutionContext context) throws Exception {
|
|
|
+ JobDataMap dataMap = context.getMergedJobDataMap();
|
|
|
+ logger.warn("group={} job={} trigger={} is running.",
|
|
|
+ context.getJobDetail().getKey().getGroup(),
|
|
|
+ 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_shi_jian_ from t_rypxcjb p " +
|
|
|
+ "left join ibps_party_employee e on e.id_=p.bian_zhi_ren_ " +
|
|
|
+ "left join ibps_party_position d on d.id_=p.bian_zhi_bu_men_ " +
|
|
|
+ "where shi_fou_guo_shen_ ='未发布' and pei_xun_shi_jian_ >=now() and pei_xun_shi_jian_<=date_add(now(), interval 1 week)";
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ List<Map<String, Object>> pxList = (List<Map<String, Object>>) commonDao.query(sql);
|
|
|
+
|
|
|
+ if (BeanUtils.isNotEmpty(pxList)){
|
|
|
+ String currentDateStr = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ for (Map<String, Object> train : pxList) {
|
|
|
+ String id = train.get("id_").toString();
|
|
|
+ String userId = train.get("bian_zhi_ren_").toString();
|
|
|
+ String userName = train.get("name_").toString();
|
|
|
+ String deptName = train.get("dept_name_").toString();
|
|
|
+
|
|
|
+ commonDao.execute("update t_rypxcjb set shi_fou_guo_shen_='未开始' where id_= '"+id+"'");
|
|
|
+
|
|
|
+ NewsPo newsPo = new NewsPo();
|
|
|
+ newsPo.setAuthor(userName);
|
|
|
+ newsPo.setContent("<p>关于参加全国两会培训的通知</p>");
|
|
|
+ newsPo.setDepId(train.get("bian_zhi_bu_men_").toString());
|
|
|
+ newsPo.setDepName(deptName);
|
|
|
+ newsPo.setPublicDate(new Date());
|
|
|
+ newsPo.setPublicItem("notices");
|
|
|
+ newsPo.setStatus("publish");
|
|
|
+ newsPo.setTitle("关于培训计划通知");
|
|
|
+ newsPo.setUserId(userId);
|
|
|
+ newsPo.setUserName(userName);
|
|
|
+ newsMgrService.save(newsPo);
|
|
|
+
|
|
|
+ PartyUserCalendarPo calendarPo = new PartyUserCalendarPo();
|
|
|
+ calendarPo.setUserId(userId);
|
|
|
+ calendarPo.setUserName(userName);
|
|
|
+ calendarPo.setTitle("关于培训计划通知");
|
|
|
+ calendarPo.setContent("关于参加全国两会培训的通知");
|
|
|
+ calendarPo.setStartTime(currentDateStr);
|
|
|
+ calendarPo.setEmergencyState("3");
|
|
|
+ calendarPo.setId(UniqueIdUtil.getId());
|
|
|
+ calendarPo.setCreateBy(userId);
|
|
|
+ calendarDao.create(calendarPo);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|