|
|
@@ -1,7 +1,9 @@
|
|
|
package com.lc.ibps.platform.plan.job;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.lc.ibps.base.core.exception.BaseException;
|
|
|
import com.lc.ibps.base.core.util.AppUtil;
|
|
|
+import com.lc.ibps.base.core.util.BeanUtils;
|
|
|
import com.lc.ibps.base.framework.table.ICommonDao;
|
|
|
import com.lc.ibps.base.web.context.ContextUtil;
|
|
|
import com.lc.ibps.cloud.message.util.MessageQueueProductorUtil;
|
|
|
@@ -9,11 +11,12 @@ import com.lc.ibps.util.BusinessEnum;
|
|
|
import org.quartz.JobExecutionContext;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
-import com.lc.ibps.base.core.util.BeanUtils;
|
|
|
+
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
public class ConfigDailyJob extends AbstractJob{
|
|
|
private static final Logger logger = LoggerFactory.getLogger(EquipmentMaintenancePlanJob.class);
|
|
|
@@ -54,30 +57,103 @@ public class ConfigDailyJob extends AbstractJob{
|
|
|
if(BeanUtils.isNotEmpty(message)){
|
|
|
content = content+message.get(1);
|
|
|
title = title+message.get(0);
|
|
|
+ logger.warn("excutePushMessagejob-消息发送开始");
|
|
|
MessageQueueProductorUtil.send(BusinessEnum.MESSAGE_JOB.getCode(), BusinessEnum.SYSTEM.getCode() , BusinessEnum.MSG_TYPE_INNER.getCode(), recivers,null , title, content, null, null, null);
|
|
|
+ logger.warn("excutePushMessagejob-消息发送成功");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void constructMessage(Map dMap, List<String> message, List<String> recivers) {
|
|
|
ArrayList<Object> constructData = new ArrayList<>();
|
|
|
+ String [] users = null;
|
|
|
+ if(BeanUtils.isEmpty(dMap.get("fu_wu_dui_xiang_"))){
|
|
|
+ throw new BaseException("提供咨询服务对象不允许为空!");
|
|
|
+ }
|
|
|
+ if(BeanUtils.isEmpty(dMap.get("fu_wu_nei_rong_"))){
|
|
|
+ throw new BaseException("提供咨询服务内容不允许为空!");
|
|
|
+ }
|
|
|
+ if(BeanUtils.isEmpty(dMap.get("fu_wu_fang_shi_"))){
|
|
|
+ throw new BaseException("提供咨询服务方式不允许为空!");
|
|
|
+ }
|
|
|
+ if(BeanUtils.isEmpty(dMap.get("fu_wu_shi_jian_"))){
|
|
|
+ throw new BaseException("提供咨询服务时间不允许为空!");
|
|
|
+ }
|
|
|
+ if(BeanUtils.isEmpty(dMap.get("zi_xun_ren_yuan_"))){
|
|
|
+ throw new BaseException("提供咨询人员不允许为空!");
|
|
|
+ }
|
|
|
+
|
|
|
String title = "主动咨询服务计划提醒";
|
|
|
String neiRong = "<br />";
|
|
|
String column1 ="咨询服务对象:"+dMap.get("fu_wu_dui_xiang_")+neiRong;
|
|
|
String column2 ="咨询服务内容:"+dMap.get("fu_wu_nei_rong_") +neiRong;
|
|
|
String column3 ="咨询服务方式:"+dMap.get("fu_wu_fang_shi_")+ neiRong;
|
|
|
String column4 ="咨询服务时间:"+dMap.get("nian_du_")+BusinessEnum.YEAR.getCode()+dMap.get("fu_wu_shi_jian_")+ neiRong;
|
|
|
- String column5 ="提供咨询人员:"+dMap.get("zi_xun_ren_yuan_")+neiRong;
|
|
|
- neiRong = neiRong + column1 + column2 + column3 + column4 + column5;
|
|
|
+
|
|
|
+
|
|
|
//转换接收人ID
|
|
|
String[] parts = dMap.get("tui_song_dui_xian").toString().split(",");
|
|
|
- if(BeanUtils.isEmpty(dMap.get("tui_song_dui_xian"))){
|
|
|
- logger.warn("主动咨询服务计划推送数据异常,异常内容 {}id{}",dMap.get("fu_wu_nei_rong_"),dMap.get("id_"));
|
|
|
+ //转换咨询人员ID
|
|
|
+ users = String.valueOf(dMap.get("zi_xun_ren_yuan_")).split(BusinessEnum.SEMICOLON.getCode());
|
|
|
+ String executeSql = buildSafeSql(users);
|
|
|
+ List<Map<String,Object>> userNames = (List<Map<String, Object>>) commonDao.query(executeSql);
|
|
|
+ logger.warn("提供咨询人员id查询语句:{}",executeSql);
|
|
|
+ if(BeanUtils.isEmpty(userNames)){
|
|
|
+ logger.warn("主动咨询服务计划推送数据异常");
|
|
|
return;
|
|
|
}
|
|
|
+ String tgzxry = userNames.stream()
|
|
|
+ .map(user -> (String) user.get("NAME_")) // 提取NAME_字段
|
|
|
+ .filter(name -> name != null && !name.trim().isEmpty()) // 过滤空值
|
|
|
+ .collect(Collectors.joining(",")); // 用引号拼接
|
|
|
+ String column5 ="提供咨询人员:"+tgzxry+neiRong;
|
|
|
+ neiRong = neiRong + column1 + column2 + column3 + column4 + column5;
|
|
|
+
|
|
|
+
|
|
|
List<String> data = Arrays.asList(parts);
|
|
|
recivers.addAll(data);
|
|
|
message.add(title);
|
|
|
message.add(neiRong);
|
|
|
}
|
|
|
+ /*
|
|
|
+ * @param ids 字符串数组
|
|
|
+ * @return 完整的SQL语句
|
|
|
+ */
|
|
|
+ public static String buildSafeSql(String[] ids) {
|
|
|
+ // 处理空数组
|
|
|
+ if (ids == null || ids.length == 0) {
|
|
|
+ return "select ID_,NAME_ from ibps_party_employee ";
|
|
|
+ }
|
|
|
+
|
|
|
+ // 使用StringBuilder提高性能
|
|
|
+ StringBuilder sqlBuilder = new StringBuilder();
|
|
|
+ sqlBuilder.append("select ID_,NAME_ from ibps_party_employee ");
|
|
|
+
|
|
|
+ // 当只有一个ID时,可以使用=而不是IN
|
|
|
+ if (ids.length == 1) {
|
|
|
+ sqlBuilder.append(" where id_ = '").append(escapeSql(ids[0])).append("';");
|
|
|
+ } else {
|
|
|
+ sqlBuilder.append(" where id_ in(");
|
|
|
+
|
|
|
+ for (int i = 0; i < ids.length; i++) {
|
|
|
+ sqlBuilder.append("'").append(escapeSql(ids[i])).append("'");
|
|
|
+ if (i < ids.length - 1) {
|
|
|
+ sqlBuilder.append(",");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sqlBuilder.append(");");
|
|
|
+ }
|
|
|
+
|
|
|
+ return sqlBuilder.toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * SQL转义(防止单引号问题)
|
|
|
+ */
|
|
|
+ private static String escapeSql(String input) {
|
|
|
+ if (input == null) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ return input.replace("'", "''");
|
|
|
+ }
|
|
|
}
|