package com.changhong.epc.admin.service.cost.impl; import com.changhong.epc.admin.mapper.centen.cost.CostFromTemplateMapper; import com.changhong.epc.admin.service.cost.CostFromTemplateService; import com.changhong.epc.bean.admin.CostFromTemplate; import com.changhong.epc.bean.admin.extend.CostGroupTypeExtend; import com.iemsoft.framework.cloud.core.tools.ObjectUtil; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.util.List; @Service("costFromTemplateServiceImpl") public class CostFromTemplateServiceImpl implements CostFromTemplateService { @Resource private CostFromTemplateMapper costFromTemplateMapper; @Override public CostGroupTypeExtend selectOne(CostFromTemplate costFrom) { return costFromTemplateMapper.selectCostType(costFrom); } @Override public int updateCost(CostGroupTypeExtend costs) { List list = costs.getCostFromTemplate(); costFromTemplateMapper.deleteCostNull(costs.getId()); if (!CollectionUtils.isEmpty(list)) { for (CostFromTemplate costFromTemplate :list){ costFromTemplate.initParam(); costFromTemplate.setCtId(costs.getId()); } list.stream().filter(costF -> ObjectUtil.notEmpty(costF.getFId())).forEach(costFromTemplateMapper::insert); return 1; } return 0; } }