Commit 7fe47dff73161c525fb355f708f1cdb2eba171aa
Merge remote-tracking branch 'origin/master' into zhongnanhuang
Showing
8 changed files
with
202 additions
and
17 deletions
src/main/java/com/order/erp/common/utils/ProfitUtils.java
0 → 100644
1 | +package com.order.erp.common.utils; | ||
2 | + | ||
3 | +import com.order.erp.domain.vo.order.ProfitCalculateVO; | ||
4 | + | ||
5 | +import java.math.BigDecimal; | ||
6 | + | ||
7 | +/** | ||
8 | + * @author: xms | ||
9 | + * @description: TODO | ||
10 | + * @date: 2023/10/23 10:51 | ||
11 | + * @version: 1.0 | ||
12 | + */ | ||
13 | +public class ProfitUtils { | ||
14 | + | ||
15 | + /** | ||
16 | + * 计算利润率 | ||
17 | + * 1 - (生产科总价/汇率 + 包装费用总价)/客单总价 | ||
18 | + * | ||
19 | + * @param calculateVO | ||
20 | + * @return | ||
21 | + */ | ||
22 | + public static double calculateProfitRate(ProfitCalculateVO calculateVO) { | ||
23 | + BigDecimal productionDepartmentTotalPrice = new BigDecimal(calculateVO.getProductionDepartmentTotalPrice()); | ||
24 | + | ||
25 | + BigDecimal exchangeRate = new BigDecimal(calculateVO.getExchangeRate()); | ||
26 | + | ||
27 | + BigDecimal packetTotalPrice = new BigDecimal(calculateVO.getPacketTotalPrice()); | ||
28 | + | ||
29 | + BigDecimal customerTotalPrice = new BigDecimal(calculateVO.getCustomerTotalPrice()); | ||
30 | + | ||
31 | + return new BigDecimal(1).subtract((productionDepartmentTotalPrice.divide(exchangeRate).add(packetTotalPrice)).divide(customerTotalPrice)).doubleValue(); | ||
32 | + } | ||
33 | +} |
src/main/java/com/order/erp/common/utils/SecurityUtils.java
@@ -18,7 +18,7 @@ public class SecurityUtils { | @@ -18,7 +18,7 @@ public class SecurityUtils { | ||
18 | try { | 18 | try { |
19 | userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); | 19 | userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); |
20 | } catch (Exception e) { | 20 | } catch (Exception e) { |
21 | - throw new BusinessException(ServerResultCode.PARAM_ERROR); | 21 | + throw new BusinessException(ServerResultCode.UNAUTHENTICATION); |
22 | } | 22 | } |
23 | return userDetails; | 23 | return userDetails; |
24 | } | 24 | } |
src/main/java/com/order/erp/controller/OrderController.java
@@ -3,10 +3,7 @@ package com.order.erp.controller; | @@ -3,10 +3,7 @@ package com.order.erp.controller; | ||
3 | import com.order.erp.common.annotation.AnonymousAccess; | 3 | import com.order.erp.common.annotation.AnonymousAccess; |
4 | import com.order.erp.common.constant.ServerResult; | 4 | import com.order.erp.common.constant.ServerResult; |
5 | import com.order.erp.common.excel4j.exceptions.Excel4JException; | 5 | import com.order.erp.common.excel4j.exceptions.Excel4JException; |
6 | -import com.order.erp.domain.vo.order.OrderAddVO; | ||
7 | -import com.order.erp.domain.vo.order.OrderBaseInfoQueryVO; | ||
8 | -import com.order.erp.domain.vo.order.OrderBaseInfoVO; | ||
9 | -import com.order.erp.domain.vo.order.OrderUnlockFieldApplyVO; | 6 | +import com.order.erp.domain.vo.order.*; |
10 | import com.order.erp.service.order.OrderBaseInfoService; | 7 | import com.order.erp.service.order.OrderBaseInfoService; |
11 | import org.springframework.validation.annotation.Validated; | 8 | import org.springframework.validation.annotation.Validated; |
12 | import org.springframework.web.bind.annotation.PostMapping; | 9 | import org.springframework.web.bind.annotation.PostMapping; |
@@ -96,12 +93,12 @@ public class OrderController { | @@ -96,12 +93,12 @@ public class OrderController { | ||
96 | /** | 93 | /** |
97 | * 编辑数据 | 94 | * 编辑数据 |
98 | * | 95 | * |
99 | - * @param orderBaseInfoVO 数据VO | 96 | + * @param updateVO 数据VO |
100 | * @return 编辑结果 | 97 | * @return 编辑结果 |
101 | */ | 98 | */ |
102 | @PostMapping("/edit") | 99 | @PostMapping("/edit") |
103 | - public ServerResult edit(@RequestBody OrderBaseInfoVO orderBaseInfoVO) { | ||
104 | - return orderBaseInfoService.edit(orderBaseInfoVO); | 100 | + public ServerResult edit(@RequestBody OrderUpdateVO updateVO) { |
101 | + return orderBaseInfoService.edit(updateVO); | ||
105 | } | 102 | } |
106 | 103 | ||
107 | /** | 104 | /** |
src/main/java/com/order/erp/domain/vo/order/OrderUpdateVO.java
0 → 100644
1 | +package com.order.erp.domain.vo.order; | ||
2 | + | ||
3 | +import lombok.*; | ||
4 | +import lombok.experimental.SuperBuilder; | ||
5 | + | ||
6 | +import java.io.Serializable; | ||
7 | + | ||
8 | +/** | ||
9 | + * 订单基础信息表(OrderBaseInfo)实体类 | ||
10 | + * | ||
11 | + * @author makejava | ||
12 | + * @since 2023-09-08 15:26:43 | ||
13 | + */ | ||
14 | +@Data | ||
15 | +@AllArgsConstructor | ||
16 | +@ToString | ||
17 | +@NoArgsConstructor | ||
18 | +@EqualsAndHashCode(callSuper = false) | ||
19 | +@SuperBuilder | ||
20 | +public class OrderUpdateVO implements Serializable { | ||
21 | + | ||
22 | + /** | ||
23 | + * 订单id | ||
24 | + */ | ||
25 | + private Long orderId; | ||
26 | + | ||
27 | + /** | ||
28 | + * 订单基础信息 | ||
29 | + */ | ||
30 | + private OrderBaseInfoVO baseInfo; | ||
31 | + | ||
32 | + /** | ||
33 | + * 利润分析信息 | ||
34 | + */ | ||
35 | + private OrderProfitAnalysisVO profitAnalysisInfo; | ||
36 | + | ||
37 | + /** | ||
38 | + * 项目完成报告信息 | ||
39 | + */ | ||
40 | + private OrderCompletionReportVO reportInfo; | ||
41 | + | ||
42 | + /** | ||
43 | + * 跟单信息 | ||
44 | + */ | ||
45 | + private OrderTrackStageVO trackStageInfo; | ||
46 | + | ||
47 | + /** | ||
48 | + * 质检信息 | ||
49 | + */ | ||
50 | + private OrderInspectionStageVO inspectionStageInfo; | ||
51 | + | ||
52 | +} |
src/main/java/com/order/erp/domain/vo/order/ProfitCalculateVO.java
0 → 100644
1 | +package com.order.erp.domain.vo.order; | ||
2 | + | ||
3 | +import lombok.*; | ||
4 | +import lombok.experimental.SuperBuilder; | ||
5 | + | ||
6 | +import java.io.Serializable; | ||
7 | + | ||
8 | +/** | ||
9 | + * 订单利润分析表(OrderProfitAnalysis)实体类 | ||
10 | + * | ||
11 | + * @author makejava | ||
12 | + * @since 2023-09-08 15:26:47 | ||
13 | + */ | ||
14 | +@Data | ||
15 | +@AllArgsConstructor | ||
16 | +@ToString | ||
17 | +@NoArgsConstructor | ||
18 | +@EqualsAndHashCode(callSuper = false) | ||
19 | +@SuperBuilder | ||
20 | +public class ProfitCalculateVO implements Serializable { | ||
21 | + | ||
22 | + /** | ||
23 | + * 客户总价$ | ||
24 | + */ | ||
25 | + private Double customerTotalPrice; | ||
26 | + /** | ||
27 | + * 生成科总价¥ | ||
28 | + */ | ||
29 | + private Double productionDepartmentTotalPrice; | ||
30 | + /** | ||
31 | + * 包装费用合计¥ | ||
32 | + */ | ||
33 | + private Double packetTotalPrice; | ||
34 | + /** | ||
35 | + * 汇率 | ||
36 | + */ | ||
37 | + private Double exchangeRate; | ||
38 | + | ||
39 | + | ||
40 | +} |
src/main/java/com/order/erp/service/order/OrderBaseInfoService.java
@@ -67,10 +67,10 @@ public interface OrderBaseInfoService extends IService<OrderBaseInfoDO> { | @@ -67,10 +67,10 @@ public interface OrderBaseInfoService extends IService<OrderBaseInfoDO> { | ||
67 | /** | 67 | /** |
68 | * 修改数据 | 68 | * 修改数据 |
69 | * | 69 | * |
70 | - * @param orderBaseInfoVO 数据VO | 70 | + * @param updateVO 数据VO |
71 | * @return 编辑结果 | 71 | * @return 编辑结果 |
72 | */ | 72 | */ |
73 | - ServerResult edit(OrderBaseInfoVO orderBaseInfoVO); | 73 | + ServerResult edit(OrderUpdateVO updateVO); |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * 通过主键删除数据 | 76 | * 通过主键删除数据 |
src/main/java/com/order/erp/service/order/impl/OrderBaseInfoServiceImpl.java
@@ -10,13 +10,14 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; | @@ -10,13 +10,14 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; | ||
10 | import com.baomidou.mybatisplus.core.toolkit.StringUtils; | 10 | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
11 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 11 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
12 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 12 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
13 | -import com.order.erp.common.constant.ServerResultCode; | ||
14 | import com.order.erp.common.constant.Constant; | 13 | import com.order.erp.common.constant.Constant; |
15 | import com.order.erp.common.constant.ServerResult; | 14 | import com.order.erp.common.constant.ServerResult; |
15 | +import com.order.erp.common.constant.ServerResultCode; | ||
16 | import com.order.erp.common.excel4j.ExcelUtils; | 16 | import com.order.erp.common.excel4j.ExcelUtils; |
17 | import com.order.erp.common.excel4j.exceptions.Excel4JException; | 17 | import com.order.erp.common.excel4j.exceptions.Excel4JException; |
18 | import com.order.erp.common.exception.BusinessException; | 18 | import com.order.erp.common.exception.BusinessException; |
19 | import com.order.erp.common.utils.OrderFieldUtils; | 19 | import com.order.erp.common.utils.OrderFieldUtils; |
20 | +import com.order.erp.common.utils.ProfitUtils; | ||
20 | import com.order.erp.config.DataScope; | 21 | import com.order.erp.config.DataScope; |
21 | import com.order.erp.domain.ApplyStatusEnum; | 22 | import com.order.erp.domain.ApplyStatusEnum; |
22 | import com.order.erp.domain.ApplyTypeEnum; | 23 | import com.order.erp.domain.ApplyTypeEnum; |
@@ -405,6 +406,7 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O | @@ -405,6 +406,7 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O | ||
405 | .eq(StringUtils.isNotBlank(queryVO.getProductStyle()), OrderBaseInfoDO::getProductStyle, queryVO.getProductStyle()) | 406 | .eq(StringUtils.isNotBlank(queryVO.getProductStyle()), OrderBaseInfoDO::getProductStyle, queryVO.getProductStyle()) |
406 | .eq(StringUtils.isNotBlank(queryVO.getOutboundType()), OrderBaseInfoDO::getOutboundType, queryVO.getOutboundType()) | 407 | .eq(StringUtils.isNotBlank(queryVO.getOutboundType()), OrderBaseInfoDO::getOutboundType, queryVO.getOutboundType()) |
407 | .eq(StringUtils.isNotBlank(queryVO.getPacketType()), OrderBaseInfoDO::getPacketType, queryVO.getPacketType()) | 408 | .eq(StringUtils.isNotBlank(queryVO.getPacketType()), OrderBaseInfoDO::getPacketType, queryVO.getPacketType()) |
409 | + .orderByDesc(OrderBaseInfoDO::getId) | ||
408 | ; | 410 | ; |
409 | } | 411 | } |
410 | 412 | ||
@@ -431,6 +433,11 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O | @@ -431,6 +433,11 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O | ||
431 | BeanUtils.copyProperties(profitAnalysisVO, profitAnalysisDO); | 433 | BeanUtils.copyProperties(profitAnalysisVO, profitAnalysisDO); |
432 | profitAnalysisDO.setOrderId(baseInfoDO.getId()); | 434 | profitAnalysisDO.setOrderId(baseInfoDO.getId()); |
433 | profitAnalysisDO.setOrderStatus(OrderStatusEnum.PROFIT_WAIT_AUDIT.getStatus()); | 435 | profitAnalysisDO.setOrderStatus(OrderStatusEnum.PROFIT_WAIT_AUDIT.getStatus()); |
436 | + profitAnalysisDO.setProfitRate(ProfitUtils.calculateProfitRate(ProfitCalculateVO.builder() | ||
437 | + .customerTotalPrice(profitAnalysisDO.getCustomerTotalPrice()) | ||
438 | + .exchangeRate(profitAnalysisDO.getExchangeRate()) | ||
439 | + .packetTotalPrice(profitAnalysisDO.getPacketTotalPrice()) | ||
440 | + .productionDepartmentTotalPrice(profitAnalysisDO.getProductionDepartmentTotalPrice()).build())); | ||
434 | profitAnalysisService.save(profitAnalysisDO); | 441 | profitAnalysisService.save(profitAnalysisDO); |
435 | } | 442 | } |
436 | 443 | ||
@@ -467,18 +474,74 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O | @@ -467,18 +474,74 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O | ||
467 | /** | 474 | /** |
468 | * 修改数据 | 475 | * 修改数据 |
469 | * | 476 | * |
470 | - * @param orderBaseInfoVO 实例对象 | 477 | + * @param updateVO 实例对象 |
471 | * @return 实例对象 | 478 | * @return 实例对象 |
472 | */ | 479 | */ |
473 | @Override | 480 | @Override |
474 | - public ServerResult edit(OrderBaseInfoVO orderBaseInfoVO) { | 481 | + public ServerResult edit(OrderUpdateVO updateVO) { |
475 | //todo 校验 | 482 | //todo 校验 |
476 | - if (Objects.isNull(orderBaseInfoVO.getId())) { | 483 | + if (Objects.isNull(updateVO.getOrderId())) { |
477 | return ServerResult.fail("id 不能为空"); | 484 | return ServerResult.fail("id 不能为空"); |
478 | } | 485 | } |
479 | - OrderBaseInfoDO orderBaseInfoDo = BeanUtil.copyProperties(orderBaseInfoVO, OrderBaseInfoDO.class); | 486 | + if (Objects.nonNull(updateVO.getBaseInfo())) { |
487 | + OrderBaseInfoDO orderBaseInfoDo = BeanUtil.copyProperties(updateVO.getBaseInfo(), OrderBaseInfoDO.class); | ||
488 | + orderBaseInfoDo.setId(updateVO.getOrderId()); | ||
489 | + updateById(orderBaseInfoDo); | ||
490 | + } | ||
491 | + if (Objects.nonNull(updateVO.getProfitAnalysisInfo())) { | ||
492 | + OrderProfitAnalysisDO profitAnalysisDO = profitAnalysisService.getOne(new LambdaQueryWrapper<OrderProfitAnalysisDO>() | ||
493 | + .eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) | ||
494 | + .eq(OrderProfitAnalysisDO::getOrderId, updateVO.getOrderId())); | ||
495 | + if (Objects.nonNull(profitAnalysisDO)) { | ||
496 | + BeanUtils.copyProperties(updateVO.getProfitAnalysisInfo(), profitAnalysisDO); | ||
497 | + profitAnalysisDO.setOrderId(updateVO.getOrderId()); | ||
498 | + profitAnalysisDO.setOrderStatus(OrderStatusEnum.PROFIT_WAIT_AUDIT.getStatus()); | ||
499 | + profitAnalysisDO.setProfitRate(ProfitUtils.calculateProfitRate(ProfitCalculateVO.builder() | ||
500 | + .customerTotalPrice(profitAnalysisDO.getCustomerTotalPrice()) | ||
501 | + .exchangeRate(profitAnalysisDO.getExchangeRate()) | ||
502 | + .packetTotalPrice(profitAnalysisDO.getPacketTotalPrice()) | ||
503 | + .productionDepartmentTotalPrice(profitAnalysisDO.getProductionDepartmentTotalPrice()).build())); | ||
504 | + profitAnalysisService.updateById(profitAnalysisDO); | ||
505 | + } | ||
506 | + } | ||
507 | + | ||
508 | + if (Objects.nonNull(updateVO.getReportInfo())) { | ||
509 | + OrderCompletionReportDO reportDO = reportService.getOne(new LambdaQueryWrapper<OrderCompletionReportDO>() | ||
510 | + .eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) | ||
511 | + .eq(OrderCompletionReportDO::getOrderId, updateVO.getOrderId())); | ||
512 | + if (Objects.nonNull(reportDO)) { | ||
513 | + BeanUtils.copyProperties(updateVO.getReportInfo(), reportDO); | ||
514 | + reportDO.setOrderId(updateVO.getOrderId()); | ||
515 | + reportDO.setOrderStatus(OrderStatusEnum.REPORT_WAIT_AUDIT.getStatus()); | ||
516 | + reportService.updateById(reportDO); | ||
517 | + } | ||
518 | + } | ||
480 | 519 | ||
481 | - updateById(orderBaseInfoDo); | 520 | + if (Objects.nonNull(updateVO.getTrackStageInfo())) { |
521 | + OrderTrackStageDO trackStageDO = trackStageService.getOne(new LambdaQueryWrapper<OrderTrackStageDO>() | ||
522 | + .eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) | ||
523 | + .eq(OrderTrackStageDO::getOrderId, updateVO.getOrderId())); | ||
524 | + if (Objects.nonNull(trackStageDO)) { | ||
525 | + BeanUtils.copyProperties(updateVO.getTrackStageInfo(), trackStageDO); | ||
526 | + trackStageDO.setOrderId(updateVO.getOrderId()); | ||
527 | + trackStageDO.setOrderStatus(OrderStatusEnum.TRACK_ING.getStatus()); | ||
528 | + trackStageService.updateById(trackStageDO); | ||
529 | + } | ||
530 | + | ||
531 | + } | ||
532 | + | ||
533 | + if (Objects.nonNull(updateVO.getInspectionStageInfo())) { | ||
534 | + OrderInspectionStageDO inspectionStageDO = inspectionStageService.getOne(new LambdaQueryWrapper<OrderInspectionStageDO>() | ||
535 | + .eq(BaseDO::getEnableFlag, Constant.ENABLE_TEN) | ||
536 | + .eq(OrderInspectionStageDO::getOrderId, updateVO.getOrderId())); | ||
537 | + if (Objects.nonNull(inspectionStageDO)) { | ||
538 | + BeanUtils.copyProperties(updateVO.getInspectionStageInfo(), inspectionStageDO); | ||
539 | + inspectionStageDO.setOrderId(updateVO.getOrderId()); | ||
540 | + inspectionStageDO.setOrderStatus(OrderStatusEnum.INSPECT_ING.getStatus()); | ||
541 | + inspectionStageService.updateById(inspectionStageDO); | ||
542 | + } | ||
543 | + | ||
544 | + } | ||
482 | 545 | ||
483 | return ServerResult.success(); | 546 | return ServerResult.success(); |
484 | } | 547 | } |
src/main/resources/application-local.yml
@@ -129,7 +129,7 @@ jwt: | @@ -129,7 +129,7 @@ jwt: | ||
129 | # 必须使用最少88位的Base64对该令牌进行编码 | 129 | # 必须使用最少88位的Base64对该令牌进行编码 |
130 | base64-secret: ZmQ0ZGI5NjQ0MDQwY2I4MjMxY2Y3ZmI3MjdhN2ZmMjNhODViOTg1ZGE0NTBjMGM4NDA5NzYxMjdjOWMwYWRmZTBlZjlhNGY3ZTg4Y2U3YTE1ODVkZDU5Y2Y3OGYwZWE1NzUzNWQ2YjFjZDc0NGMxZWU2MmQ3MjY1NzJmNTE0MzI= | 130 | base64-secret: ZmQ0ZGI5NjQ0MDQwY2I4MjMxY2Y3ZmI3MjdhN2ZmMjNhODViOTg1ZGE0NTBjMGM4NDA5NzYxMjdjOWMwYWRmZTBlZjlhNGY3ZTg4Y2U3YTE1ODVkZDU5Y2Y3OGYwZWE1NzUzNWQ2YjFjZDc0NGMxZWU2MmQ3MjY1NzJmNTE0MzI= |
131 | # 令牌过期时间 此处单位/毫秒 ,默认2小时,可在此网站生成 https://www.convertworld.com/zh-hans/time/milliseconds.html | 131 | # 令牌过期时间 此处单位/毫秒 ,默认2小时,可在此网站生成 https://www.convertworld.com/zh-hans/time/milliseconds.html |
132 | - token-validity-in-seconds: 7200000 | 132 | + token-validity-in-seconds: 720000000 |
133 | # 在线用户key | 133 | # 在线用户key |
134 | online-key: online-token | 134 | online-key: online-token |
135 | # 验证码 | 135 | # 验证码 |