施工产值增加第N周
This commit is contained in:
@ -41,6 +41,12 @@ public class OutConstructionValueRangeVo implements Serializable {
|
|||||||
@ExcelProperty(value = "项目ID")
|
@ExcelProperty(value = "项目ID")
|
||||||
private Long projectId;
|
private Long projectId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 第N周
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "第N周")
|
||||||
|
private int week;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开始日期
|
* 开始日期
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -31,15 +31,15 @@ import org.dromara.progress.service.IPgsProgressPlanDetailService;
|
|||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.context.event.EventListener;
|
import org.springframework.context.event.EventListener;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.time.DayOfWeek;
|
import java.time.DayOfWeek;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.temporal.TemporalAdjusters;
|
import java.time.temporal.TemporalAdjusters;
|
||||||
import java.util.Collection;
|
import java.time.temporal.WeekFields;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 施工产值范围Service业务层处理
|
* 施工产值范围Service业务层处理
|
||||||
@ -61,6 +61,22 @@ public class OutConstructionValueRangeServiceImpl extends ServiceImpl<OutConstru
|
|||||||
@Resource
|
@Resource
|
||||||
private IPgsProgressPlanDetailService progressPlanDetailService;
|
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) {
|
public TableDataInfo<OutConstructionValueRangeVo> queryPageList(OutConstructionValueRangeBo bo, PageQuery pageQuery) {
|
||||||
LambdaQueryWrapper<OutConstructionValueRange> lqw = buildQueryWrapper(bo);
|
LambdaQueryWrapper<OutConstructionValueRange> lqw = buildQueryWrapper(bo);
|
||||||
Page<OutConstructionValueRangeVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
Page<OutConstructionValueRangeVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||||
|
//增加第N周
|
||||||
|
result.getRecords().forEach(item -> {
|
||||||
|
item.setWeek(getCurrentWeekOfYear(item.getStartDate().toString()));
|
||||||
|
});
|
||||||
return TableDataInfo.build(result);
|
return TableDataInfo.build(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user