BE_DocClearScriptCache.groovy 6.0 KB

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