<?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.nanometer.smartlab.dao.OpeApplyDao">
|
<resultMap id="OpeApply" type="com.nanometer.smartlab.entity.OpeApply">
|
<id property="id" column="id"/>
|
<result property="firstUser" column="first_user"></result>
|
<result property="reagentId" column="reagent_id"></result>
|
<result property="firName" column="fir_name"></result>
|
<result property="secondUserName" column="second_user_name"></result>
|
<result property="applyCode" column="apply_code"></result>
|
<result property="num" column="num"></result>
|
<result property="deadline" column="deadline"></result>
|
<result property="applyUserId" column="apply_user_id"></result>
|
<result property="projectId" column="project_id"></result>
|
<result property="status" column="status" typeHandler="com.nanometer.smartlab.entity.handler.ApplyStatusHandler"></result>
|
<result property="createTime" column="create_time"></result>
|
<result property="updateTime" column="update_time"></result>
|
<result property="validFlag" column="valid_flag" typeHandler="com.nanometer.smartlab.entity.handler.ValidFlagHandler"></result>
|
<result property="approveUserId" column="approve_user_id"></result>
|
<result property="beforeApproveUserId" column="before_approve_user_id"></result>
|
<result property="memo" column="memo"></result>
|
<result property="applyUserName" column="apply_user_name"></result>
|
<result property="applyUserProject" column="apply_user_project"></result>
|
<result property="applyUserDepartment" column="apply_user_department"></result>
|
<result property="approveUserName" column="approve_user_name"></result>
|
<result property="startReagentCode" column="start_reagent_code"></result>
|
<result property="endReagentCode" column="end_reagent_code"></result>
|
<result property="arrivalNum" column="arrival_num"></result>
|
<result property="articleNumber" column="article_number"></result>
|
<result property="houseId" column="house_id"></result>
|
<result property="containerId" column="container_id"></result>
|
<result property="place" column="place"></result>
|
<result property="applyGoal" column="apply_goal"></result>
|
<result property="applyPrice" column="apply_price"></result>
|
<result property="stockFlag" column="stock_flag"></result>
|
<association property="reagent" javaType="com.nanometer.smartlab.entity.SysReagent">
|
<id property="id" column="reagent_id"></id>
|
<result property="name" column="reagent_name"></result>
|
<result property="cas" column="reagent_cas"></result>
|
<result property="reagentType" column="reagent_type"></result>
|
<result property="reagentCharacter" column="reagent_character"></result>
|
<result property="supplierId" column="reagent_supplier_id"></result>
|
<result property="reagentFormat" column="reagent_format"></result>
|
<result property="mainMetering" column="reagent_main_metering"></result>
|
<result property="reagentUnit" column="reagent_unit"></result>
|
<result property="price" column="reagent_price"></result>
|
<result property="perBox" column="reagent_per_box"></result>
|
<result property="memo" column="reagent_memo"></result>
|
<result property="validFlag" column="reagent_valid_flag"></result>
|
<result property="createTime" column="reagent_create_time"></result>
|
<result property="updateTime" column="reagent_update_time"></result>
|
<result property="supplierName" column="supplier_name"></result>
|
<result property="productSn" column="reagent_product_sn"></result>
|
<result property="controlProducts" column="control_products"></result>
|
<result property="dangerousFlag" column="reagent_dangerous_flag" typeHandler="com.nanometer.smartlab.entity.handler.DangerousFlagHandler"></result>
|
<result property="productHome" column="product_home"></result>
|
<result property="type" column="type"></result>
|
<result property="supplierFlag" column="supplier_flag"></result>
|
</association>
|
<association property="order" javaType="com.nanometer.smartlab.entity.OpeOrder">
|
<id property="id" column="order_id"></id>
|
<result property="orderName" column="order_name"></result>
|
<result property="orderCode" column="order_code"></result>
|
</association>
|
</resultMap>
|
|
<resultMap id="OpeApplyReserve" type="com.nanometer.smartlab.entity.OpeApplyReserve">
|
<id property="id" column="id"/>
|
<result property="applyCode" column="apply_code"></result>
|
<result property="num" column="num"></result>
|
<result property="used" column="used"></result>
|
<result property="arrivalNum" column="arrival_num"></result>
|
<result property="status" column="status" typeHandler="com.nanometer.smartlab.entity.handler.ApplyStatusHandler"></result>
|
<result property="applyUserId" column="apply_user_id"></result>
|
<result property="applyUser" column="apply_user"></result>
|
<result property="arrivalTime" column="arrival_time"></result>
|
<result property="articleNumber" column="article_number"></result>
|
<result property="projectManage" column="project_manage"/>
|
<result property="projectName" column="project_name"/>
|
<result property="startReagentCode" column="start_reagent_code"></result>
|
<result property="endReagentCode" column="end_reagent_code"></result>
|
<association property="reagent" javaType="com.nanometer.smartlab.entity.SysReagent">
|
<id property="id" column="reagent_id"></id>
|
<result property="name" column="reagent_name"></result>
|
<result property="cas" column="reagent_cas"></result>
|
<result property="reagentType" column="reagent_type"></result>
|
<result property="reagentCharacter" column="reagent_character"></result>
|
<result property="supplierId" column="reagent_supplier_id"></result>
|
<result property="reagentFormat" column="reagent_format"></result>
|
<result property="mainMetering" column="reagent_main_metering"></result>
|
<result property="reagentUnit" column="reagent_unit"></result>
|
<result property="price" column="reagent_price"></result>
|
<result property="perBox" column="reagent_per_box"></result>
|
<result property="memo" column="reagent_memo"></result>
|
<result property="validFlag" column="reagent_valid_flag"></result>
|
<result property="createTime" column="reagent_create_time"></result>
|
<result property="updateTime" column="reagent_update_time"></result>
|
<result property="supplierName" column="supplier_name"></result>
|
<result property="productSn" column="reagent_product_sn"></result>
|
<result property="controlProducts" column="control_products"></result>
|
<result property="dangerousFlag" column="reagent_dangerous_flag" typeHandler="com.nanometer.smartlab.entity.handler.DangerousFlagHandler"></result>
|
<result property="productHome" column="product_home"></result>
|
</association>
|
</resultMap>
|
|
<sql id="queryWhereSql">
|
<if test="reagentName != null and reagentName != ''">
|
and sr.name like #{reagentName}
|
</if>
|
<if test="startDeadline != null">
|
and oa.deadline >= #{startDeadline}
|
</if>
|
<if test="endDeadline != null">
|
and #{endDeadline} >= oa.deadline
|
</if>
|
<if test="status != null">
|
and oa.status = #{status}
|
</if>
|
<if test="applyUserId != null and applyUserId != ''">
|
and oa.apply_user_id = #{applyUserId}
|
</if>
|
<if test="approveUserId != null and approveUserId != ''">
|
and (oa.approve_user_id = #{approveUserId} or oa.before_approve_user_id = #{approveUserId})
|
</if>
|
<if test="searchApproval != null and searchApproval != ''">
|
and (oa.approve_user_id = #{searchApproval} or oa.before_approve_user_id = #{searchApproval})
|
</if>
|
|
<if test="approvaUserName != null and approvaUserName != ''">
|
and (suApprove.name like concat('%',#{approvaUserName},'%')
|
or sys.name like concat('%',#{approvaUserName},'%') )
|
</if>
|
|
<if test="editId != null and editId != ''">
|
and oa.id != #{editId}
|
</if>
|
<if test="cas != null and cas != ''">
|
and sr.cas like #{cas}
|
</if>
|
<if test="applyCode != null and applyCode != ''">
|
and oa.apply_code like concat('%',#{applyCode},'%')
|
</if>
|
<if test="applyUserName != null and applyUserName != ''">
|
and su.name like concat('%',#{applyUserName},'%')
|
</if>
|
</sql>
|
|
<select id="getOpeApply" resultMap="OpeApply" >
|
select oa.*,sys.name as secondUserName,
|
sr.name as reagent_name, sr.cas as reagent_cas ,sr.reagent_type as reagent_type, sr.reagent_character as reagent_character,
|
sr.supplier_id as reagent_supplier_id, sr.dangerous_flag as reagent_dangerous_flag,
|
sr.reagent_format as reagent_format, sr.main_metering as reagent_main_metering, sr.reagent_unit as reagent_unit,
|
sr.price as reagent_price, sr.per_box as reagent_per_box,sr.memo as reagent_memo, sr.valid_flag as reagent_valid_flag,
|
sr.create_time as reagent_create_time, sr.update_time as reagent_update_time,sr.control_products as control_products,
|
sr.product_sn as reagent_product_sn,sr.product_home as product_home,
|
ss.name as supplier_name,
|
su.name as apply_user_name,
|
sp.project_name as apply_user_project,
|
bm2.meta_value as apply_user_department,
|
fir.name as firName,
|
suApprove.name as approve_user_name,
|
ss.valid_flag as supplier_flag,
|
sr.type as type
|
from ope_apply as oa
|
left join sys_reagent sr on oa.reagent_id = sr.id
|
left join sys_supplier as ss on sr.supplier_id = ss.id
|
left join sys_user as su on oa.apply_user_id = su.id
|
left join sys_user as suApprove on oa.approve_user_id = suApprove.id
|
left join sys_user as sys on sys.id=oa.before_approve_user_id
|
left join sys_user as fir on fir.id=oa.first_user
|
left join base_meta as bm2 on bm2.id = su.department
|
left join sys_project sp on sp.id=su.project_id=sp.id
|
where oa.id = #{id} and oa.valid_flag = 1
|
</select>
|
|
<select id="getOpeApplyList" parameterType="java.util.Map" resultMap="OpeApply">
|
select oa.*,sys.name as second_user_name,
|
sr.name as reagent_name,sr.price as reagent_price ,sr.cas as reagent_cas, sr.reagent_type as reagent_type,
|
sr.reagent_character as reagent_character, sr.supplier_id as reagent_supplier_id,
|
sr.reagent_format as reagent_format, sr.main_metering as reagent_main_metering, sr.reagent_unit as reagent_unit,
|
sr.per_box as reagent_per_box,sr.memo as reagent_memo, sr.valid_flag as reagent_valid_flag, sr.create_time as reagent_create_time,
|
sr.update_time as reagent_update_time, sr.product_sn as reagent_product_sn,
|
sr.dangerous_flag as reagent_dangerous_flag,sr.control_products as control_products,sr.product_home as product_home,
|
ss.name as supplier_name,
|
su.name as apply_user_name,
|
sp.project_name as apply_user_project,
|
bm2.meta_value as apply_user_department,
|
suApprove.name as approve_user_name,
|
fir.name as fir_name,
|
ss.valid_flag as supplier_flag,
|
sr.type as type
|
from ope_apply as oa
|
left join sys_reagent sr on oa.reagent_id = sr.id
|
left join sys_supplier as ss on sr.supplier_id = ss.id
|
left join sys_user as su on oa.apply_user_id = su.id
|
left join sys_user as suApprove on oa.approve_user_id = suApprove.id
|
left join sys_user as sys on sys.id=oa.before_approve_user_id
|
left join sys_user as fir on fir.id=oa.first_user
|
left join base_meta as bm2 on bm2.id = su.department
|
left join sys_project as sp on sp.id=su.project_id
|
where oa.valid_flag = 1
|
<if test="isShow != null and isShow ==0">
|
and (ss.valid_flag = 1 or sr.type = 0)
|
</if>
|
<if test="controlProduct != null and controlProduct != ''">
|
and sr.control_products like concat("%",#{controlProduct},"%")
|
</if>
|
<include refid="queryWhereSql"/>
|
order by oa.create_time desc
|
<if test="first != null and pageSize != null">
|
limit #{first}, #{pageSize}
|
</if>
|
</select>
|
|
<select id="getOpeApplyTotalCount" parameterType="java.util.Map" resultType="int">
|
select count(1)
|
from ope_apply as oa
|
left join sys_reagent sr on oa.reagent_id = sr.id
|
left join sys_supplier as ss on sr.supplier_id = ss.id
|
left join sys_user as su on oa.apply_user_id = su.id
|
left join sys_user as suApprove on oa.approve_user_id = suApprove.id
|
left join sys_user as sys on sys.id=oa.before_approve_user_id
|
left join sys_user as fir on fir.id=oa.first_user
|
where oa.valid_flag = 1
|
<if test="isShow != null and isShow ==0">
|
and (ss.valid_flag = 1 or sr.type = 0)
|
</if>
|
<if test="controlProduct != null and controlProduct != ''">
|
and sr.control_products like concat("%",#{controlProduct},"%")
|
</if>
|
<include refid="queryWhereSql"/>
|
</select>
|
|
<insert id="insertOpeApply" parameterType="com.nanometer.smartlab.entity.OpeApply" useGeneratedKeys = "true" keyProperty = "id">
|
insert into ope_apply( apply_code, reagent_id, num, deadline, apply_user_id, project_id, status, approve_user_id, memo, valid_flag, create_time, update_time)
|
values ( #{applyCode}, #{reagent.id}, #{num}, #{deadline}, #{applyUserId}, #{projectId}, #{status}, #{approveUserId}, #{memo}, 1, now(), now())
|
</insert>
|
|
<insert id="insertOpeApplyList" parameterType="java.util.List" >
|
insert into ope_apply
|
(apply_code, reagent_id, num, deadline, apply_user_id, project_id, status, approve_user_id, memo, valid_flag, create_time, update_time,apply_goal,apply_price,first_user)
|
values
|
<foreach collection="opeApplyList" item="opeApply" separator=",">
|
( #{opeApply.applyCode}, #{opeApply.reagent.id}, #{opeApply.num}, #{opeApply.deadline},
|
#{opeApply.applyUserId}, #{opeApply.projectId}, #{opeApply.status}, #{opeApply.approveUserId}, #{opeApply.memo}, 1, now(), now(),#{opeApply.applyGoal},#{opeApply.reagent.price},#{opeApply.approveUserId})
|
</foreach>
|
</insert>
|
<insert id="insertList" parameterType="java.util.List" useGeneratedKeys = "true" keyProperty = "id">
|
insert into ope_apply
|
(apply_code, reagent_id, num, deadline, apply_user_id, project_id, status, approve_user_id, memo, valid_flag, create_time, update_time,apply_goal,apply_price,first_user)
|
values
|
<foreach collection="list" item="opeApply" separator=",">
|
( #{opeApply.applyCode}, #{opeApply.reagent.id}, #{opeApply.num}, #{opeApply.deadline},
|
#{opeApply.applyUserId}, #{opeApply.projectId}, #{opeApply.status}, #{opeApply.approveUserId}, #{opeApply.memo}, 1, #{opeApply.createTime}, #{opeApply.updateTime},#{opeApply.applyGoal},#{opeApply.reagent.price},#{opeApply.approveUserId})
|
</foreach>
|
</insert>
|
|
<update id="updateFirst" parameterType="java.util.Map">
|
update ope_apply set first_user=approve_user_id where id=#{id}
|
</update>
|
<update id="updateFirst2" parameterType="java.util.Map">
|
update ope_apply set first_user=before_approve_user_id where id=#{id}
|
</update>
|
<update id="updateOpeApply" parameterType="com.nanometer.smartlab.entity.OpeApply">
|
update ope_apply
|
<set>
|
<if test="applyCode!=null and applyCode!=''">
|
apply_code=#{applyCode},
|
</if>
|
<if test="reagent!=null and reagent.id!=null">
|
reagent_id=#{reagent.id},
|
</if>
|
<if test="num!=null and num!=''">
|
num=#{num},
|
</if>
|
<if test="deadline!=null">
|
deadline=#{deadline},
|
</if>
|
<if test="applyUserId!=null and applyUserId!=''">
|
apply_user_id=#{applyUserId},
|
</if>
|
<if test="projectId!=null and projectId!=''">
|
project_id=#{projectId},
|
</if>
|
<if test="status!=null">
|
status=#{status},
|
</if>
|
<if test="approveUserId!=null and approveUserId!=''">
|
approve_user_id=#{approveUserId},
|
</if>
|
<if test="memo!=null and memo!=''">
|
memo=#{memo},
|
</if>
|
update_time=now(),
|
<if test="startReagentCode!=null and startReagentCode!=''">
|
start_reagent_code=#{startReagentCode},
|
</if>
|
<if test="endReagentCode!=null and endReagentCode!=''">
|
end_reagent_code=#{endReagentCode},
|
</if>
|
<if test="arrivalNum!=null and arrivalNum!=''">
|
arrival_num=#{arrivalNum},
|
</if>
|
<if test="houseId!=null and houseId!=''">
|
house_id=#{houseId},
|
</if>
|
<if test="place!=null and place!=''">
|
place=#{place},
|
</if>
|
<if test="containerId!=null and containerId!=''">
|
container_id=#{containerId},
|
</if>
|
<if test="articleNumber!=null and articleNumber!=''">
|
article_number=#{articleNumber}
|
</if>
|
</set>
|
where id=#{id}
|
|
</update>
|
|
<update id="updateOpeApplyStatus" parameterType="java.util.Map" >
|
update ope_apply set status=#{status},
|
<if test="memo !=null and memo != ''">
|
memo=#{memo},
|
</if>
|
update_time=now()
|
where id in
|
<foreach collection="applyIds" item="item" index="index" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</update>
|
|
<update id="updateOpeApplyStatusById" >
|
update ope_apply set status=#{status},update_time=now()
|
where id =#{id}
|
</update>
|
|
<update id="updateOpeApplyProject" parameterType="java.util.Map">
|
update ope_apply set project_id =#{newObjective} where project_id=#{oldObjective}
|
</update>
|
|
|
<update id="cancelApply" parameterType="java.util.Map">
|
update ope_apply set status=#{status} where id=#{id}
|
</update>
|
|
<update id="updateOpeApplyUsed" parameterType="com.nanometer.smartlab.entity.OpeApplyReserve">
|
update ope_apply set used=#{used} where id=#{id}
|
</update>
|
|
<update id="updateOpeApplyAdmin" parameterType="java.util.Map" >
|
update ope_apply set before_memo=#{memo}, before_approve_user_id=approve_user_id,
|
approve_user_id=#{userId}, update_time=now()
|
where id in
|
<foreach collection="applyIds" item="item" index="index" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</update>
|
|
<update id="updateOpeApplyAdmin2" parameterType="java.util.Map" >
|
update ope_apply set before_memo=#{memo}, before_approve_user_id=#{beforeUserId},
|
approve_user_id=#{userId}, update_time=now()
|
where id =#{id}
|
</update>
|
|
|
<update id="deleteOpeApply" parameterType="java.util.List">
|
update ope_apply set valid_flag=0, update_time=now()
|
where id in
|
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</update>
|
|
|
<select id="selectOpeApplyByPrimaryKey" parameterType="java.util.Map" resultMap="OpeApply">
|
select *
|
from ope_apply as oa
|
where id = #{id}
|
</select>
|
|
<sql id="getOpeApplyReserveList_queryColumns">
|
select oa.id, oa.apply_code,
|
sr.id reagent_id,
|
oa.status,
|
sr.product_sn reagent_product_sn,
|
sr.`name` reagent_name,
|
sr.control_products,
|
sr.reagent_format,
|
sr.main_metering reagent_main_metering,
|
sr.price reagent_price,
|
sr.cas reagent_cas,
|
oa.article_number article_number,
|
sr.reagentCharacter,
|
sr.product_home,
|
sr.dangerous_flag,
|
oa.num,
|
oa.used,
|
su.`name` apply_user_id
|
</sql>
|
|
<sql id="getOpeApplyReserveList_queryJoins1">
|
left JOIN sys_reagent sr on sr.id = oa.reagent_id
|
left JOIN sys_user su on su.id = oa.apply_user_id
|
</sql>
|
|
<!-- <sql id="getOpeApplyReserveList_queryJoins2">-->
|
<!-- left join base_meta as bm2 on sr.control_products = bm2.id-->
|
<!-- left join base_meta as bm3 on sr.reagent_format = bm3.id-->
|
<!-- left join base_meta as bm4 on sr.reagent_character = bm4.id-->
|
<!-- left join base_meta as bm1 on sr.product_home = bm1.id-->
|
<!-- </sql>-->
|
|
<sql id="getOpeApplyReserveList_queryWhereSql">
|
<if test="reagentName != null and reagentName != ''">
|
and sr.name like concat('%',#{reagentName},'%')
|
</if>
|
<if test="personName != null and personName != ''">
|
and su.name like concat('%',#{personName},'%')
|
</if>
|
<if test="userId != null and userId != ''">
|
and oa.apply_user_id =#{userId}
|
</if>
|
<if test="status != null ">
|
and oa.status =#{status}
|
</if>
|
<if test="productSn != null and productSn != ''">
|
and sr.product_sn like concat('%',#{productSn},'%')
|
</if>
|
<if test="applyCode != null and applyCode != ''">
|
and oa.apply_code = #{applyCode}
|
</if>
|
</sql>
|
|
<select id="getOpeApplyReserveTotalCount" parameterType="java.util.Map"
|
resultType="int">
|
select count(1)
|
from ope_apply as oa
|
<include refid="getOpeApplyReserveList_queryJoins1" />
|
where oa.valid_flag = 1
|
<include refid="getOpeApplyReserveList_queryWhereSql" />
|
</select>
|
|
<select id="getOpeApplyReserveTotalCountFor" parameterType="java.util.Map"
|
resultType="int">
|
select count(1)
|
from
|
(select count(1)
|
from ope_apply as oa
|
LEFT JOIN sys_reagent sr ON sr.id = oa.reagent_id
|
LEFT JOIN sys_user su ON su.id = oa.apply_user_id
|
LEFT JOIN sys_project as project on project.id = su.project_id
|
LEFT JOIN sys_user as su1 on su1.id = project.sys_user_id
|
where oa.valid_flag = 1 and (
|
<choose>
|
<when test="status != null and status == 10">
|
oa.status = 10
|
</when>
|
<otherwise>
|
oa.status=4 or oa.status=6 or oa.status=9
|
</otherwise>
|
</choose>
|
)
|
<include refid="getOpeApplyReserveList_queryWhereSql" />
|
<if test="isAllApply != null">
|
<choose>
|
<when test="isAllApply == 1">
|
and oa.used = oa.num
|
</when>
|
<otherwise>
|
and oa.used != oa.num
|
</otherwise>
|
</choose>
|
</if>
|
GROUP BY oa.id
|
)as oaa
|
</select>
|
|
<select id="getOpeApplyReserveList" parameterType="java.util.Map"
|
resultMap="OpeApplyReserve">
|
<include refid="getOpeApplyReserveList_queryColumns" />
|
from ope_apply as oa
|
<include refid="getOpeApplyReserveList_queryJoins1" />
|
where oa.valid_flag = 1
|
<include refid="getOpeApplyReserveList_queryWhereSql" />
|
GROUP BY oa.id
|
order by oa.update_time desc
|
<if test="first != null and pageSize != null">
|
limit #{first}, #{pageSize}
|
</if>
|
</select>
|
|
<select id="getOpeApplyReserveListFor" parameterType="java.util.Map"
|
resultMap="OpeApplyReserve">
|
SELECT
|
oa.id,
|
oa.apply_code,
|
sr.id reagent_id,
|
oa.status,
|
sr.product_sn reagent_product_sn,
|
sr.`name` reagent_name,
|
sr.main_metering reagent_main_metering,
|
sr.price reagent_price,
|
sr.cas reagent_cas,
|
sr.reagent_unit,
|
oa.article_number article_number,
|
sr.dangerous_flag,
|
sr.control_products control_products,
|
sr.reagent_character,
|
sr.reagent_format,
|
sr.product_home,
|
oa.num,
|
su.name apply_user,
|
oa.apply_user_id,
|
oa.used,
|
su.`name` apply_user_name,
|
project.project_name as project_name,
|
su1.`name` as project_manage,
|
oa.arrival_time
|
FROM
|
ope_apply AS oa
|
LEFT JOIN sys_reagent sr ON sr.id = oa.reagent_id
|
LEFT JOIN sys_user su ON su.id = oa.apply_user_id
|
LEFT JOIN sys_project as project on project.id = su.project_id
|
LEFT JOIN sys_user as su1 on su1.id = project.sys_user_id
|
where oa.valid_flag = 1 and (
|
<choose>
|
<when test="status != null and status == 10">
|
oa.status = 10
|
</when>
|
<otherwise>
|
oa.status=4 or oa.status=6 or oa.status=9
|
</otherwise>
|
</choose>
|
)
|
<if test="reagentName != null and reagentName != ''">
|
and sr.name like concat('%',#{reagentName},'%')
|
</if>
|
<if test="personName != null and personName != ''">
|
and su.name like concat('%',#{personName},'%')
|
</if>
|
<if test="userId != null and userId != ''">
|
and oa.apply_user_id =#{userId}
|
</if>
|
<if test="status != null ">
|
and oa.status =#{status}
|
</if>
|
<if test="productSn != null and productSn != ''">
|
and sr.product_sn like concat('%',#{productSn},'%')
|
</if>
|
<if test="applyCode != null and applyCode != ''">
|
and oa.apply_code = #{applyCode}
|
</if>
|
<if test="isAllApply != null">
|
<choose>
|
<when test="isAllApply == 1">
|
and oa.used = oa.num
|
</when>
|
<otherwise>
|
and oa.used != oa.num
|
</otherwise>
|
</choose>
|
</if>
|
GROUP BY oa.id
|
order by oa.update_time desc
|
<if test="first != null and pageSize != null">
|
limit #{first}, #{pageSize}
|
</if>
|
</select>
|
<update id="updaetOpeApplyPrice" parameterType="java.util.Map" >
|
update ope_apply set apply_price=#{applyPrice}
|
where id=#{id}
|
</update>
|
|
<update id="updaetOpeApplyStockFlag" parameterType="java.util.Map">
|
update ope_apply set stock_flag=#{stockFlag} where id=#{id}
|
</update>
|
|
<select id="selectByReId" resultMap="OpeApply">
|
select * from ope_apply where reagent_id=#{id}
|
</select>
|
<select id="getOpeApplyDetail" resultMap="OpeApplyReserve">
|
select oa.id, oa.apply_code,
|
sr.id reagent_id,
|
oa.status,
|
sr.product_sn reagent_product_sn,
|
sr.`name` reagent_name,
|
sr.control_products,
|
sr.reagent_format,
|
sr.main_metering reagent_main_metering,
|
sr.price reagent_price,
|
sr.cas reagent_cas,
|
oa.article_number article_number,
|
sr.reagent_character,
|
sr.product_home,
|
sr.dangerous_flag,
|
oa.num,
|
oa.used,
|
oa.arrival_num,
|
su.id apply_user_id,
|
CONCAT(rc.code_prex,LPAD(rc.start_code,4,'0')) as start_reagent_code,
|
CONCAT(rc.code_prex,LPAD(rc.end_code,4,'0')) as end_reagent_code
|
from ope_apply as oa
|
left JOIN sys_reagent sr on sr.id = oa.reagent_id
|
left JOIN sys_user su on su.id = oa.apply_user_id
|
left join ope_reagent_code rc on rc.apply_id=oa.id
|
where oa.valid_flag = 1
|
and oa.id = #{0}
|
</select>
|
<select id="getOpeApplyReserveListByNameForRowData"
|
resultMap="OpeApplyReserve">
|
SELECT
|
oa.id,
|
oa.apply_code,
|
sr.id reagent_id,
|
oa. STATUS,
|
sr.product_sn reagent_product_sn,
|
sr.`name` reagent_name,
|
sr.control_products,
|
sr.reagent_format,
|
sr.reagent_unit,
|
sr.main_metering reagent_main_metering,
|
sr.price reagent_price,
|
sr.cas reagent_cas,
|
oa.article_number article_number,
|
sr.reagent_character,
|
sr.product_home,
|
sr.dangerous_flag,
|
oa.num,
|
oa.apply_user_id apply_user_id,
|
oa.used,
|
su.`name` apply_user,
|
project.project_name apply_user_project,
|
su1.`name` as project_manage,
|
oa.arrival_time
|
FROM
|
ope_apply AS oa
|
LEFT JOIN sys_reagent sr ON sr.id = oa.reagent_id
|
LEFT JOIN sys_user su ON su.id = oa.apply_user_id
|
LEFT JOIN sys_project as project on project.id = su.project_id
|
LEFT JOIN sys_user as su1 on su1.id = project.sys_user_id
|
where oa.id = #{id}
|
|
|
</select>
|
<select id="getApplyControlInfo" resultType="java.util.Map">
|
(SELECT sum(oa.num) sum,"易制毒" name from ope_apply oa
|
LEFT JOIN sys_reagent sr on oa.reagent_id = sr.id
|
where
|
oa.valid_flag = 1
|
and sr.valid_flag = 1
|
and YEAR(oa.create_time)=YEAR(NOW())
|
and oa.status in(2,3,4,6)
|
and
|
sr.control_products like "%易制毒%") UNION ALL(
|
|
SELECT sum(oa.num) sum,"易制爆" name from ope_apply oa
|
LEFT JOIN sys_reagent sr on oa.reagent_id = sr.id
|
where
|
oa.valid_flag = 1
|
and sr.valid_flag = 1
|
and YEAR(oa.create_time)=YEAR(NOW())
|
and oa.status in(2,3,4,6)
|
and sr.control_products like "%易制爆%")UNION ALL(
|
|
SELECT sum(oa.num) sum,"总数" name from ope_apply oa
|
LEFT JOIN sys_reagent sr on oa.reagent_id = sr.id
|
where
|
oa.valid_flag = 1
|
and sr.valid_flag = 1
|
and YEAR(oa.create_time)=YEAR(NOW())
|
and oa.status in(2,3,4,6)
|
)
|
|
</select>
|
<select id="getOpeApplySupplerRequireMngTotalCount" resultType="java.lang.Integer">
|
select count(1)
|
from ope_apply as oa
|
left join sys_reagent sr on oa.reagent_id = sr.id
|
left join sys_supplier as ss on sr.supplier_id = ss.id
|
left join sys_user as su on oa.apply_user_id = su.id
|
left join sys_user as suApprove on oa.approve_user_id = suApprove.id
|
left join sys_user as sys on sys.id=oa.before_approve_user_id
|
left join sys_user as fir on fir.id=oa.first_user
|
where oa.valid_flag = 1
|
<if test="isShow != null and isShow ==0">
|
and (ss.valid_flag = 1 or sr.type = 0)
|
</if>
|
<if test="reagentName != null and reagentName != ''">
|
and sr.name like concat("%",#{reagentName},"%")
|
</if>
|
<if test="startDeadline != null">
|
and oa.deadline >= #{startDeadline}
|
</if>
|
<if test="endDeadline != null">
|
and #{endDeadline} >= oa.deadline
|
</if>
|
<if test="status != null">
|
and oa.status = #{status}
|
</if>
|
<if test="company != null and company != ''">
|
and ss.name = #{company}
|
</if>
|
|
</select>
|
<select id="getOpeApplySupplerRequireMngList" parameterType="java.util.Map" resultMap="OpeApply">
|
|
select oa.*,sys.name as secondUserName,
|
sr.name as reagent_name,sr.price as reagent_price ,sr.cas as reagent_cas, sr.reagent_type as reagent_type, sr.reagent_character as reagent_character,
|
sr.supplier_id as reagentSupplierId,sr.reagent_format as reagent_format, sr.main_metering as reagent_main_metering,
|
sr.reagent_unit as reagent_unit, sr.per_box as reagent_per_box,sr.memo as reagent_memo, sr.valid_flag as reagent_valid_flag,
|
sr.create_time as reagent_create_time, sr.update_time as reagent_update_time, sr.product_sn as reagent_product_sn,
|
sr.dangerous_flag as reagent_dangerous_flag,sr.control_products as control_products,sr.product_home as product_home,
|
ss.name as supplier_name,
|
su.name as applyUser_name,
|
suApprove.name as approve_user_name,
|
sr.product_home as apply_user_project,
|
fir.name as fir_name,
|
ss.valid_flag as supplier_flag,
|
sr.type as type
|
from ope_apply as oa
|
left join sys_reagent sr on oa.reagent_id = sr.id
|
left join sys_supplier as ss on sr.supplier_id = ss.id
|
left join sys_user as su on oa.apply_user_id = su.id
|
left join sys_user as suApprove on oa.approve_user_id = suApprove.id
|
left join sys_user as sys on sys.id=oa.before_approve_user_id
|
left join sys_user as fir on fir.id=oa.first_user
|
where oa.valid_flag = 1
|
<if test="isShow != null and isShow ==0">
|
and (ss.valid_flag = 1 or sr.type = 0)
|
</if>
|
<if test="company != null and company != ''">
|
and ss.name = #{company}
|
</if>
|
<if test="reagentName != null and reagentName != ''">
|
and sr.name like concat("%",#{reagentName},"%")
|
</if>
|
<if test="startDeadline != null">
|
and oa.deadline >= #{startDeadline}
|
</if>
|
<if test="endDeadline != null">
|
and #{endDeadline} >= oa.deadline
|
</if>
|
<if test="status != null">
|
and oa.status = #{status}
|
</if>
|
order by oa.create_time desc
|
<if test="first != null and pageSize != null">
|
limit #{first}, #{pageSize}
|
</if>
|
</select>
|
|
|
<update id="updateByReId" parameterType="java.util.Map">
|
update ope_apply set reagent_id=#{newReId} where reagent_id=#{oldReId}
|
</update>
|
|
<update id="updateOpeApplyInfo" parameterType="java.util.Map">
|
update
|
ope_apply
|
set status = #{status}
|
<if test="arrivalTime!=null" >
|
,arrival_time = #{arrivalTime}
|
</if>
|
<if test="consigneeId!=null" >
|
,consignee_id = #{consigneeId}
|
</if>
|
<if test="arrivalNum!=null" >
|
,arrival_num = #{arrivalNum}
|
</if>
|
where valid_flag = 1
|
and id = #{applyId}
|
</update>
|
|
<select id="getOpeApplyByOrderId" resultMap="OpeApply">
|
select distinct a.id,a.apply_code,a.reagent_id,a.used,a.num,a.arrival_num,a.apply_user_id,a.status,a.project_id,a.deadline,a.approve_user_id,a.apply_price,a.create_time,a.memo,a.article_number,a.place,
|
CONCAT(c.code_prex,LPAD(c.start_code,4,'0')) as start_reagent_code,CONCAT(c.code_prex,LPAD(c.end_code,4,'0')) as end_reagent_code,
|
d.name as reagent_name, d.cas as reagent_cas, d.reagent_type as reagent_type, d.reagent_character as reagent_character,
|
d.supplier_id as reagent_supplier_id,d.product_home as product_home,d.product_sn as reagent_product_sn,
|
d.reagent_format as reagent_format, d.main_metering as reagent_main_metering, d.reagent_unit as reagent_unit,
|
d.price as reagent_price, d.per_box as reagent_per_box,d.control_products,
|
e.name as apply_user_name
|
from ope_apply a
|
left join ope_apply_order b on b.ope_apply_id=a.id
|
left join ope_reagent_code c on c.apply_id=a.id
|
left join sys_reagent d on a.reagent_id = d.id
|
left join sys_user e on a.apply_user_id = e.id
|
where b.ope_order_id=#{orderId}
|
</select>
|
|
|
<select id="getReagentByApplyId" resultType="com.nanometer.smartlab.entity.SysReagent">
|
select sa.* from sys_reagent sa
|
left join ope_apply oa on oa.reagent_id=sa.id
|
where oa.id=#{applyId}
|
</select>
|
|
|
<select id="getOpeApplyCountWithOrder" resultType="int">
|
select count(1)
|
from ope_apply as oa
|
inner join ope_apply_order ao on ao.ope_apply_id=oa.id
|
inner join ope_order oo on oo.id=ao.ope_order_id
|
<where>
|
oa.valid_flag = 1 and oo.valid_flag=1
|
<if test="applyCode!=null and applyCode!=''">
|
and oa.apply_code=#{applyCode}
|
</if>
|
</where>
|
</select>
|
|
<select id="getOpeApplyListWithOrder" resultMap="OpeApply">
|
select oa.*,
|
sr.name as reagent_name,sr.cas as reagent_cas, sr.reagent_type as reagent_type,
|
sr.reagent_character as reagent_character,sr.product_sn as reagent_product_sn,sr.product_home as product_home,
|
ss.name as supplier_name,
|
su.name as apply_user_name,
|
oo.id as order_id,oo.order_name,oo.order_code
|
from ope_apply as oa
|
inner join ope_apply_order ao on ao.ope_apply_id=oa.id
|
inner join ope_order oo on oo.id=ao.ope_order_id
|
left join sys_reagent sr on oa.reagent_id = sr.id
|
left join sys_supplier as ss on sr.supplier_id = ss.id
|
left join sys_user as su on oa.apply_user_id = su.id
|
<where>
|
oa.valid_flag = 1 and oo.valid_flag=1
|
<if test="applyCode!=null and applyCode!=''">
|
and oa.apply_code=#{applyCode}
|
</if>
|
<if test="orderCode!=null and orderCode!=''">
|
and oo.order_code=#{orderCode}
|
</if>
|
<if test="orderName!=null and orderName!=''">
|
and oo.order_name like concat('%',#{orderName},'%')
|
</if>
|
</where>
|
order by oo.create_time desc
|
<if test="first != null and pageSize != null">
|
limit #{first}, #{pageSize}
|
</if>
|
</select>
|
|
|
<select id="getArrivalNumById" resultType="int">
|
select ifnull(arrival_num ,0)from ope_apply where id=#{applyId}
|
</select>
|
|
</mapper>
|