shikeying
2024-01-11 3b67e947e36133e2a40eb2737b15ea375e157ea0
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
package com.walker.openocr.oil;
 
import com.walker.openocr.TextBlock;
import com.walker.openocr.table.CellObject;
import com.walker.openocr.table.TableConfig;
import com.walker.openocr.table.TableObject;
import com.walker.openocr.table.TableTextResolver;
 
import java.util.List;
 
@Deprecated
public class OilPrintResolver extends TableTextResolver {
 
    public OilPrintResolver(){
        super();
    }
 
    @Override
    protected TableObject doResolveTable(List<TextBlock> dataList, List<TableConfig> configList) {
 
        double money = 0;
        for(TextBlock tb : dataList){
//            Class<?> type = StringUtils.getNumbericType(tb.getText());
//            if(type == Double.class || type == Long.class){
//            }
            try{
                money = Double.parseDouble(tb.getText());
            } catch (Exception ex){
                continue;
            }
            if(money < 0){
                logger.debug("找到了单据上负数,可能是金额:{}", money);
                break;
            }
        }
 
        TableObject tableObject = super.doResolveTable(dataList, configList);
 
        if(money != 0){
            CellObject jineCellObject = new CellObject();
            jineCellObject.setId("jin_e");
            jineCellObject.setValue(String.valueOf(money));
            tableObject.getTableDataMap().put("jin_e", jineCellObject);
        }
        return tableObject;
    }
}