YYC
2023-10-31 8728429603cdb25b5fc6245915dc829e78d81571
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
package com.ld.igds.inout.service;
 
import com.bstek.bdf2.core.orm.hibernate.HibernateDao;
import com.ld.igds.models.InoutRecord;
import com.ld.igds.util.ContextUtil;
import com.ld.igds.util.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
 
import java.util.*;
 
@Component
public class HInoutReportService extends HibernateDao {
 
    public static final String BEAN_ID = "hibeInoutReportServiceImpl";
 
    public List<InoutRecord> listRecord(Map<String, Object> param)
            throws Exception {
 
        String hql = " from " + InoutRecord.class.getName()
                + " where companyId=:companyId ";
        Map<String, Object> args = new HashMap<String, Object>();
        args.put("companyId", ContextUtil.getCompanyId());
 
        if (null != param) {
            String str = (String) param.get("depotId");
            if (StringUtils.isNotEmpty(str)) {
                hql += " and depotId=:depotId ";
                args.put("depotId", str);
            }
 
            str = (String) param.get("foodVariety");
            if (StringUtils.isNotEmpty(str)) {
                hql += " and foodVariety=:foodVariety ";
                args.put("foodVariety", str);
            }
 
            str = (String) param.get("type");
            if (StringUtils.isNotEmpty(str)) {
                hql += " and type=:type ";
                args.put("type", str);
            }
 
            str = (String) param.get("type");
            if (StringUtils.isEmpty(str)) {
                hql += " and type <> 'LOSS' and type <> 'OVER'";
            } else {
                hql += " and type=:type ";
                args.put("type", str);
            }
 
            str = (String) param.get("noticeId");
            if (StringUtils.isNotEmpty(str)) {
                hql += " and noticeId=:noticeId ";
                args.put("noticeId", str);
            }
 
            str = (String) param.get("progress");
            if (StringUtils.isNotEmpty(str)) {
                hql += " and progress=:progress ";
                args.put("progress", str);
            }
 
            str = (String) param.get("deptId");
            if (StringUtils.isNotEmpty(str)) {
                hql += " and deptId=:deptId ";
                args.put("deptId", str);
            }
 
            Date date = (Date) param.get("start");
            if (null != date) {
                hql += " and completeTime >= :start ";
                args.put("start", DateUtil.getCurZero(date));
            }
 
            date = (Date) param.get("end");
            if (null != date) {
                hql += " and completeTime <= :end ";
                args.put("end", DateUtil.getNextZero(date));
            }
 
            date = (Date) param.get("day");
            if (null != date) {
                hql += " and completeTime >=:day1 and completeTime <= :day2 ";
                args.put("day1", DateUtil.getCurZero(date));
                args.put("day2", DateUtil.getNextZero(date));
            }
        }
 
        hql += " and TYPE_ <> 'NONE' and RECORD_STATUS_ <> 'ERROR' and RECORD_STATUS_ <> 'DEL' order by id asc ";
        return this.query(hql, args);
    }
}