YYC
2023-07-17 849e0634fab58695e6197b9b89e340b2791294ad
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package com.ld.igds.m.view;
 
import com.bstek.bdf2.core.model.DefaultDept;
import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.DataResolver;
import com.bstek.dorado.annotation.Expose;
import com.bstek.dorado.data.provider.Page;
import com.ld.igds.m.InoutManageUtil;
import com.ld.igds.m.service.HContractManageService;
import com.ld.igds.models.DicTrigger;
import com.ld.igds.models.InoutContract;
import com.ld.igds.sys.service.SysDeptService;
import com.ld.igds.util.ContextUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
/**
 * 合同管理
 * 
 * @author:
 *
 */
@Component
public class ContractManagePR {
 
    @Autowired
    private HContractManageService service;
    @Autowired
    private SysDeptService sysDeptService;
 
    /**
     * contractManagePR#getContractTitle 获取合同title
     *
     * @param
     * @return
     */
    @DataProvider
    public Map<String, Object> getContractTitle(Map<String, Object> param) {
        Map<String, Object> result = new HashMap<String, Object>();
        //获取参数中报表类型
        String type = (String)param.get("type");
 
        //设置计划title
        String title = "合同";
        if(InoutManageUtil.CONTRACT_TYPE_1.equals(type)){
            title = "销售" + title;
        }
        if(InoutManageUtil.CONTRACT_TYPE_2.equals(type)){
            title = "采购" + title;
        }
        if(InoutManageUtil.CONTRACT_TYPE_3.equals(type)){
            title = "轮换" + title;
        }
 
        //获取参数中分库编码
        String deptId = (String)param.get("deptId");
        if (StringUtils.isEmpty(deptId)) {
            deptId = ContextUtil.subDeptId(null);
        }
        //获取分库编码对应的分库名称
        String deptName = "";
        List<DefaultDept> defaultDepts = sysDeptService.loadUserDepts(ContextUtil.getLoginUserName());
        for (DefaultDept defaultDept : defaultDepts) {
            if(defaultDept.getId().equals(deptId)){
                deptName = defaultDept.getName();
            }
        }
 
        if (StringUtils.isNotEmpty(deptName)) {
            title = deptName + " - " + title;
        }
        result.put("title", title);
        return result;
    }
 
    /**
     * 合同类型
     * ${dorado.getDataProvider("contractManagePR#triggerContractType").getResult()}
     *
     * @return
     */
    @DataProvider
    public List<DicTrigger> triggerContractType() {
        List<DicTrigger> list = new ArrayList<DicTrigger>();
        list.add(new DicTrigger(InoutManageUtil.CONTRACT_TYPE_1, "销售合同"));
        list.add(new DicTrigger(InoutManageUtil.CONTRACT_TYPE_2, "采购合同"));
        list.add(new DicTrigger(InoutManageUtil.CONTRACT_TYPE_3, "代储合同"));
 
        return list;
    }
 
    /**
     * 客户类型
     * ${dorado.getDataProvider("contractManagePR#triggerCustomerType").getResult()}
     *
     * @return
     */
    @DataProvider
    public List<DicTrigger> triggerCustomerType() {
        List<DicTrigger> list = new ArrayList<DicTrigger>();
 
        list.add(new DicTrigger(InoutManageUtil.CUSTOMER_TYPE_1, "企业"));
        list.add(new DicTrigger(InoutManageUtil.CUSTOMER_TYPE_2, "个人"));
 
        return list;
    }
 
    /**
     * contractManagePR#pageContract
     * @param page
     * @param param
     * @throws Exception
     */
    @DataProvider
    public void pageContract(Page<InoutContract> page, Map<String, Object> param) throws Exception {
        if (null == param) {
            param = new HashMap<String, Object>();
        }
        service.pageContract(page, param);
    }
 
    /**
     * contractManagePR#saveContract
     * @param data
     */
    @DataResolver
    public void saveContract(InoutContract data) {
        service.saveContract(data);
    }
 
    /**
     * contractManagePR#delContract
     * @param data
     * @return
     */
    @Expose
    public String delContract(InoutContract data) {
        return service.delContract(data);
    }
}