1、物料分类乳液条件修改

2、增加泰山入库计算单行的金额
3、汇总计算增加乳液、钛白粉、重钙的单位处理;泰山石膏增加DHJE
This commit is contained in:
llllon 2025-08-29 16:33:29 +08:00
parent 4f39842877
commit 39fceb2797
7 changed files with 195 additions and 128 deletions

View File

@ -266,10 +266,18 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
// "FROM " + PROCUREMENT_PURCHASE_ORDER_SUMMARY + // "FROM " + PROCUREMENT_PURCHASE_ORDER_SUMMARY +
// " WHERE BKGS = ? AND CGRQ LIKE ? " + // " WHERE BKGS = ? AND CGRQ LIKE ? " +
// "GROUP BY WLMC, XQGC"; // "GROUP BY WLMC, XQGC";
String currentMonthSql = "SELECT WLMC, SLGC, SUM(JSHJHYF) AS totalAmount, SUM(RKSL) AS totalQuantity " + String currentMonthSql = "";
"FROM " + BO_EU_DWD_ORDER_RKD_HZ + if ("泰山石膏".equals(bkgs)) {
" WHERE BKGS = ? AND DJRQ LIKE ? " + currentMonthSql = "SELECT WLMC, SLGC, SUM(DHJE) AS totalAmount, SUM(RKSL) AS totalQuantity " +
"GROUP BY WLMC, SLGC"; "FROM " + BO_EU_DWD_ORDER_RKD_HZ +
" WHERE BKGS = ? AND DJRQ LIKE ? " +
"GROUP BY WLMC, SLGC";
}else {
currentMonthSql = "SELECT WLMC, SLGC, SUM(JSHJHYF) AS totalAmount, SUM(RKSL) AS totalQuantity " +
"FROM " + BO_EU_DWD_ORDER_RKD_HZ +
" WHERE BKGS = ? AND DJRQ LIKE ? " +
"GROUP BY WLMC, SLGC";
}
List<RowMap> currentMonthData = DBSql.getMaps(currentMonthSql, bkgs, yearMonth + "%"); List<RowMap> currentMonthData = DBSql.getMaps(currentMonthSql, bkgs, yearMonth + "%");
// 上月数据 // 上月数据
@ -279,11 +287,11 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
// "FROM " + PROCUREMENT_PURCHASE_ORDER_SUMMARY + // "FROM " + PROCUREMENT_PURCHASE_ORDER_SUMMARY +
// " WHERE BKGS = ? AND CGRQ LIKE ? " + // " WHERE BKGS = ? AND CGRQ LIKE ? " +
// "GROUP BY WLMC, XQGC"; // "GROUP BY WLMC, XQGC";
String lastMonthSql = "SELECT WLMC, SLGC, SUM(JSHJHYF) AS totalAmount, SUM(RKSL) AS totalQuantity " + // String lastMonthSql = "SELECT WLMC, SLGC, SUM(JSHJHYF) AS totalAmount, SUM(RKSL) AS totalQuantity " +
"FROM " + BO_EU_DWD_ORDER_RKD_HZ + // "FROM " + BO_EU_DWD_ORDER_RKD_HZ +
" WHERE BKGS = ? AND DJRQ LIKE ? " + // " WHERE BKGS = ? AND DJRQ LIKE ? " +
"GROUP BY WLMC, SLGC"; // "GROUP BY WLMC, SLGC";
lastMonthData = DBSql.getMaps(lastMonthSql, bkgs, yearLastMonth + "%"); lastMonthData = DBSql.getMaps(currentMonthSql, bkgs, yearLastMonth + "%");
} }
// 去年同期数据 // 去年同期数据
@ -293,11 +301,11 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
// "FROM " + PROCUREMENT_PURCHASE_ORDER_SUMMARY + // "FROM " + PROCUREMENT_PURCHASE_ORDER_SUMMARY +
// " WHERE BKGS = ? AND CGRQ LIKE ? " + // " WHERE BKGS = ? AND CGRQ LIKE ? " +
// "GROUP BY WLMC, XQGC"; // "GROUP BY WLMC, XQGC";
String lastYearMonthSql = "SELECT WLMC, SLGC, SUM(JSHJHYF) AS totalAmount, SUM(RKSL) AS totalQuantity " + // String lastYearMonthSql = "SELECT WLMC, SLGC, SUM(JSHJHYF) AS totalAmount, SUM(RKSL) AS totalQuantity " +
" FROM " + BO_EU_DWD_ORDER_RKD_HZ + // " FROM " + BO_EU_DWD_ORDER_RKD_HZ +
" WHERE BKGS = ? AND DJRQ LIKE ? " + // " WHERE BKGS = ? AND DJRQ LIKE ? " +
" GROUP BY WLMC, SLGC"; // " GROUP BY WLMC, SLGC";
lastYearMonthData = DBSql.getMaps(lastYearMonthSql, bkgs, lastYearMonth + "%"); lastYearMonthData = DBSql.getMaps(currentMonthSql, bkgs, lastYearMonth + "%");
} }
// 3. 创建物料名称和基地组合键映射的数据Map // 3. 创建物料名称和基地组合键映射的数据Map
@ -375,12 +383,6 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
for (RowMap row : currentMonthData) { for (RowMap row : currentMonthData) {
bases.add(row.getString("SLGC")); bases.add(row.getString("SLGC"));
} }
// for (RowMap row : lastMonthData) {
// bases.add(row.getString("SLGC"));
// }
// for (RowMap row : lastYearMonthData) {
// bases.add(row.getString("SLGC"));
// }
// 5. 批量插入 // 5. 批量插入
List<BO> bos = new ArrayList<>(); List<BO> bos = new ArrayList<>();
@ -390,53 +392,56 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
RowMap currentMonthRow = currentMonthMap.get(key); RowMap currentMonthRow = currentMonthMap.get(key);
if (currentMonthRow == null || currentMonthRow.getDouble("totalAmount") == 0.0) continue; if (currentMonthRow == null || currentMonthRow.getDouble("totalAmount") == 0.0) continue;
double avgPrice = 0.00;
BO summaryBO = new BO(); BO summaryBO = new BO();
summaryBO.set("BKGS", bkgs); summaryBO.set("BKGS", bkgs);
summaryBO.set("JD", base); summaryBO.set("JD", base);
// List<BO> bnbmCgPzwlfl = SDK.getBOAPI().query("BO_EU_BNBM_CG_PZWLFL"). if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
// addQuery("BKMC = ", bkgs).addQuery("WLMC LIKE '%" + wlmc + "%'", null).list(); summaryBO.set("CGZE", currentMonthRow.getDouble("totalAmount")/1000);
// if (bnbmCgPzwlfl!=null){ avgPrice = currentMonthRow.getDouble("totalQuantity") != 0 ?
// String wlfl = bnbmCgPzwlfl.stream().map(o -> o.getString("WLFL")).collect(Collectors.joining("|")); (currentMonthRow.getDouble("totalAmount")/1000) / currentMonthRow.getDouble("totalQuantity") : 0;
// summaryBO.set("WLMC", wlfl);
// }else {
if(("龙牌".equals(bkgs) || "梦牌".equals(bkgs) || "泰山石膏".equals(bkgs))
&& (wlmc.contains("脱硫石膏") || wlmc.contains("护面纸"))){
summaryBO.set("WLMC", "脱硫石膏");
} else if ("泰山石膏".equals(bkgs) && wlmc.contains("镀锌带钢")) {
summaryBO.set("WLMC", "镀锌带钢");
} else if (("龙牌".equals(bkgs) || "梦牌".equals(bkgs))
&& (wlmc.equals("轻钢镀锌带钢") || wlmc.equals("镀锌带钢"))) {
summaryBO.set("WLMC", "镀锌带钢");
} else if (("泰山石膏".equals(bkgs) || "龙牌".equals(bkgs) || "梦牌".equals(bkgs)) && wlmc.contains("乳液")) {
continue;
}else { }else {
summaryBO.set("WLMC", wlmc); summaryBO.set("CGZE", currentMonthRow.getDouble("totalAmount"));
avgPrice = currentMonthRow.getDouble("totalQuantity") != 0 ?
currentMonthRow.getDouble("totalAmount") / currentMonthRow.getDouble("totalQuantity") : 0;
} }
// }
summaryBO.set("YEARMONTH", yearMonth); summaryBO.set("YEARMONTH", yearMonth);
summaryBO.set("CGZE", currentMonthRow.getDouble("totalAmount")); summaryBO.set("CGZE", currentMonthRow.getDouble("totalAmount"));
summaryBO.set("CGZL", currentMonthRow.getDouble("totalQuantity")); summaryBO.set("CGZL", currentMonthRow.getDouble("totalQuantity"));
double avgPrice = currentMonthRow.getDouble("totalQuantity") != 0 ?
currentMonthRow.getDouble("totalAmount") / currentMonthRow.getDouble("totalQuantity") : 0;
summaryBO.set("PJDJ", avgPrice); summaryBO.set("PJDJ", avgPrice);
// 添加上月数据 // 添加上月数据
RowMap lastMonthRow = lastMonthMap.get(key); RowMap lastMonthRow = lastMonthMap.get(key);
if (lastMonthRow != null) { if (lastMonthRow != null) {
summaryBO.set("SQCGZE", lastMonthRow.getDouble("totalAmount")); double lastMonthAvgPrice = 0.00;
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
summaryBO.set("SQCGZE", lastMonthRow.getDouble("totalAmount")/1000);
lastMonthAvgPrice = lastMonthRow.getDouble("totalQuantity") != 0 ?
(lastMonthRow.getDouble("totalAmount")/1000) / lastMonthRow.getDouble("totalQuantity") : 0;
}else {
summaryBO.set("SQCGZE", lastMonthRow.getDouble("totalAmount"));
lastMonthAvgPrice = lastMonthRow.getDouble("totalQuantity") != 0 ?
lastMonthRow.getDouble("totalAmount") / lastMonthRow.getDouble("totalQuantity") : 0;
}
summaryBO.set("SQCGZL", lastMonthRow.getDouble("totalQuantity")); summaryBO.set("SQCGZL", lastMonthRow.getDouble("totalQuantity"));
double lastMonthAvgPrice = lastMonthRow.getDouble("totalQuantity") != 0 ?
lastMonthRow.getDouble("totalAmount") / lastMonthRow.getDouble("totalQuantity") : 0;
summaryBO.set("SQPJDJ", lastMonthAvgPrice); summaryBO.set("SQPJDJ", lastMonthAvgPrice);
} }
// 添加去年同期数据 // 添加去年同期数据
RowMap lastYearMonthRow = lastYearMonthMap.get(key); RowMap lastYearMonthRow = lastYearMonthMap.get(key);
if (lastYearMonthRow != null) { if (lastYearMonthRow != null) {
summaryBO.set("TQCGZE", lastYearMonthRow.getDouble("totalAmount")); double lastYearMonthAvgPrice = 0.00;
summaryBO.set("TQCGZL", lastYearMonthRow.getDouble("totalQuantity")); if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
double lastYearMonthAvgPrice = lastYearMonthRow.getDouble("totalQuantity") != 0 ? summaryBO.set("TQCGZE", lastYearMonthRow.getDouble("totalAmount")/1000);
lastYearMonthRow.getDouble("totalAmount") / lastYearMonthRow.getDouble("totalQuantity") : 0; lastYearMonthAvgPrice = lastYearMonthRow.getDouble("totalQuantity") != 0 ?
(lastYearMonthRow.getDouble("totalAmount")/1000) / lastYearMonthRow.getDouble("totalQuantity") : 0;
}else {
summaryBO.set("TQCGZL", lastYearMonthRow.getDouble("totalQuantity"));
lastYearMonthAvgPrice = lastYearMonthRow.getDouble("totalQuantity") != 0 ?
lastYearMonthRow.getDouble("totalAmount") / lastYearMonthRow.getDouble("totalQuantity") : 0;
}
summaryBO.set("TQPJDJ", lastYearMonthAvgPrice); summaryBO.set("TQPJDJ", lastYearMonthAvgPrice);
} }
@ -487,10 +492,18 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
// "FROM " + PROCUREMENT_PURCHASE_ORDER_SUMMARY + // "FROM " + PROCUREMENT_PURCHASE_ORDER_SUMMARY +
// " WHERE BKGS = ? AND CGRQ LIKE ? " + // " WHERE BKGS = ? AND CGRQ LIKE ? " +
// "GROUP BY WLMC"; // "GROUP BY WLMC";
String currentMonthSql = "SELECT WLMC, SUM(JSHJHYF) AS totalAmount, SUM(RKSL) AS totalQuantity " + String currentMonthSql = "";
" FROM " + BO_EU_DWD_ORDER_RKD_HZ + if ("泰山石膏".equals(bkgs)) {
" WHERE BKGS = ? AND DJRQ LIKE ? " + currentMonthSql = "SELECT WLMC, SUM(DHJE) AS totalAmount, SUM(RKSL) AS totalQuantity " +
" GROUP BY WLMC"; " FROM " + BO_EU_DWD_ORDER_RKD_HZ +
" WHERE BKGS = ? AND DJRQ LIKE ? " +
" GROUP BY WLMC";
}else {
currentMonthSql = "SELECT WLMC, SUM(JSHJHYF) AS totalAmount, SUM(RKSL) AS totalQuantity " +
" FROM " + BO_EU_DWD_ORDER_RKD_HZ +
" WHERE BKGS = ? AND DJRQ LIKE ? " +
" GROUP BY WLMC";
}
List<RowMap> currentMonthData = DBSql.getMaps(currentMonthSql, bkgs, yearMonth + "%"); List<RowMap> currentMonthData = DBSql.getMaps(currentMonthSql, bkgs, yearMonth + "%");
// 上月数据 // 上月数据
@ -500,11 +513,19 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
// "FROM " + PROCUREMENT_PURCHASE_ORDER_SUMMARY + // "FROM " + PROCUREMENT_PURCHASE_ORDER_SUMMARY +
// " WHERE BKGS = ? AND CGRQ LIKE ? " + // " WHERE BKGS = ? AND CGRQ LIKE ? " +
// "GROUP BY WLMC"; // "GROUP BY WLMC";
String lastMonthSql = "SELECT WLMC, SUM(JSHJHYF) AS totalAmount, SUM(RKSL) AS totalQuantity " + // String lastMonthSql = "";
" FROM " + BO_EU_DWD_ORDER_RKD_HZ + // if ("泰山石膏".equals(bkgs)) {
" WHERE BKGS = ? AND DJRQ LIKE ? " + // lastMonthSql = "SELECT WLMC, SUM(DHJE) AS totalAmount, SUM(RKSL) AS totalQuantity " +
" GROUP BY WLMC"; // " FROM " + BO_EU_DWD_ORDER_RKD_HZ +
lastMonthData = DBSql.getMaps(lastMonthSql, bkgs, yearLastMonth + "%"); // " WHERE BKGS = ? AND DJRQ LIKE ? " +
// " GROUP BY WLMC";
// }else {
// lastMonthSql = "SELECT WLMC, SUM(JSHJHYF) AS totalAmount, SUM(RKSL) AS totalQuantity " +
// " FROM " + BO_EU_DWD_ORDER_RKD_HZ +
// " WHERE BKGS = ? AND DJRQ LIKE ? " +
// " GROUP BY WLMC";
// }
lastMonthData = DBSql.getMaps(currentMonthSql, bkgs, yearLastMonth + "%");
} }
// 去年同期数据 // 去年同期数据
@ -514,11 +535,19 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
// "FROM " + PROCUREMENT_PURCHASE_ORDER_SUMMARY + // "FROM " + PROCUREMENT_PURCHASE_ORDER_SUMMARY +
// " WHERE BKGS = ? AND CGRQ LIKE ? " + // " WHERE BKGS = ? AND CGRQ LIKE ? " +
// "GROUP BY WLMC"; // "GROUP BY WLMC";
String lastYearMonthSql = "SELECT WLMC, SUM(JSHJHYF) AS totalAmount, SUM(RKSL) AS totalQuantity " + // String lastYearMonthSql = "";
" FROM " + BO_EU_DWD_ORDER_RKD_HZ + // if ("泰山石膏".equals(bkgs)) {
" WHERE BKGS = ? AND DJRQ LIKE ? " + // lastYearMonthSql = "SELECT WLMC, SUM(DHJE) AS totalAmount, SUM(RKSL) AS totalQuantity " +
" GROUP BY WLMC"; // " FROM " + BO_EU_DWD_ORDER_RKD_HZ +
lastYearMonthData = DBSql.getMaps(lastYearMonthSql, bkgs, lastYearMonth + "%"); // " WHERE BKGS = ? AND DJRQ LIKE ? " +
// " GROUP BY WLMC";
// }else {
// lastYearMonthSql = "SELECT WLMC, SUM(JSHJHYF) AS totalAmount, SUM(RKSL) AS totalQuantity " +
// " FROM " + BO_EU_DWD_ORDER_RKD_HZ +
// " WHERE BKGS = ? AND DJRQ LIKE ? " +
// " GROUP BY WLMC";
// }
lastYearMonthData = DBSql.getMaps(currentMonthSql, bkgs, lastYearMonth + "%");
} }
// 3. 创建物料名称映射的数据Map // 3. 创建物料名称映射的数据Map
@ -584,26 +613,41 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
String wlmc = currentMonthRow.getString("WLMC"); String wlmc = currentMonthRow.getString("WLMC");
if (currentMonthRow == null || currentMonthRow.getDouble("totalAmount") == 0.0) continue; if (currentMonthRow == null || currentMonthRow.getDouble("totalAmount") == 0.0) continue;
double avgPrice = 0.00;
BO summaryBO = new BO(); BO summaryBO = new BO();
summaryBO.set("YEARMONTH", yearMonth); summaryBO.set("YEARMONTH", yearMonth);
summaryBO.set("WLMC", wlmc); summaryBO.set("WLMC", wlmc);
summaryBO.set("CGZE", currentMonthRow.getDouble("totalAmount")); if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
summaryBO.set("CGZE", currentMonthRow.getDouble("totalAmount")/1000);
avgPrice = currentMonthRow.getDouble("totalQuantity") != 0 ?
(currentMonthRow.getDouble("totalAmount")/1000) / currentMonthRow.getDouble("totalQuantity") : 0;
}else {
summaryBO.set("CGZE", currentMonthRow.getDouble("totalAmount"));
avgPrice = currentMonthRow.getDouble("totalQuantity") != 0 ?
currentMonthRow.getDouble("totalAmount") / currentMonthRow.getDouble("totalQuantity") : 0;
}
summaryBO.set("CGZL", currentMonthRow.getDouble("totalQuantity")); summaryBO.set("CGZL", currentMonthRow.getDouble("totalQuantity"));
double avgPrice = currentMonthRow.getDouble("totalQuantity") != 0 ?
currentMonthRow.getDouble("totalAmount") / currentMonthRow.getDouble("totalQuantity") : 0;
summaryBO.set("PJDJ", avgPrice); summaryBO.set("PJDJ", avgPrice);
// 添加上月数据 // 添加上月数据
RowMap lastMonthRow = lastMonthMap.get(wlmc); RowMap lastMonthRow = lastMonthMap.get(wlmc);
if (lastMonthRow != null) { if (lastMonthRow != null) {
summaryBO.set("SQCGZE", lastMonthRow.getDouble("totalAmount")); if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
summaryBO.set("SQCGZE", lastMonthRow.getDouble("totalAmount")/1000);
}else {
summaryBO.set("SQCGZE", lastMonthRow.getDouble("totalAmount"));
}
summaryBO.set("SQCGZL", lastMonthRow.getDouble("totalQuantity")); summaryBO.set("SQCGZL", lastMonthRow.getDouble("totalQuantity"));
} }
// 添加去年同期数据 // 添加去年同期数据
RowMap lastYearMonthRow = lastYearMonthMap.get(wlmc); RowMap lastYearMonthRow = lastYearMonthMap.get(wlmc);
if (lastYearMonthRow != null) { if (lastYearMonthRow != null) {
summaryBO.set("TQCGZE", lastYearMonthRow.getDouble("totalAmount")); if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
summaryBO.set("TQCGZE", lastYearMonthRow.getDouble("totalAmount")/1000);
}else {
summaryBO.set("TQCGZE", lastYearMonthRow.getDouble("totalAmount"));
}
summaryBO.set("TQCGZL", lastYearMonthRow.getDouble("totalQuantity")); summaryBO.set("TQCGZL", lastYearMonthRow.getDouble("totalQuantity"));
} }
@ -657,10 +701,18 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
// "FROM " + PROCUREMENT_PURCHASE_ORDER_SUMMARY + // "FROM " + PROCUREMENT_PURCHASE_ORDER_SUMMARY +
// " WHERE BKGS = ? AND CGRQ = ? " + // " WHERE BKGS = ? AND CGRQ = ? " +
// "GROUP BY WLMC"; // "GROUP BY WLMC";
String querySql = "SELECT WLMC, SUM(JSHJHYF) AS totalAmount, SUM(RKSL) AS totalQuantity " + String querySql = "";
"FROM " + BO_EU_DWD_ORDER_RKD_HZ + if ("泰山石膏".equals(bkgs)) {
" WHERE BKGS = ? AND DJRQ = ? " + querySql = "SELECT WLMC, SUM(DHJE) AS totalAmount, SUM(RKSL) AS totalQuantity " +
"GROUP BY WLMC"; "FROM " + BO_EU_DWD_ORDER_RKD_HZ +
" WHERE BKGS = ? AND DJRQ = ? " +
"GROUP BY WLMC";
}else {
querySql = "SELECT WLMC, SUM(JSHJHYF) AS totalAmount, SUM(RKSL) AS totalQuantity " +
"FROM " + BO_EU_DWD_ORDER_RKD_HZ +
" WHERE BKGS = ? AND DJRQ = ? " +
"GROUP BY WLMC";
}
List<RowMap> dailyData = DBSql.getMaps(querySql, bkgs, dateStr); List<RowMap> dailyData = DBSql.getMaps(querySql, bkgs, dateStr);
// 3. 创建物料数据映射 // 3. 创建物料数据映射
@ -687,32 +739,20 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
RowMap row = dailyMap.get(wlmc); RowMap row = dailyMap.get(wlmc);
if (row == null || row.getDouble("totalAmount") == 0.0) continue; if (row == null || row.getDouble("totalAmount") == 0.0) continue;
double avgPrice = 0.00;
BO summaryBO = new BO(); BO summaryBO = new BO();
summaryBO.set("RQ", dateStr); summaryBO.set("RQ", dateStr);
// List<BO> bnbmCgPzwlfl = SDK.getBOAPI().query("BO_EU_BNBM_CG_PZWLFL"). summaryBO.set("WLMC", wlmc);
// addQuery("BKMC = ", bkgs).addQuery("WLMC LIKE '%" + wlmc + "%'", null).list(); if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
// if (bnbmCgPzwlfl!=null){ summaryBO.set("CGZE", row.getDouble("totalAmount")/1000);
// String wlfl = bnbmCgPzwlfl.stream().map(o -> o.getString("WLFL")).collect(Collectors.joining("|")); avgPrice = row.getDouble("totalQuantity") != 0 ?
// summaryBO.set("WLMC", wlfl); (row.getDouble("totalAmount")/1000) / row.getDouble("totalQuantity") : 0;
// }else {
if(("龙牌".equals(bkgs) || "梦牌".equals(bkgs) || "泰山石膏".equals(bkgs))
&& (wlmc.contains("脱硫石膏") || wlmc.contains("护面纸"))){
summaryBO.set("WLMC", "脱硫石膏");
} else if ("泰山石膏".equals(bkgs) && wlmc.contains("镀锌带钢")) {
summaryBO.set("WLMC", "镀锌带钢");
} else if (("龙牌".equals(bkgs) || "梦牌".equals(bkgs))
&& (wlmc.equals("轻钢镀锌带钢") || wlmc.equals("镀锌带钢"))) {
summaryBO.set("WLMC", "镀锌带钢");
} else if (("泰山石膏".equals(bkgs) || "龙牌".equals(bkgs) || "梦牌".equals(bkgs)) && wlmc.contains("乳液")) {
continue;
}else { }else {
summaryBO.set("WLMC", wlmc); summaryBO.set("CGZE", row.getDouble("totalAmount"));
avgPrice = row.getDouble("totalQuantity") != 0 ?
row.getDouble("totalAmount") / row.getDouble("totalQuantity") : 0;
} }
// }
summaryBO.set("CGZE", row.getDouble("totalAmount"));
summaryBO.set("CGZL", row.getDouble("totalQuantity")); summaryBO.set("CGZL", row.getDouble("totalQuantity"));
double avgPrice = row.getDouble("totalQuantity") != 0 ?
row.getDouble("totalAmount") / row.getDouble("totalQuantity") : 0;
summaryBO.set("PJDJ", avgPrice); summaryBO.set("PJDJ", avgPrice);
summaryBO.set("BKGS", bkgs); summaryBO.set("BKGS", bkgs);
bos.add(summaryBO); bos.add(summaryBO);
@ -781,7 +821,7 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
LOGGER.debug("正在处理第{}页入库数据,偏移量:{}", page + 1, offset); LOGGER.debug("正在处理第{}页入库数据,偏移量:{}", page + 1, offset);
String querySql = "SELECT DJRQ, DJH, WLMC, WLBM, GGXH, SLGC, SUM(RKSL) AS RKSL, " + String querySql = "SELECT DJRQ, DJH, WLMC, WLBM, GGXH, SLGC, SUM(RKSL) AS RKSL, " +
" JLDW, HSDJHYF, SUM(JEHYF) AS JEHYF, GYSNAME, CGDDH " + " JLDW, HSDJHYF, SUM(JEHYF) AS JEHYF, GYSNAME, CGDDH, DHJE " +
" FROM "+BO_EU_DWD_ORDER_RKD_HZ+" WHERE BKGS = ? AND DATE(DJRQ) = ? " + " FROM "+BO_EU_DWD_ORDER_RKD_HZ+" WHERE BKGS = ? AND DATE(DJRQ) = ? " +
" GROUP BY DJRQ,DJH,WLMC "+ " GROUP BY DJRQ,DJH,WLMC "+
" ORDER BY DJH LIMIT ? OFFSET ?"; " ORDER BY DJH LIMIT ? OFFSET ?";
@ -797,26 +837,18 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
detailBO.set("RKDH", row.getString("DJH")); // 入库单号 detailBO.set("RKDH", row.getString("DJH")); // 入库单号
detailBO.set("WLBM", row.getString("WLBM")); // 物料编码 detailBO.set("WLBM", row.getString("WLBM")); // 物料编码
String wlmc = row.getString("WLMC"); String wlmc = row.getString("WLMC");
if(("龙牌".equals(bkgs) || "梦牌".equals(bkgs) || "泰山石膏".equals(bkgs)) detailBO.set("WLMC", wlmc); // 物料名称
&& (wlmc.contains("脱硫石膏") || wlmc.contains("护面纸"))){
detailBO.set("WLMC", "脱硫石膏");
} else if ("泰山石膏".equals(bkgs) && wlmc.contains("镀锌带钢")) {
detailBO.set("WLMC", "镀锌带钢");
} else if (("龙牌".equals(bkgs) || "梦牌".equals(bkgs))
&& (wlmc.equals("轻钢镀锌带钢") || wlmc.equals("镀锌带钢"))) {
detailBO.set("WLMC", "镀锌带钢");
} else if (("泰山石膏".equals(bkgs) || "龙牌".equals(bkgs) || "梦牌".equals(bkgs)) && wlmc.contains("乳液")) {
continue;
}else {
detailBO.set("WLMC", wlmc);
}
// detailBO.set("WLMC", ); // 物料名称
detailBO.set("GGXH", row.getString("GGXH")); // 规格型号 detailBO.set("GGXH", row.getString("GGXH")); // 规格型号
detailBO.set("GC", row.getString("SLGC")); // 收料工厂 detailBO.set("GC", row.getString("SLGC")); // 收料工厂
detailBO.set("RKSL", row.getDouble("RKSL")); // 入库数量 detailBO.set("RKSL", row.getDouble("RKSL")); // 入库数量
detailBO.set("DW", row.getString("JLDW")); // 单位 detailBO.set("DW", row.getString("JLDW")); // 单位
detailBO.set("RKDJ", row.getDouble("HSDJHYF")); // 入库单价含税单价含运费 if ("泰山石膏".equals(bkgs)) {
detailBO.set("RKJE", row.getDouble("JEHYF")); // 入库金额金额含运费 detailBO.set("RKDJ", row.getDouble("DHJE")); // 入库单价含税单价含运费
detailBO.set("RKJE", row.getDouble("DHJE")); // 入库金额金额含运费
}else {
detailBO.set("RKDJ", row.getDouble("HSDJHYF")); // 入库单价含税单价含运费
detailBO.set("RKJE", row.getDouble("JEHYF")); // 入库金额金额含运费
}
detailBO.set("GYS", row.getString("GYSNAME")); // 供应商 detailBO.set("GYS", row.getString("GYSNAME")); // 供应商
detailBO.set("DDBH", row.getString("CGDDH")); // 订单编号 detailBO.set("DDBH", row.getString("CGDDH")); // 订单编号
detailBO.set("KCS", 0.00); // 库存数默认为0需后续计算 detailBO.set("KCS", 0.00); // 库存数默认为0需后续计算
@ -824,7 +856,6 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
detailBO.set("YEARMONTH", yearMonth); // 年月 detailBO.set("YEARMONTH", yearMonth); // 年月
bos.add(detailBO); bos.add(detailBO);
} }
// 批量插入当前页数据 // 批量插入当前页数据
if (!bos.isEmpty()) { if (!bos.isEmpty()) {
SDK.getBOAPI().createDataBO(BO_EU_CG_NYRKMX, bos, UserContext.fromUID("admin")); SDK.getBOAPI().createDataBO(BO_EU_CG_NYRKMX, bos, UserContext.fromUID("admin"));

View File

@ -670,6 +670,20 @@ public class PurchaseDataSyncServiceImpl implements DataSyncService {
String startDate = ""; String startDate = "";
String endDate = ""; String endDate = "";
PurchaseUtil purchaseUtil = new PurchaseUtil(); PurchaseUtil purchaseUtil = new PurchaseUtil();
// 查询嘉宝莉为盖的平均单价
Double gaiAverage = 0.00;
int gaiSum = 0;
RowMap map1 = DBSql.getMap("SELECT SUM(RKSL) AS gaiSum, SUM(DJHYF) AS gaiPrice FROM BO_EU_DWD_PUR_PURCHASE_ORDER" +
" WHERE WLMC LIKE '%盖%' AND DJHYF < 5");
if (map1!=null){
gaiSum = map1.getInt("gaiSum");
Double gaiPrice = map1.getDouble("gaiPrice");
if (gaiSum==0.0){
gaiAverage = 0.0;
}else {
gaiAverage = gaiPrice / gaiSum;
}
}
try { try {
do { do {
if (startDated == null || endDated == null) { if (startDated == null || endDated == null) {
@ -717,16 +731,35 @@ public class PurchaseDataSyncServiceImpl implements DataSyncService {
} }
// 如果是采购_入库单汇总 刷新物料名称 // 如果是采购_入库单汇总 刷新物料名称
if (hzb.equals("BO_EU_DWD_ORDER_RKD_HZ")){ if (hzb.equals("BO_EU_DWD_ORDER_RKD_HZ")){
String wlmc = bo.getString("WLMC");
String bkgs = bo.getString("BKGS"); String bkgs = bo.getString("BKGS");
String wlmc = bo.getString("WLMC");
String wlbm = bo.getString("WLBM"); String wlbm = bo.getString("WLBM");
String jldw = bo.getString("JLDW"); String jldw = bo.getString("JLDW");
String wlfl = bo.getString("WLFL"); String wlfl = bo.getString("WLFL");
Double djhyf = Double.parseDouble(bo.getString("DJHYF")); Double djhyf = Double.parseDouble(bo.getString("DJHYF"));
String newWlmc = purchaseUtil.materialClassificationFiltering(bkgs, wlmc, wlbm, jldw, djhyf, wlfl); String newWlmc = purchaseUtil.materialClassificationFiltering(bkgs, wlmc, wlbm, jldw, djhyf, wlfl);
if (bkgs.equals("北新嘉宝莉")) {
if (wlmc.contains("") && djhyf < 5.0){
continue;
} else if (wlmc.contains("桶身") && gaiSum > 0) {
Double djhyf1 = bo.get("DJHYF", Double.class);
bo.set("DJHYF", djhyf1 + gaiAverage);
gaiSum--;
}
}
bo.set("WLMC",newWlmc); bo.set("WLMC",newWlmc);
LOGGER.info("采购_入库单汇总,刷新物料名称------物料名称:{},板块公司:{},物料编码:{},入库单位:{},单价:{},物料分类:{}",wlmc,bkgs,wlbm,jldw,djhyf,wlfl); bo.set("OLDWLMC",wlmc);
// LOGGER.info("采购_入库单汇总,刷新物料名称------物料名称:{},板块公司:{},物料编码:{},入库单位:{},单价:{},物料分类:{}",wlmc,bkgs,wlbm,jldw,djhyf,wlfl);
if ("泰山石膏".equals(bkgs)){
// 泰山石膏处理入库单金额 入库数量*含税单价
Double rksl = bo.get("RKSL", Double.class);// 入库数量
Double hsdjhyf = bo.get("HSDJHYF", Double.class);// 含税单价含运费
BigDecimal multiply = BigDecimal.valueOf(rksl).multiply(BigDecimal.valueOf(hsdjhyf));
bo.set("DHJE",multiply.doubleValue());
}
} }
bos.add(bo); bos.add(bo);
} }

View File

@ -29,45 +29,48 @@ public class PurchaseUtil {
} }
// 煤炭 // 煤炭
else if (("龙牌".equals(bkgs) || "梦牌".equals(bkgs) else if (("龙牌".equals(bkgs) || "梦牌".equals(bkgs)
&& ("煤炭".contains(wlmc) || "籽煤".contains(wlmc) || "褐煤".contains(wlmc)))) { && (wlmc.contains("煤炭") || wlmc.contains("煤炭") || wlmc.contains("煤炭")))) {
newWlmc = "煤炭"; newWlmc = "煤炭";
} else if ("泰山石膏".equals(bkgs) && ("原煤".contains(wlmc) || "contains".equals(wlmc) || "contains".equals(wlmc))) { } else if ("泰山石膏".equals(bkgs) && (wlmc.contains("原煤") || wlmc.contains("水洗精煤") || wlmc.contains("褐煤"))) {
newWlmc = "煤炭"; newWlmc = "煤炭";
} }
// 护面纸 // 护面纸
else if (("龙牌".equals(bkgs) || "泰山石膏".equals(bkgs)) else if (("龙牌".equals(bkgs) || "泰山石膏".equals(bkgs))
&& "护面纸".contains(wlmc)) { && wlmc.contains("护面纸")) {
newWlmc = "护面纸"; newWlmc = "护面纸";
} }
// 乳液 // 乳液
else if (("北新防水".equals(bkgs) || "北新涂料".equals(bkgs) || "北新嘉宝莉".equals(bkgs) else if ("北新嘉宝莉".equals(bkgs) && wlbm.contains("11M")){
&& "乳液".contains(wlmc))){ newWlmc = "乳液";
} else if ("北新防水".equals(bkgs) && wlbm.contains("5070201")) {
newWlmc = "乳液";
} else if ("北新涂料".equals(bkgs) && wlbm.contains("10114137")) {
newWlmc = "乳液"; newWlmc = "乳液";
} }
// 钛白粉 // 钛白粉
else if (("北新防水".equals(bkgs) || "北新涂料".equals(bkgs) || "北新嘉宝莉".equals(bkgs) else if (("北新防水".equals(bkgs) || "北新涂料".equals(bkgs) || "北新嘉宝莉".equals(bkgs))
&& "钛白粉".contains(wlmc))){ && wlmc.contains("钛白粉")){
newWlmc = "钛白粉"; newWlmc = "钛白粉";
} }
// 重钙 // 重钙
else if (("北新防水".equals(bkgs) || "北新涂料".equals(bkgs) || "北新嘉宝莉".equals(bkgs) else if (("北新防水".equals(bkgs) || "北新涂料".equals(bkgs) || "北新嘉宝莉".equals(bkgs))
&& "重钙".contains(wlmc))){ && wlmc.contains("重钙")){
newWlmc = "重钙"; newWlmc = "重钙";
} }
// 包装袋 // 包装袋
else if ("龙牌".equals(bkgs) && ("编织袋".equals(wlmc) || "阀口袋".equals(wlmc) || "两纸一膜".equals(wlmc) else if ("龙牌".equals(bkgs) && (wlmc.equals("编织袋") || wlmc.equals("阀口袋") || wlmc.equals("两纸一膜")
|| "三纸一膜".contains(wlmc) || "包装袋".contains(wlmc) || "包装".contains(wlmc))) { || wlmc.contains("三纸一膜") || wlmc.contains("包装袋") || wlmc.contains("包装"))) {
newWlmc = "包装袋"; newWlmc = "包装袋";
} else if ("泰山石膏".equals(bkgs) && ("编织袋".contains(wlmc) || "纸袋".contains(wlmc))) { } else if ("泰山石膏".equals(bkgs) && (wlmc.contains("编织袋") || wlmc.contains("纸袋"))) {
newWlmc = "包装袋"; newWlmc = "包装袋";
} else if ("梦牌".equals(bkgs) && "包装袋".contains(wlmc)) { } else if ("梦牌".equals(bkgs) && wlmc.contains("包装袋")) {
newWlmc = "包装袋"; newWlmc = "包装袋";
} else if ("北新防水".equals(bkgs) && ("包装袋".contains(wlmc) || "阀口袋".contains(wlmc) || "口袋".contains(wlmc))) { } else if ("北新防水".equals(bkgs) && (wlmc.contains("包装袋") || wlmc.contains("阀口袋") || wlmc.contains("口袋"))) {
newWlmc = "包装袋"; newWlmc = "包装袋";
} else if ("北新涂料".equals(bkgs) && "包装袋".contains(wlmc)) { } else if ("北新涂料".equals(bkgs) && wlmc.contains("包装袋")) {
newWlmc = "包装袋"; newWlmc = "包装袋";
} else if ("北新嘉宝莉".equals(bkgs) && ("阀口袋".contains(wlmc) || "腻子粉袋".contains(wlmc) || "阀口纸袋".contains(wlmc) } else if ("北新嘉宝莉".equals(bkgs) && (wlmc.contains("阀口袋") || wlmc.contains("腻子粉袋") || wlmc.contains("阀口纸袋")
|| "纸袋".equals(wlmc) || "编织袋".equals(wlmc))) { || wlmc.equals("纸袋") || wlmc.equals("编织袋"))) {
newWlmc = "包装袋"; newWlmc = "包装袋";
} }
// 包装桶 // 包装桶