1、采购sql修改
2、销售增加sum不含税金额 3、一体化增加城市、月旬,修改拼接条件bug
This commit is contained in:
parent
6200b5f5aa
commit
cb42eb80cd
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -82,23 +82,14 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
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);
|
||||
|
||||
// 2. 根据年月汇总板块、基地、年月、当期、上期、同期数据
|
||||
// monthlyBaseSummaryBySegment(year, month, yearMonth, yearLastMonth, lastYearMonth, bkgs, distinctList);
|
||||
newmonthlyBaseSummaryBySegment(startDate, bkgs);
|
||||
|
||||
// 3. 计算并保存各板块物料采购总额、总量、单价(按日存储)
|
||||
// dailyMaterialSummaryBySegment(year, month, day, currentDate, bkgs, distinctList);
|
||||
newdailyMaterialSummaryBySegment(startDate, bkgs);
|
||||
|
||||
// 4. 根据日期、入库单号、物料名称分页查询 日期、入库单号、物料编码、物料名称、规格型号、
|
||||
// (汇总)入库数量、单位、入库单价、(汇总)入库金额、供应商、订单编号、库存数
|
||||
// dailyWarehousingSummary(year, month, day, currentDate, bkgs, distinctList);
|
||||
newdailyWarehousingSummary(startDate, bkgs);
|
||||
|
||||
// calculateForCurrentDate(bkgs, distinctList);
|
||||
} else {
|
||||
LOGGER.info("开始执行采购数据多维度汇总计算(时间范围: {} 至 {})",
|
||||
dateRange.getStartDate(), dateRange.getEndDate());
|
||||
@ -113,12 +104,6 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
// (汇总)入库数量、单位、入库单价、(汇总)入库金额、供应商、订单编号、库存数
|
||||
newdailyWarehousingSummary(startDate, bkgs);
|
||||
|
||||
// 计算月度维度数据(按月遍历)
|
||||
// calculateMonthlyData(dateRange, bkgs, distinctList);
|
||||
|
||||
// 计算日度维度数据(按天遍历)
|
||||
// calculateDailyData(dateRange, bkgs, distinctList);
|
||||
|
||||
LOGGER.info("采购数据多维度汇总计算完成");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@ -211,9 +196,9 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
detailBO.set("DDBH", row.getString("CGDDH")); // 订单编号
|
||||
detailBO.set("KCS", 0.00); // 库存数(默认为0,需后续计算)
|
||||
detailBO.set("BKGS", bkgs); // 板块公司
|
||||
LocalDate date = LocalDate.parse(startDate);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
||||
String yearmonth = date.format(formatter);
|
||||
YearMonth yearMonths = YearMonth.parse(row.getString("YEARMONTH"), DateTimeFormatter.ofPattern("yyyyMM"));
|
||||
DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
||||
String yearmonth = yearMonths.format(outputFormatter);
|
||||
detailBO.set("YEARMONTH", yearmonth); // 年月
|
||||
bos.add(detailBO);
|
||||
}
|
||||
@ -648,12 +633,12 @@ public class PurchaseDataSummaryServiceImpl implements DataSummaryService {
|
||||
|
||||
if (!bos.isEmpty()) {
|
||||
// 批量插入数据
|
||||
int batchSize = 1000;
|
||||
for (int i = 0; i < bos.size(); i += batchSize) {
|
||||
int end = Math.min(i + batchSize, bos.size());
|
||||
List<BO> batch = bos.subList(i, end);
|
||||
SDK.getBOAPI().createDataBO(PROCUREMENT_DETAILS_YEAR_MONTH, batch, UserContext.fromUID("admin"));
|
||||
}
|
||||
// int batchSize = 1000;
|
||||
// for (int i = 0; i < bos.size(); i += batchSize) {
|
||||
// int end = Math.min(i + batchSize, bos.size());
|
||||
// List<BO> batch = bos.subList(i, end);
|
||||
SDK.getBOAPI().createDataBO(PROCUREMENT_DETAILS_YEAR_MONTH, bos, UserContext.fromUID("admin"));
|
||||
// }
|
||||
}
|
||||
|
||||
LOGGER.info("成功保存{}条月度汇总数据,板块:{}", bos.size(), bkgs);
|
||||
|
||||
@ -398,7 +398,7 @@ public class SaleCountDimensionImpl implements DataSummaryService {
|
||||
));
|
||||
|
||||
String querySql = "SELECT DZRQ,QYGS, KCZZ, LB_1, LB_2, LB_3, SQ, CS, QY, SUM(ZSSL) AS XL," +
|
||||
" SUM(SSJERMB) AS XE, SUM(XSSL) AS TSXL, NMNY ,YEARMONTH" +
|
||||
" SUM(SSJERMB) AS XE, SUM(XSSL) AS TSXL, SUM(NMNY) AS BHSXE,YEARMONTH" +
|
||||
" FROM " + SALES_DETAIL_TABLE +
|
||||
" WHERE DZRQ >= ? AND DZRQ < ? AND BKGS = ?" +
|
||||
" GROUP BY QYGS, KCZZ, LB_1, LB_2, LB_3, SQ, CS, QY, YEARMONTH";
|
||||
@ -435,13 +435,6 @@ public class SaleCountDimensionImpl implements DataSummaryService {
|
||||
bo.set("JD", location.getLongitude());
|
||||
bo.set("WD", location.getLatitude());
|
||||
}
|
||||
String querySql2 = "SELECT SUM(ZSSL) AS XL,SUM(SSJERMB) AS XE, SUM(XSSL) AS TSXL" +
|
||||
" FROM " + SALES_DETAIL_TABLE +
|
||||
" WHERE DZRQ = ? AND BKGS = ? AND QYGS = ? AND KCZZ = ? AND LB_1 = ?";
|
||||
// LocalDate parse = LocalDate.parse(dzrq,DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S"));
|
||||
// YearMonth yearMonth = YearMonth.of(parse.getYear(), parse.getMonthValue());
|
||||
// LocalDate lastYear = yearMonth.atEndOfMonth();
|
||||
// RowMap map1 = DBSql.getMap(querySql2, lastYear.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")), bkgs, qygs, gc, lb_1);
|
||||
if ("石膏板".equals(map.getString("LB_1"))){
|
||||
bo.set("XL", map.getDouble("TSXL"));
|
||||
// if (map1!=null) {
|
||||
@ -454,7 +447,7 @@ public class SaleCountDimensionImpl implements DataSummaryService {
|
||||
// }
|
||||
}
|
||||
Double ssjermb = map.getDouble("XE");
|
||||
Double xe = map.getDouble("NMNY");
|
||||
Double xe = map.getDouble("BHSXE");
|
||||
bo.set("XE", xe);
|
||||
// bo.set("SNTQXE", map1.getString("XE"));
|
||||
// 匹配公装家装类别,如果未匹配到,则默认未其他
|
||||
|
||||
@ -179,16 +179,16 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
||||
sfMap.put("新疆维吾尔自治区","SQ LIKE '%新疆%' ");
|
||||
sfMap.put("海南省","SQ LIKE '%海南%' ");
|
||||
sfMap.put("西藏自治区","SQ LIKE '%西藏%' ");
|
||||
sfMap.put("一体化","SQ LIKE '%新疆%' OR SQ LIKE '%海南%' OR SQ LIKE '%西藏%') ");
|
||||
sfMap.put("一体化","SQ LIKE '%新疆%' OR SQ LIKE '%海南%' OR SQ LIKE '%西藏%' ");
|
||||
for (String key : sfMap.keySet()) {
|
||||
// 获取省份简称
|
||||
String abbreviation = SaleUtil.getProvinceAbbreviation(key);
|
||||
String sfSql = sfMap.get(key);
|
||||
|
||||
String sql = "SELECT DZRQ,LB_1,LB_2,BKGS,SQ,SUM(XSSL) AS tssales, SUM(ZSSL) AS lpsales,SUM(SSJERMB) AS revenue" +
|
||||
String sql = "SELECT DZRQ,LB_1,LB_2,BKGS,SQ,CS,SUM(XSSL) AS tssales, SUM(ZSSL) AS lpsales,SUM(SSJERMB) AS revenue" +
|
||||
" FROM " +SALES_DETAIL_TABLE+
|
||||
" WHERE LB_1 IN ('石膏板', '轻钢龙骨', '涂料') AND ("+sfSql+")" +
|
||||
" GROUP BY DZRQ,LB_1,BKGS ORDER BY DZRQ";
|
||||
" GROUP BY DZRQ,LB_1,BKGS,CS ORDER BY DZRQ";
|
||||
|
||||
List<RowMap> maps = DBSql.getMaps(sql);
|
||||
if (maps!=null){
|
||||
@ -203,10 +203,12 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
||||
String bkgs1 = map.getString("BKGS");
|
||||
String lb_1 = map.getString("LB_1");
|
||||
String lb_2 = map.getString("LB_2");
|
||||
String dzrq = map.getString("DZRQ");
|
||||
|
||||
BO priceBO = new BO();
|
||||
priceBO.set("BKGS", bkgs1);
|
||||
priceBO.set("DATE", map.getString("DZRQ"));
|
||||
priceBO.set("DATE", dzrq);
|
||||
priceBO.set("CITY", map.getString("CS"));
|
||||
if ("北新嘉宝莉".equals(bkgs)) {
|
||||
priceBO.set("PRODUCT_TYPE", "涂料");
|
||||
}else {
|
||||
@ -231,7 +233,7 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
||||
if (lpsales.compareTo(BigDecimal.ZERO) > 0) {
|
||||
// 石膏板单位转换:万元/万平方米 → 元/平方米
|
||||
if ("石膏板".equals(lb_1)) {
|
||||
unitPrice = revenue.divide(lpsales, 4, RoundingMode.HALF_UP);
|
||||
unitPrice = revenue.divide(tssales, 4, RoundingMode.HALF_UP);
|
||||
}
|
||||
// 轻钢龙骨单位:元/吨
|
||||
if ("轻钢龙骨".equals(lb_1)) {
|
||||
@ -246,6 +248,9 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
||||
String[] gzjzStrings = SaleUtil.matchSingleField(bkgs, lb_1, lb_2, gzjzList, "其他", "其他","其他");
|
||||
priceBO.set("MC_JC", gzjzStrings[1]);//面材/基材
|
||||
priceBO.set("JZ_GZ", gzjzStrings[0]);//家装/工装
|
||||
priceBO.set("PROD_CAT", gzjzStrings[2]);//产品类型
|
||||
String monthPeriod = SaleUtil.getMonthPeriod(dzrq);
|
||||
priceBO.set("XUN", monthPeriod);//月寻
|
||||
|
||||
list.add(priceBO);
|
||||
}
|
||||
@ -922,7 +927,7 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
||||
sfMap.put("新疆维吾尔自治区","SQ LIKE '%新疆%' ");
|
||||
sfMap.put("海南省","SQ LIKE '%海南%' ");
|
||||
sfMap.put("西藏自治区","SQ LIKE '%西藏%' ");
|
||||
sfMap.put("一体化","SQ LIKE '%新疆%' OR SQ LIKE '%海南%' OR SQ LIKE '%西藏%') ");
|
||||
sfMap.put("一体化","SQ LIKE '%新疆%' OR SQ LIKE '%海南%' OR SQ LIKE '%西藏%' ");
|
||||
for (String key : sfMap.keySet()) {
|
||||
// 获取省份简称
|
||||
String abbreviation = SaleUtil.getProvinceAbbreviation(key);
|
||||
@ -1135,7 +1140,7 @@ public class SaleDataSummaryServiceImpl implements DataSummaryService {
|
||||
"FROM " + SALES_DETAIL_TABLE + " " +
|
||||
// "WHERE YEAR(DZRQ) = '"+year+"' AND MONTH(DZRQ) BETWEEN 1 AND '"+month+"' AND LB_1 LIKE '%"+category+"%' AND BKGS = '"+bkgs+"'"+
|
||||
"WHERE YEAR(DZRQ) = '"+year+"' AND MONTH(DZRQ) = '"+month+"' AND LB_1 LIKE '%"+category+"%' AND BKGS = '"+bkgs+"'"+
|
||||
"AND (SQ LIKE '%新疆%' OR SQ LIKE '%海南%' OR SQ LIKE '%西藏%')"; // 模糊查询
|
||||
"AND ("+sfSql+")"; // 模糊查询
|
||||
double value = DBSql.getDouble(sql, "revenue");
|
||||
return BigDecimal.valueOf(value);
|
||||
}
|
||||
|
||||
@ -758,6 +758,8 @@ public class SaleDataSyncServiceImpl implements DataSyncService {
|
||||
String endDate = "";
|
||||
// 查询梦牌区域
|
||||
List<BO> mpqyList = SDK.getBOAPI().query("BO_EU_DATALINKUP_QYGSED").addQuery("BKGS = ", "梦牌").list();
|
||||
// 查询龙牌区域
|
||||
List<BO> lpqyList = SDK.getBOAPI().query("BO_EU_QYGX").list();
|
||||
try {
|
||||
do {
|
||||
if (startDated == null || endDated == null) {
|
||||
@ -820,14 +822,26 @@ public class SaleDataSyncServiceImpl implements DataSyncService {
|
||||
}
|
||||
// LOGGER.info("泰山应收的数据:{}",bo.toJSONObject());
|
||||
//销售汇总表修改区域公司
|
||||
if ("梦牌".equals(map.getString("BKGS")) && hzb.equals("BO_EU_BNBM_DATALINKUP_XS_XSL_HZ")){
|
||||
if ("梦牌".equals(map.getString("BKGS"))){
|
||||
String cs = bo.getString("CS");
|
||||
String sq = bo.getString("SQ");
|
||||
for (BO bo1 : mpqyList) {
|
||||
String ss = bo1.getString("SS");
|
||||
if (ss.contains(cs)){
|
||||
if (StringUtils.isNotBlank(cs) && ss.contains(cs)){
|
||||
bo.set("QYGS",bo1.getString("QYGS"));
|
||||
} else if (ss.contains(sq)) {
|
||||
} else if (StringUtils.isNotBlank(sq) && ss.contains(sq)) {
|
||||
bo.set("QYGS",bo1.getString("QYGS"));
|
||||
}else {
|
||||
bo.set("QYGS","其他");
|
||||
}
|
||||
}
|
||||
}
|
||||
//龙牌
|
||||
if ("龙牌".equals(map.getString("BKGS"))){
|
||||
String xszz = bo.getString("XSZZ");
|
||||
for (BO bo1 : lpqyList) {
|
||||
String swfb = bo1.getString("SWFB");
|
||||
if (swfb.contains(xszz)){
|
||||
bo.set("QYGS",bo1.getString("QYGS"));
|
||||
}else {
|
||||
bo.set("QYGS","其他");
|
||||
|
||||
@ -81,4 +81,24 @@ public class SaleUtil {
|
||||
return sfjc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算月旬
|
||||
* @param dateTimeStr
|
||||
* @return
|
||||
*/
|
||||
public static String getMonthPeriod(String dateTimeStr) {
|
||||
// 提取日期部分(假设格式为"yyyy-MM-dd HH:mm:ss")
|
||||
String dateStr = dateTimeStr.split(" ")[0];
|
||||
// 获取日期的天数部分
|
||||
int day = Integer.parseInt(dateStr.split("-")[2]);
|
||||
|
||||
if (day <= 10) {
|
||||
return "上旬";
|
||||
} else if (day <= 20) {
|
||||
return "中旬";
|
||||
} else {
|
||||
return "下旬";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user