Pārlūkot izejas kodu

+ 大屏接口研发,《网》 柱状图

chen.cheng 11 mēneši atpakaļ
vecāks
revīzija
db525452bf

+ 37 - 28
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/controller/ElecUseHController.java

@@ -1,15 +1,9 @@
 package com.ruoyi.ems.controller;
 
-import com.ruoyi.common.core.utils.poi.ExcelUtil;
-import com.ruoyi.common.core.web.controller.BaseController;
-import com.ruoyi.common.core.web.domain.AjaxResult;
-import com.ruoyi.common.core.web.page.TableDataInfo;
-import com.ruoyi.common.log.annotation.Log;
-import com.ruoyi.common.log.enums.BusinessType;
-import com.ruoyi.common.security.annotation.RequiresPermissions;
-import com.ruoyi.ems.domain.ElecUseH;
-import com.ruoyi.ems.service.IElecUseHService;
-import io.swagger.annotations.Api;
+import java.util.List;
+
+import javax.servlet.http.HttpServletResponse;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -18,22 +12,31 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
-import javax.servlet.http.HttpServletResponse;
-import java.util.List;
+import com.ruoyi.common.core.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.common.core.web.domain.AjaxResult;
+import com.ruoyi.common.core.web.page.TableDataInfo;
+import com.ruoyi.common.log.annotation.Log;
+import com.ruoyi.common.log.enums.BusinessType;
+import com.ruoyi.common.security.annotation.RequiresPermissions;
+import com.ruoyi.ems.domain.ElecUseH;
+import com.ruoyi.ems.service.IElecUseHService;
+
+import io.swagger.annotations.Api;
 
 /**
  * 用能计量-小时Controller
- * 
+ *
  * @author ruoyi
  * @date 2024-08-15
  */
 @RestController
 @RequestMapping("/elec/use/hour")
 @Api(value = "ElecUseHController", description = "用电计量数据接口")
-public class ElecUseHController extends BaseController
-{
+public class ElecUseHController extends BaseController {
     @Autowired
     private IElecUseHService elecUseHService;
 
@@ -42,8 +45,7 @@ public class ElecUseHController extends BaseController
      */
     @RequiresPermissions("ems:h:list")
     @GetMapping("/list")
-    public TableDataInfo list(ElecUseH admEmsFacsUseH)
-    {
+    public TableDataInfo list(ElecUseH admEmsFacsUseH) {
         startPage();
         List<ElecUseH> list = elecUseHService.selectElecUseHList(admEmsFacsUseH);
         return getDataTable(list);
@@ -55,8 +57,7 @@ public class ElecUseHController extends BaseController
     @RequiresPermissions("ems:h:export")
     @Log(title = "用能计量-小时", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, ElecUseH admEmsFacsUseH)
-    {
+    public void export(HttpServletResponse response, ElecUseH admEmsFacsUseH) {
         List<ElecUseH> list = elecUseHService.selectElecUseHList(admEmsFacsUseH);
         ExcelUtil<ElecUseH> util = new ExcelUtil<ElecUseH>(ElecUseH.class);
         util.exportExcel(response, list, "用能计量-小时数据");
@@ -67,8 +68,7 @@ public class ElecUseHController extends BaseController
      */
     @RequiresPermissions("ems:h:query")
     @GetMapping(value = "/{id}")
-    public AjaxResult getInfo(@PathVariable("id") Long id)
-    {
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
         return success(elecUseHService.selectElecUseHById(id));
     }
 
@@ -78,8 +78,7 @@ public class ElecUseHController extends BaseController
     @RequiresPermissions("ems:h:add")
     @Log(title = "用能计量-小时", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody ElecUseH admEmsFacsUseH)
-    {
+    public AjaxResult add(@RequestBody ElecUseH admEmsFacsUseH) {
         return toAjax(elecUseHService.insertElecUseH(admEmsFacsUseH));
     }
 
@@ -89,8 +88,7 @@ public class ElecUseHController extends BaseController
     @RequiresPermissions("ems:h:edit")
     @Log(title = "用能计量-小时", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody ElecUseH admEmsFacsUseH)
-    {
+    public AjaxResult edit(@RequestBody ElecUseH admEmsFacsUseH) {
         return toAjax(elecUseHService.updateElecUseH(admEmsFacsUseH));
     }
 
@@ -99,9 +97,20 @@ public class ElecUseHController extends BaseController
      */
     @RequiresPermissions("ems:h:remove")
     @Log(title = "用能计量-小时", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{ids}")
-    public AjaxResult remove(@PathVariable Long[] ids)
-    {
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(elecUseHService.deleteElecUseHByIds(ids));
     }
+
+    /**
+     * 网-用电量月度统计
+     *
+     * @param area the area
+     * @return the area month use supply
+     * @author chen.cheng
+     */
+    @GetMapping("/area/month/use/supply")
+    public AjaxResult getAreaMonthUseSupply(@RequestParam("area") String area) {
+        return success(elecUseHService.selectElecAndPower(area));
+    }
 }

+ 14 - 9
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/mapper/ElecUseHMapper.java

@@ -1,12 +1,15 @@
 package com.ruoyi.ems.mapper;
 
-import com.ruoyi.ems.domain.ElecUseH;
-
 import java.util.List;
+import java.util.Map;
+
+import org.apache.ibatis.annotations.Param;
+
+import com.ruoyi.ems.domain.ElecUseH;
 
 /**
  * 用能计量-小时Mapper接口
- * 
+ *
  * @author ruoyi
  * @date 2024-08-15
  */
@@ -14,7 +17,7 @@ public interface ElecUseHMapper
 {
     /**
      * 查询用能计量-小时
-     * 
+     *
      * @param id 用能计量-小时主键
      * @return 用能计量-小时
      */
@@ -22,7 +25,7 @@ public interface ElecUseHMapper
 
     /**
      * 查询用能计量-小时列表
-     * 
+     *
      * @param elecUseH 用能计量-小时
      * @return 用能计量-小时集合
      */
@@ -30,7 +33,7 @@ public interface ElecUseHMapper
 
     /**
      * 新增用能计量-小时
-     * 
+     *
      * @param elecUseH 用能计量-小时
      * @return 结果
      */
@@ -38,7 +41,7 @@ public interface ElecUseHMapper
 
     /**
      * 修改用能计量-小时
-     * 
+     *
      * @param elecUseH 用能计量-小时
      * @return 结果
      */
@@ -46,7 +49,7 @@ public interface ElecUseHMapper
 
     /**
      * 删除用能计量-小时
-     * 
+     *
      * @param id 用能计量-小时主键
      * @return 结果
      */
@@ -54,9 +57,11 @@ public interface ElecUseHMapper
 
     /**
      * 批量删除用能计量-小时
-     * 
+     *
      * @param ids 需要删除的数据主键集合
      * @return 结果
      */
      int deleteElecUseHByIds(Long[] ids);
+
+    List<Map<String, Object>> selectElecUseHByMonth(@Param("areaCode") String areaCode, @Param("date") String date);
 }

+ 2 - 0
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/mapper/PvSupplyHMapper.java

@@ -37,6 +37,8 @@ public interface PvSupplyHMapper
 
     List<Map<String,Object>> selectAreaSupplyByThisYear(@Param("areaCode")String areaCode, @Param("date")String date);
 
+    List<Map<String,Object>> selectAreaSupplyByMonth(@Param("areaCode")String areaCode, @Param("date")String date);
+
     /**
      * 新增光伏并网计量光伏并网计量-小时
      *

+ 15 - 9
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/IElecUseHService.java

@@ -1,12 +1,13 @@
 package com.ruoyi.ems.service;
 
-import com.ruoyi.ems.domain.ElecUseH;
-
 import java.util.List;
+import java.util.Map;
+
+import com.ruoyi.ems.domain.ElecUseH;
 
 /**
  * 用能计量-小时Service接口
- * 
+ *
  * @author ruoyi
  * @date 2024-08-15
  */
@@ -14,7 +15,7 @@ public interface IElecUseHService
 {
     /**
      * 查询用能计量-小时
-     * 
+     *
      * @param id 用能计量-小时主键
      * @return 用能计量-小时
      */
@@ -22,7 +23,7 @@ public interface IElecUseHService
 
     /**
      * 查询用能计量-小时列表
-     * 
+     *
      * @param elecUseH 用能计量-小时
      * @return 用能计量-小时集合
      */
@@ -30,7 +31,7 @@ public interface IElecUseHService
 
     /**
      * 新增用能计量-小时
-     * 
+     *
      * @param elecUseH 用能计量-小时
      * @return 结果
      */
@@ -38,7 +39,7 @@ public interface IElecUseHService
 
     /**
      * 修改用能计量-小时
-     * 
+     *
      * @param elecUseH 用能计量-小时
      * @return 结果
      */
@@ -46,7 +47,7 @@ public interface IElecUseHService
 
     /**
      * 批量删除用能计量-小时
-     * 
+     *
      * @param ids 需要删除的用能计量-小时主键集合
      * @return 结果
      */
@@ -54,9 +55,14 @@ public interface IElecUseHService
 
     /**
      * 删除用能计量-小时信息
-     * 
+     *
      * @param id 用能计量-小时主键
      * @return 结果
      */
      int deleteElecUseHById(Long id);
+
+    /**
+     * 查询用能和发电量
+     */
+    List<Map> selectElecAndPower(String areaCode);
 }

+ 54 - 23
ems-cloud/ems-modules/ems-server/src/main/java/com/ruoyi/ems/service/impl/ElecUseHServiceImpl.java

@@ -1,94 +1,125 @@
 package com.ruoyi.ems.service.impl;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.ruoyi.common.core.utils.DateTimeUtil;
+import com.ruoyi.common.core.utils.StreamUtils;
 import com.ruoyi.ems.domain.ElecUseH;
 import com.ruoyi.ems.mapper.ElecUseHMapper;
+import com.ruoyi.ems.mapper.PvSupplyHMapper;
 import com.ruoyi.ems.service.IElecUseHService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
+
+import cn.hutool.core.map.MapUtil;
 
 /**
  * 用能计量-小时Service业务层处理
- * 
+ *
  * @author ruoyi
  * @date 2024-08-15
  */
 @Service
-public class ElecUseHServiceImpl implements IElecUseHService
-{
+public class ElecUseHServiceImpl implements IElecUseHService {
     @Autowired
     private ElecUseHMapper elecUseHMapper;
 
+    @Autowired
+    private PvSupplyHMapper pvSupplyHMapper;
+
     /**
      * 查询用能计量-小时
-     * 
+     *
      * @param id 用能计量-小时主键
      * @return 用能计量-小时
      */
     @Override
-    public ElecUseH selectElecUseHById(Long id)
-    {
+    public ElecUseH selectElecUseHById(Long id) {
         return elecUseHMapper.selectElecUseHById(id);
     }
 
     /**
      * 查询用能计量-小时列表
-     * 
+     *
      * @param ElecUseH 用能计量-小时
      * @return 用能计量-小时
      */
     @Override
-    public List<ElecUseH> selectElecUseHList(ElecUseH ElecUseH)
-    {
+    public List<ElecUseH> selectElecUseHList(ElecUseH ElecUseH) {
         return elecUseHMapper.selectElecUseHList(ElecUseH);
     }
 
     /**
      * 新增用能计量-小时
-     * 
+     *
      * @param ElecUseH 用能计量-小时
      * @return 结果
      */
     @Override
-    public int insertElecUseH(ElecUseH ElecUseH)
-    {
+    public int insertElecUseH(ElecUseH ElecUseH) {
         return elecUseHMapper.insertElecUseH(ElecUseH);
     }
 
     /**
      * 修改用能计量-小时
-     * 
+     *
      * @param ElecUseH 用能计量-小时
      * @return 结果
      */
     @Override
-    public int updateElecUseH(ElecUseH ElecUseH)
-    {
+    public int updateElecUseH(ElecUseH ElecUseH) {
         return elecUseHMapper.updateElecUseH(ElecUseH);
     }
 
     /**
      * 批量删除用能计量-小时
-     * 
+     *
      * @param ids 需要删除的用能计量-小时主键
      * @return 结果
      */
     @Override
-    public int deleteElecUseHByIds(Long[] ids)
-    {
+    public int deleteElecUseHByIds(Long[] ids) {
         return elecUseHMapper.deleteElecUseHByIds(ids);
     }
 
     /**
      * 删除用能计量-小时信息
-     * 
+     *
      * @param id 用能计量-小时主键
      * @return 结果
      */
     @Override
-    public int deleteElecUseHById(Long id)
-    {
+    public int deleteElecUseHById(Long id) {
         return elecUseHMapper.deleteElecUseHById(id);
     }
+
+    @Override
+    public List<Map> selectElecAndPower(String areaCode) {
+        String firstDayOfRecentYear = DateTimeUtil.getFirstDayOfRecentYear();
+        List<Map<String, Object>> monthElecUse = elecUseHMapper.selectElecUseHByMonth(areaCode, firstDayOfRecentYear);
+        List<Map<String, Object>> monthPv = pvSupplyHMapper.selectAreaSupplyByMonth(areaCode, firstDayOfRecentYear);
+        Map<String, Map<String, Object>> dateElecUseIndex = StreamUtils.toIdentityMap(monthElecUse,
+            map -> MapUtil.getStr(map, "dateIndex"));
+        Map<String, Map<String, Object>> datePvIndex = StreamUtils.toIdentityMap(monthPv,
+            map -> MapUtil.getStr(map, "dateIndex"));
+        List<String> dates = DateTimeUtil.monthOfRange(firstDayOfRecentYear,
+            DateTimeUtil.currentDateTime(DateTimeUtil.DateFormatter.yyyy_MM_dd), DateTimeUtil.DateFormatter.yyyy_MM_dd,
+            DateTimeUtil.DateFormatter.yyyy_MM);
+        List<Map> result = new ArrayList<>();
+        Map<Object, Object> dateIndex;
+        for (String date : dates) {
+            dateIndex = MapUtil.builder().put("dateIndex", date).map();
+            if (dateElecUseIndex.containsKey(date)) {
+                dateIndex.putAll(dateElecUseIndex.get(date));
+            }
+            if (datePvIndex.containsKey(date)) {
+                dateIndex.putAll(datePvIndex.get(date));
+            }
+            result.add(dateIndex);
+        }
+        return result;
+    }
 }

+ 15 - 0
ems-cloud/ems-modules/ems-server/src/main/resources/mapper/ems/ElecPvSupplyHMapper.xml

@@ -89,6 +89,21 @@
             dateIndex
     </select>
 
+    <select id="selectAreaSupplyByMonth" resultType="Map">
+        SELECT area_code,
+               DATE_FORMAT(date, '%Y-%m') AS dateIndex,
+               SUM(gen_elec_quantity)        as genElecQuantity,
+               SUM(use_elec_quantity)        as useElecQuantity,
+               SUM(up_elec_quantity)         as upElecQuantity,
+               SUM(up_elec_earn)             as upElecEarn
+        FROM adm_ems_pv_supply_h
+        WHERE area_code = #{areaCode}
+          AND DATE >= #{date}
+        GROUP BY
+            area_code,
+            dateIndex
+    </select>
+
     <select id="selectAreaSupplyByThisYear" resultType="Map">
         SELECT area_code,
                DATE_FORMAT(date, '%Y') AS dateIndex,

+ 57 - 33
ems-cloud/ems-modules/ems-server/src/main/resources/mapper/ems/ElecUseHMapper.xml

@@ -1,49 +1,59 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.ems.mapper.ElecUseHMapper">
-    
+
     <resultMap type="com.ruoyi.ems.domain.ElecUseH" id="elecUseHResult">
-        <result property="id"    column="id"    />
-        <result property="areaCode"    column="area_code"    />
-        <result property="areaName"    column="area_name"    />
-        <result property="areaShortName"    column="area_short_name"    />
-        <result property="facsCode"    column="facs_code"    />
-        <result property="facsName"    column="facs_name"    />
-        <result property="date"    column="date"    />
-        <result property="time"    column="time"    />
-        <result property="timeIndex"    column="time_index"    />
-        <result property="elecQuantity"    column="elec_quantity"    />
+        <result property="id" column="id"/>
+        <result property="areaCode" column="area_code"/>
+        <result property="areaName" column="area_name"/>
+        <result property="areaShortName" column="area_short_name"/>
+        <result property="facsCode" column="facs_code"/>
+        <result property="facsName" column="facs_name"/>
+        <result property="date" column="date"/>
+        <result property="time" column="time"/>
+        <result property="timeIndex" column="time_index"/>
+        <result property="elecQuantity" column="elec_quantity"/>
     </resultMap>
 
     <sql id="selectElecUseHVo">
-        select
-            u.id, u.area_code, a.area_name, a.short_name as area_short_name, u.facs_code, f.facs_name, f.facs_type, f.facs_subtype, u.`date`, u.`time`, u.time_index, u.elec_quantity
+        select u.id,
+               u.area_code,
+               a.area_name,
+               a.short_name as area_short_name,
+               u.facs_code,
+               f.facs_name,
+               f.facs_type,
+               f.facs_subtype,
+               u.`date`,
+               u.`time`,
+               u.time_index,
+               u.elec_quantity
         from adm_ems_facs_use_h u
-            LEFT JOIN adm_service_area a ON u.`area_code` = a.`area_code`
-            LEFT JOIN adm_ems_facs f ON u.`facs_code` = f.`facs_code`
+                 LEFT JOIN adm_service_area a ON u.`area_code` = a.`area_code`
+                 LEFT JOIN adm_ems_facs f ON u.`facs_code` = f.`facs_code`
     </sql>
 
     <select id="selectElecUseHList" parameterType="com.ruoyi.ems.domain.ElecUseH" resultMap="elecUseHResult">
         <include refid="selectElecUseHVo"/>
-        <where>  
-            <if test="areaCode != null  and areaCode != ''"> and u.area_code = #{areaCode}</if>
-            <if test="facsCode != null  and facsCode != ''"> and u.facs_code = #{facsCode}</if>
-            <if test="facsType != null  and facsType != ''"> and f.facs_type = #{facsType}</if>
-            <if test="facsSubtype != null  and facsSubtype != ''"> and f.facs_subtype = #{facsSubtype}</if>
-            <if test="date != null "> and u.`date` = #{date}</if>
-            <if test="time != null "> and u.`time` = #{time}</if>
-            <if test="timeIndex != null "> and u.time_index = #{timeIndex}</if>
-            <if test="elecQuantity != null "> and u.elec_quantity = #{elecQuantity}</if>
+        <where>
+            <if test="areaCode != null  and areaCode != ''">and u.area_code = #{areaCode}</if>
+            <if test="facsCode != null  and facsCode != ''">and u.facs_code = #{facsCode}</if>
+            <if test="facsType != null  and facsType != ''">and f.facs_type = #{facsType}</if>
+            <if test="facsSubtype != null  and facsSubtype != ''">and f.facs_subtype = #{facsSubtype}</if>
+            <if test="date != null ">and u.`date` = #{date}</if>
+            <if test="time != null ">and u.`time` = #{time}</if>
+            <if test="timeIndex != null ">and u.time_index = #{timeIndex}</if>
+            <if test="elecQuantity != null ">and u.elec_quantity = #{elecQuantity}</if>
         </where>
     </select>
-    
+
     <select id="selectElecUseHById" parameterType="Long" resultMap="elecUseHResult">
         <include refid="selectElecUseHVo"/>
         where u.`id` = #{id}
     </select>
-        
+
     <insert id="insertElecUseH" parameterType="com.ruoyi.ems.domain.ElecUseH" useGeneratedKeys="true" keyProperty="id">
         insert into adm_ems_facs_use_h
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -53,7 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="time != null">time,</if>
             <if test="timeIndex != null">time_index,</if>
             <if test="elecQuantity != null">elec_quantity,</if>
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="areaCode != null and areaCode != ''">#{areaCode},</if>
             <if test="facsCode != null and facsCode != ''">#{facsCode},</if>
@@ -61,7 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="time != null">#{time},</if>
             <if test="timeIndex != null">#{timeIndex},</if>
             <if test="elecQuantity != null">#{elecQuantity},</if>
-         </trim>
+        </trim>
     </insert>
 
     <update id="updateElecUseH" parameterType="com.ruoyi.ems.domain.ElecUseH">
@@ -78,13 +88,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </update>
 
     <delete id="deleteElecUseHById" parameterType="Long">
-        delete from adm_ems_facs_use_h where id = #{id}
+        delete
+        from adm_ems_facs_use_h
+        where id = #{id}
     </delete>
 
     <delete id="deleteElecUseHByIds" parameterType="String">
-        delete from adm_ems_facs_use_h where id in 
+        delete from adm_ems_facs_use_h where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
     </delete>
-</mapper>
+
+    <select id="selectElecUseHByMonth" resultType="Map">
+        SELECT area_code,
+               DATE_FORMAT(date, '%Y-%m') AS dateIndex,
+               SUM(elec_quantity)         as elecQuantity
+        FROM adm_ems_facs_use_h
+        WHERE area_code = #{areaCode}
+          AND DATE >= #{date}
+        GROUP BY
+            area_code,
+            dateIndex
+    </select>
+</mapper>

+ 39 - 35
ems-cloud/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/DateTimeUtil.java

@@ -49,7 +49,7 @@ public class DateTimeUtil {
     /**
      * Parse date date.
      *
-     * @param dateString  the date string
+     * @param dateString the date string
      * @param formatRegex the format regex
      * @return the date
      * @author chen.cheng
@@ -78,7 +78,7 @@ public class DateTimeUtil {
      * Parse date string.
      *
      * @param localDateTime the local date time
-     * @param formatRegex   the format regex
+     * @param formatRegex the format regex
      * @return the string
      * @author chen.cheng
      */
@@ -90,7 +90,7 @@ public class DateTimeUtil {
     /**
      * Parse date string.
      *
-     * @param localDate   the local date
+     * @param localDate the local date
      * @param formatRegex the format regex
      * @return the string
      * @author chen.cheng
@@ -116,7 +116,7 @@ public class DateTimeUtil {
     /**
      * Parse local date local date time.
      *
-     * @param dateString  the date string
+     * @param dateString the date string
      * @param formatRegex the format regex
      * @return the local date time
      * @author chen.cheng
@@ -130,7 +130,7 @@ public class DateTimeUtil {
     /**
      * Parse local date local date.
      *
-     * @param dateString  the date string
+     * @param dateString the date string
      * @param formatRegex the format regex
      * @return the local date
      * @author chen.cheng
@@ -144,7 +144,7 @@ public class DateTimeUtil {
     /**
      * Parse date string string.
      *
-     * @param dateString  the date string
+     * @param dateString the date string
      * @param formatRegex the format regex
      * @return the string
      * @author chen.cheng
@@ -158,9 +158,9 @@ public class DateTimeUtil {
     /**
      * Parse date string string.
      *
-     * @param dateString     the date string
+     * @param dateString the date string
      * @param srcFormatRegex the src format regex
-     * @param formatRegex    the format regex
+     * @param formatRegex the format regex
      * @return the string
      * @author chen.cheng
      */
@@ -173,9 +173,9 @@ public class DateTimeUtil {
     /**
      * Parse short date string string(yyyyMMdd).
      *
-     * @param dateString     the date string
+     * @param dateString the date string
      * @param srcFormatRegex the src format regex
-     * @param formatRegex    the format regex
+     * @param formatRegex the format regex
      * @return the string
      * @author chen.cheng
      */
@@ -189,8 +189,8 @@ public class DateTimeUtil {
      * Days of range list.
      *
      * @param startDate the start date
-     * @param endDate   the end date DateTimeUtil.daysOfRange("2020-05-06",
-     *                  "2020-09-02",DateFormatter.yyyy_MM_dd,DateFormatter.yyyyMMdd)
+     * @param endDate the end date DateTimeUtil.daysOfRange("2020-05-06",
+     *            "2020-09-02",DateFormatter.yyyy_MM_dd,DateFormatter.yyyyMMdd)
      * @return the list
      * @author chen.cheng
      */
@@ -201,7 +201,7 @@ public class DateTimeUtil {
     /**
      * Minus month string.
      *
-     * @param monthNum   the month num
+     * @param monthNum the month num
      * @param formatRegx the format regx
      * @return the string
      * @author chen.cheng
@@ -216,7 +216,7 @@ public class DateTimeUtil {
     /**
      * Minus month string
      *
-     * @param monthNum   month num
+     * @param monthNum month num
      * @param formatRegx format regx
      * @return the string
      * @author chen.cheng
@@ -239,7 +239,7 @@ public class DateTimeUtil {
     /**
      * Minus month string.
      *
-     * @param monthNum   the month num
+     * @param monthNum the month num
      * @param formatRegx the format regx
      * @return the string
      * @author chen.cheng
@@ -254,9 +254,9 @@ public class DateTimeUtil {
     /**
      * Date minus month string
      *
-     * @param date       date
+     * @param date date
      * @param formatRegx format regx
-     * @param monthNum   month num
+     * @param monthNum month num
      * @return the string
      * @author chen.cheng
      */
@@ -267,10 +267,10 @@ public class DateTimeUtil {
     /**
      * Date minus month string
      *
-     * @param date          date
+     * @param date date
      * @param srcFormatRegx src format regx
-     * @param formatRegx    format regx
-     * @param monthNum      month num
+     * @param formatRegx format regx
+     * @param monthNum month num
      * @return the string
      * @author chen.cheng
      */
@@ -284,7 +284,7 @@ public class DateTimeUtil {
     /**
      * Minus day string.
      *
-     * @param dayNum     the day num
+     * @param dayNum the day num
      * @param formatRegx the format regx
      * @return the string
      * @author chen.cheng
@@ -299,9 +299,9 @@ public class DateTimeUtil {
     /**
      * Days of range list.
      *
-     * @param startDate    the start date
-     * @param endDate      the end date
-     * @param paramFormat  the param format
+     * @param startDate the start date
+     * @param endDate the end date
+     * @param paramFormat the param format
      * @param resultFormat the result format
      * @return the list
      * @author chen.cheng
@@ -341,8 +341,8 @@ public class DateTimeUtil {
     /**
      * Days of range list.
      *
-     * @param startDate   the start date
-     * @param endDate     the end date
+     * @param startDate the start date
+     * @param endDate the end date
      * @param paramFormat the param format
      * @return the list
      * @author chen.cheng
@@ -363,7 +363,7 @@ public class DateTimeUtil {
     /**
      * Gets time step of time index.
      *
-     * @param tp  the tp
+     * @param tp the tp
      * @param gap the gap (now + gap minutes)
      * @return the time step of time index
      * @author chen.cheng
@@ -375,13 +375,14 @@ public class DateTimeUtil {
     /**
      * Get time step index of now integer.
      *
-     * @param tp         the tp
+     * @param tp the tp
      * @param toDateTime the to date time
      * @return the integer
      * @author chen.cheng
      */
     public static int getTimeStepIndexOfNow(Integer tp, LocalDateTime toDateTime) {
-        LocalDateTime zero = LocalDateTime.of(toDateTime.getYear(), toDateTime.getMonth(), toDateTime.getDayOfMonth(), 0, 0, 0);
+        LocalDateTime zero = LocalDateTime.of(toDateTime.getYear(), toDateTime.getMonth(), toDateTime.getDayOfMonth(),
+            0, 0, 0);
         Duration duration = Duration.between(zero, toDateTime);
         double minutes = duration.toMinutes();
         return (int) Math.floor(minutes / tp);
@@ -391,7 +392,7 @@ public class DateTimeUtil {
      * Gets time from step index. tp is min the format hh:mm:00
      *
      * @param stepIndex the step index
-     * @param tp        the tp
+     * @param tp the tp
      * @return the time from step index
      * @author chen.cheng
      */
@@ -406,7 +407,7 @@ public class DateTimeUtil {
      * Gets time from step index with out second.
      *
      * @param stepIndex the step index
-     * @param tp        the tp
+     * @param tp the tp
      * @return the time from step index with out second
      * @author chen.cheng
      */
@@ -420,7 +421,7 @@ public class DateTimeUtil {
     /**
      * Gets day of week.
      *
-     * @param date           the date
+     * @param date the date
      * @param paramFormatter the param formatter
      * @return the day of week
      * @author chen.cheng
@@ -475,7 +476,7 @@ public class DateTimeUtil {
     /**
      * Cal week of year integer.
      *
-     * @param date           the date
+     * @param date the date
      * @param paramFormatter the param formatter
      * @return the integer
      * @author chen.cheng
@@ -523,7 +524,9 @@ public class DateTimeUtil {
         firstTime = firstTime.plusDays(-(weekIndex * 7L));
         // 结束时间
         lastTime = lastTime.plusDays(-1);
-        return new String[]{firstTime.format(resultDateFormat), lastTime.format(resultDateFormat)};
+        return new String[] {
+            firstTime.format(resultDateFormat), lastTime.format(resultDateFormat)
+        };
     }
 
     public static String getFirstDayOfRecentYear(String dateFormat) {
@@ -534,7 +537,7 @@ public class DateTimeUtil {
         int recentYear = today.getYear() - 1;
 
         // 使用 TemporalAdjusters 来找到近一年的第一天
-        LocalDate localDate = LocalDate.of(recentYear, 1, 1).with(TemporalAdjusters.firstDayOfYear());
+        LocalDate localDate = LocalDate.of(recentYear, today.getMonth(), 1);
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateFormat);
         return localDate.format(formatter);
     }
@@ -551,6 +554,7 @@ public class DateTimeUtil {
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateFormat);
         return localDate.format(formatter);
     }
+
     public static String getFirstDayOfRecentYear() {
         return getFirstDayOfRecentYear(DateFormatter.yyyy_MM_dd);
     }