郑永安
2023-06-19 59e91a4e9ddaf23cebb12993c774aa899ab22d16
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
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.gk.firework.Mapper.EntryOrderInfoMapper" >
  <resultMap id="BaseResultMap" type="com.gk.firework.Domain.EntryOrderInfo" >
    <!--          -->
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="code" property="code" jdbcType="VARCHAR" />
    <result column="createdby" property="createdby" jdbcType="VARCHAR" />
    <result column="createddate" property="createddate" jdbcType="TIMESTAMP" />
    <result column="modifiedby" property="modifiedby" jdbcType="VARCHAR" />
    <result column="modifieddate" property="modifieddate" jdbcType="TIMESTAMP" />
    <result column="entrydate" property="entrydate" jdbcType="TIMESTAMP" />
    <result column="num" property="num" jdbcType="INTEGER" />
    <result column="transportcert" property="transportcert" jdbcType="VARCHAR" />
    <result column="unit" property="unit" jdbcType="VARCHAR" />
    <result column="companynumber" property="companynumber" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    <!--          -->
    id, code, createdby, createddate, modifiedby, modifieddate, entrydate, num, transportcert,
    unit, companynumber
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
    <!--          -->
    select
    <include refid="Base_Column_List" />
    from entryorder
    where id = #{id,jdbcType=BIGINT}
  </select>
    <select id="selectPages" resultType="com.gk.firework.Domain.Vo.EntryOrderInfoVo">
      select
      eo.id,
      eo.code,
      eo.createdby,
      eo.createddate,
      eo.entrydate,
      round(sum(eo.num),2) boxnum,
      eo.transportcert,
      eo.unit,
      eo.companynumber,
      eo.type
      from
      (
          select
          eo.id,
          eo.code,
          eo.createdby,
          eo.createddate,
          eo.entrydate,
          sum(ed.num)/p.boxnumber num,
          eo.transportcert,
          eo.unit,
          eo.companynumber,
          eo.type
          from entryorder as eo
          left join entrydetail as ed on ed.entryorder = eo.code
          left join product as p on p.directioncode = ed.itemcode and p.isdel = 0
          <where>
            <if test="params.starttime != null and params.starttime != ''">
              and  eo.entrydate &gt;= #{params.starttime}
            </if>
            <if test="params.endtime != null and params.endtime != ''">
              and eo.entrydate &lt; #{params.endtime}
            </if>
            <if test="params.transportcert != null and params.transportcert != ''">
              and eo.transportcert like concat("%",#{params.transportcert},"%")
            </if>
            <if test="params.type != null and params.type  != ''">
              and eo.type = #{params.type}
            </if>
            <if test="params.code != null and params.code  != ''">
              and eo.code  like concat("%",#{params.code},"%")
            </if>
          </where>
          group by  eo.code,ed.itemcode
      ) as eo
      left join enterprise as e on e.enterprisenumber = eo.companynumber
      <where>
        e.validflag = 1
        and e.enterprisestatus = 'ON'
        <choose>
          <when test="params.enterprisenumber != null and params.enterprisenumber != ''">
            and eo.companynumber = #{params.enterprisenumber}
          </when>
          <otherwise>
            <if test="params.province != null and params.province != ''">
              and e.province = #{params.province}
            </if>
            <if test="params.city != null and params.city != ''">
              and e.city = #{params.city}
            </if>
            <if test="params.district != null and params.district != ''">
              and e.district = #{params.district}
            </if>
            <if test="params.street != null and params.street != ''">
              and e.street = #{params.street}
            </if>
            <if test="params.committee != null and params.committee != ''">
              and e.committee = #{params.committee}
            </if>
          </otherwise>
        </choose>
        <if test="params.filterProvince != null and params.filterProvince  != ''">
          and e.province = #{params.filterProvince}
        </if>
        <if test="params.filterCity != null and  params.filterCity  != ''">
          and e.city = #{params.filterCity}
        </if>
        <if test="params.filterDistrict != null and params.filterDistrict  != ''">
          and e.district = #{params.filterDistrict}
        </if>
        <if test="params.filterStreet != null and params.filterStreet  != ''">
          and e.street = #{params.filterStreet}
        </if>
        <if test="params.filterCommittee != null and params.filterCommittee  != ''">
          and e.committee = #{params.filterCommittee}
        </if>
        <if test="params.enterprisename != null and params.enterprisename != ''">
          and e.enterprisename like concat("%",#{params.enterprisename},"%")
        </if>
        <if test="params.safetysupervision != null and params.safetysupervision != ''">
          and e.safetysupervision = #{params.safetysupervision}
        </if>
 
      </where>
      group by eo.code
      order by eo.entrydate desc
    </select>
 
  <select id="selectEntryOrderByTimeAndUser" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from entryorder
    <where>
      entrydate = #{datetime}
      and createdby = #{createdby}
    </where>
    limit 1
  </select>
 
  <select id="selectEnterpriseEntryNumber" resultType="decimal">
    SELECT
    IFNULL(SUM( entrynum ),0)
    FROM
    (
    SELECT
    SUM( ed.num )/ p.boxnumber AS entrynum
    FROM
    entrydetail AS ed
    LEFT JOIN entryorder AS eo ON eo.`code` = ed.entryorder
    LEFT JOIN product AS p ON p.directioncode = ed.itemcode and p.isdel = 0
    <where>
      eo.companynumber = #{companyNumber}
      <if test="starttime != null and starttime != ''">
        and eo.entrydate &gt;= #{starttime}
      </if>
      <if test="endtime != null and endtime != ''">
        and eo.entrydate &lt;= #{endtime}
      </if>
    </where>
    GROUP BY
    ed.itemcode
    ) temp
  </select>
  <select id="selectCityEntryNumber" resultType="decimal">
    SELECT
    IFNULL(SUM( entrynum ),0)
    FROM
    (
    SELECT
    SUM( ed.num )/ p.boxnumber AS entrynum
    FROM
    entrydetail AS ed
    LEFT JOIN entryorder AS eo ON eo.`code` = ed.entryorder
    LEFT JOIN product AS p ON p.directioncode = ed.itemcode and p.isdel = 0
    LEFT JOIN enterprise AS e ON eo.companynumber = e.enterprisenumber
    <where>
      e.city = #{city}
      and e.enterprisestatus = 'ON'
      and e.validflag = 1
      <if test="starttime != null and starttime != ''">
        and eo.entrydate &gt;= #{starttime}
      </if>
      <if test="endtime != null and endtime != ''">
        and eo.entrydate &lt;= #{endtime}
      </if>
    </where>
    GROUP BY
    ed.itemcode
    ) temp
  </select>
  <select id="selectByCert" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List"/>
    from entryorder as eo
    <where>
      transportcert = #{code}
    </where>
  </select>
</mapper>