1、物料分析计算处理
This commit is contained in:
parent
8a7b6ce38c
commit
2fdde8355b
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -443,7 +443,7 @@ public class DataLinkUpController {
|
|||||||
.addQuery("BINDID =", bindId)
|
.addQuery("BINDID =", bindId)
|
||||||
.list();
|
.list();
|
||||||
//获取板块公司
|
//获取板块公司
|
||||||
List<RowMap> maps = DBSql.getMaps("SELECT BKGS FROM " + targetTable + "GROUP BY BKGS");
|
List<RowMap> maps = DBSql.getMaps("SELECT BKGS FROM " + targetTable + " GROUP BY BKGS");
|
||||||
String bkgss = maps.stream().map(o -> o.getString("BKGS")).collect(Collectors.joining(","));
|
String bkgss = maps.stream().map(o -> o.getString("BKGS")).collect(Collectors.joining(","));
|
||||||
String[] bkgsArr = bkgss.split(",");
|
String[] bkgsArr = bkgss.split(",");
|
||||||
|
|
||||||
|
|||||||
@ -106,8 +106,8 @@ public class WaterproofPaintAccountsReceivableJob implements IJob {
|
|||||||
// RDSAPI rdsapi = SDK.getCCAPI().getRDSAPI(RDS_ID);
|
// RDSAPI rdsapi = SDK.getCCAPI().getRDSAPI(RDS_ID);
|
||||||
|
|
||||||
// 查询销售组织和客户分组信息
|
// 查询销售组织和客户分组信息
|
||||||
List<RowMap> maps = DBSql.getMaps("SELECT FMANAGEREGIONNAME, FCUSTNAME, FPROVINCE,FCITY FROM " +
|
List<RowMap> maps = DBSql.getMaps("SELECT QYGS, FCUSTNAME, SQ AS FPROVINCE,CS AS FCITY FROM " +
|
||||||
section.getYsdTable() + " GROUP BY FMANAGEREGIONNAME, FCUSTNAME, FPROVINCE,FCITY");
|
section.getYsdTable() + " GROUP BY QYGS, FCUSTNAME, SQ,CS");
|
||||||
|
|
||||||
|
|
||||||
if (maps == null || maps.isEmpty()) {
|
if (maps == null || maps.isEmpty()) {
|
||||||
@ -128,8 +128,8 @@ public class WaterproofPaintAccountsReceivableJob implements IJob {
|
|||||||
// 遍历每个销售组织-客户组合
|
// 遍历每个销售组织-客户组合
|
||||||
for (RowMap row : maps) {
|
for (RowMap row : maps) {
|
||||||
try {
|
try {
|
||||||
String manageRegionName = row.getString("FMANAGEREGIONNAME");
|
String manageRegionName = row.getString("QYGS");
|
||||||
String saleOrgUnit = row.getString("FSALEORGUNIT");
|
String saleOrgUnit = row.getString("XSZZ");
|
||||||
String custName = row.getString("FCUSTNAME");
|
String custName = row.getString("FCUSTNAME");
|
||||||
|
|
||||||
// 查询省市区信息
|
// 查询省市区信息
|
||||||
@ -214,8 +214,8 @@ public class WaterproofPaintAccountsReceivableJob implements IJob {
|
|||||||
try {
|
try {
|
||||||
// 查询应收单总额
|
// 查询应收单总额
|
||||||
RowMap ysResult = DBSql.getMap(
|
RowMap ysResult = DBSql.getMap(
|
||||||
"SELECT SUM(FSALEAMOUNTRMB) as total FROM " + section.getYsdTable() +
|
"SELECT SUM(SSJERMB) as total FROM " + section.getYsdTable() +
|
||||||
" WHERE FSALEORGUNIT = ? AND FCUSTNAME = ? AND FBILLDATE BETWEEN ? AND ?",
|
" WHERE XSZZ = ? AND FCUSTNAME = ? AND DZRQ BETWEEN ? AND ?",
|
||||||
saleOrgUnit, custName, java.sql.Date.valueOf(startDate), java.sql.Date.valueOf(endDate)
|
saleOrgUnit, custName, java.sql.Date.valueOf(startDate), java.sql.Date.valueOf(endDate)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -258,8 +258,8 @@ public class WaterproofPaintAccountsReceivableJob implements IJob {
|
|||||||
LocalDate startDate, LocalDate endDate) {
|
LocalDate startDate, LocalDate endDate) {
|
||||||
try {
|
try {
|
||||||
RowMap result = DBSql.getMap(
|
RowMap result = DBSql.getMap(
|
||||||
"SELECT SUM(FSALEAMOUNTRMB) as total FROM " + section.getYsdTable() +
|
"SELECT SUM(SSJERMB) as total FROM " + section.getYsdTable() +
|
||||||
" WHERE FSALEORGUNIT = ? AND FCUSTNAME = ? AND FBILLDATE BETWEEN ? AND ?",
|
" WHERE XSZZ = ? AND FCUSTNAME = ? AND DZRQ BETWEEN ? AND ?",
|
||||||
saleOrgUnit, custName, java.sql.Date.valueOf(startDate), java.sql.Date.valueOf(endDate)
|
saleOrgUnit, custName, java.sql.Date.valueOf(startDate), java.sql.Date.valueOf(endDate)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -266,45 +267,27 @@ 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 = "";
|
String field = "";
|
||||||
if ("泰山石膏".equals(bkgs)) {
|
if ("泰山石膏".equals(bkgs)) {
|
||||||
currentMonthSql = "SELECT WLMC, SLGC, SUM(DHJE) AS totalAmount, SUM(RKSL) AS totalQuantity " +
|
field = " SUM(DHJE) ";
|
||||||
"FROM " + BO_EU_DWD_ORDER_RKD_HZ +
|
|
||||||
" WHERE BKGS = ? AND DJRQ LIKE ? " +
|
|
||||||
"GROUP BY WLMC, SLGC";
|
|
||||||
}else {
|
}else {
|
||||||
currentMonthSql = "SELECT WLMC, SLGC, SUM(JSHJHYF) AS totalAmount, SUM(RKSL) AS totalQuantity " +
|
field = " SUM(JSHJHYF) ";
|
||||||
"FROM " + BO_EU_DWD_ORDER_RKD_HZ +
|
|
||||||
" WHERE BKGS = ? AND DJRQ LIKE ? " +
|
|
||||||
"GROUP BY WLMC, SLGC";
|
|
||||||
}
|
}
|
||||||
|
String currentMonthSql = "SELECT WLMC, SLGC, "+field+" 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 + "%");
|
||||||
|
|
||||||
// 上月数据
|
// 上月数据
|
||||||
List<RowMap> lastMonthData = Collections.emptyList();
|
List<RowMap> lastMonthData = Collections.emptyList();
|
||||||
if (StringUtils.isNotBlank(yearLastMonth)) {
|
if (StringUtils.isNotBlank(yearLastMonth)) {
|
||||||
// String lastMonthSql = "SELECT WLMC, XQGC, SUM(JSHJ) AS totalAmount, SUM(YSSL) AS totalQuantity " +
|
|
||||||
// "FROM " + PROCUREMENT_PURCHASE_ORDER_SUMMARY +
|
|
||||||
// " WHERE BKGS = ? AND CGRQ LIKE ? " +
|
|
||||||
// "GROUP BY WLMC, XQGC";
|
|
||||||
// String lastMonthSql = "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";
|
|
||||||
lastMonthData = DBSql.getMaps(currentMonthSql, bkgs, yearLastMonth + "%");
|
lastMonthData = DBSql.getMaps(currentMonthSql, bkgs, yearLastMonth + "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 去年同期数据
|
// 去年同期数据
|
||||||
List<RowMap> lastYearMonthData = Collections.emptyList();
|
List<RowMap> lastYearMonthData = Collections.emptyList();
|
||||||
if (StringUtils.isNotBlank(lastYearMonth)) {
|
if (StringUtils.isNotBlank(lastYearMonth)) {
|
||||||
// String lastYearMonthSql = "SELECT WLMC, XQGC, SUM(JSHJ) AS totalAmount, SUM(YSSL) AS totalQuantity " +
|
|
||||||
// "FROM " + PROCUREMENT_PURCHASE_ORDER_SUMMARY +
|
|
||||||
// " WHERE BKGS = ? AND CGRQ LIKE ? " +
|
|
||||||
// "GROUP BY WLMC, XQGC";
|
|
||||||
// String lastYearMonthSql = "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";
|
|
||||||
lastYearMonthData = DBSql.getMaps(currentMonthSql, bkgs, lastYearMonth + "%");
|
lastYearMonthData = DBSql.getMaps(currentMonthSql, bkgs, lastYearMonth + "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,76 +362,121 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
|||||||
));
|
));
|
||||||
|
|
||||||
// 4. 获取所有基地
|
// 4. 获取所有基地
|
||||||
Set<String> bases = new HashSet<>();
|
// Set<String> bases = new HashSet<>();
|
||||||
for (RowMap row : currentMonthData) {
|
// for (RowMap row : currentMonthData) {
|
||||||
bases.add(row.getString("SLGC"));
|
// bases.add(row.getString("SLGC"));
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 5. 批量插入
|
// 5. 批量插入
|
||||||
List<BO> bos = new ArrayList<>();
|
List<BO> bos = new ArrayList<>();
|
||||||
for (String wlmc : distinctList) {
|
for (RowMap currentMonthRow : currentMonthData) {
|
||||||
for (String base : bases) {
|
String base = currentMonthRow.getString("SLGC");
|
||||||
String key = wlmc + "|" + base;
|
String wlmc = currentMonthRow.getString("WLMC");
|
||||||
RowMap currentMonthRow = currentMonthMap.get(key);
|
String key = wlmc + "|" + base;
|
||||||
if (currentMonthRow == null || currentMonthRow.getDouble("totalAmount") == 0.0) continue;
|
double avgPrice = 0.00;
|
||||||
|
BO summaryBO = new BO();
|
||||||
|
summaryBO.set("BKGS", bkgs);
|
||||||
|
summaryBO.set("JD", base);
|
||||||
|
summaryBO.set("WLMC",wlmc);
|
||||||
|
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
||||||
|
double totalQuantity = BigDecimal.valueOf(currentMonthRow.getDouble("totalQuantity"))
|
||||||
|
.divide(BigDecimal.valueOf(1000), 4, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||||
|
double totalAmount = currentMonthRow.getDouble("totalAmount");
|
||||||
|
|
||||||
double avgPrice = 0.00;
|
summaryBO.set("CGZL", totalQuantity);
|
||||||
BO summaryBO = new BO();
|
// 添加除数非零检查
|
||||||
summaryBO.set("BKGS", bkgs);
|
if (totalAmount != 0 && totalQuantity != 0) {
|
||||||
summaryBO.set("JD", base);
|
avgPrice = BigDecimal.valueOf(totalAmount)
|
||||||
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
.divide(BigDecimal.valueOf(totalQuantity), 2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||||
summaryBO.set("CGZE", currentMonthRow.getDouble("totalAmount")/1000);
|
} else {
|
||||||
avgPrice = currentMonthRow.getDouble("totalQuantity") != 0 ?
|
avgPrice = 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("YEARMONTH", yearMonth);
|
}else {
|
||||||
summaryBO.set("CGZE", currentMonthRow.getDouble("totalAmount"));
|
double totalQuantity = currentMonthRow.getDouble("totalQuantity");
|
||||||
summaryBO.set("CGZL", currentMonthRow.getDouble("totalQuantity"));
|
double totalAmount = currentMonthRow.getDouble("totalAmount");
|
||||||
|
|
||||||
summaryBO.set("PJDJ", avgPrice);
|
summaryBO.set("CGZL", totalQuantity);
|
||||||
|
// 添加除数非零检查
|
||||||
// 添加上月数据
|
if (totalAmount != 0 && totalQuantity != 0) {
|
||||||
RowMap lastMonthRow = lastMonthMap.get(key);
|
avgPrice = BigDecimal.valueOf(totalAmount)
|
||||||
if (lastMonthRow != null) {
|
.divide(BigDecimal.valueOf(totalQuantity), 2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||||
double lastMonthAvgPrice = 0.00;
|
} else {
|
||||||
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
avgPrice = 0;
|
||||||
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("SQPJDJ", lastMonthAvgPrice);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加去年同期数据
|
|
||||||
RowMap lastYearMonthRow = lastYearMonthMap.get(key);
|
|
||||||
if (lastYearMonthRow != null) {
|
|
||||||
double lastYearMonthAvgPrice = 0.00;
|
|
||||||
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
|
||||||
summaryBO.set("TQCGZE", lastYearMonthRow.getDouble("totalAmount")/1000);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
bos.add(summaryBO);
|
|
||||||
}
|
}
|
||||||
}
|
summaryBO.set("YEARMONTH", yearMonth);
|
||||||
|
summaryBO.set("CGZE", currentMonthRow.getDouble("totalAmount"));
|
||||||
|
summaryBO.set("PJDJ", avgPrice);
|
||||||
|
|
||||||
|
// 添加上月数据
|
||||||
|
RowMap lastMonthRow = lastMonthMap.get(key);
|
||||||
|
if (lastMonthRow != null) {
|
||||||
|
double lastMonthAvgPrice = 0.00;
|
||||||
|
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
||||||
|
double totalQuantity = BigDecimal.valueOf(lastMonthRow.getDouble("totalQuantity"))
|
||||||
|
.divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||||
|
double totalAmount = lastMonthRow.getDouble("totalAmount");
|
||||||
|
|
||||||
|
summaryBO.set("SQCGZL", totalQuantity);
|
||||||
|
// 添加除数非零检查
|
||||||
|
if (totalAmount != 0 && totalQuantity != 0) {
|
||||||
|
lastMonthAvgPrice = BigDecimal.valueOf(totalAmount)
|
||||||
|
.divide(BigDecimal.valueOf(totalQuantity), 2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||||
|
} else {
|
||||||
|
lastMonthAvgPrice = 0;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
double totalQuantity = lastMonthRow.getDouble("totalQuantity");
|
||||||
|
double totalAmount = lastMonthRow.getDouble("totalAmount");
|
||||||
|
|
||||||
|
summaryBO.set("SQCGZL", totalQuantity);
|
||||||
|
// 添加除数非零检查
|
||||||
|
if (totalAmount != 0 && totalQuantity != 0) {
|
||||||
|
lastMonthAvgPrice = BigDecimal.valueOf(totalAmount)
|
||||||
|
.divide(BigDecimal.valueOf(totalQuantity), 2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||||
|
} else {
|
||||||
|
lastMonthAvgPrice = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
summaryBO.set("SQCGZE", lastMonthRow.getDouble("totalAmount"));
|
||||||
|
summaryBO.set("SQPJDJ", lastMonthAvgPrice);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加去年同期数据
|
||||||
|
RowMap lastYearMonthRow = lastYearMonthMap.get(key);
|
||||||
|
if (lastYearMonthRow != null) {
|
||||||
|
double lastYearMonthAvgPrice = 0.00;
|
||||||
|
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
||||||
|
double totalQuantity = BigDecimal.valueOf(lastYearMonthRow.getDouble("totalQuantity"))
|
||||||
|
.divide(BigDecimal.valueOf(1000), 2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||||
|
double totalAmount = lastYearMonthRow.getDouble("totalAmount");
|
||||||
|
|
||||||
|
summaryBO.set("TQCGZL", totalQuantity);
|
||||||
|
// 添加除数非零检查
|
||||||
|
if (totalAmount != 0 && totalQuantity != 0) {
|
||||||
|
lastYearMonthAvgPrice = BigDecimal.valueOf(totalAmount)
|
||||||
|
.divide(BigDecimal.valueOf(totalQuantity), 2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||||
|
} else {
|
||||||
|
lastYearMonthAvgPrice = 0;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
double totalQuantity = lastYearMonthRow.getDouble("totalQuantity");
|
||||||
|
double totalAmount = lastYearMonthRow.getDouble("totalAmount");
|
||||||
|
|
||||||
|
summaryBO.set("TQCGZL", totalQuantity);
|
||||||
|
// 添加除数非零检查
|
||||||
|
if (totalAmount != 0 && totalQuantity != 0) {
|
||||||
|
lastYearMonthAvgPrice = BigDecimal.valueOf(totalAmount)
|
||||||
|
.divide(BigDecimal.valueOf(totalQuantity), 2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||||
|
} else {
|
||||||
|
lastYearMonthAvgPrice = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
summaryBO.set("TQCGZE",lastYearMonthRow.getDouble("totalAmount"));
|
||||||
|
summaryBO.set("TQPJDJ", lastYearMonthAvgPrice);
|
||||||
|
}
|
||||||
|
bos.add(summaryBO);
|
||||||
|
}
|
||||||
if (!bos.isEmpty()) {
|
if (!bos.isEmpty()) {
|
||||||
// 批量插入数据
|
// 批量插入数据
|
||||||
int batchSize = 1000;
|
int batchSize = 1000;
|
||||||
@ -458,7 +486,6 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
|||||||
SDK.getBOAPI().createDataBO(JD_PROCUREMENT_DETAILS_YEAR_MONTH, batch, UserContext.fromUID("admin"));
|
SDK.getBOAPI().createDataBO(JD_PROCUREMENT_DETAILS_YEAR_MONTH, batch, UserContext.fromUID("admin"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGGER.info("成功保存{}条月度基地汇总数据,板块:{}", bos.size(), bkgs);
|
LOGGER.info("成功保存{}条月度基地汇总数据,板块:{}", bos.size(), bkgs);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -492,61 +519,27 @@ 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 = "";
|
String field = "";
|
||||||
if ("泰山石膏".equals(bkgs)) {
|
if ("泰山石膏".equals(bkgs)) {
|
||||||
currentMonthSql = "SELECT WLMC, SUM(DHJE) AS totalAmount, SUM(RKSL) AS totalQuantity " +
|
field = " SUM(DHJE) ";
|
||||||
" FROM " + BO_EU_DWD_ORDER_RKD_HZ +
|
|
||||||
" WHERE BKGS = ? AND DJRQ LIKE ? " +
|
|
||||||
" GROUP BY WLMC";
|
|
||||||
}else {
|
}else {
|
||||||
currentMonthSql = "SELECT WLMC, SUM(JSHJHYF) AS totalAmount, SUM(RKSL) AS totalQuantity " +
|
field = " SUM(JSHJHYF) ";
|
||||||
" FROM " + BO_EU_DWD_ORDER_RKD_HZ +
|
|
||||||
" WHERE BKGS = ? AND DJRQ LIKE ? " +
|
|
||||||
" GROUP BY WLMC";
|
|
||||||
}
|
}
|
||||||
|
String currentMonthSql = "SELECT WLMC, "+field+" 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 + "%");
|
||||||
|
|
||||||
// 上月数据
|
// 上月数据
|
||||||
List<RowMap> lastMonthData = Collections.emptyList();
|
List<RowMap> lastMonthData = Collections.emptyList();
|
||||||
if (StringUtils.isNotBlank(yearLastMonth)) {
|
if (StringUtils.isNotBlank(yearLastMonth)) {
|
||||||
// String lastMonthSql = "SELECT WLMC, SUM(JSHJ) AS totalAmount, SUM(YSSL) AS totalQuantity " +
|
|
||||||
// "FROM " + PROCUREMENT_PURCHASE_ORDER_SUMMARY +
|
|
||||||
// " WHERE BKGS = ? AND CGRQ LIKE ? " +
|
|
||||||
// "GROUP BY WLMC";
|
|
||||||
// String lastMonthSql = "";
|
|
||||||
// if ("泰山石膏".equals(bkgs)) {
|
|
||||||
// lastMonthSql = "SELECT WLMC, SUM(DHJE) AS totalAmount, SUM(RKSL) AS totalQuantity " +
|
|
||||||
// " FROM " + BO_EU_DWD_ORDER_RKD_HZ +
|
|
||||||
// " 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 + "%");
|
lastMonthData = DBSql.getMaps(currentMonthSql, bkgs, yearLastMonth + "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 去年同期数据
|
// 去年同期数据
|
||||||
List<RowMap> lastYearMonthData = Collections.emptyList();
|
List<RowMap> lastYearMonthData = Collections.emptyList();
|
||||||
if (StringUtils.isNotBlank(lastYearMonth)) {
|
if (StringUtils.isNotBlank(lastYearMonth)) {
|
||||||
// String lastYearMonthSql = "SELECT WLMC, SUM(JSHJ) AS totalAmount, SUM(YSSL) AS totalQuantity " +
|
|
||||||
// "FROM " + PROCUREMENT_PURCHASE_ORDER_SUMMARY +
|
|
||||||
// " WHERE BKGS = ? AND CGRQ LIKE ? " +
|
|
||||||
// "GROUP BY WLMC";
|
|
||||||
// String lastYearMonthSql = "";
|
|
||||||
// if ("泰山石膏".equals(bkgs)) {
|
|
||||||
// lastYearMonthSql = "SELECT WLMC, SUM(DHJE) AS totalAmount, SUM(RKSL) AS totalQuantity " +
|
|
||||||
// " FROM " + BO_EU_DWD_ORDER_RKD_HZ +
|
|
||||||
// " 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 + "%");
|
lastYearMonthData = DBSql.getMaps(currentMonthSql, bkgs, lastYearMonth + "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -618,37 +611,51 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
|||||||
summaryBO.set("YEARMONTH", yearMonth);
|
summaryBO.set("YEARMONTH", yearMonth);
|
||||||
summaryBO.set("WLMC", wlmc);
|
summaryBO.set("WLMC", wlmc);
|
||||||
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
||||||
summaryBO.set("CGZE", currentMonthRow.getDouble("totalAmount")/1000);
|
double totalQuantity = currentMonthRow.getDouble("totalQuantity");
|
||||||
avgPrice = currentMonthRow.getDouble("totalQuantity") != 0 ?
|
double totalAmount = currentMonthRow.getDouble("totalAmount");
|
||||||
(currentMonthRow.getDouble("totalAmount")/1000) / currentMonthRow.getDouble("totalQuantity") : 0;
|
summaryBO.set("CGZL", totalQuantity!=0?totalQuantity/1000:0);
|
||||||
|
if (totalAmount!=0 || totalQuantity!=0) {
|
||||||
|
avgPrice = totalAmount / (totalQuantity / 1000);
|
||||||
|
}else {
|
||||||
|
avgPrice = 0;
|
||||||
|
}
|
||||||
}else {
|
}else {
|
||||||
summaryBO.set("CGZE", currentMonthRow.getDouble("totalAmount"));
|
double totalQuantity = currentMonthRow.getDouble("totalQuantity");
|
||||||
avgPrice = currentMonthRow.getDouble("totalQuantity") != 0 ?
|
double totalAmount = currentMonthRow.getDouble("totalAmount");
|
||||||
currentMonthRow.getDouble("totalAmount") / currentMonthRow.getDouble("totalQuantity") : 0;
|
summaryBO.set("CGZL", totalQuantity);
|
||||||
|
if (totalAmount!=0 || totalQuantity!=0) {
|
||||||
|
avgPrice = totalAmount / totalQuantity;
|
||||||
|
}else {
|
||||||
|
avgPrice = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
summaryBO.set("CGZL", currentMonthRow.getDouble("totalQuantity"));
|
summaryBO.set("CGZE", currentMonthRow.getDouble("totalAmount"));
|
||||||
summaryBO.set("PJDJ", avgPrice);
|
summaryBO.set("PJDJ", avgPrice);
|
||||||
|
|
||||||
// 添加上月数据
|
// 添加上月数据
|
||||||
RowMap lastMonthRow = lastMonthMap.get(wlmc);
|
RowMap lastMonthRow = lastMonthMap.get(wlmc);
|
||||||
if (lastMonthRow != null) {
|
if (lastMonthRow != null) {
|
||||||
|
double totalQuantity = lastMonthRow.getDouble("totalQuantity");
|
||||||
|
double totalAmount = lastMonthRow.getDouble("totalAmount");
|
||||||
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
||||||
summaryBO.set("SQCGZE", lastMonthRow.getDouble("totalAmount")/1000);
|
summaryBO.set("SQCGZL", totalQuantity!=0?totalQuantity/1000:0);
|
||||||
}else {
|
}else {
|
||||||
summaryBO.set("SQCGZE", lastMonthRow.getDouble("totalAmount"));
|
summaryBO.set("SQCGZL", totalQuantity);
|
||||||
}
|
}
|
||||||
summaryBO.set("SQCGZL", lastMonthRow.getDouble("totalQuantity"));
|
summaryBO.set("SQCGZE", totalAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加去年同期数据
|
// 添加去年同期数据
|
||||||
RowMap lastYearMonthRow = lastYearMonthMap.get(wlmc);
|
RowMap lastYearMonthRow = lastYearMonthMap.get(wlmc);
|
||||||
if (lastYearMonthRow != null) {
|
if (lastYearMonthRow != null) {
|
||||||
|
double totalQuantity = lastYearMonthRow.getDouble("totalQuantity");
|
||||||
|
double totalAmount = lastYearMonthRow.getDouble("totalAmount");
|
||||||
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
||||||
summaryBO.set("TQCGZE", lastYearMonthRow.getDouble("totalAmount")/1000);
|
summaryBO.set("TQCGZL", totalQuantity!=0?totalQuantity/1000:0);
|
||||||
}else {
|
}else {
|
||||||
summaryBO.set("TQCGZE", lastYearMonthRow.getDouble("totalAmount"));
|
summaryBO.set("TQCGZL", totalQuantity);
|
||||||
}
|
}
|
||||||
summaryBO.set("TQCGZL", lastYearMonthRow.getDouble("totalQuantity"));
|
summaryBO.set("TQCGZE", totalAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
summaryBO.set("BKGS", bkgs);
|
summaryBO.set("BKGS", bkgs);
|
||||||
@ -701,18 +708,16 @@ 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 = "";
|
String field = "";
|
||||||
if ("泰山石膏".equals(bkgs)) {
|
if ("泰山石膏".equals(bkgs)) {
|
||||||
querySql = "SELECT WLMC, SUM(DHJE) AS totalAmount, SUM(RKSL) AS totalQuantity " +
|
field = " SUM(DHJE) ";
|
||||||
"FROM " + BO_EU_DWD_ORDER_RKD_HZ +
|
|
||||||
" WHERE BKGS = ? AND DJRQ = ? " +
|
|
||||||
"GROUP BY WLMC";
|
|
||||||
}else {
|
}else {
|
||||||
querySql = "SELECT WLMC, SUM(JSHJHYF) AS totalAmount, SUM(RKSL) AS totalQuantity " +
|
field = " SUM(JSHJHYF) ";
|
||||||
"FROM " + BO_EU_DWD_ORDER_RKD_HZ +
|
|
||||||
" WHERE BKGS = ? AND DJRQ = ? " +
|
|
||||||
"GROUP BY WLMC";
|
|
||||||
}
|
}
|
||||||
|
String querySql = "SELECT WLMC, "+field+" 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. 创建物料数据映射
|
||||||
@ -744,15 +749,15 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
|||||||
summaryBO.set("RQ", dateStr);
|
summaryBO.set("RQ", dateStr);
|
||||||
summaryBO.set("WLMC", wlmc);
|
summaryBO.set("WLMC", wlmc);
|
||||||
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
if (wlmc.equals("乳液") || wlmc.equals("钛白粉") || wlmc.equals("重钙")){
|
||||||
summaryBO.set("CGZE", row.getDouble("totalAmount")/1000);
|
summaryBO.set("CGZL", row.getDouble("totalQuantity")/1000);
|
||||||
avgPrice = row.getDouble("totalQuantity") != 0 ?
|
avgPrice = row.getDouble("totalAmount") != 0 ?
|
||||||
(row.getDouble("totalAmount")/1000) / row.getDouble("totalQuantity") : 0;
|
row.getDouble("totalAmount") / (row.getDouble("totalQuantity")/1000) : 0;
|
||||||
}else {
|
}else {
|
||||||
summaryBO.set("CGZE", row.getDouble("totalAmount"));
|
summaryBO.set("CGZL", row.getDouble("totalQuantity"));
|
||||||
avgPrice = row.getDouble("totalQuantity") != 0 ?
|
avgPrice = row.getDouble("totalAmount") != 0 ?
|
||||||
row.getDouble("totalAmount") / row.getDouble("totalQuantity") : 0;
|
row.getDouble("totalAmount") / row.getDouble("totalQuantity") : 0;
|
||||||
}
|
}
|
||||||
summaryBO.set("CGZL", row.getDouble("totalQuantity"));
|
summaryBO.set("CGZE", row.getDouble("totalAmount"));
|
||||||
summaryBO.set("PJDJ", avgPrice);
|
summaryBO.set("PJDJ", avgPrice);
|
||||||
summaryBO.set("BKGS", bkgs);
|
summaryBO.set("BKGS", bkgs);
|
||||||
bos.add(summaryBO);
|
bos.add(summaryBO);
|
||||||
@ -843,7 +848,7 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
|||||||
detailBO.set("RKSL", row.getDouble("RKSL")); // 入库数量
|
detailBO.set("RKSL", row.getDouble("RKSL")); // 入库数量
|
||||||
detailBO.set("DW", row.getString("JLDW")); // 单位
|
detailBO.set("DW", row.getString("JLDW")); // 单位
|
||||||
if ("泰山石膏".equals(bkgs)) {
|
if ("泰山石膏".equals(bkgs)) {
|
||||||
detailBO.set("RKDJ", row.getDouble("DHJE")); // 入库单价(含税单价含运费)
|
detailBO.set("RKDJ", row.getDouble("HSDJHYF")); // 入库单价(含税单价含运费)
|
||||||
detailBO.set("RKJE", row.getDouble("DHJE")); // 入库金额(金额含运费)
|
detailBO.set("RKJE", row.getDouble("DHJE")); // 入库金额(金额含运费)
|
||||||
}else {
|
}else {
|
||||||
detailBO.set("RKDJ", row.getDouble("HSDJHYF")); // 入库单价(含税单价含运费)
|
detailBO.set("RKDJ", row.getDouble("HSDJHYF")); // 入库单价(含税单价含运费)
|
||||||
|
|||||||
@ -755,38 +755,61 @@ public class PurchaseDataSyncServiceImpl implements DataSyncService {
|
|||||||
bo.set(key, map.get(key));
|
bo.set(key, map.get(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 如果是采购_入库单汇总 刷新物料名称
|
// LOGGER.info("明细汇总:字段值set完毕-01");
|
||||||
if (hzb.equals("BO_EU_DWD_ORDER_RKD_HZ")){
|
if (bo!=null) {
|
||||||
String bkgs = bo.getString("BKGS");
|
// 如果是采购_入库单汇总 刷新物料名称
|
||||||
String wlmc = bo.getString("WLMC");
|
if (hzb.equals("BO_EU_DWD_ORDER_RKD_HZ")) {
|
||||||
String wlbm = bo.getString("WLBM");
|
String bkgs = bo.getString("BKGS");
|
||||||
String jldw = bo.getString("JLDW");
|
String wlmc = bo.getString("WLMC");
|
||||||
String wlfl = bo.getString("WLFL");
|
String wlbm = bo.getString("WLBM");
|
||||||
Double djhyf = Double.parseDouble(bo.getString("DJHYF"));
|
String jldw = bo.getString("JLDW");
|
||||||
String newWlmc = purchaseUtil.materialClassificationFiltering(bkgs, wlmc, wlbm, jldw, djhyf, wlfl);
|
String wlfl = bo.getString("WLFL");
|
||||||
if (bkgs.equals("北新嘉宝莉")) {
|
Double djhyfs = bo.get("DJHYF",Double.class);
|
||||||
if (wlmc.contains("盖") && djhyf < 5.0){
|
double djhyf = djhyfs != null ? djhyfs : 0.0;
|
||||||
continue;
|
// LOGGER.info("采购_入库单汇总,刷新物料名称------物料名称:{},板块公司:{},物料编码:{},入库单位:{},单价:{},物料分类:{}", wlmc, bkgs, wlbm, jldw, djhyf, wlfl);
|
||||||
} else if (wlmc.contains("桶身") && gaiSum > 0) {
|
|
||||||
Double djhyf1 = bo.get("DJHYF", Double.class);
|
String newWlmc = "";
|
||||||
bo.set("DJHYF", djhyf1 + gaiAverage);
|
if (StringUtils.isNotBlank(wlmc) || StringUtils.isNotBlank(wlbm)
|
||||||
gaiSum--;
|
|| StringUtils.isNotBlank(jldw)
|
||||||
|
|| StringUtils.isNotBlank(wlfl)) {
|
||||||
|
try {
|
||||||
|
newWlmc = purchaseUtil.materialClassificationFiltering(bkgs, wlmc, wlbm, jldw, djhyf, wlfl);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
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("OLDWLMC", wlmc);
|
||||||
|
// LOGGER.info("明细汇总:物料分类更新完毕-02");
|
||||||
|
} else {
|
||||||
|
// LOGGER.info("明细汇总:物料名称为空不进行汇总-03");
|
||||||
|
}
|
||||||
|
// 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);// 含税单价(含运费)
|
||||||
|
// 处理可能为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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bo.set("WLMC",newWlmc);
|
|
||||||
bo.set("OLDWLMC",wlmc);
|
|
||||||
// LOGGER.info("采购_入库单汇总,刷新物料名称------物料名称:{},板块公司:{},物料编码:{},入库单位:{},单价:{},物料分类:{}",wlmc,bkgs,wlbm,jldw,djhyf,wlfl);
|
|
||||||
|
|
||||||
if ("泰山石膏".equals(bkgs)){
|
bos.add(bo);
|
||||||
// 泰山石膏处理入库单金额 入库数量*含税单价
|
// LOGGER.info("明细汇总:bo add完毕-04");
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDK.getBOAPI().createDataBO(hzb, bos, UserContext.fromUID("admin"));
|
SDK.getBOAPI().createDataBO(hzb, bos, UserContext.fromUID("admin"));
|
||||||
@ -799,6 +822,7 @@ public class PurchaseDataSyncServiceImpl implements DataSyncService {
|
|||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
LOGGER.error("汇总数据失败 [汇总表={}, 第几页={}]: {}",
|
LOGGER.error("汇总数据失败 [汇总表={}, 第几页={}]: {}",
|
||||||
hzb, PAGE_SIZE, e.getMessage(), e);
|
hzb, PAGE_SIZE, e.getMessage(), e);
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import com.actionsoft.bpms.bo.engine.BO;
|
|||||||
import com.actionsoft.bpms.commons.database.RowMap;
|
import com.actionsoft.bpms.commons.database.RowMap;
|
||||||
import com.actionsoft.bpms.server.UserContext;
|
import com.actionsoft.bpms.server.UserContext;
|
||||||
import com.actionsoft.bpms.util.DBSql;
|
import com.actionsoft.bpms.util.DBSql;
|
||||||
|
import com.actionsoft.bpms.util.UtilDate;
|
||||||
import com.actionsoft.sdk.local.SDK;
|
import com.actionsoft.sdk.local.SDK;
|
||||||
import com.awspaas.user.apps.bnbm.datalinkup.entity.DateRange;
|
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.service.DataSummaryService;
|
||||||
@ -15,6 +16,7 @@ import java.math.BigDecimal;
|
|||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -373,22 +375,20 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
|||||||
int lastYear = year - 1;
|
int lastYear = year - 1;
|
||||||
int lastYearMonth = month; // 去年同月
|
int lastYearMonth = month; // 去年同月
|
||||||
|
|
||||||
// 获取板骨应收账款数据 - 当年1月到当前月
|
// 获取板块应收账款数据 - 当前月最新一天数据
|
||||||
BigDecimal boneTotal = getReceivableToMonth(year, month, bkgs);
|
RowMap bkgsYsRowMap = getReceivableToMonth(year, month, bkgs);
|
||||||
|
double qcye = bkgsYsRowMap.getDouble("QCYE");
|
||||||
|
double ljxs = bkgsYsRowMap.getDouble("LJXS");
|
||||||
|
double ljhk = bkgsYsRowMap.getDouble("LJHK");
|
||||||
|
double receivable = bkgsYsRowMap.getDouble("receivable");
|
||||||
// 获取去年同期的板骨应收账款数据 - 去年1月到去年同月
|
// 获取去年同期的板骨应收账款数据 - 去年1月到去年同月
|
||||||
BigDecimal boneLastYearTotal = getReceivableToMonth(lastYear, lastYearMonth, bkgs);
|
RowMap bkgsYsLastYearRowMap = getReceivableToMonth(lastYear, lastYearMonth, bkgs);
|
||||||
BigDecimal boneYoy = calculateYoy(boneTotal, boneLastYearTotal);
|
double receivableLastYear = bkgsYsLastYearRowMap.getDouble("receivable");
|
||||||
|
BigDecimal boneYoy = calculateYoy(BigDecimal.valueOf(receivable), BigDecimal.valueOf(receivableLastYear));//同比
|
||||||
|
|
||||||
// 获取涂料应收账款数据 - 当年1月到当前月
|
// 保存板块数据
|
||||||
BigDecimal paintTotal = getReceivableToMonth(year, month, bkgs);
|
saveReceivableYearData(yearMonth, BigDecimal.valueOf(qcye), BigDecimal.valueOf(ljxs),
|
||||||
// 获取去年同期的涂料应收账款数据 - 去年1月到去年同月
|
BigDecimal.valueOf(ljhk), BigDecimal.valueOf(receivable), boneYoy, bkgs);
|
||||||
BigDecimal paintLastYearTotal = getReceivableToMonth(lastYear, lastYearMonth, bkgs);
|
|
||||||
BigDecimal paintYoy = calculateYoy(paintTotal, paintLastYearTotal);
|
|
||||||
|
|
||||||
// 保存板骨数据
|
|
||||||
saveReceivableYearData(yearMonth, boneTotal, boneYoy, bkgs);
|
|
||||||
// 保存涂料数据
|
|
||||||
saveReceivableYearData(yearMonth, paintTotal, paintYoy, bkgs);
|
|
||||||
|
|
||||||
LOGGER.info("应收账款月度累计数据保存成功");
|
LOGGER.info("应收账款月度累计数据保存成功");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -401,10 +401,14 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
|||||||
/**
|
/**
|
||||||
* 保存应收账款月度累计数据
|
* 保存应收账款月度累计数据
|
||||||
*/
|
*/
|
||||||
private void saveReceivableYearData(String yearMonth, BigDecimal total, BigDecimal yoy, String bkgs) {
|
private void saveReceivableYearData(String yearMonth,BigDecimal qcye, BigDecimal ljxs, BigDecimal ljhk,
|
||||||
|
BigDecimal total, BigDecimal yoy, String bkgs) {
|
||||||
BO receivableBO = createBaseBO(bkgs);
|
BO receivableBO = createBaseBO(bkgs);
|
||||||
receivableBO.set("YEARMONTH", yearMonth);
|
receivableBO.set("YEARMONTH", yearMonth);
|
||||||
// receivableBO.set("RECEIVABLE_TYPE", type);
|
// receivableBO.set("RECEIVABLE_TYPE", type);
|
||||||
|
receivableBO.set("OPENING_BALANCE",qcye.setScale(2, RoundingMode.HALF_UP));
|
||||||
|
receivableBO.set("CUMULATIVE_SALES",ljxs.setScale(2, RoundingMode.HALF_UP));
|
||||||
|
receivableBO.set("CUMULATIVE_REPAYMENT",ljhk.setScale(2, RoundingMode.HALF_UP));
|
||||||
receivableBO.set("ENDING_BALANCE", total.setScale(2, RoundingMode.HALF_UP)); // 期末余额
|
receivableBO.set("ENDING_BALANCE", total.setScale(2, RoundingMode.HALF_UP)); // 期末余额
|
||||||
receivableBO.set("YOY_RATE", yoy.setScale(2, RoundingMode.HALF_UP));
|
receivableBO.set("YOY_RATE", yoy.setScale(2, RoundingMode.HALF_UP));
|
||||||
saveSummaryData(receivableBO, RECEIVABLE_YEAR_TABLE);
|
saveSummaryData(receivableBO, RECEIVABLE_YEAR_TABLE);
|
||||||
@ -630,14 +634,16 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
|||||||
* 获取应收账款从1月到指定月份的累计值
|
* 获取应收账款从1月到指定月份的累计值
|
||||||
* 公式:期初余额 + 累计销售 - 累计回款
|
* 公式:期初余额 + 累计销售 - 累计回款
|
||||||
*/
|
*/
|
||||||
private BigDecimal getReceivableToMonth(int year, int month, String bkgs) {
|
private RowMap getReceivableToMonth(int year, int month, String bkgs) {
|
||||||
StringBuilder sql = new StringBuilder("SELECT (SUM(QCYE) + SUM(LJXS) - SUM(LJXS)) AS receivable ")
|
|
||||||
.append("FROM " + RECEIVABLE_DETAIL_TABLE + " ")
|
|
||||||
.append("WHERE YEAR(RQ) = '"+year+"' AND MONTH(RQ) BETWEEN 1 AND '"+month+"' ")
|
|
||||||
.append("AND BKGS = '"+bkgs+"' ");
|
|
||||||
|
|
||||||
double value = DBSql.getDouble(sql.toString(), "receivable");
|
StringBuilder sql = new StringBuilder("SELECT SUM(QCYE) AS QCYE, SUM(LJXS) AS LJXS , SUM(LJHK) AS LJHK, (SUM(QCYE) + SUM(LJXS) - SUM(LJHK)) AS receivable")
|
||||||
return BigDecimal.valueOf(value);
|
.append(" FROM " + RECEIVABLE_DETAIL_TABLE)
|
||||||
|
.append(" WHERE RQ = ( SELECT MAX(RQ) FROM "+RECEIVABLE_DETAIL_TABLE+
|
||||||
|
" WHERE YEAR(RQ) = '"+year+"' AND MONTH(RQ) = '"+month+"' AND BKGS = '"+bkgs+"' ) ")
|
||||||
|
.append(" AND BKGS ='"+bkgs+"'");
|
||||||
|
|
||||||
|
RowMap receivable = DBSql.getMap(sql.toString());
|
||||||
|
return receivable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -645,30 +651,27 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
|||||||
*/
|
*/
|
||||||
private Map<String, BigDecimal> getMonthlyData(int year, int month, String productType, String dataType, String bkgs) {
|
private Map<String, BigDecimal> getMonthlyData(int year, int month, String productType, String dataType, String bkgs) {
|
||||||
String field = "";
|
String field = "";
|
||||||
String sql = "";
|
|
||||||
if (bkgs.contains("泰山")){
|
if (bkgs.contains("泰山")){
|
||||||
// field = "sales".equals(dataType) ? "SUM(XSSL)/10000" : "SUM(SSJERMB)";
|
if ("sales".equals(dataType)){
|
||||||
// field = "轻钢龙骨".equals(productType) ? "SUM(ZSSL)" : "SUM(SSJERMB)";
|
if ("轻钢龙骨".equals(productType)){
|
||||||
if ("sales".equals(dataType) && "轻钢龙骨".equals(productType)){
|
field = " SUM(ZSSL) ";
|
||||||
field = "SUM(ZSSL)";
|
} else if ("石膏板".equals(productType)) {
|
||||||
} else if ("sales".equals(dataType) && "石膏板".equals(productType)) {
|
field = " SUM(XSSL)/10000 ";
|
||||||
field = "SUM(XSSL)/10000";
|
}else {
|
||||||
} else if ("revenue".equals(dataType)) {
|
field = " SUM(ZSSL) ";
|
||||||
field = "SUM(SSJERMB)";
|
}
|
||||||
|
}else {
|
||||||
|
field = " SUM(SSJERMB) ";
|
||||||
}
|
}
|
||||||
sql = "SELECT LB_2 AS brand, " + field + " AS value " +
|
|
||||||
"FROM " + SALES_DETAIL_TABLE + " " +
|
|
||||||
"WHERE YEAR(DZRQ) = ? AND MONTH(DZRQ) = ? AND LB_1 = ? AND BKGS = ? " +
|
|
||||||
"AND (SQ LIKE '%新疆%' OR SQ LIKE '%海南%' OR SQ LIKE '%西藏%') " + // 模糊查询
|
|
||||||
"GROUP BY LB_2";
|
|
||||||
}else {
|
}else {
|
||||||
field = "sales".equals(dataType) ? "SUM(ZSSL)" : "SUM(SSJERMB)";
|
field = "sales".equals(dataType) ? "SUM(ZSSL)" : "SUM(SSJERMB)";
|
||||||
sql = "SELECT LB_2 AS brand, " + field + " AS value " +
|
|
||||||
"FROM " + SALES_DETAIL_TABLE + " " +
|
|
||||||
"WHERE YEAR(DZRQ) = ? AND MONTH(DZRQ) = ? AND LB_1 = ? AND BKGS = ? " +
|
|
||||||
"AND (SQ LIKE '%新疆%' OR SQ LIKE '%海南%' OR SQ LIKE '%西藏%') " + // 模糊查询
|
|
||||||
"GROUP BY LB_2";
|
|
||||||
}
|
}
|
||||||
|
String sql = "SELECT LB_2 AS brand, " + field + " AS value " +
|
||||||
|
" FROM " + SALES_DETAIL_TABLE + " " +
|
||||||
|
" WHERE YEAR(DZRQ) = ? AND MONTH(DZRQ) = ? AND LB_1 = ? AND BKGS = ? " +
|
||||||
|
" AND (SQ LIKE '%新疆%' OR SQ LIKE '%海南%' OR SQ LIKE '%西藏%') " + // 模糊查询
|
||||||
|
" GROUP BY LB_2";
|
||||||
Map<String, BigDecimal> result = new HashMap<>();
|
Map<String, BigDecimal> result = new HashMap<>();
|
||||||
List<RowMap> rows = DBSql.getMaps(sql, year, month, productType, bkgs);
|
List<RowMap> rows = DBSql.getMaps(sql, year, month, productType, bkgs);
|
||||||
for (RowMap row : rows) {
|
for (RowMap row : rows) {
|
||||||
@ -686,7 +689,7 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
|||||||
/*StringBuilder sql = new StringBuilder("SELECT SUM(YSYE) AS receivable ")
|
/*StringBuilder sql = new StringBuilder("SELECT SUM(YSYE) AS receivable ")
|
||||||
.append("FROM " + RECEIVABLE_DETAIL_TABLE + " ")
|
.append("FROM " + RECEIVABLE_DETAIL_TABLE + " ")
|
||||||
.append("WHERE YEAR(RQ) = '"+year+"' AND MONTH(RQ) = '"+month+"' AND BKGS = '"+bkgs+"' ");*/
|
.append("WHERE YEAR(RQ) = '"+year+"' AND MONTH(RQ) = '"+month+"' AND BKGS = '"+bkgs+"' ");*/
|
||||||
StringBuilder sql = new StringBuilder("SELECT YSYE AS receivable ")
|
StringBuilder sql = new StringBuilder("SELECT SUM(YSYE) AS receivable ")
|
||||||
.append("FROM " + RECEIVABLE_DETAIL_TABLE + " ")
|
.append("FROM " + RECEIVABLE_DETAIL_TABLE + " ")
|
||||||
.append("WHERE RQ = ( ")
|
.append("WHERE RQ = ( ")
|
||||||
.append(" SELECT MAX(RQ) ")
|
.append(" SELECT MAX(RQ) ")
|
||||||
|
|||||||
@ -16,84 +16,85 @@ public class PurchaseUtil {
|
|||||||
*/
|
*/
|
||||||
public static String materialClassificationFiltering(String bkgs, String wlmc, String wlbm, String jldw, Double djhyf, String wlfl) {
|
public static String materialClassificationFiltering(String bkgs, String wlmc, String wlbm, String jldw, Double djhyf, String wlfl) {
|
||||||
String newWlmc = "";
|
String newWlmc = "";
|
||||||
// 脱硫石膏
|
try {
|
||||||
if(("龙牌".equals(bkgs) || "梦牌".equals(bkgs) || "泰山石膏".equals(bkgs)) && wlmc.contains("脱硫石膏")){
|
// 脱硫石膏
|
||||||
newWlmc = "脱硫石膏";
|
if (("龙牌".equals(bkgs) || "梦牌".equals(bkgs) || "泰山石膏".equals(bkgs)) && wlmc.contains("脱硫石膏")) {
|
||||||
}
|
newWlmc = "脱硫石膏";
|
||||||
// 镀锌带钢
|
}
|
||||||
else if ("泰山石膏".equals(bkgs) && wlmc.contains("镀锌带钢")) {
|
// 镀锌带钢
|
||||||
newWlmc = "镀锌带钢";
|
else if ("泰山石膏".equals(bkgs) && wlmc.contains("镀锌带钢")) {
|
||||||
} else if (("龙牌".equals(bkgs) || "梦牌".equals(bkgs))
|
newWlmc = "镀锌带钢";
|
||||||
&& (wlmc.equals("轻钢镀锌带钢") || wlmc.equals("镀锌带钢"))) {
|
} else if (("龙牌".equals(bkgs) || "梦牌".equals(bkgs))
|
||||||
newWlmc = "镀锌带钢";
|
&& (wlmc.equals("轻钢镀锌带钢") || wlmc.equals("镀锌带钢"))) {
|
||||||
}
|
newWlmc = "镀锌带钢";
|
||||||
// 煤炭
|
}
|
||||||
else if ((("龙牌".equals(bkgs) || "梦牌".equals(bkgs))
|
// 煤炭
|
||||||
&& (wlmc.contains("煤炭") || wlmc.contains("煤炭") || wlmc.contains("煤炭")))) {
|
else if (("龙牌".equals(bkgs) || "梦牌".equals(bkgs))
|
||||||
newWlmc = "煤炭";
|
&& (wlmc.contains("煤炭") || wlmc.contains("籽煤") || wlmc.contains("褐煤"))) {
|
||||||
} else if ("泰山石膏".equals(bkgs) && (wlmc.contains("原煤") || wlmc.contains("水洗精煤") || wlmc.contains("褐煤"))) {
|
newWlmc = "煤炭";
|
||||||
newWlmc = "煤炭";
|
} else if ("泰山石膏".equals(bkgs) && (wlmc.contains("原煤") || wlmc.contains("水洗精煤") || wlmc.contains("褐煤"))) {
|
||||||
}
|
newWlmc = "煤炭";
|
||||||
// 护面纸
|
}
|
||||||
else if (("龙牌".equals(bkgs) || "泰山石膏".equals(bkgs))
|
// 护面纸
|
||||||
&& wlmc.contains("护面纸")) {
|
else if (("龙牌".equals(bkgs) || "泰山石膏".equals(bkgs))
|
||||||
newWlmc = "护面纸";
|
&& wlmc.contains("护面纸")) {
|
||||||
}
|
newWlmc = "护面纸";
|
||||||
// 乳液
|
}
|
||||||
else if ("北新嘉宝莉".equals(bkgs) && wlbm.startsWith("11M")){
|
// 乳液
|
||||||
newWlmc = "乳液";
|
else if ("北新嘉宝莉".equals(bkgs) && wlbm.startsWith("11M")) {
|
||||||
} else if ("北新防水".equals(bkgs) && wlbm.startsWith("5070201")) {
|
newWlmc = "乳液";
|
||||||
newWlmc = "乳液";
|
} else if ("北新防水".equals(bkgs) && wlbm.startsWith("5070201")) {
|
||||||
} else if ("北新涂料".equals(bkgs) && wlbm.contains("10114137")) {
|
newWlmc = "乳液";
|
||||||
newWlmc = "乳液";
|
} else if ("北新涂料".equals(bkgs) && wlbm.contains("10114137")) {
|
||||||
}
|
newWlmc = "乳液";
|
||||||
// 钛白粉
|
}
|
||||||
else if (("北新防水".equals(bkgs) || "北新涂料".equals(bkgs) || "北新嘉宝莉".equals(bkgs))
|
// 钛白粉
|
||||||
&& wlmc.contains("钛白粉")){
|
else if (("北新防水".equals(bkgs) || "北新涂料".equals(bkgs) || "北新嘉宝莉".equals(bkgs))
|
||||||
newWlmc = "钛白粉";
|
&& wlmc.contains("钛白粉")) {
|
||||||
}
|
newWlmc = "钛白粉";
|
||||||
// 重钙
|
}
|
||||||
else if (("北新防水".equals(bkgs) || "北新涂料".equals(bkgs) || "北新嘉宝莉".equals(bkgs))
|
// 重钙
|
||||||
&& wlmc.contains("重钙")){
|
else if (("北新防水".equals(bkgs) || "北新涂料".equals(bkgs) || "北新嘉宝莉".equals(bkgs))
|
||||||
newWlmc = "重钙";
|
&& wlmc.contains("重钙")) {
|
||||||
}
|
newWlmc = "重钙";
|
||||||
// 包装袋
|
}
|
||||||
else if ("龙牌".equals(bkgs) && (wlmc.equals("编织袋") || wlmc.equals("阀口袋") || wlmc.equals("两纸一膜")
|
// 包装袋
|
||||||
|| wlmc.contains("三纸一膜") || wlmc.contains("包装袋") || wlmc.contains("包装"))) {
|
else if ("龙牌".equals(bkgs) && (wlmc.equals("编织袋") || wlmc.equals("阀口袋") || wlmc.equals("两纸一膜")
|
||||||
newWlmc = "包装袋";
|
|| wlmc.contains("三纸一膜") || wlmc.contains("包装袋") || wlmc.contains("包装"))) {
|
||||||
} else if ("泰山石膏".equals(bkgs) && (wlmc.contains("编织袋") || wlmc.contains("纸袋"))) {
|
newWlmc = "包装袋";
|
||||||
newWlmc = "包装袋";
|
} else if ("泰山石膏".equals(bkgs) && (wlmc.contains("编织袋") || wlmc.contains("纸袋"))) {
|
||||||
} else if ("梦牌".equals(bkgs) && wlmc.contains("包装袋")) {
|
newWlmc = "包装袋";
|
||||||
newWlmc = "包装袋";
|
} else if ("梦牌".equals(bkgs) && wlmc.contains("包装袋")) {
|
||||||
} else if ("北新防水".equals(bkgs) && (wlmc.contains("包装袋") || wlmc.contains("阀口袋") || wlmc.contains("口袋"))) {
|
newWlmc = "包装袋";
|
||||||
newWlmc = "包装袋";
|
} else if ("北新防水".equals(bkgs) && (wlmc.contains("包装袋") || wlmc.contains("阀口袋") || wlmc.contains("口袋"))) {
|
||||||
} else if ("北新涂料".equals(bkgs) && wlmc.contains("包装袋")) {
|
newWlmc = "包装袋";
|
||||||
newWlmc = "包装袋";
|
} else if ("北新涂料".equals(bkgs) && wlmc.contains("包装袋")) {
|
||||||
} else if ("北新嘉宝莉".equals(bkgs) && (wlmc.contains("阀口袋") || wlmc.contains("腻子粉袋") || wlmc.contains("阀口纸袋")
|
newWlmc = "包装袋";
|
||||||
|| wlmc.equals("纸袋") || wlmc.equals("编织袋"))) {
|
} else if ("北新嘉宝莉".equals(bkgs) && (wlmc.contains("阀口袋") || wlmc.contains("腻子粉袋") || wlmc.contains("阀口纸袋")
|
||||||
newWlmc = "包装袋";
|
|| wlmc.equals("纸袋") || wlmc.equals("编织袋"))) {
|
||||||
}
|
newWlmc = "包装袋";
|
||||||
// 包装桶
|
}
|
||||||
else if ("龙牌".equals(bkgs) && wlbm.contains("1023411")) {
|
// 包装桶
|
||||||
newWlmc = "包装桶";
|
else if ("龙牌".equals(bkgs) && wlbm.contains("1023411")) {
|
||||||
} else if ("北新防水".equals(bkgs) && wlmc.contains("桶") && jldw.contains("个")) {
|
newWlmc = "包装桶";
|
||||||
newWlmc = "包装桶";
|
} else if ("北新防水".equals(bkgs) && wlmc.contains("桶") && jldw.contains("个")) {
|
||||||
} else if ("北新嘉宝莉".equals(bkgs) && wlmc.contains("盖") && djhyf < 5.0) {
|
newWlmc = "包装桶";
|
||||||
newWlmc = "桶盖";
|
} else if ("北新嘉宝莉".equals(bkgs) && wlmc.contains("盖") && djhyf < 5.0) {
|
||||||
} else if ("北新嘉宝莉".equals(bkgs) && wlmc.contains("桶身")) {
|
newWlmc = "桶盖";
|
||||||
newWlmc = "包装桶";
|
} else if ("北新嘉宝莉".equals(bkgs) && wlmc.contains("桶身")) {
|
||||||
} else if ("北新嘉宝莉".equals(bkgs) && wlmc.contains("桶") && jldw.contains("个")) {
|
newWlmc = "包装桶";
|
||||||
newWlmc = "包装桶";
|
} else if ("北新嘉宝莉".equals(bkgs) && wlmc.contains("桶") && jldw.contains("个")) {
|
||||||
} else if ("北新嘉宝莉".equals(bkgs) && wlmc.contains("罐")
|
newWlmc = "包装桶";
|
||||||
&& !wlmc.contains("箱") && wlfl.contains("包装物") && jldw.equals("个")) {
|
} else if ("北新嘉宝莉".equals(bkgs) && wlmc.contains("罐")
|
||||||
newWlmc = "包装桶";
|
&& !wlmc.contains("箱") && wlfl.contains("包装物") && jldw.equals("个")) {
|
||||||
} else {
|
newWlmc = "包装桶";
|
||||||
newWlmc = wlmc;
|
} else {
|
||||||
|
newWlmc = wlmc;
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return newWlmc;
|
return newWlmc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
materialClassificationFiltering("龙牌", "龙牌憎水岩棉板100", "30351010A000569", "块", 10.0, "");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user