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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package com.changhong.epc.tenant.service.cost.impl;
 
import com.changhong.epc.bean.tenant.cost.CostFromMapping;
import com.changhong.epc.bean.tenant.cost.extend.CostFromMappingExtend;
import com.changhong.epc.bean.tenant.cost.extend.CostTypeExtend;
import com.changhong.epc.tenant.mapper.tenant.cost.CostFromMappingMapper;
import com.changhong.epc.tenant.service.cost.CostFromMappingService;
import com.iemsoft.framework.cloud.core.tools.JSONTool;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.List;
 
@Service("costFromMappingServiceImpl")
public class CostFromMappingServiceImpl implements CostFromMappingService{
 
    @Resource
    private CostFromMappingMapper costFromMapping;
    
 
 
 
    @Override
    public CostFromMappingExtend selectOne(CostFromMapping costFrom) {
        // System.out.println(costFrom.getFId()+"参数为");
        return costFromMapping.selectCostType(costFrom);
    }
 
 
 
 
    @Override
    public int updateCost(CostTypeExtend cost) {
        List<CostFromMapping> list = cost.getCostFromMapping();
        int count = 0;
        if(list!=null){
            for(CostFromMapping costs : list){
                costs.setCtId(cost.getId());
                // System.out.println(JSONTool.toJson(costs));
                if(costs.getFId() == null || costs.getFName()== null || "".equals(costs.getFName())){
                    // System.out.println("删除表单");
                    costFromMapping.deleteFormByCtidAndType(costs.getCtId(),costs.getType());
                }
                if((!"".equals(costs.getFId())) && costs.getFId() != null && costFromMapping.selectByctId(costs) != null){
                    // System.out.println("进入修改");
                    // System.out.println(JSONTool.toJson(costs));
                    count += costFromMapping.updateCost(costs);
                }else if(costs.getFId() !=null && !costs.getFId().equals("")){
                    costs.initParam();
                    count += costFromMapping.insert(costs);
                    // System.out.println("进入添加");
                    // System.out.println(JSONTool.toJson(costs));
                }
            }
        } 
        return count;
    }
 
    @Override
    public List<CostFromMapping> getConstFroms(CostFromMapping cost) {
        return costFromMapping.getConstFroms(cost);
    }
 
    @Override
    public List<CostFromMapping> selectType(CostFromMapping cost) {
        return costFromMapping.selectType(cost.getType());
    }
 
 
}