|
@@ -87,77 +87,97 @@ public class SendMessageUtil {
|
|
|
sic.add("certificationTemplet.name");
|
|
|
sic.add("certificationTemplet.number");
|
|
|
sic.add("certificationTemplet.id");
|
|
|
+ sic.add("certificationTemplet.certificationBillType.name");
|
|
|
+ sic.add("certificationTemplet.certificationBillType.number");
|
|
|
+ sic.add("certificationTemplet.certificationBillType.id");
|
|
|
sic.add("certificationTemplet.templateId");
|
|
|
FilterInfo filterInfo = new FilterInfo();
|
|
|
filterInfo.getFilterItems().add(new FilterItemInfo("id", setBillId, CompareType.INCLUDE));
|
|
|
EntityViewInfo entityViewInfo = EntityViewInfo.getInstance(filterInfo, sic, null);
|
|
|
HRCertificationBillCollection hrCertificationBillCollection = ihrCertificationBill.getHRCertificationBillCollection(entityViewInfo);
|
|
|
- String md5Sign = null;
|
|
|
- //过滤封装手机号
|
|
|
- Map<String, Set> phoneMap = disposeCollFillterPhone(hrCertificationBillCollection);
|
|
|
- //密钥
|
|
|
- String appSecret = propt.getProperty("appSecret");
|
|
|
- //uuid
|
|
|
- String uuid = UUID.randomUUID().toString();
|
|
|
- System.out.println("uuid---" + uuid);
|
|
|
- //应用类型
|
|
|
- String appType = propt.getProperty("appType");
|
|
|
- //应用id
|
|
|
- String appId = propt.getProperty("appId");
|
|
|
- //url
|
|
|
- String url = propt.getProperty("url");
|
|
|
- String signName = propt.getProperty("signName");
|
|
|
- logger.error("url---" + url);
|
|
|
- for (String templateId : phoneMap.keySet()) {
|
|
|
- Set<String> phoneSet = phoneMap.get(templateId);
|
|
|
- for (String phone : phoneSet) {
|
|
|
- //时间戳
|
|
|
- Date date = new Date();
|
|
|
- String time = String.valueOf(date.getTime());
|
|
|
- messageLogsInfo.setTime(date);
|
|
|
- logger.error("time---" + time);
|
|
|
- //参数
|
|
|
- JSONObject params = new JSONObject();
|
|
|
- params.put("appId", appId);
|
|
|
- params.put("templateId", templateId);
|
|
|
- params.put("signName", signName);
|
|
|
- //批量发送才需要这个参数
|
|
|
- //params.put("phone", phone);
|
|
|
- params.put("phone", "15574198273");
|
|
|
- params.put("appId", appId);
|
|
|
- //消息模板
|
|
|
- JSONObject param = getTemplate(ctx, templateId, phone, messageLogsInfo);
|
|
|
- params.put("params", param);
|
|
|
- //请求参数
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- //jsonObject.put("params", params.toString());
|
|
|
- jsonObject.put("time", time);
|
|
|
- jsonObject.put("uuid", uuid);
|
|
|
- jsonObject.put("phones", phone);
|
|
|
- md5Sign = md5Sign(appSecret, url, params, appType, time, uuid, jsonObject);
|
|
|
- jsonObject.put("md5Sign", md5Sign);
|
|
|
- messageLogsInfo.setRequestParams(jsonObject.toString());
|
|
|
- logger.error("md5Sign---" + md5Sign);
|
|
|
- logger.error("params---" + params);
|
|
|
- Response resultResponse = sendMeesage(params, appType, appId, uuid, md5Sign, time);
|
|
|
- String body = resultResponse.body().string();
|
|
|
- logger.error("body---" + body);
|
|
|
- JSONObject result = JSONObject.parseObject(body);
|
|
|
- String code = result.get("code").toString();
|
|
|
- if (!code.equals("200")) {
|
|
|
- error++;
|
|
|
- messageLogsInfo.setStatus(SendStatusEnum.fail);
|
|
|
- } else {
|
|
|
- seccuss++;
|
|
|
- messageLogsInfo.setStatus(SendStatusEnum.succeed);
|
|
|
- }
|
|
|
- //返回结果
|
|
|
- messageLogsInfo.setResult(body);
|
|
|
- messageLogsInfo.setSuccessNum(seccuss);
|
|
|
- messageLogsInfo.setFailNum(error);
|
|
|
- iMessageLogs.save(messageLogsInfo);
|
|
|
+ for (int i = 0; i < hrCertificationBillCollection.size(); i++) {
|
|
|
+ HRCertificationBillInfo hrCertificationBillInfo = hrCertificationBillCollection.get(i);
|
|
|
+ //手机号
|
|
|
+ String callPhone = hrCertificationBillInfo.getCallPhone();
|
|
|
+ //证明模板
|
|
|
+ CertificationTempletInfo certificationTemplet = hrCertificationBillInfo.getCertificationTemplet();
|
|
|
+ String templateName = certificationTemplet.getName();
|
|
|
+ String templateId = (String) certificationTemplet.get("templateId");
|
|
|
+ //证明模板
|
|
|
+ HRCertificationBillTypeInfo certificationBillType = certificationTemplet.getCertificationBillType();
|
|
|
+ //模版名称
|
|
|
+ messageLogsInfo.setReserved1(templateName);
|
|
|
+ messageLogsInfo.setReserved2(certificationBillType.getName());
|
|
|
+ if (StringUtils.isEmpty(templateId)) {
|
|
|
+ throw new ShrWebBizException(templateName + "模板的消息id为空,请问维护!!");
|
|
|
}
|
|
|
+
|
|
|
+ String md5Sign = null;
|
|
|
+ //过滤封装手机号
|
|
|
+ //Map<String, Set> phoneMap = disposeCollFillterPhone(hrCertificationBillCollection, messageLogsInfo);
|
|
|
+ //密钥
|
|
|
+ String appSecret = propt.getProperty("appSecret");
|
|
|
+ //uuid
|
|
|
+ String uuid = UUID.randomUUID().toString();
|
|
|
+ System.out.println("uuid---" + uuid);
|
|
|
+ //应用类型
|
|
|
+ String appType = propt.getProperty("appType");
|
|
|
+ //应用id
|
|
|
+ String appId = propt.getProperty("appId");
|
|
|
+ //url
|
|
|
+ String url = propt.getProperty("url");
|
|
|
+ String signName = propt.getProperty("signName");
|
|
|
+ logger.error("url---" + url);
|
|
|
+ //时间戳
|
|
|
+ Date date = new Date();
|
|
|
+ String time = String.valueOf(date.getTime());
|
|
|
+ messageLogsInfo.setTime(date);
|
|
|
+ logger.error("time---" + time);
|
|
|
+ //参数
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("appId", appId);
|
|
|
+ params.put("templateId", templateId);
|
|
|
+ params.put("signName", signName);
|
|
|
+ //批量发送才需要这个参数
|
|
|
+ //params.put("phone", phone);
|
|
|
+ params.put("phone", "15574198273");
|
|
|
+ params.put("appId", appId);
|
|
|
+ //消息模板
|
|
|
+ Map<String, String> resultMap = SaveFileForDisk.getPDFInfo(ctx, hrCertificationBillInfo);
|
|
|
+ JSONObject param = getTemplate(ctx, templateId, callPhone, resultMap.get("urlPath"), messageLogsInfo);
|
|
|
+ params.put("params", param);
|
|
|
+ //请求参数
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ //jsonObject.put("params", params.toString());
|
|
|
+ jsonObject.put("time", time);
|
|
|
+ jsonObject.put("uuid", uuid);
|
|
|
+ jsonObject.put("phones", callPhone);
|
|
|
+ md5Sign = md5Sign(appSecret, url, params, appType, time, uuid, jsonObject);
|
|
|
+ jsonObject.put("md5Sign", md5Sign);
|
|
|
+ jsonObject.put("resultMap", resultMap);
|
|
|
+ messageLogsInfo.setRequestParams(resultMap.get("urlPath"));
|
|
|
+ messageLogsInfo.setRequestParams(jsonObject.toString());
|
|
|
+ logger.error("md5Sign---" + md5Sign);
|
|
|
+ logger.error("params---" + params);
|
|
|
+ Response resultResponse = sendMeesage(params, appType, appId, uuid, md5Sign, time);
|
|
|
+ String body = resultResponse.body().string();
|
|
|
+ logger.error("body---" + body);
|
|
|
+ JSONObject result = JSONObject.parseObject(body);
|
|
|
+ String code = result.get("code").toString();
|
|
|
+ if (!code.equals("200")) {
|
|
|
+ error++;
|
|
|
+ messageLogsInfo.setStatus(SendStatusEnum.fail);
|
|
|
+ } else {
|
|
|
+ seccuss++;
|
|
|
+ messageLogsInfo.setStatus(SendStatusEnum.succeed);
|
|
|
+ }
|
|
|
+ //返回结果
|
|
|
+ messageLogsInfo.setResult(body);
|
|
|
+ messageLogsInfo.setSuccessNum(seccuss);
|
|
|
+ messageLogsInfo.setFailNum(error);
|
|
|
+ iMessageLogs.save(messageLogsInfo);
|
|
|
}
|
|
|
+
|
|
|
} catch (Exception e) {
|
|
|
error++;
|
|
|
//返回结果
|
|
@@ -177,7 +197,7 @@ public class SendMessageUtil {
|
|
|
* @param phone
|
|
|
* @return
|
|
|
*/
|
|
|
- public JSONObject getTemplate(Context ctx, String templateId, String phone, MessageLogsInfo messageLogsInfo) throws BOSException {
|
|
|
+ public JSONObject getTemplate(Context ctx, String templateId, String phone, String urlPath, MessageLogsInfo messageLogsInfo) throws BOSException {
|
|
|
JSONObject param = new JSONObject();
|
|
|
IPersonContactMethod iPersonContactMethod = PersonContactMethodFactory.getLocalInstance(ctx);
|
|
|
PersonContactMethodInfo personContactMethodInfo = iPersonContactMethod
|
|
@@ -188,7 +208,7 @@ public class SendMessageUtil {
|
|
|
//SHR发送电子证明
|
|
|
if (templateId.equals("MSG_2411190001")) {
|
|
|
param.put("name", person.getName());
|
|
|
- param.put("urlPath", "下載地址");
|
|
|
+ param.put("urlPath", urlPath);
|
|
|
}
|
|
|
//SHR发送离职通知
|
|
|
if (templateId.equals("MSG_2411200002")) {
|
|
@@ -199,7 +219,7 @@ public class SendMessageUtil {
|
|
|
String lzDate = format.format(bizDate);
|
|
|
param.put("name", person.getName());
|
|
|
param.put("lzDate", lzDate);
|
|
|
- param.put("urlPath", "下載地址");
|
|
|
+ param.put("urlPath", urlPath);
|
|
|
}
|
|
|
return param;
|
|
|
}
|
|
@@ -211,7 +231,7 @@ public class SendMessageUtil {
|
|
|
* @param hrCertificationBillCollection
|
|
|
* @return
|
|
|
*/
|
|
|
- public Map disposeCollFillterPhone(HRCertificationBillCollection hrCertificationBillCollection) throws ShrWebBizException {
|
|
|
+ public Map disposeCollFillterPhone(HRCertificationBillCollection hrCertificationBillCollection, MessageLogsInfo messageLogsInfo) throws ShrWebBizException {
|
|
|
Map<String, Set> certificationBillTypeMap = new HashMap<>();
|
|
|
for (int i = 0; i < hrCertificationBillCollection.size(); i++) {
|
|
|
HRCertificationBillInfo hrCertificationBillInfo = hrCertificationBillCollection.get(i);
|
|
@@ -221,6 +241,11 @@ public class SendMessageUtil {
|
|
|
CertificationTempletInfo certificationTemplet = hrCertificationBillInfo.getCertificationTemplet();
|
|
|
String templateName = certificationTemplet.getName();
|
|
|
String templateId = (String) certificationTemplet.get("templateId");
|
|
|
+ //证明模板
|
|
|
+ HRCertificationBillTypeInfo certificationBillType = certificationTemplet.getCertificationBillType();
|
|
|
+ //模版名称
|
|
|
+ messageLogsInfo.setReserved1(templateName);
|
|
|
+ messageLogsInfo.setReserved2(certificationBillType.getName());
|
|
|
if (StringUtils.isEmpty(templateId)) {
|
|
|
throw new ShrWebBizException(templateName + "模板的消息id为空,请问维护!!");
|
|
|
}
|