<?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 >= #{params.starttime}
|
</if>
|
<if test="params.endtime != null and params.endtime != ''">
|
and eo.entrydate < #{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 >= #{starttime}
|
</if>
|
<if test="endtime != null and endtime != ''">
|
and eo.entrydate <= #{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 >= #{starttime}
|
</if>
|
<if test="endtime != null and endtime != ''">
|
and eo.entrydate <= #{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>
|