insert into business_meter_water(
remark,cur_reading_time,water_id,cur_degrees,operate,meter_type,pre_degrees,obj_id,pre_reading_time,
b_id,community_id,obj_type,fee_id,obj_name,price,
power_supply_bureau,household_name,household_number,electric_meter_id,`handler`,is_transferred,
company_name_after_transfer,transfer_date,corresponding_household_count,last_payment_date,reading_type,
multiplying_factor,unit_price,invoice_amount,amount_difference,auto_deduction,remark2
) values (
#{remark},#{curReadingTime},#{waterId},#{curDegrees},#{operate},#{meterType},#{preDegrees},#{objId},
#{preReadingTime},#{bId},#{communityId},#{objType},#{feeId},#{objName},#{price},
#{powerSupplyBureau},#{householdName},#{householdNumber},#{electricMeterId},#{handler},#{isTransferred},
#{companyNameAfterTransfer},#{transferDate},#{correspondingHouseholdCount},#{lastPaymentDate},#{readingType},
#{multiplyingFactor},#{unitPrice},#{invoiceAmount},#{amountDifference},#{autoDeduction},#{remark2}
)
insert into meter_water(
water_id,b_id,meter_type,obj_type,obj_id,pre_degrees,cur_degrees,pre_reading_time,cur_reading_time,
community_id,status_cd,remark,fee_id,obj_name,price,
power_supply_bureau,household_name,household_number,electric_meter_id,`handler`,is_transferred,
company_name_after_transfer,transfer_date,corresponding_household_count,last_payment_date,reading_type,
multiplying_factor,unit_price,invoice_amount,amount_difference,auto_deduction,remark2,
address,write_time,writer,check_apply_company_name,check_apply_dept_project,water_fee_payer,
account_number,meter_read_book_no,water_consumption,sewage_treatment_water,collection_standard,
arrears_unpaid,late_payment_fine,late_payment_surcharge,fee_payment_status,carry_over_balance,total_payable_amount,
road_name,floor_num,door_num,room_num
) select
t.water_id,t.b_id,t.meter_type,t.obj_type,t.obj_id,t.pre_degrees,t.cur_degrees,t.pre_reading_time,t.cur_reading_time,
t.community_id,'0',t.remark,t.fee_id,t.obj_name,t.price,
t.power_supply_bureau,t.household_name,t.household_number,t.electric_meter_id,t.`handler`,t.is_transferred,
t.company_name_after_transfer,t.transfer_date,t.corresponding_household_count,t.last_payment_date,t.reading_type,
t.multiplying_factor,t.unit_price,t.invoice_amount,t.amount_difference,t.auto_deduction,t.remark2,
#{address},#{writeTime},#{writer},#{checkApplyCompanyName},#{checkApplyDeptProject},#{waterFeePayer},
#{accountNumber},#{meterReadBookNo},#{waterConsumption},#{sewageTreatmentWater},#{collectionStandard},
#{arrearsUnpaid},#{latePaymentFine},#{latePaymentSurcharge},#{feePaymentStatus},#{carryOverBalance},#{totalPayableAmount},
SUBSTRING_INDEX(t.obj_name,'-',1),
SUBSTRING_INDEX(SUBSTRING_INDEX(t.obj_name,'-',2),'-',-1),
SUBSTRING_INDEX(SUBSTRING_INDEX(t.obj_name,'-',3),'-',-1),
SUBSTRING_INDEX(t.obj_name,'-',-1)
from business_meter_water t where 1=1
and t.remark= #{remark}
and t.cur_reading_time= #{curReadingTime}
and t.water_id= #{waterId}
and t.cur_degrees= #{curDegrees}
and t.operate= 'ADD'
and t.create_time= #{createTime}
and t.meter_type= #{meterType}
and t.pre_degrees= #{preDegrees}
and t.obj_id= #{objId}
and t.pre_reading_time= #{preReadingTime}
and t.b_id= #{bId}
and t.community_id= #{communityId}
and t.obj_type= #{objType}
and t.power_supply_bureau= #{powerSupplyBureau}
and t.household_name= #{householdName}
and t.household_number= #{householdNumber}
and t.electric_meter_id= #{electricMeterId}
update meter_water t set
t.status_cd = #{statusCd},
t.b_id = #{newBId},
t.water_id = #{waterId},
t.meter_type= #{meterType},
t.obj_type= #{objType},
t.obj_id= #{objId},
t.pre_degrees= #{preDegrees},
t.cur_degrees= #{curDegrees},
t.pre_reading_time= #{preReadingTime},
t.cur_reading_time= #{curReadingTime},
t.community_id= #{communityId},
t.remark= #{remark},
t.fee_id= #{feeId},
t.obj_name= #{objName},
t.price= #{price},
t.power_supply_bureau= #{powerSupplyBureau},
t.household_name= #{householdName},
t.household_number= #{householdNumber},
t.electric_meter_id= #{electricMeterId},
t.`handler`= #{handler},
t.is_transferred= #{isTransferred},
t.company_name_after_transfer= #{companyNameAfterTransfer},
t.transfer_date= #{transferDate},
t.corresponding_household_count= #{correspondingHouseholdCount},
t.last_payment_date= #{lastPaymentDate},
t.reading_type= #{readingType},
t.multiplying_factor= #{multiplyingFactor},
t.unit_price= #{unitPrice},
t.invoice_amount= #{invoiceAmount},
t.amount_difference= #{amountDifference},
t.auto_deduction= #{autoDeduction},
t.remark2= #{remark2},
t.address= #{address},
t.write_time= #{writeTime},
t.writer= #{writer},
t.check_apply_company_name= #{checkApplyCompanyName},
t.check_apply_dept_project= #{checkApplyDeptProject},
t.water_fee_payer= #{waterFeePayer},
t.account_number= #{accountNumber},
t.meter_read_book_no= #{meterReadBookNo},
t.water_consumption= #{waterConsumption},
t.sewage_treatment_water= #{sewageTreatmentWater},
t.collection_standard= #{collectionStandard},
t.arrears_unpaid= #{arrearsUnpaid},
t.late_payment_fine= #{latePaymentFine},
t.late_payment_surcharge= #{latePaymentSurcharge},
t.fee_payment_status= #{feePaymentStatus},
t.carry_over_balance= #{carryOverBalance},
t.total_payable_amount= #{totalPayableAmount},
t.road_name= #{roadName},
t.floor_num= #{floorNum},
t.door_num= #{doorNum},
t.room_num= #{roomNum},
1=1
where 1=1
and t.water_id= #{waterId}
and t.b_id= #{bId}
insert into meter_water
(water_id,b_id,meter_type,obj_type,obj_id,pre_degrees,cur_degrees,pre_reading_time,cur_reading_time,
community_id,status_cd,remark,fee_id,obj_name,price,
power_supply_bureau,household_name,household_number,electric_meter_id,`handler`,is_transferred,
company_name_after_transfer,transfer_date,corresponding_household_count,last_payment_date,reading_type,
multiplying_factor,unit_price,invoice_amount,amount_difference,auto_deduction,remark2,
address,write_time,writer,check_apply_company_name,check_apply_dept_project,water_fee_payer,
account_number,meter_read_book_no,water_consumption,sewage_treatment_water,collection_standard,
arrears_unpaid,late_payment_fine,late_payment_surcharge,fee_payment_status,carry_over_balance,total_payable_amount,
road_name,floor_num,door_num,room_num)
VALUES
(#{item.waterId},#{item.bId},#{item.meterType},#{item.objType},#{item.objId},#{item.preDegrees},#{item.curDegrees},
#{item.preReadingTime},#{item.curReadingTime},#{item.communityId},'0',#{item.remark},#{item.feeId},#{item.objName},#{item.price},
#{item.powerSupplyBureau},#{item.householdName},#{item.householdNumber},#{item.electricMeterId},#{item.handler},#{item.isTransferred},
#{item.companyNameAfterTransfer},#{item.transferDate},#{item.correspondingHouseholdCount},#{item.lastPaymentDate},#{item.readingType},
#{item.multiplyingFactor},#{item.unitPrice},#{item.invoiceAmount},#{item.amountDifference},#{item.autoDeduction},#{item.remark2},
#{item.address},#{item.writeTime},#{item.writer},#{item.checkApplyCompanyName},#{item.checkApplyDeptProject},#{item.waterFeePayer},
#{item.accountNumber},#{item.meterReadBookNo},#{item.waterConsumption},#{item.sewageTreatmentWater},#{item.collectionStandard},
#{item.arrearsUnpaid},#{item.latePaymentFine},#{item.latePaymentSurcharge},#{item.feePaymentStatus},#{item.carryOverBalance},#{item.totalPayableAmount},
#{item.roadName},#{item.floorNum},#{item.doorNum},#{item.roomNum})