Commit 49db20e01894e97e1cf4dff48c7129d0c12128a7

Authored by 房远帅
1 parent 078cfd4b

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

@@ -87,6 +87,17 @@ public class SupplierQuotationProject extends BaseEntity implements BaseDto { @@ -87,6 +87,17 @@ public class SupplierQuotationProject extends BaseEntity implements BaseDto {
87 private String status; 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 @TableField(exist = false) 103 @TableField(exist = false)
@@ -9,12 +9,17 @@ import com.lframework.starter.common.utils.Assert; @@ -9,12 +9,17 @@ import com.lframework.starter.common.utils.Assert;
9 import com.lframework.starter.common.utils.ObjectUtil; 9 import com.lframework.starter.common.utils.ObjectUtil;
10 import com.lframework.starter.web.core.annotations.oplog.OpLog; 10 import com.lframework.starter.web.core.annotations.oplog.OpLog;
11 import com.lframework.starter.web.core.components.resp.PageResult; 11 import com.lframework.starter.web.core.components.resp.PageResult;
  12 +import com.lframework.starter.web.core.components.security.SecurityUtil;
12 import com.lframework.starter.web.core.impl.BaseMpServiceImpl; 13 import com.lframework.starter.web.core.impl.BaseMpServiceImpl;
13 import com.lframework.starter.web.core.utils.IdUtil; 14 import com.lframework.starter.web.core.utils.IdUtil;
14 import com.lframework.starter.web.core.utils.OpLogUtil; 15 import com.lframework.starter.web.core.utils.OpLogUtil;
15 import com.lframework.starter.web.core.utils.PageHelperUtil; 16 import com.lframework.starter.web.core.utils.PageHelperUtil;
16 import com.lframework.starter.web.core.utils.PageResultUtil; 17 import com.lframework.starter.web.core.utils.PageResultUtil;
17 import com.lframework.starter.web.inner.components.oplog.OtherOpLogType; 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 import com.lframework.xingyun.basedata.entity.BreedRelationship; 23 import com.lframework.xingyun.basedata.entity.BreedRelationship;
19 import com.lframework.xingyun.basedata.service.breed.BreedRelationshipService; 24 import com.lframework.xingyun.basedata.service.breed.BreedRelationshipService;
20 import com.lframework.xingyun.sc.events.quotation.CommonChangedEvent; 25 import com.lframework.xingyun.sc.events.quotation.CommonChangedEvent;
@@ -28,11 +33,17 @@ import com.lframework.xingyun.sc.procurement.vo.quotation.CreateSupplierQuotatio @@ -28,11 +33,17 @@ import com.lframework.xingyun.sc.procurement.vo.quotation.CreateSupplierQuotatio
28 import com.lframework.xingyun.sc.procurement.vo.quotation.QuerySupplierQuotationProjectVo; 33 import com.lframework.xingyun.sc.procurement.vo.quotation.QuerySupplierQuotationProjectVo;
29 import com.lframework.xingyun.sc.procurement.vo.quotation.UpdateSupplierQuotationProjectVo; 34 import com.lframework.xingyun.sc.procurement.vo.quotation.UpdateSupplierQuotationProjectVo;
30 import java.io.Serializable; 35 import java.io.Serializable;
  36 +import java.security.Security;
31 import java.time.LocalDate; 37 import java.time.LocalDate;
32 import java.time.LocalDateTime; 38 import java.time.LocalDateTime;
33 import java.time.format.DateTimeFormatter; 39 import java.time.format.DateTimeFormatter;
  40 +import java.util.ArrayList;
34 import java.util.List; 41 import java.util.List;
  42 +import java.util.Set;
  43 +import java.util.stream.Collectors;
35 import javax.annotation.Resource; 44 import javax.annotation.Resource;
  45 +
  46 +import org.apache.commons.collections4.CollectionUtils;
36 import org.apache.commons.lang3.StringUtils; 47 import org.apache.commons.lang3.StringUtils;
37 import org.springframework.context.ApplicationEventPublisher; 48 import org.springframework.context.ApplicationEventPublisher;
38 import org.springframework.stereotype.Service; 49 import org.springframework.stereotype.Service;
@@ -72,6 +83,10 @@ public class SupplierQuotationProjectServiceImpl @@ -72,6 +83,10 @@ public class SupplierQuotationProjectServiceImpl
72 private SupplierQuotationProjectQuoteMapper supplierQuotationProjectQuoteMapper; 83 private SupplierQuotationProjectQuoteMapper supplierQuotationProjectQuoteMapper;
73 @Resource 84 @Resource
74 private ApplicationEventPublisher applicationEventPublisher; 85 private ApplicationEventPublisher applicationEventPublisher;
  86 + @Resource
  87 + private SysRoleService sysRoleService;
  88 + @Resource
  89 + private SysUserDeptService sysUserDeptService;
75 90
76 @Override 91 @Override
77 public PageResult<SupplierQuotationProject> query(Integer pageIndex, Integer pageSize, QuerySupplierQuotationProjectVo vo) { 92 public PageResult<SupplierQuotationProject> query(Integer pageIndex, Integer pageSize, QuerySupplierQuotationProjectVo vo) {
@@ -85,11 +100,34 @@ public class SupplierQuotationProjectServiceImpl @@ -85,11 +100,34 @@ public class SupplierQuotationProjectServiceImpl
85 100
86 @Override 101 @Override
87 public List<SupplierQuotationProject> query(QuerySupplierQuotationProjectVo vo) { 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 List<SupplierQuotationProject> datas = getBaseMapper().query(vo); 119 List<SupplierQuotationProject> datas = getBaseMapper().query(vo);
89 fillComputedStatus(datas); 120 fillComputedStatus(datas);
90 return datas; 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 @Override 131 @Override
94 public List<SupplierQuotationProject> queryCurrentMonthBoardList(LocalDate month, String userId) { 132 public List<SupplierQuotationProject> queryCurrentMonthBoardList(LocalDate month, String userId) {
95 LocalDate monthStart = month.withDayOfMonth(1); 133 LocalDate monthStart = month.withDayOfMonth(1);
@@ -5,6 +5,8 @@ import com.lframework.starter.web.core.vo.PageVo; @@ -5,6 +5,8 @@ import com.lframework.starter.web.core.vo.PageVo;
5 import io.swagger.annotations.ApiModelProperty; 5 import io.swagger.annotations.ApiModelProperty;
6 import java.io.Serializable; 6 import java.io.Serializable;
7 import java.time.LocalDateTime; 7 import java.time.LocalDateTime;
  8 +import java.util.List;
  9 +
8 import lombok.Data; 10 import lombok.Data;
9 11
10 @Data 12 @Data
@@ -32,5 +34,8 @@ public class QuerySupplierQuotationProjectVo extends PageVo implements BaseVo, S @@ -32,5 +34,8 @@ public class QuerySupplierQuotationProjectVo extends PageVo implements BaseVo, S
32 34
33 @ApiModelProperty("开标时间结束") 35 @ApiModelProperty("开标时间结束")
34 private LocalDateTime bidTimeEnd; 36 private LocalDateTime bidTimeEnd;
  37 +
  38 + @ApiModelProperty("供应商部门IDs")
  39 + private List<String> currentSupplierDeptIds;
35 } 40 }
36 41
@@ -16,6 +16,8 @@ @@ -16,6 +16,8 @@
16 <result column="bid_time" property="bidTime"/> 16 <result column="bid_time" property="bidTime"/>
17 <result column="purchase_rule" property="purchaseRule"/> 17 <result column="purchase_rule" property="purchaseRule"/>
18 <result column="status" property="status"/> 18 <result column="status" property="status"/>
  19 + <result column="supplier_department_id" property="supplierDepartmentId"/>
  20 + <result column="supplier_department_name" property="supplierDepartmentName"/>
19 <result column="create_by_id" property="createById"/> 21 <result column="create_by_id" property="createById"/>
20 <result column="create_by" property="createBy"/> 22 <result column="create_by" property="createBy"/>
21 <result column="update_by_id" property="updateById"/> 23 <result column="update_by_id" property="updateById"/>
@@ -39,6 +41,8 @@ @@ -39,6 +41,8 @@
39 tb.bid_time, 41 tb.bid_time,
40 tb.purchase_rule, 42 tb.purchase_rule,
41 tb.status, 43 tb.status,
  44 + tb.supplier_department_id,
  45 + sd.name AS supplier_department_name,
42 tb.create_by_id, 46 tb.create_by_id,
43 tb.create_by, 47 tb.create_by,
44 tb.update_by_id, 48 tb.update_by_id,
@@ -47,6 +51,7 @@ @@ -47,6 +51,7 @@
47 tb.update_time 51 tb.update_time
48 FROM procurement_supplier_quotation_project tb 52 FROM procurement_supplier_quotation_project tb
49 LEFT JOIN base_data_breed_relationship br ON br.id = tb.product_id 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 </sql> 55 </sql>
51 56
52 <select id="query" resultMap="SupplierQuotationProject"> 57 <select id="query" resultMap="SupplierQuotationProject">
@@ -73,6 +78,17 @@ @@ -73,6 +78,17 @@
73 <if test="vo.bidTimeEnd != null"> 78 <if test="vo.bidTimeEnd != null">
74 AND tb.bid_time <![CDATA[ <= ]]> #{vo.bidTimeEnd} 79 AND tb.bid_time <![CDATA[ <= ]]> #{vo.bidTimeEnd}
75 </if> 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 </where> 92 </where>
77 ORDER BY tb.create_time DESC, tb.id DESC 93 ORDER BY tb.create_time DESC, tb.id DESC
78 </select> 94 </select>