add:单据事件监听

This commit is contained in:
zhangzq
2026-06-09 15:20:23 +08:00
parent dde00d83cd
commit 99844f5e0f
6 changed files with 41 additions and 11 deletions

View File

@@ -2,6 +2,8 @@ package org.nl.wms.pm_manage;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.nl.common.exception.BadRequestException;
/**
* 源单据枚举关联st_ivt_iostorinvdtl表souce_bill_type字段
@@ -10,13 +12,23 @@ import lombok.Getter;
@Getter
public enum SourceBillTypeEnum {
PM_DEMADN("pm_demand","出库需求单"),
UNDEFINE("","未定义"),
;
/**
* 单据类型:对于哪个主表
*/
private String code;
private String billType;
/**
* 单据描述
*/
private String desc;
public static SourceBillTypeEnum check(String souceBillType){
for (SourceBillTypeEnum typeEnum : SourceBillTypeEnum.values()) {
if (typeEnum.getBillType().equals(souceBillType)){
return typeEnum;
}
}
return UNDEFINE;
}
}

View File

@@ -4,9 +4,9 @@ import org.nl.wms.pm_manage.listener.core.BaseFormListenerHandler;
import org.springframework.stereotype.Component;
@Component("pm_demand")
public class DemandFormListenerHandler extends BaseFormListenerHandler<ListenerParams> {
public class DemandFormListenerHandler extends BaseFormListenerHandler<DemandListenerParams> {
@Override
public void onApplicationEvent(ListenerParams params) {
public void onApplicationEvent(DemandListenerParams params) {
}
}

View File

@@ -0,0 +1,18 @@
package org.nl.wms.pm_manage.demand.listenerHandler;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class DemandListenerParams {
private String billCode;
private BigDecimal qty;
private String materialCode;
public DemandListenerParams(String billCode, BigDecimal qty, String materialCode) {
this.billCode = billCode;
this.qty = qty;
this.materialCode = materialCode;
}
}

View File

@@ -1,4 +0,0 @@
package org.nl.wms.pm_manage.demand.listenerHandler;
public class ListenerParams {
}

View File

@@ -8,8 +8,9 @@ import org.springframework.context.ApplicationEvent;
@Getter
public class PmManageEvent extends ApplicationEvent {
SourceBillTypeEnum billTypeEnum;
public PmManageEvent(SourceBillTypeEnum billTypeEnum,Object params) {
public PmManageEvent(String sourceBillType,Object params) {
super(params);
this.billTypeEnum = billTypeEnum;
this.billTypeEnum = SourceBillTypeEnum.check(sourceBillType);
}
}

View File

@@ -16,9 +16,12 @@ public class SmartFormListener implements ApplicationListener<PmManageEvent> {
@Override
public void onApplicationEvent(PmManageEvent event) {
final SourceBillTypeEnum billTypeEnum = event.getBillTypeEnum();
final BaseFormListenerHandler handler = formListenerHandlerMap.get(billTypeEnum.getCode());
if (billTypeEnum.equals(SourceBillTypeEnum.UNDEFINE)){
return;
}
final BaseFormListenerHandler handler = formListenerHandlerMap.get(billTypeEnum.getBillType());
if (handler == null){
System.out.println("======="+billTypeEnum.getCode()+"单据类型没有定义监听处理机=======");
System.out.println("======="+billTypeEnum.getBillType()+"单据类型没有定义监听处理机=======");
return;
}
handler.onApplicationEvent(event);