| | |
| | | <result property="receivedAtUtc" column="received_at_utc"/> |
| | | </resultMap> |
| | | |
| | | <!-- 落地行的显式列名,顺序与建表脚本一致;列集合不随运行期表结构变化。 --> |
| | | <sql id="ingestColumns">ingest_id, adapter_code, payload_kind, devtype, devid, subdevid, chlid, record_sequence, record_key, |
| | | source_ref, device_time_utc, device_time_raw, timezone_id, cycle_no, step_no, relative_time_seconds, |
| | | voltage_v, current_a, charge_capacity_ah, discharge_capacity_ah, charge_energy_wh, discharge_energy_wh, |
| | | payload_json, content_sha256, received_at_utc</sql> |
| | | |
| | | <!-- 驼峰映射未开启(见 mybatis-config.xml),列名带下划线的查询一律显式映射。 --> |
| | | <resultMap id="TDeviceIngestChannelResultMap" type="com.battery.business.domain.vo.TDeviceIngestChannel"> |
| | | <result property="devtype" column="devtype"/> |
| | |
| | | </select> |
| | | |
| | | <select id="selectLatestSample" resultMap="TDeviceIngestRecordResultMap"> |
| | | select * from t_device_ingest_record |
| | | select <include refid="ingestColumns"/> from t_device_ingest_record |
| | | where adapter_code = #{adapterCode} and payload_kind = 'SAMPLE' |
| | | and devtype = #{devtype} and devid = #{devid} and subdevid = #{subdevid} and chlid = #{chlid} |
| | | order by device_time_utc desc, record_sequence desc |
| | |
| | | |
| | | <!-- 只取严格晚于水位的行;同秒多行按协议序号各自成立,不按秒合并。 --> |
| | | <select id="selectSamplesSince" resultMap="TDeviceIngestRecordResultMap"> |
| | | select * from t_device_ingest_record |
| | | select <include refid="ingestColumns"/> from t_device_ingest_record |
| | | where adapter_code = #{adapterCode} and payload_kind = 'SAMPLE' |
| | | and devtype = #{devtype} and devid = #{devid} and subdevid = #{subdevid} and chlid = #{chlid} |
| | | <if test="watermarkTime != null"> |