@@ -0,0 +1,16 @@ | |||
DROP TABLE IF EXISTS `nj_balance_manage_detail`; | |||
CREATE TABLE `nj_balance_manage_detail` ( | |||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID', | |||
`user_id` bigint(20) NOT NULL COMMENT '员工编号', | |||
`user_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '员工姓名', | |||
`nick_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '员工姓名', | |||
`dept_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '部门名称', | |||
`used_day` decimal(5, 2) NULL DEFAULT NULL COMMENT '已使用天数', | |||
`apply_dates` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '申请日期', | |||
`status` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '状态 待提交0 待审批1 审批通过2 驳回3 已作废4', | |||
`create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', | |||
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间', | |||
`create_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人', | |||
`update_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新人', | |||
PRIMARY KEY (`id`) USING BTREE | |||
) ENGINE = InnoDB AUTO_INCREMENT = 20 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; |
@@ -24,6 +24,7 @@ public interface ReportMapper { | |||
List<CategoryTrendVO> selectCategoryTrendData(Map<String, Object> params); | |||
List<Map<String, Object>> selectSpecsRawData(Map<String, Object> params); | |||
List<Map<String, Object>> selectBrandRawData(Map<String, Object> params); | |||
List<String> selectCategories(); | |||
List<String> selectCategorySpecs(); |
@@ -231,6 +231,63 @@ public class ReportServiceImpl implements ReportService { | |||
quantityData.sort((a, b) -> b.getQuantity().compareTo(a.getQuantity())); | |||
dimensionCharts.put(dim, new DimensionChartVO(amountData, quantityData)); | |||
} | |||
//添加品牌 因为没在分类规格里 所以只能额外添加了 | |||
// 添加品牌 因为没在分类规格里 所以只能额外添加了 | |||
List<Map<String, Object>> brandRawData = reportMapper.selectBrandRawData(params); | |||
if (brandRawData != null && !brandRawData.isEmpty()) { | |||
List<DimensionStatsVO> amountData = new ArrayList<>(); | |||
List<DimensionStatsVO> quantityData = new ArrayList<>(); | |||
// 计算总金额和总数量 | |||
double totalAmount = brandRawData.stream() | |||
.mapToDouble(vo -> Double.parseDouble(vo.get("amount").toString())) | |||
.sum(); | |||
double totalQuantity = brandRawData.stream() | |||
.mapToDouble(vo -> Double.parseDouble(vo.get("quantity").toString())) | |||
.sum(); | |||
for (Map<String, Object> map : brandRawData) { | |||
String brand = map.get("brand") != null ? map.get("brand").toString() : "未知品牌"; | |||
double quantity = Double.parseDouble(map.get("quantity").toString()); | |||
double amount = Double.parseDouble(map.get("amount").toString()); | |||
// 金额占比(去掉%) | |||
String amountPercentage = totalAmount > 0 | |||
? String.format("%.2f", amount * 100 / totalAmount) | |||
: "0.00"; | |||
DimensionStatsVO amountVO = new DimensionStatsVO( | |||
brand, | |||
quantity, | |||
amount, | |||
amountPercentage, | |||
amount | |||
); | |||
amountData.add(amountVO); | |||
// 数量占比(去掉%) | |||
String quantityPercentage = totalQuantity > 0 | |||
? String.format("%.2f", quantity * 100 / totalQuantity) | |||
: "0.00"; | |||
DimensionStatsVO quantityVO = new DimensionStatsVO( | |||
brand, | |||
quantity, | |||
amount, | |||
quantityPercentage, | |||
quantity | |||
); | |||
quantityData.add(quantityVO); | |||
} | |||
DimensionChartVO dimensionChartVO = new DimensionChartVO(amountData, quantityData); | |||
dimensionCharts.put("品牌", dimensionChartVO); | |||
availableDimensions.add("品牌"); | |||
} | |||
CategoryAnalysisVO vo = new CategoryAnalysisVO(); | |||
vo.setDimensionCharts(dimensionCharts); | |||
vo.setAvailableDimensions(new ArrayList<>(availableDimensions)); |
@@ -255,6 +255,22 @@ | |||
LIMIT 10 | |||
</select> | |||
<!-- 16. 商品品牌--> | |||
<select id="selectBrandRawData" resultType="map"> | |||
SELECT | |||
brand, | |||
SUM(quantity) AS quantity, | |||
SUM(total_amount) AS amount | |||
FROM zs_tjfx_analysis_data | |||
WHERE date BETWEEN #{startDate} AND #{endDate} | |||
<if test="category != null and category != ''">AND category = #{category}</if> | |||
AND status = 1 | |||
AND category_specs IS NOT NULL | |||
AND category_specs != '' | |||
GROUP BY brand | |||
ORDER BY amount DESC | |||
</select> | |||
<!-- 1. 整体销售分析 基础统计 --> | |||
<!-- <select id="selectBasicStats" resultType="com.ruoyi.tjfx.entity.BasicStatsVO"> | |||
SELECT |