zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
package com.changhong.epc.count.service.system.performer.impl;
 
import com.changhong.epc.bean.count.MasterInfo;
import com.changhong.epc.bean.count.func.FunNameKey;
import com.changhong.epc.bean.tenant.bill.BillData;
import com.changhong.epc.bean.tenant.bill.IOCRBill;
import com.changhong.epc.bean.tenant.bill.OCRBillHeaderEntity;
import com.changhong.epc.bean.tenant.bill.RuleMsg;
import com.changhong.epc.bean.tenant.system.ErrSystemMsg;
import com.changhong.epc.count.service.count.data.paramiter.IParamIter;
import com.changhong.epc.count.service.count.data.paramiter.impl.ParamIter;
import com.changhong.epc.count.service.count.model.CountParamMax;
import com.changhong.epc.count.service.count.model.UnitInfo;
import com.iemsoft.framework.cloud.core.tools.JSONTool;
 
import java.lang.reflect.Field;
import java.util.*;
 
public class FormulaTest implements FunNameKey {
 
    public static void main(String... args) throws NoSuchFieldException, IllegalAccessException {
//        FunctionParam functionParam = new FunctionParam(true);
//        functionParam.initData(getIParamIter());
//        functionParam.setExpression("false <> true ");
////        functionParam.setExpression("getDate('FromDate', 'yyyy-MM-dd') != getDate('ToDate', 'yyyy-MM-dd')");
//        Map<String, Object> env = functionParam.getOriginalEnv();
//
//        {
//            env.put("a1", new MeInfo("F149", "010402", ""));
//            env.put("a2", new MeInfo("F149", "010404", ""));
//            env.put("a3", new MeInfo("F005", "0001", ""));
//        }
//
//        functionParam.setEnv(env);
//        new FormulaHandle().execute(functionParam);
        List<OCRBillHeaderEntity> bills = JSONTool.toList("[\n" +
                "    {\n" +
                "        \"allotTenant\":true,\n" +
                "        \"billBodyEntityList\":[\n" +
                "            {\n" +
                "                \"billCode\":\"074a31ca4f3e43edb85e96ab500eff90\",\n" +
                "                \"billKeyCode\":{\n" +
                "                    \"Amount\":\"182.00\"\n" +
                "                },\n" +
                "                \"billKeyName\":{\n" +
                "                    \"Amount\":\"182.00\"\n" +
                "                },\n" +
                "                \"billMasterCode\":{\n" +
                "\n" +
                "                },\n" +
                "                \"billMasterName\":{\n" +
                "\n" +
                "                },\n" +
                "                \"billMoney\":0,\n" +
                "                \"bodyDataMap\":{\n" +
                "                    \"500030\":\"日办公用品\",\n" +
                "                    \"560054\":\"182.00\"\n" +
                "                },\n" +
                "                \"ignore\":false\n" +
                "            }\n" +
                "        ],\n" +
                "        \"billCode\":\"1018500180900073-002-01\",\n" +
                "        \"billHeadMap\":{\n" +
                "            \"520040\":\"四川成都市\",\n" +
                "            \"540040\":\"\",\n" +
                "            \"550025\":\"30170237\",\n" +
                "            \"550031\":\"\",\n" +
                "            \"550044\":\"\",\n" +
                "            \"550055\":\"91510700205412308D\",\n" +
                "            \"550099\":\"151011776003\",\n" +
                "            \"560133\":\"182.00\",\n" +
                "            \"560134\":\"182.0\",\n" +
                "            \"570001\":\"发票联\",\n" +
                "            \"580008\":\"\",\n" +
                "            \"590006\":\"四川省成都市国家税务局通用机打发票\",\n" +
                "            \"590010\":\"\",\n" +
                "            \"590012\":\"四怅虹电器股份有限公司\",\n" +
                "            \"590014\":\"\",\n" +
                "            \"590024\":\"成都京东世纪贸易有限公司\",\n" +
                "            \"600008\":\"\",\n" +
                "            \"610014\":\"\",\n" +
                "            \"620024\":\"20171111\",\n" +
                "            \"640003\":\"国家税务局监制\"\n" +
                "        },\n" +
                "        \"billKeyCode\":{\n" +
                "            \"Amount\":\"182.00\"\n" +
                "        },\n" +
                "        \"billKeyName\":{\n" +
                "            \"Amount\":\"182.00\"\n" +
                "        },\n" +
                "        \"billMasterCode\":{\n" +
                "\n" +
                "        },\n" +
                "        \"billMasterName\":{\n" +
                "\n" +
                "        },\n" +
                "        \"billModelCode\":\"B00000060000\",\n" +
                "        \"ignore\":false,\n" +
                "        \"ruleMsg\":[\n" +
                "\n" +
                "        ]\n" +
                "    },\n" +
                "    {\n" +
                "        \"allotTenant\":true,\n" +
                "        \"billBodyEntityList\":[\n" +
                "            {\n" +
                "                \"billCode\":\"4f0a4048f6534c2e9d459caef3de932e\",\n" +
                "                \"billKeyCode\":{\n" +
                "                    \"Amount\":\"39.90\"\n" +
                "                },\n" +
                "                \"billKeyName\":{\n" +
                "                    \"Amount\":\"39.90\"\n" +
                "                },\n" +
                "                \"billMasterCode\":{\n" +
                "\n" +
                "                },\n" +
                "                \"billMasterName\":{\n" +
                "\n" +
                "                },\n" +
                "                \"billMoney\":0,\n" +
                "                \"bodyDataMap\":{\n" +
                "                    \"500030\":\"办公用品\",\n" +
                "                    \"560054\":\"39.90\"\n" +
                "                },\n" +
                "                \"ignore\":false\n" +
                "            }\n" +
                "        ],\n" +
                "        \"billCode\":\"1018500180900073-001-01\",\n" +
                "        \"billHeadMap\":{\n" +
                "            \"520040\":\"四川\",\n" +
                "            \"540040\":\"\",\n" +
                "            \"550025\":\"41888406\",\n" +
                "            \"550031\":\"\",\n" +
                "            \"550044\":\"\",\n" +
                "            \"550055\":\"91610139081030649M\",\n" +
                "            \"550099\":\"161011640110\",\n" +
                "            \"560133\":\"39.90\",\n" +
                "            \"560134\":\"39.9\",\n" +
                "            \"570001\":\"发票联\",\n" +
                "            \"580008\":\"\",\n" +
                "            \"590006\":\"四川西安国家税务局通用机打发票\",\n" +
                "            \"590010\":\"\",\n" +
                "            \"590012\":\"(个四川长虹电股份有限公司税\",\n" +
                "            \"590014\":\"\",\n" +
                "            \"590024\":\"西安华讯得贸易有限公司\",\n" +
                "            \"600008\":\"\",\n" +
                "            \"610014\":\"\",\n" +
                "            \"620024\":\"20171206\",\n" +
                "            \"640003\":\"国家税务局监制\"\n" +
                "        },\n" +
                "        \"billKeyCode\":{\n" +
                "            \"Amount\":\"39.90\"\n" +
                "        },\n" +
                "        \"billKeyName\":{\n" +
                "            \"Amount\":\"39.90\"\n" +
                "        },\n" +
                "        \"billMasterCode\":{\n" +
                "\n" +
                "        },\n" +
                "        \"billMasterName\":{\n" +
                "\n" +
                "        },\n" +
                "        \"billModelCode\":\"B00000060000\",\n" +
                "        \"ignore\":false,\n" +
                "        \"ruleMsg\":[\n" +
                "\n" +
                "        ]\n" +
                "    }\n" +
                "]", OCRBillHeaderEntity.class);
        ParamIter paramIter = new ParamIter();
        Field field =paramIter.getClass().getDeclaredField("billList");
        field.setAccessible(true);
        List<OCRBillHeaderEntity> bill = (List<OCRBillHeaderEntity>) field.get(paramIter);
        bill.addAll(bills);
        System.out.println(JSONTool.toJson(paramIter.getAllBillList()));
    }
 
    public static IParamIter<UnitInfo> getIParamIter(){
        final List<UnitInfo> unitInfos = new ArrayList<>();
        {
            UnitInfo unitInfo = new UnitInfo();
            unitInfo.setUnitInfoMdJoinAll(new HashSet<>(Arrays.asList(
                    new MasterInfo("F001","0001","1"),
                    new MasterInfo("F149","0001","2018-02-25", "FromDate"),
                    new MasterInfo("F006","0001","2018-02-25", "ToDate"),
                    new MasterInfo("F003","0001","300.4"),
                    new MasterInfo("F004","0001","-4"),
                    new MasterInfo("F005","0001","17741117360")
            )));
            unitInfo.setUnitInfo(unitInfo.getUnitInfoMdJoinAll());
            unitInfos.add(unitInfo);
        }
        {
            UnitInfo unitInfo = new UnitInfo();
            unitInfo.setUnitInfoMdJoinAll(new HashSet<>(Arrays.asList(
                    new MasterInfo("F001","0001","2"),
                    new MasterInfo("F002","0001","2018-03-24"),
                    new MasterInfo("F003","0001","250"),
                    new MasterInfo("F004","0001","F01803"),
                    new MasterInfo("F005","0001","F00902")
            )));
            unitInfo.setUnitInfo(unitInfo.getUnitInfoMdJoinAll());
            unitInfos.add(unitInfo);
        }
        {
            UnitInfo unitInfo = new UnitInfo();
            unitInfo.setUnitInfoMdJoinAll(new HashSet<>(Arrays.asList(
                    new MasterInfo("F001","0001","3"),
                    new MasterInfo("F002","0001","2018-04-24"),
                    new MasterInfo("F003","0001","500"),
                    new MasterInfo("F004","0001","F01804"),
                    new MasterInfo("F005","0001","F00903")
            )));
            unitInfo.setUnitInfo(unitInfo.getUnitInfoMdJoinAll());
            unitInfos.add(unitInfo);
        }
 
        final UnitInfo unitInfo = unitInfos.get(0);
 
        return new IParamIter<UnitInfo>() {
 
            @Override
            public IParamIter<UnitInfo> setDataSource(CountParamMax param, List<BillData> billList) {
                return null;
            }
 
            @Override
            public UnitInfo next() {
                return null;
            }
 
            @Override
            public Boolean hasNext() {
                return null;
            }
 
            @Override
            public UnitInfo current() {
                return null;
            }
 
            @Override
            public Set<IOCRBill> getNoJoinAllBillInfo() {
                return null;
            }
 
            @Override
            public Double getNoJoinAllBillTotalMoney() {
                return null;
            }
 
            @Override
            public List<UnitInfo> getOldUnitInfos() {
                return unitInfos;
            }
 
            @Override
            public UnitInfo getEachOldUnitInfo() {
                return unitInfo;
            }
 
            @Override
            public Map<Integer, List<IOCRBill>> getBillList() {
                return new HashMap<>();
            }
 
            @Override
            public List<RuleMsg> getRuleMsg() {
                return new ArrayList<>();
            }
 
            @Override
            public List<ErrSystemMsg> getErrSystemMsgs() {
                return new ArrayList<>();
            }
 
            @Override
            public List<IOCRBill> getAllBillList() {
                return new ArrayList<>();
            }
 
            @Override
            public String getBillType() {
                return null;
            }
 
        };
    }
}