You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
178 lines
8.5 KiB
XML
178 lines
8.5 KiB
XML
<?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.op.device.mapper.EquSparepartsInOutMapper">
|
|
|
|
<resultMap type="EquSparepartsInOut" id="EquSparepartsInOutResult">
|
|
<result property="id" column="id"/>
|
|
<result property="inOutType" column="in_out_type"/>
|
|
<result property="orderNo" column="order_no"/>
|
|
<result property="spareCode" column="spare_code"/>
|
|
<result property="spareName" column="spare_name"/>
|
|
<result property="amount" column="amount"/>
|
|
<result property="attr1" column="attr1"/>
|
|
<result property="attr2" column="attr2"/>
|
|
<result property="attr3" column="attr3"/>
|
|
<result property="createBy" column="create_by"/>
|
|
<result property="createBy" column="create_by"/>
|
|
<result property="createTime" column="create_time"/>
|
|
<result property="updateBy" column="update_by"/>
|
|
<result property="updateTime" column="update_time"/>
|
|
<result property="delFlag" column="del_flag"/>
|
|
<result property="factoryCode" column="factory_code"/>
|
|
<result property="nickName" column="nick_name" />
|
|
<result property="unitPrice" column="unit_price"/>
|
|
<result property="allPrice" column="allPrice"/>
|
|
</resultMap>
|
|
|
|
<sql id="selectEquSparepartsInOutVo">
|
|
select id, in_out_type, order_no,spare_code, spare_name ,amount, attr1, attr2, attr3, create_by, create_time, update_by, update_time, del_flag, factory_code,storage_id from equ_spareparts_in_out
|
|
</sql>
|
|
|
|
<select id="selectEquSparepartsInOutList" parameterType="EquSparepartsInOut" resultMap="EquSparepartsInOutResult">
|
|
SELECT
|
|
esio.id,
|
|
esio.in_out_type,
|
|
esio.order_no,
|
|
esio.spare_code,
|
|
esio.spare_name,
|
|
esio.amount,
|
|
esio.attr1,
|
|
esio.attr2,
|
|
esio.attr3,
|
|
esio.create_by,
|
|
esio.create_time,
|
|
esio.update_by,
|
|
esio.update_time,
|
|
esio.del_flag,
|
|
esio.factory_code,
|
|
esio.storage_id,
|
|
su.nick_name,
|
|
esl.unit_price,
|
|
(esl.unit_price * esio.amount) allPrice
|
|
FROM equ_spareparts_in_out esio
|
|
LEFT JOIN lanju_op_cloud.dbo.sys_user su ON esio.create_by = su.user_name
|
|
LEFT JOIN equ_spareparts_ledger esl ON esio.spare_code = esl.material_code AND esl.del_flag = 0
|
|
<where>
|
|
<if test="inOutType != null and inOutType != ''">and in_out_type = #{inOutType}</if>
|
|
<if test="orderNo != null and orderNo != ''">and order_no = #{orderNo}</if>
|
|
<if test="spareCode != null and spareCode != ''">and spare_code = #{spareCode}</if>
|
|
<if test="spareName != null and spareName != ''">and spare_name = #{spareName}</if>
|
|
<if test="amount != null ">and amount = #{amount}</if>
|
|
<if test="attr1 != null and attr1 != ''">and attr1 = #{attr1}</if>
|
|
<if test="attr2 != null and attr2 != ''">and attr2 = #{attr2}</if>
|
|
<if test="attr3 != null and attr3 != ''">and attr3 = #{attr3}</if>
|
|
<if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''">
|
|
AND esio.create_time between #{params.beginTime} and #{params.endTime}
|
|
</if>
|
|
<if test="updateBy != null and updateBy != ''">and esio.update_by = #{updateBy}</if>
|
|
<if test="updateTime != null ">and esio.update_time = #{updateTime}</if>
|
|
and esio.del_flag = '0'
|
|
<if test="factoryCode != null and factoryCode != ''">and factory_code = #{factoryCode}</if>
|
|
</where>
|
|
order by esio.create_time desc
|
|
</select>
|
|
|
|
<select id="selectEquSparepartsInOutById" parameterType="String" resultMap="EquSparepartsInOutResult">
|
|
<include refid="selectEquSparepartsInOutVo"/>
|
|
where id = #{id}
|
|
and del_flag = '0'
|
|
</select>
|
|
|
|
<insert id="insertEquSparepartsInOut" parameterType="EquSparepartsInOut">
|
|
insert into equ_spareparts_in_out
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="id != null">id,</if>
|
|
<if test="inOutType != null">in_out_type,</if>
|
|
<if test="orderNo != null">order_no,</if>
|
|
<if test="spareCode != null">spare_code,</if>
|
|
<if test="spareName != null">spare_name,</if>
|
|
amount,
|
|
<if test="attr1 != null">attr11,</if>
|
|
<if test="attr2 != null">attr12,</if>
|
|
<if test="attr3 != null">attr13,</if>
|
|
<if test="createBy != null">create_by,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="updateBy != null">update_by,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
<if test="delFlag != null">del_flag,</if>
|
|
<if test="factoryCode != null">factory_code,</if>
|
|
<if test="storageId != null and storageId != ''">storage_id,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="id != null">#{id},</if>
|
|
<if test="inOutType != null">#{inOutType},</if>
|
|
<if test="orderNo != null">#{orderNo},</if>
|
|
<if test="spareCode != null">#{spareCode},</if>
|
|
<if test="spareName != null">#{spareName},</if>
|
|
#{amount},
|
|
<if test="attr1 != null">#{attr1},</if>
|
|
<if test="attr2 != null">#{attr2},</if>
|
|
<if test="attr3 != null">#{attr3},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
<if test="delFlag != null">#{delFlag},</if>
|
|
<if test="factoryCode != null">#{factoryCode},</if>
|
|
<if test="storageId != null and storageId != ''">#{storageId},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateEquSparepartsInOut" parameterType="EquSparepartsInOut">
|
|
update equ_spareparts_in_out
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="inOutType != null">in_out_type = #{inOutType},</if>
|
|
<if test="orderNo != null">order_no = #{orderNo},</if>
|
|
<if test="spareCode != null">spare_code = #{spareCode},</if>
|
|
<if test="spareName != null">spare_name = #{spareName},</if>
|
|
<if test="amount != null">amount = #{amount},</if>
|
|
<if test="attr1 != null">attr1 = #{attr1},</if>
|
|
<if test="attr2 != null">attr2 = #{attr2},</if>
|
|
<if test="attr3 != null">attr3 = #{attr3},</if>
|
|
<if test="createBy != null">create_by = #{createBy},</if>
|
|
<if test="createTime != null">create_time = #{createTime},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
|
<if test="factoryCode != null">factory_code = #{factoryCode},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<delete id="deleteEquSparepartsInOutById" parameterType="String">
|
|
update equ_spareparts_in_out
|
|
set del_flag = '1'
|
|
where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteEquSparepartsInOutByIds" parameterType="String">
|
|
update equ_spareparts_in_out
|
|
set del_flag = '1'
|
|
where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<select id="selectSerialNumber" resultType="java.lang.Integer">
|
|
SELECT COUNT(id)+1 AS serialNum
|
|
FROM equ_spareparts_in_out
|
|
WHERE CONVERT(date, GETDATE()) = CONVERT(date,create_time)
|
|
</select>
|
|
<select id="selectEquSparepartsInOutListSum" resultType="com.op.device.domain.EquSparepartsInOut" parameterType="EquSparepartsInOut">
|
|
SELECT
|
|
CAST(SUM(CASE WHEN in_out_type = 'type_in' THEN amount ELSE 0 END) AS INT) AS InAmount,
|
|
CAST(SUM(CASE WHEN in_out_type = 'type_out' THEN amount ELSE 0 END) AS INT) AS OutAmount
|
|
FROM
|
|
equ_spareparts_in_out
|
|
WHERE
|
|
spare_code = #{spareCode}
|
|
<if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''">
|
|
AND create_time between #{params.beginTime} and #{params.endTime}
|
|
</if>
|
|
AND del_flag = '0'
|
|
</select>
|
|
</mapper>
|