zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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<CostFromTemplate> 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;
    }
}