whycxzp
2025-06-13 14c03b65ebfc62d32bcfeff2c1b4338247b50729
蓄电池核容测试信息统计
4个文件已修改
81 ■■■■■ 已修改文件
src/main/java/com/whyc/mapper/BatttestdataInfMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/BatttestdataInfService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/util/DateUtil.java 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/BatttestdataInfMapper.xml 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/BatttestdataInfMapper.java
@@ -13,4 +13,7 @@
    //获取电池组未放电记录(指定时间段的标准核容放电)
    List<BatttestdataInf> getNoDischargeData(@Param("battgroupId") Integer battgroupId,@Param("testStartTime") Date testStartTime
            , @Param("testEndTime") Date testEndTime, @Param("typeList") List<Integer> typeList);
    List<BatttestdataInf> getListByUserId(Integer userId);
}
src/main/java/com/whyc/service/BatttestdataInfService.java
@@ -972,4 +972,8 @@
        return new Response().setII(1,reslist.size()>0,pageInfo,"优良电源数量统计(1.2.7)");
    }
    public List<BatttestdataInf> getListByUserId(Integer userId) {
        return mapper.getListByUserId(userId);
    }
}
src/main/java/com/whyc/util/DateUtil.java
@@ -2,6 +2,10 @@
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
/**
@@ -704,33 +708,39 @@
    }
    public static void main(String[] args) throws ParseException {
        //Date d1 = YYYY_MM_DD_HH_MM_SS.parse("2023-01-22 14:12:22");
        //Date d2 = YYYY_MM_DD_HH_MM_SS.parse("2023-08-24 16:45:22");
        //Map<String, List<Date>> monthListDesc = getQueryTimeForSubTablesByMonthDesc(d1, d2);
        //
        //Set<Map.Entry<String, List<Date>>> entries = monthListDesc.entrySet();
        //for (Map.Entry<String, List<Date>> entry : entries) {
        //    System.out.println(entry);
        //}
        //Map<String,String> map = new HashMap<>();
        //map.put("2022_01","");
        //map.put("2022_02","");
        //map.put("2022_10","");
        //map.put("2022_12","");
        //map.put("2021_03","");
        //map.put("2023_01","");
        //map.put("2023_05","");
        //map.put("2021_10","");
        //Set<String> keySet = map.keySet();
        //List<String> keySetDesc = keySet.stream().sorted(Comparator.comparing(String::hashCode).reversed()).collect(Collectors.toList());
        String t1 = "2024-01-25 12:22:29";
        String t2 = "2024-01-25 12:32:24";
        String t3 = "2024-01-25 12:42:26";
        Date maxTime = getMaxTime(t1, t2, t3);
        System.out.println(maxTime.toString());
    /**
     * 获取本年的开始时间
     */
    public static LocalDateTime getStartOfYear() {
        LocalDateTime now = LocalDateTime.now();
        return now.with(TemporalAdjusters.firstDayOfYear()).with(LocalDateTime.MIN.toLocalTime());
    }
    /**
     * 获取本季度的开始时间
     */
    public static LocalDateTime getStartOfQuarter() {
        LocalDateTime now = LocalDateTime.now();
        int currentMonthValue = now.getMonthValue();
        // 计算当前季度的第一个月
        int quarterStartMonth = 3 * ((currentMonthValue - 1) / 3) + 1;
        return LocalDate.of(now.getYear(), quarterStartMonth, 1).atStartOfDay();
    }
    /**
     * 获取本月的开始时间
     */
    public static LocalDateTime getStartOfMonth() {
        LocalDateTime now = LocalDateTime.now();
        return now.with(TemporalAdjusters.firstDayOfMonth()).with(LocalDateTime.MIN.toLocalTime());
    }
    /**
     * Date 转 LocalDateTime 工具方法
     */
    public static LocalDateTime convertToLocalDateTime(java.util.Date date) {
        return date.toInstant()
                .atZone(ZoneId.systemDefault())
                .toLocalDateTime();
    }
}
src/main/resources/mapper/BatttestdataInfMapper.xml
@@ -61,4 +61,14 @@
        </where>
        order by test_starttime desc
    </select>
    <select id="getListByUserId" resultType="com.whyc.pojo.db_batt_testdata.BatttestdataInf">
        select * from db_batt_testdata.tb_batttestdata_inf
        where battgroup_id in(
            select distinct battgroup_id from db_user.tb_baojigroup_usr bu,db_user.tb_baojigroup_power bp,db_station.tb_batt_inf bi
            where bu.baoji_group_id = bp.baoji_group_id
            and bp.station_id = bi.station_id
            and bu.uid = #{userId}
        )
    </select>
</mapper>