YYC
2023-07-14 dd93297e80ecad5b4fb7267f048d50ffb9f2c191
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
package com.ld.igds.inout.view;
 
import java.util.*;
 
import com.ld.igds.inout.InoutConstant;
import com.ld.igds.inout.dto.ReportInoutDepotData;
import com.ld.igds.inout.dto.ReportInoutShipData;
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.bdf2.core.model.DefaultDept;
import com.bstek.dorado.annotation.DataProvider;
import com.ld.igds.inout.service.HInoutReportService;
import com.ld.igds.inout.service.JInoutReportService;
import com.ld.igds.models.InoutRecord;
import com.ld.igds.sys.service.SysDeptService;
import com.ld.igds.util.ContextUtil;
import com.ld.igds.util.DateUtil;
 
/**
 * @author: andy.jia
 * @description:
 * @version:
 * @data:2020年3月13日
 */
@Component
public class InoutReportPR {
 
    @Autowired
    private HInoutReportService hiberReportService;
    @Autowired
    private JInoutReportService jdbcReportService;
    @Autowired
    private SysDeptService sysDeptService;
 
    /**
     * inoutReportPR#getQuery 根据报表类型,获取默认查询信息,比如表头信息等
     *
     * @param
     * @return
     */
    @DataProvider
    public Map<String, Object> getQuery(Map<String, Object> param) {
        Map<String, Object> result = new HashMap<String, Object>();
        //获取参数中报表类型
        String type = (String) param.get("type");
        //获取参数中分库编码
        String deptId = (String) param.get("deptId");
        //获取分库编码对应的分库名称
        String deptName = "";
        List<DefaultDept> defaultDepts = sysDeptService.getCacheDept(ContextUtil.getCompanyId());
        for (DefaultDept defaultDept : defaultDepts) {
            if (defaultDept.getId().equals(deptId)) {
                deptName = defaultDept.getName();
            }
        }
        if ("INOUT_DETAIL".equals(type)) {
            result.put("title", "出入库明细汇总");
            if (StringUtils.isNotEmpty(deptName)) {
                result.put("title", deptName + "出入库明细汇总");
                result.put("deptId", deptId);
            }
 
            result.put("unit", "千克(KG)");
            result.put("end", new Date());
            Date start = DateUtil.getNewByDay(new Date(), -30);
            result.put("start", start);
 
            result.put("timeDesc",
                    DateFormatUtils.format(start, "yyyy-MM-dd") + "   截至:"
                            + DateFormatUtils.format(new Date(), "yyyy-MM-dd"));
        }
 
        /**
         * 每日出库统计
         */
        if ("OUT_DAY".equals(type)) {
            result.put("title", "每日出库汇总");
            if (StringUtils.isNotEmpty(deptName)) {
                result.put("title", deptName + "每日出库汇总");
                result.put("deptId", deptId);
            }
 
            result.put("unit", "千克(KG)");
            result.put("day", new Date());
            result.put("timeDesc",
                    DateFormatUtils.format(new Date(), "yyyy-MM-dd"));
            result.put("type", InoutConstant.TYPE_OUT);
        }
 
        /**
         * 每日入库汇总统计
         */
        if ("IN_DAY".equals(type)) {
            result.put("title", "每日入库汇总");
            if (StringUtils.isNotEmpty(deptName)) {
                result.put("title", deptName + "每日入库汇总");
                result.put("deptId", deptId);
            }
 
            result.put("unit", "千克(KG)");
            result.put("day", new Date());
            result.put("timeDesc",
                    DateFormatUtils.format(new Date(), "yyyy-MM-dd"));
            result.put("type", InoutConstant.TYPE_IN);
        }
        /**
         * 分仓收支存
         */
        if ("INOUTDEPOT".equals(type)) {
            result.put("title", "分仓粮油收支存");
            if (StringUtils.isNotEmpty(deptName)) {
                result.put("title", deptName + "分仓粮油收支存");
                result.put("deptId", deptId);
            }
            result.put("end", new Date());
            Date start = DateUtil.getNewByDay(new Date(), -30);
            result.put("start", start);
 
            result.put("timeDesc",
                    DateFormatUtils.format(start, "yyyy-MM-dd") + "   截至:"
                            + DateFormatUtils.format(new Date(), "yyyy-MM-dd"));
            result.put("unit", "千克(KG)");
        }
        /**
         * 分品种收支存
         */
        if ("INOUTFOODVARIETY".equals(type)) {
            result.put("title", "分品种粮油收支存");
            if (StringUtils.isNotEmpty(deptName)) {
                result.put("title", deptName + "分品种粮油收支存");
                result.put("deptId", deptId);
            }
            result.put("end", new Date());
            Date start = DateUtil.getNewByDay(new Date(), -30);
            result.put("start", start);
 
            result.put("timeDesc",
                    DateFormatUtils.format(start, "yyyy-MM-dd") + "   截至:"
                            + DateFormatUtils.format(new Date(), "yyyy-MM-dd"));
            result.put("unit", "千克(KG)");
        }
        if ("INOUT_SHIP_DETAIL".equals(type)) {
            result.put("title", "船运明细汇总");
            if (StringUtils.isNotEmpty(deptName)) {
                result.put("title", deptName + "船运明细汇总");
                result.put("deptId", deptId);
            }
 
            result.put("unit", "千克(KG)");
            result.put("end", new Date());
            Date start = DateUtil.getNewByDay(new Date(), -30);
            result.put("start", start);
 
            result.put("timeDesc",
                    DateFormatUtils.format(start, "yyyy-MM-dd") + "   截至:"
                            + DateFormatUtils.format(new Date(), "yyyy-MM-dd"));
        }
        return result;
    }
 
    /**
     * 出入库汇总表
     * inoutReportPR#listRecord 报表数据,只获取已经完成的,并且非异常数据和删除数据
     *
     * @param param
     * @return
     */
    @DataProvider
    public List<InoutRecord> listRecord(Map<String, Object> param)
            throws Exception {
 
        if (null == param) {
            param = new HashMap<String, Object>();
            param.put("progress", InoutConstant.PROGRESS_RECORD);
        }
 
        List<InoutRecord> result = hiberReportService.listRecord(param);
        if (null == result || result.isEmpty())
            return result;
 
        // 添加统计信息
        double emptyWeightSum = 0.0, fullWeightSum = 0.0, deCheck = 0.0, addCheck = 0.0, deWetSum = 0.0, deImpuritySum = 0.0, deHandleSum = 0.0, deOtherSum = 0.0, deSumSum = 0.0, netWeightSum = 0.0, settleWeightSum = 0.0;
        int index = 1;
        for (InoutRecord record : result) {
            record.setRemarks(String.valueOf(index));
            emptyWeightSum += record.getEmptyWeight();
            fullWeightSum += record.getFullWeight();
            deCheck += record.getDeCheck();
            addCheck += record.getAddCheck();
//            deWetSum += record.getDeWet();
//            deImpuritySum += record.getDeImpurity();
            deHandleSum += record.getDeHandle();
            deOtherSum += record.getDeOther();
            //    deSumSum += record.getDeSum();
            netWeightSum += record.getNetWeight();
            settleWeightSum += record.getSettleWeight();
            index++;
        }
        InoutRecord sum = new InoutRecord();
        sum.setId("合计");
        sum.setEmptyWeight(emptyWeightSum);
        sum.setFullWeight(fullWeightSum);
        sum.setAddCheck(addCheck);
        sum.setDeCheck(deCheck);
//        sum.setDeWet(deWetSum);
//        sum.setDeImpurity(deImpuritySum);
        sum.setDeHandle(deHandleSum);
        sum.setDeOther(deOtherSum);
        //    sum.setDeSum(deSumSum);
        sum.setNetWeight(netWeightSum);
        sum.setSettleWeight(settleWeightSum);
        result.add(sum);
 
        return result;
    }
 
    /**
     * inoutReportPR#inoutDepotData 分仓粮油收支存
     *
     * @param param
     * @return
     */
    @DataProvider
    public List<ReportInoutDepotData> inoutDepotData(Map<String, Object> param) throws Exception {
        List<ReportInoutDepotData> result = jdbcReportService.getInoutDepotData(param);
        return result;
    }
 
    /**
     * inoutReportPR#inoutFoodVarietyData 分品种粮油收支存
     *
     * @param param
     * @return
     */
    @DataProvider
    public List<ReportInoutDepotData> inoutFoodVarietyData(Map<String, Object> param)
            throws Exception {
        List<ReportInoutDepotData> result = jdbcReportService.getFoodVarietyData(param);
        return result;
    }
 
    /**
     * 船运明细汇总
     * inoutReportPR#listShipDetail
     *
     * @param param
     * @return
     */
    @DataProvider
    public List<ReportInoutShipData> listShipDetail(Map<String, Object> param) throws Exception {
 
        if (null == param) {
            param = new HashMap<String, Object>();
        }
 
        return jdbcReportService.listShipDetail(param);
    }
}