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.

175 lines
9.3 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.os.mes.base.mapper.BaseDeviceLedgerMapper">
<resultMap type="BaseDeviceLedger" id="BaseDeviceLedgerResult">
<result property="objId" column="obj_id"/>
<result property="deviceCode" column="device_code"/>
<result property="deviceName" column="device_name"/>
<result property="deviceModel" column="device_model"/>
<result property="deviceType" column="device_type"/>
<result property="deviceAddress" column="device_address"/>
<result property="deviceStatus" column="device_status"/>
<result property="usedDepartment" column="used_department"/>
<result property="costCenter" column="cost_center"/>
<result property="manufacturer" column="manufacturer"/>
<result property="enableDate" column="enable_date"/>
<result property="productLineCode" column="product_line_code"/>
<result property="productLineName" column="product_line_name"/>
<result property="isFlag" column="is_flag"/>
<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="factoryCode" column="factory_code"/>
<result property="teamCode" column="team_code"/>
<result property="assetCode" column="asset_code"/>
</resultMap>
<sql id="selectBaseDeviceLedgerVo">
select bdl.obj_id,
bdl.device_code,
bdl.device_name,
bdl.device_model,
bdl.device_type,
bdl.device_address,
bdl.device_status,
bdl.used_department,
bdl.cost_center,
bdl.manufacturer,
bdl.enable_date,
bdl.product_line_code,
bpl.product_line_name,
bdl.is_flag,
bdl.create_by,
bdl.create_time,
bdl.update_by,
bdl.update_time,
bdl.factory_code,
bdl.team_code,
bdl.asset_code
from base_device_ledger bdl
left join base_product_line bpl on bpl.product_line_code = bdl.product_line_code
</sql>
<select id="selectBaseDeviceLedgerList" parameterType="BaseDeviceLedger" resultMap="BaseDeviceLedgerResult">
<include refid="selectBaseDeviceLedgerVo"/>
<where>
<if test="deviceCode != null and deviceCode != ''">and bdl.device_code = #{deviceCode}</if>
<if test="deviceName != null and deviceName != ''">and bdl.device_name like concat('%', #{deviceName}, '%')
</if>
<if test="deviceModel != null and deviceModel != ''">and bdl.device_model = #{deviceModel}</if>
<if test="deviceType != null and deviceType != ''">and bdl.device_type = #{deviceType}</if>
<if test="deviceAddress != null and deviceAddress != ''">and bdl.device_address = #{deviceAddress}</if>
<if test="deviceStatus != null and deviceStatus != ''">and bdl.device_status = #{deviceStatus}</if>
<if test="usedDepartment != null and usedDepartment != ''">and bdl.used_department = #{usedDepartment}</if>
<if test="costCenter != null and costCenter != ''">and bdl.cost_center = #{costCenter}</if>
<if test="manufacturer != null and manufacturer != ''">and bdl.manufacturer = #{manufacturer}</if>
<if test="enableDate != null ">and bdl.enable_date = #{enableDate}</if>
<if test="productLineCode != null and productLineCode != ''">and bdl.product_line_code = #{productLineCode}
</if>
<if test="isFlag != null and isFlag != ''">and bdl.is_flag = #{isFlag}</if>
<if test="factoryCode != null and factoryCode != ''">and bdl.factory_code = #{factoryCode}</if>
<if test="teamCode != null and teamCode != ''">and bdl.team_code = #{teamCode}</if>
<if test="assetCode != null and assetCode != ''">and bdl.asset_code = #{assetCode}</if>
</where>
</select>
<select id="selectBaseDeviceLedgerByObjId" parameterType="Long" resultMap="BaseDeviceLedgerResult">
<include refid="selectBaseDeviceLedgerVo"/>
where bdl.obj_id = #{objId}
</select>
<insert id="insertBaseDeviceLedger" parameterType="BaseDeviceLedger" useGeneratedKeys="true" keyProperty="objId">
insert into base_device_ledger
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceCode != null and deviceCode != ''">device_code,</if>
<if test="deviceName != null">device_name,</if>
<if test="deviceModel != null">device_model,</if>
<if test="deviceType != null">device_type,</if>
<if test="deviceAddress != null">device_address,</if>
<if test="deviceStatus != null">device_status,</if>
<if test="usedDepartment != null">used_department,</if>
<if test="costCenter != null">cost_center,</if>
<if test="manufacturer != null">manufacturer,</if>
<if test="enableDate != null">enable_date,</if>
<if test="productLineCode != null">product_line_code,</if>
<if test="isFlag != null">is_flag,</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="factoryCode != null">factory_code,</if>
<if test="teamCode != null">team_code,</if>
<if test="assetCode != null">asset_code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deviceCode != null and deviceCode != ''">#{deviceCode},</if>
<if test="deviceName != null">#{deviceName},</if>
<if test="deviceModel != null">#{deviceModel},</if>
<if test="deviceType != null">#{deviceType},</if>
<if test="deviceAddress != null">#{deviceAddress},</if>
<if test="deviceStatus != null">#{deviceStatus},</if>
<if test="usedDepartment != null">#{usedDepartment},</if>
<if test="costCenter != null">#{costCenter},</if>
<if test="manufacturer != null">#{manufacturer},</if>
<if test="enableDate != null">#{enableDate},</if>
<if test="productLineCode != null">#{productLineCode},</if>
<if test="isFlag != null">#{isFlag},</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="factoryCode != null">#{factoryCode},</if>
<if test="teamCode != null">#{teamCode},</if>
<if test="assetCode != null">#{assetCode},</if>
</trim>
</insert>
<update id="updateBaseDeviceLedger" parameterType="BaseDeviceLedger">
update base_device_ledger
<trim prefix="SET" suffixOverrides=",">
<if test="deviceCode != null and deviceCode != ''">device_code = #{deviceCode},</if>
<if test="deviceName != null">device_name = #{deviceName},</if>
<if test="deviceModel != null">device_model = #{deviceModel},</if>
<if test="deviceType != null">device_type = #{deviceType},</if>
<if test="deviceAddress != null">device_address = #{deviceAddress},</if>
<if test="deviceStatus != null">device_status = #{deviceStatus},</if>
<if test="usedDepartment != null">used_department = #{usedDepartment},</if>
<if test="costCenter != null">cost_center = #{costCenter},</if>
<if test="manufacturer != null">manufacturer = #{manufacturer},</if>
<if test="enableDate != null">enable_date = #{enableDate},</if>
<if test="productLineCode != null">product_line_code = #{productLineCode},</if>
<if test="isFlag != null">is_flag = #{isFlag},</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="factoryCode != null">factory_code = #{factoryCode},</if>
<if test="teamCode != null">team_code = #{teamCode},</if>
<if test="assetCode != null">asset_code = #{assetCode},</if>
</trim>
where obj_id = #{objId}
</update>
<delete id="deleteBaseDeviceLedgerByObjId" parameterType="Long">
delete
from base_device_ledger
where obj_id = #{objId}
</delete>
<delete id="deleteBaseDeviceLedgerByObjIds" parameterType="String">
delete from base_device_ledger where obj_id in
<foreach item="objId" collection="array" open="(" separator="," close=")">
#{objId}
</foreach>
</delete>
<select id="getDeviceCode" resultType="java.lang.String">
SELECT MAX(DEVICE_CODE) DEVICE_CODE
from base_deviceledger
</select>
</mapper>