<?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.gkhy.safePlatform.equipment.repository.SafeMaterialInfoRepository">
|
|
<resultMap type="com.gkhy.safePlatform.equipment.entity.SafeMaterialInfo" id="materialResult">
|
<id column="id" property="id" jdbcType="BIGINT"/>
|
<result column="serial_num" property="serialNum" jdbcType="VARCHAR"/>
|
<result column="big_classify_id" property="bigClassifyId" jdbcType="BIGINT"/>
|
<result column="small_classify_id" property="smallClassifyId" jdbcType="BIGINT"/>
|
<result column="dep_id" property="depId" jdbcType="BIGINT"/>
|
<result column="dep_name" property="depName" jdbcType="VARCHAR"/>
|
<result column="material_name" property="materilaName" jdbcType="VARCHAR"/>
|
<result column="consumable" property="consumable" jdbcType="TINYINT"/>
|
<result column="total_count" property="totalCount" jdbcType="INTEGER"/>
|
<result column="stock_count" property="stockCount" jdbcType="INTEGER"/>
|
<result column="del_flag" property="delFlag" jdbcType="INTEGER"/>
|
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
<result column="create_uid" property="createUid" jdbcType="BIGINT"/>
|
<result column="create_uname" property="createUname" jdbcType="VARCHAR"/>
|
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
<result column="update_uid" property="updateUid" jdbcType="BIGINT"/>
|
<result column="update_uname" property="updateUname" jdbcType="VARCHAR"/>
|
</resultMap>
|
<!--查询单条数据-->
|
<select id="queryById" resultType="com.gkhy.safePlatform.equipment.entity.SafeMaterialDO">
|
select m.id,
|
m.serial_num,
|
m.big_classify_id as bigClassifyId,
|
m.small_classify_id as smallClassifyId,
|
m.dep_id,
|
m.dep_name,
|
m.material_name,
|
m.consumable,
|
m.stock_count,
|
m.total_count,
|
m.create_time,
|
m.material_name as smallClassifyName,
|
c.material_classify_name as bigClassifyName
|
from safe_material m
|
inner join safe_material_classify c
|
on m.big_classify_id = c.id
|
where m.del_flag = 0
|
and m.id = #{id};
|
</select>
|
<!--查询所有数量-->
|
<select id="getTotalCount" resultType="java.lang.Integer">
|
select count(1) from safe_material;
|
</select>
|
<!--根据小类型统计数量-->
|
<select id="getCountBySmallClassifyId" resultType="java.lang.Integer">
|
select count(1) from safe_material where del_flag = 0 and small_classify_id = #{smallClassifyId}
|
</select>
|
<update id="deleteBatch">
|
update safe_material set del_flag = 1 where id in
|
<foreach collection="ids" item="id" separator="," open="(" close=")" >
|
#{id}
|
</foreach>
|
</update>
|
<!--条件查询-->
|
<select id="listByConditions" resultType="com.gkhy.safePlatform.equipment.entity.SafeMaterialDO">
|
select m.id,
|
m.serial_num,
|
m.big_classify_id as bigClassifyId,
|
m.small_classify_id as smallClassifyId,
|
m.dep_id,
|
m.dep_name,
|
m.material_name,
|
m.consumable,
|
m.stock_count,
|
m.total_count,
|
m.create_time,
|
m.material_name as smallClassifyName,
|
c.material_classify_name as bigClassifyName
|
from safe_material m
|
inner join safe_material_classify c
|
on m.big_classify_id = c.id
|
where m.del_flag = 0
|
<if test="query.materialName != null and query.materialName != '' ">
|
and instr(m.material_name,#{query.materialName})>0
|
</if>
|
<if test="query.bigClassifyId != null">
|
and m.big_classify_id = #{query.bigClassifyId}
|
</if>
|
<if test="query.depId != null">
|
and m.dep_id = #{query.depId}
|
</if>
|
order by m.create_time desc
|
</select>
|
<select id="checkMatrial" resultType="java.lang.Integer">
|
select count(1)
|
from safe_material
|
where del_flag = 0
|
and small_classify_id = #{smallClassifyId}
|
and dep_id = #{depId}
|
<if test="id != null">
|
and id != #{id}
|
</if>
|
</select>
|
<update id="updateCountById">
|
update safe_material
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="totalCount != null">
|
total_count = total_count + #{totalCount},
|
</if>
|
<if test="stockCount != null">
|
stock_count = stock_count + #{stockCount},
|
</if>
|
</trim>
|
where id = #{id}
|
</update>
|
<update id="updateStockCount">
|
<foreach collection="safeMaterialBOList" item="safeMaterialBO" separator=";">
|
update safe_material
|
<trim prefix="SET" suffixOverrides=",">
|
<if test="safeMaterialBO.totalCount != null">
|
total_count = total_count + #{safeMaterialBO.totalCount},
|
</if>
|
<if test="safeMaterialBO.stockCount != null">
|
stock_count = stock_count + #{safeMaterialBO.stockCount}
|
</if>
|
</trim>
|
where id = #{safeMaterialBO.id}
|
</foreach>
|
|
</update>
|
|
</mapper>
|