|
@@ -40,12 +40,15 @@ import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.UUID;
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
+import java.util.concurrent.Executors;
|
|
|
|
|
|
import static org.jeecg.common.constant.CommonConstant.SC_INTERNAL_SERVER_ERROR_500;
|
|
|
|
|
|
@Service
|
|
|
@Log4j2
|
|
|
public class UserServiceImpl implements IUserService {
|
|
|
+ private static final ExecutorService executor = Executors.newFixedThreadPool(4);
|
|
|
@Resource
|
|
|
private WxMaService wxMaService;
|
|
|
@Resource
|
|
@@ -81,44 +84,57 @@ public class UserServiceImpl implements IUserService {
|
|
|
if (null == user) {
|
|
|
|
|
|
// 用户不存在则创建
|
|
|
- user = new SysUser()
|
|
|
- .setOpenid(openid)
|
|
|
- .setPassword(openid)
|
|
|
- .setStatus(1)
|
|
|
- .setDelFlag(0)
|
|
|
- .setUserIdentity(3)
|
|
|
- .setSalt(oConvertUtils.randomGen(8))
|
|
|
- .setCreateBy("admin")
|
|
|
- .setRealname("微信用户")
|
|
|
- .setUsername("微信用户_" + UUID.randomUUID());
|
|
|
+ user = new SysUser()
|
|
|
+ .setOpenid(openid)
|
|
|
+ .setPassword(openid)
|
|
|
+ .setStatus(1)
|
|
|
+ .setDelFlag(0)
|
|
|
+ .setUserIdentity(3)
|
|
|
+ .setSalt(oConvertUtils.randomGen(8))
|
|
|
+ .setCreateBy("admin")
|
|
|
+ .setRealname("微信用户")
|
|
|
+ .setUsername("微信用户_" + UUID.randomUUID());
|
|
|
boolean result = sysUserMapper.insert(user) > 0;
|
|
|
- if (!result) {
|
|
|
- throw new JeecgBootException("登录失败", SC_INTERNAL_SERVER_ERROR_500);
|
|
|
+ if (!result) {
|
|
|
+ throw new JeecgBootException("登录失败", SC_INTERNAL_SERVER_ERROR_500);
|
|
|
}
|
|
|
familyMembersMapper.insert(new FamilyMembers().setDelFlag(0).setUserId(user.getId()).setUserType(0).setRealNameStatus(0));
|
|
|
- int dateAsInt = Integer.parseInt(
|
|
|
- LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))
|
|
|
- );
|
|
|
- //查询当天是否有平台统计信息
|
|
|
- StatisticsInfo statisticsInfo= statisticsInfoMapper.findByOrgCode("A01",dateAsInt);
|
|
|
- SysDepart byOrgCode = sysDepartMapper.findByOrgCode("A01");
|
|
|
- if (byOrgCode==null){
|
|
|
- throw new JeecgBootException("登录失败,平台部门不存在", SC_INTERNAL_SERVER_ERROR_500);
|
|
|
- }
|
|
|
- if (statisticsInfo==null){
|
|
|
- statisticsInfo=new StatisticsInfo();
|
|
|
- statisticsInfo.setDateDaily(dateAsInt);
|
|
|
- statisticsInfo.setOrgCode(byOrgCode.getOrgCode());
|
|
|
- statisticsInfo.setDeptId(byOrgCode.getId());
|
|
|
- statisticsInfo.setAddNumber(1);
|
|
|
- statisticsInfo.setUpdateTime(new Date());
|
|
|
- statisticsInfo.setCreateTime(new Date());
|
|
|
- }else {
|
|
|
- statisticsInfo.setAddNumber(statisticsInfo.getAddNumber()+1);
|
|
|
- statisticsInfo.setUpdateTime(new Date());
|
|
|
- }
|
|
|
- statisticsInfoMapper.insert(statisticsInfo);
|
|
|
+ executor.submit(() -> {
|
|
|
+ try {
|
|
|
+ int dateAsInt = Integer.parseInt(
|
|
|
+ LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))
|
|
|
+ );
|
|
|
+ //查询当天是否有平台统计信息
|
|
|
+ StatisticsInfo statisticsInfo = statisticsInfoMapper.findByOrgCode("A01", dateAsInt);
|
|
|
+ SysDepart byOrgCode = sysDepartMapper.findByOrgCode("A01");
|
|
|
+ if (byOrgCode == null) {
|
|
|
+ throw new JeecgBootException("登录失败,平台部门不存在", SC_INTERNAL_SERVER_ERROR_500);
|
|
|
+ }
|
|
|
+ if (statisticsInfo == null) {
|
|
|
+ statisticsInfo = new StatisticsInfo();
|
|
|
+ statisticsInfo.setDateDaily(dateAsInt);
|
|
|
+ statisticsInfo.setOrgCode(byOrgCode.getOrgCode());
|
|
|
+ statisticsInfo.setDeptId(byOrgCode.getId());
|
|
|
+ statisticsInfo.setAddNumber(1);
|
|
|
+ statisticsInfo.setUpdateTime(new Date());
|
|
|
+ statisticsInfo.setCreateTime(new Date());
|
|
|
+ statisticsInfoMapper.insert(statisticsInfo);
|
|
|
+ } else {
|
|
|
+ statisticsInfo.setAddNumber(statisticsInfo.getAddNumber() + 1);
|
|
|
+ statisticsInfo.setUpdateTime(new Date());
|
|
|
+ statisticsInfoMapper.updateById(statisticsInfo);
|
|
|
+ }
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ log.error(e);
|
|
|
+ } catch (JeecgBootException e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ log.error(e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
return generateLoginUserVO(user);
|
|
|
} catch (WxErrorException e) {
|
|
|
log.error("微信登录失败: {}", e.getMessage());
|
|
@@ -132,7 +148,7 @@ public class UserServiceImpl implements IUserService {
|
|
|
public List<MsgVO> getMsg() {
|
|
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
List<MsgVO> msgVOList = new ArrayList<>();
|
|
|
- if(null != user){
|
|
|
+ if (null != user) {
|
|
|
sysAnnouncementSendMapper.selectList(Wrappers.<SysAnnouncementSend>lambdaQuery()
|
|
|
.eq(SysAnnouncementSend::getUserId, user.getId())).forEach(sysAnnouncementSend -> {
|
|
|
SysAnnouncement sysAnnouncement = sysAnnouncementMapper.selectById(sysAnnouncementSend.getAnntId());
|
|
@@ -161,12 +177,12 @@ public class UserServiceImpl implements IUserService {
|
|
|
@Transactional
|
|
|
public boolean updateUserInfo(String nickName, String avatarUrl) {
|
|
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
- if(null != nickName && !nickName.isEmpty()){
|
|
|
- sysUserMapper.update(null,Wrappers.<SysUser>lambdaUpdate()
|
|
|
+ if (null != nickName && !nickName.isEmpty()) {
|
|
|
+ sysUserMapper.update(null, Wrappers.<SysUser>lambdaUpdate()
|
|
|
.eq(SysUser::getId, user.getId())
|
|
|
.set(SysUser::getRealname, nickName));
|
|
|
- }else if(null != avatarUrl && !avatarUrl.isEmpty()){
|
|
|
- sysUserMapper.update(null,Wrappers.<SysUser>lambdaUpdate()
|
|
|
+ } else if (null != avatarUrl && !avatarUrl.isEmpty()) {
|
|
|
+ sysUserMapper.update(null, Wrappers.<SysUser>lambdaUpdate()
|
|
|
.eq(SysUser::getId, user.getId())
|
|
|
.set(SysUser::getAvatar, avatarUrl));
|
|
|
}
|
|
@@ -196,7 +212,7 @@ public class UserServiceImpl implements IUserService {
|
|
|
subject.login(jwtToken); // 触发 Shiro 登录流程
|
|
|
// 确保 LoginUser 可被后续获取
|
|
|
LoginUser loginUser = new LoginUser();
|
|
|
- BeanUtils.copyProperties(user,loginUser);
|
|
|
+ BeanUtils.copyProperties(user, loginUser);
|
|
|
return new LoginUserVO()
|
|
|
.setToken(token)
|
|
|
.setId(user.getId())
|