@startuml 'https://plantuml.com/activity-diagram-beta start note left: TsKvNativeSQL.amSumV1 repeat:forEach protoList :dataProto; :初始化参数:\n inter:时间间隔(min 换算成 ms)\n thingCode: 物编码 \n key: 属性编码 \n value: 属性值 \n ts: 数据时间 \n stTs: 基于当前时间计算获取的开始时间 \n enTs: 基于当前时间计算获取的结束时间; if ((ts - inter) == stTs \n 当前时间可用于统计) then (yes) : 查询stTs~enTs在每个inter之间的最小值 \n => rowList; switch(rowList.size) case (多条) :计算连续数据的差值\n作为单个am数据值; :收集am到amList; case (1条) :向ts之前查询第一条数据; if (存在) then (yes) :与当前数据value计算差值\n作为单个am数据值; :收集am到amList; else (false) :设置am值为0并收集; :log error; endif if (当前时间 > enTs) :查询ts之后的第一条数据; :与之前查询出的1条计算差值\n收集到amList; endif endswitch : todo; else (false) :将stTs向左移动一个inter的时间\n然后查询新的开始时间~ts之间的数据\n => rowList; switch(rowList.size) case (多条) :计算连续数据的差值\n作为单个am数据值; :收集am到amList; case (1条) :向stTs之前查询第一条数据; if (存在) then (yes) :与当前数据value计算差值\n作为单个am数据值; :收集am到amList; else (false) :设置am值为0并收集; :log error; endif if (当前时间 > enTs) :查询enTs之后的第一条数据; :与之前查询出的1条计算差值\n收集到amList; endif endswitch endif repeat while(hasNext?) if (amList非空) then (yes) : 存储聚合好的amList数据; : 将amList推送到数据消费事件中(v1/tskv/latest); endif stop @enduml