sgj
2026-02-25 23ba8d87f56be44209687ee03c8bda3e351412d1
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
package com.fzzy.igds;
 
import com.bstek.dorado.annotation.DataProvider;
import com.fzzy.igds.constant.Constant;
import com.fzzy.igds.data.InoutParam;
import com.fzzy.igds.data.SuperInventoryReportData;
import com.fzzy.igds.data.SuperInventoryReportParam;
import com.fzzy.igds.domain.InoutRecord;
import com.fzzy.igds.service.InoutRecordService;
import com.fzzy.igds.service.SuperInventoryReportService;
import com.fzzy.igds.service.SysDeptService;
import com.fzzy.igds.utils.ContextUtil;
import com.fzzy.igds.utils.DateUtil;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.utils.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
import java.text.DecimalFormat;
import java.util.*;
 
/**
 * @Description 出入库相关报表
 * @Author CZT
 * @Date 2025/12/29 10:32
 */
@Component
public class ReportInoutPR {
 
    @Resource
    private InoutRecordService inoutReportService;
    @Resource
    private SysDeptService sysDeptService;
    @Resource
    private SuperInventoryReportService superInventoryReportService;
 
    /**
     * reportInoutPR#getQueryInout
     *
     * @param
     * @return
     */
    @DataProvider
    public Map<String, Object> getQueryInout(InoutParam param) {
        Map<String, Object> result = new HashMap<String, Object>();
 
        //获取参数中报表类型
        String type = param.getType();
 
        //获取参数中分库编码
        String deptId = param.getDeptId();
        result.put("deptId", deptId);
 
        //获取分库编码对应的分库名称
//        String deptName = "";
//        SysDept subDept = sysDeptService.getCacheDept(null, ContextUtil.subDeptId(null));
//        if (null != subDept) {
//            deptName = subDept.getDeptName();
//        }
        String title = "汇总表";
        if ("IN".equals(type)) {
            title =  "入库明细汇总";
        }
        if ("OUT".equals(type)) {
            title =  "出库明细汇总";
        }
        if ("STORE".equals(type)) {
            title =  "库存汇总表";
        }
 
        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("createUser", ContextUtil.getLoginUserName());
        result.put("createTime", new Date());
        result.put("title", title);
        result.put("type", type);
 
        return result;
    }
 
    /**
     * reportInoutPR#getQuery 根据报表类型,获取默认查询信息,比如表头信息等
     *
     * @param
     * @return
     */
    @DataProvider
    public Map<String, Object> getQueryStore(SuperInventoryReportParam param) {
        Map<String, Object> result = new HashMap<String, Object>();
 
        //获取参数中分库编码
        String deptId = param.getDeptId();
        result.put("deptId", deptId);
 
        //获取分库编码对应的分库名称
//        String deptName = "";
//        SysDept subDept = sysDeptService.getCacheDept(null, ContextUtil.subDeptId(null));
//        if (null != subDept) {
//            deptName = subDept.getDeptName();
//        }
        String title = "库存汇总表";
 
        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("createUser", ContextUtil.getLoginUserName());
        result.put("createTime", new Date());
        result.put("title", title);
 
        return result;
    }
 
    /**
     * 出入库汇总表
     * reportInoutPR#listRecord 报表数据,只获取已经完成的,并且非异常数据和删除数据
     *
     * @param param
     * @return
     */
    @DataProvider
    public List<InoutRecord> listRecord(InoutParam param) {
 
        if (null == param) {
            param = new InoutParam();
        }
        //查询入库数据
        param.setProgress(Constant.PROGRESS_RECORD);
        param.setRecordStatus(Constant.RECORD_STATUS_NORMAL);
        //多参数分页查询
        com.baomidou.mybatisplus.extension.plugins.pagination.Page<InoutRecord> corePage = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(0, 10000);
        //收储公司查询处理
        if (StringUtils.isNotEmpty(param.getDeptId()) && StringUtils.isNotEmpty(param.getCompanyId())) {
            String substring = param.getDeptId().substring(0, (param.getDeptId().length() - 3));
            if (!substring.equals(param.getCompanyId())) {
                return new ArrayList<InoutRecord>();
            }
        }
        if (StringUtils.isEmpty(param.getDeptId())) {
            param.setDeptId(param.getCompanyId());
        }
 
        param.setCompanyId(null);
        inoutReportService.listPageInout(corePage, param);
        //获取查询到得list数据
        List<InoutRecord> result = corePage.getRecords();
        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;
        List<InoutRecord> list = new ArrayList<>();
        for (InoutRecord record : result) {
            if (StringUtils.isNotBlank(record.getDeptId())) {
                record.setCompanyId(record.getDeptId().substring(0, (record.getDeptId().length() - 3)));
            }
            list.add(record);
            record.setRemarks(String.valueOf(index));
            emptyWeightSum += record.getEmptyWeight();
            fullWeightSum += record.getFullWeight();
            deOtherSum += record.getDeOther();
            netWeightSum += record.getNetWeight();
            settleWeightSum += record.getSettleWeight();
            index++;
        }
        InoutRecord sum = new InoutRecord();
        sum.setId("合计");
        sum.setEmptyWeight(emptyWeightSum);
        sum.setFullWeight(fullWeightSum);
        sum.setDeOther(deOtherSum);
        sum.setNetWeight(netWeightSum);
        sum.setSettleWeight(settleWeightSum);
 
        if (sum.getNoticeId() == null) sum.setNoticeId("");
        if (sum.getDepotId() == null) sum.setDepotId("");
        if (sum.getProgress() == null) sum.setProgress("");
        if (sum.getUserName() == null) sum.setUserName("");
        if (sum.getPlateNum() == null) sum.setPlateNum("");
        if (sum.getFoodVariety() == null) sum.setFoodVariety("");
 
        list.add(sum);
 
        return list;
    }
 
    /**
     * reportInoutPR#getStoreData
     *
     * @param param
     */
    @DataProvider
    public List<SuperInventoryReportData> getStoreData(SuperInventoryReportParam param) {
        if (null == param) {
            param = new SuperInventoryReportParam();
        }
 
        return superInventoryReportService.listSuperInventoryReportData(param);
    }
}