Commit cb3b5ce241428ccab6231fa81be092e2cbb9359a
1 parent
afa4f88d
fix: 记录日志
Showing
2 changed files
with
56 additions
and
5 deletions
src/main/java/com/order/erp/domain/OrderOptTypeEnum.java
0 → 100644
1 | +package com.order.erp.domain; | |
2 | + | |
3 | +import lombok.AllArgsConstructor; | |
4 | +import lombok.Getter; | |
5 | + | |
6 | +/** | |
7 | + * @author: xms | |
8 | + * @description: TODO | |
9 | + * @date: 2023/9/13 18:05 | |
10 | + * @version: 1.0 | |
11 | + */ | |
12 | +@Getter | |
13 | +@AllArgsConstructor | |
14 | +public enum OrderOptTypeEnum { | |
15 | + | |
16 | + ORDER_DELETE(-10, "订单删除"), | |
17 | + | |
18 | + ORDER_CREATE(0, "订单创建"), | |
19 | + | |
20 | + ORDER_EDIT(10, "订单编辑"), | |
21 | + | |
22 | + ORDER_FIELD_UNLOCK_APPLY(20, "订单字段解锁申请"), | |
23 | + | |
24 | + ORDER_PROFIT_EDIT_APPLY(30, "利润分析编辑申请"), | |
25 | + | |
26 | + ORDER_REPORT_EDIT_APPLY(40, "项目报告书编辑申请"), | |
27 | + | |
28 | + ; | |
29 | + private Integer type; | |
30 | + | |
31 | + private String desc; | |
32 | +} | ... | ... |
src/main/java/com/order/erp/service/order/impl/OrderBaseInfoServiceImpl.java
... | ... | @@ -20,10 +20,7 @@ import com.order.erp.common.utils.FileUtil; |
20 | 20 | import com.order.erp.common.utils.OrderFieldUtils; |
21 | 21 | import com.order.erp.common.utils.ProfitUtils; |
22 | 22 | import com.order.erp.config.DataScope; |
23 | -import com.order.erp.domain.ApplyStatusEnum; | |
24 | -import com.order.erp.domain.ApplyTypeEnum; | |
25 | -import com.order.erp.domain.OrderLockFieldEnum; | |
26 | -import com.order.erp.domain.OrderStatusEnum; | |
23 | +import com.order.erp.domain.*; | |
27 | 24 | import com.order.erp.domain.dto.BaseDO; |
28 | 25 | import com.order.erp.domain.dto.order.*; |
29 | 26 | import com.order.erp.domain.excel.OrderExcelVO; |
... | ... | @@ -222,6 +219,7 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
222 | 219 | OrderFieldLockApplyDO applyDO = initOrderFieldLockApplyDO(fieldVO, userId); |
223 | 220 | |
224 | 221 | orderFieldLockApplyService.save(applyDO); |
222 | + orderOptLogService.save(buildOrderOptLogDo(fieldVO.getOrderId(), userId, OrderOptTypeEnum.ORDER_FIELD_UNLOCK_APPLY.getDesc(), applyDO.getFields())); | |
225 | 223 | return ServerResult.success(); |
226 | 224 | } |
227 | 225 | |
... | ... | @@ -536,6 +534,7 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
536 | 534 | if (Objects.isNull(baseInfoVO)) { |
537 | 535 | throw new BusinessException(ServerResultCode.ORDER_BASE_INFO_EMPTY); |
538 | 536 | } |
537 | + Long userId = dataScope.getLoginUserId(); | |
539 | 538 | OrderBaseInfoDO baseInfoDO = new OrderBaseInfoDO(); |
540 | 539 | BeanUtils.copyProperties(baseInfoVO, baseInfoDO); |
541 | 540 | baseInfoDO.setOrderStatus(OrderStatusEnum.CREATE_FINISH.getStatus()); |
... | ... | @@ -582,10 +581,23 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
582 | 581 | inspectionStageService.save(inspectionStageDO); |
583 | 582 | } |
584 | 583 | |
584 | + orderOptLogService.save(buildOrderOptLogDo(baseInfoDO.getId(), userId, OrderOptTypeEnum.ORDER_CREATE.getDesc(), null)); | |
585 | + | |
585 | 586 | return ServerResult.success(); |
586 | 587 | } |
587 | 588 | |
588 | 589 | /** |
590 | + * @param orderId | |
591 | + * @param userId | |
592 | + * @param optType | |
593 | + * @param jsonString | |
594 | + * @return | |
595 | + */ | |
596 | + private OrderOptLogDO buildOrderOptLogDo(Long orderId, Long userId, String optType, String jsonString) { | |
597 | + return OrderOptLogDO.builder().orderId(orderId).userId(userId).fields(jsonString).optType(optType).build(); | |
598 | + } | |
599 | + | |
600 | + /** | |
589 | 601 | * 修改数据 |
590 | 602 | * |
591 | 603 | * @param updateVO 实例对象 |
... | ... | @@ -615,6 +627,7 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
615 | 627 | |
616 | 628 | orderBaseInfoDo.setOrderStatus(OrderStatusEnum.PROFIT_WAIT_AUDIT.getStatus()); |
617 | 629 | updateById(orderBaseInfoDo); |
630 | + orderOptLogService.save(buildOrderOptLogDo(updateVO.getOrderId(), userId, OrderOptTypeEnum.ORDER_PROFIT_EDIT_APPLY.getDesc(), orderFieldLockApplyDO.getFields())); | |
618 | 631 | } |
619 | 632 | |
620 | 633 | if (Objects.nonNull(updateVO.getReportInfo())) { |
... | ... | @@ -624,6 +637,7 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
624 | 637 | |
625 | 638 | orderBaseInfoDo.setOrderStatus(OrderStatusEnum.REPORT_WAIT_AUDIT.getStatus()); |
626 | 639 | updateById(orderBaseInfoDo); |
640 | + orderOptLogService.save(buildOrderOptLogDo(updateVO.getOrderId(), userId, OrderOptTypeEnum.ORDER_REPORT_EDIT_APPLY.getDesc(), orderFieldLockApplyDO.getFields())); | |
627 | 641 | } |
628 | 642 | |
629 | 643 | if (Objects.nonNull(updateVO.getTrackStageInfo())) { |
... | ... | @@ -664,6 +678,7 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
664 | 678 | updateById(orderBaseInfoDo); |
665 | 679 | } |
666 | 680 | |
681 | + orderOptLogService.save(buildOrderOptLogDo(updateVO.getOrderId(), userId, OrderOptTypeEnum.ORDER_EDIT.getDesc(), JSONObject.toJSONString(updateVO))); | |
667 | 682 | return ServerResult.success(); |
668 | 683 | } |
669 | 684 | |
... | ... | @@ -680,6 +695,7 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
680 | 695 | if (CollUtil.isEmpty(ids)) { |
681 | 696 | return ServerResult.fail("ids 参数不能为空"); |
682 | 697 | } |
698 | + Long userId = dataScope.getLoginUserId(); | |
683 | 699 | List<OrderBaseInfoDO> orderBaseInfoList = listByIds(ids); |
684 | 700 | if (CollUtil.isEmpty(orderBaseInfoList)) { |
685 | 701 | return ServerResult.success(); |
... | ... | @@ -717,7 +733,10 @@ public class OrderBaseInfoServiceImpl extends ServiceImpl<OrderBaseInfoMapper, O |
717 | 733 | //订单-跟单环节 |
718 | 734 | trackStageService.deleteByOrderIds(ids); |
719 | 735 | |
720 | - | |
736 | + List<OrderOptLogDO> orderOptLogDOS = ids.stream().map(x -> { | |
737 | + return buildOrderOptLogDo(x, userId, OrderOptTypeEnum.ORDER_DELETE.getDesc(), null); | |
738 | + }).collect(Collectors.toList()); | |
739 | + orderOptLogService.saveBatch(orderOptLogDOS); | |
721 | 740 | return ServerResult.success(); |
722 | 741 | } |
723 | 742 | ... | ... |