add:单据事件监听
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
package org.nl.wms.pm_manage;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 源单据枚举:关联st_ivt_iostorinvdtl表souce_bill_type字段
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public enum SourceBillTypeEnum {
|
||||||
|
PM_DEMADN("pm_demand","出库需求单"),
|
||||||
|
;
|
||||||
|
/**
|
||||||
|
* 单据类型:对于哪个主表
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
/**
|
||||||
|
* 单据描述
|
||||||
|
*/
|
||||||
|
private String desc;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package org.nl.wms.pm_manage.demand.listenerHandler;
|
||||||
|
|
||||||
|
import org.nl.wms.pm_manage.listener.core.BaseFormListenerHandler;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component("pm_demand")
|
||||||
|
public class DemandFormListenerHandler extends BaseFormListenerHandler<ListenerParams> {
|
||||||
|
@Override
|
||||||
|
public void onApplicationEvent(ListenerParams params) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package org.nl.wms.pm_manage.demand.listenerHandler;
|
||||||
|
|
||||||
|
public class ListenerParams {
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package org.nl.wms.pm_manage.listener;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.nl.wms.pm_manage.SourceBillTypeEnum;
|
||||||
|
import org.springframework.context.ApplicationEvent;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class PmManageEvent extends ApplicationEvent {
|
||||||
|
SourceBillTypeEnum billTypeEnum;
|
||||||
|
public PmManageEvent(SourceBillTypeEnum billTypeEnum,Object params) {
|
||||||
|
super(params);
|
||||||
|
this.billTypeEnum = billTypeEnum;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package org.nl.wms.pm_manage.listener.core;
|
||||||
|
|
||||||
|
|
||||||
|
public abstract class BaseFormListenerHandler<T> {
|
||||||
|
|
||||||
|
public abstract void onApplicationEvent(T params);
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package org.nl.wms.pm_manage.listener.core;
|
||||||
|
|
||||||
|
import org.nl.wms.pm_manage.SourceBillTypeEnum;
|
||||||
|
import org.nl.wms.pm_manage.listener.PmManageEvent;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.ApplicationListener;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class SmartFormListener implements ApplicationListener<PmManageEvent> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
Map<String,BaseFormListenerHandler> formListenerHandlerMap;
|
||||||
|
@Override
|
||||||
|
public void onApplicationEvent(PmManageEvent event) {
|
||||||
|
final SourceBillTypeEnum billTypeEnum = event.getBillTypeEnum();
|
||||||
|
final BaseFormListenerHandler handler = formListenerHandlerMap.get(billTypeEnum.getCode());
|
||||||
|
if (handler == null){
|
||||||
|
System.out.println("======="+billTypeEnum.getCode()+"单据类型没有定义监听处理机=======");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
handler.onApplicationEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user