INSERT INTO sc_device ( id, device_no, device_type, sys_id, site_id, building_id, loc_desc, manufacturer_id, device_status, `status`, create_by, update_by, date_create, date_update, water_meter_no, water_meter_file_no, customer_id, register_status ) VALUES ( #{waterMeter.deviceId,jdbcType=BIGINT}, #{waterMeter.deviceNo,jdbcType=VARCHAR}, #{waterMeter.deviceTypeId,jdbcType=BIGINT}, #{waterMeter.sysId,jdbcType=BIGINT}, #{waterMeter.siteId,jdbcType=BIGINT}, #{waterMeter.buildingId,jdbcType=BIGINT}, #{waterMeter.location,jdbcType=VARCHAR}, #{waterMeter.manufacturerId,jdbcType=BIGINT}, #{waterMeter.deviceStatus,jdbcType=INTEGER}, #{waterMeter.status,jdbcType=INTEGER}, #{waterMeter.createBy,jdbcType=VARCHAR}, #{waterMeter.updateBy,jdbcType=VARCHAR}, #{waterMeter.dateCreate,jdbcType=TIMESTAMP}, #{waterMeter.dateUpdate,jdbcType=TIMESTAMP}, #{waterMeter.meterNo,jdbcType=VARCHAR}, #{waterMeter.meterFileNo,jdbcType=VARCHAR}, #{waterMeter.customerId,jdbcType=INTEGER}, #{waterMeter.registerStatus,jdbcType=INTEGER} ) device_id ,water_meter_type,device_no, site_id, sys_id, building_id, province, city, region, community, customer_id, meter_no, meter_file_no, device_type_id, concentrator_id,collector_id, `location`,valve_measuring_code, reading_measuring_code,date_create d.id as device_id , wmt.parent_id as water_meter_type , d.device_no as device_no , d.site_id as site_id , d.sys_id as sys_id , d.building_id as building_id , b.province as province , b.city as city , b.region as region, b.community as community , d.customer_id as customer_id , d.water_meter_no as meter_no , d.water_meter_file_no as meter_file_no, d.device_type as device_type_id , wrd.concentrator_id as concentrator_id , wrd.collector_id as collector_id , d.loc_desc as location, wmt.valve_measuring_code as valve_measuring_code , wmt.reading_measuring_code as reading_measuring_code, d.date_create as date_create, b.`name` as building_name, c.`name` as community_name , p.name as province_name, cc.name as city_name, r.`name` as region_name, con.serial_number as concentrator_no, col.collector_no as collector_no, concat_ws('/',m.name,dt.equipment_type,dt.model) as device_type_name, d.manufacturer_id as manufacturer_id , m.`name` as manufacturer_name, cu.customer_name as customer_name, cn.channel_name as channel_name , wrd.channel_number_id as channel_number_id d.`status` = 1 and wmt.`status` = 1 and wmt.valve_measuring_code is not null and wmt.reading_measuring_code is not null and wmt.parent_id in (1,2) SELECT FROM WHERE sc_w_meter_type wmt left join sc_device d on (d.`status` = 1 and wmt.device_type_id = d.device_type) left join sc_water_related_device wrd on (wrd.device_id =d.id) left join sc_building b on (d.building_id = b.id) LEFT JOIN sc_community c on (b.community = c.id ) LEFT JOIN sc_area p on (c.province = p.id) LEFT JOIN sc_area cc on (c.city = cc.id) LEFT JOIN sc_area r on (c.region =r.id) LEFT JOIN sc_concentrator con on (con.id = wrd.concentrator_id) LEFT JOIN sc_collector col on (col.id = wrd.collector_id) left join sc_device_type dt on (d.device_type = dt.id) left join sc_device_manufacturer m on (d.manufacturer_id = m.id) left join sc_customer cu on (cu.id = d.customer_id) left join sc_channel_number cn on(cn.id = wrd.channel_number_id)