1、一体化销售计修改
2、采购汇总计算增加计算空值,取值修改
This commit is contained in:
parent
4b7e7440d8
commit
953e6eec99
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -611,8 +611,10 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
summaryBO.set("YEARMONTH", yearMonth);
|
||||
summaryBO.set("WLMC", wlmc);
|
||||
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
||||
double totalQuantity = currentMonthRow.getDouble("totalQuantity");
|
||||
double totalAmount = currentMonthRow.getDouble("totalAmount");
|
||||
Double totalQuantity1 = currentMonthRow.getDouble("totalQuantity");
|
||||
double totalQuantity = totalQuantity1 != null ? totalQuantity1 : 0.0;
|
||||
Double totalAmount1 = currentMonthRow.getDouble("totalAmount");
|
||||
double totalAmount = totalAmount1 != null ? totalAmount1 : 0.0;
|
||||
summaryBO.set("CGZL", totalQuantity!=0?totalQuantity/1000:0);
|
||||
if (totalAmount!=0 || totalQuantity!=0) {
|
||||
avgPrice = totalAmount / (totalQuantity / 1000);
|
||||
@ -620,8 +622,10 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
avgPrice = 0;
|
||||
}
|
||||
}else {
|
||||
double totalQuantity = currentMonthRow.getDouble("totalQuantity");
|
||||
double totalAmount = currentMonthRow.getDouble("totalAmount");
|
||||
Double totalQuantity1 = currentMonthRow.getDouble("totalQuantity");
|
||||
double totalQuantity = totalQuantity1 != null ? totalQuantity1 : 0.0;
|
||||
Double totalAmount1 = currentMonthRow.getDouble("totalAmount");
|
||||
double totalAmount = totalAmount1 != null ? totalAmount1 : 0.0;
|
||||
summaryBO.set("CGZL", totalQuantity);
|
||||
if (totalAmount!=0 || totalQuantity!=0) {
|
||||
avgPrice = totalAmount / totalQuantity;
|
||||
@ -635,8 +639,10 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
// 添加上月数据
|
||||
RowMap lastMonthRow = lastMonthMap.get(wlmc);
|
||||
if (lastMonthRow != null) {
|
||||
double totalQuantity = lastMonthRow.getDouble("totalQuantity");
|
||||
double totalAmount = lastMonthRow.getDouble("totalAmount");
|
||||
Double totalQuantity1 = currentMonthRow.getDouble("totalQuantity");
|
||||
double totalQuantity = totalQuantity1 != null ? totalQuantity1 : 0.0;
|
||||
Double totalAmount1 = currentMonthRow.getDouble("totalAmount");
|
||||
double totalAmount = totalAmount1 != null ? totalAmount1 : 0.0;
|
||||
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
||||
summaryBO.set("SQCGZL", totalQuantity!=0?totalQuantity/1000:0);
|
||||
}else {
|
||||
@ -648,8 +654,10 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
// 添加去年同期数据
|
||||
RowMap lastYearMonthRow = lastYearMonthMap.get(wlmc);
|
||||
if (lastYearMonthRow != null) {
|
||||
double totalQuantity = lastYearMonthRow.getDouble("totalQuantity");
|
||||
double totalAmount = lastYearMonthRow.getDouble("totalAmount");
|
||||
Double totalQuantity1 = currentMonthRow.getDouble("totalQuantity");
|
||||
double totalQuantity = totalQuantity1 != null ? totalQuantity1 : 0.0;
|
||||
Double totalAmount1 = currentMonthRow.getDouble("totalAmount");
|
||||
double totalAmount = totalAmount1 != null ? totalAmount1 : 0.0;
|
||||
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
||||
summaryBO.set("TQCGZL", totalQuantity!=0?totalQuantity/1000:0);
|
||||
}else {
|
||||
@ -852,7 +860,7 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
detailBO.set("RKJE", row.getDouble("DHJE")); // 入库金额(金额含运费)
|
||||
}else {
|
||||
detailBO.set("RKDJ", row.getDouble("HSDJHYF")); // 入库单价(含税单价含运费)
|
||||
detailBO.set("RKJE", row.getDouble("JEHYF")); // 入库金额(金额含运费)
|
||||
detailBO.set("RKJE", row.getDouble("JSHJHYF")); // 入库金额(金额含运费)
|
||||
}
|
||||
detailBO.set("GYS", row.getString("GYSNAME")); // 供应商
|
||||
detailBO.set("DDBH", row.getString("CGDDH")); // 订单编号
|
||||
|
||||
@ -818,18 +818,15 @@ public class PurchaseDataSyncServiceImpl implements DataSyncService {
|
||||
if (StringUtils.isNotBlank(wlmc) || StringUtils.isNotBlank(wlbm)
|
||||
|| StringUtils.isNotBlank(jldw)
|
||||
|| StringUtils.isNotBlank(wlfl)) {
|
||||
try {
|
||||
newWlmc = purchaseUtil.materialClassificationFiltering(bkgs.trim(),
|
||||
wlmc.trim(), wlbm.trim(), jldw.trim(), djhyf, wlfl.trim());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (bkgs.equals("北新嘉宝莉")) {
|
||||
if (wlmc.contains("盖") && djhyf < 5.0) {
|
||||
if (wlmc.contains("盖")&& !wlmc.contains("桶") && !wlmc.contains("罐") && djhyf < 3.5) {
|
||||
continue;
|
||||
} else if (wlmc.contains("桶身") && gaiSum > 0) {
|
||||
} else if (wlmc.contains("桶身")&& jldw.equals("个") && gaiSum > 0) {
|
||||
Double djhyf1 = bo.get("DJHYF", Double.class);
|
||||
bo.set("DJHYF", djhyf1 + gaiAverage);
|
||||
double djhyf2 = djhyf1 != null ? djhyf1 : 0.0;
|
||||
bo.set("DJHYF", djhyf2 + gaiAverage);
|
||||
gaiSum--;
|
||||
}
|
||||
}
|
||||
@ -844,7 +841,6 @@ public class PurchaseDataSyncServiceImpl implements DataSyncService {
|
||||
// 处理可能为null的值,默认设为0.0
|
||||
double safeRksl = rksl != null ? rksl : 0.0;
|
||||
double safeHsdjhyf = hsdjhyf != null ? hsdjhyf : 0.0;
|
||||
|
||||
BigDecimal multiply = BigDecimal.valueOf(safeRksl).multiply(BigDecimal.valueOf(safeHsdjhyf));
|
||||
bo.set("DHJE", multiply.doubleValue());
|
||||
}
|
||||
|
||||
@ -203,6 +203,11 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
||||
try {
|
||||
LOGGER.info("开始计算{}年{}月产品配套率数据", year, month);
|
||||
|
||||
//新增前删除数据
|
||||
int delete = DBSql.update("DELETE FROM " + MATCHING_RATE_YEAR_TABLE
|
||||
+ " WHERE YEARMONTH = '" + yearMonth + "' AND BKGS = '"+bkgs+"'");
|
||||
LOGGER.info("准备同步{}年{}月产品配套率数据,删除了{}条数据",year, month,delete);
|
||||
|
||||
// 获取石膏板年度销售量(万平方米) - 从当年1月到当前月
|
||||
BigDecimal gypsumSales = getSalesToMonth(year, month, "石膏板", bkgs);
|
||||
// 获取轻钢龙骨年度销售量(吨) - 从当年1月到当前月
|
||||
@ -238,12 +243,19 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
||||
*/
|
||||
private void calculateAndSaveProductMonthly(int year, int month, String yearMonth, String bkgs) {
|
||||
try {
|
||||
LOGGER.info("开始计算{}年{}月产品销售明细数据", year, month);
|
||||
List<RowMap> maps = DBSql.getMaps("SELECT LB_1 FROM " + SALES_DETAIL_TABLE + " WHERE BKGS = '" + bkgs + "'" +
|
||||
"AND (SQ LIKE '%新疆%' OR SQ LIKE '%海南%' OR SQ LIKE '%西藏%') " + // 模糊查询
|
||||
" GROUP BY LB_1");
|
||||
for (RowMap map : maps) {
|
||||
String lb_1 = map.getString("LB_1");
|
||||
LOGGER.info("开始计算{}年{}月-产品销售明细数据", year, month);
|
||||
|
||||
//新增前删除数据
|
||||
int delete = DBSql.update("DELETE FROM " + PRODUCT_MONTHLY_TABLE
|
||||
+ " WHERE YEARMONTH = '" + yearMonth + "' AND BKGS = '"+bkgs+"'");
|
||||
LOGGER.info("准备同步{}年{}月-产品销售明细数据,删除了{}条数据",year, month,delete);
|
||||
|
||||
// List<RowMap> maps = DBSql.getMaps("SELECT LB_1 FROM " + SALES_DETAIL_TABLE + " WHERE BKGS = '" + bkgs + "'" +
|
||||
// "AND (SQ LIKE '%新疆%' OR SQ LIKE '%海南%' OR SQ LIKE '%西藏%') " + // 模糊查询
|
||||
// " GROUP BY LB_1");
|
||||
String[] lb1s = new String[]{"石膏板","轻钢龙骨","涂料"};
|
||||
for (String lb_1 : lb1s) {
|
||||
// String lb_1 = map.getString("LB_1");
|
||||
processProductData(lb_1, year, month, yearMonth, bkgs);
|
||||
}
|
||||
// 处理石膏板数据
|
||||
@ -332,6 +344,11 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
||||
try {
|
||||
LOGGER.info("开始计算{}年{}月应收账款品牌明细数据", year, month);
|
||||
|
||||
//新增前删除数据
|
||||
int delete = DBSql.update("DELETE FROM " + RECEIVABLE_BRAND_MONTHLY_TABLE
|
||||
+ " WHERE YEARMONTH = '" + yearMonth + "' AND BKGS = '"+bkgs+"'");
|
||||
LOGGER.info("准备同步{}年{}月-应收账款品牌月明细,删除了{}条数据",year, month,delete);
|
||||
|
||||
// 处理应收账款
|
||||
processReceivableData(getBoneReceivable(year, month, bkgs), yearMonth, bkgs);
|
||||
// 处理涂料应收账款
|
||||
@ -372,6 +389,12 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
||||
private void calculateAndSaveReceivableYear(int year, int month, String yearMonth, String bkgs) {
|
||||
try {
|
||||
LOGGER.info("开始计算{}年{}月应收账款累计数据", year, month);
|
||||
|
||||
//新增前删除数据
|
||||
int delete = DBSql.update("DELETE FROM " + RECEIVABLE_YEAR_TABLE
|
||||
+ " WHERE YEARMONTH = '" + yearMonth + "' AND BKGS = '"+bkgs+"'");
|
||||
LOGGER.info("准备同步{}年{}月-应收账款年度汇总(按月存储),删除了{}条数据",year, month,delete);
|
||||
|
||||
int lastYear = year - 1;
|
||||
int lastYearMonth = month; // 去年同月
|
||||
|
||||
@ -422,14 +445,22 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
||||
private void calculateAndSaveRevenueYear(int year, int month, String yearMonth, String bkgs) {
|
||||
try {
|
||||
LOGGER.info("开始计算{}年{}月营业收入累计数据", year, month);
|
||||
|
||||
//新增前删除数据
|
||||
int delete = DBSql.update("DELETE FROM " + REVENUE_YEAR_TABLE
|
||||
+ " WHERE YEARMONTH = '" + yearMonth + "' AND BKGS = '"+bkgs+"'");
|
||||
LOGGER.info("准备同步{}年{}月-营业收入累计数据,删除了{}条数据",year, month,delete);
|
||||
|
||||
int lastYear = year - 1;
|
||||
int lastYearMonth = month; // 去年同月
|
||||
|
||||
if (bkgs.equals("泰山石膏") || bkgs.equals("梦牌") || bkgs.equals("龙牌")) {
|
||||
// 处理石膏板数据 - 当年当前月
|
||||
saveRevenueYearData(yearMonth, "石膏板",
|
||||
getRevenueToMonth(year, month, "石膏板", bkgs),
|
||||
getRevenueToMonth(lastYear, lastYearMonth, "石膏板", bkgs),
|
||||
bkgs);
|
||||
}
|
||||
|
||||
// 处理轻钢龙骨数据 - 当年当前月
|
||||
saveRevenueYearData(yearMonth, "轻钢龙骨",
|
||||
@ -485,11 +516,17 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
||||
try {
|
||||
LOGGER.info("开始计算{}-{}-{}产品单价日明细数据", year, month, day);
|
||||
|
||||
//新增前删除数据YEAR(DZRQ) = '" + year + "' AND MONTH(DZRQ) = '" + month + "AND DAY(DZRQ) = '"+day+"'
|
||||
int delete = DBSql.update("DELETE FROM " + UNIT_PRICE_DAILY_TABLE
|
||||
+ " WHERE YEAR(DATE) = '" + year + "' AND MONTH(DATE) = '"+month+"' AND DAY(DATE) = '"+day+"' AND BKGS = '"+bkgs+"'");
|
||||
LOGGER.info("准备同步{}-产品单价日明细数据,删除了{}条数据",date,delete);
|
||||
|
||||
List<RowMap> maps = DBSql.getMaps("SELECT LB_1 FROM " + SALES_DETAIL_TABLE + " WHERE BKGS = '" + bkgs + "'" +
|
||||
"AND (SQ LIKE '%新疆%' OR SQ LIKE '%海南%' OR SQ LIKE '%西藏%') " + // 模糊查询
|
||||
" GROUP BY LB_1");
|
||||
for (RowMap map : maps) {
|
||||
String lb_1 = map.getString("LB_1");
|
||||
String[] lb1s = new String[]{"石膏板","轻钢龙骨","涂料"};
|
||||
for (String lb_1 : lb1s) {
|
||||
// String lb_1 = map.getString("LB_1");
|
||||
saveUnitPriceData(date, lb_1, year, month, day, bkgs);
|
||||
}
|
||||
|
||||
@ -695,7 +732,7 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
||||
.append(" SELECT MAX(RQ) ")
|
||||
.append(" FROM " + RECEIVABLE_DETAIL_TABLE + " ")
|
||||
.append(" WHERE YEAR(RQ) = '" + year + "' AND MONTH(RQ) = '" + month + "' AND BKGS = '" + bkgs + "' ")
|
||||
.append(") AND BKGS = '" + bkgs + "'");
|
||||
.append(") AND BKGS = '" + bkgs + "' AND SHENGQU IN( '新疆维吾尔自治区','海南','西藏')");
|
||||
|
||||
Map<String, BigDecimal> result = new HashMap<>();
|
||||
List<RowMap> rows = DBSql.getMaps(sql.toString());
|
||||
@ -722,51 +759,13 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
||||
*/
|
||||
private void saveSummaryData(BO summary, String tableName) {
|
||||
try {
|
||||
// 根据表名构建唯一性查询条件
|
||||
String whereClause = buildUniqueCondition(tableName, summary);
|
||||
if (whereClause == null) {
|
||||
SDK.getBOAPI().createDataBO(tableName, summary, UserContext.fromUID("admin"));
|
||||
LOGGER.debug("{} 表创建新数据: {}", tableName, summary);
|
||||
return;
|
||||
}
|
||||
|
||||
// 查询已存在记录
|
||||
String sql = "SELECT * FROM " + tableName + " WHERE " + whereClause;
|
||||
LOGGER.info("查询已存在sql:{}",sql);
|
||||
RowMap existing = DBSql.getMap(sql);
|
||||
if (existing!=null){
|
||||
if (StringUtils.isNotBlank(existing.getString("ID"))) {
|
||||
// 更新现有记录
|
||||
String id = existing.getString("ID");
|
||||
summary.set("ID", id);
|
||||
summary.set("ORGID", existing.getString("ORGID"));
|
||||
summary.set("BINDID", existing.getString("BINDID"));
|
||||
summary.set("CREATEDATE", existing.getString("CREATEDATE"));
|
||||
summary.set("CREATEUSER", existing.getString("CREATEUSER"));
|
||||
summary.set("UPDATEDATE",new Timestamp(System.currentTimeMillis()));
|
||||
summary.set("PROCESSDEFID", existing.getString("PROCESSDEFID"));
|
||||
summary.set("ISEND", existing.getString("ISEND"));
|
||||
SDK.getBOAPI().update(tableName, summary);
|
||||
LOGGER.debug("{} 表数据更新成功: ID={}", tableName, id);
|
||||
}
|
||||
} else {
|
||||
// 创建新记录
|
||||
SDK.getBOAPI().createDataBO(tableName, summary, UserContext.fromUID("admin"));
|
||||
LOGGER.debug("{} 表创建新数据: {}", tableName, summary);
|
||||
}
|
||||
LOGGER.debug("{} 表数据保存成功: {}", tableName, summary);
|
||||
} catch (Exception e) {
|
||||
String errorMsg = String.format("%s 表数据保存失败: %s", tableName, e.getMessage());
|
||||
LOGGER.error(errorMsg, e);
|
||||
throw new RuntimeException(errorMsg, e);
|
||||
}
|
||||
// try {
|
||||
// SDK.getBOAPI().createDataBO(tableName, summary, UserContext.fromUID("admin"));
|
||||
// LOGGER.debug("{} 表数据保存成功: {}", tableName, summary);
|
||||
// } catch (Exception e) {
|
||||
// String errorMsg = String.format("%s 表数据保存失败: %s", tableName, e.getMessage());
|
||||
// LOGGER.error(errorMsg, e);
|
||||
// throw new RuntimeException(errorMsg, e);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user