<?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.business.BackorderMapper">
|
<resultMap id="BaseResultMap" type="doumeemes.dao.business.model.Backorder">
|
<id column="ID" jdbcType="INTEGER" property="id"/>
|
<result column="DELETED" jdbcType="TINYINT" property="deleted"/>
|
<result column="CREATE_USER" jdbcType="INTEGER" property="createUser"/>
|
<result column="CREATE_TIME" jdbcType="TIMESTAMP" property="createTime"/>
|
<result column="UPDATE_USER" jdbcType="INTEGER" property="updateUser"/>
|
<result column="UPDATE_TIME" jdbcType="TIMESTAMP" property="updateTime"/>
|
<result column="REMARK" jdbcType="VARCHAR" property="remark"/>
|
<result column="ROOT_DEPART_ID" jdbcType="INTEGER" property="rootDepartId"/>
|
<result column="ORDER_DEPART_ID" jdbcType="INTEGER" property="orderDepartId"/>
|
<result column="PROCEDURE_ID" jdbcType="INTEGER" property="procedureId"/>
|
<result column="MATERIAL_ID" jdbcType="INTEGER" property="materialId"/>
|
<result column="BATCH" jdbcType="VARCHAR" property="batch"/>
|
<result column="TYPE" jdbcType="INTEGER" property="type"/>
|
<result column="PLAN_DATE" jdbcType="TIMESTAMP" property="planDate"/>
|
<result column="BACK_PROCEDURE_ID" jdbcType="INTEGER" property="backProcedureId"/>
|
<result column="CONTENT" jdbcType="VARCHAR" property="content"/>
|
<result column="STATUS" jdbcType="INTEGER" property="status"/>
|
<result column="INSTANCE_ID" jdbcType="VARCHAR" property="instanceId"/>
|
<result column="CODE" jdbcType="VARCHAR" property="code"/>
|
<result column="NUM" jdbcType="DECIMAL" property="num"/>
|
<result column="SALEORDER_ID" jdbcType="INTEGER" property="saleorderId"/>
|
<result column="WAREHOUSE_ID" jdbcType="INTEGER" property="warehouseId"/>
|
<result column="FACTORY_ID" jdbcType="INTEGER" property="factoryId"/>
|
<result column="TITLE" jdbcType="VARCHAR" property="title"/>
|
<result column="WAREHOUSE_OUT_ID" jdbcType="VARCHAR" property="warehouseOutId"/>
|
</resultMap>
|
|
<sql id="Base_Column_List">
|
`ID`, `DELETED`, `CREATE_USER`, `CREATE_TIME`, `UPDATE_USER`, `UPDATE_TIME`, `REMARK`, `ROOT_DEPART_ID`, `ORDER_DEPART_ID`, `PROCEDURE_ID`, `MATERIAL_ID`, `BATCH`, `TYPE`, `PLAN_DATE`, `BACK_PROCEDURE_ID`, `CONTENT`, `STATUS`, `INSTANCE_ID`, `CODE`, `NUM`, `SALEORDER_ID`, `WAREHOUSE_ID`
|
</sql>
|
|
<select id="selectByModel" parameterType="doumeemes.dao.business.model.Backorder" resultMap="BaseResultMap">
|
select a.*,b.UNIT_ID as unitId,c.company_id as companyId,m.name as materialName,m.code as materialCode
|
,p.name as backProcedureName,cu.name as customerName,u.code as saleorderCode,f.name as factoryName
|
,w.name as warehouseName,ow.name as warehouseOutName
|
from backorder a
|
left join department c on a.ROOT_DEPART_ID=c.id
|
left join material_distribute b on a.MATERIAL_ID=b.id
|
left join material m on b.MATERIAL_ID=m.id
|
left join procedures p on a.BACK_PROCEDURE_ID=p.id
|
left join salesorder u on a.SALEORDER_ID=u.id
|
left join customer cu on cu.id=u.CUSTOMER_ID
|
left join department f on a.FACTORY_ID=f.id
|
left join warehouse w on a.WAREHOUSE_ID=w.id
|
left join warehouse ow on a.WAREHOUSE_OUT_ID=ow.id
|
<where>
|
<if test="id != null">
|
AND `a`.`ID` = #{id}
|
</if>
|
<if test="rootDepartId != null">
|
AND `a`.`ROOT_DEPART_ID` = #{rootDepartId}
|
</if>
|
<if test="deleted != null">
|
AND `a`.`DELETED` = #{deleted}
|
</if>
|
<if test="instanceId != null and instanceId!=''">
|
AND `a`.`INSTANCE_ID` = #{instanceId}
|
</if>
|
</where>
|
limit 1
|
</select>
|
<select id="selectList" parameterType="doumeemes.dao.business.model.Backorder" resultMap="BaseResultMap">
|
select a.*,b.UNIT_ID as unitId,c.company_id as companyId,m.name as materialName,m.code as materialCode
|
,p.name as backProcedureName,cu.name as customerName,u.code as saleorderCode
|
from backorder a
|
left join department c on a.ROOT_DEPART_ID=c.id
|
left join material_distribute b on a.MATERIAL_ID=b.id
|
left join material m on b.MATERIAL_ID=m.id
|
left join procedures p on a.BACK_PROCEDURE_ID=p.id
|
left join salesorder u on a.SALEORDER_ID=u.id
|
left join customer cu on cu.id=u.CUSTOMER_ID
|
<where>
|
<if test="id != null">
|
AND `a`.`ID` = #{id}
|
</if>
|
<if test="deleted != null">
|
AND `a`.`DELETED` = #{deleted}
|
</if>
|
<if test="status != null">
|
AND `a`.`status` = #{status}
|
</if>
|
<if test="type != null">
|
AND `a`.`type` = #{type}
|
</if>
|
<if test="startDate != null">
|
AND `a`.`CREATE_TIME` >= #{startDate}
|
</if>
|
<if test="endDate != null">
|
AND #{endDate} >= `a`.`CREATE_TIME`
|
</if>
|
<if test="rootDepartId != null">
|
AND `a`.`ROOT_DEPART_ID` = #{rootDepartId}
|
</if>
|
<if test="instanceId != null and instanceId!=''">
|
AND `a`.`INSTANCE_ID` = #{instanceId}
|
</if>
|
<if test="queryParam != null and queryParam!=''">
|
AND (`a`.`title` like concat('%', #{queryParam},'%') or `a`.`code` like concat('%', #{queryParam},'%') )
|
</if>
|
|
<choose>
|
<when test="departIds != null and departIds.size()>0">
|
AND (a.CREATE_USER=#{createUser}
|
or exists (select d.id from company_user d where ( d.user_id =`a`.`CREATE_USER` 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}
|
</if>
|
</otherwise>
|
</choose>
|
order by `a`.`CREATE_TIME` desc
|
</where>
|
</select>
|
|
|
</mapper>
|