Merge branch 'repair'

This commit is contained in:
xyc 2025-08-01 17:26:44 +08:00
commit 3b2f80ec64
13 changed files with 224 additions and 12 deletions

View File

@ -2,8 +2,11 @@ package cn.iocoder.yudao.module.inspection.controller.admin;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.inspection.entity.InspectionInfo;
import cn.iocoder.yudao.module.inspection.service.IInspectionInfoService;
import cn.iocoder.yudao.module.payment.entity.OrderInfo;
import cn.iocoder.yudao.module.payment.service.OrderInfoService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
@ -14,6 +17,8 @@ public class InspectionOrderInfoController {
private final OrderInfoService orderInfoService;
private final IInspectionInfoService inspectionInfoService;
/**
* 修改订单信息
*
@ -24,7 +29,7 @@ public class InspectionOrderInfoController {
public CommonResult<?> cashier(@RequestBody OrderInfo orderInfo) {
if ("accounting".equals(orderInfo.getType())) {
orderInfo.setAccountingConfirmUser(SecurityFrameworkUtils.getLoginUserId());
}else {
} else {
orderInfo.setCashierConfirmUser(SecurityFrameworkUtils.getLoginUserId());
}
return CommonResult.success(orderInfoService.updateById(orderInfo));
@ -32,11 +37,18 @@ public class InspectionOrderInfoController {
/**
* 获取订单信息
*
* @param id
* @return
*/
@GetMapping("/{id}")
public CommonResult<?> get(@PathVariable Long id){
return CommonResult.success(orderInfoService.getById(id));
public CommonResult<?> get(@PathVariable Long id) {
OrderInfo byId = orderInfoService.getById(id);
InspectionInfo one = inspectionInfoService.getOne(Wrappers.<InspectionInfo>lambdaQuery()
.eq(InspectionInfo::getInspectionOrderId, id));
if (one != null) {
byId.setCarNo(one.getCarNum());
}
return CommonResult.success(byId);
}
}

View File

@ -2718,7 +2718,7 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa
Long realPayMoney = query.getRealPayMoney();
Long reduceMoney = query.getReduceMoney();
long averageMoney = realPayMoney / query.getIds().size();
long averageReduceMoney = reduceMoney / query.getIds().size();
long averageReduceMoney = reduceMoney != null ? reduceMoney / query.getIds().size() : 0L;
// 根据ids 修改工单结算
orderService.update(Wrappers.<OrderInfo>lambdaUpdate()
.in(OrderInfo::getId, orderIds)

View File

@ -0,0 +1,59 @@
package cn.iocoder.yudao.module.base.controller.admin;
import cn.hutool.core.bean.BeanUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.base.entity.RepairStaff;
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.service.permission.RoleService;
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/base/repair-staff")
@RequiredArgsConstructor
public class RepairStaffController {
private final AdminUserService userService;
private final RoleService roleService;
/**
* 获取维修员工信息
*
* @param id 用户id
* @return
*/
@GetMapping("/get")
public CommonResult<?> getRepairStaff(Long id) {
// 查询信息
AdminUserDO user = userService.getUser(id);
if (user == null) {
return CommonResult.error(400,"用户不存在");
}
// 查询对应角色
List<RoleDO> roleDOS = roleService.selectRoleByUserId(id);
if (roleDOS == null) {
roleDOS = Collections.emptyList();
}
RepairStaff repairStaff = BeanUtil.copyProperties(user, RepairStaff.class);
// 过滤出服务套餐为 weixiu
List<RoleDO> weixiuRoleDOS = roleDOS.stream()
.filter(item -> "weixiu".equals(item.getServicePackageId()))
.collect(Collectors.toList());
repairStaff.setRoles(weixiuRoleDOS);
return CommonResult.success(repairStaff);
}
}

View File

@ -0,0 +1,58 @@
package cn.iocoder.yudao.module.base.entity;
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
import lombok.Data;
import java.util.List;
@Data
public class RepairStaff {
/**
* 用户id
*/
private Long id;
/**
* 用户账号
*/
private String username;
/**
* 用户昵称
*/
private String nickname;
/**
* 备注
*/
private String remark;
/**
* 用户手机号码
*/
private String mobile;
/**
* 用户头像
*/
private String avatar;
/**
* 用户性别
**/
private String sex;
/**
* 用户openId
**/
private String openId;
/**
* 用户openId
**/
private Long tenantId;
/**
* 用户状态
*/
private Integer status;
/**
* 角色名称 多个角色以逗号隔开
*/
private String roleNames;
List<RoleDO> roles;
}

View File

@ -76,7 +76,11 @@ public class PermissionController {
@PostMapping("/assign-user-role")
@PreAuthorize("@ss.hasPermission('system:permission:assign-user-role')")
public CommonResult<Boolean> assignUserRole(@Validated @RequestBody PermissionAssignUserRoleReqVO reqVO) {
permissionService.assignUserRole(reqVO.getUserId(), reqVO.getRoleIds());
if (reqVO.getServicePackageId() != null) {
permissionService.assignUserRoleByServicePackageId(reqVO.getUserId(), reqVO.getRoleIds(), reqVO.getServicePackageId());
}else {
permissionService.assignUserRole(reqVO.getUserId(), reqVO.getRoleIds());
}
return success(true);
}

View File

@ -100,52 +100,57 @@ public class RoleController {
/**
* app端通过服务套餐id查询角色列表
*
* @param roleDO
* @return
*/
@GetMapping("/pageByQuery")
public CommonResult pageByQuery(RoleDO roleDO){
public CommonResult pageByQuery(RoleDO roleDO) {
return success(roleService.pageByQuery(roleDO));
}
/**
* 通过角色id查询角色
*
* @param roleIds
* @return
*/
@GetMapping("/selectListByRoleId")
public CommonResult selectListByRoleId(RolePageReqVO role){
public CommonResult selectListByRoleId(RolePageReqVO role) {
return success(roleService.selectListByRoleId(role));
}
/**
* 通过角色id查询角色
*
* @return
*/
@GetMapping("/selectListByRoleIdJX")
public CommonResult selectListByRoleIdJX(RolePageReqVO role){
public CommonResult selectListByRoleIdJX(RolePageReqVO role) {
return success(roleService.selectListByRoleIdJX(role));
}
/**
* 通过角色id查询角色
*
* @return
*/
@GetMapping("/selectListByRoleIdRepair")
public CommonResult selectListByRoleIdRepair(RolePageReqVO role){
public CommonResult selectListByRoleIdRepair(RolePageReqVO role) {
return success(roleService.selectListByRoleIdRepair(role));
}
/**
* 通过角色code查询用户
*
* @param code
* @return
*/
@GetMapping("/getUsersByRoleCode")
public CommonResult getUsersByRoleCode(String code){
public CommonResult getUsersByRoleCode(String code) {
//获取当前登陆人的tenanId
Long tenantId = SecurityFrameworkUtils.getLoginUser().getTenantId();
return success(roleService.selectByRoleCode(tenantId,code));
return success(roleService.selectByRoleCode(tenantId, code));
}
}

View File

@ -18,4 +18,7 @@ public class PermissionAssignUserRoleReqVO {
@Schema(description = "角色编号列表", example = "1,3,5")
private Set<Long> roleIds = Collections.emptySet(); // 兜底
@Schema(description = "服务套餐编号", example = "1")
private String servicePackageId;
}

View File

@ -21,6 +21,8 @@ public interface UserRoleMapper extends BaseMapperX<UserRoleDO> {
return selectList(UserRoleDO::getUserId, userId);
}
List<UserRoleDO> selectListByUserIdAndServicePackageId(@Param("userId")Long userId, @Param("servicePackageId")String servicePackageId);
default void deleteListByUserIdAndRoleIdIds(Long userId, Collection<Long> roleIds) {
delete(new LambdaQueryWrapper<UserRoleDO>()
.eq(UserRoleDO::getUserId, userId)

View File

@ -182,4 +182,11 @@ public interface PermissionService {
**/
List<Long> getUserIdByRoleId(Long roleId);
/**
* 赋予用户角色
* @param userId
* @param roleIds
* @param servicePackageId
*/
void assignUserRoleByServicePackageId(Long userId, Set<Long> roleIds, String servicePackageId);
}

View File

@ -390,4 +390,34 @@ public class PermissionServiceImpl implements PermissionService {
List<Long> userIds = userRoleDOS.stream().map(item -> item.getUserId()).collect(Collectors.toList());
return userIds;
}
/**
* 赋予用户角色
*
* @param userId
* @param roleIds
* @param servicePackageId
*/
@Override
public void assignUserRoleByServicePackageId(Long userId, Set<Long> roleIds, String servicePackageId) {
// 获得角色拥有角色编号
Set<Long> dbRoleIds = convertSet(userRoleMapper.selectListByUserIdAndServicePackageId(userId, servicePackageId),
UserRoleDO::getRoleId);
// 计算新增和删除的角色编号
Set<Long> roleIdList = CollUtil.emptyIfNull(roleIds);
Collection<Long> createRoleIds = CollUtil.subtract(roleIdList, dbRoleIds);
Collection<Long> deleteRoleIds = CollUtil.subtract(dbRoleIds, roleIdList);
// 执行新增和删除对于已经授权的角色不用做任何处理
if (!CollectionUtil.isEmpty(createRoleIds)) {
userRoleMapper.insertBatch(CollectionUtils.convertList(createRoleIds, roleId -> {
UserRoleDO entity = new UserRoleDO();
entity.setUserId(userId);
entity.setRoleId(roleId);
return entity;
}));
}
if (!CollectionUtil.isEmpty(deleteRoleIds)) {
userRoleMapper.deleteListByUserIdAndRoleIdIds(userId, deleteRoleIds);
}
}
}

View File

@ -172,7 +172,9 @@ public interface RoleService {
List<RoleDO> pageByQuery(RoleDO roleDO);
IPage<UserDTO> selectListByRoleId(RolePageReqVO role);
IPage<UserDTO> selectListByRoleIdJX(RolePageReqVO role);
IPage<UserDTO> selectListByRoleIdRepair(RolePageReqVO role);
/**
@ -214,4 +216,12 @@ public interface RoleService {
* @return
*/
List<UserDTO> getUserListByCodesAndTenantId(List<String> codes, Long tenantId);
/**
* 根据用户id查询角色
*
* @param userId 用户id
* @return
*/
List<RoleDO> selectRoleByUserId(Long userId);
}

View File

@ -435,6 +435,21 @@ public class RoleServiceImpl implements RoleService {
return userRoleMapper.selectByRoleCodesAndTenantId(codes, tenantId);
}
/**
* 根据用户id查询角色
*
* @param userId 用户id
* @return
*/
@Override
public List<RoleDO> selectRoleByUserId(Long userId) {
List<UserRoleDO> userRoleDOS = userRoleMapper.selectList(new LambdaQueryWrapper<UserRoleDO>()
.eq(UserRoleDO::getUserId, userId));
// 获取角色id集合
List<Long> roleIds = userRoleDOS.stream().map(item -> item.getRoleId()).collect(Collectors.toList());
return getRoleListFromCache(roleIds);
}
/**
* 获得自身的代理对象解决 AOP 生效问题
*

View File

@ -97,7 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
from system_users su
left join system_user_role sr on su.id = sr.user_id and sr.deleted = 0
left join system_role sr2 on sr.role_id = sr2.id
INNER JOIN dl_repair_worker dsc ON dsc.user_id = su.id
-- INNER JOIN dl_repair_worker dsc ON dsc.user_id = su.id
<where>
su.deleted = 0 and sr2.service_package_id = 'weixiu'
@ -210,4 +210,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
) AND sur.deleted = 0
) AND deleted = 0
</select>
<select id="selectListByUserIdAndServicePackageId"
resultType="cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO">
SELECT sur.*
FROM system_user_role sur
LEFT JOIN system_role sr ON sur.role_id = sr.id
WHERE sur.user_id = #{userId} AND sr.service_package_id = #{servicePackageId}
</select>
</mapper>