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.

134 lines
7.8 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.hw.dms.mapper.DmsBaseDeviceLedgerMapper">
<resultMap type="DmsBaseDeviceLedger" id="DmsBaseDeviceLedgerResult">
<result property="deviceId" column="device_id" />
<result property="deviceCode" column="device_code" />
<result property="deviceName" column="device_name" />
<result property="stationId" column="station_id" />
<result property="assetNumber" column="asset_number" />
<result property="deviceLocation" column="device_location" />
<result property="deviceTypeId" column="device_type_id" />
<result property="deviceSpec" column="device_spec" />
<result property="supplierId" column="supplier_id" />
<result property="deviceStatus" column="device_status" />
<result property="isFlag" column="is_flag" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectDmsBaseDeviceLedgerVo">
select device_id, device_code, device_name, station_id, asset_number, device_location, device_type_id, device_spec, supplier_id, device_status, is_flag, remark, create_by, create_time, update_by, update_time from dms_base_device_ledger
</sql>
<select id="selectDmsBaseDeviceLedgerList" parameterType="DmsBaseDeviceLedger" resultMap="DmsBaseDeviceLedgerResult">
select a.device_id, a.device_code, a.device_name, a.station_id, a.asset_number, a.device_location, a.device_type_id, a.device_spec, a.supplier_id, a.device_status, a.is_flag, a.remark, a.create_by, a.create_time, a.update_by, a.update_time
from dms_base_device_ledger a
left join dms_base_device_suplier b on a.supplier_id = b.supplier_id
<where>
<if test="deviceCode != null and deviceCode != ''"> and a.device_code = #{deviceCode}</if>
<if test="deviceName != null and deviceName != ''"> and a.device_name like concat('%', #{deviceName}, '%')</if>
<if test="stationId != null and stationId != ''"> and a.station_id = #{stationId}</if>
<if test="assetNumber != null and assetNumber != ''"> and a.asset_number = #{assetNumber}</if>
<if test="deviceLocation != null and deviceLocation != ''"> and a.device_location = #{deviceLocation}</if>
<if test="deviceTypeId != null and deviceTypeId != ''"> and a.device_type_id = #{deviceTypeId}</if>
<if test="deviceSpec != null and deviceSpec != ''"> and a.device_spec = #{deviceSpec}</if>
<if test="supplierId != null and supplierId != ''"> and a.supplier_id = #{supplierId}</if>
<if test="deviceStatus != null "> and a.device_status = #{deviceStatus}</if>
<if test="isFlag != null "> and a.is_flag = #{isFlag}</if>
<if test="suplierName != null "> and b.suplier_name like concat('%', #{suplierName},'%')</if>
</where>
</select>
<select id="selectDmsBaseDeviceLedgerByDeviceId" parameterType="Long" resultMap="DmsBaseDeviceLedgerResult">
<include refid="selectDmsBaseDeviceLedgerVo"/>
where device_id = #{deviceId}
</select>
<insert id="insertDmsBaseDeviceLedger" parameterType="DmsBaseDeviceLedger" useGeneratedKeys="true" keyProperty="deviceId">
insert into dms_base_device_ledger
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceCode != null and deviceCode != ''">device_code,</if>
<if test="deviceName != null and deviceName != ''">device_name,</if>
<if test="stationId != null">station_id,</if>
<if test="assetNumber != null">asset_number,</if>
<if test="deviceLocation != null">device_location,</if>
<if test="deviceTypeId != null and deviceTypeId != ''">device_type_id,</if>
<if test="deviceSpec != null">device_spec,</if>
<if test="supplierId != null">supplier_id,</if>
<if test="deviceStatus != null">device_status,</if>
<if test="isFlag != null">is_flag,</if>
<if test="remark != null">remark,</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>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceCode != null and deviceCode != ''">#{deviceCode},</if>
<if test="deviceName != null and deviceName != ''">#{deviceName},</if>
<if test="stationId != null">#{stationId},</if>
<if test="assetNumber != null">#{assetNumber},</if>
<if test="deviceLocation != null">#{deviceLocation},</if>
<if test="deviceTypeId != null and deviceTypeId != ''">#{deviceTypeId},</if>
<if test="deviceSpec != null">#{deviceSpec},</if>
<if test="supplierId != null">#{supplierId},</if>
<if test="deviceStatus != null">#{deviceStatus},</if>
<if test="isFlag != null">#{isFlag},</if>
<if test="remark != null">#{remark},</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>
</trim>
</insert>
<update id="updateDmsBaseDeviceLedger" parameterType="DmsBaseDeviceLedger">
update dms_base_device_ledger
<trim prefix="SET" suffixOverrides=",">
<if test="deviceCode != null and deviceCode != ''">device_code = #{deviceCode},</if>
<if test="deviceName != null and deviceName != ''">device_name = #{deviceName},</if>
<if test="stationId != null">station_id = #{stationId},</if>
<if test="assetNumber != null">asset_number = #{assetNumber},</if>
<if test="deviceLocation != null">device_location = #{deviceLocation},</if>
<if test="deviceTypeId != null and deviceTypeId != ''">device_type_id = #{deviceTypeId},</if>
<if test="deviceSpec != null">device_spec = #{deviceSpec},</if>
<if test="supplierId != null">supplier_id = #{supplierId},</if>
<if test="deviceStatus != null">device_status = #{deviceStatus},</if>
<if test="isFlag != null">is_flag = #{isFlag},</if>
<if test="remark != null">remark = #{remark},</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>
</trim>
where device_id = #{deviceId}
</update>
<delete id="deleteDmsBaseDeviceLedgerByDeviceId" parameterType="Long">
delete from dms_base_device_ledger where device_id = #{deviceId}
</delete>
<delete id="deleteDmsBaseDeviceLedgerByDeviceIds" parameterType="String">
delete from dms_base_device_ledger where device_id in
<foreach item="deviceId" collection="array" open="(" separator="," close=")">
#{deviceId}
</foreach>
</delete>
<select id="selectDmsBaseDeviceLedgerByDeviceCode" parameterType="String" resultMap="DmsBaseDeviceLedgerResult">
<include refid="selectDmsBaseDeviceLedgerVo"/>
where device_code = #{deviceCode}
</select>
</mapper>