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
package com.changhong.epc;
 
import com.changhong.epc.bean.tenant.bill.IOCRBill;
import com.changhong.epc.bean.tenant.bill.OCRBillEntity;
import com.changhong.epc.count.service.count.data.paramiter.impl.ParamIter;
import com.changhong.epc.count.service.count.performer.impl.OtherTypeParamIter;
import com.iemsoft.framework.cloud.core.tools.JSONTool;
import org.junit.Test;
 
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
 
public class BillTest {
 
    @Test
    public void test(){
        OCRBillEntity billEntity = JSONTool.toObj("{\"billDatas\":[{\"allotTenant\":true,\"bhJouneryId\":8,\"billBodyEntityList\":[{\"billCode\":\"1813bb4b770a41fa9adb85233300bb50\",\"billKeyCode\":{\"R_VTax\":\"30.34\",\"Amount\":\"536.00\",\"R_EAmout\":\"505.66\"},\"billKeyName\":{\"R_VTax\":\"30.34\",\"Amount\":\"536.00\",\"R_EAmout\":\"505.66\"},\"billMasterCode\":{},\"billMasterName\":{},\"billMoney\":536.0,\"bodyDataMap\":{\"560054\":\"505.66\",\"590018\":\"*住宿服务*住宿费\",\"560081\":\"30.34\",\"560082\":\"6%\"},\"child\":[],\"costType\":{\"code\":\"quarterage\",\"name\":\"住宿费\"},\"ignore\":false}],\"billCode\":\"101GW20190100051-002-01\",\"billHeadMap\":{\"590006\":\"四川增值税专用发票\",\"620024\":\"20180322\",\"560133\":\"536.00\",\"560134\":\"536.0\",\"560038\":\"505.66\",\"550031\":\"\",\"590024\":\"四川省艾林投资集团艾林大千酒店有限公司\",\"550025\":\"07857434\",\"640003\":\"\",\"600042\":\"四川省绵阳市高新区绵兴东路35号0816-2418758\",\"600043\":\"工行绵阳市高新区支行2308412609022150272\",\"600044\":\"四川省内江市东兴区大千路666号0832-2222222\",\"600045\":\"中国工商银行股份有限公司内江中兴支行2307483109124917484\",\"520040\":\"四川\",\"560041\":\"30.34\",\"600008\":\"税总函[2016]659号西安印钞有限公司\",\"590010\":\"\",\"610007\":\"高\",\"570001\":\"抵扣联\",\"590012\":\"四川长虹电器股份有限公司\",\"550035\":\"91510700205412308D\",\"550099\":\"5100171130\",\"550055\":\"91511000777906493T\",\"580006\":\"018年03601*9%2B89%2B4/5/2//47>/8791%2B*\",\"500002\":\"无\",\"540040\":\"\"},\"billKeyCode\":{\"Amount\":\"nullnull\"},\"billKeyName\":{\"Amount\":\"nullnull\"},\"billMasterCode\":{},\"billMasterName\":{},\"billModelCode\":\"B00000000000\",\"child\":[],\"ignore\":false,\"ruleMsg\":[]},{\"allotTenant\":true,\"bhJouneryId\":8,\"billBodyEntityList\":[],\"billCode\":\"101GW20190100051-001-01\",\"billHeadMap\":{\"590006\":\"上海市国家税务局通用定额发票\",\"550025\":\"01733105\",\"550099\":\"131001727861\",\"560134\":\"20.0\",\"630001\":\"\",\"640003\":\"国家税务局监制\",\"590010\":\"上海华程西南国际旅行社有限公司\",\"550031\":\"20170813s00001065000\",\"570001\":\"发票联\",\"520040\":\"上海市\",\"540040\":\"发票专用章\"},\"billKeyCode\":{\"Amount\":\"20.0\"},\"billKeyName\":{\"Amount\":\"20.0\"},\"billMasterCode\":{},\"billMasterName\":{},\"billModelCode\":\"B00000030000\",\"child\":[],\"costType\":{\"code\":\"shineiJTF\",\"name\":\"市内交通费\"},\"ignore\":false,\"ruleMsg\":[]}],\"formId\":\"921a8ff3e3d0101f3a1946f2503cf79e\",\"orderCode\":\"101GW20190100051\",\"tenantId\":100000362}"
                , OCRBillEntity.class);
        List<IOCRBill> bills = new ArrayList<>();
        billEntity.getBillDatas()
                .stream()
                .map(ioc->new ParamIter().getIOCRBill(ioc))
                .forEach(bills::addAll);
        Double val = new ParamIter().marge(
                    bills
                        .stream()
                        .map(OtherTypeParamIter.OtherTypeIOCRBill::new)
                        .collect(Collectors.toList())
        ).stream()
                .map(ioc->BigDecimal.valueOf(ioc.getBillMoney()))
                .reduce(new BigDecimal(0), (a1, a2)->a1.add(a2))
                .doubleValue();
        System.out.println(val);
    }
 
}