对比新文件 |
| | |
| | | package com.gk.firework.Service.ServiceImpl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.OrderItem; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.gk.firework.Config.Oauth2.OauthRole; |
| | | import com.gk.firework.Domain.DTO.JiangWaiDeadlineReqDTO; |
| | | import com.gk.firework.Domain.Exception.BusinessException; |
| | | import com.gk.firework.Domain.RoleInfo; |
| | | import com.gk.firework.Domain.UserDeadlineOperationLog; |
| | | import com.gk.firework.Domain.UserInfo; |
| | | import com.gk.firework.Domain.Utils.PageInfo; |
| | | import com.gk.firework.Domain.Utils.StringUtils; |
| | | import com.gk.firework.Domain.Vo.UserVo; |
| | | import com.gk.firework.Mapper.UserInfoMapper; |
| | | import com.gk.firework.Service.RoleService; |
| | | import com.gk.firework.Service.UserDeadlineService; |
| | | import com.gk.firework.Service.UserService; |
| | | import com.spire.xls.BubbleSizeType; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Service("UserService") |
| | | public class UserServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo> implements UserService { |
| | | |
| | | @Autowired |
| | | private UserInfoMapper userInfoMapper; |
| | | @Autowired |
| | | private RoleService roleService; |
| | | @Autowired |
| | | private UserDeadlineService userDeadlineService; |
| | | |
| | | |
| | | @Override |
| | | public UserVo selectByLoginname(String username) { |
| | | return userInfoMapper.selectByLoginname(username); |
| | | } |
| | | |
| | | @Override |
| | | public List<OauthRole> selectRoleByUser(Integer userId) { |
| | | return userInfoMapper.selectRoleByUser(userId); |
| | | } |
| | | |
| | | @Override |
| | | public void selectUserDataGrid(PageInfo pageInfo) { |
| | | Page<UserVo> page = new Page<>(pageInfo.getPageIndex(), pageInfo.getPageSize()); |
| | | List<OrderItem> orderItems = new ArrayList<>(); |
| | | OrderItem orderItem = new OrderItem(); |
| | | if (StringUtils.isNotBlank(pageInfo.getSort()) && StringUtils.isNotBlank(pageInfo.getOrder())) { |
| | | orderItem.setAsc(pageInfo.getOrder().equalsIgnoreCase("ascending")); |
| | | orderItem.setColumn(pageInfo.getSort()); |
| | | }else { |
| | | orderItem.setAsc(false); |
| | | orderItem.setColumn("createddate"); |
| | | } |
| | | orderItems.add(orderItem); |
| | | page.setOrders(orderItems); |
| | | List<UserVo> list = userInfoMapper.selectUserDataGrid(page,pageInfo.getCondition()); |
| | | for (UserVo userVo : list) { |
| | | List<RoleInfo> roleInfoList = roleService.selectRoleByUser(userVo.getId()); |
| | | userVo.setRoles(roleInfoList); |
| | | } |
| | | pageInfo.setResult(list); |
| | | pageInfo.setTotalCount(page.getTotal()); |
| | | } |
| | | |
| | | @Override |
| | | public UserInfo selectByUser(String username) { |
| | | UserInfo userInfo = new UserInfo(); |
| | | userInfo.setUsername(username); |
| | | userInfo.setIsdel((byte)0); |
| | | QueryWrapper<UserInfo> wrapper = new QueryWrapper<> (userInfo); |
| | | return userInfoMapper.selectOne(wrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<UserInfo> selectUserInfo(Long id, String username) { |
| | | return userInfoMapper.selectUserInfo(id,username); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteOneByCompanyId(Long companyId) { |
| | | userInfoMapper.deleteOneByCompanyId(companyId); |
| | | } |
| | | |
| | | @Override |
| | | public UserInfo selectOneByCompanyId(Long companyId) { |
| | | LambdaQueryWrapper<UserInfo> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(UserInfo::getCompanyid, companyId) |
| | | .eq(UserInfo::getIsdel,(byte)0); |
| | | return userInfoMapper.selectOne(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public boolean checkUserById(String userId) { |
| | | if (StringUtils.isBlank(userId)){ |
| | | return false; |
| | | } |
| | | UserInfo userInfo = userInfoMapper.selectById(userId); |
| | | return userInfo != null; |
| | | } |
| | | |
| | | @Override |
| | | public UserInfo selectSupervise(String province, String city, String district, String street, String committee) { |
| | | return userInfoMapper.selectSupervise(province, city, district, street, committee); |
| | | } |
| | | |
| | | @Override |
| | | public UserVo selectUserVoByName(String username) { |
| | | return userInfoMapper.selectUserVoByName(username); |
| | | } |
| | | |
| | | /** |
| | | * @Description: 根据企业id查找用户和终端机用户 |
| | | * @date 2021/5/13 19:03 |
| | | */ |
| | | @Override |
| | | public List<UserInfo> selectByCompanyId(Long id,int isdel) { |
| | | LambdaQueryWrapper<UserInfo> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(UserInfo::getCompanyid, id) |
| | | .eq(UserInfo::getIsdel,(byte)isdel); |
| | | return userInfoMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteById(Long id) { |
| | | LambdaUpdateWrapper<UserInfo> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.set(UserInfo::getIsdel, (byte) 1) |
| | | .eq(UserInfo::getId, id); |
| | | this.update(updateWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void recoverOneById(Long id) { |
| | | LambdaUpdateWrapper<UserInfo> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.set(UserInfo::getIsdel, (byte) 0) |
| | | .eq(UserInfo::getId, id); |
| | | this.update(updateWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public List<UserInfo> selectByCompany(String company) { |
| | | LambdaQueryWrapper<UserInfo> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(UserInfo::getCompany, company).eq(UserInfo::getIsdel,(byte)0); |
| | | return userInfoMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public void updateCodeByCompany(String company, String code) { |
| | | LambdaUpdateWrapper<UserInfo> updateWrapper = new LambdaUpdateWrapper<>(); |
| | | updateWrapper.set(UserInfo::getCode, code) |
| | | .eq(UserInfo::getCompany, company) |
| | | .eq(UserInfo::getIsdel,(byte)0); |
| | | this.update(updateWrapper); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void updateDeadline(JiangWaiDeadlineReqDTO reqDTO, UserInfo user) { |
| | | if (reqDTO.getUid() == null || reqDTO.getDeadline() == null) { |
| | | throw new BusinessException("入参为空"); |
| | | } |
| | | UserInfo userInfo = this.getById(reqDTO.getUid()); |
| | | if (userInfo == null || userInfo.getIsdel() == 1) { |
| | | throw new BusinessException("用户不存在"); |
| | | } |
| | | if (reqDTO.getDeadline().before(new Date())) { |
| | | throw new BusinessException("选择截止时间需要在今日之后"); |
| | | } |
| | | if (user.getType() == null || user.getType() != 1) { |
| | | throw new BusinessException("当前操作人无权操作"); |
| | | } |
| | | |
| | | // 判断修改企业类型 |
| | | if (userInfo.getIssale() == 1) { |
| | | throw new BusinessException("操作用户类型错误,需为非销售用户"); |
| | | } |
| | | // 数据得有companynumber 和 companyid =>确定他不是监管部门 |
| | | if (StringUtils.isBlank(userInfo.getCompanynumber()) || userInfo.getCompanyid() == null) { |
| | | throw new BusinessException("用户企业类型非法,只能修改企业信息"); |
| | | } |
| | | Date deadline = reqDTO.getDeadline(); |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.setTime(deadline); |
| | | instance.set(Calendar.HOUR_OF_DAY,23); |
| | | instance.set(Calendar.MINUTE,59); |
| | | instance.set(Calendar.SECOND,59); |
| | | |
| | | //exc |
| | | // 根据 companyid 修改 会修改 销售端和 非销售端 两条数据 |
| | | int i = userInfoMapper.updateDeadlineByCompanyId(userInfo.getCompanyid(), instance.getTime()); |
| | | if (i == 0) { |
| | | throw new BusinessException("数据未发生改变"); |
| | | } |
| | | if (i != 2) { |
| | | throw new BusinessException("数据修改失败,请联系管理员"); |
| | | } |
| | | UserDeadlineOperationLog log = new UserDeadlineOperationLog(); |
| | | log.setGmtCreate(new Date()); |
| | | log.setOperator(user.getUsername()); |
| | | log.setOperatorUid(user.getId()); |
| | | log.setToUname(userInfo.getUsername()); |
| | | log.setToUid(userInfo.getId()); |
| | | log.setVal(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(instance.getTime())); |
| | | boolean save = userDeadlineService.save(log); |
| | | if (!save) { |
| | | throw new BusinessException("记录保存失败,请联系管理员"); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void updateDeadline2NullByComapnyId(Long companyid) { |
| | | if (companyid == null) { |
| | | throw new BusinessException("系统入参为空"); |
| | | } |
| | | userInfoMapper.updateDeadline2NullByComapnyId(companyid); |
| | | } |
| | | |
| | | |
| | | } |