Browse Source

检疫证扫描修改

wwh 2 years ago
parent
commit
3e85f24091

+ 75 - 0
admin/src/main/java/com/huimv/farm/damsubsidy/common/utils/WordToNum.java

@@ -0,0 +1,75 @@
+package com.huimv.farm.damsubsidy.common.utils;
+
+
+import org.apache.commons.lang.StringUtils;
+
+import java.math.BigDecimal;
+import java.util.*;
+
+public class WordToNum {
+    private static List<Map.Entry<String, String>> units = new ArrayList<>();
+
+    /*数字转换*/
+    private static Map<String, String> numbers2 = new HashMap<>();
+
+    static {
+        units.add(new AbstractMap.SimpleEntry<>("1000000000","亿"));
+        units.add(new AbstractMap.SimpleEntry<>("10000", "万"));
+        units.add(new AbstractMap.SimpleEntry<>("1000", "仟"));
+        units.add(new AbstractMap.SimpleEntry<>("100", "佰"));
+        units.add(new AbstractMap.SimpleEntry<>("10", "拾"));
+        units.add(new AbstractMap.SimpleEntry<>("1", "圆"));
+        units.add(new AbstractMap.SimpleEntry<>("0.1", "角"));
+        units.add(new AbstractMap.SimpleEntry<>("0.01", "分"));
+
+        numbers2.put("零", "0");
+        numbers2.put("壹", "1");
+        numbers2.put("贰", "2");
+        numbers2.put("叁", "3");
+        numbers2.put("肆", "4");
+        numbers2.put("伍", "5");
+        numbers2.put("陆", "6");
+        numbers2.put("柒", "7");
+        numbers2.put("捌", "8");
+        numbers2.put("玖", "9");
+
+
+    }
+
+    public Integer ToNumber(String chars) {
+        if (StringUtils.isBlank(chars)) {
+            return null;
+        } else {
+
+        }
+        Integer beginIndex1 = 0;//值
+        //
+        for (int i = 0; i < chars.length(); i++) {
+            String matchChars = chars.substring(i, i + 1);
+            for (Map.Entry<String, String> unit : units) {
+                String unitChars = unit.getValue();
+                if (matchChars == null || matchChars.equals("")) {
+                    return beginIndex1;
+                }
+                if (unitChars.equals(matchChars)) {
+                    String s = beginIndex1.toString();//当前值的长度
+                    String substring = s.substring(s.length() - 1);//当前值的个位
+                    Integer a= beginIndex1 - Integer.parseInt(substring);//当前值的抹零
+                    beginIndex1 = a+ Integer.parseInt(substring) * Integer.parseInt(unit.getKey());
+                }
+            }
+            if (numbers2.containsKey(matchChars)) {
+                beginIndex1 = beginIndex1 + Integer.parseInt(numbers2.get(matchChars));
+            }
+        }
+        return beginIndex1;
+    }
+
+/*    public static void main(String[] args) {
+
+        WordToNum wordToNum = new WordToNum();
+        Integer number = wordToNum.ToNumber("叁仟");
+        System.out.println(number);
+
+    }*/
+}

File diff suppressed because it is too large
+ 59 - 0
admin/src/main/java/com/huimv/farm/damsubsidy/controller/BillLandingInspectionController.java