package com.changhong.epc.count.service.count.data.condition.impl;
|
|
import com.changhong.epc.bean.tenant.norm.extend.AppStanderExtend;
|
import com.changhong.epc.bean.tenant.norm.extend.SuppStanderExtend;
|
import com.changhong.epc.count.service.count.data.condition.ICountConditionIter;
|
import com.changhong.epc.count.service.count.execution.ICounter;
|
import com.changhong.epc.count.service.count.execution.impl.FuncCountImpl;
|
import com.changhong.epc.count.service.count.execution.impl.SimpleCounterImpl;
|
import com.changhong.epc.count.service.count.model.AmountKey;
|
import com.changhong.epc.count.service.count.model.UnitInfo;
|
import com.iemsoft.framework.cloud.core.tools.ObjectUtil;
|
import com.iemsoft.framework.cloud.core.tools.SpringUtil;
|
import org.springframework.context.annotation.Scope;
|
import org.springframework.stereotype.Service;
|
|
import java.util.*;
|
|
/**
|
* 补助标准 数据迭代器
|
* @author wangZX
|
*
|
*/
|
@Service("countConditionIter")
|
@Scope("prototype")
|
public class CountConditionIterImpl implements ICountConditionIter<AppStanderExtend, SuppStanderExtend, UnitInfo>{
|
|
private List<SuppStanderExtend> suppStanderExtend;
|
|
private Iterator<SuppStanderExtend> groupIterator;
|
|
@Override
|
public CountConditionIterImpl setDataSource(List<SuppStanderExtend> data) {
|
if(data == null) return this;
|
suppStanderExtend = data;
|
|
init( data);
|
groupIterator = suppStanderExtend.iterator();
|
return this;
|
}
|
|
/**
|
* 将原始数据转换为可用数据
|
* @param data
|
*/
|
private void init(List<SuppStanderExtend> data) {
|
if(ObjectUtil.empty(data)){
|
return;
|
}
|
// 迭代每一大块
|
for (SuppStanderExtend supp : data) {
|
// 按照行号,分为补助,标准,金额,转换为二维矩阵
|
// System.err.println(JSONTool.toJson(supp));
|
Map<Integer,List<AppStanderExtend>> matrix = new HashMap<>();
|
for (AppStanderExtend appslist : supp.getAppStanderDefs()) {
|
// System.err.println(JSONTool.toJson(appslist));
|
if( matrix.get(appslist.getRowNo()) == null){
|
List<AppStanderExtend> temp = new ArrayList<>();
|
matrix.put(appslist.getRowNo(), temp);
|
}
|
matrix.get(appslist.getRowNo()).add(appslist);
|
}
|
MapToMatrix(supp,matrix);
|
}
|
// System.out.println(JSONTool.toJson(suppStanderExtend));
|
// System.out.println("将原始数据转换为可用数据");
|
}
|
|
private void MapToMatrix(SuppStanderExtend supp, Map<Integer, List<AppStanderExtend>> matrix) {
|
// System.out.println(JSONTool.toJson(supp));
|
List<List<AppStanderExtend>> matrixList = new ArrayList<>();
|
for (Integer colKey : matrix.keySet()) {
|
matrixList.add(matrix.get(colKey));
|
}
|
supp.setAppStanderDefMatrix(matrixList);
|
// System.out.println(JSONTool.toJson(supp));
|
}
|
|
@Override
|
public Boolean hasGropNext() {
|
return groupIterator !=null && groupIterator.hasNext();
|
}
|
private SuppStanderExtend currGroup;
|
List<List<AppStanderExtend>> appStanderDefTwe;
|
Iterator<List<AppStanderExtend>> rowIterator;
|
|
@Override
|
public void initGroup(){
|
appStanderDefTwe = currGroup.getAppStanderDefMatrix();
|
initRow();
|
}
|
|
@Override
|
public void groupNext() {
|
currGroup = groupIterator.next();
|
initGroup();
|
return ;
|
}
|
|
@Override
|
public SuppStanderExtend getCurrGroup() {
|
countEachSuppStanderCount(currGroup);
|
|
|
return currGroup;
|
}
|
|
|
@Override
|
public void gropReset() {
|
if(suppStanderExtend == null)
|
return ;
|
groupIterator = suppStanderExtend.iterator();
|
}
|
|
/***********************************************************************/
|
|
@Override
|
public void initRow(){
|
rowIterator = appStanderDefTwe.iterator();
|
}
|
|
@Override
|
public Boolean hasRowNext() {
|
return rowIterator.hasNext();
|
}
|
|
List<AppStanderExtend> currRow;
|
Iterator<AppStanderExtend> elem;
|
@Override
|
public void rowNext() {
|
currRow = rowIterator.next();
|
initCol();
|
return ;
|
}
|
|
@Override
|
public List<AppStanderExtend> cruuRow() {
|
return currRow;
|
}
|
|
@Override
|
public void initCol(){
|
elem = currRow.iterator();
|
}
|
|
@Override
|
public Boolean hasColNext() {
|
return elem.hasNext();
|
}
|
|
private AppStanderExtend currElem;
|
|
@Override
|
public AppStanderExtend colNext() {
|
currElem = elem.next();
|
return currElem;
|
}
|
|
@Override
|
public AppStanderExtend cruuCol() {
|
return currElem;
|
}
|
|
@Override
|
public ICounter<AppStanderExtend, UnitInfo> getExeCounter() {
|
return getExeCounter(this.cruuCol());
|
}
|
|
@Override
|
public ICounter<AppStanderExtend, UnitInfo> getExeCounter(AppStanderExtend appStanderExtend){
|
if(appStanderExtend.getDefType() == 5){
|
return SpringUtil.getBean(FuncCountImpl.class);
|
}else{
|
return SpringUtil.getBean(SimpleCounterImpl.class);
|
}
|
}
|
|
private Map<AmountKey, String> amountLastCount = new HashMap<>();
|
|
private void countEachSuppStanderCount(SuppStanderExtend guoup) {
|
if(guoup.getRule() != null
|
&& !Objects.equals(guoup.getRule(), "0")){
|
AmountKey k = new AmountKey();
|
// System.out.println("取值规则是:"+guoup.getRule());
|
k.fylx = guoup.getType(); // mdCode
|
// System.out.println("选择的补助类型:"+guoup.getType());
|
k.bxfs = guoup.getName(); // 报销方式
|
// System.out.println("报销方式是:"+guoup.getName());
|
k.id = String.valueOf(guoup.getId());//表中数据ID
|
// System.out.println("表单ID是:"+guoup.getId());
|
amountLastCount.put(k, guoup.getRule());
|
|
}
|
}
|
|
public Map<AmountKey, String> getRecord(){
|
return amountLastCount;
|
}
|
}
|