Commit 49db20e01894e97e1cf4dff48c7129d0c12128a7

Authored by 房远帅
1 parent 078cfd4b

供应商报价:供应商查看权限(项目选择供应商部门则该部门下供应商能看见,为空则都可见)

... ... @@ -87,6 +87,17 @@ public class SupplierQuotationProject extends BaseEntity implements BaseDto {
87 87 private String status;
88 88
89 89 /**
  90 + * 供应商部门ID
  91 + */
  92 + private String supplierDepartmentId;
  93 +
  94 + /**
  95 + * 供应商部门名称
  96 + */
  97 + @TableField(exist = false)
  98 + private String supplierDepartmentName;
  99 +
  100 + /**
90 101 * 供应商报价
91 102 */
92 103 @TableField(exist = false)
... ...
... ... @@ -9,12 +9,17 @@ import com.lframework.starter.common.utils.Assert;
9 9 import com.lframework.starter.common.utils.ObjectUtil;
10 10 import com.lframework.starter.web.core.annotations.oplog.OpLog;
11 11 import com.lframework.starter.web.core.components.resp.PageResult;
  12 +import com.lframework.starter.web.core.components.security.SecurityUtil;
12 13 import com.lframework.starter.web.core.impl.BaseMpServiceImpl;
13 14 import com.lframework.starter.web.core.utils.IdUtil;
14 15 import com.lframework.starter.web.core.utils.OpLogUtil;
15 16 import com.lframework.starter.web.core.utils.PageHelperUtil;
16 17 import com.lframework.starter.web.core.utils.PageResultUtil;
17 18 import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
  19 +import com.lframework.starter.web.inner.entity.SysRole;
  20 +import com.lframework.starter.web.inner.entity.SysUserDept;
  21 +import com.lframework.starter.web.inner.service.system.SysRoleService;
  22 +import com.lframework.starter.web.inner.service.system.SysUserDeptService;
18 23 import com.lframework.xingyun.basedata.entity.BreedRelationship;
19 24 import com.lframework.xingyun.basedata.service.breed.BreedRelationshipService;
20 25 import com.lframework.xingyun.sc.events.quotation.CommonChangedEvent;
... ... @@ -28,11 +33,17 @@ import com.lframework.xingyun.sc.procurement.vo.quotation.CreateSupplierQuotatio
28 33 import com.lframework.xingyun.sc.procurement.vo.quotation.QuerySupplierQuotationProjectVo;
29 34 import com.lframework.xingyun.sc.procurement.vo.quotation.UpdateSupplierQuotationProjectVo;
30 35 import java.io.Serializable;
  36 +import java.security.Security;
31 37 import java.time.LocalDate;
32 38 import java.time.LocalDateTime;
33 39 import java.time.format.DateTimeFormatter;
  40 +import java.util.ArrayList;
34 41 import java.util.List;
  42 +import java.util.Set;
  43 +import java.util.stream.Collectors;
35 44 import javax.annotation.Resource;
  45 +
  46 +import org.apache.commons.collections4.CollectionUtils;
36 47 import org.apache.commons.lang3.StringUtils;
37 48 import org.springframework.context.ApplicationEventPublisher;
38 49 import org.springframework.stereotype.Service;
... ... @@ -72,6 +83,10 @@ public class SupplierQuotationProjectServiceImpl
72 83 private SupplierQuotationProjectQuoteMapper supplierQuotationProjectQuoteMapper;
73 84 @Resource
74 85 private ApplicationEventPublisher applicationEventPublisher;
  86 + @Resource
  87 + private SysRoleService sysRoleService;
  88 + @Resource
  89 + private SysUserDeptService sysUserDeptService;
75 90
76 91 @Override
77 92 public PageResult<SupplierQuotationProject> query(Integer pageIndex, Integer pageSize, QuerySupplierQuotationProjectVo vo) {
... ... @@ -85,11 +100,34 @@ public class SupplierQuotationProjectServiceImpl
85 100
86 101 @Override
87 102 public List<SupplierQuotationProject> query(QuerySupplierQuotationProjectVo vo) {
  103 + //供应商报价
  104 + String userId = SecurityUtil.getCurrentUser().getId();
  105 + Set<String> roleCodeSet = getRoleCodeSet(userId);
  106 +
  107 + //判断是否为供应商角色
  108 + boolean isSupplier = roleCodeSet.contains("gys");
  109 + if (isSupplier) {
  110 + List<SysUserDept> userDepts = sysUserDeptService.getByUserId(userId);
  111 + List<String> userDeptIds = new ArrayList<>();
  112 + if (CollectionUtils.isNotEmpty(userDepts)) {
  113 + userDeptIds = userDepts.stream()
  114 + .map(SysUserDept::getDeptId)
  115 + .collect(Collectors.toList());
  116 + vo.setCurrentSupplierDeptIds(userDeptIds);
  117 + }
  118 + }
88 119 List<SupplierQuotationProject> datas = getBaseMapper().query(vo);
89 120 fillComputedStatus(datas);
90 121 return datas;
91 122 }
92 123
  124 + private Set<String> getRoleCodeSet(String userId) {
  125 + List<SysRole> sysRoleList = sysRoleService.getByUserId(userId);
  126 + return sysRoleList.stream()
  127 + .map(SysRole::getCode)
  128 + .collect(Collectors.toSet());
  129 + }
  130 +
93 131 @Override
94 132 public List<SupplierQuotationProject> queryCurrentMonthBoardList(LocalDate month, String userId) {
95 133 LocalDate monthStart = month.withDayOfMonth(1);
... ...
... ... @@ -5,6 +5,8 @@ import com.lframework.starter.web.core.vo.PageVo;
5 5 import io.swagger.annotations.ApiModelProperty;
6 6 import java.io.Serializable;
7 7 import java.time.LocalDateTime;
  8 +import java.util.List;
  9 +
8 10 import lombok.Data;
9 11
10 12 @Data
... ... @@ -32,5 +34,8 @@ public class QuerySupplierQuotationProjectVo extends PageVo implements BaseVo, S
32 34
33 35 @ApiModelProperty("开标时间结束")
34 36 private LocalDateTime bidTimeEnd;
  37 +
  38 + @ApiModelProperty("供应商部门IDs")
  39 + private List<String> currentSupplierDeptIds;
35 40 }
36 41
... ...
... ... @@ -16,6 +16,8 @@
16 16 <result column="bid_time" property="bidTime"/>
17 17 <result column="purchase_rule" property="purchaseRule"/>
18 18 <result column="status" property="status"/>
  19 + <result column="supplier_department_id" property="supplierDepartmentId"/>
  20 + <result column="supplier_department_name" property="supplierDepartmentName"/>
19 21 <result column="create_by_id" property="createById"/>
20 22 <result column="create_by" property="createBy"/>
21 23 <result column="update_by_id" property="updateById"/>
... ... @@ -39,6 +41,8 @@
39 41 tb.bid_time,
40 42 tb.purchase_rule,
41 43 tb.status,
  44 + tb.supplier_department_id,
  45 + sd.name AS supplier_department_name,
42 46 tb.create_by_id,
43 47 tb.create_by,
44 48 tb.update_by_id,
... ... @@ -47,6 +51,7 @@
47 51 tb.update_time
48 52 FROM procurement_supplier_quotation_project tb
49 53 LEFT JOIN base_data_breed_relationship br ON br.id = tb.product_id
  54 + LEFT JOIN sys_dept sd ON sd.id = tb.supplier_department_id
50 55 </sql>
51 56
52 57 <select id="query" resultMap="SupplierQuotationProject">
... ... @@ -73,6 +78,17 @@
73 78 <if test="vo.bidTimeEnd != null">
74 79 AND tb.bid_time <![CDATA[ <= ]]> #{vo.bidTimeEnd}
75 80 </if>
  81 + <!-- 供应商数据权限过滤 -->
  82 + <if test="vo.currentSupplierDeptIds != null and vo.currentSupplierDeptIds.size() > 0">
  83 + AND (
  84 + tb.supplier_department_id in
  85 + <foreach collection="vo.currentSupplierDeptIds" open="(" separator="," close=")" item="item">
  86 + #{item}
  87 + </foreach>
  88 + OR
  89 + tb.supplier_department_id IS NULL
  90 + )
  91 + </if>
76 92 </where>
77 93 ORDER BY tb.create_time DESC, tb.id DESC
78 94 </select>
... ...