BOM变更通知-增加箱变

This commit is contained in:
mzr 2025-10-20 15:18:18 +08:00
parent 4df22f0b94
commit 092db38e67
1 changed files with 75 additions and 10 deletions

View File

@ -65,20 +65,84 @@ public class MsgResource extends AbstractNCCRestResource {
if (pkOrg == null || pkOrg.isEmpty()) {
return ResultMessageUtil.toJSON(false, "未查询到组织:" + orgCode);
}
String materialCode = (String) jsonObject.get("materialCode");
if (materialCode == null || materialCode.isEmpty()) {
return ResultMessageUtil.toJSON(false, "´«²ÎÖÐȱÉÙÎïÁϱàÂë");
String materialCode = "";
if (jsonObject.containsKey("materialCode")) {
materialCode = (String) jsonObject.get("materialCode");
if (materialCode == null || materialCode.isEmpty()) {
return ResultMessageUtil.toJSON(false, "传参中缺少物料编码");
}
}
// 通知消息字段最大为4000位
if (content != null && content.length() > 1500) {
content = content.substring(0, 1500);
}
Map<String, String> configParams = MyHelper.getConfigParams("Dldz-config", null);
// 定义接收消息人员信息集合
ArrayList<UserNameObject> userList = new ArrayList<>();
// 根据传递的角色查询要发送消息的用户信息
String roleId = getMsgRole(pkOrg, materialCode);
String roleId = getMsgRole(pkOrg, materialCode, 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("BOM变更信息通知");
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));
}
}
@POST
@Path("operation/saveXb")
@Consumes({"application/json"})
@Produces({"application/json"})
public JSONString saveXb(JSONObject jsonObject) {
String content = (String) jsonObject.get("content");
String orgCode = (String) jsonObject.get("orgCode");
try {
String pkOrg = MyHelper.transferField(FactoryVO.getDefaultTableName(), FactoryVO.PK_FACTORY, FactoryVO.CODE, orgCode);
if (pkOrg == null || pkOrg.isEmpty()) {
return ResultMessageUtil.toJSON(false, "未查询到组织:" + orgCode);
}
// 通知消息字段最大为4000位
if (content != null && content.length() > 1500) {
content = content.substring(0, 1500);
}
Map<String, String> configParams = MyHelper.getConfigParams("xb-config", null);
// 定义接收消息人员信息集合
ArrayList<UserNameObject> userList = new ArrayList<>();
// 根据传递的角色查询要发送消息的用户信息
String roleId = getMsgRole(pkOrg, "", configParams);
UserVO[] userVOS = getUserByRole(roleId);
if (userVOS == null || userVOS.length == 0) {
return ResultMessageUtil.toJSON(false, "未查询到用户");
@ -151,14 +215,15 @@ public class MsgResource extends AbstractNCCRestResource {
/**
* 查询要发消息的角色id
*/
private String getMsgRole(String pkOrg, String materialCode) throws BusinessException {
private String getMsgRole(String pkOrg, String materialCode, Map<String, String> configParams) throws BusinessException {
String pkRole = "";
// 先查询物料分类上配置的角色如果有则返回否则查询自定义档案中配置的角色
pkRole = getGoodsTypeRole(pkOrg, materialCode);
if (pkRole != null && !"~".equals(pkRole) && !pkRole.isEmpty()) {
return pkRole;
if (StringUtils.isNotEmpty(materialCode)) {
pkRole = getGoodsTypeRole(pkOrg, materialCode);
if (pkRole != null && !"~".equals(pkRole) && !pkRole.isEmpty()) {
return pkRole;
}
}
Map<String, String> configParams = MyHelper.getConfigParams("Dldz-config", null);
String strWhere = " dr = 0 ";
String msgRoleCode = configParams.getOrDefault("msgRoleCode", "");
if (StringUtils.isEmpty(msgRoleCode)) {