commit | author | age
|
a18bfa
|
1 |
package com.changhong.epc.parsing.service.bill.group; |
Z |
2 |
|
|
3 |
import com.alibaba.fastjson.JSON; |
|
4 |
import com.changhong.epc.bean.form.Fieldsets; |
|
5 |
import com.changhong.epc.bean.parsing.BillInfo; |
|
6 |
import com.changhong.epc.bean.parsing.BillLevel; |
|
7 |
import com.changhong.epc.bean.tenant.bill.OCRBillEntity; |
|
8 |
import com.changhong.epc.bean.tenant.bill.OCRBillHeaderEntity; |
|
9 |
import com.changhong.epc.parsing.service.bill.BillMappingJourney; |
|
10 |
import com.changhong.epc.parsing.service.bill.impl.AbstractJourney; |
|
11 |
import com.changhong.epc.parsing.service.loop.tools.impl.SortBill; |
|
12 |
import com.changhong.epc.parsing.service.util.BillTool; |
|
13 |
import com.iemsoft.framework.cloud.core.tools.JSONTool; |
|
14 |
import lombok.extern.slf4j.Slf4j; |
|
15 |
import org.apache.commons.collections4.CollectionUtils; |
|
16 |
|
|
17 |
import javax.annotation.Resource; |
|
18 |
import java.util.ArrayList; |
|
19 |
import java.util.List; |
|
20 |
|
|
21 |
@Slf4j |
|
22 |
public abstract class AbstractGroupBill extends AbstractJourney implements BillMappingJourney{ |
|
23 |
|
|
24 |
@Resource |
|
25 |
private BillValToCode billValToCode; |
|
26 |
/** |
|
27 |
* 所有票据分组 |
|
28 |
*/ |
|
29 |
protected List<BillLevel> blAll = new ArrayList<>(); |
|
30 |
|
|
31 |
protected Fieldsets fieldsets; |
|
32 |
|
|
33 |
/* |
|
34 |
* 一组票据信息 |
|
35 |
*/ |
|
36 |
protected BillLevel billLevel; |
|
37 |
|
|
38 |
//@Override |
|
39 |
public void mappingJourney(BillInfo billInfo) { |
|
40 |
//sdfdsdsf |
|
41 |
List<OCRBillHeaderEntity> bills = getOCRBillEntity().getBillDatas(); |
|
42 |
if(CollectionUtils.isEmpty(bills)) |
|
43 |
return; |
|
44 |
|
|
45 |
/** |
|
46 |
* 1.获得表单基本信息 |
|
47 |
*/ |
|
48 |
this.fieldsets = this.billValToCode.getFieldsets(getOCRBillEntity()); |
|
49 |
|
|
50 |
/** |
|
51 |
* 2.获得城市间交通费 |
|
52 |
*/ |
|
53 |
setCityBill(); |
|
54 |
|
|
55 |
/** |
|
56 |
* 3.循环其他票据 |
|
57 |
*/ |
|
58 |
for (OCRBillHeaderEntity ocrBillHeaderEntity : bills) { |
|
59 |
/* 城市间交通费 */ |
|
60 |
if(BillTool.isJourneyBill(ocrBillHeaderEntity)) |
|
61 |
continue; |
|
62 |
setBillGroup(ocrBillHeaderEntity); |
|
63 |
} |
|
64 |
log.debug("编辑行程信息"); |
|
65 |
/** |
|
66 |
* 5.编辑行程信息,向子表单添加行程 |
|
67 |
*/ |
|
68 |
// System.err.println("子表单数据+"+JSONTool.toJson(billInfo)); |
|
69 |
editJourney(billInfo); |
|
70 |
log.debug("---------------------------->行程信息:\n" + JSON.toJSONString(blAll)); |
|
71 |
|
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* 获得票据中的城市间交通费 |
|
76 |
* @Title: getCityBill |
|
77 |
|
|
78 |
* @param @return 设定文件 |
|
79 |
* @return List<OCRBillHeaderEntity> 返回类型 |
|
80 |
* @throws |
|
81 |
*/ |
|
82 |
protected void setCityBill() { |
|
83 |
List<OCRBillHeaderEntity> allBill = getOCRBillEntity().getBillDatas(); |
|
84 |
log.debug("排序前票据信息:{}", JSONTool.toJson(allBill)); |
|
85 |
SortBill.sortBill(allBill); |
|
86 |
log.debug("排序后票据信息:{}", JSONTool.toJson(allBill)); |
|
87 |
/** |
|
88 |
* 2.迭代分组票据 |
|
89 |
*/ |
|
90 |
allBill.stream().forEach(ocrBillHeaderEntity -> { |
|
91 |
if(!BillTool.isJourneyBill(ocrBillHeaderEntity)){ |
|
92 |
return; |
|
93 |
} |
|
94 |
billLevel = new BillLevel(); |
|
95 |
setBillInfo(ocrBillHeaderEntity); |
|
96 |
billLevel.setBill(ocrBillHeaderEntity); |
|
97 |
blAll.add(billLevel); |
|
98 |
}); |
|
99 |
log.debug("过滤行程后:{}", JSONTool.toJson(blAll)); |
|
100 |
} |
|
101 |
|
|
102 |
/** |
|
103 |
* 对除 城市间交通费 其他说有票据进行分组处理 |
|
104 |
* @param bill |
|
105 |
* @return |
|
106 |
*/ |
|
107 |
protected boolean setBillGroup(OCRBillHeaderEntity bill) { |
|
108 |
for (BillLevel eachBillLevel : blAll) { |
|
109 |
if(BillGroupRule.billEquery(eachBillLevel, bill)){ |
|
110 |
eachBillLevel.setBill(bill); |
|
111 |
return Boolean.TRUE; |
|
112 |
} |
|
113 |
} |
|
114 |
return Boolean.FALSE; |
|
115 |
} |
|
116 |
|
|
117 |
/** |
|
118 |
* @param billInfo |
|
119 |
* 编辑行程 |
|
120 |
* @Title: editJourney |
|
121 |
|
|
122 |
* @param |
|
123 |
* @return void 返回类型 |
|
124 |
* @throws |
|
125 |
*/ |
|
126 |
protected abstract void editJourney(BillInfo billInfo); |
|
127 |
|
|
128 |
/** |
|
129 |
* set票据信息 |
|
130 |
* @Title: setBillInfo |
|
131 |
|
|
132 |
* @param @param bill 设定文件 |
|
133 |
* @return void 返回类型 |
|
134 |
* @throws |
|
135 |
*/ |
|
136 |
protected void setBillInfo(OCRBillHeaderEntity bill) { |
|
137 |
/** |
|
138 |
* 1.添加一组票据时间 |
|
139 |
*/ |
|
140 |
/* |
|
141 |
* 出发地 |
|
142 |
*/ |
|
143 |
billLevel.setBeginSit(bill.getVal(FROM)); |
|
144 |
/* |
|
145 |
* 到达地 |
|
146 |
*/ |
|
147 |
billLevel.setEndSit(bill.getVal(TO)); |
|
148 |
/* |
|
149 |
* 开始日期 |
|
150 |
*/ |
|
151 |
String formDate = bill.getVal(FROM_DATE); |
|
152 |
billLevel.setBeginDate(formDate); |
|
153 |
/* |
|
154 |
* 开始时间 |
|
155 |
*/ |
|
156 |
String formTime = bill.getVal(FROM_TIME); |
|
157 |
billLevel.setBeginTime(formTime); |
|
158 |
/* |
|
159 |
* 截止日期 |
|
160 |
*/ |
|
161 |
billLevel.setEndDate(bill.getVal(TO_DATE)); |
|
162 |
/* |
|
163 |
* 缓存截止时间 |
|
164 |
*/ |
|
165 |
billLevel.setCacheEndDate(bill.getVal(TO_DATE)); |
|
166 |
/* |
|
167 |
* 截止时间 |
|
168 |
*/ |
|
169 |
billLevel.setEndTime(bill.getVal(TO_TIME)); |
|
170 |
|
|
171 |
/** |
|
172 |
* 2.修改上一组票据的结束时间 |
|
173 |
*/ |
|
174 |
if(CollectionUtils.isNotEmpty(blAll)){ |
|
175 |
BillLevel lastBl = blAll.get(blAll.size()-1); |
|
176 |
lastBl.setEndDate(formDate); |
|
177 |
lastBl.setEndTime(formTime); |
|
178 |
} |
|
179 |
} |
|
180 |
|
|
181 |
/** |
|
182 |
* 获得所有票据信息 |
|
183 |
* @Title: getBillInfo |
|
184 |
|
|
185 |
* @param @return 设定文件 |
|
186 |
* @return OCRBillEntity 返回类型 |
|
187 |
* @throws |
|
188 |
*/ |
|
189 |
protected abstract OCRBillEntity getOCRBillEntity(); |
|
190 |
|
|
191 |
/** |
|
192 |
* 获得原始票据 |
|
193 |
* @Title: getOldOCRBillEntity |
|
194 |
* @param @return 设定文件 |
|
195 |
* @return OCRBillEntity 返回类型 |
|
196 |
* @throws |
|
197 |
*/ |
|
198 |
protected abstract OCRBillEntity getOldOCRBillEntity(); |
|
199 |
|
|
200 |
|
|
201 |
|
|
202 |
} |