jiazx0107@163.com
2023-11-06 786b5b76fee42107cef33892cbf7e3e8fab4f0e4
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
package com.ld.igds.m.view;
 
import java.util.*;
import com.bstek.bdf2.core.business.IUser;
import com.bstek.bdf2.core.model.DefaultDept;
import com.ld.igds.constant.Constant;
import com.ld.igds.inout.InoutConstant;
import com.ld.igds.m.dto.NoticeDto;
import com.ld.igds.m.service.HInoutNoticeService;
import com.ld.igds.m.service.InoutCommonService;
import com.ld.igds.models.DicTrigger;
import com.ld.igds.models.InoutNoticeIn;
import com.ld.igds.models.InoutSysConf;
import com.ld.igds.sys.service.SysDeptService;
import com.ld.igds.util.ContextUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.Expose;
import com.bstek.dorado.data.provider.Page;
import com.ld.igds.models.InoutNoticeOut;
import javax.annotation.Resource;
 
/**
 * 通知单管理
 *
 * @author: chen
 *
 */
@Component
public class InoutNoticePR {
 
    @Autowired
    private HInoutNoticeService noticeService;
    @Autowired
    private SysDeptService sysDeptService;
    @Resource(name = InoutCommonService.BEAN_ID)
    private InoutCommonService inoutManagerService;
 
    /**
     * inoutNoticePR#getTitle 根据报表类型,获取默认查询信息,比如表头信息等
     *
     * @param
     * @return
     */
    @DataProvider
    public Map<String, Object> getTitle(Map<String, Object> param) {
        Map<String, Object> result = new HashMap<String, Object>();
        //获取参数中报表类型
        String type = (String)param.get("type");
        //获取参数中分库编码
        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 ("NOTICE_IN".equals(type)) {
            result.put("title", "入库通知单");
            if (StringUtils.isNotEmpty(deptName)) {
                result.put("title", deptName + "入库通知单");
            }
        }
        if ("NOTICE_OUT".equals(type)) {
            result.put("title", "出库通知单");
            if (StringUtils.isNotEmpty(deptName)) {
                result.put("title", deptName + "出库通知单");
            }
        }
        return result;
    }
 
    /**
     * 通知单状态下拉框
     *
     * ${dorado.getDataProvider("inoutNoticePR#triggerNoticeStatus").getResult()}
     * @return
     */
    @DataProvider
    public List<DicTrigger> triggerNoticeStatus() throws Exception {
        List<DicTrigger> list = new ArrayList<DicTrigger>();
        list.add(new DicTrigger(InoutConstant.COMPLETE_STATUS_NONE, "未完成"));
        list.add(new DicTrigger(InoutConstant.COMPLETE_STATUS_COMPLETE, "已完成"));
        return list;
    }
 
    /**
     * inoutNoticePR#getYearQuery 默认年份
     *
     * @param
     * @return
     */
    @DataProvider
    public Map<String, Object> getYearQuery(Map<String, Object> param) {
        Map<String, Object> result = new HashMap<String, Object>();
        //获取参数中分库编码
        String deptId = (String)param.get("deptId");
 
        result.put("year", DateFormatUtils.format(new Date(), "yyyy"));
        result.put("deptId", deptId);
        return result;
    }
 
 
    /**
     * inoutNoticePR#queryNoticeByKey  根据参数查询出入库通知单,用于手动补单时,选择通知单
     *
     * @param
     * @return
     */
    @DataProvider
    public List<NoticeDto> queryNoticeByKey(Map<String, Object> param) {
 
        return noticeService.queryNoticeByKey(param);
    }
 
    /*==================== 入库通知单相关业务 ====================*/
 
    /**
     * inoutNoticePR#initAddIn 入库通知单新增初始化
     *
     * @return
     */
    @Expose
    public InoutNoticeIn initAddIn() {
        IUser user = ContextUtil.getLoginUser();
        InoutNoticeIn data = new InoutNoticeIn();
        data.setId("RKTZD_" + ContextUtil.getTimeId());
        data.setName("入库通知单");
        data.setCompanyId(user.getCompanyId());
        data.setDeptId(ContextUtil.subDeptId(user));
        data.setTag(Constant.YN_Y);
        return data;
    }
 
    /**
     * inoutNoticePR#pageQueryIn 获取入库通知单
     *
     * @param parameter
     * @return
     * @throws Exception
     */
    @DataProvider
    public void pageQueryIn(Page<InoutNoticeIn> page, Map<String, Object> parameter) throws Exception {
        if (null == parameter){
            parameter = new HashMap<String, Object>();
        }
        noticeService.pageQueryIn(page, parameter);
    }
 
    /**
     * inoutNoticePR#saveIn 更新入库通知单
     */
    @Expose
    public String saveIn(InoutNoticeIn data) {
        return noticeService.saveOrUpdateIn(data);
    }
 
    /**
     * inoutNoticePR#delDataIn
     */
    @Expose
    public String delDataIn(InoutNoticeIn data) {
        return noticeService.delDataIn(data);
    }
 
    /**
     * 重新核算入库通知单完成量
     *
     * inoutNoticePR#updateSumNoticeIn
     *
     * @return
     */
    @Expose
    public String updateSumNoticeIn() {
 
        //获取所有未完成状态的入库通知单
        String companyId = ContextUtil.getCompanyId();
        String deptId = ContextUtil.subDeptId(null);
 
        InoutSysConf inoutSysConf = inoutManagerService.getCacheInoutSysConf(companyId, deptId);
 
        List<InoutNoticeIn> noticeInList = inoutManagerService.getUnComNoticeIn(companyId);
 
        if (noticeInList != null && noticeInList.size() > 0) {
            inoutManagerService.updateSumNoticeIn(inoutSysConf.getDeptId(), noticeInList);
            return "success";
        }
        
        
        return "fail";
    }
 
 
 
    /*==================== 出库通知单相关业务 ====================*/
 
    /**
     * inoutNoticePR#initAddOut 出库通知单新增初始化
     *
     * @return
     */
    @Expose
    public InoutNoticeOut initAddOut() {
        IUser user = ContextUtil.getLoginUser();
        InoutNoticeOut data = new InoutNoticeOut();
        data.setId("CKTZD_" + ContextUtil.getTimeId());
        data.setName("出库通知单");
        data.setCompanyId(user.getCompanyId());
        data.setDeptId(ContextUtil.subDeptId(user));
        data.setTag(Constant.YN_Y);
        return data;
    }
 
    /**
     * inoutNoticePR#pageQueryOut 获取出库通知单
     * @param page
     * @param parameter
     * @throws Exception
     */
    @DataProvider
    public void pageQueryOut(Page<InoutNoticeOut> page, Map<String, Object> parameter) throws Exception {
        if (null == parameter){
            parameter = new HashMap<String, Object>();
        }
        noticeService.pageQueryOut(page, parameter);
    }
 
    /**
     * inoutNoticePR#saveOut 更新出库通知单
     * @param data
     * @return
     */
    @Expose
    public String saveOut(InoutNoticeOut data) {
        return noticeService.saveOrUpdateOut(data);
    }
 
    /**
     * inoutNoticePR#delDataOut
     */
    @Expose
    public String delDataOut(InoutNoticeOut data) {
        return noticeService.delDataOut(data);
    }
 
 
    /**
     * 重新核算出库通知单完成量
     *
     * inoutNoticePR#updateSumNoticeOut
     *
     * @return
     */
    @Expose
    public String updateSumNoticeOut() {
 
        //获取所有未完成状态的入库通知单
        String companyId = ContextUtil.getCompanyId();
        String deptId = ContextUtil.subDeptId(null);
 
        InoutSysConf inoutSysConf = inoutManagerService.getCacheInoutSysConf(companyId, deptId);
 
        List<InoutNoticeOut> noticeOutList = inoutManagerService.getUnComNoticeOut(companyId);
 
        if (noticeOutList != null && noticeOutList.size() > 0) {
            inoutManagerService.updateSumNoticeOut(inoutSysConf.getDeptId(), noticeOutList);
            return "success";
        }
        return "fail";
    }
}