This commit is contained in:
xyc 2025-05-10 17:50:41 +08:00
parent 5caea1c148
commit a5015bddbb
18 changed files with 283 additions and 53 deletions

View File

@ -276,7 +276,7 @@ public class InspectionInfoController extends BaseController {
*/
@GetMapping("isExamine")
public CommonResult isExamine() {
return success(inspectionInfoService.isExamine());
return success(inspectionInfoService.isExamine("jcsfdl"));
}
/**
@ -389,12 +389,24 @@ public class InspectionInfoController extends BaseController {
/**
* 修改异常工单
*
* @param inspectionWorkNode
* @return
*/
@PostMapping("/updateException")
public CommonResult<?> updateException(@RequestBody InspectionWorkNode inspectionWorkNode){
public CommonResult<?> updateException(@RequestBody InspectionWorkNode inspectionWorkNode) {
inspectionWorkNodeService.updateException(inspectionWorkNode.getInspectionInfoId(), inspectionWorkNode.getIdList());
return success("操作成功");
}
/**
* 员工 引车接单
*
* @return
*/
@PostMapping("/leadCar")
public CommonResult<?> leadCar(@RequestBody InspectionInfo inspectionInfo) {
inspectionInfoService.leadCar(inspectionInfo);
return success("操作成功");
}
}

View File

@ -179,6 +179,19 @@ public class InspectionStaffController extends BaseController {
return success(inspectionStaffService.addFolder(userId));
}
/**
* 获取已完成项目
* @param userId 用户id
* @return
*/
@GetMapping("/getFinishProjectByUserId")
public CommonResult<?> getFinishProjectByUserId(@RequestParam("userId") Long userId,
@RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
Page<Map<String, Object>> page = new Page<>(pageNo, pageSize);
return success(inspectionStaffService.getFinishProjectByUserId(page, userId));
}
/**
* 校验信息
*

View File

@ -65,8 +65,10 @@ public class InspectionInfo extends TenantBaseDO
//是否重审
private String isRetrial;
private String remark;
/** 检测次数 */
private Integer infoCount;
/** 复检次数 */
private Integer recheckCount;
/** 重检次数 */
private Integer reinspectCount;
/** 0进行中1已结束 */
@Excel(name = "0进行中1已结束")

View File

@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.inspection.entity.InspectionWorkNode;
import cn.iocoder.yudao.module.inspection.vo.StaffProjectCountVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -48,4 +49,6 @@ public interface InspectionWorkNodeMapper extends BaseMapper<InspectionWorkNode>
* @return
*/
List<Map<String, Object>> selectExceptionNodesByInspectionIds(@Param("ids") List<Long> idList);
IPage<Map<String, Object>> selectStaffProjectByUserId(@Param("page")Page<Map<String, Object>> page, @Param("userId") Long userId);
}

View File

@ -34,4 +34,7 @@ public class OrderTableQuery {
/** 车龄 */
private Integer carYear;
/** 检测类型*/
private String skuName;
}

View File

@ -111,7 +111,7 @@ public interface IInspectionInfoService extends IService<InspectionInfo>
* 判断app当前检测人是否有审核权限
* @return
*/
Boolean isExamine();
Boolean isExamine(String code);
/**
* 获取某个工单针对当前操作用户某个状态的项目们
@ -153,4 +153,10 @@ public interface IInspectionInfoService extends IService<InspectionInfo>
* @param inspectionWorkNode
*/
Boolean meetCarPhoto(InspectionWorkNode inspectionWorkNode);
/**
* 引车
* @param inspectionInfo
*/
void leadCar(InspectionInfo inspectionInfo);
}

View File

@ -75,5 +75,12 @@ public interface InspectionStaffService extends IService<InspectionStaff> {
* @return 文件夹id
*/
Long addFolder(Long userId);
/**
* 获取已完成项目
* @param userId
* @return
*/
IPage<Map<String, Object>> getFinishProjectByUserId(Page<Map<String, Object>> page, Long userId);
}

View File

@ -47,6 +47,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
@ -1576,7 +1577,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
res.setGoodsPrice(order.getGoodsPrice());
res.setGoodsName(sku.getSkuName());
res.setIsOnline(order.getIsOnline());
res.setInfoCount(info.getInfoCount());
res.setRecheckCount(info.getRecheckCount());
res.setReinspectCount(info.getReinspectCount());
res.setIsRetrial(info.getIsRetrial());
res.setIsPass(info.getIsPass());
res.setRemark(info.getRemark());
@ -1924,6 +1926,10 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
startTime = startTime + " 00:00:00";
endTime = endTime + " 23:59:59";
Map<String, Integer> map = baseMapper.staticsTable2(partnerId, startTime, endTime);
// 查询未完成 所有时间
Map<String, Integer> stringIntegerMap = baseMapper.staticsTable2(partnerId, null, null);
map.put("allJxzNum", stringIntegerMap.get("jxzNum"));
return map;
}
@ -2215,6 +2221,25 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
*/
@Override
public List<Map<String, Object>> getStaffCount(DlInspectionProject dlInspectionProject) {
return inspectionWorkNodeService.getStaffCount(dlInspectionProject);
List<Map<String, Object>> staffCount = inspectionWorkNodeService.getStaffCount(dlInspectionProject);
// 根据userId查询检测工单表 接车人
List<InspectionInfo> list = inspectionInfoService.list(Wrappers.<InspectionInfo>lambdaQuery()
.eq(InspectionInfo::getIsMeetCar, 1));
// 统计每个 meetManId 的数量避免 null key 异常
Map<Long, Long> meetManIdCountMap = list.stream()
.filter(info -> info.getMeetManId() != null) // 过滤 null
.collect(Collectors.groupingBy(InspectionInfo::getMeetManId, Collectors.counting()));
for (Map<String, Object> stringObjectMap : staffCount) {
Long userId = (Long) stringObjectMap.get("userId");
List<Map<String, Object>> children = (List<Map<String, Object>>) stringObjectMap.get("children");
stringObjectMap.put("meetCarCount", meetManIdCountMap.get(userId));
HashMap<String, Object> objectObjectHashMap = new HashMap<>();
objectObjectHashMap.put("count", meetManIdCountMap.get(userId) == null ? 0 : meetManIdCountMap.get(userId));
objectObjectHashMap.put("projectName", "接车");
children.add(objectObjectHashMap);
}
return staffCount;
}
}

View File

@ -656,7 +656,7 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
* @return
*/
@Override
public Boolean isExamine() {
public Boolean isExamine(String code) {
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
//获取当前登陆人的所有角色
List<UserRoleDO> userRoles = roleService.getByUserId(loginUser.getId());
@ -666,7 +666,7 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
//判断当前角色集合中的code是否包含jcyszz
if (CollectionUtil.isNotEmpty(roleList)) {
List<RoleDO> filteredRoleList = roleList.stream()
.filter(role -> role.getCode().contains("jcsfdl"))
.filter(role -> role.getCode().contains(code))
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(filteredRoleList)) {
return true;
@ -829,9 +829,9 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
Map<String, Long> result = new ConcurrentHashMap<>(); // 线程安全
// 这里 `5` 而不是 `6`因为 i `0` 开始
CompletableFuture<Void>[] futures = new CompletableFuture[8];
CompletableFuture<Void>[] futures = new CompletableFuture[9];
for (int i = 0; i < 8; i++) { // 改为 `0~4`
for (int i = 0; i < 9; i++) { // 改为 `0~4`
final String status = String.valueOf(i + 1);
// 深拷贝对象防止多线程修改冲突
@ -906,4 +906,18 @@ public class InspectionInfoServiceImpl extends ServiceImpl<InspectionInfoMapper,
return true;
}
/**
* 引车
*
* @param inspectionInfo
*/
@Override
public void leadCar(InspectionInfo inspectionInfo) {
// 获取当前登陆人
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
inspectionInfo.setLeadManId(loginUser.getId());
baseMapper.updateById(inspectionInfo);
}
}

View File

@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.inspection.entity.InspectionFile;
import cn.iocoder.yudao.module.inspection.entity.InspectionPickCar;
import cn.iocoder.yudao.module.inspection.entity.InspectionStaff;
import cn.iocoder.yudao.module.inspection.mapper.InspectionStaffMapper;
import cn.iocoder.yudao.module.inspection.mapper.InspectionWorkNodeMapper;
import cn.iocoder.yudao.module.inspection.query.InspectionStaffQuery;
import cn.iocoder.yudao.module.inspection.service.IInspectionFileService;
import cn.iocoder.yudao.module.inspection.service.InspectionStaffService;
@ -64,6 +65,9 @@ public class InspectionStaffServiceImpl extends ServiceImpl<InspectionStaffMappe
@Autowired
private IInspectionFileService inspectionFileService;
@Autowired
private InspectionWorkNodeMapper inspectionWorkNodeMapper;
/**
* 获取检测员工分页
*
@ -242,12 +246,23 @@ public class InspectionStaffServiceImpl extends ServiceImpl<InspectionStaffMappe
this.update(Wrappers.<InspectionStaff>lambdaUpdate().eq(InspectionStaff::getUserId, userId).set(InspectionStaff::getFolderId, folderId));
}
return folderId;
}else {
} else {
log.error("用户不存在");
return null;
}
}
/**
* 获取已完成项目
*
* @param userId
* @return
*/
@Override
public IPage<Map<String, Object>> getFinishProjectByUserId(Page<Map<String, Object>> page, Long userId) {
return inspectionWorkNodeMapper.selectStaffProjectByUserId(page,userId);
}
/**
* 保存检测员工
*

View File

@ -373,10 +373,10 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
info.setIsRetrial("1");
info.setIsPass("0");
// 设置检测次数加一
if (ObjectUtil.isNotEmpty(info.getInfoCount())) {
info.setInfoCount(info.getInfoCount() + 1);
if (ObjectUtil.isNotEmpty(info.getReinspectCount())) {
info.setReinspectCount(info.getReinspectCount() + 1);
} else {
info.setInfoCount(2);
info.setReinspectCount(1);
}
//更新工单表
inspectionInfoService.updateById(info);
@ -574,7 +574,7 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
}
/**
*
*
*
* @param inspectionWorkNode
*/
@ -595,7 +595,14 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod
.set("type", null)
.in("id", workNodeIds));
//跟新工单表
// 复检次数加一
if (ObjectUtil.isNotNull(info.getRecheckCount())) {
info.setRecheckCount(info.getRecheckCount() + 1);
} else {
info.setRecheckCount(1);
}
//更新工单表
inspectionInfoService.updateById(info);
//获取重审的节点的roleID

View File

@ -34,7 +34,10 @@ public class InspectionInfoVo {
private String remark;
private String buyUserName;
private String buyUserPhone;
private Integer infoCount;
/** 复检次数 */
private Integer recheckCount;
/** 重检次数 */
private Integer reinspectCount;
@TableField(exist = false)
private String buyName;

View File

@ -283,4 +283,39 @@
)
ORDER BY w.order_num
</select>
<select id="selectStaffProjectByUserId" resultType="java.util.Map">
SELECT
ii.id AS inspectionInfoId,
ii.user_id AS userId,
ii.user_name AS userName,
ii.buy_name AS buyName,
ii.buy_phone AS buyPhone,
ii.car_num AS carNum,
ii.car_model AS carModel,
ii.car_status AS carStatus,
ii.start_time AS startTime,
ii.end_time AS endTime,
ii.unit_name AS unitName,
ii.partner_id,
ii.work_id AS workId,
ii.worker_name AS workerName,
ii.worker_phone AS workerPhone,
ii.worker_avatar AS workerAvatar,
CASE
WHEN ii.is_pass = '0' THEN '不通过'
WHEN ii.is_pass = '1' THEN '通过'
WHEN ii.is_pass IS NULL THEN '进行中'
ELSE '未知'
END AS status,
GROUP_CONCAT(ip.project_name ORDER BY iwn.order_num SEPARATOR ',') AS projectName
FROM inspection_work_node iwn
LEFT JOIN inspection_info ii ON iwn.inspection_info_id = ii.id
LEFT JOIN inspection_project ip ON ip.id = iwn.project_id
WHERE
iwn.deal_user_id = #{userId}
AND iwn.status = '2'
AND iwn.deleted = b'0'
GROUP BY ii.id
ORDER BY ii.start_time DESC;
</select>
</mapper>

View File

@ -472,19 +472,26 @@ FROM
and ii.create_time BETWEEN #{startTime} and #{endTime}
</select>
<select id="staticsTable2" resultType="java.util.Map">
SELECT
count(1) allNum,
IFNULL(SUM(ii.status='0'),0) jxzNum,
IFNULL(SUM(ii.status='1'),0) ywcNum,
IFNULL(SUM(oi.sku_name LIKE '%年审%'),0) nsNum,
IFNULL(SUM(oi.sku_name LIKE '%上户%'),0) shNum,
IFNULL(SUM(oi.sku_name LIKE '%非定检%'),0) fdjNum,
IFNULL(SUM(oi.sku_name LIKE '%双燃料%'),0) srlNum
FROM
inspection_info ii
LEFT JOIN order_info oi on oi.id = ii.inspection_order_id
WHERE ii.partner_id =#{partnerId} and ii.deleted = 0 and oi.deleted = 0
and ii.create_time BETWEEN #{startTime} and #{endTime}
SELECT
count(1) allNum,
IFNULL(SUM(ii.status='0'),0) jxzNum,
IFNULL(SUM(ii.status='1'),0) ywcNum,
IFNULL(SUM(oi.sku_name LIKE '%年审%'),0) nsNum,
IFNULL(SUM(oi.sku_name LIKE '%上户%'),0) shNum,
IFNULL(SUM(oi.sku_name LIKE '%非定检%'),0) fdjNum,
IFNULL(SUM(oi.sku_name LIKE '%双燃料%'),0) srlNum,
IFNULL(SUM(ii.recheck_count),0) recheckNum,
IFNULL(SUM(ii.reinspect_count),0) reinspectNum
FROM
inspection_info ii
LEFT JOIN order_info oi on oi.id = ii.inspection_order_id
<where>
ii.partner_id =#{partnerId} and ii.deleted = 0 and oi.deleted = 0
<if test="startTime != null and endTime != null">
and ii.create_time BETWEEN #{startTime} and #{endTime}
</if>
</where>
</select>
<select id="newStaticsTable2" resultType="java.util.Map">
SELECT
@ -668,6 +675,9 @@ FROM
<if test="query.payType!=null and query.payType!=''">
AND oi.pay_type = #{query.payType}
</if>
<if test="query.skuName!=null and query.skuName!=''">
AND oi.sku_name LIKE concat('%',#{query.skuName},'%')
</if>
<if test="query.customerSource!=null and query.customerSource!=''">
AND ii.customer_source = #{query.customerSource}
</if>

View File

@ -369,6 +369,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND ii.status != '1'
ORDER BY iwn.update_time DESC
</if>
<!-- 新增lead_man_id 为空 -->
<if test="inspectionInfo.status == 9">
AND ii.lead_man_id IS NULL
AND ii.status = '0'
ORDER BY ii.update_time DESC
</if>
</where>
) AS subquery
WHERE rn = 1;
@ -555,6 +561,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND iwn.type = '0'
AND ii.status != '1'
</if>
<!-- 新增lead_man_id 为空 -->
<if test="inspectionInfo.status == 9">
AND ii.lead_man_id IS NULL
AND ii.status = '0'
</if>
</where>
</if>
<if test="inspectionInfo.status == 6">

View File

@ -37,7 +37,7 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
@Tag(name = "管理后台 - 用户")
@RestController
@RequestMapping("/system/user")
@RequestMapping("/system/user")
@Validated
public class UserController {
@ -180,7 +180,7 @@ public class UserController {
/**
* 通过角色id查询用户列表
* @param roleId
* @param roleId 角色id
* @return
*/
@GetMapping("/selectByRoleId")
@ -188,4 +188,14 @@ public class UserController {
return success(userService.selectByRoleId(roleId));
}
/**
* 判断当前登录用户是否拥有某个角色
* @param roleCode 角色code
* @return
*/
@GetMapping("/ifLoginUserHasRoleByCode")
public CommonResult<?> ifLoginUserHasRoleByCode(String roleCode){
return success(userService.ifLoginUserHasRoleByCode(roleCode));
}
}

View File

@ -48,16 +48,17 @@ public interface AdminUserService extends IService<AdminUserDO> {
/**
* 微信小程序端修改用户个人信息
*
* @param userInfoVO 用户对象
* @author vinjor-M
* @date 20:11 2024/10/11
* @param userInfoVO 用户对象
**/
**/
void updateCusInfo(UserInfoVO userInfoVO);
/**
* 更新用户的最后登陆信息
*
* @param id 用户编号
* @param id 用户编号
* @param loginIp 登陆 IP
*/
void updateUserLogin(Long id, String loginIp);
@ -65,7 +66,7 @@ public interface AdminUserService extends IService<AdminUserDO> {
/**
* 修改用户个人信息
*
* @param id 用户编号
* @param id 用户编号
* @param reqVO 用户个人信息
*/
void updateUserProfile(Long id, @Valid UserProfileUpdateReqVO reqVO);
@ -73,7 +74,7 @@ public interface AdminUserService extends IService<AdminUserDO> {
/**
* 修改用户个人密码
*
* @param id 用户编号
* @param id 用户编号
* @param reqVO 更新用户个人密码
*/
void updateUserPassword(Long id, @Valid UserProfileUpdatePasswordReqVO reqVO);
@ -96,12 +97,13 @@ public interface AdminUserService extends IService<AdminUserDO> {
/**
* 修改用户所属部门
*
* @param id 用户id
* @param deptId H部门id
* @author vinjor-M
* @date 16:34 2024/8/2
* @param id 用户id
* @param deptId H部门id
**/
void updateUserDept(Long id,Long deptId);
**/
void updateUserDept(Long id, Long deptId);
/**
* 修改状态
@ -125,13 +127,15 @@ public interface AdminUserService extends IService<AdminUserDO> {
* @return 用户对象信息
*/
AdminUserDO getUserByUsername(String username);
/**
* 通过用户名查询用户
*
* @param username 用户名
* @return 用户对象信息
*/
AdminUserDO getUserByUsername(String username,Long tenantId);
AdminUserDO getUserByUsername(String username, Long tenantId);
/**
* 通过用户名查询用户---不带租户ID
*
@ -147,6 +151,7 @@ public interface AdminUserService extends IService<AdminUserDO> {
* @return 用户对象信息
*/
AdminUserDO getUserByMobile(String mobile);
/**
* 通过手机号获取用户(不带租户id)
*
@ -245,14 +250,16 @@ public interface AdminUserService extends IService<AdminUserDO> {
/**
* 判断密码是否匹配
*
* @param rawPassword 未加密的密码
* @param rawPassword 未加密的密码
* @param encodedPassword 加密后的密码
* @return 是否匹配
*/
boolean isPasswordMatch(String rawPassword, String encodedPassword);
List<AdminUserDO> getUsersByRoleRescue(String roleCode, String searchValue, List<String> deptIds);
IPage<AdminUserDO> getUsersByRoleRescueTow(Page<AdminUserDO> page,String roleCode, String searchValue, List<String> deptIds);
List<AdminUserDO> getUsersByRoleRescue(String roleCode, String searchValue, List<String> deptIds);
IPage<AdminUserDO> getUsersByRoleRescueTow(Page<AdminUserDO> page, String roleCode, String searchValue, List<String> deptIds);
Integer getStudentNumberByUserId(Long jlId);
List<String> getStudentNumber(Long id);
@ -263,12 +270,14 @@ public interface AdminUserService extends IService<AdminUserDO> {
/**
* 根据openid和租户id查询用户
*
* @param openId 微信id
* @param tenantId 租户id可能为null
* @author vinjor-M
* @date 11:29 2024/9/24
* @param openId 微信id
* @param tenantId 租户id可能为null
**/
AdminUserDO selectUserByOpenId(String openId,String tenantId);
AdminUserDO selectUserByOpenId(String openId, String tenantId);
/**
* 设置用户openId
*
@ -277,19 +286,21 @@ public interface AdminUserService extends IService<AdminUserDO> {
* @author vinjor-M
* @date 15:45 2024/9/24
**/
void setOpenId(Long userId,String openId);
void setOpenId(Long userId, String openId);
/**
* 根据手机号查询所有用户--员工
* @author vinjor-M
* @date 14:43 2024/10/16
*
* @param phone 手机号
* @return java.util.List<cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO>
**/
* @author vinjor-M
* @date 14:43 2024/10/16
**/
List<AdminUserDO> selectListByPhoneStaff(String phone);
/**
* 根据角色id查询用户
*
* @param roleId
* @return
*/
@ -297,8 +308,17 @@ public interface AdminUserService extends IService<AdminUserDO> {
/**
* 查询用户信息(排除掉租户)
*
* @param reqVO
* @return
*/
Map<String, Object> queryUserIgnoreTenant(AuthLoginReqVO reqVO);
/**
* 判断当前登录用户是否拥有某个角色
*
* @param roleCode 角色编码
* @return
*/
Boolean ifLoginUserHasRoleByCode(String roleCode);
}

View File

@ -26,12 +26,15 @@ import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSaveReqV
import cn.iocoder.yudao.module.system.controller.app.user.UserInfoVO;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.UserPostDO;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.dal.mysql.dept.UserPostMapper;
import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper;
import cn.iocoder.yudao.module.system.service.dept.DeptService;
import cn.iocoder.yudao.module.system.service.dept.PostService;
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
import cn.iocoder.yudao.module.system.service.permission.RoleService;
import cn.iocoder.yudao.module.system.service.tenant.TenantService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -43,6 +46,7 @@ import com.mzt.logapi.service.impl.DiffParseFunction;
import com.mzt.logapi.starter.annotation.LogRecord;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
@ -52,6 +56,7 @@ import javax.annotation.Resource;
import java.io.InputStream;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_STAFF;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
@ -94,6 +99,9 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
@Resource
private ConfigApi configApi;
@Autowired
private RoleService roleService;
@Override
@Transactional(rollbackFor = Exception.class)
@LogRecord(type = SYSTEM_USER_TYPE, subType = SYSTEM_USER_CREATE_SUB_TYPE, bizNo = "{{#user.id}}",
@ -662,6 +670,32 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser
return baseMapper.queryUserIgnoreTenant(reqVO);
}
/**
* 判断当前登录用户是否拥有某个角色
*
* @param roleCode 角色编码
* @return
*/
@Override
public Boolean ifLoginUserHasRoleByCode(String roleCode) {
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
//获取当前登陆人的所有角色
List<UserRoleDO> userRoles = roleService.getByUserId(loginUser.getId());
List<Long> userRoleIds = userRoles.stream().map(UserRoleDO::getRoleId).collect(Collectors.toList());
List<RoleDO> roleList = roleService.getRoleList(userRoleIds);
//判断当前角色集合中的code是否包含jcyszz
if (CollectionUtil.isNotEmpty(roleList)) {
List<RoleDO> filteredRoleList = roleList.stream()
.filter(role -> role.getCode().contains(roleCode))
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(filteredRoleList)) {
return true;
}
}
return false;
}
/**
* 对密码进行加密
*