|
|
@@ -0,0 +1,194 @@
|
|
|
+package com.jzg.organization.aop;
|
|
|
+
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.jzg.commons.entity.finance.vo.BatchModifyVo;
|
|
|
+import com.jzg.commons.entity.orders.po.InsOrders;
|
|
|
+import com.jzg.commons.entity.orders.po.InsOrdersCarInfo;
|
|
|
+import com.jzg.commons.entity.orders.po.InsOrdersTrack;
|
|
|
+import com.jzg.commons.entity.vo.PtlAgreementCostRatioVo;
|
|
|
+import com.jzg.commons.entity.vo.QuestionOrder;
|
|
|
+import com.jzg.organization.client.InsOrdersClient;
|
|
|
+import com.jzg.quotation.summary.aop.aspect.OrderOperationLog;
|
|
|
+import org.aspectj.lang.ProceedingJoinPoint;
|
|
|
+import org.aspectj.lang.annotation.Around;
|
|
|
+import org.aspectj.lang.annotation.Aspect;
|
|
|
+import org.aspectj.lang.reflect.MethodSignature;
|
|
|
+import org.hibernate.validator.internal.util.stereotypes.Lazy;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.expression.EvaluationContext;
|
|
|
+import org.springframework.expression.ExpressionParser;
|
|
|
+import org.springframework.expression.spel.standard.SpelExpressionParser;
|
|
|
+import org.springframework.expression.spel.support.StandardEvaluationContext;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Aspect
|
|
|
+@Component
|
|
|
+public class OrderOperationLogAspect {
|
|
|
+
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(OrderOperationLogAspect.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ @Lazy
|
|
|
+ private InsOrdersClient insOrdersClient;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Around("@annotation(log)")
|
|
|
+ public Object handleLog(ProceedingJoinPoint joinPoint, OrderOperationLog log) throws Throwable {
|
|
|
+ // 获取方法信息和参数
|
|
|
+ MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
|
|
+ Object[] args = joinPoint.getArgs();
|
|
|
+ logger.info("订单相关的参数:args=[{}]", JSONUtil.toJsonStr(args));
|
|
|
+ String[] paramNames = signature.getParameterNames();
|
|
|
+ // 设置 SpEL 上下文
|
|
|
+ EvaluationContext context = new StandardEvaluationContext();
|
|
|
+ for (int i = 0; i < args.length; i++) {
|
|
|
+ context.setVariable(paramNames[i], args[i]); // 命名参数:#dto
|
|
|
+ context.setVariable("p" + i, args[i]); // 索引参数:#p0
|
|
|
+ }
|
|
|
+ ExpressionParser parser = new SpelExpressionParser();
|
|
|
+ Object result = null;
|
|
|
+ switch (log.optType().getCode()){
|
|
|
+ // 费用调整
|
|
|
+ case 15:
|
|
|
+ logger.info("费用调整log.orderSpEl()=[{}]",log.orderSpEl());
|
|
|
+ PtlAgreementCostRatioVo vo = parser.parseExpression(log.orderSpEl()).getValue(context, PtlAgreementCostRatioVo.class);
|
|
|
+ result = joinPoint.proceed();
|
|
|
+ this.saveCostInfo(result,log, vo);
|
|
|
+ break;
|
|
|
+ // 批量修改比例
|
|
|
+ case 16:
|
|
|
+ logger.info("批量修改比例.log.orderSpEl()=[{}]",log.orderSpEl());
|
|
|
+ BatchModifyVo batchModifyVo = parser.parseExpression(log.orderSpEl()).getValue(context, BatchModifyVo.class);
|
|
|
+ result = joinPoint.proceed();
|
|
|
+ this.batchModify(result,log, batchModifyVo);
|
|
|
+ break;
|
|
|
+ // 设为疑问订单
|
|
|
+ case 17:
|
|
|
+ logger.info("设置为疑问订单.log.orderSpEl()=[{}]",log.orderSpEl());
|
|
|
+ QuestionOrder questionOrder = parser.parseExpression(log.orderSpEl()).getValue(context, QuestionOrder.class);
|
|
|
+ result = joinPoint.proceed();
|
|
|
+ this.updateToQuestionOrder(result,log, questionOrder);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 设置为疑问订单
|
|
|
+ *
|
|
|
+ * @author lipf
|
|
|
+ * @date 2026/7/16 16:35
|
|
|
+ */
|
|
|
+ private void updateToQuestionOrder(Object result, OrderOperationLog log, QuestionOrder questionOrder) {
|
|
|
+ logger.info("设置为疑问订单。questionOrder=[{}]", JSONUtil.toJsonStr(questionOrder));
|
|
|
+ InsOrdersTrack track = new InsOrdersTrack();
|
|
|
+ track.setModule(log.module());
|
|
|
+ track.setSubModule(log.subModule());
|
|
|
+ track.setOptType(log.optType().getCode());
|
|
|
+ track.setOptContent(log.description());
|
|
|
+ track.setChangeAfter(JSONUtil.toJsonStr(questionOrder));
|
|
|
+ track.setResult(JSONUtil.toJsonStr(result));
|
|
|
+ InsOrders insOrders = insOrdersClient.getById(questionOrder.getOrderNo());
|
|
|
+ if(insOrders != null){
|
|
|
+ InsOrdersCarInfo carInfo = insOrdersClient.getByOrderId(insOrders.getId());
|
|
|
+ track.setLicenseNo(carInfo.getLicenseNo());
|
|
|
+ track.setCompanyId(insOrders.getCompanyId());
|
|
|
+ // track.setResult(result.getMsg());
|
|
|
+ }else{
|
|
|
+ track.setResult("要设置位疑问订单的订单不存在");
|
|
|
+ }
|
|
|
+ track.setStatus(1);
|
|
|
+ track.setOrderNo(questionOrder.getOrderNo());
|
|
|
+ insOrdersClient.save(track);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 批量修改比例
|
|
|
+ *
|
|
|
+ * @author lipf
|
|
|
+ * @date 2026/7/8 15:29
|
|
|
+ */
|
|
|
+ private void batchModify(Object result, OrderOperationLog log, BatchModifyVo vo) {
|
|
|
+ List<String> orderNos = vo.getOrderNos();
|
|
|
+ if(CollUtil.isEmpty(orderNos)){
|
|
|
+ logger.info("批量修改没有传入订单号");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (String orderNo : orderNos) {
|
|
|
+ InsOrdersTrack track = new InsOrdersTrack();
|
|
|
+ track.setModule(log.module());
|
|
|
+ track.setSubModule(log.subModule());
|
|
|
+ track.setOptType(log.optType().getCode());
|
|
|
+ track.setOptContent(log.description());
|
|
|
+ track.setChangeAfter(JSONUtil.toJsonStr(vo));
|
|
|
+ track.setResult(JSONUtil.toJsonStr(result));
|
|
|
+ InsOrders insOrders = insOrdersClient.getById(orderNo);
|
|
|
+ if(insOrders != null){
|
|
|
+ InsOrdersCarInfo carInfo = insOrdersClient.getByOrderId(insOrders.getId());
|
|
|
+ track.setLicenseNo(carInfo.getLicenseNo());
|
|
|
+ track.setCompanyId(insOrders.getCompanyId());
|
|
|
+ // track.setResult(result.getMsg());
|
|
|
+ }else{
|
|
|
+ track.setResult("要修改的订单不存在");
|
|
|
+ }
|
|
|
+ track.setStatus(1);
|
|
|
+ track.setOrderNo(orderNo);
|
|
|
+ insOrdersClient.save(track);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存费用信息
|
|
|
+ * @author lipf
|
|
|
+ * @date 2026/7/8 15:28
|
|
|
+ */
|
|
|
+ private void saveCostInfo(Object result, OrderOperationLog log, PtlAgreementCostRatioVo vo) {
|
|
|
+ InsOrdersTrack track = new InsOrdersTrack();
|
|
|
+ String orderNo = vo.getOrderNo();
|
|
|
+ track.setModule(log.module());
|
|
|
+ track.setSubModule(log.subModule());
|
|
|
+ track.setOptType(log.optType().getCode());
|
|
|
+ track.setOptContent(log.description());
|
|
|
+ track.setResult(JSONUtil.toJsonStr(vo));
|
|
|
+ InsOrders insOrders = insOrdersClient.getById(orderNo);
|
|
|
+ if(insOrders != null){
|
|
|
+ InsOrdersCarInfo carInfo = insOrdersClient.getByOrderId(insOrders.getId());
|
|
|
+ track.setLicenseNo(carInfo.getLicenseNo());
|
|
|
+ track.setCompanyId(insOrders.getCompanyId());
|
|
|
+ // track.setResult(result.getMsg());
|
|
|
+ }else{
|
|
|
+ track.setResult("要进行费用调整的订单不存在");
|
|
|
+ }
|
|
|
+ track.setStatus(1);
|
|
|
+ track.setChangeBefore("");
|
|
|
+ track.setChangeAfter("费用调整完成");
|
|
|
+ track.setOrderNo(orderNo);
|
|
|
+ track.setResult(JSONUtil.toJsonStr(result));
|
|
|
+ insOrdersClient.save(track);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|