Commit 60c93830 by wukaiqiang

修改消息创建接口 及新增加/sand/user下接口

parent c3bcf9c7
...@@ -5,7 +5,9 @@ import org.springframework.context.annotation.Configuration; ...@@ -5,7 +5,9 @@ import org.springframework.context.annotation.Configuration;
import com.xyst.dinas.biz.init.PlanningCycleInit; import com.xyst.dinas.biz.init.PlanningCycleInit;
import com.xyst.dinas.biz.internal.dao.PlanningCycleDao; import com.xyst.dinas.biz.internal.dao.PlanningCycleDao;
import com.xyst.dinas.biz.internal.service.DinasCommonServiceImpl;
import com.xyst.dinas.biz.internal.service.PlanningCycleServiceImpl; import com.xyst.dinas.biz.internal.service.PlanningCycleServiceImpl;
import com.xyst.dinas.biz.service.DinasCommonService;
import com.xyst.dinas.biz.service.PlanningCycleService; import com.xyst.dinas.biz.service.PlanningCycleService;
import com.xyst.dinas.biz.web.DinasCommonController; import com.xyst.dinas.biz.web.DinasCommonController;
import com.xyst.dinas.biz.web.SandAttachmentController; import com.xyst.dinas.biz.web.SandAttachmentController;
...@@ -84,4 +86,9 @@ public class DinasCommonConfiguration { ...@@ -84,4 +86,9 @@ public class DinasCommonConfiguration {
public PlanningCycleInit planningCycleInit() { public PlanningCycleInit planningCycleInit() {
return new PlanningCycleInit(); return new PlanningCycleInit();
} }
@Bean
public DinasCommonService dinasCommonService() {
return new DinasCommonServiceImpl();
}
} }
package com.xyst.dinas.biz.internal.service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import com.beecode.amino.core.Amino;
import com.beecode.bap.staff.Staff;
import com.beecode.bap.staff.service.StaffService;
import com.beecode.bcp.authz.Identity;
import com.beecode.bcp.authz.Privilege;
import com.beecode.bcp.authz.service.IdentityService;
import com.beecode.bcp.authz.service.PrivilegeService;
import com.beecode.bcp.type.KObject;
import com.beecode.bcp.type.json.JSONObjectUtils;
import com.beecode.inz.message.CommonConstants;
import com.beecode.inz.message.RemPartRelationConstants;
import com.beecode.inz.message.RemindConstants;
import com.beecode.inz.message.enumeration.ParterType;
import com.beecode.inz.message.service.RemindService;
import com.beecode.inz.message.util.MessageUtils;
import com.jiuqi.np.util.DateUtil;
import com.xyst.dinas.biz.service.DinasCommonService;
import com.xyst.dinas.biz.service.DinasOrganizationService;
public class DinasCommonServiceImpl implements DinasCommonService {
@Autowired
private RemindService remService;
@Autowired
public StaffService staffService;
@Autowired
DinasOrganizationService dinasOrganizationService;
@Autowired
IdentityService identityService;
@Autowired
PrivilegeService privilegeService;
@Override
public void addByPermissions(JSONObject data) throws Exception {
// TODO Auto-generated method stub
Date currentTime = new Date();
String currentTimeStr = DateUtil.dateTime2String(currentTime);
JSONObject remObject = data.getJSONObject("remind");
String remindId = UUID.randomUUID().toString();
remObject.put(RemindConstants.ID, remindId);
remObject.put("createTime", currentTimeStr);
remObject.put("_type", CommonConstants.REMIND_ENTITY);
if (remObject.has(RemindConstants.BUSINESS_INFO)) {
remObject.put(RemindConstants.BUSINESS_INFO, remObject.get(RemindConstants.BUSINESS_INFO).toString());
}
KObject kobject = (KObject) JSONObjectUtils.toObject(remObject.toString());
KObject creater = MessageUtils.gerCurrentStaff();
kobject.set(RemindConstants.SENDER, creater);
kobject.validate();
List<String> noticePerson = new ArrayList<String>();// 获取提醒人员
String privilegeName = data.getString("privilegeId");// 功能权限
List<UUID> staffList = dinasOrganizationService
.queryStaffByRegionalCompanyForMessage(dinasOrganizationService.getCurrentRegionalCompanyId());
for (UUID staffId : staffList) {
KObject staff = staffService.getById(staffId);
List<Identity> list = identityService.getByUser(staff.get("user").getUuid("id"));
Identity identity = list.get(0);
Privilege privilege = Amino.getApplicationMetadataContext().getBean(privilegeName, Privilege.class);
Boolean flag = privilegeService.canAccess(privilege.getId(), identity.getId(), null);
if (flag) {
noticePerson.add(staffId.toString());
}
}
JSONArray parts = new JSONArray();
for (String person : noticePerson) {
JSONObject part = new JSONObject();
part.put("participateId", person);
part.put("participateType", "person");
parts.put(part);
}
List<KObject> listRes = new ArrayList<KObject>();
for (int i = 0; i < parts.length(); i++) {
JSONObject item = parts.getJSONObject(i);
item.put("_type", CommonConstants.REM_PART_RELATION_ENTITTY);
item.put(RemPartRelationConstants.REMIND_ID, remindId);
item.put(RemPartRelationConstants.ID, UUID.randomUUID());
String partType = item.getString(RemPartRelationConstants.PARTICIPATE_TYPE);
if (ParterType.PERSON.getPartnerType().equals(partType)) {
// 参与者id是员工的id
String staffPartId = item.getString(RemPartRelationConstants.PARTICIPATE_ID);
// 根据员工的参与者id获得userId
KObject staffKObject = staffService.getById(UUID.fromString(staffPartId));
KObject userKObject = staffKObject.get(Staff.USER);
String userId = userKObject.getString("id");
item.put(RemPartRelationConstants.PARTICIPATE_ID, userId);
}
KObject entity = (KObject) JSONObjectUtils.toObject(item.toString());
listRes.add(entity);
entity.validate();
}
remService.add(kobject, listRes);
}
}
package com.xyst.dinas.biz.service;
import org.json.JSONObject;
public interface DinasCommonService {
void addByPermissions(JSONObject data)throws Exception;
}
...@@ -40,6 +40,7 @@ import com.beecode.inz.message.util.MessageUtils; ...@@ -40,6 +40,7 @@ import com.beecode.inz.message.util.MessageUtils;
import com.beecode.nlib.utils.StringUtils; import com.beecode.nlib.utils.StringUtils;
import com.jiuqi.np.util.DateUtil; import com.jiuqi.np.util.DateUtil;
import com.xyst.dinas.biz.enumeration.PlanningCycleEnum; import com.xyst.dinas.biz.enumeration.PlanningCycleEnum;
import com.xyst.dinas.biz.service.DinasCommonService;
import com.xyst.dinas.biz.service.DinasOrganizationService; import com.xyst.dinas.biz.service.DinasOrganizationService;
import com.xyst.dinas.biz.service.PlanningCycleService; import com.xyst.dinas.biz.service.PlanningCycleService;
...@@ -49,10 +50,9 @@ public class DinasCommonController { ...@@ -49,10 +50,9 @@ public class DinasCommonController {
@Autowired @Autowired
public DepartmentService departmentService; public DepartmentService departmentService;
@Autowired @Autowired
private RemindService remService;
@Autowired
public StaffService staffService; public StaffService staffService;
@Autowired
DinasCommonService dinasCommonService;
@Autowired @Autowired
DinasOrganizationService dinasOrganizationService; DinasOrganizationService dinasOrganizationService;
@Autowired @Autowired
...@@ -233,72 +233,18 @@ public class DinasCommonController { ...@@ -233,72 +233,18 @@ public class DinasCommonController {
@ResponseBody @ResponseBody
@RequestMapping(value = "/message/remindByPermissions", method = RequestMethod.POST) @RequestMapping(value = "/message/remindByPermissions", method = RequestMethod.POST)
public void addByPermissions(@RequestBody String body) throws Exception { public void addByPermissions(@RequestBody String body) throws Exception {
Date currentTime = new Date();
String currentTimeStr = DateUtil.dateTime2String(currentTime);
JSONObject data = new JSONObject(body); JSONObject data = new JSONObject(body);
JSONObject remObject = data.getJSONObject("remind"); dinasCommonService.addByPermissions(data);
String remindId = UUID.randomUUID().toString(); }
remObject.put(RemindConstants.ID, remindId); /**
remObject.put("createTime", currentTimeStr); * 创建一条提醒 通过自查当前权限
//remObject.put("remindTime", currentTimeStr); *
/* * @throws Exception
* remObject.put("remindContent", message);// 消息 remObject.put("data", billId); */
* remObject.put("lookName", lookName);// 标题 remObject.put("lookType", @ResponseBody
* lookType); @RequestMapping(value = "/sand/user/message/remindByPermissions", method = RequestMethod.POST)
*/ public void addByPermissionsForSandUser(@RequestBody String body) throws Exception {
remObject.put("_type", CommonConstants.REMIND_ENTITY); JSONObject data = new JSONObject(body);
if (remObject.has(RemindConstants.BUSINESS_INFO)) { dinasCommonService.addByPermissions(data);
remObject.put(RemindConstants.BUSINESS_INFO, remObject.get(RemindConstants.BUSINESS_INFO).toString());
}
KObject kobject = (KObject) JSONObjectUtils.toObject(remObject.toString());
KObject creater = MessageUtils.gerCurrentStaff();
kobject.set(RemindConstants.SENDER, creater);
kobject.validate();
List<String> noticePerson = new ArrayList<String>();// 获取提醒人员
//String privilegeName = "com.xyst.dinas.biz.auth.SensitiveInfoLook";//敏感信息查看功能权限
String privilegeName = data.getString("privilegeId");//功能权限
List<UUID> staffList = dinasOrganizationService
.queryStaffByRegionalCompanyForMessage(dinasOrganizationService.getCurrentRegionalCompanyId());
for(UUID staffId :staffList) {
KObject staff = staffService.getById(staffId);
List<Identity> list = identityService.getByUser(staff.get("user").getUuid("id"));
Identity identity = list.get(0);
Privilege privilege = Amino.getApplicationMetadataContext().getBean(privilegeName, Privilege.class);
Boolean flag = privilegeService.canAccess(privilege.getId(), identity.getId(), null);
if(flag) {
noticePerson.add(staffId.toString());
}
}
JSONArray parts = new JSONArray();
for (String person : noticePerson) {
JSONObject part = new JSONObject();
part.put("participateId", person);
part.put("participateType", "person");
parts.put(part);
}
List<KObject> listRes = new ArrayList<KObject>();
for (int i = 0; i < parts.length(); i++) {
JSONObject item = parts.getJSONObject(i);
item.put("_type", CommonConstants.REM_PART_RELATION_ENTITTY);
item.put(RemPartRelationConstants.REMIND_ID, remindId);
item.put(RemPartRelationConstants.ID, UUID.randomUUID());
String partType = item.getString(RemPartRelationConstants.PARTICIPATE_TYPE);
if (ParterType.PERSON.getPartnerType().equals(partType)) {
// 参与者id是员工的id
String staffPartId = item.getString(RemPartRelationConstants.PARTICIPATE_ID);
// 根据员工的参与者id获得userId
KObject staffKObject = staffService.getById(UUID.fromString(staffPartId));
KObject userKObject = staffKObject.get(Staff.USER);
String userId = userKObject.getString("id");
item.put(RemPartRelationConstants.PARTICIPATE_ID, userId);
}
KObject entity = (KObject) JSONObjectUtils.toObject(item.toString());
listRes.add(entity);
entity.validate();
}
remService.add(kobject, listRes);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment