mirror of https://github.com/jeecgboot/jeecg-boot
feat : sku weight finished, grafana, loki, loki4j
parent
e5fb4d9220
commit
694fbb3115
24
db/util.sql
24
db/util.sql
|
@ -18,19 +18,27 @@ SHOW VARIABLES LIKE 'collation%';
|
|||
SHOW TABLE STATUS LIKE 'sen%';
|
||||
ALTER DATABASE wia_app COLLATE utf8mb4_general_ci;
|
||||
|
||||
SELECT c.internal_code AS '客户',
|
||||
s.erp_code AS SKU,
|
||||
p.zh_name AS '中文名',
|
||||
p.weight AS '重量',
|
||||
WITH latestSkuWeights AS (
|
||||
SELECT
|
||||
sku_id,
|
||||
weight,
|
||||
effective_date,
|
||||
ROW_NUMBER() OVER (PARTITION BY sku_id ORDER BY effective_date DESC) AS rn
|
||||
FROM sku_weight
|
||||
)
|
||||
SELECT c.internal_code AS '客户',
|
||||
s.erp_code AS SKU,
|
||||
s.zh_name AS '中文名',
|
||||
lsw.weight AS '重量',
|
||||
ROUND(calculate_shipping_fees(IF(sa.zh_name = '普货', '联邮通优先挂号-普货', '联邮通优先挂号-带电'), 'FR', '2021-06-24',
|
||||
p.weight), 2) AS '运费',
|
||||
lsw.weight), 2) AS '运费',
|
||||
get_registration_fees(IF(sa.zh_name = '普货', '联邮通优先挂号-普货', '联邮通优先挂号-带电'), 'FR', '2021-06-24',
|
||||
p.weight) AS '挂号费'
|
||||
lsw.weight) AS '挂号费'
|
||||
FROM sku s
|
||||
LEFT JOIN client_sku ON s.id = client_sku.sku_id
|
||||
LEFT JOIN client c ON client_sku.client_id = c.id
|
||||
JOIN product p ON p.id = s.product_id
|
||||
JOIN sensitive_attribute sa ON p.sensitive_attribute_id = sa.id;
|
||||
LEFT JOIN latestSkuWeights lsw ON lsw.sku_id = s.id AND lsw.rn = 1
|
||||
JOIN sensitive_attribute sa ON s.sensitive_attribute_id = sa.id;
|
||||
|
||||
SELECT c.internal_code AS 'Client',
|
||||
po.platform_order_id AS 'Order ID',
|
||||
|
|
|
@ -9,7 +9,7 @@ SELECT s.name AS 'Boutique',
|
|||
po.country AS 'Pays',
|
||||
po.postcode AS 'Code postal',
|
||||
JSON_ARRAYAGG(sku.erp_code) AS 'SKU',
|
||||
JSON_ARRAYAGG(p.en_name) AS 'Nom produits',
|
||||
JSON_ARRAYAGG(sku.en_name) AS 'Nom produits',
|
||||
JSON_ARRAYAGG(poc.quantity) AS 'Quantité',
|
||||
SUM(poc.purchase_fee) AS 'Frais d\'achat',
|
||||
po.fret_fee AS 'Frais de FRET',
|
||||
|
@ -23,7 +23,6 @@ FROM platform_order po
|
|||
JOIN shop s ON po.shop_id = s.id
|
||||
RIGHT JOIN platform_order_content poc ON po.id = poc.platform_order_id
|
||||
JOIN sku ON poc.sku_id = sku.id
|
||||
JOIN product p ON sku.product_id = p.id
|
||||
WHERE shipping_invoice_number IS NOT NULL
|
||||
AND poc.erp_status <> 5
|
||||
GROUP BY po.id, s.name, po.order_time
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
CREATE OR REPLACE VIEW inventory_record AS
|
||||
SELECT sku.id AS id,
|
||||
cs.client_id AS client_id,
|
||||
sku.product_id AS product_id,
|
||||
sku.id AS product_id,
|
||||
sku.erp_code AS erp_code,
|
||||
sku.image_source AS image_source,
|
||||
sku.available_amount AS available_amount,
|
||||
p.moq AS moq,
|
||||
sku.moq AS moq,
|
||||
rs.quantity AS red_quantity,
|
||||
gs.quantity AS green_quantity,
|
||||
sales_7.quantity AS sales_7,
|
||||
|
@ -13,7 +13,6 @@ SELECT sku.id AS id,
|
|||
sales_28.quantity AS sales_28,
|
||||
sipo.quantity AS platform_order_quantity
|
||||
FROM sku
|
||||
JOIN product p ON sku.product_id = p.id
|
||||
JOIN client_sku cs ON sku.id = cs.sku_id
|
||||
LEFT JOIN sales_7 ON sku.id = sales_7.sku_id
|
||||
LEFT JOIN sales_14 ON sku.id = sales_14.sku_id
|
||||
|
|
|
@ -13,9 +13,14 @@ SELECT c.internal_code AS '客户代码',
|
|||
WHEN s2.erp_code IS NOT NULL
|
||||
THEN s2.erp_code
|
||||
END AS 'SKU',
|
||||
p.zh_name AS '产品中文名',
|
||||
s2.zh_name AS '产品中文名',
|
||||
poc.quantity AS '产品数量',
|
||||
p.weight AS '商品收费重',
|
||||
(
|
||||
SELECT sw.weight
|
||||
FROM sku_weight sw
|
||||
WHERE sw.sku_id = s.id
|
||||
ORDER BY effective_date DESC LIMIT 1
|
||||
) AS '商品收费重',
|
||||
poc.purchase_fee AS '商品采购费',
|
||||
poc.service_fee AS '商品服务费',
|
||||
poc.shipping_fee AS '商品运费',
|
||||
|
@ -35,7 +40,6 @@ SELECT c.internal_code AS '客户代码',
|
|||
po.logistic_channel_name AS '物流渠道'
|
||||
FROM platform_order_content poc
|
||||
LEFT JOIN sku s2 ON poc.sku_id = s2.id
|
||||
LEFT JOIN product p ON s2.product_id = p.id
|
||||
JOIN platform_order po ON poc.platform_order_id = po.id
|
||||
JOIN shop s ON po.shop_id = s.id
|
||||
JOIN client c ON s.owner_id = c.id
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
CREATE OR REPLACE VIEW sku_country_channel_choice AS
|
||||
SELECT sku.id AS id,
|
||||
cs.client_id AS client_id,
|
||||
sku.product_id AS product_id,
|
||||
sku.id AS product_id,
|
||||
sku.erp_code AS erp_code,
|
||||
sku.image_source AS image_source,
|
||||
sku.available_amount AS available_amount,
|
||||
p.moq AS moq,
|
||||
sku.moq AS moq,
|
||||
rs.quantity AS red_quantity,
|
||||
gs.quantity AS green_quantity,
|
||||
sales_7.quantity AS sales_7,
|
||||
|
@ -13,7 +13,6 @@ SELECT sku.id AS id,
|
|||
sales_28.quantity AS sales_28,
|
||||
sipo.quantity AS platform_order_quantity
|
||||
FROM sku
|
||||
JOIN product p ON sku.product_id = p.id
|
||||
JOIN client_sku cs ON sku.id = cs.sku_id
|
||||
LEFT JOIN sales_7 ON sku.id = sales_7.sku_id
|
||||
LEFT JOIN sales_14 ON sku.id = sales_14.sku_id
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
CREATE OR REPLACE VIEW sku_price_promotion AS
|
||||
SELECT s.id AS sku_id,
|
||||
p.en_name AS name_en,
|
||||
p.zh_name AS name_zh,
|
||||
s.en_name AS name_en,
|
||||
s.zh_name AS name_zh,
|
||||
s.erp_code AS erp_code,
|
||||
s.image_source AS image_source,
|
||||
spr.promotion_id AS promotion_id,
|
||||
|
@ -17,6 +17,5 @@ SELECT s.id AS sku_id,
|
|||
FROM sku s
|
||||
LEFT JOIN sku_promotion_relation spr ON s.id = spr.sku_id
|
||||
LEFT JOIN sku_current_price scp ON s.id = scp.sku_id
|
||||
JOIN product p ON s.product_id = p.id
|
||||
LEFT JOIN sku_in_platform_order sipo ON s.id = sipo.sku_id
|
||||
ORDER BY sipo.quantity DESC;
|
|
@ -1,7 +1,7 @@
|
|||
CREATE OR REPLACE VIEW sku_weight_discount_service_fees AS
|
||||
SELECT s.id,
|
||||
s.erp_code,
|
||||
p.weight,
|
||||
(SELECT sw.weight FROM sku_weight sw WHERE sw.sku_id = s.id ORDER BY effective_date DESC LIMIT 1) as weight,
|
||||
s.shipping_discount,
|
||||
s.service_fee
|
||||
FROM sku s JOIN product p ON p.id = s.product_id;
|
||||
FROM sku s
|
|
@ -0,0 +1,43 @@
|
|||
networks:
|
||||
loki:
|
||||
services:
|
||||
loki:
|
||||
container_name: loki
|
||||
image: grafana/loki:2.9.0
|
||||
ports:
|
||||
- "3100:3100"
|
||||
command: -config.file=/etc/loki/local-config.yaml
|
||||
volumes:
|
||||
- "C:/Users/logau/Documents/wia_app/grafana/loki:/etc/loki"
|
||||
networks:
|
||||
- loki
|
||||
grafana:
|
||||
container_name: grafana
|
||||
environment:
|
||||
- GF_PATHS_PROVISIONING=/etc/grafana/provisioning
|
||||
- GF_AUTH_ANONYMOUS_ENABLED=true
|
||||
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
|
||||
entrypoint:
|
||||
- sh
|
||||
- -euc
|
||||
- |
|
||||
mkdir -p /etc/grafana/provisioning/datasources
|
||||
cat <<EOF > /etc/grafana/provisioning/datasources/ds.yaml
|
||||
apiVersion: 1
|
||||
datasources:
|
||||
- name: Loki
|
||||
type: loki
|
||||
access: proxy
|
||||
orgId: 1
|
||||
url: http://loki:3100
|
||||
basicAuth: false
|
||||
isDefault: true
|
||||
version: 1
|
||||
editable: false
|
||||
EOF
|
||||
/run.sh
|
||||
image: grafana/grafana:latest
|
||||
ports:
|
||||
- "3000:3000"
|
||||
networks:
|
||||
- loki
|
|
@ -0,0 +1,62 @@
|
|||
auth_enabled: false
|
||||
|
||||
server:
|
||||
http_listen_port: 3100
|
||||
|
||||
common:
|
||||
path_prefix: /loki
|
||||
storage:
|
||||
filesystem:
|
||||
chunks_directory: /loki/chunks
|
||||
rules_directory: /loki/rules
|
||||
replication_factor: 1
|
||||
ring:
|
||||
kvstore:
|
||||
store: inmemory
|
||||
|
||||
## added
|
||||
query_range:
|
||||
results_cache:
|
||||
cache:
|
||||
embedded_cache:
|
||||
enabled: true
|
||||
max_size_mb: 500
|
||||
|
||||
chunk_store_config:
|
||||
max_look_back_period: 0s
|
||||
chunk_cache_config:
|
||||
embedded_cache:
|
||||
enabled: true
|
||||
max_size_mb: 500
|
||||
ttl: 24h
|
||||
## end added
|
||||
|
||||
schema_config:
|
||||
configs:
|
||||
- from: 2020-10-24
|
||||
store: boltdb-shipper
|
||||
object_store: filesystem
|
||||
schema: v11
|
||||
index:
|
||||
prefix: index_
|
||||
period: 24h
|
||||
|
||||
## added
|
||||
limits_config:
|
||||
split_queries_by_interval: 0
|
||||
|
||||
ruler:
|
||||
alertmanager_url: http://localhost:9093
|
||||
|
||||
# By default, Loki will send anonymous, but uniquely-identifiable usage and configuration
|
||||
# analytics to Grafana Labs. These statistics are sent to https://stats.grafana.org/
|
||||
#
|
||||
# Statistics help us better understand how Loki is used, and they show us performance
|
||||
# levels for most users. This helps us prioritize features and documentation.
|
||||
# For more information on what's sent, look at
|
||||
# https://github.com/grafana/loki/blob/main/pkg/usagestats/stats.go
|
||||
# Refer to the buildReport method to see what goes into a report.
|
||||
#
|
||||
# If you would like to disable reporting, uncomment the following lines:
|
||||
#analytics:
|
||||
# reporting_enabled: false
|
|
@ -3,7 +3,6 @@ package org.jeecg.modules.business.controller.admin;
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.jeecg.modules.business.entity.ShippingDiscount;
|
||||
import org.jeecg.modules.business.entity.ShippingFeesWaiver;
|
||||
import org.jeecg.modules.business.entity.ShippingFeesWaiverProduct;
|
||||
import org.jeecg.modules.business.service.IShippingFeesWaiverProductService;
|
||||
|
|
|
@ -373,24 +373,23 @@ public class SkuController {
|
|||
} catch (RuntimeException e) {
|
||||
return Result.error("Error 400 Bad Request");
|
||||
}
|
||||
List<SkuOrderPage> allSkuOrdersPage = new ArrayList<>();
|
||||
List<SkuOrderPage> skuOrdersPage = new ArrayList<>();
|
||||
int total = 0;
|
||||
List<SkuOrderPage> skuOrdersPage;
|
||||
int total;
|
||||
if(erpCodes != null || zhNames != null || enNames != null) {
|
||||
List<String> erpCodeList = erpCodes == null ? null : Arrays.asList(erpCodes.split(","));
|
||||
List<String> zhNameList = zhNames == null ? null : Arrays.asList(zhNames.split(","));
|
||||
List<String> enNameList = enNames == null ? null : Arrays.asList(enNames.split(","));
|
||||
if(clientId != null) {
|
||||
allSkuOrdersPage = skuService.fetchSkusByClientWithFilters(clientId, 1, -1, parsedColumn, parsedOrder, erpCodeList, zhNameList, enNameList);
|
||||
total = skuService.countAllClientSkusWithFilters(clientId, erpCodeList, zhNameList, enNameList);
|
||||
skuOrdersPage = skuService.fetchSkusByClientWithFilters(clientId, pageNo, pageSize, parsedColumn, parsedOrder, erpCodeList, zhNameList, enNameList);
|
||||
} else {
|
||||
total = skuService.countAllSkuWeightsWithFilters();
|
||||
total = skuService.countAllSkuWeightsWithFilters(erpCodeList, zhNameList, enNameList);
|
||||
skuOrdersPage = skuService.fetchSkuWeightsWithFilters(pageNo, pageSize, parsedColumn, parsedOrder, erpCodeList, zhNameList, enNameList);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(clientId != null) {
|
||||
allSkuOrdersPage = skuService.fetchSkusByClient(clientId, 1, -1, parsedColumn, parsedOrder);
|
||||
total = skuService.countAllClientSkus();
|
||||
skuOrdersPage = skuService.fetchSkusByClient(clientId, pageNo, pageSize, parsedColumn, parsedOrder);
|
||||
} else {
|
||||
total = skuService.countAllSkus();
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.quartz.JobDataMap;
|
|||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
|
@ -29,6 +30,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ChangeWarehouseJob implements Job {
|
||||
@Autowired
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.quartz.JobExecutionContext;
|
|||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
|
||||
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
|
||||
|
||||
|
@ -25,7 +26,7 @@ import java.math.BigDecimal;
|
|||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ConfirmedClientsInvoicingJob implements Job {
|
||||
@Autowired
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.quartz.JobDataMap;
|
|||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
|
@ -22,11 +23,12 @@ import java.util.List;
|
|||
|
||||
import static org.jeecg.modules.business.domain.api.mabang.getorderlist.OrderStatus.*;
|
||||
|
||||
@Setter
|
||||
@Component
|
||||
@Slf4j
|
||||
public class MabangJob implements Job {
|
||||
|
||||
@Autowired
|
||||
@Setter
|
||||
private IPlatformOrderMabangService platformOrderMabangService;
|
||||
|
||||
private static final Integer DEFAULT_NUMBER_OF_DAYS = 5;
|
||||
|
|
|
@ -13,10 +13,12 @@ import org.quartz.JobDataMap;
|
|||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MabangOrderSyncJob implements Job {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -5,7 +5,6 @@ import lombok.Setter;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.codehaus.jettison.json.JSONException;
|
||||
import org.codehaus.jettison.json.JSONObject;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.modules.business.domain.api.mabang.doSearchSkuListNew.*;
|
||||
import org.jeecg.modules.business.domain.api.mabang.doSearchSkuListNew.SkuData;
|
||||
|
@ -51,9 +50,6 @@ public class MabangSkuJob implements Job {
|
|||
private static final Integer DEFAULT_NUMBER_OF_DAYS = 5;
|
||||
private static final DateType DEFAULT_DATE_TYPE = DateType.CREATE;
|
||||
|
||||
@Autowired
|
||||
private ISysBaseAPI ISysBaseApi;
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
LocalDateTime endDateTime = LocalDateTime.now(ZoneId.of(ZoneId.SHORT_IDS.get("CTT")));
|
||||
|
|
|
@ -73,5 +73,5 @@ public class ShippingFeesWaiverProduct implements Serializable {
|
|||
@Excel(name = "产品ID", width = 15, dictTable = "product", dicText = "code", dicCode = "id")
|
||||
@Dict(dictTable = "product", dicText = "code", dicCode = "id")
|
||||
@ApiModelProperty(value = "产品ID")
|
||||
private java.lang.String productId;
|
||||
private java.lang.String skuId;
|
||||
}
|
||||
|
|
|
@ -22,11 +22,6 @@ import java.util.Map;
|
|||
*/
|
||||
@Repository
|
||||
public interface SkuMapper extends BaseMapper<Sku> {
|
||||
|
||||
boolean deleteByMainId(@Param("mainId") String mainId);
|
||||
|
||||
List<Sku> selectByMainId(@Param("mainId") String mainId);
|
||||
|
||||
List<InventoryRecord> pageSkuByClientId(String clientId, long offset, long size);
|
||||
|
||||
long countTotal(String clientId);
|
||||
|
@ -55,7 +50,10 @@ public interface SkuMapper extends BaseMapper<Sku> {
|
|||
List<SkuQuantity> getSkuQuantitiesFromOrderIds(@Param("orderIds") List<String> orderIds);
|
||||
|
||||
Integer countAllSkus();
|
||||
Integer countAllSkuWeightsWithFilters();
|
||||
Integer countAllSkuWeightsWithFilters(@Param("erpCodes") String erpCodesRegex, @Param("zhNames") String zhNamesRegex, @Param("enNames") String enNamesRegex);
|
||||
Integer countAllClientSkus();
|
||||
Integer countAllClientSkusWithFilters(@Param("clientId") String clientId, @Param("erpCodes") String erpCodesRegex, @Param("zhNames") String zhNamesRegex, @Param("enNames") String enNamesRegex);
|
||||
|
||||
List<SkuOrderPage> fetchSkuWeights(@Param("offset") Integer offset, @Param("size") Integer pageSize, @Param("column") String column, @Param("order") String order);
|
||||
List<SkuOrderPage> fetchSkusByClient(@Param("clientId") String clientId, @Param("offset") Integer offset, @Param("size") Integer pageSize, @Param("column") String column, @Param("order") String order);
|
||||
List<SkuOrderPage> fetchSkuWeightsWithFilters(@Param("offset") Integer offset, @Param("size") Integer pageSize, @Param("column") String column, @Param("order") String order, @Param("erpCodes") String erpCodesRegex, @Param("zhNames") String zhNamesRegex, @Param("enNames") String enNamesRegex);
|
||||
|
|
|
@ -13,17 +13,15 @@
|
|||
FROM purchase_order_sku
|
||||
WHERE purchase_order_id = #{mainId} </select>
|
||||
<select id="selectInvoiceDataByID" resultType="org.jeecg.modules.business.domain.purchase.invoice.PurchaseInvoiceEntry">
|
||||
SELECT s.erp_code, p.en_name, pos.quantity, pos.total_amount
|
||||
SELECT s.erp_code, s.en_name, pos.quantity, pos.total_amount
|
||||
FROM purchase_order_sku pos
|
||||
JOIN sku s on pos.sku_id = s.id
|
||||
JOIN product p on s.product_id = p.id
|
||||
WHERE purchase_order_id = #{purchaseID}
|
||||
</select>
|
||||
<select id="selectInvoicesDataByID" resultType="org.jeecg.modules.business.domain.purchase.invoice.PurchaseInvoiceEntry">
|
||||
SELECT s.erp_code, p.en_name, SUM(pos.quantity) as quantity, SUM(pos.total_amount) as total_amount
|
||||
SELECT s.erp_code, s.en_name, SUM(pos.quantity) as quantity, SUM(pos.total_amount) as total_amount
|
||||
FROM purchase_order_sku pos
|
||||
JOIN sku s on pos.sku_id = s.id
|
||||
JOIN product p on s.product_id = p.id
|
||||
WHERE purchase_order_id IN
|
||||
<foreach collection="purchaseIds" item="purchaseId" index="i" open="(" close=")" separator=",">
|
||||
#{purchaseId}
|
||||
|
|
|
@ -4,10 +4,8 @@
|
|||
<select id="getHighestPriorityAttribute" resultType="org.jeecg.modules.business.entity.SensitiveAttribute">
|
||||
SELECT sa.en_name, sa.priority
|
||||
FROM sensitive_attribute sa
|
||||
JOIN product p
|
||||
ON sa.id = p.sensitive_attribute_id
|
||||
JOIN sku s
|
||||
ON p.id = s.product_id
|
||||
ON s.sensitive_attribute_id = sa.id
|
||||
JOIN platform_order_content poc
|
||||
ON s.id = poc.sku_id
|
||||
JOIN platform_order po
|
||||
|
@ -18,10 +16,8 @@
|
|||
<select id="getHighestPriorityAttributeId" resultType="java.lang.String">
|
||||
SELECT sa.id
|
||||
FROM sensitive_attribute sa
|
||||
JOIN product p
|
||||
ON sa.id = p.sensitive_attribute_id
|
||||
JOIN sku s
|
||||
ON p.id = s.product_id
|
||||
ON sa.id = s.sensitive_attribute_id
|
||||
JOIN platform_order_content poc
|
||||
ON s.id = poc.sku_id
|
||||
JOIN platform_order po
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
SELECT sku.id, sku.erp_code, sfw.id AS waiver_id, sfw.name AS waiver_name, sfw.threshold, sfw.fees
|
||||
FROM shipping_fees_waiver_product sfwp
|
||||
JOIN shipping_fees_waiver sfw ON sfwp.waiver_id = sfw.id
|
||||
JOIN sku ON sku.product_id = sfwp.product_id
|
||||
JOIN sku ON sku.id = sfwp.sku_id
|
||||
WHERE sku.id IN
|
||||
<foreach collection="list" index="i" item="item" open="(" separator="," close=")">#{item}</foreach>
|
||||
</select>
|
||||
|
|
|
@ -1,18 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.business.mapper.SkuMapper">
|
||||
|
||||
<delete id="deleteByMainId" parameterType="java.lang.String">
|
||||
DELETE
|
||||
FROM sku
|
||||
WHERE product_id = #{mainId} </delete>
|
||||
|
||||
<select id="selectByMainId" parameterType="java.lang.String" resultType="org.jeecg.modules.business.entity.Sku">
|
||||
SELECT *
|
||||
FROM sku
|
||||
WHERE product_id = #{mainId} </select>
|
||||
|
||||
|
||||
<sql id="selectSkuByClientId">
|
||||
SELECT *
|
||||
FROM inventory_record i
|
||||
|
@ -179,6 +167,13 @@
|
|||
LIMIT #{offset}, #{size}
|
||||
;
|
||||
</select>
|
||||
<select id="countAllClientSkus" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*) AS total
|
||||
FROM sku s
|
||||
JOIN client_sku ON s.id = client_sku.sku_id
|
||||
WHERE s.status = 3
|
||||
AND client_sku.client_id = #{clientId};
|
||||
</select>
|
||||
<select id="fetchSkusByClient" resultType="org.jeecg.modules.business.vo.SkuOrderPage">
|
||||
WITH qtyInOrdersNotShipped AS (
|
||||
SELECT sku_id as ID, SUM(quantity) AS quantity
|
||||
|
@ -193,11 +188,11 @@
|
|||
)
|
||||
SELECT s.id,
|
||||
s.erp_code,
|
||||
p.en_name as productEn,
|
||||
p.zh_name as product,
|
||||
s.en_name as productEn,
|
||||
s.zh_name as product,
|
||||
s.purchasing_amount,
|
||||
s.available_amount,
|
||||
qtyInOrdersNotShipped.quantity as qtyInOrdersNotShipped,
|
||||
qtyInOrdersNotShipped.quantity as qtyInOrdersNotShipped,
|
||||
s.available_amount + s.purchasing_amount - IF(qtyInOrdersNotShipped.quantity IS NULL, 0, qtyInOrdersNotShipped.quantity) as stock,
|
||||
s.image_source,
|
||||
s.service_fee,
|
||||
|
@ -229,7 +224,6 @@
|
|||
s42.quantity as sales_six_weeks
|
||||
FROM sku s
|
||||
JOIN client_sku ON s.id = client_sku.sku_id
|
||||
JOIN product p ON s.product_id = p.id
|
||||
LEFT JOIN sku_current_price sp ON s.id = sp.sku_id
|
||||
LEFT JOIN sales_28 s28 ON s.id = s28.sku_id
|
||||
LEFT JOIN sales_42 s42 ON s.id = s42.sku_id
|
||||
|
@ -238,9 +232,7 @@
|
|||
WHERE client_sku.client_id = #{clientId}
|
||||
AND s.status = 3
|
||||
ORDER BY ${column} ${order}
|
||||
<if test="size != -1">
|
||||
LIMIT #{offset}, #{size}
|
||||
</if>
|
||||
LIMIT #{offset}, #{size}
|
||||
;
|
||||
</select>
|
||||
<select id="countAllSkuWeightsWithFilters" resultType="java.lang.Integer">
|
||||
|
@ -306,6 +298,30 @@
|
|||
</if>
|
||||
;
|
||||
</select>
|
||||
<select id="countAllClientSkusWithFilters" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*) AS total
|
||||
FROM sku s
|
||||
JOIN client_sku ON s.id = client_sku.sku_id
|
||||
WHERE s.status = 3
|
||||
AND client_sku.client_id = #{clientId}
|
||||
AND (
|
||||
<if test="erpCodes != ''">
|
||||
s.erp_code REGEXP #{erpCodes}
|
||||
</if>
|
||||
<if test="zhNames != ''">
|
||||
<if test="erpCodes != ''">
|
||||
AND
|
||||
</if>
|
||||
s.zh_name REGEXP #{zhNames}
|
||||
</if>
|
||||
<if test="enNames != ''">
|
||||
<if test="erpCodes != '' || zhNames != ''">
|
||||
AND
|
||||
</if>
|
||||
s.en_name REGEXP #{enNames}
|
||||
</if>
|
||||
);
|
||||
</select>
|
||||
<select id="fetchSkusByClientWithFilters" resultType="org.jeecg.modules.business.vo.SkuOrderPage">
|
||||
WITH qtyInOrdersNotShippedCTE AS (
|
||||
SELECT sku_id as ID, SUM(quantity) AS quantity
|
||||
|
@ -320,8 +336,8 @@
|
|||
)
|
||||
SELECT s.id,
|
||||
s.erp_code,
|
||||
p.en_name as productEn,
|
||||
p.zh_name as product,
|
||||
s.en_name as productEn,
|
||||
s.zh_name as product,
|
||||
s.purchasing_amount,
|
||||
s.available_amount,
|
||||
qtyInOrdersNotShippedCTE.quantity as qtyInOrdersNotShipped,
|
||||
|
@ -356,7 +372,6 @@
|
|||
s42.quantity as sales_six_weeks
|
||||
FROM sku s
|
||||
JOIN client_sku ON s.id = client_sku.sku_id
|
||||
JOIN product p ON s.product_id = p.id
|
||||
LEFT JOIN sku_current_price sp ON s.id = sp.sku_id
|
||||
LEFT JOIN sales_28 s28 ON s.id = s28.sku_id
|
||||
LEFT JOIN sales_42 s42 ON s.id = s42.sku_id
|
||||
|
@ -372,13 +387,13 @@
|
|||
<if test="erpCodes != ''">
|
||||
AND
|
||||
</if>
|
||||
p.zh_name REGEXP #{zhNames}
|
||||
s.zh_name REGEXP #{zhNames}
|
||||
</if>
|
||||
<if test="enNames != ''">
|
||||
<if test="erpCodes != '' || zhNames != ''">
|
||||
AND
|
||||
</if>
|
||||
p.en_name REGEXP #{enNames}
|
||||
s.en_name REGEXP #{enNames}
|
||||
</if>
|
||||
)
|
||||
ORDER BY ${column} ${order}
|
||||
|
@ -407,8 +422,8 @@
|
|||
)
|
||||
SELECT s.id,
|
||||
s.erp_code,
|
||||
p.en_name as productEn,
|
||||
p.zh_name as product,
|
||||
s.en_name as productEn,
|
||||
s.zh_name as product,
|
||||
sfi.quantity as qtyOrdered,
|
||||
s.purchasing_amount as purchasing_amount,
|
||||
s.available_amount as available_amount,
|
||||
|
@ -446,7 +461,6 @@
|
|||
IFNULL(s28.quantity, 0) as sales_four_weeks,
|
||||
IFNULL(s42.quantity, 0) as sales_six_weeks
|
||||
FROM sku s
|
||||
JOIN product p ON s.product_id = p.id
|
||||
LEFT JOIN sku_price sp ON s.id = sp.sku_id
|
||||
LEFT JOIN sales_28 s28 ON s.id = s28.sku_id
|
||||
LEFT JOIN sales_42 s42 ON s.id = s42.sku_id
|
||||
|
|
|
@ -21,8 +21,6 @@ import java.util.Map;
|
|||
*/
|
||||
public interface ISkuService extends IService<Sku> {
|
||||
List<Sku> listSkus();
|
||||
List<Sku> selectByMainId(String mainId);
|
||||
|
||||
/**
|
||||
* 添加一对多
|
||||
*/
|
||||
|
@ -97,10 +95,14 @@ public interface ISkuService extends IService<Sku> {
|
|||
|
||||
Integer countAllSkus();
|
||||
List<SkuOrderPage> fetchSkuWeights(Integer pageNo, Integer pageSize, String parsedColumn, String parsedOrder);
|
||||
|
||||
Integer countAllClientSkus();
|
||||
List<SkuOrderPage> fetchSkusByClient(String clientId, Integer pageNo, Integer pageSize, String column, String order);
|
||||
|
||||
Integer countAllSkuWeightsWithFilters();
|
||||
Integer countAllSkuWeightsWithFilters(List<String> erpCodeList, List<String> zhNameList, List<String> enNameList);
|
||||
List<SkuOrderPage> fetchSkuWeightsWithFilters(Integer pageNo, Integer pageSize, String parsedColumn, String parsedOrder, List<String> erpCodes, List<String> zhNames, List<String> enNames);
|
||||
|
||||
Integer countAllClientSkusWithFilters(String clientId, List<String> erpCodeList, List<String> zhNameList, List<String> enNameList);
|
||||
List<SkuOrderPage> fetchSkusByClientWithFilters(String clientId, Integer pageNo, Integer pageSize, String column, String order, List<String> erpCodes, List<String> zhNames, List<String> enNames);
|
||||
|
||||
void addSkuQuantity(Map<String, Integer> quantityPurchased);
|
||||
|
|
|
@ -36,7 +36,6 @@ import java.util.stream.Collectors;
|
|||
@Slf4j
|
||||
@Service
|
||||
public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuService {
|
||||
|
||||
@Autowired
|
||||
private SkuMapper skuMapper;
|
||||
@Autowired
|
||||
|
@ -158,11 +157,6 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS
|
|||
return skuMapper.listSkus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Sku> selectByMainId(String mainId) {
|
||||
return skuMapper.selectByMainId(mainId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillPageForCurrentClient(Page<InventoryRecord> page) {
|
||||
// search client id for current user
|
||||
|
@ -425,14 +419,40 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS
|
|||
return skuMapper.fetchSkuWeights(offset, pageSize, column, order);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer countAllClientSkus() {
|
||||
return skuMapper.countAllClientSkus();
|
||||
}
|
||||
@Override
|
||||
public List<SkuOrderPage> fetchSkusByClient(String clientId, Integer pageNo, Integer pageSize, String column, String order) {
|
||||
int offset = (pageNo - 1) * pageSize;
|
||||
return skuMapper.fetchSkusByClient(clientId, offset, pageSize, column, order);
|
||||
}
|
||||
@Override
|
||||
public Integer countAllSkuWeightsWithFilters() {
|
||||
return skuMapper.countAllSkuWeightsWithFilters();
|
||||
public Integer countAllSkuWeightsWithFilters(List<String> erpCodes, List<String> zhNames, List<String> enNames) {
|
||||
StringBuilder erpCodesRegex= new StringBuilder(), zhNamesRegex = new StringBuilder(), enNamesRegex = new StringBuilder();
|
||||
if(erpCodes != null){
|
||||
erpCodesRegex.append("^");
|
||||
for(String name : erpCodes){
|
||||
erpCodesRegex.append("(?=.*").append(name).append(")");
|
||||
}
|
||||
erpCodesRegex.append(".*");
|
||||
}
|
||||
if(enNames != null){
|
||||
enNamesRegex.append("^");
|
||||
for(String name : enNames){
|
||||
enNamesRegex.append("(?=.*").append(name).append(")");
|
||||
}
|
||||
enNamesRegex.append(".*");
|
||||
}
|
||||
if(zhNames != null){
|
||||
zhNamesRegex.append("^");
|
||||
for(String name : zhNames){
|
||||
zhNamesRegex.append("(?=.*").append(name).append(")");
|
||||
}
|
||||
zhNamesRegex.append(".*$");
|
||||
}
|
||||
return skuMapper.countAllSkuWeightsWithFilters(erpCodesRegex.toString(), zhNamesRegex.toString(), enNamesRegex.toString());
|
||||
}
|
||||
@Override
|
||||
public List<SkuOrderPage> fetchSkuWeightsWithFilters(Integer pageNo, Integer pageSize, String column, String order, List<String> erpCodes, List<String> zhNames, List<String> enNames) {
|
||||
|
@ -462,6 +482,33 @@ public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuS
|
|||
return skuMapper.fetchSkuWeightsWithFilters(offset, pageSize, column, order, erpCodesRegex.toString(), zhNamesRegex.toString(), enNamesRegex.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer countAllClientSkusWithFilters(String clientId, List<String> erpCodes, List<String> zhNames, List<String> enNames) {
|
||||
StringBuilder erpCodesRegex= new StringBuilder(), zhNamesRegex = new StringBuilder(), enNamesRegex = new StringBuilder();
|
||||
if(erpCodes != null){
|
||||
erpCodesRegex.append("^");
|
||||
for(String name : erpCodes){
|
||||
erpCodesRegex.append("(?=.*").append(name).append(")");
|
||||
}
|
||||
erpCodesRegex.append(".*");
|
||||
}
|
||||
if(enNames != null){
|
||||
enNamesRegex.append("^");
|
||||
for(String name : enNames){
|
||||
enNamesRegex.append("(?=.*").append(name).append(")");
|
||||
}
|
||||
enNamesRegex.append(".*");
|
||||
}
|
||||
if(zhNames != null){
|
||||
zhNamesRegex.append("^");
|
||||
for(String name : zhNames){
|
||||
zhNamesRegex.append("(?=.*").append(name).append(")");
|
||||
}
|
||||
zhNamesRegex.append(".*$");
|
||||
}
|
||||
return skuMapper.countAllClientSkusWithFilters(clientId, erpCodesRegex.toString(), zhNamesRegex.toString(), enNamesRegex.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SkuOrderPage> fetchSkusByClientWithFilters(String clientId, Integer pageNo, Integer pageSize, String column, String order, List<String> erpCodes, List<String> zhNames, List<String> enNames) {
|
||||
int offset = (pageNo - 1) * pageSize;
|
||||
|
|
|
@ -60,6 +60,30 @@
|
|||
</appender>
|
||||
<!-- 每天生成一个html格式的日志结束 -->
|
||||
|
||||
<!-- loki日志输出 -->
|
||||
<appender name="LOKI" class="com.github.loki4j.logback.Loki4jAppender">
|
||||
<http>
|
||||
<url>http://localhost:3100/loki/api/v1/push</url>
|
||||
</http>
|
||||
<format>
|
||||
<label>
|
||||
<pattern>app=WIA-APP,host=${HOSTNAME},level=%level</pattern>
|
||||
<readMarkers>true</readMarkers>
|
||||
</label>
|
||||
<message>
|
||||
<pattern>
|
||||
{
|
||||
"level":"%-5level",
|
||||
"class":"%class{0}",
|
||||
"thread":%.10thread,
|
||||
"message": "%msg",
|
||||
"exception": "%ex"
|
||||
}
|
||||
</pattern>
|
||||
</message>
|
||||
</format>
|
||||
</appender>
|
||||
|
||||
<!--myibatis log configure -->
|
||||
<logger name="com.apache.ibatis" level="TRACE" />
|
||||
<logger name="java.sql.Connection" level="DEBUG" />
|
||||
|
@ -72,6 +96,7 @@
|
|||
<appender-ref ref="FILE" />
|
||||
<appender-ref ref="HTML" />
|
||||
<appender-ref ref="FILE_HTML" />
|
||||
<appender-ref ref="LOKI" />
|
||||
</root>
|
||||
|
||||
</configuration>
|
Loading…
Reference in New Issue