Browse Source

新增:SysSalesVo对象新增查询条件字段applyUsers,字段类型为List。修改:查询当登录角色为业务经理时,查询经理同部门下的业务员,查询条件新增为apply_user字段介于(in)(applyUsers) 的条件搜索。条件新增为apply_user。

dev
zhangsiqi 3 months ago
parent
commit
e5a314f0a7
  1. 32
      ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysSalesOrderController.java
  2. 11
      ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysSalesOrderVo.java
  3. 8
      ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysSalesOrderMapper.java
  4. 29
      ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysSalesOrderServiceImpl.java
  5. 12
      ruoyi-admin/src/main/resources/mapper/system/SysSalesOrderMapper.xml

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

@ -123,41 +123,9 @@ public class SysSalesOrderController extends BaseController
@ResponseBody
public TableDataInfo list(SysSalesOrderVo 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("ywyRole");
sysUserlist.add(curUser);
if (curUser.getUserName().contains("admin")) {
SysSalesOrderVo sysSalesOrderVo2 = new SysSalesOrderVo();
startPage();
List<SysSalesOrderVo> list2 = sysSalesOrderService.selectSysSalesOrderList(sysSalesOrderVo2);
return getDataTable(list2);
}
//如果主管审批,查看当前自己部门的审核
//如果经理审计需要查询自己部门下所有业务员的提交的订单,以及自身的提交的订单
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<SysSalesOrderVo> list2 = list.stream().filter(item -> user.contains(item.getApplyUser())).collect(Collectors.toList());
return getDataTable(list2);
}
// 业务员角色只能看到自己创建的数据
if (roleKeys.contains("ywyRole")) {
sysSalesOrderVo.setApplyUser(curUser.getLoginName());
startPage();
List<SysSalesOrderVo> list2 = sysSalesOrderService.selectSysSalesOrderList(sysSalesOrderVo);
return getDataTable(list2);
}
return getDataTable(list);
}catch(NullPointerException e){
throw new NullPointerException("当前用户没有申请客户资料");
}
}
/**

11
ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysSalesOrderVo.java

@ -1,6 +1,7 @@
package com.ruoyi.system.domain;
import java.util.Date;
import java.util.List;
public class SysSalesOrderVo extends SysSalesOrder{
/** 申请人姓名 */
@ -19,8 +20,18 @@ public class SysSalesOrderVo extends SysSalesOrder{
private String todoUserId;
/** 流程实例类型名称 */
private String instanceTypeName;
/*上级经理和所属业务员*/
private List<String> applyUsers;
public List<String> getApplyUsers() {
return applyUsers;
}
public void setApplyUsers(List<String> applyUsers) {
this.applyUsers = applyUsers;
}
/**
* 关键词
*/

8
ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysSalesOrderMapper.java

@ -30,6 +30,14 @@ public interface SysSalesOrderMapper
*/
public List<SysSalesOrderVo> selectSysSalesOrderList(SysSalesOrderVo sysSalesOrderVo);
/**
* 查询销售订单列表(根据经理的部门)
*
* @param sysSalesOrderVo 销售订单
* @return 销售订单集合
*/
public List<SysSalesOrderVo> selectSysSalesOrderByMange(SysSalesOrderVo sysSalesOrderVo);
/**
* 新增销售订单
*

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

@ -30,6 +30,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
/**
* 销售订单Service业务层处理
@ -81,6 +82,8 @@ public class SysSalesOrderServiceImpl implements ISysSalesOrderService
@Autowired
private IWarehouseOutOrderService warehouseOutOrderService;
@Autowired
private ISysUserService sysUserService;
/**
* 查询销售订单
@ -122,9 +125,28 @@ public class SysSalesOrderServiceImpl implements ISysSalesOrderService
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
SysUser curUser = ShiroUtils.getSysUser();
String loginName = ShiroUtils.getLoginName();
Long userId = curUser.getUserId();
List<SysSalesOrderVo> returnList = new ArrayList<>();
//PageHelper 仅对第一List分页有效
Page<SysSalesOrderVo> list = (Page<SysSalesOrderVo>) sysSalesOrderMapper.selectSysSalesOrderList(sysSalesOrderVo1);
Page<SysSalesOrderVo> returnList = new Page<>();
List<SysSalesOrderVo> list =sysSalesOrderMapper.selectSysSalesOrderList(sysSalesOrderVo1);
Set<String> roleKeys = roleService.selectRoleKeys(userId);
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());
List<String> user = findUser.stream().map(SysUser::getLoginName).collect(Collectors.toList());
String userStr = String.join(",", user);
sysSalesOrderVo1.setApplyUsers(user);
list = sysSalesOrderMapper.selectSysSalesOrderList(sysSalesOrderVo1);
}
if (roleKeys.contains("ywyRole")) {
sysSalesOrderVo1.setApplyUser(curUser.getLoginName());
list = list.stream().filter(item -> item.getApplyUser().equals(curUser.getLoginName())).collect(Collectors.toList());
}
for(SysSalesOrderVo sysSalesOrderVo : list){
SysUser sysUser = userMapper.selectUserByLoginName(sysSalesOrderVo.getCreateBy());
if (sysUser != null) {
@ -166,9 +188,6 @@ public class SysSalesOrderServiceImpl implements ISysSalesOrderService
}
returnList.add(sysSalesOrderVo);
}
returnList.setTotal(CollectionUtils.isEmpty(list) ? 0 : list.getTotal());
returnList.setPageNum(pageNum);
returnList.setPageSize(pageSize);
return returnList;
}

12
ruoyi-admin/src/main/resources/mapper/system/SysSalesOrderMapper.xml

@ -129,10 +129,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="applyUser != null and applyUser != ''"> and s.apply_user = #{applyUser}</if>
<if test="applyTime != null and applyTime != ''"> and s.apply_time = #{applyTime}</if>
<if test="applyTitle != null and applyTitle != ''"> and s.apply_title = #{applyTitle}</if>
<if test="applyUsers != null and applyUsers != ''"> and s.apply_user in
<foreach item="user" index="index" collection="applyUsers" open="(" separator="," close=")">
#{user}
</foreach>
</if>
</where>
order by s.audit_status asc, s.create_time desc
order by s.create_time desc
</select>
<select id="selectSysSalesOrderById" parameterType="Long" resultMap="SysSalesOrderResult">
<include refid="selectSysSalesOrderVo"/>
where sales_order_id = #{salesOrderId}
@ -203,6 +207,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="applyTime != null">apply_time,</if>
<if test="applyTitle != null">apply_title,</if>
<if test="createTime!= null">create_time,</if>
<if test="createBy != null">create_by,</if>
first_add_time,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
@ -264,6 +269,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="applyTime != null">#{applyTime},</if>
<if test="applyTitle != null">#{applyTitle},</if>
<if test="createTime!= null">#{createTime},</if>
<if test="creatBy != null">#{creatBy},</if>
now()
</trim>
</insert>
@ -330,6 +336,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="applyTime != null">apply_time = #{applyTime},</if>
<if test="applyTitle != null">apply_title = #{applyTitle},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
update_info_time = now()
</trim>
where sales_order_id = #{salesOrderId}
@ -398,6 +405,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="applyTime != null">apply_time = #{applyTime},</if>
<if test="applyTitle != null">apply_title = #{applyTitle},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
where sales_order_code = #{salesOrderCode}
</update>

Loading…
Cancel
Save