use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class DataTransfer method pmphUser.
/**
* 社内用户表迁移
*/
public int pmphUser() {
String sql = "SELECT a.usercode,a.`password`,a.username,c.orgid,b.handset,b.email,a.memo,a.sortno FROM sys_user a LEFT JOIN sys_userext b ON a.userid = b.userid LEFT JOIN sys_userorganize c ON b.userid = c.userid WHERE a.sysflag = 0";
ConnectionManager cm;
ResultSet rs;
try {
cm = new ConnectionManager(url, username, password);
rs = cm.getResultSet(sql);
} catch (ClassNotFoundException | SQLException ex) {
logger.error("JDBC初始化发生错误", ex);
return 0;
}
int count = 0;
try {
while (rs.next()) {
PmphUser pmphUser = new PmphUser();
pmphUser.setUsername(rs.getString(1));
pmphUser.setPassword(rs.getString(2));
pmphUser.setRealname(rs.getString(3));
pmphUser.setHandphone(rs.getString(5));
pmphUser.setEmail(rs.getString(6));
pmphUser.setNote(rs.getString(7));
pmphUser.setSort(rs.getInt(8));
pmphUserService.add(pmphUser);
count++;
if (count % 100 == 0) {
logger.info("已经迁移{}条数据", count);
}
}
logger.info("一共迁移{}条数据", count);
cm.close();
} catch (SQLException ex) {
logger.error("SQL语句运行发生错误", ex);
return count;
}
return count;
}
use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class SessionUtil method getPmphUserBySessionId.
/**
* <pre>
* 功能描述:根据SessionId获取用户对象(现阶段使用)
* 使用示范:
*
* @return
* </pre>
*/
public static PmphUser getPmphUserBySessionId(String sessionId) throws CheckedServiceException {
HttpSession session = SessionContext.getSession(sessionId);
if (ObjectUtil.isNull(session)) {
throw new CheckedServiceException(CheckedExceptionBusiness.SESSION, CheckedExceptionResult.USER_SESSION, "当前Session会话已过期,请重新登录!");
}
PmphUser pmphUser = (PmphUser) session.getAttribute(Const.SESSION_PMPH_USER);
return pmphUser;
}
use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class MigrationPlus method department.
// 清除冗余部门
protected void department() {
// 查询现在所有部门,
PmphUserDepartmentVO departmentVO = pmphDepartmentService.listPmphDepartment(null);
// 部门总数为28,超过则是多余部门
if (ObjectUtil.notNull(departmentVO) && departmentVO.getSonDepartment().size() > 28) {
for (PmphUserDepartmentVO pmphDepartment : departmentVO.getSonDepartment()) {
// 查询该部门下的所有成员
List<PmphUser> pmphUsers = pmphUserService.listPmphUserByDepartmentId(pmphDepartment.getId());
switch(pmphDepartment.getDpName()) {
case "出版社科室1":
if (ObjectUtil.notNull(pmphUsers)) {
for (PmphUser pmphUser : pmphUsers) {
// 把该部门人员移到人民卫生出版社部门下
pmphUser.setDepartmentId(0L);
pmphUserService.updateUser(pmphUser);
}
}
// 删除多余的部门
pmphDepartmentService.deletePmphDepartmentBatch(pmphDepartment.getId());
break;
case "公司领导":
// 查询该部门下的所有成员
if (ObjectUtil.notNull(pmphUsers)) {
for (PmphUser pmphUser : pmphUsers) {
// 把该部门人员移到人民卫生出版社部门下
pmphUser.setDepartmentId(0L);
pmphUserService.updateUser(pmphUser);
}
}
// 删除多余的部门
pmphDepartmentService.deletePmphDepartmentBatch(pmphDepartment.getId());
break;
case "其他":
// 查询该部门下的所有成员
if (ObjectUtil.notNull(pmphUsers)) {
for (PmphUser pmphUser : pmphUsers) {
// 把该部门人员移到人民卫生出版社部门下
pmphUser.setDepartmentId(0L);
pmphUserService.updateUser(pmphUser);
}
}
// 删除多余的部门
pmphDepartmentService.deletePmphDepartmentBatch(pmphDepartment.getId());
break;
case "农协":
// 查询该部门下的所有成员
if (ObjectUtil.notNull(pmphUsers)) {
for (PmphUser pmphUser : pmphUsers) {
// 把该部门人员移到人民卫生出版社部门下
pmphUser.setDepartmentId(0L);
pmphUserService.updateUser(pmphUser);
}
}
// 删除多余的部门
pmphDepartmentService.deletePmphDepartmentBatch(pmphDepartment.getId());
break;
default:
break;
}
}
}
}
use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class PmphGroupMessageServiceImpl method addGroupMessage.
@Override
public String addGroupMessage(String msgConrent, Long groupId, String sessionId, Short senderType) throws CheckedServiceException, IOException {
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (null == pmphUser || null == pmphUser.getId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "用户为空");
}
Long userId = pmphUser.getId();
PmphGroupMemberVO pmphGroupMemberVO = pmphGroupMemberService.getPmphGroupMemberByMemberId(groupId, userId, // 获取后台用户
false);
if (ObjectUtil.isNull(pmphGroupMemberVO)) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "您不是该小组成员,无法与其他成员对话或上传小组文件。");
}
PmphGroupMessage pmphGroupMessage;
if (senderType == 0) {
pmphGroupMessage = new PmphGroupMessage(groupId, 0L, msgConrent);
} else {
pmphGroupMessage = new PmphGroupMessage(groupId, pmphGroupMemberVO.getId(), msgConrent);
}
pmphGroupMessageDao.addPmphGroupMessage(pmphGroupMessage);
pmphGroupMessage = pmphGroupMessageDao.getPmphGroupMessageById(pmphGroupMessage.getId());
// 将该条消息创建时间作为最后一条消息时间放入该小组中
PmphGroup pmphGroup = new PmphGroup();
pmphGroup.setId(groupId);
pmphGroup.setGmtLastMessage(pmphGroupMessage.getGmtCreate());
pmphGroupDao.updatePmphGroup(pmphGroup);
// 进行推送消息步骤1.查询接收人的id 2.进行推送
List<PmphGroupMemberVO> list = pmphGroupMemberService.listPmphGroupMember(groupId, sessionId);
List<String> ids = new ArrayList<String>();
for (PmphGroupMemberVO groupMemberVO : list) {
String tempId = (groupMemberVO.getIsWriter() ? "2" : "1") + "_" + groupMemberVO.getUserId();
ids.add(tempId);
}
WebScocketMessage webScocketMessage = new WebScocketMessage(String.valueOf(pmphGroupMessage.getId()), Const.MSG_TYPE_3, userId, pmphGroupMemberVO.getDisplayName(), senderType, Const.SEND_MSG_TYPE_0, null, null, msgConrent, pmphGroupMessage.getGmtCreate());
webScocketMessage.setGroupId(groupId);
webScocketMessage.setSenderIcon(pmphGroupMemberVO.getAvatar());
handler.sendWebSocketMessageToUser(ids, webScocketMessage);
return "SUCCESS";
}
use of com.bc.pmpheep.back.po.PmphUser in project pmph by BCSquad.
the class PmphGroupServiceImpl method getlistPmphGroup.
@Override
public PageResult<PmphGroupListVO> getlistPmphGroup(PageParameter<PmphGroupListVO> pageParameter, String sessionId) throws CheckedServiceException {
if (null == pageParameter) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "参数对象为空");
}
// session PmphUser用户验证
PmphUser pmphUser = SessionUtil.getPmphUserBySessionId(sessionId);
if (null == pmphUser || null == pmphUser.getId()) {
throw new CheckedServiceException(CheckedExceptionBusiness.GROUP, CheckedExceptionResult.NULL_PARAM, "用户为空");
}
List<PmphGroupListVO> list = new ArrayList<>();
PageResult<PmphGroupListVO> pageResult = new PageResult<>();
PageParameterUitl.CopyPageParameter(pageParameter, pageResult);
Integer total = 0;
if (pmphUser.getIsAdmin()) {
total = pmphGroupDao.getAdminCount();
list = pmphGroupDao.getPmphGroupList(pageParameter);
for (PmphGroupListVO pmphGroupListVO : list) {
pmphGroupListVO.setGroupImage(RouteUtil.groupImage(pmphGroupListVO.getGroupImage()));
}
pageResult.setRows(list);
pageResult.setTotal(total);
} else {
PmphGroup pmphGroup = new PmphGroup();
List<PmphGroupListVO> groupListVOs = pmphGroupDao.getList(pmphGroup, pmphUser.getId());
for (PmphGroupListVO pmphGroupListVO : groupListVOs) {
pmphGroupListVO.setGroupImage(RouteUtil.groupImage(pmphGroupListVO.getGroupImage()));
}
if (groupListVOs.size() > 0) {
pageResult.setRows(groupListVOs);
pageResult.setTotal(groupListVOs.size());
}
}
return pageResult;
}
Aggregations