1、销售sql修改
This commit is contained in:
parent
5a90a8e12b
commit
d2a02fdf56
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -9,12 +9,14 @@ import com.awspaas.user.apps.bnbm.datalinkup.entity.DateRange;
|
||||
import com.awspaas.user.apps.bnbm.datalinkup.service.DataSummaryService;
|
||||
import com.awspaas.user.apps.bnbm.datalinkup.util.PurchaseUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.docx4j.org.apache.poi.util.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.YearMonth;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@ -74,27 +76,27 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
}
|
||||
|
||||
// 获取物料分类列表(带缓存)
|
||||
List<String> distinctList = getDistinctMaterialList();
|
||||
// List<String> distinctList = getDistinctMaterialList();
|
||||
|
||||
if (dateRange == null || dateRange.getStartDate() == null || dateRange.getEndDate() == null) {
|
||||
LOGGER.info("未提供有效时间范围,按当前日期计算");
|
||||
String startDate = LocalDate.now().minusDays(1).format(DateTimeFormatter.ofPattern("yyyy-mm-dd"));
|
||||
// 1. 计算并保存各板块物料采购总额、总量、单价(按月存储)
|
||||
// monthlyMaterialSummaryBySegment(year, month, yearMonth, yearLastMonth, lastYearMonth, bkgs, distinctList);
|
||||
newmonthlyMaterialSummaryBySegment(startDate, bkgs, distinctList);
|
||||
newmonthlyMaterialSummaryBySegment(startDate, bkgs);
|
||||
|
||||
// 2. 根据年月汇总板块、基地、年月、当期、上期、同期数据
|
||||
// monthlyBaseSummaryBySegment(year, month, yearMonth, yearLastMonth, lastYearMonth, bkgs, distinctList);
|
||||
newmonthlyBaseSummaryBySegment(startDate, bkgs, distinctList);
|
||||
newmonthlyBaseSummaryBySegment(startDate, bkgs);
|
||||
|
||||
// 3. 计算并保存各板块物料采购总额、总量、单价(按日存储)
|
||||
// dailyMaterialSummaryBySegment(year, month, day, currentDate, bkgs, distinctList);
|
||||
newdailyMaterialSummaryBySegment(startDate, bkgs, distinctList);
|
||||
newdailyMaterialSummaryBySegment(startDate, bkgs);
|
||||
|
||||
// 4. 根据日期、入库单号、物料名称分页查询 日期、入库单号、物料编码、物料名称、规格型号、
|
||||
// (汇总)入库数量、单位、入库单价、(汇总)入库金额、供应商、订单编号、库存数
|
||||
// dailyWarehousingSummary(year, month, day, currentDate, bkgs, distinctList);
|
||||
newdailyWarehousingSummary(startDate, bkgs, distinctList);
|
||||
newdailyWarehousingSummary(startDate, bkgs);
|
||||
|
||||
// calculateForCurrentDate(bkgs, distinctList);
|
||||
} else {
|
||||
@ -102,14 +104,14 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
dateRange.getStartDate(), dateRange.getEndDate());
|
||||
String startDate = DATE_FORMAT.format(dateRange.getStartDate());
|
||||
//计算并保存各板块物料采购总额、总量、单价(按月存储)
|
||||
newmonthlyMaterialSummaryBySegment(startDate, bkgs, distinctList);
|
||||
newmonthlyMaterialSummaryBySegment(startDate, bkgs);
|
||||
//根据年月汇总板块、基地、年月、当期、上期、同期数据
|
||||
newmonthlyBaseSummaryBySegment(startDate, bkgs, distinctList);
|
||||
newmonthlyBaseSummaryBySegment(startDate, bkgs);
|
||||
//计算并保存各板块物料采购总额、总量、单价(按日存储)
|
||||
newdailyMaterialSummaryBySegment(startDate, bkgs, distinctList);
|
||||
newdailyMaterialSummaryBySegment(startDate, bkgs);
|
||||
// 4. 根据日期、入库单号、物料名称分页查询 日期、入库单号、物料编码、物料名称、规格型号、
|
||||
// (汇总)入库数量、单位、入库单价、(汇总)入库金额、供应商、订单编号、库存数
|
||||
newdailyWarehousingSummary(startDate, bkgs, distinctList);
|
||||
newdailyWarehousingSummary(startDate, bkgs);
|
||||
|
||||
// 计算月度维度数据(按月遍历)
|
||||
// calculateMonthlyData(dateRange, bkgs, distinctList);
|
||||
@ -130,9 +132,9 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
* 根据日期、入库单号、物料名称分页查询 日期、入库单号、物料编码、物料名称、规格型号、
|
||||
* @param startDate
|
||||
* @param bkgs
|
||||
* @param distinctList
|
||||
* @param
|
||||
*/
|
||||
private void newdailyWarehousingSummary(String startDate, String bkgs, List<String> distinctList) {
|
||||
private void newdailyWarehousingSummary(String startDate, String bkgs) {
|
||||
LOGGER.info("开始计算{}入库明细日度汇总数据,板块公司:{}", startDate, bkgs);
|
||||
|
||||
try {
|
||||
@ -182,20 +184,36 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
detailBO.set("WLMC", wlmc); // 物料名称
|
||||
detailBO.set("GGXH", row.getString("GGXH")); // 规格型号
|
||||
detailBO.set("GC", row.getString("SLGC")); // 收料工厂
|
||||
detailBO.set("RKSL", row.getDouble("RKSL")); // 入库数量
|
||||
|
||||
// 处理入库数量,防止空值
|
||||
Double rksl = row.getDouble("RKSL");
|
||||
detailBO.set("RKSL", rksl != null ? rksl : 0.0); // 入库数量
|
||||
|
||||
detailBO.set("DW", row.getString("JLDW")); // 单位
|
||||
if ("泰山石膏".equals(bkgs)) {
|
||||
detailBO.set("RKDJ", row.getDouble("HSDJHYF")); // 入库单价(含税单价含运费)
|
||||
detailBO.set("RKJE", row.getDouble("DHJE")); // 入库金额(金额含运费)
|
||||
}else {
|
||||
detailBO.set("RKDJ", row.getDouble("HSDJHYF")); // 入库单价(含税单价含运费)
|
||||
detailBO.set("RKJE", row.getDouble("JSHJHYF")); // 入库金额(金额含运费)
|
||||
|
||||
// 处理单价和金额,添加除零检查
|
||||
Double hsdjhyf = row.getDouble("HSDJHYF");
|
||||
double rkdj = 0.0;
|
||||
if (hsdjhyf != null && hsdjhyf != 0 && rksl != null && rksl != 0) {
|
||||
rkdj = hsdjhyf / rksl;
|
||||
}
|
||||
detailBO.set("RKDJ", rkdj); // 入库单价
|
||||
|
||||
if ("泰山石膏".equals(bkgs)) {
|
||||
Double dhje = row.getDouble("DHJE");
|
||||
detailBO.set("RKJE", dhje != null ? dhje : 0.0); // 入库金额
|
||||
} else {
|
||||
Double jshjhyf = row.getDouble("JSHJHYF");
|
||||
detailBO.set("RKJE", jshjhyf != null ? jshjhyf : 0.0); // 入库金额
|
||||
}
|
||||
|
||||
detailBO.set("GYS", row.getString("GYSNAME")); // 供应商
|
||||
detailBO.set("DDBH", row.getString("CGDDH")); // 订单编号
|
||||
detailBO.set("KCS", 0.00); // 库存数(默认为0,需后续计算)
|
||||
detailBO.set("BKGS", bkgs); // 板块公司
|
||||
String yearmonth = String.format("%04d-%02d", row.getString("YEARMONTH"));
|
||||
LocalDate date = LocalDate.parse(startDate);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
||||
String yearmonth = date.format(formatter);
|
||||
detailBO.set("YEARMONTH", yearmonth); // 年月
|
||||
bos.add(detailBO);
|
||||
}
|
||||
@ -220,13 +238,12 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
* 计算并保存各板块物料采购总额、总量、单价(按日存储)
|
||||
* @param startDate
|
||||
* @param bkgs
|
||||
* @param distinctList
|
||||
* @param
|
||||
*/
|
||||
private void newdailyMaterialSummaryBySegment(String startDate, String bkgs, List<String> distinctList) {
|
||||
private void newdailyMaterialSummaryBySegment(String startDate, String bkgs) {
|
||||
try {
|
||||
// 格式化日期字符串 (yyyy-MM-dd)
|
||||
LOGGER.info("开始计算{}物料采购日度汇总数据,板块公司:{}", startDate, bkgs);
|
||||
|
||||
// 1. 删除该日期已存在的汇总数据
|
||||
String deleteSql = "DELETE FROM " + PROCUREMENT_DETAILS_YEAR_MONTH_DAY +
|
||||
" WHERE BKGS = ? AND RQ >= ?";
|
||||
@ -261,13 +278,19 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")) {
|
||||
double adjustedQuantity = safeTotalQuantity / 1000;
|
||||
summaryBO.set("CGZL", adjustedQuantity);
|
||||
// 添加除零检查
|
||||
if (safeTotalAmount != 0 && adjustedQuantity != 0) {
|
||||
avgPrice = safeTotalAmount / adjustedQuantity;
|
||||
} else {
|
||||
avgPrice = 0.0;
|
||||
}
|
||||
} else {
|
||||
summaryBO.set("CGZL", safeTotalQuantity);
|
||||
// 添加除零检查
|
||||
if (safeTotalAmount != 0 && safeTotalQuantity != 0) {
|
||||
avgPrice = safeTotalAmount / safeTotalQuantity;
|
||||
} else {
|
||||
avgPrice = 0.0;
|
||||
}
|
||||
}
|
||||
summaryBO.set("CGZE", safeTotalAmount);
|
||||
@ -277,13 +300,19 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")) {
|
||||
double adjustedQuantity = safeTotalQuantity / 1000;
|
||||
summaryBO.set("CGZL", adjustedQuantity);
|
||||
// 添加除零检查
|
||||
if (safeTotalAmount != 0 && adjustedQuantity != 0) {
|
||||
avgPrice = safeTotalAmount / adjustedQuantity;
|
||||
} else {
|
||||
avgPrice = 0.0;
|
||||
}
|
||||
} else {
|
||||
summaryBO.set("CGZL", safeTotalQuantity);
|
||||
// 添加除零检查
|
||||
if (safeTotalAmount != 0 && safeTotalQuantity != 0) {
|
||||
avgPrice = safeTotalAmount / safeTotalQuantity;
|
||||
} else {
|
||||
avgPrice = 0.0;
|
||||
}
|
||||
}
|
||||
summaryBO.set("CGZE", safeTotalAmount);
|
||||
@ -307,17 +336,19 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
* 根据年月汇总板块、基地、年月、当期、上期、同期数据
|
||||
* @param startDate
|
||||
* @param bkgs
|
||||
* @param distinctList
|
||||
* @param
|
||||
*/
|
||||
private void newmonthlyBaseSummaryBySegment(String startDate, String bkgs, List<String> distinctList) {
|
||||
private void newmonthlyBaseSummaryBySegment(String startDate, String bkgs) {
|
||||
try {
|
||||
LOGGER.info("开始计算{}物料采购各基地月度汇总数据,板块公司:{}", startDate, bkgs);
|
||||
|
||||
LocalDate date = LocalDate.parse(startDate);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
||||
String yearMonth = date.format(formatter);
|
||||
// 1. 删除该月份已存在的汇总数据(避免重复)
|
||||
String deleteSql = "DELETE FROM " + JD_PROCUREMENT_DETAILS_YEAR_MONTH +
|
||||
" WHERE BKGS = ? AND YEARMONTH >= ?";
|
||||
int update = DBSql.update(deleteSql, new Object[]{bkgs, startDate});
|
||||
LOGGER.info("采购_基地_年月采购明细:{}物料采购月度汇总数据,板块公司:{},删除了{}条数据", startDate, bkgs, update);
|
||||
int update = DBSql.update(deleteSql, new Object[]{bkgs, yearMonth});
|
||||
LOGGER.info("采购_基地_年月采购明细:{}年月物料采购月度汇总数据,板块公司:{},删除了{}条数据", yearMonth, bkgs, update);
|
||||
|
||||
String currentMonthSql = "SELECT c.BKGS,c.DJRQ,c.YEARMONTH,c.WLMC,c.SLGC,c.tstotalAmount,c.lptotalAmount,c.totalQuantity," +
|
||||
" ly.tstotalAmount AS ly_tstotalAmount,ly.lptotalAmount AS ly_lptotalAmount,ly.totalQuantity AS ly_totalQuantity," +
|
||||
@ -356,12 +387,14 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
String base = currentMonthRow.getString("SLGC");
|
||||
String wlmc = currentMonthRow.getString("WLMC");
|
||||
String bkgs1 = currentMonthRow.getString("BKGS");
|
||||
String yearMonth = currentMonthRow.getString("YEARMONTH");
|
||||
YearMonth yearMonths = YearMonth.parse(currentMonthRow.getString("YEARMONTH"), DateTimeFormatter.ofPattern("yyyyMM"));
|
||||
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
||||
String yearmonth1 = yearMonths.format(outputFormatter);
|
||||
BO summaryBO = new BO();
|
||||
summaryBO.set("BKGS", bkgs1);
|
||||
summaryBO.set("JD", base);
|
||||
summaryBO.set("WLMC",wlmc);
|
||||
summaryBO.set("YEARMONTH", yearMonth);
|
||||
summaryBO.set("YEARMONTH", yearmonth1);
|
||||
double avgPrice = 0.0;
|
||||
double lyavgPrice = 0.0;
|
||||
double lmavgPrice = 0.0;
|
||||
@ -373,19 +406,37 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
double lytotalQuantity = 0.00;
|
||||
double lmtotalQuantity = 0.00;
|
||||
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")) {
|
||||
totalQuantity = BigDecimal.valueOf(currentMonthRow.getDouble("totalQuantity"))
|
||||
double Quantity = currentMonthRow.getDouble("totalQuantity")==0.0?0.00:currentMonthRow.getDouble("totalQuantity");
|
||||
if (Quantity==0.0){
|
||||
totalQuantity=0.0;
|
||||
}else {
|
||||
totalQuantity = BigDecimal.valueOf(Quantity)
|
||||
.divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
lytotalQuantity = BigDecimal.valueOf(currentMonthRow.getDouble("ly_totalQuantity"))
|
||||
}
|
||||
double lyQuantity = currentMonthRow.getDouble("ly_totalQuantity")==0.0?0.00:currentMonthRow.getDouble("ly_totalQuantity");
|
||||
if (lyQuantity==0.0){
|
||||
lytotalQuantity = 0.0;
|
||||
}else {
|
||||
lytotalQuantity = BigDecimal.valueOf(lyQuantity)
|
||||
.divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
lmtotalQuantity = BigDecimal.valueOf(currentMonthRow.getDouble("lm_totalQuantity"))
|
||||
}
|
||||
double lmQuantity = currentMonthRow.getDouble("lm_totalQuantity")==0.0?0.00:currentMonthRow.getDouble("lm_totalQuantity");
|
||||
if (lmQuantity==0.0){
|
||||
lmQuantity = 0.0;
|
||||
}else {
|
||||
lmtotalQuantity = BigDecimal.valueOf(lmQuantity)
|
||||
.divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
}
|
||||
summaryBO.set("CGZL", totalQuantity);
|
||||
summaryBO.set("TQCGZL", lytotalQuantity);
|
||||
summaryBO.set("SQCGZL", lmtotalQuantity);
|
||||
}else {
|
||||
totalQuantity = BigDecimal.valueOf(currentMonthRow.getDouble("totalQuantity")).doubleValue();
|
||||
lytotalQuantity = BigDecimal.valueOf(currentMonthRow.getDouble("ly_totalQuantity")).doubleValue();
|
||||
lmtotalQuantity = BigDecimal.valueOf(currentMonthRow.getDouble("lm_totalQuantity")).doubleValue();
|
||||
double Quantity = currentMonthRow.getDouble("totalQuantity")==0.0?0.00:currentMonthRow.getDouble("totalQuantity");
|
||||
totalQuantity = BigDecimal.valueOf(Quantity).doubleValue();
|
||||
double lyQuantity = currentMonthRow.getDouble("ly_totalQuantity")==0.0?0.00:currentMonthRow.getDouble("ly_totalQuantity");
|
||||
lytotalQuantity = BigDecimal.valueOf(lyQuantity).doubleValue();
|
||||
double lmQuantity = currentMonthRow.getDouble("lm_totalQuantity")==0.0?0.00:currentMonthRow.getDouble("lm_totalQuantity");
|
||||
lmtotalQuantity = BigDecimal.valueOf(lmQuantity).doubleValue();
|
||||
summaryBO.set("CGZL", totalQuantity);
|
||||
summaryBO.set("TQCGZL", lytotalQuantity);
|
||||
summaryBO.set("SQCGZL", lmtotalQuantity);
|
||||
@ -399,15 +450,15 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
}
|
||||
//同期
|
||||
if (lytotalAmount != 0 && lytotalQuantity != 0) {
|
||||
lyavgPrice = BigDecimal.valueOf(totalAmount)
|
||||
.divide(BigDecimal.valueOf(totalQuantity), 2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
lyavgPrice = BigDecimal.valueOf(lytotalAmount)
|
||||
.divide(BigDecimal.valueOf(lytotalQuantity), 2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
} else {
|
||||
lyavgPrice = 0;
|
||||
}
|
||||
//上期
|
||||
if (lmtotalAmount != 0 && lmtotalQuantity != 0) {
|
||||
lmavgPrice = BigDecimal.valueOf(totalAmount)
|
||||
.divide(BigDecimal.valueOf(totalQuantity), 2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
lmavgPrice = BigDecimal.valueOf(lmtotalAmount)
|
||||
.divide(BigDecimal.valueOf(lmtotalQuantity), 2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
} else {
|
||||
lmavgPrice = 0;
|
||||
}
|
||||
@ -415,26 +466,44 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
summaryBO.set("TQCGZE", lytotalAmount);
|
||||
summaryBO.set("SQCGZE", lmtotalAmount);
|
||||
}else {
|
||||
double totalAmount = currentMonthRow.getDouble("lptotalAmount");
|
||||
double lytotalAmount = currentMonthRow.getDouble("ly_lptotalAmount");
|
||||
double lmtotalAmount = currentMonthRow.getDouble("lm_lptotalAmount");
|
||||
double totalAmount = currentMonthRow.getDouble("lptotalAmount")==0.0?0.0:currentMonthRow.getDouble("lptotalAmount");
|
||||
double lytotalAmount = currentMonthRow.getDouble("ly_lptotalAmount")==0.0?0.0:currentMonthRow.getDouble("ly_lptotalAmount");
|
||||
double lmtotalAmount = currentMonthRow.getDouble("lm_lptotalAmount")==0.0?0.0:currentMonthRow.getDouble("lm_lptotalAmount");
|
||||
double totalQuantity = 0.00;
|
||||
double lytotalQuantity = 0.00;
|
||||
double lmtotalQuantity = 0.00;
|
||||
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")) {
|
||||
totalQuantity = BigDecimal.valueOf(currentMonthRow.getDouble("totalQuantity"))
|
||||
double Quantity = currentMonthRow.getDouble("totalQuantity")==0.0?0.0:currentMonthRow.getDouble("totalQuantity");
|
||||
if (Quantity==0.00) {
|
||||
totalQuantity = 0.0;
|
||||
}else {
|
||||
totalQuantity = BigDecimal.valueOf(Quantity)
|
||||
.divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
lytotalQuantity = BigDecimal.valueOf(currentMonthRow.getDouble("ly_totalQuantity"))
|
||||
}
|
||||
double lyQuantity = currentMonthRow.getDouble("ly_totalQuantity")==0.0?0.0:currentMonthRow.getDouble("ly_totalQuantity");
|
||||
if (lyQuantity==0.0){
|
||||
lytotalQuantity = 0.0;
|
||||
}else {
|
||||
lytotalQuantity = BigDecimal.valueOf(lyQuantity)
|
||||
.divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
lmtotalQuantity = BigDecimal.valueOf(currentMonthRow.getDouble("lm_totalQuantity"))
|
||||
}
|
||||
double lmQuantity = currentMonthRow.getDouble("lm_totalQuantity")==0.0?0.0:currentMonthRow.getDouble("lm_totalQuantity");
|
||||
if (lmQuantity==0.0){
|
||||
lmtotalQuantity = 0.0;
|
||||
}else {
|
||||
lmtotalQuantity = BigDecimal.valueOf(lmQuantity)
|
||||
.divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
}
|
||||
summaryBO.set("CGZL", totalQuantity);
|
||||
summaryBO.set("TQCGZL", lytotalQuantity);
|
||||
summaryBO.set("SQCGZL", lmtotalQuantity);
|
||||
}else {
|
||||
totalQuantity = BigDecimal.valueOf(currentMonthRow.getDouble("totalQuantity")).doubleValue();
|
||||
lytotalQuantity = BigDecimal.valueOf(currentMonthRow.getDouble("ly_totalQuantity")).doubleValue();
|
||||
lmtotalQuantity = BigDecimal.valueOf(currentMonthRow.getDouble("lm_totalQuantity")).doubleValue();
|
||||
double Quantity = currentMonthRow.getDouble("totalQuantity")==0.0?0.0:currentMonthRow.getDouble("totalQuantity");
|
||||
double lyQuantity = currentMonthRow.getDouble("ly_totalQuantity")==0.0?0.0:currentMonthRow.getDouble("ly_totalQuantity");
|
||||
double lmQuantity = currentMonthRow.getDouble("lm_totalQuantity")==0.0?0.0:currentMonthRow.getDouble("lm_totalQuantity");
|
||||
totalQuantity = BigDecimal.valueOf(Quantity).doubleValue();
|
||||
lytotalQuantity = BigDecimal.valueOf(lyQuantity).doubleValue();
|
||||
lmtotalQuantity = BigDecimal.valueOf(lmQuantity).doubleValue();
|
||||
summaryBO.set("CGZL", totalQuantity);
|
||||
summaryBO.set("TQCGZL", lytotalQuantity);
|
||||
summaryBO.set("SQCGZL", lmtotalQuantity);
|
||||
@ -448,15 +517,15 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
}
|
||||
//同期
|
||||
if (lytotalAmount != 0 && lytotalQuantity != 0) {
|
||||
lyavgPrice = BigDecimal.valueOf(totalAmount)
|
||||
.divide(BigDecimal.valueOf(totalQuantity), 2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
lyavgPrice = BigDecimal.valueOf(lytotalAmount)
|
||||
.divide(BigDecimal.valueOf(lytotalQuantity), 2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
} else {
|
||||
lyavgPrice = 0;
|
||||
}
|
||||
//上期
|
||||
if (lmtotalAmount != 0 && lmtotalQuantity != 0) {
|
||||
lmavgPrice = BigDecimal.valueOf(totalAmount)
|
||||
.divide(BigDecimal.valueOf(totalQuantity), 2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
lmavgPrice = BigDecimal.valueOf(lmtotalAmount)
|
||||
.divide(BigDecimal.valueOf(lmtotalQuantity), 2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
} else {
|
||||
lmavgPrice = 0;
|
||||
}
|
||||
@ -487,17 +556,20 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
* 逻辑:按物料名称(WLMC)分组,计算月度采购总额(SUM(JSHJ))、采购总量(SUM(YSSL))和平均单价(采购总额/采购总量)
|
||||
* @param startDate
|
||||
* @param bkgs
|
||||
* @param distinctList
|
||||
* @param
|
||||
*/
|
||||
private void newmonthlyMaterialSummaryBySegment(String startDate, String bkgs, List<String> distinctList) {
|
||||
private void newmonthlyMaterialSummaryBySegment(String startDate, String bkgs) {
|
||||
try {
|
||||
LOGGER.info("开始计算{}物料采购月度汇总数据,板块公司:{}", startDate, bkgs);
|
||||
LocalDate date = LocalDate.parse(startDate);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
||||
String yearMonth = date.format(formatter);
|
||||
|
||||
// 1. 删除该月份已存在的汇总数据(避免重复)
|
||||
String deleteSql = "DELETE FROM " + PROCUREMENT_DETAILS_YEAR_MONTH +
|
||||
" WHERE BKGS = ? AND YEARMONTH >= ?";
|
||||
int update = DBSql.update(deleteSql, new Object[]{bkgs, startDate});
|
||||
LOGGER.info("采购_年月采购明细:{}物料采购月度汇总数据,板块公司:{},删除了{}条数据",startDate, bkgs, update);
|
||||
int update = DBSql.update(deleteSql, new Object[]{bkgs, yearMonth});
|
||||
LOGGER.info("采购_年月采购明细:{}年月物料采购月度汇总数据,板块公司:{},删除了{}条数据",yearMonth, bkgs, update);
|
||||
|
||||
String currentMonthSql = "SELECT CONCAT(c.Year, '-', LPAD(c.Month, 2, '0')) ASyear_month,c.Year AS year,c.Month AS month,c.WLMC AS WLMC," +
|
||||
" c.tstotalAmount AS tstotalAmount,c.lptotalAmount AS lptotalAmount,c.totalQuantity AS totalQuantity," +
|
||||
|
||||
@ -278,7 +278,7 @@ public class SaleDataSyncServiceImpl implements DataSyncService {
|
||||
" WHERE " + conditionBuilder.toString() +
|
||||
orderByBuilder.toString(); // 添加排序子句
|
||||
|
||||
LOGGER.debug("执行Oracle查询: {}", querySql);
|
||||
LOGGER.info("执行Oracle查询: {}", querySql);
|
||||
|
||||
List<RowMap> pageData;
|
||||
// 根据条件类型执行查询
|
||||
|
||||
@ -74,7 +74,7 @@ public class SaleUtil {
|
||||
String sfjc = "";
|
||||
BO bo_eu_1755768181783 = SDK.getBOAPI().query("BO_EU_1755768181783").addQuery("F_D2IYKX5I = ", sf).detail();
|
||||
if (bo_eu_1755768181783==null){
|
||||
sfjc = "其他";
|
||||
sfjc = sf;
|
||||
}else {
|
||||
sfjc = bo_eu_1755768181783.getString("SQ_SHORT");
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user