Browse Source

[update]销售管理:主管可以查询所有业务员,业务经理可以查询归属下的业务员,业务员只能查询自己申请的销售订单

dev
zhangsiqi 7 months ago
parent
commit
b0e9f7d618
  1. 61
      ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysSalesOrderController.java
  2. 2
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSalesOrderServiceImpl.java

61
ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysSalesOrderController.java

@ -101,64 +101,33 @@ public class SysSalesOrderController extends BaseController
@ResponseBody
public TableDataInfo list(SysSalesOrderVo sysSalesOrderVo)
{
startPage();
List<SysSalesOrderVo> list = sysSalesOrderService.selectSysSalesOrderList(sysSalesOrderVo);
try {
startPage();
List<SysSalesOrderVo> list = sysSalesOrderService.selectSysSalesOrderList(sysSalesOrderVo);
SysUser curUser = ShiroUtils.getSysUser();
String loginName = ShiroUtils.getLoginName();
Long userId = curUser.getUserId();
Set<String> roleKeys = roleService.selectRoleKeys(userId);
List<SysUser> sysUserlist = sysUserService.selectRoleToUserList("ywy");
if(roleKeys.contains("ywjlRole")){
sysUserlist = sysUserlist.stream().filter(item -> {
return item.getDept().getDeptId() == curUser.getDeptId();
}).collect(Collectors.toList());
List<SysUser> finalSysUserlist = sysUserlist;
finalSysUserlist.add(curUser);
List<SysUser> sysUserlist = sysUserService.selectRoleToUserList("ywyRole");
sysUserlist.add(curUser);
if (roleKeys.contains("ywjlRole")) {
List<SysUser> findUser = sysUserlist.stream().filter(item -> (item.getDeptId().equals(curUser.getDeptId()))).collect(Collectors.toList());
Set<String> user = findUser.stream().map(SysUser::getLoginName).collect(Collectors.toSet());
startPage();
list = list.stream().filter(item -> {
for (SysUser sysUser : finalSysUserlist) {
if (sysUser.getLoginName().equals(item.getApplyUser())) {
return true;
}
}
return false;
}).collect(Collectors.toList());
return getDataTable(list);
List<SysSalesOrderVo> list2 = list.stream().filter(item -> user.contains(item.getApplyUser())).collect(Collectors.toList());
return getDataTable(list2);
}
if(roleKeys.contains("ywzgRole")){
sysUserlist = sysUserlist.stream().filter(item -> {
return item.getDept().getDeptId() == curUser.getDeptId();
}).collect(Collectors.toList());
List<SysUser> finalSysUserlist = sysUserlist;
finalSysUserlist.add(curUser);
startPage();
list = list.stream().filter(item -> {
for (SysUser sysUser : finalSysUserlist) {
if (sysUser.getLoginName().equals(item.getApplyUser())) {
return true;
}
}
return false;
}).collect(Collectors.toList());
return getDataTable(list);
}
// 业务员角色只能看到自己创建的数据
if(roleKeys.contains("ywyRole")){
sysSalesOrderVo.setApplyUser(curUser.getLoginName());
// 业务员角色只能看到自己创建的数据
if (roleKeys.contains("ywyRole")) {
sysSalesOrderVo.setApplyUser(curUser.getUserName());
startPage();
list = sysSalesOrderService.selectSysSalesOrderList(sysSalesOrderVo);
return getDataTable(list);
}
if(!roleKeys.contains("ywzjRole") && !roleKeys.contains("ywzjRole") && !roleKeys.contains("ywzjRole")){
sysSalesOrderVo.setApplyUser(curUser.getLoginName());
startPage();
list = sysSalesOrderService.selectSysSalesOrderList(sysSalesOrderVo);
}
}catch (NullPointerException e){
return getDataTable(list);
}catch(NullPointerException e){
throw new NullPointerException("当前用户没有申请客户资料");
}
return getDataTable(list);
}
/**

2
ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSalesOrderServiceImpl.java

@ -170,7 +170,7 @@ public class SysSalesOrderServiceImpl implements ISysSalesOrderService
public int insertSysSalesOrder(SysSalesOrder sysSalesOrder){
String loginName = ShiroUtils.getLoginName();
sysSalesOrder.setCreateBy(loginName);
sysSalesOrder.setCreateTime(new Date());
sysSalesOrder.setCreateTime(DateUtils.getNowDate());
int result = sysSalesOrderMapper.insertSysSalesOrder(sysSalesOrder);
sysSalesOrder.getSalesOrderId();
int s = sysSalesOrder.getSysSalesOrderChildList().size();

Loading…
Cancel
Save