<?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.lzbi.draft.mapper.DcBusiBillModelMasterMapper" >
<resultMap type= "com.lzbi.draft.domain.DcBusiBillModelMaster" id= "DcBusiBillModelMasterResult" >
<result property= "tenantId" column= "tenant_id" />
<result property= "revision" column= "revision" />
<result property= "createdBy" column= "created_by" />
<result property= "createdTime" column= "created_time" />
<result property= "updatedBy" column= "updated_by" />
<result property= "updatedTime" column= "updated_time" />
<result property= "deleteBy" column= "delete_by" />
<result property= "deleteTime" column= "delete_time" />
<result property= "deptId" column= "dept_id" />
<result property= "roleId" column= "role_id" />
<result property= "billModelNo" column= "bill_model_no" />
<result property= "billModelName" column= "bill_model_name" />
<result property= "fieldCode" column= "field_code" />
<result property= "companyName" column= "company_name" />
<result property= "companyId" column= "company_id" />
<result property= "billModelPoint" column= "bill_model_point" />
<result property= "orgName" column= "org_name" />
<result property= "orgId" column= "org_id" />
<result property= "id" column= "id" />
<result property= "dataState" column= "data_state" />
<result property= "useState" column= "use_state" />
<result property= "fieldName" column= "field_name" />
<result property= "modelType" column= "model_type" />
</resultMap>
<resultMap id= "DcBusiBillModelMasterDcBusiBillModelSubResult" type= "DcBusiBillModelMaster" extends= "DcBusiBillModelMasterResult" >
<collection property= "dcBusiBillModelSubList" notNullColumn= "sub_id" javaType= "java.util.List" resultMap= "DcBusiBillModelSubResult" />
</resultMap>
<resultMap type= "DcBusiBillModelSub" id= "DcBusiBillModelSubResult" >
<result property= "billModelNo" column= "sub_bill_model_no" />
<result property= "assetCode" column= "sub_asset_code" />
<result property= "assetName" column= "sub_asset_name" />
<result property= "assetUnitCode" column= "sub_asset_unit_code" />
<result property= "assetUnitName" column= "sub_asset_unit_name" />
<result property= "assetUnitType" column= "sub_asset_unit_type" />
<result property= "id" column= "sub_id" />
<result property= "assetId" column= "sub_asset_id" />
<result property= "assetUnitAlialsName" column= "sub_asset_unit_alials_name" />
<result property= "aUnit" column= "sub_a_unit" />
</resultMap>
<sql id= "selectDcBusiBillModelMasterVo" >
select tenant_id, revision, created_by, created_time, updated_by, updated_time, delete_by, delete_time, dept_id, role_id, bill_model_no, bill_model_name, field_code, company_name, company_id, bill_model_point, org_name, org_id, id, data_state, use_state, field_name,model_type from dc_busi_bill_model_master
</sql>
<select id= "selectDcBusiBillModelMasterList" parameterType= "DcBusiBillModelMaster" resultMap= "DcBusiBillModelMasterResult" >
<include refid= "selectDcBusiBillModelMasterVo" />
<where >
<if test= "deptId != null and deptId != ''" > and dept_id = #{deptId}</if>
<if test= "roleId != null " > and role_id = #{roleId}</if>
<if test= "billModelNo != null and billModelNo != ''" > and bill_model_no = #{billModelNo}</if>
<if test= "billModelName != null and billModelName != ''" > and bill_model_name like concat('%', #{billModelName}, '%')</if>
<if test= "fieldCode != null and fieldCode != ''" > and field_code = #{fieldCode}</if>
<if test= "companyName != null and companyName != ''" > and company_name like concat('%', #{companyName}, '%')</if>
<if test= "companyId != null " > and company_id = #{companyId}</if>
<if test= "billModelPoint != null and billModelPoint != ''" > and bill_model_point = #{billModelPoint}</if>
<if test= "orgName != null and orgName != ''" > and org_name like concat('%', #{orgName}, '%')</if>
<if test= "orgId != null " > and org_id = #{orgId}</if>
<if test= "dataState != null and dataState != ''" > and data_state = #{dataState}</if>
<if test= "useState != null and useState != ''" > and use_state = #{useState}</if>
<if test= "fieldName != null and fieldName != ''" > and field_name like concat('%', #{fieldName}, '%')</if>
<if test= "modelType != null and modelType != ''" > and model_type =#{modelType}</if>
</where>
</select>
<select id= "selectDcBusiBillModelMasterById" parameterType= "Long" resultMap= "DcBusiBillModelMasterDcBusiBillModelSubResult" >
select a.tenant_id, a.revision, a.created_by, a.created_time, a.updated_by, a.updated_time, a.delete_by, a.delete_time, a.dept_id, a.role_id, a.bill_model_no, a.bill_model_name, a.field_code, a.company_name, a.company_id, a.bill_model_point, a.org_name, a.org_id, a.id, a.data_state, a.use_state, a.field_name,a.model_type,
b.bill_model_no as sub_bill_model_no, b.asset_code as sub_asset_code, b.asset_name as sub_asset_name, b.asset_unit_code as sub_asset_unit_code, b.asset_unit_name as sub_asset_unit_name, b.asset_unit_type as sub_asset_unit_type, b.id as sub_id, b.asset_id as sub_asset_id,asset_unit_alials_name as sub_asset_unit_alials_name,a_unit as sub_a_unit
from dc_busi_bill_model_master a
left join dc_busi_bill_model_sub b on b.bill_model_no = a.bill_model_no
where a.id = #{id}
</select>
<insert id= "insertDcBusiBillModelMaster" parameterType= "DcBusiBillModelMaster" useGeneratedKeys= "true" keyProperty= "id" >
insert into dc_busi_bill_model_master
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "tenantId != null" > tenant_id,</if>
<if test= "revision != null" > revision,</if>
<if test= "createdBy != null" > created_by,</if>
<if test= "createdTime != null" > created_time,</if>
<if test= "updatedBy != null" > updated_by,</if>
<if test= "updatedTime != null" > updated_time,</if>
<if test= "deleteBy != null" > delete_by,</if>
<if test= "deleteTime != null" > delete_time,</if>
<if test= "deptId != null" > dept_id,</if>
<if test= "roleId != null" > role_id,</if>
<if test= "billModelNo != null" > bill_model_no,</if>
<if test= "billModelName != null" > bill_model_name,</if>
<if test= "fieldCode != null" > field_code,</if>
<if test= "companyName != null" > company_name,</if>
<if test= "companyId != null" > company_id,</if>
<if test= "billModelPoint != null" > bill_model_point,</if>
<if test= "orgName != null" > org_name,</if>
<if test= "orgId != null" > org_id,</if>
<if test= "dataState != null" > data_state,</if>
<if test= "useState != null" > use_state,</if>
<if test= "fieldName != null" > field_name,</if>
<if test= "modelType != null " > model_type,</if>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "tenantId != null" > #{tenantId},</if>
<if test= "revision != null" > #{revision},</if>
<if test= "createdBy != null" > #{createdBy},</if>
<if test= "createdTime != null" > #{createdTime},</if>
<if test= "updatedBy != null" > #{updatedBy},</if>
<if test= "updatedTime != null" > #{updatedTime},</if>
<if test= "deleteBy != null" > #{deleteBy},</if>
<if test= "deleteTime != null" > #{deleteTime},</if>
<if test= "deptId != null" > #{deptId},</if>
<if test= "roleId != null" > #{roleId},</if>
<if test= "billModelNo != null" > #{billModelNo},</if>
<if test= "billModelName != null" > #{billModelName},</if>
<if test= "fieldCode != null" > #{fieldCode},</if>
<if test= "companyName != null" > #{companyName},</if>
<if test= "companyId != null" > #{companyId},</if>
<if test= "billModelPoint != null" > #{billModelPoint},</if>
<if test= "orgName != null" > #{orgName},</if>
<if test= "orgId != null" > #{orgId},</if>
<if test= "dataState != null" > #{dataState},</if>
<if test= "useState != null" > #{useState},</if>
<if test= "fieldName != null" > #{fieldName},</if>
<if test= "modelType != null " > #{modelType},</if>
</trim>
</insert>
<update id= "updateDcBusiBillModelMaster" parameterType= "DcBusiBillModelMaster" >
update dc_busi_bill_model_master
<trim prefix= "SET" suffixOverrides= "," >
<if test= "tenantId != null" > tenant_id = #{tenantId},</if>
<if test= "revision != null" > revision = #{revision},</if>
<if test= "createdBy != null" > created_by = #{createdBy},</if>
<if test= "createdTime != null" > created_time = #{createdTime},</if>
<if test= "updatedBy != null" > updated_by = #{updatedBy},</if>
<if test= "updatedTime != null" > updated_time = #{updatedTime},</if>
<if test= "deleteBy != null" > delete_by = #{deleteBy},</if>
<if test= "deleteTime != null" > delete_time = #{deleteTime},</if>
<if test= "deptId != null" > dept_id = #{deptId},</if>
<if test= "roleId != null" > role_id = #{roleId},</if>
<if test= "billModelNo != null" > bill_model_no = #{billModelNo},</if>
<if test= "billModelName != null" > bill_model_name = #{billModelName},</if>
<if test= "fieldCode != null" > field_code = #{fieldCode},</if>
<if test= "companyName != null" > company_name = #{companyName},</if>
<if test= "companyId != null" > company_id = #{companyId},</if>
<if test= "billModelPoint != null" > bill_model_point = #{billModelPoint},</if>
<if test= "orgName != null" > org_name = #{orgName},</if>
<if test= "orgId != null" > org_id = #{orgId},</if>
<if test= "dataState != null" > data_state = #{dataState},</if>
<if test= "useState != null" > use_state = #{useState},</if>
<if test= "fieldName != null" > field_name = #{fieldName},</if>
<if test= "modelType != null" > model_type =#{modelType},</if>
</trim>
where id = #{id}
</update>
<delete id= "deleteDcBusiBillModelMasterById" parameterType= "Long" >
delete from dc_busi_bill_model_master where id = #{id}
</delete>
<delete id= "deleteDcBusiBillModelMasterByNo" parameterType= "String" >
delete from dc_busi_bill_model_master where bill_model_no = #{billNo}
</delete>
<delete id= "deleteDcBusiBillModelMasterByIds" parameterType= "String" >
delete from dc_busi_bill_model_master where id in
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</delete>
<delete id= "deleteDcBusiBillModelSubByBillModelNos" parameterType= "String" >
delete from dc_busi_bill_model_sub where bill_model_no in
<foreach item= "billModelNo" collection= "array" open= "(" separator= "," close= ")" >
#{billModelNo}
</foreach>
</delete>
<delete id= "deleteDcBusiBillModelSubByBillModelNo" parameterType= "String" >
delete from dc_busi_bill_model_sub where bill_model_no = #{billModelNo}
</delete>
<insert id= "batchDcBusiBillModelSub" >
insert into dc_busi_bill_model_sub( bill_model_no, asset_code, asset_name, asset_unit_code, asset_unit_name, asset_unit_type, id, asset_id,a_unit,asset_unit_alials_name) values
<foreach item= "item" index= "index" collection= "list" separator= "," >
( #{item.billModelNo}, #{item.assetCode}, #{item.assetName}, #{item.assetUnitCode}, #{item.assetUnitName}, #{item.assetUnitType}, #{item.id}, #{item.assetId},#{item.aUnit},#{item.assetUnitAlialsName})
</foreach>
</insert>
</mapper>