|
|
|
@ -324,6 +324,16 @@ public class OutEfcodeCpPlanServiceImpl implements IOutEfcodeCpPlanService { |
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getChannelNo()), EfcodeCpPlan::getChannelNo, bo.getChannelNo()); |
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getOutSerialNo()), EfcodeCpPlan::getOutSerialNo, bo.getOutSerialNo()); |
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getTaskId()), EfcodeCpPlan::getTaskId, bo.getTaskId()); |
|
|
|
// 关键字:企业名称 / 执法事项 / 执法单位 / 执法人员
|
|
|
|
if (StringUtils.isNotBlank(bo.getSearchValue())) { |
|
|
|
String sv = bo.getSearchValue(); |
|
|
|
lqw.and(w -> w |
|
|
|
.like(EfcodeCpPlan::getEnterpriseName, sv) |
|
|
|
.or().like(EfcodeCpPlan::getEnforceContent, sv) |
|
|
|
.or().like(EfcodeCpPlan::getBureauDeptName, sv) |
|
|
|
.or().like(EfcodeCpPlan::getEnforceUserNames, sv) |
|
|
|
); |
|
|
|
} |
|
|
|
// 本月/本季/本年/自定义月份(按 plan_date)
|
|
|
|
applyPlanDateFilter(lqw, bo.getDateType(), bo.getDateSearch()); |
|
|
|
return lqw; |
|
|
|
@ -331,30 +341,36 @@ public class OutEfcodeCpPlanServiceImpl implements IOutEfcodeCpPlanService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 计划日期筛选:1=本月 2=本季 3=本年;dateSearch=YYYY-MM 为自定义月份 |
|
|
|
* <p>用 Java 算区间再 ge/le,避免 apply+DATE_FORMAT 在部分环境下不生效。</p> |
|
|
|
*/ |
|
|
|
private void applyPlanDateFilter(LambdaQueryWrapper<EfcodeCpPlan> lqw, Integer dateType, String dateSearch) { |
|
|
|
LocalDate today = LocalDate.now(); |
|
|
|
LocalDate start = null; |
|
|
|
LocalDate end = null; |
|
|
|
if (dateType != null) { |
|
|
|
if (dateType == 1) { |
|
|
|
lqw.apply("DATE_FORMAT(plan_date, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m')"); |
|
|
|
start = today.withDayOfMonth(1); |
|
|
|
end = today.withDayOfMonth(today.lengthOfMonth()); |
|
|
|
} else if (dateType == 2) { |
|
|
|
lqw.apply("DATE_FORMAT(plan_date, '%Y-%m') >= CONCAT(YEAR(CURDATE()), '-', " + |
|
|
|
"CASE WHEN QUARTER(CURDATE()) IN (1) THEN '01' " + |
|
|
|
"WHEN QUARTER(CURDATE()) IN (2) THEN '04' " + |
|
|
|
"WHEN QUARTER(CURDATE()) IN (3) THEN '07' " + |
|
|
|
"ELSE '10' END) " + |
|
|
|
"and DATE_FORMAT(plan_date, '%Y-%m') <= CONCAT(YEAR(CURDATE()), '-', " + |
|
|
|
"CASE " + |
|
|
|
"WHEN QUARTER(CURDATE()) IN (1) THEN '03' " + |
|
|
|
"WHEN QUARTER(CURDATE()) IN (2) THEN '06' " + |
|
|
|
"WHEN QUARTER(CURDATE()) IN (3) THEN '09' " + |
|
|
|
"ELSE '12' " + |
|
|
|
"END)"); |
|
|
|
int firstMonth = ((today.getMonthValue() - 1) / 3) * 3 + 1; |
|
|
|
start = LocalDate.of(today.getYear(), firstMonth, 1); |
|
|
|
end = start.plusMonths(3).minusDays(1); |
|
|
|
} else if (dateType == 3) { |
|
|
|
lqw.apply("DATE_FORMAT(plan_date, '%Y') = DATE_FORMAT(CURDATE(), '%Y')"); |
|
|
|
start = LocalDate.of(today.getYear(), 1, 1); |
|
|
|
end = LocalDate.of(today.getYear(), 12, 31); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(dateSearch)) { |
|
|
|
lqw.apply("DATE_FORMAT(plan_date, '%Y-%m') = {0}", dateSearch); |
|
|
|
if (StringUtils.isNotBlank(dateSearch) && dateSearch.matches("\\d{4}-\\d{2}")) { |
|
|
|
String[] parts = dateSearch.split("-"); |
|
|
|
int year = Integer.parseInt(parts[0]); |
|
|
|
int month = Integer.parseInt(parts[1]); |
|
|
|
start = LocalDate.of(year, month, 1); |
|
|
|
end = start.withDayOfMonth(start.lengthOfMonth()); |
|
|
|
} |
|
|
|
if (start != null && end != null) { |
|
|
|
lqw.ge(EfcodeCpPlan::getPlanDate, java.sql.Date.valueOf(start)); |
|
|
|
lqw.le(EfcodeCpPlan::getPlanDate, java.sql.Date.valueOf(end)); |
|
|
|
log.info("[计划筛选] dateType={}, dateSearch={}, range={} ~ {}", dateType, dateSearch, start, end); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|