feat: 一些调整
This commit is contained in:
parent
ed316c7925
commit
3a3220d7d3
|
|
@ -1,8 +1,6 @@
|
|||
package com.nflg.mobilebroken.admin.controller;
|
||||
|
||||
import com.nflg.mobilebroken.admin.annotation.ApiMark;
|
||||
import com.nflg.mobilebroken.common.constant.STATE;
|
||||
import com.nflg.mobilebroken.common.exception.NflgException;
|
||||
import com.nflg.mobilebroken.starter.service.impl.APPSSEManagerService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.MediaType;
|
||||
|
|
@ -13,7 +11,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
|
||||
@RestController
|
||||
@Slf4j
|
||||
|
|
@ -33,13 +30,13 @@ public class SSEController extends ControllerBase {
|
|||
@ApiMark(moduleName = "连接", apiName = "SSE", isPublic = true)
|
||||
public SseEmitter connect(@RequestParam String userId) {
|
||||
SseEmitter sse = sseManagerService.connect(Integer.valueOf(userId));
|
||||
try {
|
||||
sse.send("您已连接");
|
||||
} catch (IOException e) {
|
||||
log.error("sse发送数据出错", e);
|
||||
sse.complete();
|
||||
throw new NflgException(STATE.BusinessError, "sse发送数据出错");
|
||||
}
|
||||
// try {
|
||||
// sse.send("您已连接");
|
||||
// } catch (IOException e) {
|
||||
// log.error("sse发送数据出错", e);
|
||||
// sse.complete();
|
||||
// throw new NflgException(STATE.BusinessError, "sse发送数据出错");
|
||||
// }
|
||||
return sse;
|
||||
}
|
||||
}
|
||||
|
|
@ -511,7 +511,7 @@ public class TicketController extends ControllerBase {
|
|||
vo.setMessages(messageVOS);
|
||||
String key="chatMessage:readed:"+ticketId+":admin:"+AdminUserUtil.getUserId();
|
||||
Set<String> readeds=redisTemplate.opsForSet().members(key);
|
||||
Set<String> notReadeds=new HashSet<>();
|
||||
Set<String> notReadeds=new LinkedHashSet<>();
|
||||
if (CollectionUtil.isEmpty(readeds)){
|
||||
notReadeds=messageVOS.stream()
|
||||
.filter(m->!Objects.equals(m.getSenderId(),AdminUserUtil.getUserId()))
|
||||
|
|
@ -529,7 +529,7 @@ public class TicketController extends ControllerBase {
|
|||
if (CollectionUtil.isNotEmpty(notReadeds)) {
|
||||
redisTemplate.opsForSet().add(key, notReadeds.toArray(String[]::new));
|
||||
vo.setNotReadCount(notReadeds.size());
|
||||
vo.setFirstMessageId(notReadeds.stream().findFirst().get());
|
||||
vo.setFirstMessageId(notReadeds.iterator().next());
|
||||
}
|
||||
return ApiResult.success(vo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class TicketReplyEvent extends ApplicationEvent implements ApplicationCon
|
|||
|
||||
public void send(){
|
||||
sendUserMessage();
|
||||
sendEmail();
|
||||
// sendEmail();
|
||||
}
|
||||
|
||||
private void sendUserMessage(){
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import com.nflg.mobilebroken.repository.entity.*;
|
|||
import com.nflg.mobilebroken.repository.service.*;
|
||||
import com.nflg.mobilebroken.starter.service.EmailService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -34,6 +35,9 @@ import java.util.stream.Collectors;
|
|||
@Slf4j
|
||||
public class TicketScheduledTasks {
|
||||
|
||||
@Value("${email.activate.app.website}")
|
||||
private String websiteUrl;
|
||||
|
||||
@Resource
|
||||
private ITicketService ticketService;
|
||||
|
||||
|
|
@ -82,12 +86,10 @@ public class TicketScheduledTasks {
|
|||
List<AdminUser> adminUsers = adminUserService.listByIds(adminUserIds);
|
||||
String subject = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_TITLE_TICKET_INVITE_COMMENT, Constant.DEFAULT_LANGUAGE_CODE);
|
||||
String content = dictionaryItemTranslateService.getValueByCode(Constant.DICTIONARY_EMAIL_NOTIFY, Constant.DICTIONARY_ITEM_EMAIL_CONTENT_TICKET_INVITE_COMMENT, Constant.DEFAULT_LANGUAGE_CODE)
|
||||
.replace("${no}", ticket.getNo())
|
||||
.replace("${websiteUrl}", websiteUrl)
|
||||
.replace("${title}", ticket.getTitle())
|
||||
.replace("${createUser}", createUser.getUserName())
|
||||
.replace("${handleUser}", StrUtil.join(",", adminUsers.stream().map(AdminUser::getUserName).collect(Collectors.toList())))
|
||||
.replace("${createTime}", toTimeString(ticket.getCreateTime()))
|
||||
.replace("${msg}", subject);
|
||||
.replace("${url}", websiteUrl+"/#/workOrder/workOrderDetail?id="+ticket.getId());
|
||||
try {
|
||||
sendEamilForAdminUser(adminUsers, subject, content);
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package com.nflg.mobilebroken.cfs.controller;
|
||||
|
||||
import com.nflg.mobilebroken.common.constant.STATE;
|
||||
import com.nflg.mobilebroken.common.exception.NflgException;
|
||||
import com.nflg.mobilebroken.starter.service.impl.AdminSSEManagerService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.MediaType;
|
||||
|
|
@ -12,7 +10,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* sse相关接口
|
||||
|
|
@ -35,13 +32,13 @@ public class SSEController extends ControllerBase {
|
|||
@GetMapping(value = "connect",produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
||||
public SseEmitter connect(@RequestParam Integer userId) {
|
||||
SseEmitter sse = adminSSEManagerService.connect(userId);
|
||||
try {
|
||||
sse.send("您已连接");
|
||||
} catch (IOException e) {
|
||||
log.error("sse发送数据出错",e);
|
||||
sse.complete();
|
||||
throw new NflgException(STATE.BusinessError,"sse发送数据出错");
|
||||
}
|
||||
// try {
|
||||
// sse.send("您已连接");
|
||||
// } catch (IOException e) {
|
||||
// log.error("sse发送数据出错",e);
|
||||
// sse.complete();
|
||||
// throw new NflgException(STATE.BusinessError,"sse发送数据出错");
|
||||
// }
|
||||
return sse;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ public class TiketController extends ControllerBase {
|
|||
vo.setMessages(messageVOS);
|
||||
String key="chatMessage:readed:"+ticketId+":app:"+AppUserUtil.getUserId();
|
||||
Set<String> readeds=redisTemplate.opsForSet().members(key);
|
||||
Set<String> notReadeds=new HashSet<>();
|
||||
Set<String> notReadeds=new LinkedHashSet<>();
|
||||
if (CollectionUtil.isEmpty(readeds)){
|
||||
notReadeds=messageVOS.stream()
|
||||
.filter(m->!Objects.equals(m.getSenderId(),AppUserUtil.getUserId()))
|
||||
|
|
@ -304,7 +304,7 @@ public class TiketController extends ControllerBase {
|
|||
if (CollectionUtil.isNotEmpty(notReadeds)) {
|
||||
redisTemplate.opsForSet().add(key, notReadeds.toArray(String[]::new));
|
||||
vo.setNotReadCount(notReadeds.size());
|
||||
vo.setFirstMessageId(notReadeds.stream().findFirst().get());
|
||||
vo.setFirstMessageId(notReadeds.iterator().next());
|
||||
}
|
||||
return ApiResult.success(vo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ public class UserController extends ControllerBase {
|
|||
if (CollectionUtil.isNotEmpty(adminUsers)){
|
||||
adminUsers.forEach(c -> adminMessageService.add(
|
||||
new AdminMessage()
|
||||
.setNo(applyfor.getUserEmail())
|
||||
.setNo(request.getEmail())
|
||||
.setUserId(c.getId())
|
||||
.setSourceId(applyfor.getId())
|
||||
.setSource(1)
|
||||
|
|
|
|||
|
|
@ -95,9 +95,9 @@ public class AppUserApplyfor implements Serializable {
|
|||
private String salesUserName;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
* 创建人id
|
||||
*/
|
||||
private String createBy;
|
||||
private Integer createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ public class AdminRoleServiceImpl extends ServiceImpl<AdminRoleMapper, AdminRole
|
|||
if (!Objects.equals(0,menu.getParentId())){
|
||||
AdminMenu mp=menuService.getById(menu.getParentId());
|
||||
if (datas.stream().noneMatch(d->Objects.equals(d.getId(),mp.getId()))){
|
||||
MenuVO m=new MenuVO().setId(mp.getId()).setName(mp.getName()).setUrl(mp.getUrl()).setComponent(mp.getComponent()).setParentId(mp.getParentId());
|
||||
MenuVO m=new MenuVO().setId(mp.getId()).setName(mp.getName()).setShow(mp.getShow()).setUrl(mp.getUrl()).setComponent(mp.getComponent()).setParentId(mp.getParentId());
|
||||
datas.add(m);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ public class AppUserApplyforServiceImpl extends ServiceImpl<AppUserApplyforMappe
|
|||
.setCompanyId(request.getCompanyId())
|
||||
.setTitleId(request.getTitleId())
|
||||
.setType(AppUserApplyforType.ADD.getState().byteValue())
|
||||
.setCreateBy(AppUserUtil.getUserName())
|
||||
.setCreateBy(AppUserUtil.getUserId())
|
||||
.setCreateTime(LocalDateTime.now());
|
||||
save(applyfor);
|
||||
return applyfor;
|
||||
|
|
@ -87,12 +87,17 @@ public class AppUserApplyforServiceImpl extends ServiceImpl<AppUserApplyforMappe
|
|||
|
||||
@Override
|
||||
public AppUserApplyfor addEnable(EnableRequest request) {
|
||||
VUtils.trueThrowBusinessError(lambdaQuery()
|
||||
.eq(AppUserApplyfor::getUserId, request.getId())
|
||||
.eq(AppUserApplyfor::getState, AppUserApplyForState.PENDINGAPPROVAL.getState().byteValue())
|
||||
.exists())
|
||||
.throwMessage("正在审批中,请勿重复申请");
|
||||
AppUserApplyfor applyfor = new AppUserApplyfor()
|
||||
.setUserId(request.getId())
|
||||
.setReason(request.getReason())
|
||||
.setState(AppUserApplyForState.PENDINGAPPROVAL.getState().byteValue())
|
||||
.setType(AppUserApplyforType.ENABLE.getState().byteValue())
|
||||
.setCreateBy(AppUserUtil.getUserName())
|
||||
.setCreateBy(AppUserUtil.getUserId())
|
||||
.setCreateTime(LocalDateTime.now());
|
||||
save(applyfor);
|
||||
return applyfor;
|
||||
|
|
@ -100,12 +105,19 @@ public class AppUserApplyforServiceImpl extends ServiceImpl<AppUserApplyforMappe
|
|||
|
||||
@Override
|
||||
public AppUserApplyfor applyForExtension(ApplyForExtensionRequest request) {
|
||||
VUtils.trueThrowBusinessError(lambdaQuery()
|
||||
.eq(AppUserApplyfor::getUserId, request.getUserId())
|
||||
.eq(AppUserApplyfor::getState, AppUserApplyForState.PENDINGAPPROVAL.getState().byteValue())
|
||||
.exists())
|
||||
.throwMessage("正在审批中,请勿重复申请");
|
||||
AppUser appUser=appUserService.getById(request.getUserId());
|
||||
AppUserApplyfor applyfor = new AppUserApplyfor()
|
||||
.setUserId(request.getUserId())
|
||||
.setReason(request.getReason())
|
||||
.setUserEmail(appUser.getEmail())
|
||||
.setState(AppUserApplyForState.PENDINGAPPROVAL.getState().byteValue())
|
||||
.setType(AppUserApplyforType.EXTENSION.getState().byteValue())
|
||||
.setCreateBy(AppUserUtil.getUserName())
|
||||
.setCreateBy(AppUserUtil.getUserId())
|
||||
.setCreateTime(LocalDateTime.now());
|
||||
save(applyfor);
|
||||
return applyfor;
|
||||
|
|
@ -115,6 +127,8 @@ public class AppUserApplyforServiceImpl extends ServiceImpl<AppUserApplyforMappe
|
|||
public AppUserApplyforVO getAppUserApplyfor(Integer id) {
|
||||
AppUserApplyfor applyfor = getById(id);
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(applyfor)).throwMessage("审批信息不存在");
|
||||
VUtils.trueThrowBusinessError(!Objects.equals(applyfor.getState(), AppUserApplyForState.PENDINGAPPROVAL.getState().byteValue()))
|
||||
.throwMessage("已经审批过了");
|
||||
AppUserApplyforVO vo = new AppUserApplyforVO();
|
||||
AppUserApplyforInfoVO applyforInfo=new AppUserApplyforInfoVO()
|
||||
.setType(applyfor.getType())
|
||||
|
|
@ -125,6 +139,10 @@ public class AppUserApplyforServiceImpl extends ServiceImpl<AppUserApplyforMappe
|
|||
.setReason(applyfor.getReason())
|
||||
.setCreateTime(applyfor.getCreateTime());
|
||||
AppUser appUser;
|
||||
String companyId= "";
|
||||
if (Objects.nonNull(applyfor.getCompanyId())){
|
||||
companyId= String.valueOf(applyfor.getCompanyId());
|
||||
}
|
||||
if (Objects.nonNull(applyfor.getUserId())) {
|
||||
appUser = appUserService.getById(applyfor.getUserId());
|
||||
if (Objects.isNull(applyfor.getAreaId())) {
|
||||
|
|
@ -133,13 +151,17 @@ public class AppUserApplyforServiceImpl extends ServiceImpl<AppUserApplyforMappe
|
|||
if (Objects.isNull(applyfor.getTitleId())) {
|
||||
applyfor.setTitleId(appUser.getTitleId());
|
||||
}
|
||||
List<TBaseCustomer> customers =customerService.listByIds(Arrays.stream(appUser.getCompanyId().split(",")).map(Integer::parseInt).collect(Collectors.toList()));
|
||||
applyforInfo
|
||||
.setCompanyName(StrUtil.join(",",customers.stream().map(TBaseCustomer::getAgencyCompanyName).collect(Collectors.toList())))
|
||||
.setPhone(appUser.getPhone())
|
||||
if (StrUtil.isBlank(companyId)){
|
||||
companyId= appUser.getCompanyId();
|
||||
}
|
||||
applyforInfo.setPhone(appUser.getPhone())
|
||||
.setUserName(appUser.getName())
|
||||
.setEmail(appUser.getEmail());
|
||||
}
|
||||
if (StrUtil.isNotBlank(companyId)) {
|
||||
List<TBaseCustomer> customers =customerService.listByIds(Arrays.stream(companyId.split(",")).map(Integer::parseInt).collect(Collectors.toList()));
|
||||
applyforInfo.setCompanyName(StrUtil.join(",",customers.stream().map(TBaseCustomer::getAgencyCompanyName).collect(Collectors.toList())));
|
||||
}
|
||||
if (Objects.nonNull(applyfor.getAreaId())) {
|
||||
AppArea area = appAreaService.getById(applyfor.getAreaId());
|
||||
applyforInfo.setAreaName(area.getName());
|
||||
|
|
@ -157,6 +179,7 @@ public class AppUserApplyforServiceImpl extends ServiceImpl<AppUserApplyforMappe
|
|||
.setState(1)
|
||||
.setTitle(Objects.isNull(appUser.getTitleId()) ? "" : positionService.getById(appUser.getTitleId()).getPositionName())
|
||||
.setExpireTime(appUser.getExpireTime())
|
||||
.setLoginName(appUser.getLoginName())
|
||||
.setEmail(appUser.getEmail())
|
||||
.setName(appUser.getName())
|
||||
.setPrimary(appUser.getIsPrimary()));
|
||||
|
|
@ -168,6 +191,8 @@ public class AppUserApplyforServiceImpl extends ServiceImpl<AppUserApplyforMappe
|
|||
public void approveAppUserApplyfor(ApproveAppUserApplyforRequest request) {
|
||||
AppUserApplyfor applyfor = getById(request.getId());
|
||||
VUtils.trueThrowBusinessError(Objects.isNull(applyfor)).throwMessage("审批信息不存在");
|
||||
VUtils.trueThrowBusinessError(!Objects.equals(applyfor.getState(), AppUserApplyForState.PENDINGAPPROVAL.getState().byteValue()))
|
||||
.throwMessage("已经审批过了");
|
||||
if (request.getPass()) {
|
||||
if (applyfor.getType() == AppUserApplyforType.ADD.getState().byteValue()) {
|
||||
//新增账号
|
||||
|
|
@ -184,7 +209,7 @@ public class AppUserApplyforServiceImpl extends ServiceImpl<AppUserApplyforMappe
|
|||
.setCompanyId(String.valueOf(applyfor.getCompanyId()))
|
||||
.setTitleId(applyfor.getTitleId())
|
||||
.setState(UserState.ToBeActivated.getState())
|
||||
.setCreateBy(applyfor.getCreateBy())
|
||||
.setCreateBy(appUser.getName())
|
||||
.setCreateTime(LocalDateTime.now())
|
||||
.setExpireTime(appUser.getExpireTime())
|
||||
.setSalesUserName(appUser.getSalesUserName());
|
||||
|
|
@ -192,15 +217,17 @@ public class AppUserApplyforServiceImpl extends ServiceImpl<AppUserApplyforMappe
|
|||
} else if (applyfor.getType() == AppUserApplyforType.ENABLE.getState().byteValue()) {
|
||||
//账号启用
|
||||
AppUser appUser = appUserService.getById(applyfor.getUserId());
|
||||
AppUser applyUser = appUserService.getById(applyfor.getCreateBy());
|
||||
appUser.setState(UserState.Activated.getState())
|
||||
.setUpdateBy(applyfor.getCreateBy())
|
||||
.setUpdateBy(applyUser.getName())
|
||||
.setUpdateTime(LocalDateTime.now());
|
||||
appUserService.updateById(appUser);
|
||||
} else if (applyfor.getType() == AppUserApplyforType.EXTENSION.getState().byteValue()) {
|
||||
//账号延期
|
||||
AppUser appUser = appUserService.getById(applyfor.getUserId());
|
||||
AppUser applyUser = appUserService.getById(applyfor.getCreateBy());
|
||||
appUser.setExpireTime(appUser.getExpireTime().plusYears(1))
|
||||
.setUpdateBy(applyfor.getCreateBy())
|
||||
.setUpdateBy(applyUser.getName())
|
||||
.setUpdateTime(LocalDateTime.now());
|
||||
appUserService.updateById(appUser);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.mobilebroken.common.constant.AppUserApplyForState;
|
||||
import com.nflg.mobilebroken.common.constant.Constant;
|
||||
import com.nflg.mobilebroken.common.constant.STATE;
|
||||
import com.nflg.mobilebroken.common.constant.UserState;
|
||||
import com.nflg.mobilebroken.common.constant.*;
|
||||
import com.nflg.mobilebroken.common.exception.NflgException;
|
||||
import com.nflg.mobilebroken.common.pojo.PageData;
|
||||
import com.nflg.mobilebroken.common.pojo.request.*;
|
||||
|
|
@ -311,7 +308,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
|||
if (Objects.nonNull(d.getTitleId())) {
|
||||
title = positionService.getById(d.getTitleId());
|
||||
}
|
||||
return new AppUserForAdminVO()
|
||||
AppUserForAdminVO vo= new AppUserForAdminVO()
|
||||
.setKey("u-" + d.getId())
|
||||
.setId(d.getId())
|
||||
.setAvatar(d.getAvatar())
|
||||
|
|
@ -331,12 +328,22 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
|||
.setCreateBy(d.getCreateBy())
|
||||
.setCreateTime(d.getCreateTime())
|
||||
.setUpdateBy(d.getUpdateBy())
|
||||
.setUpdateTime(d.getUpdateTime())
|
||||
.setPrimary(true)
|
||||
.setState(d.getExpireTime().isAfter(ChronoLocalDate.from(LocalDateTime.now())) ? 1 : 2)
|
||||
.setLastLoginTime(d.getLastLoginTime())
|
||||
.setTitleId(d.getTitleId())
|
||||
.setTitle(Objects.isNull(title)?"":title.getPositionName())
|
||||
.setChildren(getChildrenOfAppUser(d.getId()));
|
||||
AppUserApplyfor applyFor=appUserApplyforService.lambdaQuery()
|
||||
.eq(AppUserApplyfor::getUserId, d.getId())
|
||||
.eq(AppUserApplyfor::getState, AppUserApplyForState.PENDINGAPPROVAL.getState().byteValue())
|
||||
.ne(AppUserApplyfor::getType, AppUserApplyforType.ADD.getState().byteValue())
|
||||
.one();
|
||||
if (Objects.nonNull(applyFor)) {
|
||||
vo.setKey("f-" + applyFor.getId()).setId(applyFor.getId()).setState(0);
|
||||
}
|
||||
return vo;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -398,7 +405,7 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
|||
}
|
||||
TBaseCustomer customer=customerService.getById(Integer.valueOf(d.getCompanyId()));
|
||||
TBasePosition title=positionService.getById(d.getTitleId());
|
||||
return new AppUserForAdminVO()
|
||||
AppUserForAdminVO vo= new AppUserForAdminVO()
|
||||
.setKey("u-" + d.getId())
|
||||
.setId(d.getId())
|
||||
.setAvatar(d.getAvatar())
|
||||
|
|
@ -421,11 +428,22 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
|||
.setCreateBy(d.getCreateBy())
|
||||
.setCreateTime(d.getCreateTime())
|
||||
.setUpdateBy(d.getUpdateBy())
|
||||
.setUpdateTime(d.getUpdateTime())
|
||||
.setState(d.getExpireTime().isAfter(ChronoLocalDate.from(LocalDateTime.now())) ? 1 : 2)
|
||||
.setLastLoginTime(d.getLastLoginTime());
|
||||
AppUserApplyfor applyFor=appUserApplyforService.lambdaQuery()
|
||||
.eq(AppUserApplyfor::getUserId, d.getId())
|
||||
.eq(AppUserApplyfor::getState, AppUserApplyForState.PENDINGAPPROVAL.getState().byteValue())
|
||||
.ne(AppUserApplyfor::getType, AppUserApplyforType.ADD.getState().byteValue())
|
||||
.one();
|
||||
if (Objects.nonNull(applyFor)) {
|
||||
vo.setKey("f-" + applyFor.getId()).setId(applyFor.getId()).setState(0);
|
||||
}
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<AppUserApplyfor> queryApplyforListWrapper = new LambdaQueryWrapper<>();
|
||||
queryApplyforListWrapper.eq(AppUserApplyfor::getState, AppUserApplyForState.PENDINGAPPROVAL.getState().byteValue());
|
||||
queryApplyforListWrapper.eq(AppUserApplyfor::getType, AppUserApplyforType.ADD.getState().byteValue());
|
||||
queryApplyforListWrapper.and(wrapper -> {
|
||||
for (String companyId : companyIds) {
|
||||
wrapper.or().eq(AppUserApplyfor::getCompanyId, Integer.parseInt(companyId));
|
||||
|
|
@ -435,6 +453,8 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
|||
vos.addAll(applyforList.stream().map(d -> {
|
||||
AppArea area = appAreaService.getById(d.getAreaId());
|
||||
TBaseCustomer company = customerService.getById(d.getCompanyId());
|
||||
TBasePosition title=positionService.getById(d.getTitleId());
|
||||
AppUser createdByUser = getById(d.getCreateBy());
|
||||
return new AppUserForAdminVO()
|
||||
.setKey("f-" + d.getId())
|
||||
.setId(d.getId())
|
||||
|
|
@ -447,8 +467,13 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserMapper, AppUser> impl
|
|||
.setEmail(d.getUserEmail())
|
||||
.setSalesUserName(d.getSalesUserName())
|
||||
.setAreaName(area.getName())
|
||||
.setAreaId(d.getAreaId())
|
||||
.setUserState(UserState.ToBeActivated.getState())
|
||||
.setPrimary(false)
|
||||
.setTitleId(d.getTitleId())
|
||||
.setTitle(title.getPositionName())
|
||||
.setCreateBy(createdByUser.getName())
|
||||
.setCreateTime(d.getCreateTime())
|
||||
.setState(0);
|
||||
}).collect(Collectors.toList()));
|
||||
return vos;
|
||||
|
|
|
|||
|
|
@ -98,7 +98,8 @@ public class TBaseCustomerServiceImpl extends ServiceImpl<TBaseCustomerMapper, T
|
|||
return datas.stream()
|
||||
.map(d -> new CompanySimpleVO()
|
||||
.setId(d.getId())
|
||||
.setName(d.getAgencyCompanyName()))
|
||||
.setName(d.getAgencyCompanyName())
|
||||
.setCode(d.getAgencyCompanyCode()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
</select>
|
||||
|
||||
<select id="getMenusByRoleCodes" resultType="com.nflg.mobilebroken.common.pojo.vo.MenuVO">
|
||||
SELECT DISTINCT m.id,m.`name`,m.url,m.component,m.parent_id AS 'parentId'
|
||||
SELECT DISTINCT m.id,m.`name`,m.url,m.component,m.parent_id AS 'parentId',m.`show`
|
||||
FROM admin_role r
|
||||
INNER JOIN admin_role_menu_map rmm ON r.id=rmm.role_id
|
||||
INNER JOIN admin_menu m ON rmm.menu_id=m.id
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ public class CodeGenerator {
|
|||
, Paths.get(System.getProperty("user.dir")) + "/src/main/resources/mapper"))
|
||||
)
|
||||
.strategyConfig(builder -> {
|
||||
builder.entityBuilder()
|
||||
builder.addInclude("aaa") //只生成指定表
|
||||
.entityBuilder()
|
||||
.enableLombok()
|
||||
.enableChainModel()
|
||||
.enableFileOverride();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.nflg.mobilebroken.starter.service;
|
||||
|
||||
import com.nflg.mobilebroken.common.constant.STATE;
|
||||
import com.nflg.mobilebroken.common.util.IdUtil;
|
||||
import com.nflg.mobilebroken.common.util.VUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
|
@ -39,7 +38,15 @@ public class SSEManagerBase {
|
|||
|
||||
protected SseEmitter connect(Integer userId, Map<Integer, SseEmitter> emitters) {
|
||||
SseEmitter emitter = new SseEmitter(Long.MAX_VALUE);
|
||||
emitters.put(userId, emitter);
|
||||
SseEmitter old=emitters.put(userId, emitter);
|
||||
if (Objects.nonNull(old)){
|
||||
log.warn("停止旧连接:"+userId);
|
||||
try {
|
||||
old.complete();
|
||||
} catch (Exception e) {
|
||||
old.completeWithError(e);
|
||||
}
|
||||
}
|
||||
emitter.onError((ex) -> {
|
||||
emitters.remove(userId);
|
||||
emitter.complete();
|
||||
|
|
@ -55,7 +62,11 @@ public class SSEManagerBase {
|
|||
emitter.complete();
|
||||
log.error("SSE完成:"+userId);
|
||||
});
|
||||
SseEmitter.event().id(IdUtil.getIdStr()).name("connected").data("已连接").reconnectTime(5000);
|
||||
try {
|
||||
emitter.send(SseEmitter.event().data("已连接").reconnectTime(5000));
|
||||
} catch (IOException e) {
|
||||
log.error("sse发送数据出错", e);
|
||||
}
|
||||
return emitter;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
|
@ -53,4 +54,17 @@ public class APPSSEManagerService extends SSEManagerBase implements SSEManagerSe
|
|||
public Collection<Integer> getUserIds() {
|
||||
return EMITTERS.keySet();
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void cleanup() {
|
||||
log.info("释放SSE连接");
|
||||
for (SseEmitter emitter : EMITTERS.values()) {
|
||||
try {
|
||||
emitter.complete();
|
||||
} catch (Exception e) {
|
||||
emitter.completeWithError(e);
|
||||
}
|
||||
}
|
||||
EMITTERS.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
|
@ -29,7 +30,7 @@ public class AdminSSEManagerService extends SSEManagerBase implements SSEManager
|
|||
|
||||
@Override
|
||||
public void send(Integer userId, SSEMessageDTO message) throws IOException {
|
||||
log.info(StrUtil.format("管理端端SSE发送消息,用户id: {},内容: {}", userId, message));
|
||||
log.info(StrUtil.format("管理端SSE发送消息,用户id: {},内容: {}", userId, message));
|
||||
SseEmitter emitter = EMITTERS.get(userId);
|
||||
if (Objects.isNull(emitter)) {
|
||||
log.error("用户未连接SSE: " + userId);
|
||||
|
|
@ -53,4 +54,17 @@ public class AdminSSEManagerService extends SSEManagerBase implements SSEManager
|
|||
public Collection<Integer> getUserIds() {
|
||||
return EMITTERS.keySet();
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void cleanup() {
|
||||
log.info("释放SSE连接");
|
||||
for (SseEmitter emitter : EMITTERS.values()) {
|
||||
try {
|
||||
emitter.complete();
|
||||
} catch (Exception e) {
|
||||
emitter.completeWithError(e);
|
||||
}
|
||||
}
|
||||
EMITTERS.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue