Commit 586d7043b54fa352f9feb0b899bdf59ed98208d8
1 parent
16c5a531
销售-发货计划:业务员(能看到自己申请发货创建的和本区域人创建的数据+系统自动生成),明细数据只能看到自己创建的和本区域内的,关联订单查询合同创建人实现
Showing
6 changed files
with
111 additions
and
1 deletions
| @@ -77,6 +77,17 @@ public class ShipmentsPlanDetailServiceImpl extends BaseMpServiceImpl<ShipmentsP | @@ -77,6 +77,17 @@ public class ShipmentsPlanDetailServiceImpl extends BaseMpServiceImpl<ShipmentsP | ||
| 77 | Assert.greaterThanZero(pageIndex); | 77 | Assert.greaterThanZero(pageIndex); |
| 78 | Assert.greaterThanZero(pageSize); | 78 | Assert.greaterThanZero(pageSize); |
| 79 | 79 | ||
| 80 | + // 业务员(ywy)角色做权限控制:明细创建人多为系统自动生成,按明细关联订货单的合同创建人过滤(自己 + 本区域人) | ||
| 81 | + String currentUserId = SecurityUtil.getCurrentUser().getId(); | ||
| 82 | + List<SysRole> roleList = sysRoleService.getByUserId(currentUserId); | ||
| 83 | + for (SysRole role : roleList) { | ||
| 84 | + String code = role.getCode(); | ||
| 85 | + if ("ywy".equals(code)) { | ||
| 86 | + vo.setCreateByIds(sysUserDeptService.listAllUserByUserId(Collections.singletonList(currentUserId), true)); | ||
| 87 | + break; | ||
| 88 | + } | ||
| 89 | + } | ||
| 90 | + | ||
| 80 | PageHelperUtil.startPage(pageIndex, pageSize); | 91 | PageHelperUtil.startPage(pageIndex, pageSize); |
| 81 | List<ShipmentsPlanDetail> dataList = this.query(vo); | 92 | List<ShipmentsPlanDetail> dataList = this.query(vo); |
| 82 | 93 |
| @@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; | @@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||
| 5 | import com.github.pagehelper.PageInfo; | 5 | import com.github.pagehelper.PageInfo; |
| 6 | import com.lframework.starter.web.core.components.security.SecurityUtil; | 6 | import com.lframework.starter.web.core.components.security.SecurityUtil; |
| 7 | import com.lframework.starter.web.inner.entity.SysRole; | 7 | import com.lframework.starter.web.inner.entity.SysRole; |
| 8 | +import com.lframework.starter.web.inner.entity.SysUserDept; | ||
| 8 | import com.lframework.starter.web.inner.service.system.SysRoleService; | 9 | import com.lframework.starter.web.inner.service.system.SysRoleService; |
| 10 | +import com.lframework.starter.web.inner.service.system.SysUserDeptService; | ||
| 9 | import com.lframework.xingyun.sc.entity.ShipmentsPlan; | 11 | import com.lframework.xingyun.sc.entity.ShipmentsPlan; |
| 10 | import com.lframework.starter.web.core.impl.BaseMpServiceImpl; | 12 | import com.lframework.starter.web.core.impl.BaseMpServiceImpl; |
| 11 | import com.lframework.starter.web.core.utils.PageResultUtil; | 13 | import com.lframework.starter.web.core.utils.PageResultUtil; |
| @@ -30,6 +32,7 @@ import org.springframework.stereotype.Service; | @@ -30,6 +32,7 @@ import org.springframework.stereotype.Service; | ||
| 30 | import javax.annotation.Resource; | 32 | import javax.annotation.Resource; |
| 31 | import java.util.ArrayList; | 33 | import java.util.ArrayList; |
| 32 | import java.util.List; | 34 | import java.util.List; |
| 35 | +import java.util.stream.Collectors; | ||
| 33 | 36 | ||
| 34 | @Service | 37 | @Service |
| 35 | public class ShipmentsPlanServiceImpl extends BaseMpServiceImpl<ShipmentsPlanMapper, ShipmentsPlan> implements ShipmentsPlanService { | 38 | public class ShipmentsPlanServiceImpl extends BaseMpServiceImpl<ShipmentsPlanMapper, ShipmentsPlan> implements ShipmentsPlanService { |
| @@ -38,6 +41,12 @@ public class ShipmentsPlanServiceImpl extends BaseMpServiceImpl<ShipmentsPlanMap | @@ -38,6 +41,12 @@ public class ShipmentsPlanServiceImpl extends BaseMpServiceImpl<ShipmentsPlanMap | ||
| 38 | 41 | ||
| 39 | @Resource | 42 | @Resource |
| 40 | private SysRoleService sysRoleService; | 43 | private SysRoleService sysRoleService; |
| 44 | + @Resource | ||
| 45 | + private SysUserDeptService sysUserDeptService; | ||
| 46 | + /** | ||
| 47 | + * 业务员角色编码 | ||
| 48 | + */ | ||
| 49 | + private static final String ROLE_CODE_YWY = "ywy"; | ||
| 41 | 50 | ||
| 42 | @Override | 51 | @Override |
| 43 | public PageResult<ShipmentsPlan> query(Integer pageIndex, Integer pageSize, QueryShipmentsPlanVo vo) { | 52 | public PageResult<ShipmentsPlan> query(Integer pageIndex, Integer pageSize, QueryShipmentsPlanVo vo) { |
| @@ -48,11 +57,16 @@ public class ShipmentsPlanServiceImpl extends BaseMpServiceImpl<ShipmentsPlanMap | @@ -48,11 +57,16 @@ public class ShipmentsPlanServiceImpl extends BaseMpServiceImpl<ShipmentsPlanMap | ||
| 48 | String currentUserId = SecurityUtil.getCurrentUser().getId(); | 57 | String currentUserId = SecurityUtil.getCurrentUser().getId(); |
| 49 | // 获取当前人所属角色 | 58 | // 获取当前人所属角色 |
| 50 | List<SysRole> roleList = sysRoleService.getByUserId(currentUserId); | 59 | List<SysRole> roleList = sysRoleService.getByUserId(currentUserId); |
| 60 | + // 业务员(ywy)角色标记:需特殊处理,额外可见系统自动生成且非申请发货来源的数据 | ||
| 61 | + boolean isYwy = false; | ||
| 51 | for (SysRole role : roleList) { | 62 | for (SysRole role : roleList) { |
| 52 | String roleCode = role.getCode(); | 63 | String roleCode = role.getCode(); |
| 53 | if (StringUtils.isBlank(roleCode)) { | 64 | if (StringUtils.isBlank(roleCode)) { |
| 54 | continue; | 65 | continue; |
| 55 | } | 66 | } |
| 67 | + if (ROLE_CODE_YWY.equals(roleCode)) { | ||
| 68 | + isYwy = true; | ||
| 69 | + } | ||
| 56 | String workshopCode = ""; | 70 | String workshopCode = ""; |
| 57 | if (roleCode.startsWith("yfc")) { | 71 | if (roleCode.startsWith("yfc")) { |
| 58 | workshopCode = "yfc"; | 72 | workshopCode = "yfc"; |
| @@ -68,9 +82,17 @@ public class ShipmentsPlanServiceImpl extends BaseMpServiceImpl<ShipmentsPlanMap | @@ -68,9 +82,17 @@ public class ShipmentsPlanServiceImpl extends BaseMpServiceImpl<ShipmentsPlanMap | ||
| 68 | } | 82 | } |
| 69 | } | 83 | } |
| 70 | vo.setWorkshopCodeList(workshopCodeList); | 84 | vo.setWorkshopCodeList(workshopCodeList); |
| 85 | + if (isYwy) { | ||
| 86 | + // 业务员口径:自己创建的 + 本区域(所属部门及其下级部门)人创建的 + 系统自动生成且非申请发货来源的 | ||
| 87 | + vo.setYwyUserId(currentUserId); | ||
| 88 | + List<SysUserDept> userDeptList = sysUserDeptService.getByUserId(currentUserId); | ||
| 89 | + vo.setYwyDeptIds(userDeptList.stream().map(SysUserDept::getDeptId).distinct() | ||
| 90 | + .collect(Collectors.toList())); | ||
| 91 | + } | ||
| 71 | // 开启分页 | 92 | // 开启分页 |
| 72 | PageHelperUtil.startPage(pageIndex, pageSize); | 93 | PageHelperUtil.startPage(pageIndex, pageSize); |
| 73 | - List<ShipmentsPlan> dataList = this.query(vo); | 94 | + List<ShipmentsPlan> dataList = vo.getYwyUserId() != null |
| 95 | + ? getBaseMapper().queryYwyScope(vo) : this.query(vo); | ||
| 74 | 96 | ||
| 75 | return PageResultUtil.convert(new PageInfo<>(dataList)); | 97 | return PageResultUtil.convert(new PageInfo<>(dataList)); |
| 76 | } | 98 | } |
| @@ -30,6 +30,12 @@ public interface ShipmentsPlanMapper extends BaseMapper<ShipmentsPlan> { | @@ -30,6 +30,12 @@ public interface ShipmentsPlanMapper extends BaseMapper<ShipmentsPlan> { | ||
| 30 | List<ShipmentsPlan> query(@Param("vo") QueryShipmentsPlanVo vo); | 30 | List<ShipmentsPlan> query(@Param("vo") QueryShipmentsPlanVo vo); |
| 31 | 31 | ||
| 32 | /** | 32 | /** |
| 33 | + * 业务员(ywy)角色专用查询(无数据权限注解,Service 层按角色分流调用): | ||
| 34 | + * 自己创建的 + 本区域(所属部门及其下级部门)人创建的 + 系统自动创建的 | ||
| 35 | + */ | ||
| 36 | + List<ShipmentsPlan> queryYwyScope(@Param("vo") QueryShipmentsPlanVo vo); | ||
| 37 | + | ||
| 38 | + /** | ||
| 33 | * 查询列表 | 39 | * 查询列表 |
| 34 | * | 40 | * |
| 35 | * @param id 查询条件 | 41 | * @param id 查询条件 |
| @@ -38,4 +38,16 @@ public class QueryShipmentsPlanVo extends PageVo implements BaseVo, Serializable | @@ -38,4 +38,16 @@ public class QueryShipmentsPlanVo extends PageVo implements BaseVo, Serializable | ||
| 38 | @ApiModelProperty("制单时间") | 38 | @ApiModelProperty("制单时间") |
| 39 | private LocalDateTime createStartTime; | 39 | private LocalDateTime createStartTime; |
| 40 | private LocalDateTime createEndTime; | 40 | private LocalDateTime createEndTime; |
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * 业务员(ywy)角色专用:当前用户ID(后端注入,前端传参无效) | ||
| 44 | + */ | ||
| 45 | + @ApiModelProperty(hidden = true) | ||
| 46 | + private String ywyUserId; | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * 业务员(ywy)角色专用:当前用户所属部门ID集合(后端注入,前端传参无效) | ||
| 50 | + */ | ||
| 51 | + @ApiModelProperty(hidden = true) | ||
| 52 | + private List<String> ywyDeptIds; | ||
| 41 | } | 53 | } |
| @@ -126,6 +126,13 @@ | @@ -126,6 +126,13 @@ | ||
| 126 | </otherwise> | 126 | </otherwise> |
| 127 | </choose> | 127 | </choose> |
| 128 | </if> | 128 | </if> |
| 129 | + <!-- 业务员(ywy)权限:明细创建人多为系统自动生成,按关联订货单的合同创建人过滤(Java 层已预算常量集合) --> | ||
| 130 | + <if test="vo.createByIds != null and vo.createByIds.size() > 0"> | ||
| 131 | + AND o.contract_create_by_id IN | ||
| 132 | + <foreach collection="vo.createByIds" open="(" separator="," close=")" item="item"> | ||
| 133 | + #{item} | ||
| 134 | + </foreach> | ||
| 135 | + </if> | ||
| 129 | </where> | 136 | </where> |
| 130 | ORDER BY | 137 | ORDER BY |
| 131 | CASE | 138 | CASE |
| @@ -62,6 +62,58 @@ | @@ -62,6 +62,58 @@ | ||
| 62 | ORDER BY tb.create_time DESC | 62 | ORDER BY tb.create_time DESC |
| 63 | </select> | 63 | </select> |
| 64 | 64 | ||
| 65 | + <!-- 业务员(ywy)角色专用查询(Mapper 方法无 @DataPermissions 注解,避免框架创建人条件把系统自动创建的数据过滤掉): | ||
| 66 | + 自己创建的 + 本区域(所属部门及其下级部门)人创建的 + 系统自动生成且非申请发货来源的 --> | ||
| 67 | + <select id="queryYwyScope" resultMap="ShipmentsPlan"> | ||
| 68 | + <include refid="ShipmentsPlan_sql"/> | ||
| 69 | + <where> | ||
| 70 | + <if test="vo.workshopId != null and vo.workshopId != ''"> | ||
| 71 | + AND tb.workshop_id = #{vo.workshopId} | ||
| 72 | + </if> | ||
| 73 | + <if test="vo.workshopCodeList != null and vo.workshopCodeList.size() > 0"> | ||
| 74 | + AND w.code IN | ||
| 75 | + <foreach collection="vo.workshopCodeList" open="(" separator="," close=")" item="item"> | ||
| 76 | + #{item} | ||
| 77 | + </foreach> | ||
| 78 | + </if> | ||
| 79 | + <if test="vo.status != null and vo.status != ''"> | ||
| 80 | + AND tb.status = #{vo.status} | ||
| 81 | + </if> | ||
| 82 | + <if test="vo.createStartTime != null"> | ||
| 83 | + AND tb.create_time >= #{vo.createStartTime} | ||
| 84 | + </if> | ||
| 85 | + <if test="vo.createEndTime != null"> | ||
| 86 | + AND tb.create_time <= #{vo.createEndTime} | ||
| 87 | + </if> | ||
| 88 | + <!-- 业务员数据口径(部门树口径与框架"创建人部门与本人相同/是本人的下级部门"规则一致) --> | ||
| 89 | + AND ( | ||
| 90 | + ( | ||
| 91 | + tb.auto_generate = 1 | ||
| 92 | + AND (tb.source IS NULL OR tb.source != 'APPLY_SHIPMENT') | ||
| 93 | + ) | ||
| 94 | + OR tb.create_by_id = #{vo.ywyUserId} | ||
| 95 | + <if test="vo.ywyDeptIds != null and vo.ywyDeptIds.size() > 0"> | ||
| 96 | + OR tb.create_by_id IN ( | ||
| 97 | + SELECT __ud.user_id FROM sys_user_dept __ud | ||
| 98 | + WHERE __ud.dept_id IN ( | ||
| 99 | + SELECT __mp.node_id FROM recursion_mapping __mp | ||
| 100 | + WHERE __mp.node_type = 1 | ||
| 101 | + AND EXISTS ( | ||
| 102 | + SELECT 1 FROM sys_dept __d | ||
| 103 | + WHERE __d.id IN | ||
| 104 | + <foreach collection="vo.ywyDeptIds" open="(" separator="," close=")" item="deptId"> | ||
| 105 | + #{deptId} | ||
| 106 | + </foreach> | ||
| 107 | + AND FIND_IN_SET(__d.id, __mp.path) | ||
| 108 | + ) | ||
| 109 | + ) | ||
| 110 | + ) | ||
| 111 | + </if> | ||
| 112 | + ) | ||
| 113 | + </where> | ||
| 114 | + ORDER BY tb.create_time DESC | ||
| 115 | + </select> | ||
| 116 | + | ||
| 65 | <select id="getById" resultMap="ShipmentsPlan"> | 117 | <select id="getById" resultMap="ShipmentsPlan"> |
| 66 | <include refid="ShipmentsPlan_sql"/> | 118 | <include refid="ShipmentsPlan_sql"/> |
| 67 | <where> | 119 | <where> |