@ -10,22 +10,23 @@ import com.qs.serve.common.framework.manager.AsyncManager;
import com.qs.serve.common.model.enums.BudgetLogOptFlag ;
import com.qs.serve.common.model.enums.BudgetLogOptFlag ;
import com.qs.serve.common.model.consts.BudgetLogRollbackFlag ;
import com.qs.serve.common.model.consts.BudgetLogRollbackFlag ;
import com.qs.serve.common.model.dto.R ;
import com.qs.serve.common.model.dto.R ;
import com.qs.serve.common.model.enums.MonthValues ;
import com.qs.serve.common.util.* ;
import com.qs.serve.common.util.* ;
import com.qs.serve.common.util.model.DateFormatString ;
import com.qs.serve.common.util.model.DateFormatString ;
import com.qs.serve.modules.bir.entity.BirActivityCenterGoods ;
import com.qs.serve.modules.bir.entity.BirActivityCenterGoods ;
import com.qs.serve.modules.bir.entity.BirBaseActivity ;
import com.qs.serve.modules.bir.entity.BirBaseActivity ;
import com.qs.serve.modules.bir.entity.dto.BirRoiCostDTO ;
import com.qs.serve.modules.bir.entity.dto.BirRoiCostDTO ;
import com.qs.serve.modules.bir.entity.vo.BirRoiCostItemVo ;
import com.qs.serve.modules.bir.entity.vo.YtdQtdToOAVo ;
import com.qs.serve.modules.bir.entity.vo.YtdQtdToOAVo ;
import com.qs.serve.modules.bir.mapper.BirActivityCenterGoodsMapper ;
import com.qs.serve.modules.bir.mapper.BirActivityCenterGoodsMapper ;
import com.qs.serve.modules.bir.mapper.BirBaseActivityMapper ;
import com.qs.serve.modules.bir.mapper.BirBaseActivityMapper ;
import com.qs.serve.modules.bir.mapper.BirRoiRateMapper ;
import com.qs.serve.modules.bir.service.BirCenterRateService ;
import com.qs.serve.modules.bir.service.BirCenterRateService ;
import com.qs.serve.modules.bir.service.BirRoiRateService ;
import com.qs.serve.modules.bir.service.BirRoiRateService ;
import com.qs.serve.modules.bms.entity.BmsRegion ;
import com.qs.serve.modules.bms.entity.* ;
import com.qs.serve.modules.bms.entity.BmsRegion2 ;
import com.qs.serve.modules.bms.entity.BmsSubject ;
import com.qs.serve.modules.bms.entity.BmsSupplier ;
import com.qs.serve.modules.bms.mapper.BmsRegion2Mapper ;
import com.qs.serve.modules.bms.mapper.BmsRegion2Mapper ;
import com.qs.serve.modules.bms.mapper.BmsRegionMapper ;
import com.qs.serve.modules.bms.mapper.BmsRegionMapper ;
import com.qs.serve.modules.bms.mapper.BmsSupplierTargetMapper ;
import com.qs.serve.modules.bms.service.BmsSubjectService ;
import com.qs.serve.modules.bms.service.BmsSubjectService ;
import com.qs.serve.modules.bms.service.BmsSupplierService ;
import com.qs.serve.modules.bms.service.BmsSupplierService ;
import com.qs.serve.modules.erp.entity.dto.ErpDispatchSumVo ;
import com.qs.serve.modules.erp.entity.dto.ErpDispatchSumVo ;
@ -112,6 +113,11 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC
private BirCenterRateService centerRateService ;
private BirCenterRateService centerRateService ;
private BirActivityCenterGoodsMapper birActivityCenterGoodsMapper ;
private BirActivityCenterGoodsMapper birActivityCenterGoodsMapper ;
private BirBaseActivityMapper birBaseActivityMapper ;
private BirBaseActivityMapper birBaseActivityMapper ;
private BirRoiRateMapper birRoiRateMapper ;
private final ErpDispatchDataMapper dispatchDataMapper ;
private TbsScheduleItemMapper tbsScheduleItemMapper ;
private BmsSupplierTargetMapper bmsSupplierTargetMapper ;
private TbsBudgetMatchApplication tbsBudgetMatchApplication ;
private TbsBudgetMatchApplication tbsBudgetMatchApplication ;
@ -572,61 +578,8 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC
List < TbsCostContract > contracts = costContractMapper . selectList ( lqw ) ;
List < TbsCostContract > contracts = costContractMapper . selectList ( lqw ) ;
if ( contracts . size ( ) > 0 ) {
if ( contracts . size ( ) > 0 ) {
//活动的科目和成本中心
//构建合同DATA
List < TbsActivityCenter > tbsActivityCenters = tbsActivityCenterService . listByCostApplyId ( Long . parseLong ( id ) ) ;
buildContractSeeyonData ( id , data , contracts ) ;
String concatCenterCodes = tbsActivityCenters . stream ( ) . map ( TbsActivityCenter : : getCenterCode ) . collect ( Collectors . joining ( "," ) ) ;
String concatCenterNames = tbsActivityCenters . stream ( ) . map ( TbsActivityCenter : : getCenterName ) . collect ( Collectors . joining ( "," ) ) ;
List < TbsActivitySubject > tbsActivitySubjects = tbsActivitySubjectService . listByCostApplyId ( Long . parseLong ( id ) ) ;
List < Long > subjectIds = tbsActivitySubjects . stream ( ) . map ( a - > a . getSubjectId ( ) ) . collect ( Collectors . toList ( ) ) ;
if ( subjectIds . size ( ) > 0 ) {
List < BmsSubject > subjectList = subjectService . listByIds ( subjectIds ) ;
String concatSubjectCodes = subjectList . stream ( ) . map ( BmsSubject : : getThirdCode ) . collect ( Collectors . joining ( "," ) ) ;
String concatSubjectNames = subjectList . stream ( ) . map ( BmsSubject : : getThirdName ) . collect ( Collectors . joining ( "," ) ) ;
data . put ( "financeAccountCode" , concatSubjectCodes ) ;
data . put ( "financeAccountName" , concatSubjectNames ) ;
data . put ( "accountCode" , concatSubjectCodes ) ;
data . put ( "accountName" , concatSubjectNames ) ;
}
TbsCostContract contract = contracts . get ( 0 ) ;
data . put ( "payee" , contract . getPayee ( ) ) ;
data . put ( "bankName" , contract . getBankName ( ) ) ;
data . put ( "bankAccount" , contract . getBankAccount ( ) ) ;
data . put ( "sealID" , contract . getSealId ( ) ) ;
data . put ( "sealName" , contract . getSealName ( ) ) ;
data . put ( "sealNum" , contract . getSealNum ( ) ) ;
data . put ( "fileNum" , contract . getFileNum ( ) ) ;
data . put ( "costCenterNo" , concatCenterCodes ) ;
data . put ( "costCenterName" , concatCenterNames ) ;
data . put ( "businessCompany" , contract . getBusinessCompany ( ) ) ;
data . put ( "businessCompanyId" , contract . getDutyNumber ( ) ) ;
data . put ( "contractName" , contract . getContractName ( ) ) ;
data . put ( "applyMoney" , contract . getContractAmount ( ) ) ;
data . put ( "signDate" , contract . getSignTime ( ) = = null ? null : contract . getSignTime ( ) . toString ( ) ) ;
data . put ( "expireDate" , contract . getExpireTime ( ) = = null ? null : contract . getExpireTime ( ) . toString ( ) ) ;
data . put ( "contractContent" , contract . getContractCondition ( ) ) ;
String urls = "" ;
final String ossPrefix = "https://qsjslservice.oss-cn-guangzhou.aliyuncs.com/" ;
if ( CollectionUtil . isNotEmpty ( contract . getAttachIds ( ) ) ) {
List < String > attachIds = Arrays . asList ( contract . getAttachIds ( ) ) ;
List < SysAttach > attachList = sysAttachService . listByIds ( attachIds ) ;
urls = attachList . stream ( ) . map ( a - > {
if ( a . getPath ( ) ! = null ) {
try {
String tmp = URLEncoder . encode ( a . getPath ( ) , "UTF8" ) . replace ( "%2F" , "/" ) ;
return ossPrefix + tmp ;
} catch ( UnsupportedEncodingException e ) {
e . printStackTrace ( ) ;
}
}
return "" ;
} ) . collect ( Collectors . joining ( " , " ) ) ;
}
data . put ( "contractFile" , urls ) ;
} else {
} else {
Assert . throwEx ( "请补充合同信息" ) ;
Assert . throwEx ( "请补充合同信息" ) ;
}
}
@ -635,33 +588,7 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC
List < Object > subList = new ArrayList < > ( ) ;
List < Object > subList = new ArrayList < > ( ) ;
//活动明细
//活动明细
LambdaQueryWrapper < TbsActivityCenterGoods > actCgLqw = new LambdaQueryWrapper < > ( ) ;
buildActivityCenterGoodsSeeyonData ( id , tbsCostApply , activityList , subList ) ;
actCgLqw . eq ( TbsActivityCenterGoods : : getCostApplyId , id ) ;
List < TbsActivityCenterGoods > activityCenterGoodsList = tbsActivityCenterGoodsMapper . selectList ( actCgLqw ) ;
for ( TbsActivityCenterGoods centerGoods : activityCenterGoodsList ) {
TbsActivity currActivity = null ;
for ( TbsActivity activity : activityList ) {
if ( centerGoods . getActivityId ( ) . equals ( activity . getId ( ) ) ) {
currActivity = activity ;
break ;
}
}
TbsContractCostSubItem . Activity dataActivity = new TbsContractCostSubItem . Activity ( ) ;
dataActivity . setActivityCode ( currActivity . getActivityCode ( ) ) ;
dataActivity . setActivityPurpose ( currActivity . getActTitle ( ) ) ;
dataActivity . setCostCode ( tbsCostApply . getCode ( ) ) ;
dataActivity . setStartDate ( currActivity . getActStartDate ( ) = = null ? null : currActivity . getActStartDate ( ) . toString ( ) ) ;
dataActivity . setEndDate ( currActivity . getActEndDate ( ) = = null ? null : currActivity . getActEndDate ( ) . toString ( ) ) ;
dataActivity . setWriteOffDate ( currActivity . getPreCheckDate ( ) = = null ? null : currActivity . getPreCheckDate ( ) . toString ( ) ) ;
dataActivity . setProductType ( GoodsType . getName ( centerGoods . getTargetType ( ) ) ) ;
dataActivity . setProduct ( centerGoods . getTargetName ( ) ) ;
dataActivity . setActivityAccountCode ( centerGoods . getSubjectCode ( ) ) ;
dataActivity . setActivityAccountName ( centerGoods . getSubjectName ( ) ) ;
dataActivity . setActivityCostCenterNo ( centerGoods . getCenterCode ( ) ) ;
dataActivity . setActivityCostCenterName ( centerGoods . getCenterName ( ) + "(" + centerGoods . getCenterType ( ) + ")" ) ;
dataActivity . setMoney ( centerGoods . getCenterGoodsAmount ( ) ) ;
subList . add ( dataActivity ) ;
}
// 付款条件
// 付款条件
for ( TbsActivityPayCondition payCondition : payConditions ) {
for ( TbsActivityPayCondition payCondition : payConditions ) {
// TbsActivity currActivity = null;
// TbsActivity currActivity = null;
@ -697,10 +624,240 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC
toDoItem . setAgreeCompleteState ( costTodo . getFinishedFlag ( ) . equals ( 1 ) ? "已完成" : "未完成" ) ;
toDoItem . setAgreeCompleteState ( costTodo . getFinishedFlag ( ) . equals ( 1 ) ? "已完成" : "未完成" ) ;
subList . add ( toDoItem ) ;
subList . add ( toDoItem ) ;
}
}
//构造客户维度的 年度、季度合计
try {
List < TbsContractCostSubItem . CusCenterRate > cusCenterRateList = buildCusRateMain ( supplier ) ;
subList . addAll ( cusCenterRateList ) ;
} catch ( Exception e ) {
log . error ( "[构造客户维度的 年度、季度合计]异常:{}" , e . getMessage ( ) ) ;
}
//关联
//关联
data . put ( "sub" , subList ) ;
data . put ( "sub" , subList ) ;
}
}
private void buildActivityCenterGoodsSeeyonData ( String id , TbsCostApply tbsCostApply , List < TbsActivity > activityList , List < Object > subList ) {
LambdaQueryWrapper < TbsActivityCenterGoods > actCgLqw = new LambdaQueryWrapper < > ( ) ;
actCgLqw . eq ( TbsActivityCenterGoods : : getCostApplyId , id ) ;
List < TbsActivityCenterGoods > activityCenterGoodsList = tbsActivityCenterGoodsMapper . selectList ( actCgLqw ) ;
for ( TbsActivityCenterGoods centerGoods : activityCenterGoodsList ) {
TbsActivity currActivity = null ;
for ( TbsActivity activity : activityList ) {
if ( centerGoods . getActivityId ( ) . equals ( activity . getId ( ) ) ) {
currActivity = activity ;
break ;
}
}
TbsContractCostSubItem . Activity dataActivity = new TbsContractCostSubItem . Activity ( ) ;
dataActivity . setActivityCode ( currActivity . getActivityCode ( ) ) ;
dataActivity . setActivityPurpose ( currActivity . getActTitle ( ) ) ;
dataActivity . setCostCode ( tbsCostApply . getCode ( ) ) ;
dataActivity . setStartDate ( currActivity . getActStartDate ( ) = = null ? null : currActivity . getActStartDate ( ) . toString ( ) ) ;
dataActivity . setEndDate ( currActivity . getActEndDate ( ) = = null ? null : currActivity . getActEndDate ( ) . toString ( ) ) ;
dataActivity . setWriteOffDate ( currActivity . getPreCheckDate ( ) = = null ? null : currActivity . getPreCheckDate ( ) . toString ( ) ) ;
dataActivity . setProductType ( GoodsType . getName ( centerGoods . getTargetType ( ) ) ) ;
dataActivity . setProduct ( centerGoods . getTargetName ( ) ) ;
dataActivity . setActivityAccountCode ( centerGoods . getSubjectCode ( ) ) ;
dataActivity . setActivityAccountName ( centerGoods . getSubjectName ( ) ) ;
dataActivity . setActivityCostCenterNo ( centerGoods . getCenterCode ( ) ) ;
dataActivity . setActivityCostCenterName ( centerGoods . getCenterName ( ) + "(" + centerGoods . getCenterType ( ) + ")" ) ;
dataActivity . setMoney ( centerGoods . getCenterGoodsAmount ( ) ) ;
subList . add ( dataActivity ) ;
}
}
private void buildContractSeeyonData ( String id , Map < String , Object > data , List < TbsCostContract > contracts ) {
//活动的科目和成本中心
List < TbsActivityCenter > tbsActivityCenters = tbsActivityCenterService . listByCostApplyId ( Long . parseLong ( id ) ) ;
String concatCenterCodes = tbsActivityCenters . stream ( ) . map ( TbsActivityCenter : : getCenterCode ) . collect ( Collectors . joining ( "," ) ) ;
String concatCenterNames = tbsActivityCenters . stream ( ) . map ( TbsActivityCenter : : getCenterName ) . collect ( Collectors . joining ( "," ) ) ;
List < TbsActivitySubject > tbsActivitySubjects = tbsActivitySubjectService . listByCostApplyId ( Long . parseLong ( id ) ) ;
List < Long > subjectIds = tbsActivitySubjects . stream ( ) . map ( a - > a . getSubjectId ( ) ) . collect ( Collectors . toList ( ) ) ;
if ( subjectIds . size ( ) > 0 ) {
List < BmsSubject > subjectList = subjectService . listByIds ( subjectIds ) ;
String concatSubjectCodes = subjectList . stream ( ) . map ( BmsSubject : : getThirdCode ) . collect ( Collectors . joining ( "," ) ) ;
String concatSubjectNames = subjectList . stream ( ) . map ( BmsSubject : : getThirdName ) . collect ( Collectors . joining ( "," ) ) ;
data . put ( "financeAccountCode" , concatSubjectCodes ) ;
data . put ( "financeAccountName" , concatSubjectNames ) ;
data . put ( "accountCode" , concatSubjectCodes ) ;
data . put ( "accountName" , concatSubjectNames ) ;
}
TbsCostContract contract = contracts . get ( 0 ) ;
data . put ( "payee" , contract . getPayee ( ) ) ;
data . put ( "bankName" , contract . getBankName ( ) ) ;
data . put ( "bankAccount" , contract . getBankAccount ( ) ) ;
data . put ( "sealID" , contract . getSealId ( ) ) ;
data . put ( "sealName" , contract . getSealName ( ) ) ;
data . put ( "sealNum" , contract . getSealNum ( ) ) ;
data . put ( "fileNum" , contract . getFileNum ( ) ) ;
data . put ( "costCenterNo" , concatCenterCodes ) ;
data . put ( "costCenterName" , concatCenterNames ) ;
data . put ( "businessCompany" , contract . getBusinessCompany ( ) ) ;
data . put ( "businessCompanyId" , contract . getDutyNumber ( ) ) ;
data . put ( "contractName" , contract . getContractName ( ) ) ;
data . put ( "applyMoney" , contract . getContractAmount ( ) ) ;
data . put ( "signDate" , contract . getSignTime ( ) = = null ? null : contract . getSignTime ( ) . toString ( ) ) ;
data . put ( "expireDate" , contract . getExpireTime ( ) = = null ? null : contract . getExpireTime ( ) . toString ( ) ) ;
data . put ( "contractContent" , contract . getContractCondition ( ) ) ;
String urls = "" ;
final String ossPrefix = "https://qsjslservice.oss-cn-guangzhou.aliyuncs.com/" ;
if ( CollectionUtil . isNotEmpty ( contract . getAttachIds ( ) ) ) {
List < String > attachIds = Arrays . asList ( contract . getAttachIds ( ) ) ;
List < SysAttach > attachList = sysAttachService . listByIds ( attachIds ) ;
urls = attachList . stream ( ) . map ( a - > {
if ( a . getPath ( ) ! = null ) {
try {
String tmp = URLEncoder . encode ( a . getPath ( ) , "UTF8" ) . replace ( "%2F" , "/" ) ;
return ossPrefix + tmp ;
} catch ( UnsupportedEncodingException e ) {
e . printStackTrace ( ) ;
}
}
return "" ;
} ) . collect ( Collectors . joining ( " , " ) ) ;
}
data . put ( "contractFile" , urls ) ;
}
@NotNull
private List < TbsContractCostSubItem . CusCenterRate > buildCusRateMain ( BmsSupplier supplier ) {
List < BmsSupplierTarget > supplierTargetList = bmsSupplierTargetMapper . selectList (
new LambdaQueryWrapper < BmsSupplierTarget > ( )
. eq ( BmsSupplierTarget : : getSupplierId , supplier . getId ( ) )
) ;
List < Long > scheduleItemIds = supplierTargetList . stream ( ) . map ( BmsSupplierTarget : : getScheduleItemId ) . collect ( Collectors . toList ( ) ) ;
List < Long > scheduleIds = supplierTargetList . stream ( ) . map ( BmsSupplierTarget : : getScheduleId ) . collect ( Collectors . toList ( ) ) ;
List < TbsScheduleItem > scheduleItems = null ;
if ( scheduleItemIds . size ( ) > 0 & & scheduleIds . size ( ) > 0 ) {
LambdaQueryWrapper < TbsScheduleItem > scheduleItemsLqw = new LambdaQueryWrapper < > ( ) ;
scheduleItemsLqw . in ( TbsScheduleItem : : getId , scheduleItemIds ) ;
scheduleItemsLqw . in ( TbsScheduleItem : : getScheduleId , scheduleIds ) ;
scheduleItems = tbsScheduleItemMapper . selectList ( scheduleItemsLqw ) ;
}
//最近12个月
LocalDate currMonth = LocalDate . now ( ) ;
int currMonthNum = currMonth . getYear ( ) * 100 + currMonth . getMonthValue ( ) ;
LocalDate startMonth = currMonth . plusMonths ( - 12 ) ;
int startMonthNum = startMonth . getYear ( ) * 100 + startMonth . getMonthValue ( ) ;
//发货金额
List < ErpDispatchSumVo > dispatchSumVos = dispatchDataMapper . querySumCost ( startMonthNum , currMonthNum , Arrays . asList ( supplier . getCode ( ) ) ) ;
//客户核销金额
BirRoiCostDTO costDTO = new BirRoiCostDTO ( ) ;
costDTO . setStartMonthNum ( startMonthNum ) ;
costDTO . setEndMonthNum ( currMonthNum ) ;
costDTO . setSupplierId ( supplier . getId ( ) ) ;
List < BirRoiCostItemVo > costItemVoList = birRoiRateMapper . queryRoiCostItems ( costDTO ) ;
//用户季度费率
List < TbsContractCostSubItem . CusCenterRate > cusCenterRateList =
this . buildCusCenterRate ( supplierTargetList , scheduleItems , currMonth , startMonth , dispatchSumVos , costItemVoList ) ;
//用户年费率
this . buildCusCenterYearRate ( supplierTargetList , dispatchSumVos , costItemVoList , cusCenterRateList ) ;
return cusCenterRateList ;
}
/ * *
* 用户年费率
* @param supplierTargetList
* @param dispatchSumVos
* @param costItemVoList
* @param cusCenterRateList
* /
private void buildCusCenterYearRate ( List < BmsSupplierTarget > supplierTargetList , List < ErpDispatchSumVo > dispatchSumVos , List < BirRoiCostItemVo > costItemVoList , List < TbsContractCostSubItem . CusCenterRate > cusCenterRateList ) {
BigDecimal dispatchAmt = BigDecimal . ZERO ;
BigDecimal totalCost = BigDecimal . ZERO ;
BigDecimal cusDispatch = BigDecimal . ZERO ;
BigDecimal cusCost = BigDecimal . ZERO ;
for ( ErpDispatchSumVo dispatchSumVo : dispatchSumVos ) {
dispatchAmt = dispatchAmt . add ( dispatchSumVo . getDispatchSumCost ( ) ) ;
}
for ( BirRoiCostItemVo itemVo : costItemVoList ) {
totalCost = totalCost . add ( itemVo . getCostRealAmt ( ) ) ;
}
for ( BmsSupplierTarget supplierTarget : supplierTargetList ) {
cusDispatch = cusDispatch . add ( supplierTarget . getTargetCostAmount ( ) ) ;
cusCost = cusCost . add ( supplierTarget . getTargetCostAmount ( ) ) ;
}
for ( TbsContractCostSubItem . CusCenterRate centerRate : cusCenterRateList ) {
centerRate . setYtdCusCenterCost ( totalCost . toString ( ) ) ;
centerRate . setYtdCusCenterSend ( dispatchAmt . toString ( ) ) ;
centerRate . setYtdCusCenterExpenseRate ( totalCost . divide ( dispatchAmt , RoundingMode . DOWN ) . toString ( ) ) ;
if ( cusCost . compareTo ( BigDecimal . ZERO ) ! = 0 & & cusDispatch . compareTo ( BigDecimal . ZERO ) ! = 0 ) {
centerRate . setYtdCusCenterTargetExpenseRate ( cusCost . divide ( cusDispatch , RoundingMode . DOWN ) . toString ( ) ) ;
}
}
}
/ * *
* 创建客户维度的季度费率
* @param supplierTargetList
* @param scheduleItems
* @param currMonth
* @param startMonth
* @param dispatchSumVos
* @param costItemVoList
* /
private List < TbsContractCostSubItem . CusCenterRate > buildCusCenterRate ( List < BmsSupplierTarget > supplierTargetList ,
List < TbsScheduleItem > scheduleItems ,
LocalDate currMonth , LocalDate startMonth ,
List < ErpDispatchSumVo > dispatchSumVos ,
List < BirRoiCostItemVo > costItemVoList ) {
List < TbsContractCostSubItem . CusCenterRate > cusCenterRateList = new ArrayList < > ( ) ;
int [ ] currQ = MonthValues . getQArr ( startMonth . getMonthValue ( ) ) ;
if ( currQ ! = null ) {
BigDecimal dispatchAmt = BigDecimal . ZERO ;
BigDecimal totalCost = BigDecimal . ZERO ;
BigDecimal cusDispatch = BigDecimal . ZERO ;
BigDecimal cusCost = BigDecimal . ZERO ;
for ( int monthVal : currQ ) {
int monthNum = currMonth . getYear ( ) * 100 + monthVal ;
if ( dispatchSumVos ! = null ) {
for ( ErpDispatchSumVo dispatchSumVo : dispatchSumVos ) {
if ( dispatchSumVo . getYearMonth ( ) . equals ( monthNum ) ) {
dispatchAmt = dispatchAmt . add ( dispatchSumVo . getDispatchSumCost ( ) ) ;
break ;
}
}
}
for ( BirRoiCostItemVo itemVo : costItemVoList ) {
if ( itemVo . getYearMonth ( ) . equals ( monthNum ) ) {
totalCost = totalCost . add ( itemVo . getCostRealAmt ( ) ) ;
}
}
if ( scheduleItems ! = null ) {
for ( BmsSupplierTarget supplierTarget : supplierTargetList ) {
for ( TbsScheduleItem item : scheduleItems ) {
//匹配条件
if ( supplierTarget . getScheduleItemId ( ) . equals ( item . getId ( ) ) ) {
//匹配时间
int itemMonth = item . getStartDate ( ) . getMonthValue ( ) ;
if ( itemMonth = = monthVal ) {
cusDispatch = cusDispatch . add ( supplierTarget . getTargetCostAmount ( ) ) ;
cusCost = cusCost . add ( supplierTarget . getTargetCostAmount ( ) ) ;
break ;
}
}
}
}
}
}
TbsContractCostSubItem . CusCenterRate centerRate = new TbsContractCostSubItem . CusCenterRate ( ) ;
centerRate . setQtdCusCenterCost ( totalCost . toString ( ) ) ;
centerRate . setQtdCusCenterSend ( dispatchAmt . toString ( ) ) ;
centerRate . setQtdCusCenterExpenseRate ( totalCost . divide ( dispatchAmt , RoundingMode . DOWN ) . toString ( ) ) ;
if ( cusCost . compareTo ( BigDecimal . ZERO ) ! = 0 & & cusDispatch . compareTo ( BigDecimal . ZERO ) ! = 0 ) {
centerRate . setQtdCusCenterTargetExpenseRate ( cusCost . divide ( cusDispatch , RoundingMode . DOWN ) . toString ( ) ) ;
}
cusCenterRateList . add ( centerRate ) ;
}
return cusCenterRateList ;
}
private void buildCommonApplyData ( String id , TbsCostApply tbsCostApply , List < TbsActivity > activityList , BmsSupplier supplier , SysUser sysUser , Map < String , Object > data ) {
private void buildCommonApplyData ( String id , TbsCostApply tbsCostApply , List < TbsActivity > activityList , BmsSupplier supplier , SysUser sysUser , Map < String , Object > data ) {
String actTitles = activityList . stream ( ) . map ( TbsActivity : : getActTitle ) . collect ( Collectors . joining ( "; " ) ) ;
String actTitles = activityList . stream ( ) . map ( TbsActivity : : getActTitle ) . collect ( Collectors . joining ( "; " ) ) ;
data . put ( "costApplyCode" , tbsCostApply . getCode ( ) ) ;
data . put ( "costApplyCode" , tbsCostApply . getCode ( ) ) ;
@ -753,7 +910,14 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC
try {
try {
this . buildSubList ( tbsActivityCenters , subjectNames , subList ) ;
this . buildSubList ( tbsActivityCenters , subjectNames , subList ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
e . printStackTrace ( ) ;
log . error ( "【费用申请,创建子表数据】:{}" , e . getMessage ( ) ) ;
}
//构造客户维度的 年度、季度合计
try {
List < TbsContractCostSubItem . CusCenterRate > cusCenterRateList = buildCusRateMain ( supplier ) ;
subList . addAll ( cusCenterRateList ) ;
} catch ( Exception e ) {
log . error ( "【费用申请,创建客户维度费率数据】:{}" , e . getMessage ( ) ) ;
}
}
//创建商品抬头列表
//创建商品抬头列表
List < TbsActivityGoods > tbsActivityGoods = tbsActivityGoodsService . listByCostApplyId ( Long . parseLong ( id ) ) ;
List < TbsActivityGoods > tbsActivityGoods = tbsActivityGoodsService . listByCostApplyId ( Long . parseLong ( id ) ) ;
@ -827,7 +991,7 @@ public class TbsCostApplyServiceImpl extends ServiceImpl<TbsCostApplyMapper,TbsC
//成本中心去重
//成本中心去重
Map < String , List < TbsActivityCenter > > centerMapList = tbsActivityCenters . stream ( ) . collect ( Collectors . groupingBy ( a - > a . getCenterType ( ) + "-" + a . getCenterId ( ) ) ) ;
Map < String , List < TbsActivityCenter > > centerMapList = tbsActivityCenters . stream ( ) . collect ( Collectors . groupingBy ( a - > a . getCenterType ( ) + "-" + a . getCenterId ( ) ) ) ;
List < TbsActivityCenter > centerList = centerMapList . values ( ) . stream ( ) . map ( a - > a . get ( 0 ) ) . collect ( Collectors . toList ( ) ) ;
List < TbsActivityCenter > centerList = centerMapList . values ( ) . stream ( ) . map ( a - > a . get ( 0 ) ) . collect ( Collectors . toList ( ) ) ;
// TODO 有异常
for ( TbsActivityCenter center : centerList ) {
for ( TbsActivityCenter center : centerList ) {
TbsCostSubItem . CostCenterTranStr costCenter = centerRateService . buildCostCenter ( center . getCenterType ( ) , center . getCenterId ( ) , center . getCenterName ( ) ) ;
TbsCostSubItem . CostCenterTranStr costCenter = centerRateService . buildCostCenter ( center . getCenterType ( ) , center . getCenterId ( ) , center . getCenterName ( ) ) ;
subList . add ( costCenter ) ;
subList . add ( costCenter ) ;