package com.changhong.epc.form.service.budget.department; import com.changhong.autoform.entity.BudgetData; import com.changhong.autoform.entity.BudgetTitle; import com.changhong.epc.bean.form.FormType; import com.changhong.epc.bean.form.budget.BudgetUserDefined; import com.changhong.epc.bean.form.budget.BudgetUserDefined.Dimension; import com.changhong.epc.bean.form.budget.filtrate.BudgetclassifyKey; import com.changhong.epc.bean.form.budget.filtrate.BudgetclassifyValue; import com.changhong.epc.bean.tenant.cost.budgetlog.IBillCostLog; import com.changhong.epc.bean.tenant.cost.budgetlog.MoneyApplyLog; import com.changhong.epc.bean.tenant.cost.budgetlog.MoneyBudgetLog; import com.changhong.epc.bean.tenant.cost.budgetlog.MoneyExpendLog; import com.changhong.epc.constter.system.SystemClients; import com.changhong.epc.constter.system.businesscode.BudgetBusinessMeaningCode; import com.changhong.epc.constter.system.run.EpcRestInterface; import com.changhong.epc.constter.tenant.TenantUrlConst; import com.changhong.epc.form.service.budget.department.util.TitletTool; import com.iemsoft.framework.cloud.core.base.ResMsg; import com.iemsoft.framework.cloud.core.tools.SpringUtil; import com.iemsoft.framework.cloud.ribbon.RestInterface; import java.math.BigDecimal; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Objects; public abstract class SuperBudgt implements IDepartment, BudgetBusinessMeaningCode, SystemClients{ protected BudgetUserDefined budgetUserDefined; protected Map data; private Object iBillCostLog; //预算余额是否含有小数位数 protected Integer budgetItemBalanceType; //预算单id protected String superFormId = ""; public void setBudgetItemBalanceType(Integer budgetItemBalanceType){ this.budgetItemBalanceType = budgetItemBalanceType; } // protected void setIBillCostLog(IBillCostLog iBillCostLog){ // this.iBillCostLog = iBillCostLog; // } // // protected Object getIBillCostLog(){ // return this.iBillCostLog; // } @Override public boolean isFilter(Map data) { Double balance= 0D; try { balance = Double.valueOf(Objects.toString(data.get(BudgetBusinessMeaningCode.BUDGET_ITEM_BALANCE), "0")); } catch (NumberFormatException e) { } if(balance <= 0){ return false; } if(!budgetUserDefined.isFilterSubForm()){ return true; } for(List dimensionRow : budgetUserDefined.getSubDimensions()){ boolean folg = true; for(Dimension dimension: dimensionRow){ folg = Objects.equals(data.get(dimension.getName()),dimension.getValue()); if(!folg){ break; } } if(folg){ return true; } } return false; } protected Object getValueByBalanceType(BigDecimal money){ Object value = budgetItemBalanceType == 0 ? money.intValue() : money.setScale(budgetItemBalanceType, BigDecimal.ROUND_HALF_UP); return value; } /** * 将数据封装成 BudgetData * @param datas * @return */ protected List envelopedBudgetData(List> datas){ List budgetDatas = new ArrayList<>(); datas.forEach(o->{ BudgetData budgetData = new BudgetData(); budgetData.setFormData(o); budgetDatas.add(budgetData); }); return budgetDatas; } @Override public List getTitles(){ return TitletTool.getDefTitlet(); } public Object getPostRest(String url,Object parm){ RestInterface restInterface = SpringUtil.getBean(SERVER_TENANT.getBeanName(), RestInterface.class); Object data = restInterface.post(url, parm, ResMsg.class, EpcRestInterface.getEpcHeads()).getData(); return data; } /** * 记录费用类型变更日志 * @param billCostLog */ public void recordLog(IBillCostLog billCostLog){ if(billCostLog instanceof MoneyBudgetLog){ }else if(billCostLog instanceof MoneyApplyLog){ }else if(billCostLog instanceof MoneyExpendLog){ } } public void recordLog(FormType formType, IBillCostLog billCostLog){ switch (formType) { case YS: getPostRest(TenantUrlConst.REST_TENANT_COST_RECORDLOG_YS, billCostLog); break; case SQ: getPostRest(TenantUrlConst.REST_TENANT_COST_RECORDLOG_SQ, billCostLog); break; case BX: getPostRest(TenantUrlConst.REST_TENANT_COST_RECORDLOG_BX, billCostLog); break; default: break; } } }