Commit f3f7642e428d7264f61b36baae01fef40906cf4b

Authored by 房远帅
1 parent 78a4980e

订货单:上传质保书按钮显示权限

... ... @@ -338,6 +338,12 @@ public class GetPurchaseOrderInfoBo extends BaseBo<PurchaseOrderInfo> {
338 338 @ApiModelProperty("质保书名称")
339 339 private String warrantyCertificateFileName;
340 340
  341 + /**
  342 + * 是否展示上传按钮(非持久化字段)
  343 + */
  344 + @ApiModelProperty("是否展示上传按钮")
  345 + private boolean showUpload = false;
  346 +
341 347
342 348 public GetPurchaseOrderInfoBo() {
343 349
... ...
... ... @@ -87,6 +87,9 @@ public class PurchaseOrderInfoController extends DefaultBaseController {
87 87 private TransactorHandler transactorHandler;
88 88 @Resource
89 89 private ContractDistributorStandardService contractDistributorStandardService;
  90 + @Resource
  91 + private SysRoleService sysRoleService;
  92 +
90 93
91 94
92 95 /**
... ... @@ -104,7 +107,8 @@ public class PurchaseOrderInfoController extends DefaultBaseController {
104 107
105 108 if (!CollectionUtil.isEmpty(datas)) {
106 109 String currentUserId = SecurityUtil.getCurrentUser().getId();
107   -
  110 + List<SysRole> roles = sysRoleService.getByUserId(currentUserId);
  111 + List<String> roleCodes = roles.stream().map(SysRole::getCode).collect(Collectors.toList());
108 112 results = datas.stream().map(purchaseOrderInfo -> {
109 113 GetPurchaseOrderInfoBo bo = new GetPurchaseOrderInfoBo(purchaseOrderInfo);
110 114 // 判断 contractCreateById 是否等于当前用户 ID
... ... @@ -113,6 +117,16 @@ public class PurchaseOrderInfoController extends DefaultBaseController {
113 117 isCreateBy = true;
114 118 }
115 119 bo.setContractCreateBy(isCreateBy);
  120 + // 最终精简版代码
  121 + if (CollectionUtils.isNotEmpty(roleCodes)) {
  122 + String workshopCode = purchaseOrderInfo.getWorkshopCode();
  123 + // 只有当车间代码在白名单内,且用户拥有对应权限时,才显示上传
  124 + if (Arrays.asList("yfc", "efc", "sfc", "ztfc").contains(workshopCode)) {
  125 + if (roleCodes.contains(workshopCode + "pzglkzjy")) {
  126 + bo.setShowUpload(true);
  127 + }
  128 + }
  129 + }
116 130 return bo;
117 131 }).collect(Collectors.toList());
118 132 }
... ...