package com.changhong.epc.admin.service.asset.impl; import com.changhong.epc.admin.mapper.centen.asset.AssetDepreciationMapper; import com.changhong.epc.admin.service.asset.AssetDepreciationService; import com.changhong.epc.bean.admin.AssetDepreciation; import com.iemsoft.framework.cloud.core.tools.ObjectUtil; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.Arrays; import java.util.List; @Service public class AssetDepreciationServiceImpl implements AssetDepreciationService { @Resource private AssetDepreciationMapper assetDepreciationMapper; @Override @Transactional public int insert(AssetDepreciation assetDepreciation) { assetDepreciation.initParam(); if(ObjectUtil.empty(assetDepreciation.getOrgCodes())) { return assetDepreciationMapper.insertSelective(assetDepreciation); }else{ Arrays.asList(assetDepreciation.getOrgCodes()).stream().forEach(orgCode->{ assetDepreciation.setOrgCode(orgCode); assetDepreciationMapper.insertSelective(assetDepreciation); }); return assetDepreciation.getOrgCodes().length; } } @Override @Transactional public List select(AssetDepreciation assetDepreciation) { return assetDepreciationMapper.select(assetDepreciation); } @Override public int update(AssetDepreciation assetDepreciation) { assetDepreciation.updateIngParam(); return assetDepreciationMapper.updateByPrimaryKeySelective(assetDepreciation); } @Override public String selectLastAccountDate(AssetDepreciation assetDepreciation) { return assetDepreciationMapper.selectLastAccountDate(assetDepreciation); } }