|
|
@@ -0,0 +1,197 @@
|
|
|
+package com.ydtech.modules.scheme.aop.aspect;
|
|
|
+
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.ydtech.constants.enums.InsuranceRisk;
|
|
|
+import com.ydtech.constants.enums.dict.agreement.ProductsType;
|
|
|
+import com.ydtech.constants.sys.SystemConstant;
|
|
|
+import com.ydtech.core.page.HttpResult;
|
|
|
+import com.ydtech.exception.SystemException;
|
|
|
+import com.ydtech.modules.admin.model.SysUser;
|
|
|
+import com.ydtech.modules.admin.model.SysUserRole;
|
|
|
+import com.ydtech.modules.admin.service.SysUserRoleService;
|
|
|
+import com.ydtech.modules.admin.service.SysUserService;
|
|
|
+import com.ydtech.modules.base.controller.BaseController;
|
|
|
+import com.ydtech.modules.esm.model.EsmInsCompany;
|
|
|
+import com.ydtech.modules.esm.service.EsmInsCompanyService;
|
|
|
+import com.ydtech.modules.fee.service.CostsCalcService;
|
|
|
+import com.ydtech.modules.fee.service.FeeDisplayService;
|
|
|
+import com.ydtech.modules.fee.service.FeeRuleSchemeNewService;
|
|
|
+import com.ydtech.modules.ins.model.vo.KindInfoVo;
|
|
|
+import com.ydtech.modules.ins.model.vo.QuoteRespVo;
|
|
|
+import com.ydtech.modules.ins.model.vo.RiskInfoVo;
|
|
|
+import com.ydtech.modules.order.components.InsOrdersComponents;
|
|
|
+import com.ydtech.modules.order.entity.InsAreaCompany;
|
|
|
+import com.ydtech.modules.order.entity.InsAreaCompanyAccidentalDriving;
|
|
|
+import com.ydtech.modules.order.entity.InsOrders;
|
|
|
+import com.ydtech.modules.order.entity.po.InsAreaCompanyError;
|
|
|
+import com.ydtech.modules.order.entity.vo.BaseQuoteInfoVo;
|
|
|
+import com.ydtech.modules.order.entity.vo.BaseQuoteVo;
|
|
|
+import com.ydtech.modules.order.entity.vo.SubOrderExportFeeVo;
|
|
|
+import com.ydtech.modules.order.service.InsAreaCompanyAccidentalDrivingService;
|
|
|
+import com.ydtech.modules.order.service.InsAreaCompanyErrorService;
|
|
|
+import com.ydtech.modules.order.service.InsAreaCompanyService;
|
|
|
+import com.ydtech.modules.order.service.InsOrdersService;
|
|
|
+import com.ydtech.modules.protocol.constants.TaxSourceStatusConstants;
|
|
|
+import com.ydtech.modules.protocol.dao.PtlTaxSourceNewMapper;
|
|
|
+import com.ydtech.modules.protocol.entity.dto.TaxSourceExcludeDto;
|
|
|
+import com.ydtech.modules.protocol.entity.po.PtlAgreement;
|
|
|
+import com.ydtech.modules.protocol.entity.po.PtlTaxSourceNew;
|
|
|
+import com.ydtech.modules.protocol.service.ITaxSourceExcludeService;
|
|
|
+import com.ydtech.modules.protocol.service.PtlAgreementDeptService;
|
|
|
+import com.ydtech.modules.protocol.service.PtlAgreementService;
|
|
|
+import com.ydtech.modules.protocol.service.PtlTaxSourceNewService;
|
|
|
+import com.ydtech.modules.protocol.service.impl.TaxSourceServiceImpl;
|
|
|
+import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
|
|
|
+import com.ydtech.modules.protocols.service.InsFeeOrderNewService;
|
|
|
+import com.ydtech.modules.scheme.aop.RuleTrajectory;
|
|
|
+import com.ydtech.modules.scheme.constants.ExecuteStatusConstant;
|
|
|
+import com.ydtech.modules.scheme.entity.po.PtlSchemeRulesAttr;
|
|
|
+import com.ydtech.modules.scheme.entity.po.PtlSchemeRulesTrajectory;
|
|
|
+import com.ydtech.modules.scheme.entity.vo.RuleResultVo;
|
|
|
+import com.ydtech.modules.scheme.entity.vo.RuleSaveVo;
|
|
|
+import com.ydtech.modules.scheme.service.PtlSchemeRulesAttrService;
|
|
|
+import com.ydtech.modules.scheme.service.PtlSchemeRulesService;
|
|
|
+import com.ydtech.modules.scheme.service.PtlSchemeRulesTrajectoryService;
|
|
|
+import com.ydtech.utils.StringUtils;
|
|
|
+import com.ydtech.utils.idgen.IdGenerate;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.aspectj.lang.JoinPoint;
|
|
|
+import org.aspectj.lang.annotation.AfterReturning;
|
|
|
+import org.aspectj.lang.annotation.AfterThrowing;
|
|
|
+import org.aspectj.lang.annotation.Aspect;
|
|
|
+import org.aspectj.lang.annotation.Before;
|
|
|
+import org.aspectj.lang.reflect.MethodSignature;
|
|
|
+import org.dom4j.rule.Rule;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@Aspect
|
|
|
+@Component
|
|
|
+@RequiredArgsConstructor
|
|
|
+public class RuleTrajectoryAspect {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ PtlSchemeRulesTrajectoryService ptlSchemeRulesTrajectoryService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ PtlSchemeRulesService ptlSchemeRulesService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ PtlSchemeRulesAttrService ptlSchemeRulesAttrService;
|
|
|
+
|
|
|
+ private ThreadLocal<MethodContext> methodContext = new ThreadLocal<>();
|
|
|
+
|
|
|
+ @AfterReturning(pointcut = "@annotation(com.ydtech.modules.scheme.aop.RuleTrajectory)",returning = "result")
|
|
|
+ public void doAfter(JoinPoint joinPoint,HttpResult result) {
|
|
|
+ MethodContext context = methodContext.get();
|
|
|
+ if (context != null) {
|
|
|
+ // 在这里验证结果
|
|
|
+ String methodName = context.getMethodName();
|
|
|
+ if(joinPoint.getSignature().getName().equals(methodName)){
|
|
|
+ if(Objects.isNull(context.getId())){
|
|
|
+ throw new SystemException("线程上下文异常,请重试");
|
|
|
+ }
|
|
|
+ PtlSchemeRulesTrajectory byId = ptlSchemeRulesTrajectoryService.getById(context.getId());
|
|
|
+ if(result.getCode() == 200){
|
|
|
+ if(byId.getOperatorType().equals("C")){
|
|
|
+ JSONObject jsonObject = JSON.parseObject(result.getData().toString());
|
|
|
+ byId.setRuleId(jsonObject.getString("ruleId"));
|
|
|
+ }
|
|
|
+ byId.setExecuteStatus(ExecuteStatusConstant.ES1.getCode());
|
|
|
+ }else{
|
|
|
+ byId.setExecuteStatus(ExecuteStatusConstant.ES2.getCode());
|
|
|
+ byId.setErrorMsg(result.getMsg());
|
|
|
+ }
|
|
|
+ ptlSchemeRulesTrajectoryService.updateById(byId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 清除上下文
|
|
|
+ methodContext.remove();
|
|
|
+ }
|
|
|
+
|
|
|
+ //拦截异常消息
|
|
|
+ @AfterThrowing(pointcut = "@annotation(com.ydtech.modules.scheme.aop.RuleTrajectory)", throwing = "ex")
|
|
|
+ public void doAfterThrowing(JoinPoint joinPoint, Throwable ex) {
|
|
|
+ MethodContext context = methodContext.get();
|
|
|
+ if (context != null) {
|
|
|
+ String methodName = context.getMethodName();
|
|
|
+ if(joinPoint.getSignature().getName().equals(methodName)){
|
|
|
+ PtlSchemeRulesTrajectory byId = ptlSchemeRulesTrajectoryService.getById(context.getId());
|
|
|
+ byId.setExecuteStatus(ExecuteStatusConstant.ES2.getCode());
|
|
|
+ byId.setErrorMsg(ex.getMessage());
|
|
|
+ ptlSchemeRulesTrajectoryService.updateById(byId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 清除上下文
|
|
|
+ methodContext.remove();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Before("@annotation(ruleTrajectory)")
|
|
|
+ public void doBefore(JoinPoint point, RuleTrajectory ruleTrajectory) {
|
|
|
+ RuleSaveVo ruleSaveVo = null;
|
|
|
+ String ruleId = null;
|
|
|
+ if(ruleTrajectory.type().equals("C") || ruleTrajectory.type().equals("U")) {
|
|
|
+ //强转参数
|
|
|
+ ruleSaveVo = (RuleSaveVo) point.getArgs()[0];
|
|
|
+ }else if(ruleTrajectory.type().equals("D")){
|
|
|
+ ruleId = point.getArgs()[0].toString();
|
|
|
+ }
|
|
|
+ PtlSchemeRulesTrajectory trajectory = new PtlSchemeRulesTrajectory(ruleSaveVo);
|
|
|
+ trajectory.setId(IdGenerate.nextId());
|
|
|
+ trajectory.setOperatorType(ruleTrajectory.type());
|
|
|
+ List<PtlSchemeRulesAttr> schemeRulesAttrs = null;
|
|
|
+ RuleResultVo rulesInfoById = null;
|
|
|
+ switch(ruleTrajectory.type()){
|
|
|
+ //创建
|
|
|
+ case "C":
|
|
|
+ ptlSchemeRulesTrajectoryService.save(trajectory);
|
|
|
+ break;
|
|
|
+ //更新
|
|
|
+ case "U":
|
|
|
+ schemeRulesAttrs = ptlSchemeRulesAttrService.getRulesAttrList();
|
|
|
+ rulesInfoById = ptlSchemeRulesAttrService.getRulesInfoById(ruleSaveVo.getRule().getId(), schemeRulesAttrs);
|
|
|
+ trajectory.setBeforeJson(JSON.toJSONString(rulesInfoById));
|
|
|
+ trajectory.setRuleId(rulesInfoById.getId());
|
|
|
+ ptlSchemeRulesTrajectoryService.save(trajectory);
|
|
|
+ break;
|
|
|
+ //删除
|
|
|
+ case "D":
|
|
|
+ schemeRulesAttrs = ptlSchemeRulesAttrService.getRulesAttrList();
|
|
|
+ rulesInfoById = ptlSchemeRulesAttrService.getRulesInfoById(ruleId, schemeRulesAttrs);
|
|
|
+ trajectory.setBeforeJson(JSON.toJSONString(rulesInfoById));
|
|
|
+ trajectory.setRuleId(rulesInfoById.getId());
|
|
|
+ ptlSchemeRulesTrajectoryService.save(trajectory);
|
|
|
+ break;
|
|
|
+
|
|
|
+ }
|
|
|
+ // 用于验证上下文
|
|
|
+ methodContext.set(new MethodContext(point.getSignature().getName(), trajectory.getId()));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private static class MethodContext {
|
|
|
+ private final String methodName;
|
|
|
+ private final String id;
|
|
|
+
|
|
|
+ public MethodContext(String methodName, String id) {
|
|
|
+ this.methodName = methodName;
|
|
|
+ this.id = id;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getMethodName() {
|
|
|
+ return methodName;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getId() {
|
|
|
+ return id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|