消息通知接口-增加通用接口
This commit is contained in:
parent
97f3a96a9e
commit
845885e418
|
|
@ -7,8 +7,9 @@ import nc.bs.logging.Logger;
|
||||||
import nc.bs.trade.business.HYSuperDMO;
|
import nc.bs.trade.business.HYSuperDMO;
|
||||||
import nc.bs.uapbd.util.MyHelper;
|
import nc.bs.uapbd.util.MyHelper;
|
||||||
import nc.jdbc.framework.processor.ColumnProcessor;
|
import nc.jdbc.framework.processor.ColumnProcessor;
|
||||||
|
import nc.pubitf.para.SysInitQuery;
|
||||||
import nc.vo.fi.pub.SqlUtils;
|
import nc.vo.fi.pub.SqlUtils;
|
||||||
import nc.vo.org.FactoryVO;
|
import nc.vo.org.OrgVO;
|
||||||
import nc.vo.pub.BusinessException;
|
import nc.vo.pub.BusinessException;
|
||||||
import nc.vo.pub.lang.UFDateTime;
|
import nc.vo.pub.lang.UFDateTime;
|
||||||
import nc.vo.pub.msg.CommonMessageVO;
|
import nc.vo.pub.msg.CommonMessageVO;
|
||||||
|
|
@ -61,7 +62,8 @@ public class MsgResource extends AbstractNCCRestResource {
|
||||||
String content = (String) jsonObject.get("content");
|
String content = (String) jsonObject.get("content");
|
||||||
String orgCode = (String) jsonObject.get("orgCode");
|
String orgCode = (String) jsonObject.get("orgCode");
|
||||||
try {
|
try {
|
||||||
String pkOrg = MyHelper.transferField(FactoryVO.getDefaultTableName(), FactoryVO.PK_FACTORY, FactoryVO.CODE, orgCode);
|
String pkOrg = MyHelper.getStrValByCondition(OrgVO.getDefaultTableName(), OrgVO.PK_ORG,
|
||||||
|
OrgVO.CODE + " = '" + orgCode + "' and ISBUSINESSUNIT = 'Y'");
|
||||||
if (pkOrg == null || pkOrg.isEmpty()) {
|
if (pkOrg == null || pkOrg.isEmpty()) {
|
||||||
return ResultMessageUtil.toJSON(false, "未查询到组织:" + orgCode);
|
return ResultMessageUtil.toJSON(false, "未查询到组织:" + orgCode);
|
||||||
}
|
}
|
||||||
|
|
@ -128,7 +130,8 @@ public class MsgResource extends AbstractNCCRestResource {
|
||||||
String content = (String) jsonObject.get("content");
|
String content = (String) jsonObject.get("content");
|
||||||
String orgCode = (String) jsonObject.get("orgCode");
|
String orgCode = (String) jsonObject.get("orgCode");
|
||||||
try {
|
try {
|
||||||
String pkOrg = MyHelper.transferField(FactoryVO.getDefaultTableName(), FactoryVO.PK_FACTORY, FactoryVO.CODE, orgCode);
|
String pkOrg = MyHelper.getStrValByCondition(OrgVO.getDefaultTableName(), OrgVO.PK_ORG,
|
||||||
|
OrgVO.CODE + " = '" + orgCode + "' and ISBUSINESSUNIT = 'Y'");
|
||||||
if (pkOrg == null || pkOrg.isEmpty()) {
|
if (pkOrg == null || pkOrg.isEmpty()) {
|
||||||
return ResultMessageUtil.toJSON(false, "未查询到组织:" + orgCode);
|
return ResultMessageUtil.toJSON(false, "未查询到组织:" + orgCode);
|
||||||
}
|
}
|
||||||
|
|
@ -180,6 +183,65 @@ public class MsgResource extends AbstractNCCRestResource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("operation/commonSave")
|
||||||
|
@Consumes({"application/json"})
|
||||||
|
@Produces({"application/json"})
|
||||||
|
public JSONString commonSave(JSONObject jsonObject) {
|
||||||
|
String content = (String) jsonObject.get("content");
|
||||||
|
String orgCode = (String) jsonObject.get("orgCode");
|
||||||
|
String title = jsonObject.get("title") + "";
|
||||||
|
try {
|
||||||
|
String pkOrg = MyHelper.getStrValByCondition(OrgVO.getDefaultTableName(), OrgVO.PK_ORG,
|
||||||
|
OrgVO.CODE + " = '" + orgCode + "' and ISBUSINESSUNIT = 'Y'");
|
||||||
|
if (pkOrg == null || pkOrg.isEmpty()) {
|
||||||
|
return ResultMessageUtil.toJSON(false, "未查询到组织:" + orgCode);
|
||||||
|
}
|
||||||
|
String msgRoleCode = SysInitQuery.getParaString(pkOrg, "msgRoleCode");
|
||||||
|
Map<String, String> configParams = new HashMap<>();
|
||||||
|
configParams.put("msgRoleCode", msgRoleCode);
|
||||||
|
// 定义接收消息人员信息集合
|
||||||
|
ArrayList<UserNameObject> userList = new ArrayList<>();
|
||||||
|
|
||||||
|
// 根据传递的角色查询要发送消息的用户信息
|
||||||
|
String roleId = getMsgRole(pkOrg, "", configParams);
|
||||||
|
UserVO[] userVOS = getUserByRole(roleId);
|
||||||
|
if (userVOS == null || userVOS.length == 0) {
|
||||||
|
return ResultMessageUtil.toJSON(false, "未查询到用户");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (UserVO smUser : userVOS) {
|
||||||
|
// 用户档案主键
|
||||||
|
String cuserid = smUser.getCuserid();
|
||||||
|
// 用户名称
|
||||||
|
String user_name = smUser.getUser_name();
|
||||||
|
// 用户编码
|
||||||
|
String user_code = smUser.getUser_code();
|
||||||
|
|
||||||
|
UserNameObject userNameObject = new UserNameObject(user_name);// 用户名称
|
||||||
|
userNameObject.setUserCode(user_code);// 用户编码
|
||||||
|
userNameObject.setUserPK(cuserid);// 用户档案主键
|
||||||
|
userList.add(userNameObject);
|
||||||
|
}
|
||||||
|
UserNameObject[] users = userList.toArray(new UserNameObject[0]);
|
||||||
|
|
||||||
|
CommonMessageVO commonMessageVO = new CommonMessageVO();
|
||||||
|
commonMessageVO.setReceiver(users);
|
||||||
|
commonMessageVO.setTitle(title);
|
||||||
|
commonMessageVO.setSender(DEFAULT_SENDER);
|
||||||
|
commonMessageVO.setSendDataTime(new UFDateTime());
|
||||||
|
commonMessageVO.setPriority(1);
|
||||||
|
commonMessageVO.setMessageContent(content);
|
||||||
|
|
||||||
|
PfMessageUtil.sendNoticeMessage(commonMessageVO);
|
||||||
|
|
||||||
|
return ResultMessageUtil.toJSON(true, "消息发送成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.error("MsgResource-exp:", e);
|
||||||
|
return ResultMessageUtil.exceptionToJSON(new BusinessException(e.getMessage(), e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询用户
|
* 查询用户
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue