parent
389ea41304
commit
e7910c9124
|
@ -24,11 +24,6 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
public class BillReceivableReportListDataPlugin extends AbstractReportListDataPlugin {
|
||||
|
||||
@Override
|
||||
public ReportQueryParam getQueryParam() {
|
||||
return super.getQueryParam();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSet query(ReportQueryParam reportQueryParam, Object o) throws Throwable {
|
||||
|
||||
|
@ -283,24 +278,6 @@ public class BillReceivableReportListDataPlugin extends AbstractReportListDataPl
|
|||
.collect(Collectors.joining(","));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定日期的年月字符串
|
||||
*
|
||||
* @param date 输入的日期对象,可以为null
|
||||
* @return 返回格式为"yyyy-MM"的年月字符串,如果输入为null则返回null
|
||||
*/
|
||||
private String getYearMonth(Object date) {
|
||||
if (date == null) {
|
||||
return null;
|
||||
}
|
||||
java.util.Calendar cal = java.util.Calendar.getInstance();
|
||||
cal.setTime((java.util.Date) date);
|
||||
// 获取年份和月份
|
||||
int year = cal.get(java.util.Calendar.YEAR);
|
||||
int month = cal.get(java.util.Calendar.MONTH) + 1; // Calendar中的月份从0开始,需要加1
|
||||
// 构造该月的第一天和最后一天
|
||||
return String.format("%04d-%02d", year, month);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -353,127 +330,6 @@ public class BillReceivableReportListDataPlugin extends AbstractReportListDataPl
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取指定日期的前一天
|
||||
*
|
||||
* @param dateStr 输入的日期字符串
|
||||
* @return 返回前一天的日期字符串,如果解析失败则返回原字符串
|
||||
*/
|
||||
private String getPrevDay(String dateStr) {
|
||||
try {
|
||||
// 根据输入格式自动判断
|
||||
String pattern = getInputDateFormatPattern(dateStr);
|
||||
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(pattern);
|
||||
|
||||
java.util.Date date = sdf.parse(dateStr);
|
||||
java.util.Calendar cal = java.util.Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
// 计算前一天日期
|
||||
cal.add(java.util.Calendar.DAY_OF_MONTH, -1);
|
||||
|
||||
return sdf.format(cal.getTime());
|
||||
} catch (Exception e) {
|
||||
return dateStr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取指定日期的后一天
|
||||
*
|
||||
* @param dateStr 输入的日期字符串
|
||||
* @return 返回指定日期的后一天日期字符串,如果解析失败则返回原字符串
|
||||
*/
|
||||
private String getNextDay(String dateStr) {
|
||||
try {
|
||||
// 根据输入格式自动判断日期格式模式
|
||||
String pattern = getInputDateFormatPattern(dateStr);
|
||||
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(pattern);
|
||||
|
||||
// 解析日期并加一天
|
||||
java.util.Date date = sdf.parse(dateStr);
|
||||
java.util.Calendar cal = java.util.Calendar.getInstance();
|
||||
cal.setTime(date);
|
||||
cal.add(java.util.Calendar.DAY_OF_MONTH, 1);
|
||||
|
||||
return sdf.format(cal.getTime());
|
||||
} catch (Exception e) {
|
||||
return dateStr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 计算指定月份的最后一天
|
||||
*
|
||||
* @param yearMonth 年月字符串,格式为 "yyyy-MM"
|
||||
* @return 指定月份的最后一天,格式为 "yyyy-MM-dd"
|
||||
*/
|
||||
private String getMonthEndDateString(String yearMonth) {
|
||||
try {
|
||||
if (yearMonth == null || yearMonth.isEmpty()) {
|
||||
return yearMonth;
|
||||
}
|
||||
|
||||
// 解析年月字符串
|
||||
String[] parts = yearMonth.split("-");
|
||||
int year = Integer.parseInt(parts[0]);
|
||||
int month = Integer.parseInt(parts[1]);
|
||||
|
||||
// 计算下一月的第一天,然后减去一天得到当前月的最后一天
|
||||
java.util.Calendar cal = java.util.Calendar.getInstance();
|
||||
cal.set(year, month - 1, 1); // month在Calendar中是从0开始的
|
||||
cal.add(java.util.Calendar.MONTH, 1);
|
||||
cal.add(java.util.Calendar.DAY_OF_MONTH, -1);
|
||||
|
||||
int lastDay = cal.get(java.util.Calendar.DAY_OF_MONTH);
|
||||
return String.format("%04d-%02d-%02d", year, month, lastDay);
|
||||
} catch (Exception e) {
|
||||
// 出错时返回原日期加上-31作为默认值
|
||||
return yearMonth + "-31";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据输入字符串判断日期格式
|
||||
*
|
||||
* @param dateStr 日期字符串
|
||||
* @return 对应的日期格式模式
|
||||
*/
|
||||
private String getInputDateFormatPattern(String dateStr) {
|
||||
if (dateStr == null || dateStr.isEmpty()) {
|
||||
return "yyyy-MM";
|
||||
}
|
||||
|
||||
// 根据字符串特征判断格式
|
||||
if (dateStr.contains(":")) {
|
||||
// 包含时间部分
|
||||
if (dateStr.contains(".")) {
|
||||
// 包含毫秒
|
||||
return "yyyy-MM-dd HH:mm:ss.SSS";
|
||||
} else {
|
||||
// 不包含毫秒
|
||||
return "yyyy-MM-dd HH:mm:ss";
|
||||
}
|
||||
} else if (dateStr.contains("-")) {
|
||||
// 只包含日期部分
|
||||
String[] parts = dateStr.split("-");
|
||||
if (parts.length == 3) {
|
||||
// yyyy-MM-dd格式
|
||||
return "yyyy-MM-dd";
|
||||
} else {
|
||||
// yyyy-MM格式
|
||||
return "yyyy-MM";
|
||||
}
|
||||
} else {
|
||||
// 默认格式
|
||||
return "yyyy-MM";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//贴现
|
||||
private DataSet getDisCountData(Object sDate, Object eDate, Object sMonthDate, Object eMonthDate) {
|
||||
StringBuilder sql = new StringBuilder();
|
||||
|
|
Loading…
Reference in New Issue