Commit 5328203c authored by 朱晨阳's avatar 朱晨阳

去除接口同一逆变器重复数据

parent 4d2f0a25
......@@ -15,4 +15,10 @@ public interface TdHYGFInverterDayGenerateMapper extends BaseMapper<TdHYGFInvert
@UserEmpower(field ={"regional_companies_code"},dealerField ={"amos_company_code","regional_companies_code"} ,fieldConditions ={"eq","in"} ,relationship="and")
List<TdHYGFInverterDayGenerate> selectList(@Param(Constants.WRAPPER) Wrapper<TdHYGFInverterDayGenerate> queryWrapper);
// @UserEmpower(field ={"regional_companies_code"},dealerField ={"amos_company_code","regional_companies_code"} ,fieldConditions ={"eq","in"} ,relationship="and")
List<Map<String,Object>> selectSnCodeList(String startTime, String endTime, List<String> sncodes);
@UserEmpower(field ={"regional_companies_code"},dealerField ={"amos_company_code","regional_companies_code"} ,fieldConditions ={"eq","in"} ,relationship="and")
List<TdHYGFInverterDayGenerate> selectListPage(List<String> snCodeList, List<String> maxCreatedTimeList);
}
......@@ -23,4 +23,59 @@
</select>
<!-- <select id="selectListPage" resultType="com.yeejoin.amos.boot.module.hygf.api.entity.TdHYGFInverterDayGenerate">-->
<!-- SELECT-->
<!-- *-->
<!-- from-->
<!-- house_pv_data.td_hygf_inverter_day_generate-->
<!-- <where>-->
<!-- created_time >= #{startTime} and created_time &lt;= #{endTime}-->
<!-- <if test="sncodes != null and sncodes.size>0">-->
<!-- sn_code in-->
<!-- <foreach collection="sncodes" item="sncode" open="(" close=")" separator=",">-->
<!-- #{sncode}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- </where>-->
<!-- </select>-->
<select id="selectSnCodeList" resultType="map">
SELECT
sn_code, max(TO_UNIXTIMESTAMP(TO_ISO8601(created_time))) max_created_time
from
house_pv_data.td_hygf_inverter_day_generate
<where>
created_time >= #{startTime} and created_time &lt;= #{endTime}
<if test="sncodes != null and sncodes.size>0">
sn_code in
<foreach collection="sncodes" item="sncode" open="(" close=")" separator=",">
#{sncode}
</foreach>
</if>
</where>
GROUP BY sn_code
</select>
<select id="selectListPage" resultType="com.yeejoin.amos.boot.module.hygf.api.entity.TdHYGFInverterDayGenerate">
SELECT
*
from
house_pv_data.td_hygf_inverter_day_generate
<where>
<if test="snCodeList != null and snCodeList.size>0">
sn_code in
<foreach collection="snCodeList" item="sncode" open="(" close=")" separator=",">
#{sncode}
</foreach>
</if>
<if test="maxCreatedTimeList != null and maxCreatedTimeList.size>0">
and created_time in
<foreach collection="maxCreatedTimeList" item="maxCreatedTime" open="(" close=")" separator=",">
#{maxCreatedTime}
</foreach>
</if>
</where>
order by created_time desc
</select>
</mapper>
\ No newline at end of file
......@@ -149,18 +149,38 @@ public class JpInverterServiceImpl extends BaseService<JpInverterDto, JpInverter
String endTime = DateUtil.format(LocalDateTime.parse(time2,df), "yyyy-MM-dd HH:mm:ss");
QueryWrapper queryWrapper = new QueryWrapper<TdHYGFInverterDayGenerate>()
.ge("created_time", startTime)
.le("created_time", endTime);
// .in("third_station_id", stationIds);
;
if (CollectionUtil.isNotEmpty(sncodes)) {
queryWrapper.in("sn_code", sncodes);
// QueryWrapper queryWrapper = new QueryWrapper<TdHYGFInverterDayGenerate>()
// .ge("created_time", startTime)
// .le("created_time", endTime);
//// .in("third_station_id", stationIds);
// ;
// if (CollectionUtil.isNotEmpty(sncodes)) {
// queryWrapper.in("sn_code", sncodes);
// }
// queryWrapper.orderByDesc("created_time");
//
// PageHelper.startPage(current, size);
// List<TdHYGFInverterDayGenerate> tdHYGFInverterDayGenerates = tdHYGFInverterDayGenerateMapper.selectList(queryWrapper);
List<Map<String, Object>> listData = tdHYGFInverterDayGenerateMapper.selectSnCodeList(startTime, endTime, sncodes);
List<String> snCodeList = new ArrayList<>();
List<String> maxCreatedTimeList = new ArrayList<>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
listData.stream().forEach(item -> {
if(item.get("sn_code") != null) {
snCodeList.add(item.get("sn_code").toString());
}
queryWrapper.orderByDesc("created_time");
if(item.get("max_created_time") != null) {
maxCreatedTimeList.add(sdf.format(item.get("max_created_time")));
}
});
PageHelper.startPage(current, size);
List<TdHYGFInverterDayGenerate> tdHYGFInverterDayGenerates = tdHYGFInverterDayGenerateMapper.selectList(queryWrapper);
List<TdHYGFInverterDayGenerate> tdHYGFInverterDayGenerates = tdHYGFInverterDayGenerateMapper.selectListPage(snCodeList, maxCreatedTimeList);
tdHYGFInverterDayGenerates.forEach(tdHYGFInverterDayGenerate -> {
Date date1 = new Date(tdHYGFInverterDayGenerate.getCreatedTime());
tdHYGFInverterDayGenerate.setCreatedTimeStr(DateUtil.format(date1, DatePattern.NORM_DATETIME_PATTERN));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment