This commit is contained in:
xiaofajia 2024-10-17 17:28:53 +08:00
commit 1f4a63a296
14 changed files with 234 additions and 74 deletions

View File

@ -13,6 +13,8 @@ import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.core.text.Convert; import cn.iocoder.yudao.module.core.text.Convert;
import cn.iocoder.yudao.module.core.text.ServletUtils; import cn.iocoder.yudao.module.core.text.ServletUtils;
import cn.iocoder.yudao.module.label.vo.LabelRespVO; import cn.iocoder.yudao.module.label.vo.LabelRespVO;
import cn.iocoder.yudao.module.partner.entity.PartnerCustomerInfo;
import cn.iocoder.yudao.module.partner.service.IPartnerCustomerInfoService;
import cn.iocoder.yudao.module.partner.service.IPartnerWorkerService; import cn.iocoder.yudao.module.partner.service.IPartnerWorkerService;
import cn.iocoder.yudao.module.payment.service.OrderInfoService; import cn.iocoder.yudao.module.payment.service.OrderInfoService;
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO; import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
@ -57,6 +59,8 @@ public class InspectionMallPartnersController extends BaseController {
private PermissionService permissionService; private PermissionService permissionService;
@Autowired @Autowired
private RoleService roleService; private RoleService roleService;
@Autowired
private IPartnerCustomerInfoService partnerCustomerInfoService;
/** /**
* 查询合作商管理列表 * 查询合作商管理列表
@ -128,6 +132,8 @@ public class InspectionMallPartnersController extends BaseController {
return CommonResult.success(list); return CommonResult.success(list);
} }
@GetMapping("/delWorkOrder") @GetMapping("/delWorkOrder")
public CommonResult<IPage<?>> delWorkOrder(String carNum,String goodsTitle,String customerSource,String payType,String startTime,Long roleId,String endTime,Integer pageSize,Integer pageNum) public CommonResult<IPage<?>> delWorkOrder(String carNum,String goodsTitle,String customerSource,String payType,String startTime,Long roleId,String endTime,Integer pageSize,Integer pageNum)
{ {

View File

@ -2,14 +2,9 @@ package cn.iocoder.yudao.module.partner.controller;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.core.controller.BaseController; import cn.iocoder.yudao.module.core.controller.BaseController;
import cn.iocoder.yudao.module.core.page.TableDataInfo;
import cn.iocoder.yudao.module.core.text.Convert;
import cn.iocoder.yudao.module.core.text.ServletUtils;
import cn.iocoder.yudao.module.inspection.service.AppInspectionPartnerService; import cn.iocoder.yudao.module.inspection.service.AppInspectionPartnerService;
import cn.iocoder.yudao.module.label.vo.LabelRespVO;
import cn.iocoder.yudao.module.partner.entity.PartnerCustomerInfo; import cn.iocoder.yudao.module.partner.entity.PartnerCustomerInfo;
import cn.iocoder.yudao.module.partner.service.IPartnerCustomerInfoService; import cn.iocoder.yudao.module.partner.service.IPartnerCustomerInfoService;
import cn.iocoder.yudao.module.shop.entity.ShopMallPartners;
import cn.iocoder.yudao.util.ExcelUtil; import cn.iocoder.yudao.util.ExcelUtil;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -18,8 +13,6 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
/** /**
* 客户信息Controller * 客户信息Controller
* *
@ -51,6 +44,7 @@ public class PartnerCustomerInfoController extends BaseController
// return getDataTable(list); // return getDataTable(list);
} }
/** /**
* 导出客户信息列表 * 导出客户信息列表
*/ */

View File

@ -43,6 +43,7 @@ public class PartnerCustomerInfo extends TenantBaseDO
@Excel(name = "性别") @Excel(name = "性别")
private String sex; private String sex;
/** 年龄 */ /** 年龄 */
@Excel(name = "年龄") @Excel(name = "年龄")
private Integer userAge; private Integer userAge;
@ -57,5 +58,7 @@ public class PartnerCustomerInfo extends TenantBaseDO
private String roleCode; private String roleCode;
@TableField(exist = false) @TableField(exist = false)
private String roleName; private String roleName;
@TableField(exist = false)
private int orderCount;
} }

View File

@ -1,8 +1,6 @@
package cn.iocoder.yudao.module.partner.mapper; package cn.iocoder.yudao.module.partner.mapper;
import cn.iocoder.yudao.module.label.vo.LabelPageReqVO;
import cn.iocoder.yudao.module.label.vo.LabelRespVO;
import cn.iocoder.yudao.module.partner.entity.PartnerCustomerInfo; import cn.iocoder.yudao.module.partner.entity.PartnerCustomerInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
@ -56,4 +54,6 @@ public interface PartnerCustomerInfoMapper extends BaseMapper<PartnerCustomerInf
* @return 结果 * @return 结果
*/ */
public int deletePartnerCustomerInfoByIds(Long[] ids); public int deletePartnerCustomerInfoByIds(Long[] ids);
} }

View File

@ -1,7 +1,5 @@
package cn.iocoder.yudao.module.partner.service; package cn.iocoder.yudao.module.partner.service;
import cn.iocoder.yudao.module.label.vo.LabelPageReqVO;
import cn.iocoder.yudao.module.label.vo.LabelRespVO;
import cn.iocoder.yudao.module.partner.entity.PartnerCustomerInfo; import cn.iocoder.yudao.module.partner.entity.PartnerCustomerInfo;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -60,4 +58,7 @@ public interface IPartnerCustomerInfoService extends IService<PartnerCustomerInf
*/ */
public int deletePartnerCustomerInfoByIds(Long[] ids); public int deletePartnerCustomerInfoByIds(Long[] ids);
} }

View File

@ -53,6 +53,8 @@ public class PartnerCustomerInfoServiceImpl extends ServiceImpl<PartnerCustomerI
private PermissionService permissionService; private PermissionService permissionService;
@Resource @Resource
private PartnerCustomerInfoMapper customerInfoMapper; private PartnerCustomerInfoMapper customerInfoMapper;
@Autowired
private PartnerCustomerInfoMapper partnerCustomerInfoMapper;
/** /**
* 查询客户信息列表 * 查询客户信息列表
@ -241,4 +243,8 @@ public class PartnerCustomerInfoServiceImpl extends ServiceImpl<PartnerCustomerI
{ {
return baseMapper.deletePartnerCustomerInfoByIds(ids); return baseMapper.deletePartnerCustomerInfoByIds(ids);
} }
} }

View File

@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.data.repository.query.Param;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -48,6 +49,9 @@ public interface OrderInfoService extends IService<OrderInfo> {
**/ **/
IPage<OrderInfo> queryListPage(OrderInfo orderInfo, Page<OrderInfo> page); IPage<OrderInfo> queryListPage(OrderInfo orderInfo, Page<OrderInfo> page);
Long createOrder(OrderInfo orderInfo) throws Exception; Long createOrder(OrderInfo orderInfo) throws Exception;
JSONObject pickCarDetail(Long pickCarId); JSONObject pickCarDetail(Long pickCarId);

View File

@ -181,6 +181,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
return baseMapper.pageOrderListSystem(orderInfo,page); return baseMapper.pageOrderListSystem(orderInfo,page);
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Long createOrder(OrderInfo orderInfo) throws Exception { public Long createOrder(OrderInfo orderInfo) throws Exception {

View File

@ -50,12 +50,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
resultType="cn.iocoder.yudao.module.partner.entity.PartnerCustomerInfo"> resultType="cn.iocoder.yudao.module.partner.entity.PartnerCustomerInfo">
select pci.*, select pci.*,
sr.name as roleName, sr.name as roleName,
sr.code as roleCode sr.code as roleCode,
COUNT(ins.id) AS orderCount
from partner_customer_info pci from partner_customer_info pci
left join shop_user_car suc on suc.user_id = pci.user_id left join shop_user_car suc on suc.user_id = pci.user_id
left join system_users su on su.id = pci.user_id left join system_users su on su.id = pci.user_id
left join system_user_role sur on sur.user_id = su.id left join system_user_role sur on sur.user_id = su.id
left join system_role sr on sr.id = sur.role_id left join system_role sr on sr.id = sur.role_id
LEFT JOIN inspection_info ins ON ins.user_id = pci.user_id AND YEAR(ins.create_time) =YEAR(NOW())
<where> <where>
<if test="vo.carNum != null and vo.carNum != ''"> and suc.car_no like concat('%', #{vo.carNum}, '%')</if> <if test="vo.carNum != null and vo.carNum != ''"> and suc.car_no like concat('%', #{vo.carNum}, '%')</if>
<if test="vo.customerName != null and vo.customerName != ''"> and pci.customer_name like concat('%', #{vo.customerName}, '%')</if> <if test="vo.customerName != null and vo.customerName != ''"> and pci.customer_name like concat('%', #{vo.customerName}, '%')</if>
@ -126,4 +128,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
</mapper> </mapper>

View File

@ -0,0 +1,100 @@
package cn.iocoder.yudao.module.app.controller.admin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import javax.websocket.*;
import javax.websocket.server.PathParam;
import javax.websocket.server.ServerEndpoint;
import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;
/**
* 维修APP消息监听
* @author vinjor-M
* @date 10:22 2024/10/17
**/
@ServerEndpoint(value = "/websocket/message/{tenantId}/{userId}")
@Component
public class NotifyMessageSocket {
private final static Logger log = LoggerFactory.getLogger(NotifyMessageSocket.class);
// 保存链接的sessionkey为用户名,value为对应的session名
public static ConcurrentHashMap<String, Session> sessionMap = new ConcurrentHashMap<>();
//关键代码设置一个静态上下文属性appcontext
private static ApplicationContext appcontext;
public static void setAppcontext(ApplicationContext appcontext) {
NotifyMessageSocket.appcontext = appcontext;
}
public static ApplicationContext getAppcontext() {
return appcontext;
}
/**
* 创建连接
* 用于监听建立连接当有客户端与该服务端点建立连接时将会自回调该注解标注的方法
* @param session
* @param userId
*/
@OnOpen
public void onOpen(Session session, @PathParam(value = "tenantId") String tenantId,@PathParam(value = "userId") String userId) {
this.sessionMap.put(tenantId+"_"+userId,session);
log.info("{}租户下用户{}已创建连接", tenantId,userId);
}
/**
* 用于监听客户端向服务端发送消息当客户端与服务端发送消息时将会回调该注解标注的方法
* {
* Stringitude:124.11,
* latitude:125.33,
* positionInfo:"山东省济南市市中区八一立交桥"
* }
* @param msg
* @param userId
*/
@OnMessage
public void onMessage(String msg,@PathParam(value = "userId") String userId){
System.out.println("消息通知+"+userId);
}
/**
* 用于监听连接关闭当客户端与该服务端点断开连接时将会回调该注解标注的方法
* @param session
* @param userId
*/
@OnClose
public void onClose(Session session,@PathParam(value = "tenantId") String tenantId,@PathParam(value = "userId") String userId){
this.sessionMap.remove(tenantId+"_"+userId);
}
/**
* 用于监听该连接上的任何错误当客户端与该服务端点的连接发生任何异常都将回调该注解标注的方法
* 注意该方法的参数必选Throwable可选Sessiion以及0-n个String参数且String参数需要使用@PathParam注解标注
* @param throwable
* @param tenantId 租户id
* @param userId 用户id
*/
@OnError
public void onError(Throwable throwable,@PathParam(value = "tenantId") String tenantId,@PathParam(value = "userId") String userId){
log.error("{}租户下用户{}已创建连接", tenantId,userId);
}
/**
* 发送给指定的用户
* @param message
*/
public void sendMessage(String message, String tenantId,String userId) throws IOException {
if (sessionMap.containsKey(tenantId+"_"+userId)){
Session session = sessionMap.get(tenantId+"_"+userId);
session.getAsyncRemote().sendText(message);
}
}
}

View File

@ -1,7 +1,10 @@
package cn.iocoder.yudao.module.base.controller.admin; package cn.iocoder.yudao.module.base.controller.admin;
import cn.iocoder.yudao.common.MessageSend;
import cn.iocoder.yudao.common.dto.MessageDTO;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.app.controller.admin.NotifyMessageSocket;
import cn.iocoder.yudao.module.base.entity.RepairWorker; import cn.iocoder.yudao.module.base.entity.RepairWorker;
import cn.iocoder.yudao.module.base.service.RepairWorkerService; import cn.iocoder.yudao.module.base.service.RepairWorkerService;
import cn.iocoder.yudao.module.base.vo.RepairWorkerPageReqVO; import cn.iocoder.yudao.module.base.vo.RepairWorkerPageReqVO;
@ -13,12 +16,17 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import static cn.iocoder.yudao.common.BaseConstants.QUALS_INTERIM_PERIOD;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.ok;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 维修工人") @Tag(name = "管理后台 - 维修工人")
@ -29,6 +37,10 @@ public class RepairWorkerController {
@Resource @Resource
private RepairWorkerService workerService; private RepairWorkerService workerService;
@Autowired
private NotifyMessageSocket notifyMessageSocket;
@Autowired
private MessageSend messageSend;
/** /**
@ -124,4 +136,30 @@ public class RepairWorkerController {
} }
/**
* 测试给维修工发送消息---测试
* @author vinjor-M
* @date 18:08 2024/10/16
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
**/
@GetMapping("/sendMessage")
@Operation(summary = "测试给维修工发送消息")
public CommonResult<?> sendMessage(Long userId) {
try {
MessageDTO messageDTO = new MessageDTO();
List<Long> userIds = new ArrayList<>();
userIds.add(userId);
messageDTO.setUserIds(userIds);
messageDTO.setTemplateCode(QUALS_INTERIM_PERIOD);
List<Object> paramList = new ArrayList<>();
paramList.add("测试");
paramList.add("3");
messageDTO.setParamList(paramList);
messageSend.send(messageDTO);
notifyMessageSocket.sendMessage("11","180",userId.toString());
} catch (IOException e) {
e.printStackTrace();
}
return ok();
}
} }

View File

@ -97,7 +97,7 @@ public interface DlRepairTicketsService extends IService<DlRepairTickets> {
* @author 小李 * @author 小李
* @date 9:28 2024/10/14 * @date 9:28 2024/10/14
**/ **/
Integer getUserRole(); String getUserRole();
/** /**
* 接单 * 接单

View File

@ -3,8 +3,8 @@ package cn.iocoder.yudao.module.tickets.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.common.RepairConstants;
import cn.iocoder.yudao.common.RepairErrorCodeConstants; import cn.iocoder.yudao.common.RepairErrorCodeConstants;
import cn.iocoder.yudao.common.RepairRoleEnum;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.base.entity.RepairWorker; import cn.iocoder.yudao.module.base.entity.RepairWorker;
import cn.iocoder.yudao.module.base.service.RepairWorkerService; import cn.iocoder.yudao.module.base.service.RepairWorkerService;
@ -51,21 +51,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.deepoove.poi.XWPFTemplate; import com.deepoove.poi.XWPFTemplate;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.print.Doc;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Arrays; import java.util.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static cn.iocoder.yudao.common.BaseConstants.ORDER_TENANT_NAME; import static cn.iocoder.yudao.common.BaseConstants.ORDER_TENANT_NAME;
@ -138,6 +131,8 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
@Resource @Resource
@Lazy @Lazy
private RepairWorkerService repairWorkerService; private RepairWorkerService repairWorkerService;
@Resource
private RepairWorkerService workerService;
/** /**
* 维修工单表 新增 * 维修工单表 新增
@ -395,28 +390,29 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
**/ **/
@Override @Override
public IPage<DlRepairTickets> getPageType(DlRepairTicketsReqVO repairTicketsReqVO, Page<DlRepairTickets> page){ public IPage<DlRepairTickets> getPageType(DlRepairTicketsReqVO repairTicketsReqVO, Page<DlRepairTickets> page){
Integer userRole = getUserRole(); String userRoleCode = getUserRole();
switch (userRole){ if(userRoleCode.equals(RepairRoleEnum.ADMIN.getCode())|| userRoleCode.equals(RepairRoleEnum.INSPECTION.getCode())){
case 1: //维修管理员和总检看所有数据
break; }else if(userRoleCode.equals(RepairRoleEnum.ADVISOR.getCode())){
case 2: //服务顾问看自己的
repairTicketsReqVO.setAdviserId(String.valueOf(SecurityFrameworkUtils.getLoginUserId())); repairTicketsReqVO.setAdviserId(String.valueOf(SecurityFrameworkUtils.getLoginUserId()));
break; }else if(userRoleCode.equals(RepairRoleEnum.REPAIR_STAFF.getCode())){
case 3: //维修工进一步判断是否是班组长
// 查自己是什么班组的组长 boolean ifLeader = workerService.getIfLeader();
if(ifLeader){
//班组长看本班组所有数据
RepairWorker one = repairWorkerService.getOne(new LambdaQueryWrapper<RepairWorker>().eq(RepairWorker::getUserId, SecurityFrameworkUtils.getLoginUserId())); RepairWorker one = repairWorkerService.getOne(new LambdaQueryWrapper<RepairWorker>().eq(RepairWorker::getUserId, SecurityFrameworkUtils.getLoginUserId()));
// 查自己班组的员工信息 // 查自己班组的员工信息
List<RepairWorker> list = repairWorkerService.list(new LambdaQueryWrapper<RepairWorker>().eq(RepairWorker::getWorkType, one.getWorkType())); List<RepairWorker> list = repairWorkerService.list(new LambdaQueryWrapper<RepairWorker>().eq(RepairWorker::getWorkType, one.getWorkType()));
// 所有的员工信息 // 所有的员工信息
List<Long> userIds = list.stream().map(RepairWorker::getUserId).collect(Collectors.toList()); List<Long> userIds = list.stream().map(RepairWorker::getUserId).collect(Collectors.toList());
repairTicketsReqVO.setUserIds(userIds); repairTicketsReqVO.setUserIds(userIds);
break; }else{
case 4: //普通维修工
repairTicketsReqVO.setUserIds(Collections.singletonList(SecurityFrameworkUtils.getLoginUserId())); repairTicketsReqVO.setUserIds(Collections.singletonList(SecurityFrameworkUtils.getLoginUserId()));
break; }
case -1: }else{
default: return null;
return null;
} }
return baseMapper.getPageType(repairTicketsReqVO, page); return baseMapper.getPageType(repairTicketsReqVO, page);
} }
@ -428,7 +424,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
* @date 9:28 2024/10/14 * @date 9:28 2024/10/14
**/ **/
@Override @Override
public Integer getUserRole(){ public String getUserRole(){
// 查看当前登录用户是什么角色 // 查看当前登录用户是什么角色
// 当前登录用户的角色信息 // 当前登录用户的角色信息
List<Long> byUserId = permissionApi.getRoleIdsByUserId(SecurityFrameworkUtils.getLoginUserId()); List<Long> byUserId = permissionApi.getRoleIdsByUserId(SecurityFrameworkUtils.getLoginUserId());
@ -437,29 +433,33 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
// 过滤出登录用户有的角色信息 // 过滤出登录用户有的角色信息
List<RoleReqDTO> collect = roleList.stream().filter(item -> byUserId.contains(item.getId())).collect(Collectors.toList()); List<RoleReqDTO> collect = roleList.stream().filter(item -> byUserId.contains(item.getId())).collect(Collectors.toList());
// 取出角色名称 // 取出角色名称
List<String> names = collect.stream().map(RoleReqDTO::getName).collect(Collectors.toList()); List<String> codes = collect.stream().map(RoleReqDTO::getCode).collect(Collectors.toList());
// 维修业务管理员--可以看所有数据但不能做操作
if (codes.contains(RepairRoleEnum.ADMIN.getCode())){
return RepairRoleEnum.ADMIN.getCode();
}
// 总检 // 总检
if (names.contains(RepairConstants.GENERAL_INSPECTION)){ if (codes.contains(RepairRoleEnum.INSPECTION.getCode())){
return 1; return RepairRoleEnum.INSPECTION.getCode();
} }
// 服务顾问 // 服务顾问
if (names.contains(RepairConstants.SERVICE_ADVISOR)){ if (codes.contains(RepairRoleEnum.ADVISOR.getName())){
return 2; return RepairRoleEnum.ADVISOR.getName();
} }
// 班组长 // 维修工或班组长
if (names.contains(RepairConstants.TEAM_LEADER)){ if (codes.contains(RepairRoleEnum.REPAIR_STAFF.getCode())){
return 3; return RepairRoleEnum.REPAIR_STAFF.getCode();
}
// 维修工
if (names.contains(RepairConstants.REPAIR_STAFF)){
return 4;
} }
// 维修仓库管理员 // 维修仓库管理员
if(names.contains(RepairConstants.REPAIR_WAREHOUSE)){ if(codes.contains(RepairRoleEnum.WAREHOUSE.getCode())){
return 5; return RepairRoleEnum.WAREHOUSE.getCode();
}
// 维修财务
if(codes.contains(RepairRoleEnum.WXCW.getCode())){
return RepairRoleEnum.WXCW.getCode();
} }
// 啥也不是 // 啥也不是
return -1; return null;
} }
/** /**

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.tickets.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.common.RepairRoleEnum;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.base.entity.RepairWorker; import cn.iocoder.yudao.module.base.entity.RepairWorker;
import cn.iocoder.yudao.module.base.service.RepairWorkerService; import cn.iocoder.yudao.module.base.service.RepairWorkerService;
@ -75,6 +76,8 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
@Resource @Resource
@Lazy @Lazy
private RepairWaresService repairWaresService; private RepairWaresService repairWaresService;
@Resource
private RepairWorkerService workerService;
/** /**
* 分页查询 * 分页查询
@ -86,35 +89,33 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
@Override @Override
public IPage<DlTicketWares> getPage(DlTicketWaresReqVO reqVO, Page<DlTicketWares> page){ public IPage<DlTicketWares> getPage(DlTicketWaresReqVO reqVO, Page<DlTicketWares> page){
// 确认查看者身份 // 确认查看者身份
Integer userRole = repairTicketsService.getUserRole(); String userRoleCode = repairTicketsService.getUserRole();
// 啥也不是 if(userRoleCode.equals(RepairRoleEnum.ADMIN.getCode())|| userRoleCode.equals(RepairRoleEnum.INSPECTION.getCode())){
if (userRole == -1){ //维修管理员和总检看所有数据
return null; }else if(userRoleCode.equals(RepairRoleEnum.ADVISOR.getCode())){
} //服务顾问
switch (userRole){ reqVO.setAdviserId(SecurityFrameworkUtils.getLoginUserId());
// 服务顾问 }else if(userRoleCode.equals(RepairRoleEnum.REPAIR_STAFF.getCode())){
case 2: //维修工进一步判断是否是班组长
reqVO.setAdviserId(SecurityFrameworkUtils.getLoginUserId()); boolean ifLeader = workerService.getIfLeader();
break; if(ifLeader){
// 班组长 //班组长看本班组所有数据
case 3:
// 查自己是什么班组的组长
RepairWorker one = repairWorkerService.getOne(new LambdaQueryWrapper<RepairWorker>().eq(RepairWorker::getUserId, SecurityFrameworkUtils.getLoginUserId())); RepairWorker one = repairWorkerService.getOne(new LambdaQueryWrapper<RepairWorker>().eq(RepairWorker::getUserId, SecurityFrameworkUtils.getLoginUserId()));
// 查自己班组的员工信息 // 查自己班组的员工信息
List<RepairWorker> list = repairWorkerService.list(new LambdaQueryWrapper<RepairWorker>().eq(RepairWorker::getWorkType, one.getWorkType())); List<RepairWorker> list = repairWorkerService.list(new LambdaQueryWrapper<RepairWorker>().eq(RepairWorker::getWorkType, one.getWorkType()));
// 所有的员工信息 // 所有的员工信息
List<Long> userIds = list.stream().map(RepairWorker::getUserId).collect(Collectors.toList()); List<Long> userIds = list.stream().map(RepairWorker::getUserId).collect(Collectors.toList());
reqVO.setUserIds(userIds); reqVO.setUserIds(userIds);
break; }else{
// 维修工 //普通维修工
case 4:
reqVO.setUserIds(Collections.singletonList(SecurityFrameworkUtils.getLoginUserId())); reqVO.setUserIds(Collections.singletonList(SecurityFrameworkUtils.getLoginUserId()));
break; }
}else if(userRoleCode.equals(RepairRoleEnum.WAREHOUSE.getCode())){
// 维修仓库管理员 // 维修仓库管理员
case 5: reqVO.setStatus(null);
reqVO.setStatus(null); reqVO.setUserRole(5);
reqVO.setUserRole(5); }else{
break; return null;
} }
return baseMapper.getPage(reqVO, page); return baseMapper.getPage(reqVO, page);
} }