|
@@ -1,22 +1,26 @@
|
|
|
package com.lc.ibps.business.service.impl;
|
|
package com.lc.ibps.business.service.impl;
|
|
|
|
|
|
|
|
import com.lc.ibps.api.form.sql.util.BeanUtils;
|
|
import com.lc.ibps.api.form.sql.util.BeanUtils;
|
|
|
|
|
+import com.lc.ibps.base.framework.id.UniqueIdUtil;
|
|
|
import com.lc.ibps.base.framework.table.ICommonDao;
|
|
import com.lc.ibps.base.framework.table.ICommonDao;
|
|
|
|
|
+import com.lc.ibps.base.web.context.ContextUtil;
|
|
|
import com.lc.ibps.business.service.AuditService;
|
|
import com.lc.ibps.business.service.AuditService;
|
|
|
|
|
+import com.lc.ibps.cloud.message.util.MessageQueueProductorUtil;
|
|
|
import com.lc.ibps.common.api.INewsMgrService;
|
|
import com.lc.ibps.common.api.INewsMgrService;
|
|
|
import com.lc.ibps.common.system.persistence.entity.NewsPo;
|
|
import com.lc.ibps.common.system.persistence.entity.NewsPo;
|
|
|
|
|
+import lombok.extern.log4j.Log4j2;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.Date;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author Administrator
|
|
* @author Administrator
|
|
|
*/
|
|
*/
|
|
|
|
|
+@Log4j2
|
|
|
@Service
|
|
@Service
|
|
|
public class AuditServiceImpl implements AuditService {
|
|
public class AuditServiceImpl implements AuditService {
|
|
|
|
|
|
|
@@ -27,6 +31,154 @@ public class AuditServiceImpl implements AuditService {
|
|
|
@Resource
|
|
@Resource
|
|
|
private INewsMgrService newsMgrService;
|
|
private INewsMgrService newsMgrService;
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void personnelTrain(String[] records) throws Exception {
|
|
|
|
|
+
|
|
|
|
|
+ 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_,p.shi_fou_guo_shen_," +
|
|
|
|
|
+ "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') " +
|
|
|
|
|
+ " pei_xun_jie_shu_s,p.pei_xun_ren_yuan_,p.pei_xun_di_dian_,p.pei_xun_lao_shi_,p.di_dian_ 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 p.id_ in(%s)";
|
|
|
|
|
+ sql = String.format(sql, String.join(",", records));
|
|
|
|
|
+ List<Map<String, Object>> pxList = (List<Map<String, Object>>) commonDao.query(sql);
|
|
|
|
|
+
|
|
|
|
|
+ if (BeanUtils.isNotEmpty(pxList)){
|
|
|
|
|
+ for (Map<String, Object> train : pxList) {
|
|
|
|
|
+ String id = train.get("id_").toString();
|
|
|
|
|
+ String didian = train.get("di_dian_").toString();
|
|
|
|
|
+ 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 endDate = train.get("pei_xun_shi_jian_")==null?"":train.get("pei_xun_shi_jian_").toString();
|
|
|
|
|
+ String title = "【"+ peiXunNeiRong +"】的培训准备通知";
|
|
|
|
|
+ String content = "您有一个主题为【"+peiXunNeiRong+"】的培训将于 "+starDate+" 开始,请及时前往培训管理页面完善培训信息!";
|
|
|
|
|
+ this.sendCalendarRemind(id,fuzeren,content,starDate,title,didian,endDate);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ 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 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 = deduplication(nameIds + "," + teachIds);
|
|
|
|
|
+ }
|
|
|
|
|
+ String nameStr = getUserName(nameIds);
|
|
|
|
|
+ String[] ids = nameIds.split(",");
|
|
|
|
|
+ for (String str : ids){
|
|
|
|
|
+ this.sendCalendarByDone(id,str,peiXunNeiRong,starDate,endDate,peiXunDiDian, nameStr,didian);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String content = "<p style=\"font-weight: 600; font-size: 24px; text-align: center; margin-bottom: 20px;\"><strong>培训通知</strong></p>" +
|
|
|
|
|
+ "<p><strong>一、培训主题</strong></p><p style=\"margin: 0 0 10px 32px;\">"+peiXunNeiRong+"</p><p><strong>二、时间安排</strong></p>" +
|
|
|
|
|
+ "<p style=\"margin-left: 32px;\">开始时间:"+starDate+"</p><p style=\"margin: 0 0 10px 32px\">结束时间:"+endDate+"</p>" +
|
|
|
|
|
+ "<p><strong>三、培训地点</strong></p><p style=\"margin: 0 0 10px 32px\">"+peiXunDiDian+"</p><p><strong>四、参加人员</strong></p>" +
|
|
|
|
|
+ "<p style=\"margin: 0 0 10px 32px\">"+nameStr+"</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("【"+ peiXunNeiRong +"】的培训通知");
|
|
|
|
|
+ newsPo.setUserId(userId);
|
|
|
|
|
+ newsPo.setUserName(userName);
|
|
|
|
|
+ newsPo.setType(didian);
|
|
|
|
|
+ newsMgrService.save(newsPo);
|
|
|
|
|
+
|
|
|
|
|
+ if (train.get("shi_fou_guo_shen_").equals("未发布")){
|
|
|
|
|
+ commonDao.execute("update t_rypxcjb set shi_fou_guo_shen_='未开始' where id_= '"+id+"'");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public String deduplication(String nameIds){
|
|
|
|
|
+ String[] idsArray = nameIds.split(",");
|
|
|
|
|
+ Set<String> uniqueIds = new HashSet<>();
|
|
|
|
|
+ for (String ids : idsArray) {
|
|
|
|
|
+ uniqueIds.add(ids.trim());
|
|
|
|
|
+ }
|
|
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
|
|
+ for (String ids : uniqueIds) {
|
|
|
|
|
+ if (sb.length() > 0) {
|
|
|
|
|
+ sb.append(",");
|
|
|
|
|
+ }
|
|
|
|
|
+ sb.append(ids);
|
|
|
|
|
+ }
|
|
|
|
|
+ return sb.toString();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 培训提醒
|
|
|
|
|
+ private void sendCalendarRemind(String id,String userId,String peiXunNeiRong,String starDate,String title,String diDian,String endDate) throws Exception {
|
|
|
|
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
|
|
+ data.put("id_", UniqueIdUtil.getId());
|
|
|
|
|
+ data.put("create_by_", ContextUtil.getCurrentUserId());
|
|
|
|
|
+ data.put("create_time_", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
|
|
+ data.put("di_dian_", diDian);
|
|
|
|
|
+ data.put("user_id_", userId);
|
|
|
|
|
+ data.put("user_name_", "");
|
|
|
|
|
+ data.put("title_", title);
|
|
|
|
|
+ data.put("content_", peiXunNeiRong);
|
|
|
|
|
+ data.put("start_time_", starDate);
|
|
|
|
|
+ data.put("end_time_", endDate);
|
|
|
|
|
+ data.put("emergency_state_", "2");
|
|
|
|
|
+ data.put("serial_num_", "");
|
|
|
|
|
+ data.put("data_source_id_", id);
|
|
|
|
|
+ data.put("data_info_", "t_rypxcjb");
|
|
|
|
|
+ data.put("type_", "");
|
|
|
|
|
+ commonDao.execute(buildInsertSql(data,"ibps_party_user_calendar"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //培训通知
|
|
|
|
|
+ private void sendCalendarByDone(String id,String userId,String peiXunNeiRong,String starDate,String endDate,String didian,String nameStr,String diDian) throws Exception {
|
|
|
|
|
+ String title = "【"+ peiXunNeiRong +"】的培训通知";
|
|
|
|
|
+ String neiRong = peiXunNeiRong+"培训通知:\n" +
|
|
|
|
|
+ " 1.培训主题: "+peiXunNeiRong+"\n" +
|
|
|
|
|
+ " 2.时间安排: 开始时间:"+starDate+" 结束时间:"+endDate+"\n" +
|
|
|
|
|
+ " 3.培训地点: "+didian+" \n" +
|
|
|
|
|
+ " 4.参加人员: "+nameStr;
|
|
|
|
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
|
|
+ data.put("id_", UniqueIdUtil.getId());
|
|
|
|
|
+ data.put("create_by_", ContextUtil.getCurrentUserId());
|
|
|
|
|
+ data.put("create_time_", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
|
|
|
+ data.put("di_dian_", diDian);
|
|
|
|
|
+ data.put("user_id_", userId);
|
|
|
|
|
+ data.put("title_", title);
|
|
|
|
|
+ data.put("content_", neiRong);
|
|
|
|
|
+ data.put("start_time_", starDate);
|
|
|
|
|
+ data.put("end_time_", endDate);
|
|
|
|
|
+ data.put("emergency_state_", "2");
|
|
|
|
|
+ data.put("serial_num_", "");
|
|
|
|
|
+ data.put("data_source_id_", id);
|
|
|
|
|
+ data.put("data_info_", "t_rypxcjb");
|
|
|
|
|
+ data.put("type_", "");
|
|
|
|
|
+ commonDao.execute(buildInsertSql(data,"ibps_party_user_calendar"));
|
|
|
|
|
+
|
|
|
|
|
+ List<String> receiver = new ArrayList<>();
|
|
|
|
|
+ receiver.add(userId);
|
|
|
|
|
+ MessageQueueProductorUtil.send("PersonnelTrainJob", "system" , "inner"
|
|
|
|
|
+ , receiver,null , title, neiRong, null, null, null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 管理评审通知
|
|
// 管理评审通知
|
|
|
@Override
|
|
@Override
|
|
|
public void NoticeByOneMonth(){
|
|
public void NoticeByOneMonth(){
|
|
@@ -150,13 +302,12 @@ public class AuditServiceImpl implements AuditService {
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getUserName(String userId){
|
|
public String getUserName(String userId){
|
|
|
- String sql2 = " select *from ibps_party_employee where id_ in ("+userId+") ";
|
|
|
|
|
|
|
+ String sql2 = " select NAME_ from ibps_party_employee where id_ in ("+userId+") ";
|
|
|
List<Map<String, Object>> userList = (List<Map<String, Object>>) commonDao.query(sql2);
|
|
List<Map<String, Object>> userList = (List<Map<String, Object>>) commonDao.query(sql2);
|
|
|
StringBuilder namesBuilder = new StringBuilder();
|
|
StringBuilder namesBuilder = new StringBuilder();
|
|
|
for (Map<String, Object> map : userList) {
|
|
for (Map<String, Object> map : userList) {
|
|
|
- Object name = map.get("NAME_");
|
|
|
|
|
- if (name != null) {
|
|
|
|
|
- namesBuilder.append(name.toString());
|
|
|
|
|
|
|
+ if (BeanUtils.isNotEmpty(map.get("NAME_"))) {
|
|
|
|
|
+ namesBuilder.append(map.get("NAME_"));
|
|
|
namesBuilder.append(",");
|
|
namesBuilder.append(",");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -166,5 +317,19 @@ public class AuditServiceImpl implements AuditService {
|
|
|
return namesBuilder.toString();
|
|
return namesBuilder.toString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public String buildInsertSql(Map<String, Object> map , String tableName) throws Exception {
|
|
|
|
|
+ StringBuilder sql = new StringBuilder("insert into "+tableName+" (");
|
|
|
|
|
+ for (Object key : map.keySet()) {
|
|
|
|
|
+ sql.append(key).append(",");
|
|
|
|
|
+ }
|
|
|
|
|
+ sql.delete(sql.length()-1,sql.length());
|
|
|
|
|
+ sql.append(") values(");
|
|
|
|
|
+ for (Object val : map.values()) {
|
|
|
|
|
+ sql.append("'").append(val).append("'").append(",");
|
|
|
|
|
+ }
|
|
|
|
|
+ sql.delete(sql.length()-1,sql.length());
|
|
|
|
|
+ sql.append(")");
|
|
|
|
|
+ return sql.toString();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|