<?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.thhy.mobile.modules.biz.steelstock.mapper.SteelStockMapper">
|
|
<!-- 通用查询结果列 -->
|
<sql id="Base_Column_List">
|
t.steel_stock_id as steelStockId,
|
t.block_id as blockId,
|
t.create_time as createTime,
|
t.pro_id as proId,
|
t.reinforcement_id as reinforcementId,
|
t.size_id as sizeId,
|
t.stock as stock,
|
t.update_time as updateTime
|
</sql>
|
|
<sql id="condition_query">
|
<where>
|
<trim suffixOverrides=" AND ">
|
<if test="blockId!=null and blockId!=''">
|
t.block_id = #{blockId} AND
|
</if>
|
<if test="createTime!=null">
|
t.create_time = #{createTime} AND
|
</if>
|
<if test="proId!=null and proId!=''">
|
t.pro_id = #{proId} AND
|
</if>
|
<if test="reinforcementId!=null and reinforcementId!=''">
|
t.reinforcement_id = #{reinforcementId} AND
|
</if>
|
<if test="sizeId!=null and sizeId!=''">
|
t.size_id = #{sizeId} AND
|
</if>
|
<if test="stock!=null">
|
t.stock = #{stock} AND
|
</if>
|
<if test="updateTime!=null">
|
t.update_time = #{updateTime} AND
|
</if>
|
</trim>
|
</where>
|
</sql>
|
|
<select id="queryById" resultType="com.thhy.mobile.modules.biz.steelstock.entity.SteelStock">
|
select <include refid="Base_Column_List" />
|
from t_steel_stock t
|
where t.steel_stock_id=#{steelStockId}
|
</select>
|
|
<select id="queryVersionById" resultType="integer">
|
select version from t_steel_stock
|
where steel_stock_id=#{steelStockId}
|
</select>
|
|
<!--查询列表-->
|
<select id="findList" resultType="com.thhy.mobile.modules.biz.steelstock.entity.SteelStock">
|
SELECT
|
<include refid="Base_Column_List" />
|
from t_steel_stock t
|
<include refid="condition_query" />
|
</select>
|
|
<!--查询列表-->
|
<select id="findAll" resultType="com.thhy.mobile.modules.biz.steelstock.entity.SteelStock">
|
SELECT
|
<include refid="Base_Column_List" />
|
from t_steel_stock t
|
</select>
|
|
<!--插入操作-->
|
<insert id="insert">
|
insert into t_steel_stock
|
<trim prefix="(" suffix=")" suffixOverrides="," >
|
<if test="blockId != null">
|
block_id,
|
</if>
|
<if test="createTime != null">
|
create_time,
|
</if>
|
<if test="proId != null">
|
pro_id,
|
</if>
|
<if test="reinforcementId != null">
|
reinforcement_id,
|
</if>
|
<if test="sizeId != null">
|
size_id,
|
</if>
|
<if test="steelStockId != null">
|
steel_stock_id,
|
</if>
|
<if test="stock != null">
|
stock,
|
</if>
|
<if test="updateTime != null">
|
update_time,
|
</if>
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides="," >
|
<if test="blockId != null">
|
#{blockId},
|
</if>
|
<if test="createTime != null">
|
#{createTime},
|
</if>
|
<if test="proId != null">
|
#{proId},
|
</if>
|
<if test="reinforcementId != null">
|
#{reinforcementId},
|
</if>
|
<if test="sizeId != null">
|
#{sizeId},
|
</if>
|
<if test="steelStockId != null">
|
#{steelStockId},
|
</if>
|
<if test="stock != null">
|
#{stock},
|
</if>
|
<if test="updateTime != null">
|
#{updateTime},
|
</if>
|
</trim>
|
</insert>
|
|
|
<!--更新操作-->
|
<update id="update">
|
update t_steel_stock
|
<set>
|
<if test="blockId != null">
|
block_id=#{blockId},
|
</if>
|
<if test="createTime != null">
|
create_time=#{createTime},
|
</if>
|
<if test="proId != null">
|
pro_id=#{proId},
|
</if>
|
<if test="reinforcementId != null">
|
reinforcement_id=#{reinforcementId},
|
</if>
|
<if test="sizeId != null">
|
size_id=#{sizeId},
|
</if>
|
<if test="stock != null">
|
stock=#{stock},
|
</if>
|
<if test="updateTime != null">
|
update_time=#{updateTime},
|
</if>
|
</set>
|
where steel_stock_id=#{steelStockId}
|
</update>
|
|
<!--逻辑删除-->
|
<update id="deletelogic">
|
update t_steel_stock
|
SET is_use = 0
|
where steel_stock_id=#{steelStockId}
|
</update>
|
|
<!--根据ID删除-->
|
<delete id="deleteById">
|
delete from t_steel_stock
|
where steel_stock_id=#{steelStockId}
|
</delete>
|
|
<select id="countStockByPSRB" resultType="int">
|
select count(steel_stock_id) from t_steel_stock where pro_id = #{proId} and size_id = #{sizeId}
|
and reinforcement_id = #{reinforcementId} and block_id =#{blockId}
|
</select>
|
|
<update id="updatePlusStock">
|
update t_steel_stock set stock = stock+1,update_time = sysdate() where pro_id = #{proId} and size_id = #{sizeId}
|
and reinforcement_id = #{reinforcementId} and block_id =#{blockId}
|
</update>
|
|
<update id="updateMinusStock">
|
update t_steel_stock set stock = stock-1,update_time = sysdate() where pro_id = #{proId} and size_id = #{sizeId}
|
and reinforcement_id = #{reinforcementId} and block_id =#{blockId}
|
</update>
|
|
<select id="querySteelStock" resultType="com.thhy.mobile.modules.biz.steelstock.entity.SteelStockListVo">
|
select
|
t.pro_id as proId,
|
sp.pro_name as proName,
|
t.reinforcement_id as reinforcementId,
|
sd1.dict_name as reinforcementName,
|
sd.dict_name as sizeName,
|
t.size_id as sizeId,
|
sd2.dict_name as blockNumName,
|
t.stock as stock
|
from t_steel_stock t
|
left join sys_project sp on t.pro_id = sp.pro_id
|
left join sys_dict sd on sd.dict_id = t.size_id
|
left join sys_dict sd1 on sd1.dict_id = t.reinforcement_id
|
left join sys_dict sd2 on sd2.dict_id = t.block_id
|
<where>
|
<trim suffixOverrides=" AND ">
|
sp.company_id = #{companyId} AND
|
<if test="blockId!=null and blockId!=''">
|
t.block_id = #{blockId} AND
|
</if>
|
<if test="proId!=null and proId!=''">
|
t.pro_id = #{proId} AND
|
</if>
|
<if test="reinforcementId!=null and reinforcementId!=''">
|
t.reinforcement_id = #{reinforcementId} AND
|
</if>
|
<if test="sizeId!=null and sizeId!=''">
|
t.size_id = #{sizeId} AND
|
</if>
|
</trim>
|
</where>
|
</select>
|
|
|
|
<!--这里是钢筋理论耗量的查询-->
|
<select id="queryByPSRB" resultType="com.thhy.mobile.modules.biz.steelstock.entity.SteelConsume">
|
select ss.steel_id as steelId,ss.steel_name as steelName,ss.steel_model as steelModel,tsn.need_num as needNum,tsn.coefficient
|
from t_steel_need tsn
|
left join t_steel_consumption tsc on tsc.consumption_id = tsn.consumption_id
|
left join sys_steel ss on ss.steel_id = tsn.steel_id
|
where tsc.pro_id = #{proId} and tsc.size_id = #{sizeId}
|
and tsc.reinforcement_id = #{reinforcementId} and tsc.block_id = #{blockId}
|
</select>
|
|
<!--更新钢筋库存-->
|
<update id="updateMinusSteelStock">
|
update sys_steel set stock = (stock-(#{needNum}*#{coefficient})) where steel_id = #{steelId}
|
</update>
|
<!--更新钢筋库存,这里的needNum 当参数用,是减去的库存-->
|
<update id="updatePlusSteelStock">
|
update sys_steel set stock = (stock+#{needNum}) where steel_id = #{steelId}
|
</update>
|
|
<insert id="insertSteelStockRecord">
|
insert into t_steel_stock_record
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<if test="recordId !=null and recordId !=''">
|
record_id,
|
</if>
|
<if test="steelRecordId !=null and steelRecordId !=''">
|
check_record_id,
|
</if>
|
<if test="modCheckId !=null and modCheckId !=''">
|
mod_check_id,
|
</if>
|
<if test="proId !=null and proId !=''">
|
pro_id,
|
</if>
|
<if test="sizeId !=null and sizeId !=''">
|
size_id,
|
</if>
|
<if test="reinforcementId !=null and reinforcementId !=''">
|
reinforcement_id,
|
</if>
|
<if test="blockId !=null and blockId !=''">
|
block_id,
|
</if>
|
<if test="stock !=null and stock !=''">
|
stock,
|
</if>
|
<if test="createTime !=null and createTime !=''">
|
create_time,
|
</if>
|
<if test="type !=null">
|
type,
|
</if>
|
</trim>
|
<trim prefix=" values (" suffix=")" suffixOverrides=",">
|
<if test="recordId !=null and recordId !=''">
|
#{recordId},
|
</if>
|
<if test="steelRecordId !=null and steelRecordId !=''">
|
#{steelRecordId},
|
</if>
|
<if test="modCheckId !=null and modCheckId !=''">
|
#{modCheckId},
|
</if>
|
<if test="proId !=null and proId !=''">
|
#{proId},
|
</if>
|
<if test="sizeId !=null and sizeId !=''">
|
#{sizeId},
|
</if>
|
<if test="reinforcementId !=null and reinforcementId !=''">
|
#{reinforcementId},
|
</if>
|
<if test="blockId !=null and blockId !=''">
|
#{blockId},
|
</if>
|
<if test="stock !=null and stock !=''">
|
#{stock},
|
</if>
|
<if test="createTime !=null and createTime !=''">
|
#{createTime},
|
</if>
|
<if test="type !=null">
|
#{type},
|
</if>
|
</trim>
|
</insert>
|
|
<update id="updateSteelStockRecordByCheckId">
|
update t_steel_stock_record set is_use = #{isUse} where check_record_id = #{checkRecordId}
|
</update>
|
|
</mapper>
|