#
Junjie
2024-08-12 4a129f05fb7369b7916ccd8e68e727bb182439f1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package com.zy.asrs.wms.asrs.entity.template;
 
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.zy.asrs.common.utils.Synchro;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
 
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
 
@Data
public class OrderTemplate {
 
    //订单编号
    @ApiModelProperty(value= "订单编号")
    private String orderNo;
 
    //单据类型
    @ApiModelProperty(value= "单据类型")
    private String orderType;
 
    //商品编号
    @ApiModelProperty(value= "商品编号")
    private String matnr;
 
    //批号
    @ApiModelProperty(value= "批号")
    private String batch;
 
    //数量
    @ApiModelProperty(value= "数量")
    private Double anfme;
 
    //备注
    @ApiModelProperty(value= "备注")
    private String memo;
 
    public void sync(Object source) {
        Synchro.Copy(source, this);
    }
 
    //动态扩展字段
    public transient Map<String, Object> dynamicFields = new HashMap<>();
 
    @JsonAnyGetter
    public Map<String,Object> getDynamicFields() {
        return dynamicFields;
    }
 
    public void syncFieldMap(Map<String, Object> map) {
        ArrayList<String> keys = new ArrayList<>();
        Field[] fields = this.getClass().getDeclaredFields();
        for (Field field : fields) {
            keys.add(field.getName());
        }
        keys.add("detlId");
 
        Map<String, Object> dynamicFields = new HashMap<>();
        for (Map.Entry<String, Object> entry : map.entrySet()) {
            if (keys.contains(entry.getKey())) {
                continue;
            }
            dynamicFields.put(entry.getKey(), entry.getValue());
        }
 
        this.dynamicFields = dynamicFields;
    }
 
    public String getFieldString(String key) {
        return dynamicFields.get(key).toString();
    }
 
    public void setField(String key, Object value) {
        dynamicFields.put(key, value);
    }
 
}