修改OTA发消息

This commit is contained in:
高嵩
2023-08-28 17:40:51 +08:00
parent b4e083a577
commit 0e4c2b2db2
4 changed files with 148 additions and 1 deletions
@@ -169,6 +169,12 @@ public enum TemplateInfoEnum2 {
// 认证参数收集-退回
HOMO_PARAMETER_COLLECTION_BACK("认证参数收集","ctp_AArY5ngxD5cv","Homo Parameter Collection"), // 已同步飞书开放平台
// OTA认证管理-公共-绿色
OTA_MANAGER_G("OTA认证管理","ctp_AAm2fgLqJccz","OTA Manager Green"), // 已同步飞书开放平台
// OTA认证管理-公共-红色
OTA_MANAGER_R("OTA认证管理","ctp_AAmvnNtu20oM","OTA Manager Red"), // 已同步飞书开放平台
;
String nameCn;
@@ -159,4 +159,10 @@ public interface IFeishuService {
*/
void sendMessageHomoParameterCollection(String templeteId,Map<String,Object> params,String flag);
/**
* 飞书消息模板--OTA认证管理(主题颜色为绿色)
*/
public void sendMessageOtaManager(String templeteId, Map<String, Object> params);
}
@@ -1636,4 +1636,52 @@ public class FeishuServiceImpl implements IFeishuService {
}
}
/**
* 飞书消息模板--OTA认证管理(主题颜色为红色或绿色)
*
* @param templeteId
* @param params
*/
@Override
public void sendMessageOtaManager(String templeteId, Map<String, Object> params) {
List<String> userIdList = (List<String>) params.get("userIdList");
if (CollectionUtils.isNotEmpty(userIdList)) {
List<SysUser> userInfoList = this.sysUserService.querySysUserListByIdList(userIdList);
String contentCn = (String) params.get("contentCn");
String contentEn = (String) params.get("contentEn");
String viewBtnUrlCn = (String) params.get("viewBtnUrlCn");
String viewBtnUrlEn = (String) params.get("viewBtnUrlEn");
String viewBtnUrlCnPhone = (String) params.get("viewBtnUrlCnPhone");
String plannedBpLaunchBatch = (String) params.get("plannedBpLaunchBatch");
String appliedVehicleProject = (String) params.get("appliedVehicleProject");
String initiator = (String) params.get("initiator");
try {
for (String userId : userIdList) {
String thirdId = this.sysUserService.getUserThirdIdByUserId(userInfoList, userId);
if (StringUtils.isNotEmpty(thirdId)) {
// 根据结束时间进行排序,获取最近的时间,发消息时使用。
JSONObject larkMesJson = new JSONObject();
larkMesJson.put("template_id", templeteId);
larkMesJson.put("userIds", thirdId);
Map<String, Object> templateVariableMap = new HashMap<>();
templateVariableMap.put("contentCn", contentCn);
templateVariableMap.put("contentEn", contentEn);
templateVariableMap.put("viewBtnUrlCn", viewBtnUrlCn);
templateVariableMap.put("viewBtnUrlEn", viewBtnUrlEn);
templateVariableMap.put("viewBtnUrlCnPhone", viewBtnUrlCnPhone);
templateVariableMap.put("plannedBpLaunchBatch", plannedBpLaunchBatch);
templateVariableMap.put("appliedVehicleProject", appliedVehicleProject);
templateVariableMap.put("Initiator", " " + initiator);
larkMesJson.put("templateVariableMap", templateVariableMap);
batchSendLarkCardMsgByTemplate2(larkMesJson);
}
}
} catch (Exception e) {
log.error("飞书消息推送失败");
}
}
}
}
@@ -9,6 +9,8 @@ import com.jero.common.system.vo.LoginUser;
import com.jero.common.util.DateUtils;
import com.jero.common.util.oConvertUtils;
import com.jero.modules.dummy.enums.OrderEnum;
import com.jero.modules.feishu.enums.TemplateInfoEnum2;
import com.jero.modules.feishu.service.IFeishuService;
import com.jero.modules.ota.entity.OtaManageApplyEO;
import com.jero.modules.ota.entity.OtaManageHistory;
import com.jero.modules.ota.entity.OtaManagePermission;
@@ -110,9 +112,15 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
private ISysDictService sysDictService;
@Autowired
private ProjectNameInfoEOServiceImpl projectNameInfoEOService;
@Autowired
private IFeishuService feishuService;
@Value(value = "${jero.path.upload}")
private String upLoadPath;
@Value(value = "${jero.backUrl}")
private String backUrl;
@Value(value = "${jero.backUrlPhone}")
private String backUrlPhone;
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
@@ -1278,7 +1286,6 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
}
}
}
//TODO 给studio发消息
List<OtaManagePermission> ompList = new ArrayList<>();
for (String studioId : matchStudioSet) {
OtaManagePermission omp = new OtaManagePermission();
@@ -1287,6 +1294,26 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
ompList.add(omp);
}
otaManagePermissionService.saveBatch(ompList);
//给studio发消息
LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
Map<String, Object> params = new HashMap<>();
List<String> userIdList = new ArrayList<>(matchStudioSet);
params.put("userIdList", userIdList);
params.put("contentCn", "您好,请及时查看处理此项任务,谢谢!-请在PC端查看");
params.put("contentEn", "Hello! Please check and address the task in a timely manner. Thank you!-Check on the PC");
params.put("plannedBpLaunchBatch", id);
params.put("viewBtnUrlCnPhone", backUrlPhone);
String url = backUrl;
if (omrList.size() > 0) {
url = backUrl + "/components/detil?plannedBpLaunchBatch=" + id + "&releaseDate=" + omrList.get(0).getReleaseDate();
}
params.put("viewBtnUrlCn", url);
params.put("viewBtnUrlEn", url);
params.put("appliedVehicleProject", appMap.keySet().stream().collect(Collectors.joining(",")));
params.put("Initiator", " " + currentUser.getUsername());
params.put("initiatorStrCn", "发起人");
params.put("initiatorStrEn", "Initiator");
feishuService.sendMessageOtaManager(TemplateInfoEnum2.OTA_MANAGER_G.getValue(), params);
}
}
@@ -1298,6 +1325,14 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
return isOtaManager() && !isStudio();
}
private List<String> getAllOtaManager() {
List<SysUserRole> omList = this.sysUserRoleMapper.selectList(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getRoleId, RoleEnum.STUDIO.getId()));
List<String> resList = omList.stream()
.filter(e -> StringUtils.isNotBlank(e.getId()))
.map(SysUserRole::getId).distinct().collect(Collectors.toList());
return resList;
}
private boolean isOtaManager() {
LoginUser currentUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
List<SysUserRole> userRoleList = this.sysUserRoleMapper.selectList(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, currentUser.getId())); // 查询用户所有角色
@@ -1476,6 +1511,9 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
@Override
public List<String> submit(List<OtaManageApplyEO> list, String cut) {
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//发消息用参数
List<String> userIdList = getAllOtaManager();
//操作历史
List<OtaManageHistory> hisList = new ArrayList<>();
List<String> msgList = new ArrayList<>();
for (OtaManageApplyEO oma : list) {
@@ -1503,10 +1541,27 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
his.setContentCn(user.getUsername() + " 提交了 VDR:" + oma.getVdr());
his.setContentEn(user.getUsername() + " submitted VDR:" + oma.getVdr());
hisList.add(his);
//给manager发消息
Map<String, Object> params = new HashMap<>();
params.put("userIdList", userIdList);
params.put("contentCn", "您好,该任务信息已提交,请及时查看处理此项任务,谢谢!-请在PC端查看");
params.put("contentEn", "Hello! The task information has been submitted, please check and address the task in a timely manner. Thank you!-Check on the PC");
params.put("plannedBpLaunchBatch", oma.getPlannedBpLaunchBatch());
params.put("viewBtnUrlCnPhone", backUrlPhone);
String url = backUrl + "/components/detil?plannedBpLaunchBatch=" + oma.getPlannedBpLaunchBatch() + "&releaseDate=" + oma.getReleaseDate();
params.put("viewBtnUrlCn", url);
params.put("viewBtnUrlEn", url);
params.put("appliedVehicleProject", oma.getVehicleType());
params.put("Initiator", " " + user.getUsername());
params.put("initiatorStrCn", "提交人");
params.put("initiatorStrEn", "Submitter");
feishuService.sendMessageOtaManager(TemplateInfoEnum2.OTA_MANAGER_G.getValue(), params);
}
}
this.temporarySave(list, true, cut);
otaManageHistoryService.saveBatch(hisList);
return msgList;
}
@@ -1627,6 +1682,22 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
his.setContentCn(user.getUsername() + " 确认了 VDR:" + oma.getVdr());
his.setContentEn(user.getUsername() + " confirm VDR:" + oma.getVdr());
hisList.add(his);
//给studio发消息
Map<String, Object> params = new HashMap<>();
params.put("userIdList", oma.getStudio());
params.put("contentCn", "您好,该任务被发起人审查通过。-请在PC端查看");
params.put("contentEn", "Hello! The task has been approved by the initiator.-Check on the PC");
params.put("plannedBpLaunchBatch", oma.getPlannedBpLaunchBatch());
params.put("viewBtnUrlCnPhone", backUrlPhone);
String url = backUrl + "/components/detil?plannedBpLaunchBatch=" + oma.getPlannedBpLaunchBatch() + "&releaseDate=" + oma.getReleaseDate();
params.put("viewBtnUrlCn", url);
params.put("viewBtnUrlEn", url);
params.put("appliedVehicleProject", oma.getVehicleType());
params.put("Initiator", " " + user.getUsername());
params.put("initiatorStrCn", "发起人");
params.put("initiatorStrEn", "Initiator");
feishuService.sendMessageOtaManager(TemplateInfoEnum2.OTA_MANAGER_G.getValue(), params);
} else {
//状态不对
if (CutEnum.CN.getValue().equals(cut)) {
@@ -1659,6 +1730,22 @@ public class OtaManageApplyEOServiceImpl extends ServiceImpl<OtaManageApplyEOMap
his.setContentCn(user.getUsername() + " 退回了 VDR:" + oma.getVdr() + " 退回原因:" + rejectReason);
his.setContentEn(user.getUsername() + " returned VDR:" + oma.getVdr() + " Reason for return:" + rejectReason);
hisList.add(his);
//给studio发消息
Map<String, Object> params = new HashMap<>();
params.put("userIdList", oma.getStudio());
params.put("contentCn", "您好,该任务被发起人审查退回,请重新处理。-请在PC端查看");
params.put("contentEn", "Hello! The task is rejected by the inditiator, please address it again.-Check on the PC");
params.put("plannedBpLaunchBatch", oma.getPlannedBpLaunchBatch());
params.put("viewBtnUrlCnPhone", backUrlPhone);
String url = backUrl + "/components/detil?plannedBpLaunchBatch=" + oma.getPlannedBpLaunchBatch() + "&releaseDate=" + oma.getReleaseDate();
params.put("viewBtnUrlCn", url);
params.put("viewBtnUrlEn", url);
params.put("appliedVehicleProject", oma.getVehicleType());
params.put("Initiator", " " + user.getUsername());
params.put("initiatorStrCn", "发起人");
params.put("initiatorStrEn", "Initiator");
feishuService.sendMessageOtaManager(TemplateInfoEnum2.OTA_MANAGER_R.getValue(), params);
} else {
//状态不对
if (CutEnum.CN.getValue().equals(cut)) {