Commit e29b15652c0eeac56c78475f6578daf8809ea66d
1 parent
42bbd60c
fix: 修复导出/编辑利润率/审核列表
Showing
6 changed files
with
88 additions
and
9 deletions
src/main/java/com/order/erp/config/DataScope.java
... | ... | @@ -2,6 +2,7 @@ package com.order.erp.config; |
2 | 2 | |
3 | 3 | import com.order.erp.common.utils.SecurityUtils; |
4 | 4 | import com.order.erp.domain.vo.UserVO; |
5 | +import com.order.erp.domain.vo.admin.AdminResultVO; | |
5 | 6 | import com.order.erp.service.admin.AdminUserService; |
6 | 7 | import org.springframework.stereotype.Component; |
7 | 8 | |
... | ... | @@ -27,10 +28,16 @@ public class DataScope { |
27 | 28 | } |
28 | 29 | |
29 | 30 | /** |
30 | - * | |
31 | 31 | * @return |
32 | 32 | */ |
33 | - public String getLoginUserName(){ | |
33 | + public AdminResultVO isAdmin() { | |
34 | + return userService.isAdmin(SecurityUtils.getUsername()).getData(); | |
35 | + } | |
36 | + | |
37 | + /** | |
38 | + * @return | |
39 | + */ | |
40 | + public String getLoginUserName() { | |
34 | 41 | return SecurityUtils.getUsername(); |
35 | 42 | } |
36 | 43 | ... | ... |
src/main/java/com/order/erp/domain/vo/admin/AdminResultVO.java
0 → 100644
1 | +package com.order.erp.domain.vo.admin; | |
2 | + | |
3 | +import com.order.erp.domain.vo.BasePageVO; | |
4 | +import com.order.erp.domain.vo.UserVO; | |
5 | +import lombok.*; | |
6 | +import lombok.experimental.SuperBuilder; | |
7 | + | |
8 | +import java.io.Serializable; | |
9 | + | |
10 | +/** | |
11 | + * 用户表(AdminUser)实体类 | |
12 | + * | |
13 | + * @author makejava | |
14 | + * @since 2023-08-30 17:51:48 | |
15 | + */ | |
16 | +@Data | |
17 | +@AllArgsConstructor | |
18 | +@ToString | |
19 | +@NoArgsConstructor | |
20 | +@EqualsAndHashCode(callSuper = false) | |
21 | +@SuperBuilder | |
22 | +public class AdminResultVO extends BasePageVO implements Serializable { | |
23 | + | |
24 | + private Boolean isAdmin; | |
25 | + | |
26 | + private UserVO userVO; | |
27 | +} | |
28 | + | ... | ... |
src/main/java/com/order/erp/service/admin/AdminUserService.java
... | ... | @@ -61,6 +61,13 @@ public interface AdminUserService extends IService<AdminUserDO> { |
61 | 61 | ServerResult deleteById(AdminUserQueryVO adminUserQueryVO); |
62 | 62 | |
63 | 63 | /** |
64 | + * | |
65 | + * @param userName | |
66 | + * @return | |
67 | + */ | |
68 | + ServerResult<AdminResultVO> isAdmin(String userName); | |
69 | + | |
70 | + /** | |
64 | 71 | * 修改密码 |
65 | 72 | * |
66 | 73 | * @param pwdVO | ... | ... |
src/main/java/com/order/erp/service/admin/impl/AdminUserServiceImpl.java
... | ... | @@ -14,6 +14,7 @@ import com.order.erp.common.constant.ServerResult; |
14 | 14 | import com.order.erp.common.constant.ServerResultCode; |
15 | 15 | import com.order.erp.common.exception.BusinessException; |
16 | 16 | import com.order.erp.common.utils.ImgCaptchaUtils; |
17 | +import com.order.erp.common.utils.SecurityUtils; | |
17 | 18 | import com.order.erp.common.utils.SmsUtils; |
18 | 19 | import com.order.erp.common.utils.TransactionHelper; |
19 | 20 | import com.order.erp.config.DataScope; |
... | ... | @@ -40,6 +41,7 @@ import org.springframework.stereotype.Service; |
40 | 41 | import javax.annotation.Resource; |
41 | 42 | import java.time.LocalDateTime; |
42 | 43 | import java.util.*; |
44 | +import java.util.concurrent.atomic.AtomicReference; | |
43 | 45 | import java.util.function.Function; |
44 | 46 | import java.util.stream.Collectors; |
45 | 47 | |
... | ... | @@ -180,8 +182,8 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser |
180 | 182 | if (Objects.nonNull(adminUserVO.getId())) { |
181 | 183 | adminUserVO.setId(null); |
182 | 184 | } |
183 | - List<AdminUserDO> userDOS = list(new LambdaQueryWrapper<AdminUserDO>().eq(BaseDO::getEnableFlag,Constant.ENABLE_TEN) | |
184 | - .eq(AdminUserDO::getPhone,adminUserVO.getPhone())); | |
185 | + List<AdminUserDO> userDOS = list(new LambdaQueryWrapper<AdminUserDO>().eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) | |
186 | + .eq(AdminUserDO::getPhone, adminUserVO.getPhone())); | |
185 | 187 | if (CollectionUtils.isNotEmpty(userDOS)) { |
186 | 188 | throw new BusinessException("手机号已被注册"); |
187 | 189 | } |
... | ... | @@ -251,6 +253,26 @@ public class AdminUserServiceImpl extends ServiceImpl<AdminUserMapper, AdminUser |
251 | 253 | return ServerResult.success(); |
252 | 254 | } |
253 | 255 | |
256 | + @Override | |
257 | + public ServerResult<AdminResultVO> isAdmin(String userName) { | |
258 | + UserVO user = findByUserName(SecurityUtils.getUsername()); | |
259 | + if (Objects.isNull(user)) { | |
260 | + throw new BusinessException("用户不存在"); | |
261 | + } | |
262 | + List<AdminUserRoleDO> userRoleDOList = userRoleService.list(new LambdaQueryWrapper<AdminUserRoleDO>() | |
263 | + .eq(AdminUserRoleDO::getUserId, user.getId())); | |
264 | + if (CollectionUtils.isEmpty(userRoleDOList)) { | |
265 | + return ServerResult.success(AdminResultVO.builder().isAdmin(false).userVO(user).build()); | |
266 | + } | |
267 | + AtomicReference<Boolean> result = new AtomicReference<>(false); | |
268 | + userRoleDOList.forEach(x -> { | |
269 | + if (RoleEnum.ADMIN.getId().equals(x.getRoleId())) { | |
270 | + result.set(true); | |
271 | + } | |
272 | + }); | |
273 | + return ServerResult.success(AdminResultVO.builder().isAdmin(result.get()).userVO(user).build()); | |
274 | + } | |
275 | + | |
254 | 276 | /** |
255 | 277 | * 通过主键删除数据 |
256 | 278 | * | ... | ... |
src/main/java/com/order/erp/service/order/impl/OrderBaseInfoServiceImpl.java
... | ... | @@ -302,8 +302,9 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
302 | 302 | } |
303 | 303 | } |
304 | 304 | } |
305 | - OrderProfitAnalysisVO profitAnalysisVO = orderInfoResultVO.getProfitAnalysisInfo(); | |
306 | - if (Objects.nonNull(profitAnalysisFields) && Objects.nonNull(profitAnalysisVO)) { | |
305 | + OrderProfitAnalysisVO profitAnalysisVO = Objects.nonNull(orderInfoResultVO.getProfitAnalysisInfo()) ? | |
306 | + orderInfoResultVO.getProfitAnalysisInfo() : new OrderProfitAnalysisVO(); | |
307 | + if (Objects.nonNull(profitAnalysisFields)) { | |
307 | 308 | if (StringUtils.isNotBlank(profitAnalysisFields.getCustomerPrice())) { |
308 | 309 | map.put("客户单价$", profitAnalysisVO.getCustomerPrice()); |
309 | 310 | } |
... | ... | @@ -329,7 +330,8 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
329 | 330 | map.put("利润率", profitAnalysisVO.getProfitRate()); |
330 | 331 | } |
331 | 332 | } |
332 | - OrderCompletionReportVO reportInfo = orderInfoResultVO.getReportInfo(); | |
333 | + OrderCompletionReportVO reportInfo = Objects.nonNull(orderInfoResultVO.getReportInfo()) ? | |
334 | + orderInfoResultVO.getReportInfo() : new OrderCompletionReportVO(); | |
333 | 335 | if (Objects.nonNull(reportFields) && Objects.nonNull(reportInfo)) { |
334 | 336 | if (StringUtils.isNotBlank(reportFields.getIdeaSource())) { |
335 | 337 | map.put("想法来源", reportInfo.getIdeaSource()); |
... | ... | @@ -341,7 +343,8 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
341 | 343 | map.put("想法和手工比例分配", reportInfo.getIdeaManualRate()); |
342 | 344 | } |
343 | 345 | } |
344 | - OrderTrackStageVO trackStageInfo = orderInfoResultVO.getTrackStageInfo(); | |
346 | + OrderTrackStageVO trackStageInfo = Objects.nonNull(orderInfoResultVO.getTrackStageInfo()) ? | |
347 | + orderInfoResultVO.getTrackStageInfo() : new OrderTrackStageVO(); | |
345 | 348 | if (Objects.nonNull(trackStageFields) && Objects.nonNull(trackStageInfo)) { |
346 | 349 | if (StringUtils.isNotBlank(trackStageFields.getPpTime())) { |
347 | 350 | map.put("pp date", trackStageInfo.getPpTime()); |
... | ... | @@ -380,7 +383,8 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
380 | 383 | map.put("最晚订舱+报关资料时间", trackStageInfo.getLatestBkTime()); |
381 | 384 | } |
382 | 385 | } |
383 | - OrderInspectionStageVO inspectionStageInfo = orderInfoResultVO.getInspectionStageInfo(); | |
386 | + OrderInspectionStageVO inspectionStageInfo = Objects.nonNull(orderInfoResultVO.getInspectionStageInfo()) ? | |
387 | + orderInfoResultVO.getInspectionStageInfo() : new OrderInspectionStageVO(); | |
384 | 388 | if (Objects.nonNull(inspectionStageFields) && Objects.nonNull(inspectionStageInfo)) { |
385 | 389 | if (StringUtils.isNotBlank(inspectionStageFields.getMidCheckApplyTime())) { |
386 | 390 | map.put("中期验货申请时间", inspectionStageInfo.getMidCheckApplyTime()); | ... | ... |
src/main/java/com/order/erp/service/order/impl/OrderFieldLockApplyServiceImpl.java
... | ... | @@ -20,6 +20,7 @@ import com.order.erp.domain.ApplyTypeEnum; |
20 | 20 | import com.order.erp.domain.OrderStatusEnum; |
21 | 21 | import com.order.erp.domain.dto.BaseDO; |
22 | 22 | import com.order.erp.domain.dto.order.*; |
23 | +import com.order.erp.domain.vo.admin.AdminResultVO; | |
23 | 24 | import com.order.erp.domain.vo.order.*; |
24 | 25 | import com.order.erp.mapper.order.OrderFieldLockApplyMapper; |
25 | 26 | import com.order.erp.service.order.*; |
... | ... | @@ -299,6 +300,10 @@ public class OrderFieldLockApplyServiceImpl extends ServiceImpl<OrderFieldLockAp |
299 | 300 | * @return |
300 | 301 | */ |
301 | 302 | private LambdaQueryWrapper<OrderFieldLockApplyDO> buildQueryByParam(OrderFieldLockApplyQueryVO queryVO) { |
303 | + AdminResultVO resultVO = dataScope.isAdmin(); | |
304 | + if (!resultVO.getIsAdmin()) { | |
305 | + queryVO.setApplyUserId(Objects.nonNull(resultVO.getUserVO()) ? resultVO.getUserVO().getId() : -1); | |
306 | + } | |
302 | 307 | return new LambdaQueryWrapper<OrderFieldLockApplyDO>() |
303 | 308 | .eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) |
304 | 309 | .eq(Objects.nonNull(queryVO.getApplyUserId()), OrderFieldLockApplyDO::getApplyUserId, queryVO.getApplyUserId()) |
... | ... | @@ -442,11 +447,14 @@ public class OrderFieldLockApplyServiceImpl extends ServiceImpl<OrderFieldLockAp |
442 | 447 | profitAnalysisDO.setOrderStatus(OrderStatusEnum.PROFIT_AUDIT_PASS.getStatus()); |
443 | 448 | profitAnalysisDO.setCustomerPrice(Objects.nonNull(profitAnalysisFieldVO.getCustomerPrice()) ? Double.valueOf(profitAnalysisFieldVO.getCustomerPrice()) : null); |
444 | 449 | profitAnalysisDO.setCustomerTotalPrice(Objects.nonNull(profitAnalysisFieldVO.getCustomerTotalPrice()) ? Double.valueOf(profitAnalysisFieldVO.getCustomerTotalPrice()) : null); |
450 | + profitAnalysisDO.setCustomerCurrency(StringUtils.isNotBlank(profitAnalysisFieldVO.getCustomerCurrency()) ? profitAnalysisFieldVO.getCustomerCurrency() : null); | |
445 | 451 | profitAnalysisDO.setExchangeRate(Objects.nonNull(profitAnalysisFieldVO.getExchangeRate()) ? Double.valueOf(profitAnalysisFieldVO.getExchangeRate()) : null); |
446 | 452 | profitAnalysisDO.setPacketPrice(Objects.nonNull(profitAnalysisFieldVO.getPacketPrice()) ? Double.valueOf(profitAnalysisFieldVO.getPacketPrice()) : null); |
453 | + profitAnalysisDO.setPacketCurrency(StringUtils.isNotBlank(profitAnalysisFieldVO.getPacketCurrency()) ? profitAnalysisFieldVO.getPacketCurrency() : null); | |
447 | 454 | profitAnalysisDO.setPacketTotalPrice(Objects.nonNull(profitAnalysisFieldVO.getPacketTotalPrice()) ? Double.valueOf(profitAnalysisFieldVO.getPacketTotalPrice()) : null); |
448 | 455 | profitAnalysisDO.setProductionDepartmentPrice(Objects.nonNull(profitAnalysisFieldVO.getProductionDepartmentPrice()) ? Double.valueOf(profitAnalysisFieldVO.getProductionDepartmentPrice()) : null); |
449 | 456 | profitAnalysisDO.setProductionDepartmentTotalPrice(Objects.nonNull(profitAnalysisFieldVO.getProductionDepartmentTotalPrice()) ? Double.valueOf(profitAnalysisFieldVO.getProductionDepartmentTotalPrice()) : null); |
457 | + profitAnalysisDO.setProductionDepartmentCurrency(StringUtils.isNotBlank(profitAnalysisFieldVO.getProductionDepartmentCurrency()) ? profitAnalysisFieldVO.getProductionDepartmentCurrency() : null); | |
450 | 458 | profitAnalysisDO.setProfitRate(Objects.nonNull(profitAnalysisFieldVO.getProfitRate()) ? Double.valueOf(profitAnalysisFieldVO.getProfitRate()) : null); |
451 | 459 | profitAnalysisDO.setProfitType(profitAnalysisFieldVO.getProfitType()); |
452 | 460 | profitAnalysisService.updateById(profitAnalysisDO); |
... | ... | @@ -485,11 +493,14 @@ public class OrderFieldLockApplyServiceImpl extends ServiceImpl<OrderFieldLockAp |
485 | 493 | .profitType(profitAnalysisFieldVO.getProfitType()) |
486 | 494 | .customerPrice(Objects.nonNull(profitAnalysisFieldVO.getCustomerPrice()) ? Double.valueOf(profitAnalysisFieldVO.getCustomerPrice()) : null) |
487 | 495 | .customerTotalPrice(Objects.nonNull(profitAnalysisFieldVO.getCustomerTotalPrice()) ? Double.valueOf(profitAnalysisFieldVO.getCustomerTotalPrice()) : null) |
496 | + .customerCurrency(StringUtils.isNotBlank(profitAnalysisFieldVO.getCustomerCurrency()) ? profitAnalysisFieldVO.getCustomerCurrency() : null) | |
488 | 497 | .exchangeRate(Objects.nonNull(profitAnalysisFieldVO.getExchangeRate()) ? Double.valueOf(profitAnalysisFieldVO.getExchangeRate()) : null) |
489 | 498 | .packetPrice(Objects.nonNull(profitAnalysisFieldVO.getPacketPrice()) ? Double.valueOf(profitAnalysisFieldVO.getPacketPrice()) : null) |
490 | 499 | .packetTotalPrice(Objects.nonNull(profitAnalysisFieldVO.getPacketTotalPrice()) ? Double.valueOf(profitAnalysisFieldVO.getPacketTotalPrice()) : null) |
500 | + .packetCurrency(StringUtils.isNotBlank(profitAnalysisFieldVO.getPacketCurrency()) ? profitAnalysisFieldVO.getPacketCurrency() : null) | |
491 | 501 | .productionDepartmentPrice(Objects.nonNull(profitAnalysisFieldVO.getProductionDepartmentPrice()) ? Double.valueOf(profitAnalysisFieldVO.getProductionDepartmentPrice()) : null) |
492 | 502 | .productionDepartmentTotalPrice(Objects.nonNull(profitAnalysisFieldVO.getProductionDepartmentTotalPrice()) ? Double.valueOf(profitAnalysisFieldVO.getProductionDepartmentTotalPrice()) : null) |
503 | + .productionDepartmentCurrency(StringUtils.isNotBlank(profitAnalysisFieldVO.getProductionDepartmentCurrency()) ? profitAnalysisFieldVO.getProductionDepartmentCurrency() : null) | |
493 | 504 | .profitRate(Objects.nonNull(profitAnalysisFieldVO.getProfitRate()) ? Double.valueOf(profitAnalysisFieldVO.getProfitRate()) : null) |
494 | 505 | .build(); |
495 | 506 | } | ... | ... |