id,
read_date,
site_id,
sys_id,
province,
city,
region,
community,
building_id,
location,
device_type_id,
device_id,
device_no,
meter_no,
meter_file_no,
read_time,
read_status,
read_data,
last_valid,
last_cost,
status,
date_create,
date_update,
create_by,
update_by
INSERT INTO sc_meter_read_record (
id,
read_date,
site_id,
sys_id,
province,
city,
region,
community,
building_id,
location,
device_type_id,
device_id,
device_no,
meter_no,
meter_file_no,
read_time,
read_status,
read_data,
last_valid,
last_cost,
status,
date_create,
date_update,
create_by,
update_by
) VALUES (
#{meterReadRecord.id,jdbcType=BIGINT},
#{meterReadRecord.readDate,jdbcType=INTEGER},
#{meterReadRecord.siteId,jdbcType=INTEGER},
#{meterReadRecord.sysId,jdbcType=INTEGER},
#{meterReadRecord.province,jdbcType=INTEGER},
#{meterReadRecord.city,jdbcType=INTEGER},
#{meterReadRecord.region,jdbcType=INTEGER},
#{meterReadRecord.communityId,jdbcType=VARCHAR},
#{meterReadRecord.buildingId,jdbcType=INTEGER},
#{meterReadRecord.location,jdbcType=VARCHAR},
#{meterReadRecord.deviceTypeId,jdbcType=INTEGER},
#{meterReadRecord.deviceId,jdbcType=BIGINT},
#{meterReadRecord.deviceNo,jdbcType=VARCHAR},
#{meterReadRecord.meterNo,jdbcType=VARCHAR},
#{meterReadRecord.meterFileNo,jdbcType=VARCHAR},
#{meterReadRecord.readTime,jdbcType=TIMESTAMP},
#{meterReadRecord.readStatus,jdbcType=VARCHAR},
#{meterReadRecord.readData,jdbcType=VARCHAR},
#{meterReadRecord.lastValid,jdbcType=VARCHAR},
#{meterReadRecord.lastCost,jdbcType=DECIMAL},
#{meterReadRecord.status,jdbcType=INTEGER},
#{meterReadRecord.dateCreate,jdbcType=TIMESTAMP},
#{meterReadRecord.dateUpdate,jdbcType=TIMESTAMP},
#{meterReadRecord.createBy,jdbcType=VARCHAR},
#{meterReadRecord.updateBy,jdbcType=VARCHAR}
)
INSERT INTO sc_meter_read_record
id,
read_date,
site_id,
sys_id,
province,
city,
region,
community,
building_id,
location,
device_type_id,
device_id,
device_no,
meter_no,
meter_file_no,
read_time,
read_status,
read_data,
last_valid,
last_cost,
status,
date_create,
date_update,
create_by,
update_by,
VALUES
#{meterReadRecord.id,jdbcType=BIGINT},
#{meterReadRecord.readDate,jdbcType=INTEGER},
#{meterReadRecord.siteId,jdbcType=INTEGER},
#{meterReadRecord.sysId,jdbcType=INTEGER},
#{meterReadRecord.province,jdbcType=INTEGER},
#{meterReadRecord.city,jdbcType=INTEGER},
#{meterReadRecord.region,jdbcType=INTEGER},
#{meterReadRecord.communityId,jdbcType=VARCHAR},
#{meterReadRecord.buildingId,jdbcType=INTEGER},
#{meterReadRecord.location,jdbcType=VARCHAR},
#{meterReadRecord.deviceTypeId,jdbcType=INTEGER},
#{meterReadRecord.deviceId,jdbcType=BIGINT},
#{meterReadRecord.deviceNo,jdbcType=VARCHAR},
#{meterReadRecord.meterNo,jdbcType=VARCHAR},
#{meterReadRecord.meterFileNo,jdbcType=VARCHAR},
#{meterReadRecord.readTime,jdbcType=TIMESTAMP},
#{meterReadRecord.readStatus,jdbcType=VARCHAR},
#{meterReadRecord.readData,jdbcType=VARCHAR},
#{meterReadRecord.lastValid,jdbcType=VARCHAR},
#{meterReadRecord.lastCost,jdbcType=DECIMAL},
#{meterReadRecord.status,jdbcType=INTEGER},
#{meterReadRecord.dateCreate,jdbcType=TIMESTAMP},
#{meterReadRecord.dateUpdate,jdbcType=TIMESTAMP},
#{meterReadRecord.createBy,jdbcType=VARCHAR},
#{meterReadRecord.updateBy,jdbcType=VARCHAR},
replace INTO sc_meter_read_record (
id,
read_date,
site_id,
sys_id,
province,
city,
region,
community,
customer_id,
building_id,
location,
device_type_id,
device_id,
device_no,
meter_no,
meter_file_no,
read_time,
read_status,
read_data,
last_valid,
last_cost,
status,
date_create,
date_update,
create_by,
update_by
)VALUES
(
#{meterReadRecord.id,jdbcType=BIGINT},
#{meterReadRecord.readDate,jdbcType=INTEGER},
#{meterReadRecord.siteId,jdbcType=INTEGER},
#{meterReadRecord.sysId,jdbcType=INTEGER},
#{meterReadRecord.province,jdbcType=INTEGER},
#{meterReadRecord.city,jdbcType=INTEGER},
#{meterReadRecord.region,jdbcType=INTEGER},
#{meterReadRecord.communityId,jdbcType=INTEGER},
#{meterReadRecord.customerId,jdbcType=INTEGER},
#{meterReadRecord.buildingId,jdbcType=INTEGER},
#{meterReadRecord.location,jdbcType=VARCHAR},
#{meterReadRecord.deviceTypeId,jdbcType=INTEGER},
#{meterReadRecord.deviceId,jdbcType=BIGINT},
#{meterReadRecord.deviceNo,jdbcType=VARCHAR},
#{meterReadRecord.meterNo,jdbcType=VARCHAR},
#{meterReadRecord.meterFileNo,jdbcType=VARCHAR},
#{meterReadRecord.readTime,jdbcType=TIMESTAMP},
#{meterReadRecord.readStatus,jdbcType=VARCHAR},
#{meterReadRecord.readData,jdbcType=VARCHAR},
#{meterReadRecord.lastValid, jdbcType=VARCHAR},
#{meterReadRecord.lastCost,jdbcType=DECIMAL},
#{meterReadRecord.status,jdbcType=INTEGER},
#{meterReadRecord.dateCreate,jdbcType=TIMESTAMP},
#{meterReadRecord.dateUpdate,jdbcType=TIMESTAMP},
#{meterReadRecord.createBy,jdbcType=VARCHAR},
#{meterReadRecord.updateBy,jdbcType=VARCHAR}
)
UPDATE sc_meter_read_record
read_date= #{meterReadRecord.readDate,jdbcType=INTEGER},
site_id= #{meterReadRecord.siteId,jdbcType=INTEGER},
sys_id= #{meterReadRecord.sysId,jdbcType=INTEGER},
province= #{meterReadRecord.province,jdbcType=INTEGER},
city= #{meterReadRecord.city,jdbcType=INTEGER},
region= #{meterReadRecord.region,jdbcType=INTEGER},
community= #{meterReadRecord.communityId,jdbcType=VARCHAR},
building_id= #{meterReadRecord.buildingId,jdbcType=INTEGER},
location= #{meterReadRecord.location,jdbcType=VARCHAR},
device_type_id= #{meterReadRecord.deviceTypeId,jdbcType=INTEGER},
device_id= #{meterReadRecord.deviceId,jdbcType=BIGINT},
device_no= #{meterReadRecord.deviceNo,jdbcType=VARCHAR},
meter_no= #{meterReadRecord.meterNo,jdbcType=VARCHAR},
meter_file_no= #{meterReadRecord.meterFileNo,jdbcType=VARCHAR},
read_time= #{meterReadRecord.readTime,jdbcType=TIMESTAMP},
read_status= #{meterReadRecord.readStatus,jdbcType=VARCHAR},
read_data= #{meterReadRecord.readData,jdbcType=VARCHAR},
last_valid = #{meterReadRecord.lastValid,jdbcType=VARCHAR},
last_cost = #{meterReadRecord.lastCost,jdbcType=DECIMAL},
status= #{meterReadRecord.status,jdbcType=INTEGER},
date_create= #{meterReadRecord.dateCreate,jdbcType=TIMESTAMP},
date_update= #{meterReadRecord.dateUpdate,jdbcType=TIMESTAMP},
create_by= #{meterReadRecord.createBy,jdbcType=VARCHAR},
update_by= #{meterReadRecord.updateBy,jdbcType=VARCHAR}
WHERE id = #{meterReadRecord.id,jdbcType=BIGINT}
create TEMPORARY table ${tableName} as
select
province,
city,
community,
building_id,
id
from
sc_meter_read_record
where status = 1
and sys_id = #{param.channelId}
and site_id = #{param.siteId}
and device_id in (
select
df.device_id
FROM sc_device_dim_info df
WHERE 1 = 1
and
(df.dimension_code = #{item.dimensionCode} and df.dimension_value = #{item.dimensionValue})
)
and province = #{param.province}
and region = #{param.region}
and city = #{param.city}
and community = #{param.communityId}
and device_no like #{param.deviceNo}
and read_status = #{param.readStatus,jdbcType=VARCHAR}
and location like #{param.location}
and read_date >= #{param.startDate}
and read_date #{param.endDate}
drop TEMPORARY table if exists ${tableName}
UPDATE sc_meter_read_record
when id=#{item.id} then #{item.lastValid}
when id=#{item.id} then #{item.lastCost}
id in #{item.id}
UPDATE sc_meter_read_record
sys_id= #{meterReadRecord.sysId,jdbcType=INTEGER},
where device_id= #{meterReadRecord.deviceId,jdbcType=BIGINT}