管理员主页信息

This commit is contained in:
csc 2025-10-17 02:23:27 +08:00
parent 59c460f5d4
commit dc4d26965d
4 changed files with 72 additions and 38 deletions

View File

@ -14,29 +14,29 @@ const authStore = useAuthStore();
const gap = computed(() => (appStore.isMobile ? 0 : 16));
interface StatisticData {
id: number;
label: string;
value: string;
}
const statisticData = computed<StatisticData[]>(() => [
{
id: 0,
label: $t('page.home.projectCount'),
value: '25'
},
{
id: 1,
label: $t('page.home.todo'),
value: '4/16'
},
{
id: 2,
label: $t('page.home.message'),
value: '12'
}
]);
// interface StatisticData {
// id: number;
// label: string;
// value: string;
// }
//
// const statisticData = computed<StatisticData[]>(() => [
// {
// id: 0,
// label: $t('page.home.projectCount'),
// value: '25'
// },
// {
// id: 1,
// label: $t('page.home.todo'),
// value: '4/16'
// },
// {
// id: 2,
// label: $t('page.home.message'),
// value: '12'
// }
// ]);
</script>
<template>
@ -61,7 +61,7 @@ const statisticData = computed<StatisticData[]>(() => [
</NGi>
<NGi span="24 s:24 m:6">
<NSpace :size="24" justify="end">
<NStatistic v-for="item in statisticData" :key="item.id" class="whitespace-nowrap" v-bind="item" />
<!-- <NStatistic v-for="item in statisticData" :key="item.id" class="whitespace-nowrap" v-bind="item" />-->
</NSpace>
</NGi>
</NGrid>

View File

@ -26,6 +26,11 @@ public interface MpsMarketMapper extends BaseMapperPlus<MpsMarket, MpsMarketVo>
return this.selectVoPage(page, queryWrapper);
}
/**
* 按照客户身份证号去重后查询数量
*/
Integer selectCountByCustId( @Param("startDate") String startDate, @Param("endDate") String endDate);
//@DataPermission({
// @DataColumn(key = "deptName", value = "create_dept"),

View File

@ -1,8 +1,14 @@
package org.dromara.statistics.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.business.mapper.BusinessSubcategoryMapper;
import org.dromara.common.core.domain.R;
import org.dromara.mps.domain.MpsMarket;
import org.dromara.mps.mapper.MpsMarketMapper;
import org.dromara.statistics.domain.vo.*;
import org.dromara.system.mapper.SysUserMapper;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -20,12 +26,17 @@ import java.util.*;
* 数据 按需根据业务表自行计算,目前为mock数据
*
*/
@Slf4j
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/common/statistics")
public class StatisticsController {
private final SysUserMapper sysUserMapper;
private final MpsMarketMapper mpsMarketMapper;
private final BusinessSubcategoryMapper businessSubcategoryMapper;
// 日期格式化器
private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("MM/dd");
private static final DateTimeFormatter FULL_DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
@ -138,23 +149,28 @@ public class StatisticsController {
LocalDate end = LocalDate.parse(endDate);
long days = ChronoUnit.DAYS.between(start, end) + 1;
// 根据天数调整比例 (最大不超过2倍)
double multiplier = Math.min(1 + days / 30.0, 2.0);
// 创建模拟数据
Map<String, Integer> data = new HashMap<>();
// 基础值
int[] baseValues = {400, 4000, 16, 66};
String[] keys = {"staffCount", "mpsCount", "busiCount", "customerCount"};
Random random = new Random();
for (int i = 0; i < keys.length; i++) {
// 基础值乘以倍数并添加随机波动
int value = (int) Math.round(baseValues[i] * multiplier * (0.9 + 0.2 * random.nextDouble()));
data.put(keys[i], value);
try {
Long staffCount = sysUserMapper.selectCount(new LambdaQueryWrapper<>());
LambdaQueryWrapper<MpsMarket> wrapper = new LambdaQueryWrapper<>();
//entry_date
wrapper.ge(MpsMarket::getEntryDate, startDate);
wrapper.le(MpsMarket::getEntryDate, endDate);
Long mpsCount = mpsMarketMapper.selectCount(wrapper);
Long busiCount = businessSubcategoryMapper.selectCount(new LambdaQueryWrapper<>());
Integer customerCount = mpsMarketMapper.selectCountByCustId(startDate, endDate);
data.put("staffCount", Math.toIntExact(staffCount));
data.put("mpsCount", Math.toIntExact(mpsCount));
data.put("busiCount", Math.toIntExact(busiCount));
data.put("customerCount", customerCount);
} catch (Exception e) {
log.error("获取汇总卡片数据异常", e);
data.put("staffCount", 0);
data.put("mpsCount", 0);
data.put("busiCount", 0);
data.put("customerCount", 0);
}
return R.ok(data);
}

View File

@ -85,4 +85,17 @@
)
</foreach>
</insert>
<!-- 按照客户身份证号去重后查询数量-->
<select id="selectCountByCustId" resultType="java.lang.Integer">
SELECT COUNT(DISTINCT cust_id) FROM mps_market
WHERE del_flag = 0
<if test="startDate != null and startDate != ''">
AND entry_date >= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
AND entry_date &lt;= #{endDate}
</if>
</select>
</mapper>