<?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="doumeemes.dao.ext.WTransferExtMapper">
|
|
<!-- 管理页面查询 -->
|
<resultMap id="WTransferExtListVO" type="doumeemes.dao.ext.vo.WTransferExtListVO" autoMapping="true">
|
<id column="ID" jdbcType="INTEGER" property="id"/>
|
</resultMap>
|
<select id="selectList" parameterType="doumeemes.dao.ext.dto.QueryWTransferExtDTO" resultMap="WTransferExtListVO">
|
SELECT
|
a.*
|
FROM w_transfer a
|
<where>
|
<if test="id != null">
|
AND a.ID = #{id}
|
</if>
|
<if test="deleted != null">
|
AND a.DELETED = #{deleted}
|
</if>
|
<if test="createUser != null">
|
AND a.CREATE_USER = #{createUser}
|
</if>
|
<if test="createTime != null">
|
AND a.CREATE_TIME = #{createTime}
|
</if>
|
<if test="updateUser != null">
|
AND a.UPDATE_USER = #{updateUser}
|
</if>
|
<if test="updateTime != null">
|
AND a.UPDATE_TIME = #{updateTime}
|
</if>
|
<if test="remark != null and remark != ''">
|
AND a.REMARK = #{remark}
|
</if>
|
<if test="rootDepartId != null">
|
AND a.ROOT_DEPART_ID = #{rootDepartId}
|
</if>
|
<if test="code != null and code != ''">
|
AND a.CODE = #{code}
|
</if>
|
<if test="origin != null">
|
AND a.ORIGIN = #{origin}
|
</if>
|
<if test="validDate != null">
|
AND a.VALID_DATE = #{validDate}
|
</if>
|
<if test="originType != null">
|
AND a.ORIGIN_TYPE = #{originType}
|
</if>
|
<if test="originCode != null and originCode != ''">
|
AND a.ORIGIN_CODE = #{originCode}
|
</if>
|
<if test="originId != null">
|
AND a.ORIGIN_ID = #{originId}
|
</if>
|
<if test="abstracts != null and abstracts != ''">
|
AND a.ABSTRACTS = #{abstracts}
|
</if>
|
<if test="outDepartId != null">
|
AND a.OUT_DEPART_ID = #{outDepartId}
|
</if>
|
<if test="outUserId != null">
|
AND a.OUT_USER_ID = #{outUserId}
|
</if>
|
<if test="outWarehouseId != null">
|
AND a.OUT_WAREHOUSE_ID = #{outWarehouseId}
|
</if>
|
<if test="outPlandate != null">
|
AND a.OUT_PLANDATE = #{outPlandate}
|
</if>
|
<if test="outActdate != null">
|
AND a.OUT_ACTDATE = #{outActdate}
|
</if>
|
<if test="inUserId != null">
|
AND a.IN_USER_ID = #{inUserId}
|
</if>
|
<if test="inWarehouseId != null">
|
AND a.IN_WAREHOUSE_ID = #{inWarehouseId}
|
</if>
|
<if test="inPlandate != null">
|
AND a.IN_PLANDATE = #{inPlandate}
|
</if>
|
<if test="inActdate != null">
|
AND a.IN_ACTDATE = #{inActdate}
|
</if>
|
<if test="status != null">
|
AND a.STATUS = #{status}
|
</if>
|
<if test="type != null">
|
AND a.TYPE = #{type}
|
</if>
|
and to_days(`a`.`CREATE_TIME`)=to_days(now())
|
</where>
|
</select>
|
<select id="selectCountToday" parameterType="doumeemes.dao.ext.dto.QueryWTransferExtDTO" resultType="java.lang.Integer">
|
SELECT
|
count(1)
|
FROM w_transfer a
|
<where>
|
<if test="id != null">
|
AND a.ID = #{id}
|
</if>
|
<if test="deleted != null">
|
AND a.DELETED = #{deleted}
|
</if>
|
<if test="createUser != null">
|
AND a.CREATE_USER = #{createUser}
|
</if>
|
<if test="createTime != null">
|
AND a.CREATE_TIME = #{createTime}
|
</if>
|
<if test="updateUser != null">
|
AND a.UPDATE_USER = #{updateUser}
|
</if>
|
<if test="updateTime != null">
|
AND a.UPDATE_TIME = #{updateTime}
|
</if>
|
<if test="remark != null and remark != ''">
|
AND a.REMARK = #{remark}
|
</if>
|
<if test="rootDepartId != null">
|
AND a.ROOT_DEPART_ID = #{rootDepartId}
|
</if>
|
<if test="code != null and code != ''">
|
AND a.CODE = #{code}
|
</if>
|
<if test="origin != null">
|
AND a.ORIGIN = #{origin}
|
</if>
|
<if test="validDate != null">
|
AND a.VALID_DATE = #{validDate}
|
</if>
|
<if test="originType != null">
|
AND a.ORIGIN_TYPE = #{originType}
|
</if>
|
<if test="originCode != null and originCode != ''">
|
AND a.ORIGIN_CODE = #{originCode}
|
</if>
|
<if test="originId != null">
|
AND a.ORIGIN_ID = #{originId}
|
</if>
|
<if test="abstracts != null and abstracts != ''">
|
AND a.ABSTRACTS = #{abstracts}
|
</if>
|
<if test="outDepartId != null">
|
AND a.OUT_DEPART_ID = #{outDepartId}
|
</if>
|
<if test="outUserId != null">
|
AND a.OUT_USER_ID = #{outUserId}
|
</if>
|
<if test="outWarehouseId != null">
|
AND a.OUT_WAREHOUSE_ID = #{outWarehouseId}
|
</if>
|
<if test="outPlandate != null">
|
AND a.OUT_PLANDATE = #{outPlandate}
|
</if>
|
<if test="outActdate != null">
|
AND a.OUT_ACTDATE = #{outActdate}
|
</if>
|
<if test="inUserId != null">
|
AND a.IN_USER_ID = #{inUserId}
|
</if>
|
<if test="inWarehouseId != null">
|
AND a.IN_WAREHOUSE_ID = #{inWarehouseId}
|
</if>
|
<if test="inPlandate != null">
|
AND a.IN_PLANDATE = #{inPlandate}
|
</if>
|
<if test="inActdate != null">
|
AND a.IN_ACTDATE = #{inActdate}
|
</if>
|
<if test="status != null">
|
AND a.STATUS = #{status}
|
</if>
|
<if test="type != null">
|
AND a.TYPE = #{type}
|
</if>
|
</where>
|
</select>
|
|
|
|
<select id="selectAdminList" parameterType="doumeemes.dao.ext.beanDto.QueryWTransferDto" resultMap="WTransferExtListVO">
|
SELECT
|
a.* , outWarehouse.NAME as outWarehouseName , inWarehouse.NAME as inWarehouseName,
|
outD.NAME outDepartName , inD.NAME inDepartName, su.REALNAME as createName ,
|
( select s.REALNAME from system_user s where s.id = a.OUT_USER_ID ) as outUserName ,
|
( select s.REALNAME from system_user s where s.id = a.IN_USER_ID ) as inUserName
|
FROM w_transfer a
|
left join warehouse outWarehouse on a.OUT_WAREHOUSE_ID = outWarehouse.id
|
left join warehouse inWarehouse on a.IN_WAREHOUSE_ID = inWarehouse.id
|
left join department outD on a.OUT_DEPART_ID = outD.id
|
left join department inD on a.IN_DEPART_ID = inD.id
|
left join `system_user` su on a.CREATE_USER = su.ID
|
<where>
|
<if test="code != null and code != ''">
|
AND a.CODE like CONCAT('%',#{code},'%')
|
</if>
|
<if test="outPlanDateStart != null">
|
AND a.OUT_PLANDATE >= #{outPlanDateStart}
|
</if>
|
<if test="outPlanDateEnd != null">
|
AND #{outPlanDateEnd} >= a.OUT_PLANDATE
|
</if>
|
<if test="inDepartId != null">
|
AND a.IN_DEPART_ID = #{inDepartId}
|
</if>
|
<if test="outDepartId != null">
|
AND a.OUT_DEPART_ID = #{outDepartId}
|
</if>
|
<if test="outWarehouseId != null">
|
AND a.OUT_WAREHOUSE_ID = #{outWarehouseId}
|
</if>
|
<if test="inWarehouseId != null">
|
AND a.IN_WAREHOUSE_ID = #{inWarehouseId}
|
</if>
|
<if test="status != null">
|
AND a.STATUS = #{status}
|
</if>
|
<if test="type != null">
|
AND a.TYPE = #{type}
|
</if>
|
|
<if test="rootDepartId != null">
|
AND `a`.`ROOT_DEPART_ID` = #{rootDepartId}
|
</if>
|
|
|
<if test="departId != null">
|
AND ( `a`.`OUT_DEPART_ID` = #{departId} or `a`.`IN_DEPART_ID` = #{departId} )
|
</if>
|
|
|
<!-- <if test="proUserId != null">-->
|
<!-- AND `a`.`CREATE_USER` = #{proUserId}-->
|
<!-- </if>-->
|
|
<choose>
|
<when test="departIds != null and departIds.size()>0">
|
AND (
|
a.CREATE_USER=#{createUser} or a.OUT_USER_ID=#{createUser} or a.IN_USER_ID=#{createUser}
|
or
|
exists (select d.id from company_user d where (d.user_id= a.CREATE_USER or d.user_id=a.OUT_USER_ID or d.user_id= a.IN_USER_ID ) and d.department_id
|
in <foreach collection="departIds" item="item" separator="," open="(" close=")">#{item}</foreach>)
|
)
|
</when>
|
<otherwise>
|
<if test="createUser!=null">
|
and ( a.CREATE_USER=#{createUser} or a.OUT_USER_ID=#{createUser} or a.IN_USER_ID=#{createUser})
|
</if>
|
</otherwise>
|
</choose>
|
|
</where>
|
order by a.CREATE_TIME desc
|
</select>
|
|
|
|
|
<select id="selectCount" parameterType="doumeemes.dao.ext.beanDto.QueryWTransferDto" resultType="java.lang.Integer">
|
SELECT
|
count(1)
|
FROM w_transfer a
|
left join warehouse outWarehouse on a.OUT_WAREHOUSE_ID = outWarehouse.id
|
left join warehouse inWarehouse on a.IN_WAREHOUSE_ID = inWarehouse.id
|
left join department outD on a.OUT_DEPART_ID = outD.id
|
left join department inD on a.IN_DEPART_ID = inD.id
|
left join `system_user` su on a.CREATE_USER = su.ID
|
<where>
|
<if test="code != null and code != ''">
|
AND a.CODE like CONCAT('%',#{code},'%')
|
</if>
|
<if test="outPlanDateStart != null">
|
AND a.OUT_PLANDATE >= #{outPlanDateStart}
|
</if>
|
<if test="outPlanDateEnd != null">
|
AND #{outPlanDateEnd} >= a.OUT_PLANDATE
|
</if>
|
<if test="inDepartId != null">
|
AND a.IN_DEPART_ID = #{inDepartId}
|
</if>
|
<if test="outDepartId != null">
|
AND a.OUT_DEPART_ID = #{outDepartId}
|
</if>
|
<if test="outWarehouseId != null">
|
AND a.OUT_WAREHOUSE_ID = #{outWarehouseId}
|
</if>
|
<if test="inWarehouseId != null">
|
AND a.IN_WAREHOUSE_ID = #{inWarehouseId}
|
</if>
|
<if test="status != null">
|
AND a.STATUS = #{status}
|
</if>
|
<if test="type != null">
|
AND a.TYPE = #{type}
|
</if>
|
|
<if test="rootDepartId != null">
|
AND `a`.`ROOT_DEPART_ID` = #{rootDepartId}
|
</if>
|
<if test="departId != null">
|
AND ( `a`.`OUT_DEPART_ID` = #{departId} or `a`.`IN_DEPART_ID` = #{departId} )
|
</if>
|
<!-- <if test="proUserId != null">-->
|
<!-- AND `a`.`CREATE_USER` = #{proUserId}-->
|
<!-- </if>-->
|
|
<choose>
|
<when test="departIds != null and departIds.size()>0">
|
AND (
|
a.CREATE_USER=#{createUser} or a.OUT_USER_ID=#{createUser} or a.IN_USER_ID=#{createUser}
|
or
|
exists (select d.id from company_user d where (d.user_id= a.CREATE_USER or d.user_id=a.OUT_USER_ID or d.user_id= a.IN_USER_ID ) and d.department_id
|
in <foreach collection="departIds" item="item" separator="," open="(" close=")">#{item}</foreach>)
|
)
|
</when>
|
<otherwise>
|
<if test="createUser!=null">
|
and ( a.CREATE_USER=#{createUser} or a.OUT_USER_ID=#{createUser} or a.IN_USER_ID=#{createUser})
|
</if>
|
</otherwise>
|
</choose>
|
</where>
|
order by a.CREATE_TIME desc
|
</select>
|
|
<select id="wTransferById" resultType="doumeemes.dao.business.model.WTransfer">
|
SELECT w.* ,
|
outDepartment.name as outDepartName , outW.name as outWarehouseName, outUser.REALNAME as outUserName,
|
( select wo.CODE from w_outbound wo where wo.ORIGIN_ID = w.id and wo.TYPE = 0 and wo.ORIGIN_CODE = w.`CODE` limit 1 ) as outBillCode,
|
inDepartment.name as inDepartName,inW.name as inWarehouseName,inUser.REALNAME as inUserName,
|
( select wo.CODE from w_outbound wo where wo.ORIGIN_ID = w.id and wo.TYPE = 1 and wo.ORIGIN_CODE = w.`CODE` limit 1 ) inBillCode ,
|
cancel.REALNAME as cancelUserName , cancel.mobile as cancelUserMobile
|
from w_transfer w
|
left join department outDepartment on w.OUT_DEPART_ID = outDepartment.id
|
left join department inDepartment on w.IN_DEPART_ID = inDepartment.id
|
left join warehouse outW on w.OUT_WAREHOUSE_ID = outW.id
|
left join warehouse inW on w.IN_WAREHOUSE_ID = inW.id
|
left join `system_user` outUser on w.OUT_USER_ID = outUser.id
|
left join `system_user` inUser on w.IN_USER_ID = inUser.id
|
left join `system_user` cancel on w.CANCEL_USER_ID = cancel.id
|
where 1 = 1 and w.id = #{id}
|
limit 1
|
</select>
|
|
|
<select id="selectListByWorkorder" resultType="doumeemes.dao.ext.bean.WTransferBean">
|
select '1' as origin , CURDATE() as validDate , 3 as type , #{userId} as outUserId ,
|
CURDATE() as outPlandate , CURDATE() as inPlandate ,a2.PICKING_WAREHOUSE_ID as outWarehouseId ,
|
a4.WAREHOUSE_ID as inWarehouseId , ( select wu.PRO_USER_ID from workorder_user wu where wu.WORKORDER_ID = a1.id and wu.DELETED = 0 limit 1 ) as inUserId , a4.id as inLocationId ,
|
a2.ID as proceduresId, a5.DEPART_ID as inDepartId , a6.DEPART_ID as outDepartId ,
|
a1.BACKORDER_ID as backOrderId, GROUP_CONCAT( a1.CODE ) AS workorderCode,
|
GROUP_CONCAT( a1.id ) AS workorderId
|
from workorder a1
|
left join procedures a2 on a1.PROCEDURE_ID = a2.id
|
left join device a3 on a1.PRO_GROUP_ID = a3.id
|
left join warehouse_location a4 on a3.PRODUCE_WAREHOUSE_LOCATION_ID = a4.id
|
LEFT JOIN warehouse a5 on a4.WAREHOUSE_ID = a5.id
|
LEFT JOIN warehouse a6 on a2.PRODUCE_WAREHOUSE_ID = a6.id
|
LEFT JOIN ( select GROUP_CONCAT( PRO_USER_ID ) as proUserId , WORKORDER_ID from workorder_user
|
where DELETED = 0 and FIND_IN_SET(workorder_user.WORKORDER_ID, #{ids} ) group by workorder_user.WORKORDER_ID ) a7 on a7.WORKORDER_ID = a1.id
|
where 1 = 1 and FIND_IN_SET(a1.id, #{ids} )
|
group by a7.proUserId , a2.PRODUCE_WAREHOUSE_ID , a1.PRO_USER_ID , a4.WAREHOUSE_ID , a4.id, a1.BACKORDER_ID
|
</select>
|
|
|
|
</mapper>
|