BE_DocClearScriptCache.groovy 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import com.yinjie.heating.common.api.BusinessExecutor
  2. import com.yinjie.heating.common.api.DocInfoService
  3. import com.yinjie.heating.common.api.StoreService
  4. import com.yinjie.heating.common.api.SystemService
  5. import com.yinjie.heating.common.api.flycat.ExpressOutService
  6. import com.yinjie.heating.common.api.flycat.OrderSearchService
  7. import com.yinjie.heating.common.api.flycat.OrderService
  8. import com.yinjie.heating.common.datas.ERPModule
  9. import com.yinjie.heating.common.datas.ERPModuleEntity
  10. import com.yinjie.heating.common.entity.base.BusinessOperation
  11. import com.yinjie.heating.common.entity.base.ProcessEntityItem
  12. import com.sweetfish.service.RetResult
  13. import org.apache.logging.log4j.LogManager
  14. import org.apache.logging.log4j.Logger
  15. import javax.annotation.Resource
  16. /**
  17. * Created by jlutt on 2020-08-25
  18. *
  19. * @author jlutt
  20. */
  21. @SuppressWarnings("unused")
  22. class BE_DocClearScriptCache implements BusinessExecutor<ProcessEntityItem<ERPModuleEntity>, ERPModuleEntity> {
  23. protected final Logger logger = LogManager.getLogger(this.getClass().getSimpleName())
  24. @Resource
  25. SystemService systemService
  26. @Resource
  27. DocInfoService docInfoService
  28. @Resource
  29. ExpressOutService expressOutService
  30. @Resource
  31. StoreService storeService
  32. @Resource
  33. OrderService orderService
  34. @Resource
  35. OrderSearchService orderSearchService
  36. @Override
  37. String scriptName() {
  38. return "保存业务脚本清除对象"
  39. }
  40. @Override
  41. ERPModule module() {
  42. return ERPModule.NONE
  43. }
  44. @Override
  45. RetResult<ERPModuleEntity> execute(ProcessEntityItem<ERPModuleEntity> source) {
  46. ERPModule erpModule = source.getInputItem().getErpModule()
  47. logger.info("修改模块" + erpModule.getModuleDisplayName())
  48. if ("Init_ExpandoGroovy".equalsIgnoreCase(source.getInputItem().getCode())) {
  49. //Init_ExpandoGroovy每个使用脚本的service都载入了,由于是默认载入的,而且是启动自动载入的,所以不提供清除的方法,而是每个都重载一次
  50. //2024-01-26未测试这个重载能不能不重启给groovy增加扩展方法,需要测试,不过理论上没啥用,因为Init_ExpandoGroovy的脚本是用的其它groovy代码实现的,先这样吧,留着以后处理,暂时不经常修改GroovyExtensions代码算了
  51. systemService.reloadScriptCache(source.inputItem.code, ERPModule.SYSTEM, source.dataSourceId, source.supplierCode)
  52. docInfoService.reloadScriptCache(source.inputItem.code, ERPModule.SYSTEM, source.dataSourceId, source.supplierCode)
  53. expressOutService.reloadScriptCache(source.inputItem.code, ERPModule.SYSTEM, source.dataSourceId, source.supplierCode)
  54. storeService.reloadScriptCache(source.inputItem.code, ERPModule.SYSTEM, source.dataSourceId, source.supplierCode)
  55. orderService.reloadScriptCache(source.inputItem.code, ERPModule.SYSTEM, source.dataSourceId, source.supplierCode)
  56. orderSearchService.reloadScriptCache(source.inputItem.code, ERPModule.SYSTEM, source.dataSourceId, source.supplierCode)
  57. }
  58. else {
  59. switch (erpModule) {
  60. case ERPModule.NONE:
  61. break
  62. case ERPModule.SYSTEM:
  63. if (source.getOperation() == BusinessOperation.SAVE) {
  64. systemService.invalidateScriptCache(source.getSupplierCode() + "-" + source.getInputItem().getCode())
  65. } else {
  66. systemService.reloadScriptCache(source.getInputItem().getCode(), erpModule, source.getDataSourceId(), source.getSupplierCode())
  67. }
  68. break
  69. case [ERPModule.DOC, ERPModule.INQUIREINFO]:
  70. if (source.getOperation() == BusinessOperation.SAVE) {
  71. docInfoService.invalidateScriptCache(source.getSupplierCode() + "-" + source.getInputItem().getCode())
  72. } else {
  73. docInfoService.reloadScriptCache(source.getInputItem().getCode(), erpModule, source.getDataSourceId(), source.getSupplierCode())
  74. }
  75. break
  76. case [ERPModule.EXPORT, ERPModule.CHARTS]:
  77. if (source.getOperation() == BusinessOperation.SAVE) {
  78. systemService.invalidateScriptCache(source.getSupplierCode() + "-" + source.getInputItem().getCode())
  79. } else {
  80. systemService.reloadScriptCache(source.getInputItem().getCode(), erpModule, source.getDataSourceId(), source.getSupplierCode())
  81. }
  82. break
  83. case ERPModule.EXPRESS_API:
  84. if (source.getOperation() == BusinessOperation.SAVE) {
  85. expressOutService.invalidateScriptCache(source.getSupplierCode() + "-" + source.getInputItem().getCode())
  86. } else {
  87. expressOutService.reloadScriptCache(source.getInputItem().getCode(), erpModule, source.getDataSourceId(), source.getSupplierCode())
  88. }
  89. break
  90. case [ERPModule.ERP_ORDER, ERPModule.ORDER_API]:
  91. if (source.getOperation() == BusinessOperation.SAVE) {
  92. orderService.invalidateScriptCache(source.getSupplierCode() + "-" + source.getInputItem().getCode())
  93. } else {
  94. orderService.reloadScriptCache(source.getInputItem().getCode(), erpModule, source.getDataSourceId(), source.getSupplierCode())
  95. }
  96. break
  97. case ERPModule.ERP_ORDER_SEARCH:
  98. if (source.getOperation() == BusinessOperation.SAVE) {
  99. orderSearchService.invalidateScriptCache(source.getSupplierCode() + "-" + source.getInputItem().getCode())
  100. } else {
  101. orderSearchService.reloadScriptCache(source.getInputItem().getCode(), erpModule, source.getDataSourceId(), source.getSupplierCode())
  102. }
  103. break
  104. case ERPModule.STORE_API:
  105. if (source.getOperation() == BusinessOperation.SAVE) {
  106. storeService.invalidateScriptCache(source.getSupplierCode() + "-" + source.getInputItem().getCode())
  107. } else {
  108. storeService.reloadScriptCache(source.getInputItem().getCode(), erpModule, source.getDataSourceId(), source.getSupplierCode())
  109. }
  110. break
  111. case ERPModule.ADDRESSPARSER:
  112. break
  113. case ERPModule.APP:
  114. break
  115. default:
  116. break
  117. }
  118. }
  119. return RetResult.success().result(source.getInputItem())
  120. }
  121. }