|
@@ -20,6 +20,7 @@ import com.lframework.starter.web.inner.service.system.SysUserDeptService; |
|
@@ -20,6 +20,7 @@ import com.lframework.starter.web.inner.service.system.SysUserDeptService; |
|
20
|
import com.lframework.starter.web.inner.service.system.SysUserRoleService;
|
20
|
import com.lframework.starter.web.inner.service.system.SysUserRoleService;
|
|
21
|
import com.lframework.xingyun.basedata.entity.Workshop;
|
21
|
import com.lframework.xingyun.basedata.entity.Workshop;
|
|
22
|
import com.lframework.xingyun.basedata.service.workshop.WorkshopService;
|
22
|
import com.lframework.xingyun.basedata.service.workshop.WorkshopService;
|
|
|
|
23
|
+import com.lframework.xingyun.basedata.vo.workshop.QueryWorkshopVo;
|
|
23
|
import com.lframework.xingyun.sc.controller.contract.ContractDistributorStandardController;
|
24
|
import com.lframework.xingyun.sc.controller.contract.ContractDistributorStandardController;
|
|
24
|
import com.lframework.xingyun.sc.entity.*;
|
25
|
import com.lframework.xingyun.sc.entity.*;
|
|
25
|
import com.lframework.starter.web.core.impl.BaseMpServiceImpl;
|
26
|
import com.lframework.starter.web.core.impl.BaseMpServiceImpl;
|
|
@@ -117,10 +118,39 @@ public class ContractDistributorStandardServiceImpl extends |
|
@@ -117,10 +118,39 @@ public class ContractDistributorStandardServiceImpl extends |
|
117
|
if (!"DELETED".equals(vo.getStatus())) { // 不为删除状态,则根据角色查询不同的数据
|
118
|
if (!"DELETED".equals(vo.getStatus())) { // 不为删除状态,则根据角色查询不同的数据
|
|
118
|
String userId = SecurityUtil.getCurrentUser().getId();
|
119
|
String userId = SecurityUtil.getCurrentUser().getId();
|
|
119
|
List<SysRole> sysRoleList = sysRoleService.getByUserId(userId);
|
120
|
List<SysRole> sysRoleList = sysRoleService.getByUserId(userId);
|
|
120
|
- String roleCodeStr = CollectionUtils.emptyIfNull(sysRoleList).stream().map(SysRole::getCode).collect(Collectors.joining(","));
|
|
|
|
121
|
- if (StringUtils.isNotBlank(roleCodeStr) && roleCodeStr.equals(YWY_ROLE_CODE)) { // 业务员只查询自己的数据
|
121
|
+ List<String> roleCodes = sysRoleList.stream()
|
|
|
|
122
|
+ .map(SysRole::getCode) // 提取每个 SysRole 的 code 属性
|
|
|
|
123
|
+ .collect(Collectors.toList());
|
|
|
|
124
|
+ if (CollectionUtils.isNotEmpty(roleCodes) && roleCodes.contains(YWY_ROLE_CODE)) { // 业务员只查询自己的数据
|
|
122
|
vo.setCreateById(userId);
|
125
|
vo.setCreateById(userId);
|
|
123
|
- } else {
|
126
|
+ } else if (CollectionUtils.isNotEmpty(roleCodes) && (roleCodes.contains("yzkzg") || roleCodes.contains("dgfsbscfg")
|
|
|
|
127
|
+ || roleCodes.contains("nbwzbscfg") || roleCodes.contains("szczbfbscfg") || roleCodes.contains("ztbscfg")
|
|
|
|
128
|
+ || roleCodes.contains("sckzg") || roleCodes.contains("scbzg") || roleCodes.contains("yxbzg")
|
|
|
|
129
|
+ || roleCodes.contains("yxzxzg") || roleCodes.contains("zjl") || roleCodes.contains("001"))) {
|
|
|
|
130
|
+ //运作科主管,营销部分管,市场科主管,市场部主管,营销部主管,营销中心主管,总经理,系统管理员可查看所有数据
|
|
|
|
131
|
+ } else if (CollectionUtils.isNotEmpty(roleCodes) && (roleCodes.contains("yfcjybjhy") || roleCodes.contains("efcjybjhy")
|
|
|
|
132
|
+ || roleCodes.contains("sfcjybjhy") || roleCodes.contains("ztfcjybjhy") || roleCodes.contains("yfcjybzg")
|
|
|
|
133
|
+ || roleCodes.contains("efcjybzg") || roleCodes.contains("sfcjybzg") || roleCodes.contains("ztcjybzg"))) {
|
|
|
|
134
|
+ //经营办计划员,经营办主管可以看到自己分厂的数据
|
|
|
|
135
|
+ Set<String> allowedRoles = new HashSet<>(Arrays.asList(
|
|
|
|
136
|
+ "yfcjybjhy", "efcjybjhy", "sfcjybjhy", "ztfcjybjhy",
|
|
|
|
137
|
+ "yfcjybzg", "efcjybzg", "sfcjybzg", "ztcjybzg"
|
|
|
|
138
|
+ ));
|
|
|
|
139
|
+ List<String> matchedRoles = roleCodes.stream()
|
|
|
|
140
|
+ .filter(allowedRoles::contains)
|
|
|
|
141
|
+ .collect(Collectors.toList());
|
|
|
|
142
|
+ Set<String> set = extractPrefixes(matchedRoles);
|
|
|
|
143
|
+ List<String> workshopIdList = new ArrayList<>();
|
|
|
|
144
|
+ for (String code : set) {
|
|
|
|
145
|
+ QueryWorkshopVo vo1 = new QueryWorkshopVo();
|
|
|
|
146
|
+ vo1.setCode(code);
|
|
|
|
147
|
+ List<Workshop> query = workshopService.query(vo1);
|
|
|
|
148
|
+ if (CollectionUtils.isNotEmpty(query)) {
|
|
|
|
149
|
+ workshopIdList.add(query.get(0).getId());
|
|
|
|
150
|
+ }
|
|
|
|
151
|
+ }
|
|
|
|
152
|
+ vo.setWorkshopIdList(workshopIdList);
|
|
|
|
153
|
+ } else {
|
|
124
|
Map<String, List<String>> userIdMap = sysUserDeptService.mapAllUserByUserId(Collections.singletonList(userId), true);
|
154
|
Map<String, List<String>> userIdMap = sysUserDeptService.mapAllUserByUserId(Collections.singletonList(userId), true);
|
|
125
|
vo.setCreateByIdList(CollectionUtils.isEmpty(userIdMap.get(userId)) ? new ArrayList<>(0) : userIdMap.get(userId));
|
155
|
vo.setCreateByIdList(CollectionUtils.isEmpty(userIdMap.get(userId)) ? new ArrayList<>(0) : userIdMap.get(userId));
|
|
126
|
vo.getCreateByIdList().add(userId);
|
156
|
vo.getCreateByIdList().add(userId);
|
|
@@ -156,6 +186,30 @@ public class ContractDistributorStandardServiceImpl extends |
|
@@ -156,6 +186,30 @@ public class ContractDistributorStandardServiceImpl extends |
|
156
|
return PageResultUtil.convert(new PageInfo<>(datas));
|
186
|
return PageResultUtil.convert(new PageInfo<>(datas));
|
|
157
|
}
|
187
|
}
|
|
158
|
|
188
|
|
|
|
|
189
|
+ public static Set<String> extractPrefixes(List<String> matchedRoles) {
|
|
|
|
190
|
+ if (matchedRoles == null) {
|
|
|
|
191
|
+ return Collections.emptySet();
|
|
|
|
192
|
+ }
|
|
|
|
193
|
+
|
|
|
|
194
|
+ return matchedRoles.stream()
|
|
|
|
195
|
+ .filter(Objects::nonNull)
|
|
|
|
196
|
+ .map(role -> {
|
|
|
|
197
|
+ if (role.startsWith("ztfc")) {
|
|
|
|
198
|
+ return "ztfc";
|
|
|
|
199
|
+ } else if (role.startsWith("yfc")) {
|
|
|
|
200
|
+ return "yfc";
|
|
|
|
201
|
+ } else if (role.startsWith("efc")) {
|
|
|
|
202
|
+ return "efc";
|
|
|
|
203
|
+ } else if (role.startsWith("sfc")) {
|
|
|
|
204
|
+ return "sfc";
|
|
|
|
205
|
+ } else {
|
|
|
|
206
|
+ return null; // 不符合前缀,标记为 null 后续过滤
|
|
|
|
207
|
+ }
|
|
|
|
208
|
+ })
|
|
|
|
209
|
+ .filter(Objects::nonNull) // 过滤掉不匹配的角色
|
|
|
|
210
|
+ .collect(Collectors.toSet()); // 自动去重
|
|
|
|
211
|
+ }
|
|
|
|
212
|
+
|
|
159
|
@Override
|
213
|
@Override
|
|
160
|
public List<ContractDistributorStandard> query(QueryContractDistributorStandardVo vo) {
|
214
|
public List<ContractDistributorStandard> query(QueryContractDistributorStandardVo vo) {
|
|
161
|
|
215
|
|