1、防水涂料应收计算修改

This commit is contained in:
llllon 2025-10-13 16:00:37 +08:00
parent 5835b02cf2
commit d568c97995
2 changed files with 69 additions and 54 deletions

View File

@ -87,8 +87,8 @@ public class WaterproofPaintAccountsReceivableJob implements IJob {
// 获取所有销售组织-客户组合
String bkgs = section.getBkgs();
String sql = "SELECT DISTINCT QYGS, FCUSTNAME, SQ AS FPROVINCE, CS AS FCITY, QY AS FDISTRICT, XSZZ " +
" FROM " + section.getYsdTable() + " WHERE QYGS IS NOT NULL AND FCUSTNAME IS NOT NULL";
String sql = "SELECT QYGS, FCUSTNAME, SQ AS FPROVINCE, CS AS FCITY, QY AS FDISTRICT, XSZZ " +
" FROM " + section.getYsdTable() + " WHERE QYGS IS NOT NULL AND FCUSTNAME IS NOT NULL GROUP BY FCUSTNAME,XSZZ";
// if (bkgs.equals("北新防水")){
// sql += " AND XSZZ !='北新防水工程(辽宁)有限公司' " +
// "AND XSZZ != '北新防水工程(四川)有限公司' AND F_SFNBJY ='是'";
@ -238,6 +238,9 @@ public class WaterproofPaintAccountsReceivableJob implements IJob {
// 扩展日期范围包含去年完整数据和当前时间范围
LocalDate extendedStartDate = monthEndDates.get(0).minusYears(1).withDayOfYear(1);
LocalDate extendedEndDate = monthEndDates.get(monthEndDates.size() - 1);
String format = extendedStartDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
String format2 = extendedEndDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
LOGGER.info("format:{};format2:{}",format,format2);
List<LocalDate> extendedMonthEndDates = getMonthEndDates(extendedStartDate, extendedEndDate);
// 批量查询应收单数据
Map<String, BigDecimal> ysData = batchQueryYSDData(section, saleOrgUnits, custNames, extendedMonthEndDates);
@ -274,17 +277,20 @@ public class WaterproofPaintAccountsReceivableJob implements IJob {
// 构建日期条件
StringBuilder dateCondition = new StringBuilder();
for (LocalDate date : monthEndDates) {
LocalDate monthStart = date.withDayOfMonth(1);
if (dateCondition.length() > 0) {
dateCondition.append(" OR ");
}
dateCondition.append("(DZRQ >= '")
.append(monthStart.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
.append(" 00:00:00' AND DZRQ <= '")
.append(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
.append(" 23:59:59')");
}
dateCondition.append("DZRQ >= '")
.append(monthEndDates.get(0).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))).append(" 00:00:00' AND DZRQ <= '")
.append(monthEndDates.get(monthEndDates.size()-1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))).append(" 23:59:59'");
// for (LocalDate date : monthEndDates) {
// LocalDate monthStart = date.withDayOfMonth(1);
// if (dateCondition.length() > 0) {
// dateCondition.append(" OR ");
// }
// dateCondition.append("(DZRQ >= '")
// .append(monthStart.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
// .append(" 00:00:00' AND DZRQ <= '")
// .append(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
// .append(" 23:59:59')");
// }
String bkgs = section.getBkgs();
String sql = "SELECT XSZZ, FCUSTNAME, DATE_FORMAT(DZRQ, '%Y-%m-%d') as BILL_DATE, SUM(SSJERMB) as TOTAL " +
@ -292,14 +298,14 @@ public class WaterproofPaintAccountsReceivableJob implements IJob {
" WHERE XSZZ IN (" + inSaleOrgs + ") " +
" AND FCUSTNAME IN (" + inCustNames + ") " +
" AND (" + dateCondition + ") ";
if (bkgs.equals("北新防水")){
sql += " AND XSZZ !='北新防水工程(辽宁)有限公司' " +
"AND XSZZ != '北新防水工程(四川)有限公司' AND F_SFNBJY ='是'";
}else {
sql += " AND F_SFNBJY ='是'";
}
// if (bkgs.equals("北新防水")){
// sql += " AND XSZZ !='北新防水工程(辽宁)有限公司' " +
// "AND XSZZ != '北新防水工程(四川)有限公司' AND F_SFNBJY ='是'";
// }else {
// sql += " AND F_SFNBJY ='是'";
// }
sql += " GROUP BY XSZZ, FCUSTNAME, DATE_FORMAT(DZRQ, '%Y-%m-%d')";
// LOGGER.info("应收单数据sql = " + sql);
List<RowMap> queryResults = DBSql.getMaps(sql);
for (RowMap row : queryResults) {
@ -328,17 +334,20 @@ public class WaterproofPaintAccountsReceivableJob implements IJob {
String inCustNames = buildInCondition(custNames);
StringBuilder dateCondition = new StringBuilder();
for (LocalDate date : monthEndDates) {
LocalDate monthStart = date.withDayOfMonth(1);
if (dateCondition.length() > 0) {
dateCondition.append(" OR ");
}
dateCondition.append("(FBILLDATE >= '")
.append(monthStart.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
.append(" 00:00:00' AND FBILLDATE <= '")
.append(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
.append(" 23:59:59')");
}
dateCondition.append("FBILLDATE >= '")
.append(monthEndDates.get(0).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))).append(" 00:00:00' AND FBILLDATE <= '")
.append(monthEndDates.get(monthEndDates.size()-1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))).append(" 23:59:59'");
// for (LocalDate date : monthEndDates) {
// LocalDate monthStart = date.withDayOfMonth(1);
// if (dateCondition.length() > 0) {
// dateCondition.append(" OR ");
// }
// dateCondition.append("(DZRQ >= '")
// .append(monthStart.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
// .append(" 00:00:00' AND DZRQ <= '")
// .append(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
// .append(" 23:59:59')");
// }
String bkgs = section.getBkgs();
String sql = "SELECT FSALEORGUNIT, FCUSTNAME, DATE_FORMAT(FBILLDATE, '%Y-%m-%d') as BILL_DATE, SUM(FSALEAMOUNTRMB) as TOTAL " +
@ -346,14 +355,15 @@ public class WaterproofPaintAccountsReceivableJob implements IJob {
" WHERE FSALEORGUNIT IN (" + inSaleOrgs + ") " +
" AND FCUSTNAME IN (" + inCustNames + ") " +
" AND (" + dateCondition + ") ";
if (bkgs.equals("北新防水")){
sql += " AND FSALEORGUNIT !='北新防水工程(辽宁)有限公司' " +
"AND FSALEORGUNIT != '北新防水工程(四川)有限公司' AND F_SFNBJY ='是'";
}else {
sql += " AND F_SFNBJY ='是'";
}
// if (bkgs.equals("北新防水")){
// sql += " AND FSALEORGUNIT !='北新防水工程(辽宁)有限公司' " +
// "AND FSALEORGUNIT != '北新防水工程(四川)有限公司' AND F_SFNBJY ='是'";
// }else {
// sql += " AND F_SFNBJY ='是'";
// }
sql += " GROUP BY FSALEORGUNIT, FCUSTNAME, DATE_FORMAT(FBILLDATE, '%Y-%m-%d')";
// LOGGER.info("收款单数据sql = " + sql);
List<RowMap> queryResults = DBSql.getMaps(sql);
for (RowMap row : queryResults) {
@ -382,17 +392,20 @@ public class WaterproofPaintAccountsReceivableJob implements IJob {
String inCustNames = buildInCondition(custNames);
StringBuilder dateCondition = new StringBuilder();
for (LocalDate date : monthEndDates) {
LocalDate monthStart = date.withDayOfMonth(1);
if (dateCondition.length() > 0) {
dateCondition.append(" OR ");
}
dateCondition.append("(FBILLDATE >= '")
.append(monthStart.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
.append(" 00:00:00' AND FBILLDATE <= '")
.append(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
.append(" 23:59:59')");
}
dateCondition.append("FBILLDATE >= '")
.append(monthEndDates.get(0).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))).append(" 00:00:00' AND FBILLDATE <= '")
.append(monthEndDates.get(monthEndDates.size()-1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))).append(" 23:59:59'");
// for (LocalDate date : monthEndDates) {
// LocalDate monthStart = date.withDayOfMonth(1);
// if (dateCondition.length() > 0) {
// dateCondition.append(" OR ");
// }
// dateCondition.append("(DZRQ >= '")
// .append(monthStart.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
// .append(" 00:00:00' AND DZRQ <= '")
// .append(date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))
// .append(" 23:59:59')");
// }
String bkgs = section.getBkgs();
String sql = "SELECT FSALEORGUNIT, FCUSTNAME, DATE_FORMAT(FBILLDATE, '%Y-%m-%d') as BILL_DATE, SUM(FSALEAMOUNTRMB) as TOTAL " +
@ -400,14 +413,15 @@ public class WaterproofPaintAccountsReceivableJob implements IJob {
" WHERE FSALEORGUNIT IN (" + inSaleOrgs + ") " +
" AND FCUSTNAME IN (" + inCustNames + ") " +
" AND (" + dateCondition + ") ";
if (bkgs.equals("北新防水")){
sql += " AND FSALEORGUNIT !='北新防水工程(辽宁)有限公司' " +
"AND FSALEORGUNIT != '北新防水工程(四川)有限公司' AND F_SFNBJY ='是'";
}else {
sql += " AND F_SFNBJY ='是'";
}
// if (bkgs.equals("北新防水")){
// sql += " AND FSALEORGUNIT !='北新防水工程(辽宁)有限公司' " +
// "AND FSALEORGUNIT != '北新防水工程(四川)有限公司' AND F_SFNBJY ='是'";
// }else {
// sql += " AND F_SFNBJY ='是'";
// }
sql += " GROUP BY FSALEORGUNIT, FCUSTNAME, DATE_FORMAT(FBILLDATE, '%Y-%m-%d')";
// LOGGER.info("收款退款单数据sql = " + sql);
List<RowMap> queryResults = DBSql.getMaps(sql);
for (RowMap row : queryResults) {
@ -444,6 +458,7 @@ public class WaterproofPaintAccountsReceivableJob implements IJob {
" AND KH IN (" + inCustNames + ") " +
" AND RQ IN (" + inDates + ")";
// LOGGER.info("历史余额数据sql = " + sql);
List<RowMap> queryResults = DBSql.getMaps(sql);
for (RowMap row : queryResults) {