YYC
2023-06-25 1459bdb1184f2aec10dbf987ddf900fea343a54b
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
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.HPlanManageService;
import com.ld.igds.models.DicTrigger;
import com.ld.igds.models.InoutPlan;
import com.ld.igds.models.InoutPlanDetail;
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: chen
 *
 */
@Component
public class PlanManagePR {
 
    @Autowired
    private HPlanManageService service;
    @Autowired
    private SysDeptService sysDeptService;
 
    /**
     * planManagePR#getPlanTitle 获取计划title
     *
     * @param
     * @return
     */
    @DataProvider
    public Map<String, Object> getPlanTitle(Map<String, Object> param) {
        Map<String, Object> result = new HashMap<String, Object>();
        //获取参数中报表类型
        String type = (String)param.get("type");
 
        //设置计划title
        String title = "计划";
        if(InoutManageUtil.PLAN_TYPE_1.equals(type)){
            title = "采购" + title;
        }
        if(InoutManageUtil.PLAN_TYPE_2.equals(type)){
            title = "销售" + title;
        }
        if(InoutManageUtil.PLAN_TYPE_3.equals(type)){
            title = "轮换" + title;
        }
        if(InoutManageUtil.PLAN_TYPE_4.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("planManagePR#triggerPlanType").getResult()}
     *
     * @return
     */
    @DataProvider
    public List<DicTrigger> triggerPlanType() {
        List<DicTrigger> list = new ArrayList<DicTrigger>();
 
        list.add(new DicTrigger(InoutManageUtil.PLAN_TYPE_1, "采购计划"));
        list.add(new DicTrigger(InoutManageUtil.PLAN_TYPE_2, "销售计划"));
        list.add(new DicTrigger(InoutManageUtil.PLAN_TYPE_3, "轮换计划"));
        list.add(new DicTrigger(InoutManageUtil.PLAN_TYPE_4, "加工计划"));
 
        return list;
    }
 
    /**
     * 轮换计划类型
     * ${dorado.getDataProvider("planManagePR#triggerPlanTurn").getResult()}
     *
     * @return
     */
    @DataProvider
    public List<DicTrigger> triggerPlanTurn() {
        List<DicTrigger> list = new ArrayList<DicTrigger>();
 
        list.add(new DicTrigger(InoutManageUtil.PLAN_TYPE_TURN_IN, "轮入"));
        list.add(new DicTrigger(InoutManageUtil.PLAN_TYPE_TURN_OUT, "轮出"));
 
        return list;
    }
 
    /**
     * 获取计划列表
     * planManagePR#pagePlan
     * 
     * @param page
     * @param param
     * @throws Exception
     */
    @DataProvider
    public void pagePlan(Page<InoutPlan> page, Map<String, Object> param) throws Exception {
        if (null == param) {
            param = new HashMap<String, Object>();
        }
        service.pagePlan(page, param);
    }
 
    /**
     * 获取计划详细列表
     * planManagePR#listPlanDetail
     * 
     * @param planId
     * @return
     */
    @DataProvider
    public List<InoutPlanDetail> listPlanDetail(String planId) {
        return service.listPlanDetail(planId);
    }
 
    /**
     * 保存计划
     * planManagePR#savePlan
     * 
     * @param data
     */
    @DataResolver
    public void savePlan(InoutPlan data) {
        service.savePlan(data);
    }
 
    /**
     * 删除计划
     * planManagePR#delPlan
     * 
     * @param data
     * @return
     */
    @Expose
    public String delPlan(InoutPlan data) {
        return service.delPlan(data);
    }
    
    /**
     * 删除计划详细信息
     * planManagePR#delPlanDetail
     *
     * @param data
     * @return
     */
    @Expose
    public String delPlanDetail(InoutPlanDetail data){
        return service.delPlanDetail(data);
    }
}