正在显示
4 个修改的文件
包含
103 行增加
和
2 行删除
| 1 | +package com.sy.event; | ||
| 2 | + | ||
| 3 | +import com.sy.model.GatherInfo; | ||
| 4 | +import org.basis.enhance.groovy.entity.ExecuteParams; | ||
| 5 | +import org.springframework.context.ApplicationEvent; | ||
| 6 | + | ||
| 7 | +public class EngineCheckPassedEvent extends ApplicationEvent { | ||
| 8 | + private final GatherInfo gatherInfo; | ||
| 9 | + private final ExecuteParams executeParams; | ||
| 10 | + | ||
| 11 | + public EngineCheckPassedEvent( | ||
| 12 | + Object source, | ||
| 13 | + GatherInfo gatherInfo, | ||
| 14 | + ExecuteParams executeParams | ||
| 15 | + ) { | ||
| 16 | + super(source); | ||
| 17 | + this.gatherInfo = gatherInfo; | ||
| 18 | + this.executeParams = executeParams; | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + // 提供getter方法 | ||
| 22 | + public GatherInfo getGatherInfo() { | ||
| 23 | + return gatherInfo; | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + public ExecuteParams getExecuteParams() { | ||
| 27 | + return executeParams; | ||
| 28 | + } | ||
| 29 | +} |
| 1 | +package com.sy.event.listener; | ||
| 2 | + | ||
| 3 | +import com.sy.event.EngineCheckPassedEvent; | ||
| 4 | +import com.sy.model.GatherInfo; | ||
| 5 | +import com.sy.model.LAND_BUSINEESTYPE_LIST_INFO; | ||
| 6 | +import com.sy.model.LandBusinessTypeList; | ||
| 7 | +import lombok.extern.slf4j.Slf4j; | ||
| 8 | +import org.basis.enhance.groovy.entity.ExecuteParams; | ||
| 9 | +import org.springframework.context.event.EventListener; | ||
| 10 | +import org.springframework.stereotype.Component; | ||
| 11 | + | ||
| 12 | +import java.util.List; | ||
| 13 | +import java.util.Optional; | ||
| 14 | + | ||
| 15 | +@Component | ||
| 16 | +@Slf4j | ||
| 17 | +public class AccontBookLisener { | ||
| 18 | + | ||
| 19 | + @EventListener // 自动监听事件 | ||
| 20 | + public void handleEngineCheckPassed(EngineCheckPassedEvent event) { | ||
| 21 | + // 从事件中获取参数 | ||
| 22 | + GatherInfo gatherInfo = event.getGatherInfo(); | ||
| 23 | + ExecuteParams executeParams = event.getExecuteParams(); | ||
| 24 | + | ||
| 25 | + // ✅ 在这里编写新业务逻辑(完全独立于原方法) | ||
| 26 | + /** | ||
| 27 | + * 1 获取申报信息 | ||
| 28 | + */ | ||
| 29 | + LandBusinessTypeList chanelFormInfo = Optional.ofNullable(executeParams.get("ChanelFormInfo")) | ||
| 30 | + .filter(obj -> obj instanceof LandBusinessTypeList) | ||
| 31 | + .map(obj -> (LandBusinessTypeList) obj) | ||
| 32 | + .orElse(null); // 或者使用.orElseThrow()抛出异常 | ||
| 33 | + if (chanelFormInfo != null) { | ||
| 34 | + //1. 获取表头-业务类型 | ||
| 35 | + String businesstype = chanelFormInfo.getBusinesstype(); | ||
| 36 | + //1.1 获取表头-通道类型 | ||
| 37 | + String chaneltype = chanelFormInfo.getTurnoverflag(); | ||
| 38 | + //2. 获取表头-申报条码 | ||
| 39 | + String barcode = chanelFormInfo.getBarcode(); | ||
| 40 | + //2. 获取表体提运单列表 | ||
| 41 | + List<LAND_BUSINEESTYPE_LIST_INFO> landBusineestypeListInfoList = chanelFormInfo.getLandBusineestypeListInfoList(); | ||
| 42 | + } | ||
| 43 | + // 例如:发送通知、更新状态、调用外部系统等 | ||
| 44 | + System.out.println("新业务处理: " + gatherInfo.getBarcode()); | ||
| 45 | + | ||
| 46 | + // 注意:此处异常不会影响原主流程(除非配置同步异常传播) | ||
| 47 | + } | ||
| 48 | +} |
| @@ -2,6 +2,7 @@ package com.sy.service.impl; | @@ -2,6 +2,7 @@ package com.sy.service.impl; | ||
| 2 | 2 | ||
| 3 | import com.alibaba.fastjson.JSONArray; | 3 | import com.alibaba.fastjson.JSONArray; |
| 4 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; |
| 5 | +import com.sy.event.EngineCheckPassedEvent; | ||
| 5 | import com.sy.mapper.RuleChannelConfigDao; | 6 | import com.sy.mapper.RuleChannelConfigDao; |
| 6 | import com.sy.model.*; | 7 | import com.sy.model.*; |
| 7 | import com.sy.service.*; | 8 | import com.sy.service.*; |
| @@ -15,6 +16,7 @@ import org.basis.enhance.groovy.entity.ScriptQuery; | @@ -15,6 +16,7 @@ import org.basis.enhance.groovy.entity.ScriptQuery; | ||
| 15 | import org.basis.enhance.groovy.executor.EngineExecutor; | 16 | import org.basis.enhance.groovy.executor.EngineExecutor; |
| 16 | import org.springframework.beans.factory.annotation.Autowired; | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | import org.springframework.beans.factory.annotation.Value; | 18 | import org.springframework.beans.factory.annotation.Value; |
| 19 | +import org.springframework.context.ApplicationEventPublisher; | ||
| 18 | import org.springframework.stereotype.Service; | 20 | import org.springframework.stereotype.Service; |
| 19 | 21 | ||
| 20 | import javax.annotation.Resource; | 22 | import javax.annotation.Resource; |
| @@ -64,6 +66,9 @@ public class EnginCheckServiceImpl implements EnginCheckService { | @@ -64,6 +66,9 @@ public class EnginCheckServiceImpl implements EnginCheckService { | ||
| 64 | @Value("${devdebug}") | 66 | @Value("${devdebug}") |
| 65 | private Boolean debug; | 67 | private Boolean debug; |
| 66 | 68 | ||
| 69 | + @Autowired | ||
| 70 | + private ApplicationEventPublisher eventPublisher; | ||
| 71 | + | ||
| 67 | 72 | ||
| 68 | @Override | 73 | @Override |
| 69 | public Boolean enginCheckByGatherInfo(GatherInfo gatherInfo,ExecuteParams executeParams) { | 74 | public Boolean enginCheckByGatherInfo(GatherInfo gatherInfo,ExecuteParams executeParams) { |
| @@ -395,19 +400,28 @@ public class EnginCheckServiceImpl implements EnginCheckService { | @@ -395,19 +400,28 @@ public class EnginCheckServiceImpl implements EnginCheckService { | ||
| 395 | } | 400 | } |
| 396 | } | 401 | } |
| 397 | 402 | ||
| 403 | + /** | ||
| 404 | + * 关锁验放异步后置处理 | ||
| 405 | + * @param gatherInfo | ||
| 406 | + */ | ||
| 398 | @Override | 407 | @Override |
| 399 | public void lockNoticeContinueCheck(GatherInfo gatherInfo) { | 408 | public void lockNoticeContinueCheck(GatherInfo gatherInfo) { |
| 400 | 409 | ||
| 401 | ExecuteParams executeParams = makeParaByGagherInfo(gatherInfo); | 410 | ExecuteParams executeParams = makeParaByGagherInfo(gatherInfo); |
| 402 | Boolean check = enginCheckByLockNotice(gatherInfo,executeParams); | 411 | Boolean check = enginCheckByLockNotice(gatherInfo,executeParams); |
| 403 | if (check){ | 412 | if (check){ |
| 404 | - log.info("脚本验放通过"); | 413 | + log.info("[关锁异步验放流程]-规则脚本验放通过"); |
| 405 | //放行 | 414 | //放行 |
| 406 | pass(gatherInfo,executeParams); | 415 | pass(gatherInfo,executeParams); |
| 407 | 416 | ||
| 408 | formRelease(gatherInfo,executeParams); | 417 | formRelease(gatherInfo,executeParams); |
| 418 | + | ||
| 419 | + //发布事件. | ||
| 420 | + eventPublisher.publishEvent( | ||
| 421 | + new EngineCheckPassedEvent(this, gatherInfo, executeParams) | ||
| 422 | + ); | ||
| 409 | }else { | 423 | }else { |
| 410 | - log.error("验放失败"); | 424 | + log.error("[关锁异步验放流程]-验放失败"); |
| 411 | } | 425 | } |
| 412 | } | 426 | } |
| 413 | 427 |
| @@ -3,6 +3,7 @@ package com.sy.service.router; | @@ -3,6 +3,7 @@ package com.sy.service.router; | ||
| 3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
| 4 | import com.sy.bwAnalysis.GatherInfoAnalysis; | 4 | import com.sy.bwAnalysis.GatherInfoAnalysis; |
| 5 | import com.sy.bwAssist.Message; | 5 | import com.sy.bwAssist.Message; |
| 6 | +import com.sy.event.EngineCheckPassedEvent; | ||
| 6 | import com.sy.mapper.LandListDao; | 7 | import com.sy.mapper.LandListDao; |
| 7 | import com.sy.mapper.LandRouterConfigDao; | 8 | import com.sy.mapper.LandRouterConfigDao; |
| 8 | import com.sy.model.*; | 9 | import com.sy.model.*; |
| @@ -14,6 +15,7 @@ import lombok.extern.slf4j.Slf4j; | @@ -14,6 +15,7 @@ import lombok.extern.slf4j.Slf4j; | ||
| 14 | import org.apache.commons.lang.StringUtils; | 15 | import org.apache.commons.lang.StringUtils; |
| 15 | import org.basis.enhance.groovy.entity.ExecuteParams; | 16 | import org.basis.enhance.groovy.entity.ExecuteParams; |
| 16 | import org.springframework.beans.factory.annotation.Autowired; | 17 | import org.springframework.beans.factory.annotation.Autowired; |
| 18 | +import org.springframework.context.ApplicationEventPublisher; | ||
| 17 | import org.springframework.stereotype.Service; | 19 | import org.springframework.stereotype.Service; |
| 18 | 20 | ||
| 19 | import javax.annotation.Resource; | 21 | import javax.annotation.Resource; |
| @@ -60,6 +62,9 @@ public class MessageRouterX21 implements MessageRouter { | @@ -60,6 +62,9 @@ public class MessageRouterX21 implements MessageRouter { | ||
| 60 | @Resource | 62 | @Resource |
| 61 | private LandListDao landListDao; | 63 | private LandListDao landListDao; |
| 62 | 64 | ||
| 65 | + @Autowired | ||
| 66 | + private ApplicationEventPublisher eventPublisher; // Spring事件发布器 | ||
| 67 | + | ||
| 63 | /** | 68 | /** |
| 64 | * 入场标识 | 69 | * 入场标识 |
| 65 | */ | 70 | */ |
| @@ -246,6 +251,11 @@ public class MessageRouterX21 implements MessageRouter { | @@ -246,6 +251,11 @@ public class MessageRouterX21 implements MessageRouter { | ||
| 246 | enginCheckService.pass(gatherInfo,executeParams); | 251 | enginCheckService.pass(gatherInfo,executeParams); |
| 247 | 252 | ||
| 248 | enginCheckService.formRelease(gatherInfo,executeParams); | 253 | enginCheckService.formRelease(gatherInfo,executeParams); |
| 254 | + | ||
| 255 | + //发布事件. | ||
| 256 | + eventPublisher.publishEvent( | ||
| 257 | + new EngineCheckPassedEvent(this, gatherInfo, executeParams) | ||
| 258 | + ); | ||
| 249 | }else { | 259 | }else { |
| 250 | log.error("脚本验放测试失败或等待关锁施解封"); | 260 | log.error("脚本验放测试失败或等待关锁施解封"); |
| 251 | } | 261 | } |
-
请 注册 或 登录 后发表评论