| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- import com.yinjie.heating.common.api.BusinessExecutor
- import com.yinjie.heating.common.api.DocInfoService
- import com.yinjie.heating.common.api.StoreService
- import com.yinjie.heating.common.api.SystemService
- import com.yinjie.heating.common.api.flycat.ExpressOutService
- import com.yinjie.heating.common.api.flycat.OrderSearchService
- import com.yinjie.heating.common.api.flycat.OrderService
- import com.yinjie.heating.common.datas.ERPModule
- import com.yinjie.heating.common.datas.ERPModuleEntity
- import com.yinjie.heating.common.entity.base.BusinessOperation
- import com.yinjie.heating.common.entity.base.ProcessEntityItem
- import com.sweetfish.service.RetResult
- import org.apache.logging.log4j.LogManager
- import org.apache.logging.log4j.Logger
- import javax.annotation.Resource
- /**
- * Created by jlutt on 2020-08-25
- *
- * @author jlutt
- */
- @SuppressWarnings("unused")
- class BE_DocClearScriptCache implements BusinessExecutor<ProcessEntityItem<ERPModuleEntity>, ERPModuleEntity> {
- protected final Logger logger = LogManager.getLogger(this.getClass().getSimpleName())
- @Resource
- SystemService systemService
- @Resource
- DocInfoService docInfoService
- @Resource
- ExpressOutService expressOutService
- @Resource
- StoreService storeService
- @Resource
- OrderService orderService
- @Resource
- OrderSearchService orderSearchService
- @Override
- String scriptName() {
- return "保存业务脚本清除对象"
- }
- @Override
- ERPModule module() {
- return ERPModule.NONE
- }
- @Override
- RetResult<ERPModuleEntity> execute(ProcessEntityItem<ERPModuleEntity> source) {
- ERPModule erpModule = source.getInputItem().getErpModule()
- logger.info("修改模块" + erpModule.getModuleDisplayName())
- if ("Init_ExpandoGroovy".equalsIgnoreCase(source.getInputItem().getCode())) {
- //Init_ExpandoGroovy每个使用脚本的service都载入了,由于是默认载入的,而且是启动自动载入的,所以不提供清除的方法,而是每个都重载一次
- //2024-01-26未测试这个重载能不能不重启给groovy增加扩展方法,需要测试,不过理论上没啥用,因为Init_ExpandoGroovy的脚本是用的其它groovy代码实现的,先这样吧,留着以后处理,暂时不经常修改GroovyExtensions代码算了
- systemService.reloadScriptCache(source.inputItem.code, ERPModule.SYSTEM, source.dataSourceId, source.supplierCode)
- docInfoService.reloadScriptCache(source.inputItem.code, ERPModule.SYSTEM, source.dataSourceId, source.supplierCode)
- expressOutService.reloadScriptCache(source.inputItem.code, ERPModule.SYSTEM, source.dataSourceId, source.supplierCode)
- storeService.reloadScriptCache(source.inputItem.code, ERPModule.SYSTEM, source.dataSourceId, source.supplierCode)
- orderService.reloadScriptCache(source.inputItem.code, ERPModule.SYSTEM, source.dataSourceId, source.supplierCode)
- orderSearchService.reloadScriptCache(source.inputItem.code, ERPModule.SYSTEM, source.dataSourceId, source.supplierCode)
- }
- else {
- switch (erpModule) {
- case ERPModule.NONE:
- break
- case ERPModule.SYSTEM:
- if (source.getOperation() == BusinessOperation.SAVE) {
- systemService.invalidateScriptCache(source.getSupplierCode() + "-" + source.getInputItem().getCode())
- } else {
- systemService.reloadScriptCache(source.getInputItem().getCode(), erpModule, source.getDataSourceId(), source.getSupplierCode())
- }
- break
- case [ERPModule.DOC, ERPModule.INQUIREINFO]:
- if (source.getOperation() == BusinessOperation.SAVE) {
- docInfoService.invalidateScriptCache(source.getSupplierCode() + "-" + source.getInputItem().getCode())
- } else {
- docInfoService.reloadScriptCache(source.getInputItem().getCode(), erpModule, source.getDataSourceId(), source.getSupplierCode())
- }
- break
- case [ERPModule.EXPORT, ERPModule.CHARTS]:
- if (source.getOperation() == BusinessOperation.SAVE) {
- systemService.invalidateScriptCache(source.getSupplierCode() + "-" + source.getInputItem().getCode())
- } else {
- systemService.reloadScriptCache(source.getInputItem().getCode(), erpModule, source.getDataSourceId(), source.getSupplierCode())
- }
- break
- case ERPModule.EXPRESS_API:
- if (source.getOperation() == BusinessOperation.SAVE) {
- expressOutService.invalidateScriptCache(source.getSupplierCode() + "-" + source.getInputItem().getCode())
- } else {
- expressOutService.reloadScriptCache(source.getInputItem().getCode(), erpModule, source.getDataSourceId(), source.getSupplierCode())
- }
- break
- case [ERPModule.ERP_ORDER, ERPModule.ORDER_API]:
- if (source.getOperation() == BusinessOperation.SAVE) {
- orderService.invalidateScriptCache(source.getSupplierCode() + "-" + source.getInputItem().getCode())
- } else {
- orderService.reloadScriptCache(source.getInputItem().getCode(), erpModule, source.getDataSourceId(), source.getSupplierCode())
- }
- break
- case ERPModule.ERP_ORDER_SEARCH:
- if (source.getOperation() == BusinessOperation.SAVE) {
- orderSearchService.invalidateScriptCache(source.getSupplierCode() + "-" + source.getInputItem().getCode())
- } else {
- orderSearchService.reloadScriptCache(source.getInputItem().getCode(), erpModule, source.getDataSourceId(), source.getSupplierCode())
- }
- break
- case ERPModule.STORE_API:
- if (source.getOperation() == BusinessOperation.SAVE) {
- storeService.invalidateScriptCache(source.getSupplierCode() + "-" + source.getInputItem().getCode())
- } else {
- storeService.reloadScriptCache(source.getInputItem().getCode(), erpModule, source.getDataSourceId(), source.getSupplierCode())
- }
- break
- case ERPModule.ADDRESSPARSER:
- break
- case ERPModule.APP:
- break
- default:
- break
- }
- }
- return RetResult.success().result(source.getInputItem())
- }
- }
|