施工产值增加第N周

This commit is contained in:
2025-10-28 11:57:14 +08:00
parent d4301da0ec
commit 7e47b8a74f
2 changed files with 29 additions and 3 deletions

View File

@ -41,6 +41,12 @@ public class OutConstructionValueRangeVo implements Serializable {
@ExcelProperty(value = "项目ID")
private Long projectId;
/**
* 第N周
*/
@ExcelProperty(value = "第N周")
private int week;
/**
* 开始日期
*/

View File

@ -31,15 +31,15 @@ import org.dromara.progress.service.IPgsProgressPlanDetailService;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;
import java.time.format.DateTimeFormatter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.temporal.TemporalAdjusters;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.time.temporal.WeekFields;
import java.util.*;
/**
* 施工产值范围Service业务层处理
@ -61,6 +61,22 @@ public class OutConstructionValueRangeServiceImpl extends ServiceImpl<OutConstru
@Resource
private IPgsProgressPlanDetailService progressPlanDetailService;
/**
* 获取指定日期所在的周数(根据中国周规则)
*
* @param dateStr 日期字符串格式yyyy-MM-dd
* @return 指定日期所在的周数1-52
*/
public Integer getCurrentWeekOfYear(String dateStr) {
// 解析为 LocalDate可根据需要调整日期格式
LocalDate specifiedDate = LocalDate.parse(dateStr, DateTimeFormatter.ISO_LOCAL_DATE);
// 2. 定义周规则(可选,默认使用系统区域,也可指定)
// 示例2中国规则周一为第一天第一周包含1月1日即可
WeekFields chinaWeekFields = WeekFields.of(Locale.CHINA);
// 3. 获取指定时间在当年的周数(根据需要选择周规则)
return specifiedDate.get(chinaWeekFields.weekOfYear());
}
/**
* 查询施工产值范围
*
@ -87,6 +103,10 @@ public class OutConstructionValueRangeServiceImpl extends ServiceImpl<OutConstru
public TableDataInfo<OutConstructionValueRangeVo> queryPageList(OutConstructionValueRangeBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<OutConstructionValueRange> lqw = buildQueryWrapper(bo);
Page<OutConstructionValueRangeVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
//增加第N周
result.getRecords().forEach(item -> {
item.setWeek(getCurrentWeekOfYear(item.getStartDate().toString()));
});
return TableDataInfo.build(result);
}