| | |
| | | |
| | | import cc.mrbird.febs.mall.entity.MallAchieveRecord; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | public interface MallAchieveRecordMapper extends BaseMapper<MallAchieveRecord> { |
| | | |
| | | BigDecimal selectAchieveTotal(@Param("type") String type, @Param("date") Date date); |
| | | } |
| | |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.service.ValidateCodeService; |
| | | import cc.mrbird.febs.common.utils.Md5Util; |
| | | import cc.mrbird.febs.mall.mapper.MallAchieveRecordMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallMemberMapper; |
| | | import cc.mrbird.febs.monitor.entity.LoginLog; |
| | | import cc.mrbird.febs.monitor.service.ILoginLogService; |
| | | import cc.mrbird.febs.system.entity.User; |
| | | import cc.mrbird.febs.system.service.IUserService; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.shiro.authc.UsernamePasswordToken; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | import javax.servlet.http.HttpSession; |
| | | import javax.validation.constraints.NotBlank; |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | private final IUserService userService; |
| | | private final ValidateCodeService validateCodeService; |
| | | private final ILoginLogService loginLogService; |
| | | private final MallMemberMapper mallMemberMapper; |
| | | private final MallAchieveRecordMapper mallAchieveRecordMapper; |
| | | |
| | | @PostMapping("login") |
| | | @Limit(key = "login", period = 60, count = 10, name = "登录接口", prefix = "limit") |
| | |
| | | this.userService.updateLoginTime(username); |
| | | Map<String, Object> data = new HashMap<>(5); |
| | | // 获取系统访问记录 |
| | | Long totalVisitCount = this.loginLogService.findTotalVisitCount(); |
| | | data.put("totalVisitCount", totalVisitCount); |
| | | Long todayVisitCount = this.loginLogService.findTodayVisitCount(); |
| | | data.put("todayVisitCount", todayVisitCount); |
| | | Long todayIp = this.loginLogService.findTodayIp(); |
| | | data.put("todayIp", todayIp); |
| | | // Long totalVisitCount = this.loginLogService.findTotalVisitCount(); |
| | | // data.put("totalVisitCount", totalVisitCount); |
| | | // Long todayVisitCount = this.loginLogService.findTodayVisitCount(); |
| | | // data.put("todayVisitCount", todayVisitCount); |
| | | // Long todayIp = this.loginLogService.findTodayIp(); |
| | | // data.put("todayIp", todayIp); |
| | | |
| | | data.put("lastDay", mallAchieveRecordMapper.selectAchieveTotal("D", DateUtil.offsetDay(new Date(), -1))); |
| | | data.put("today", mallAchieveRecordMapper.selectAchieveTotal("D", new Date())); |
| | | data.put("lastMonth", mallAchieveRecordMapper.selectAchieveTotal("M", DateUtil.offsetMonth(new Date(), -1))); |
| | | data.put("thisMonth", mallAchieveRecordMapper.selectAchieveTotal("M", new Date())); |
| | | |
| | | // 获取近期系统访问记录 |
| | | List<Map<String, Object>> lastSevenVisitCount = this.loginLogService.findLastSevenDaysVisitCount(null); |
| | | data.put("lastSevenVisitCount", lastSevenVisitCount); |
| | |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cc.mrbird.febs.mall.mapper.MallAchieveRecordMapper"> |
| | | |
| | | <select id="selectAchieveTotal" resultType="java.math.BigDecimal"> |
| | | select IFNULL(sum(IFNULL(amount,0)),0) from mall_achieve_record |
| | | where 1=1 |
| | | <if test='type == "D"'> |
| | | and date_format(achieve_time, '%Y-%m-%d') = date_format(#{date}, '%Y-%m-%d'); |
| | | </if> |
| | | <if test='type == "M"'> |
| | | and date_format(achieve_time, '%Y-%m') = date_format(#{date}, '%Y-%m'); |
| | | </if> |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | </div> |
| | | </div> |
| | | <div class="layui-col-md6 layui-col-sm12 layui-col-xs12"> |
| | | <div class="layui-col-md-offset5"> |
| | | <div class="layui-col-md-offset4"> |
| | | <table class="login-count-table"> |
| | | <tr> |
| | | <td>今日IP</td> |
| | | <td>今日访问</td> |
| | | <td>总访问量</td> |
| | | <td>今日业绩</td> |
| | | <td>昨日业绩</td> |
| | | <td>本月业绩</td> |
| | | <td>上月业绩</td> |
| | | </tr> |
| | | <tr> |
| | | <td class="count" id="today-ip"> |
| | | <td class="count" id="today"> |
| | | 0 |
| | | </td> |
| | | <td class="count" id="today-visit-count"> |
| | | <td class="count" id="lastDay"> |
| | | 0 |
| | | </td> |
| | | <td class="count" id="total-visit-count"> |
| | | <td class="count" id="thisMonth"> |
| | | 0 |
| | | </td> |
| | | <td class="count" id="lastMonth"> |
| | | 0 |
| | | </td> |
| | | </tr> |
| | |
| | | </div> |
| | | </div> |
| | | <div class="layui-col-md6 layui-col-sm6 layui-col-xs12"> |
| | | <div class="layui-card"> |
| | | <div class="layui-card-body"> |
| | | <div id="chart" style="height: 350px"></div> |
| | | </div> |
| | | </div> |
| | | <!-- <div class="layui-card">--> |
| | | <!-- <div class="layui-card-body">--> |
| | | <!-- </div>--> |
| | | <!-- </div>--> |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | ]; |
| | | var index = Math.floor((Math.random() * welcomeArr.length)); |
| | | var welcomeMessage = time + ',<a id="febs-index-user">' + currentUser.username + '</a>,' + welcomeArr[index]; |
| | | $view.find('#today-ip').text(data.todayIp).end() |
| | | .find('#today-visit-count').text(data.todayVisitCount).end() |
| | | .find('#total-visit-count').text(data.totalVisitCount).end() |
| | | $view.find('#today').text(data.today).end() |
| | | .find('#lastDay').text(data.lastDay).end() |
| | | .find('#thisMonth').text(data.thisMonth).end() |
| | | .find('#lastMonth').text(data.lastMonth).end() |
| | | .find('#user-dept').text(currentUser.deptName ? currentUser.deptName : '暂无所属部门').end() |
| | | .find('#user-role').text(currentUser.roleName ? currentUser.roleName : '暂无角色').end() |
| | | .find('#last-login-time').text(currentUser.lastLoginTime ? currentUser.lastLoginTime : '第一次访问系统').end() |
| | |
| | | }); |
| | | if (!contain) totalVisitCount.push(0); |
| | | }); |
| | | |
| | | var options = { |
| | | chart: { |
| | | height: 350, |
| | | type: 'area', |
| | | toolbar: { |
| | | show: false |
| | | } |
| | | }, |
| | | colors: ['#1890ff', '#0acf97'], |
| | | plotOptions: { |
| | | bar: { |
| | | horizontal: false, |
| | | columnWidth: '32rem' |
| | | } |
| | | }, |
| | | dataLabels: { |
| | | enabled: false |
| | | }, |
| | | stroke: { |
| | | width: [3, 3], |
| | | curve: 'smooth' |
| | | }, |
| | | series: [{ |
| | | name: '总数', |
| | | data: totalVisitCount |
| | | }, { |
| | | name: '您', |
| | | data: yourVisitCount |
| | | }], |
| | | xaxis: { |
| | | categories: lastTenDays, |
| | | axisTicks: { |
| | | show: true |
| | | }, |
| | | axisBorder: { |
| | | show: true, |
| | | color: '#f1f1f1' |
| | | } |
| | | }, |
| | | fill: { |
| | | type: 'gradient', |
| | | gradient: { |
| | | shadeIntensity: 1, |
| | | inverseColors: false, |
| | | opacityFrom: 0.5, |
| | | opacityTo: 0, |
| | | stops: [0, 90, 100] |
| | | } |
| | | }, |
| | | title: { |
| | | text: '近10天系统访问记录', |
| | | align: 'left', |
| | | style: { |
| | | color: 'rgba(0, 0, 0, .65)' |
| | | } |
| | | }, |
| | | tooltip: { |
| | | y: { |
| | | formatter: function (val) { |
| | | return "访问次数 " + val + " 次" |
| | | } |
| | | } |
| | | }, |
| | | grid: { |
| | | row: { |
| | | colors: ['transparent', 'transparent'], |
| | | opacity: 0.2 |
| | | }, |
| | | borderColor: '#f1f1f1' |
| | | } |
| | | }; |
| | | |
| | | new ApexCharts( |
| | | document.querySelector("#chart"), |
| | | options |
| | | ).render(); |
| | | } |
| | | |
| | | $view.on('click', '#febs-index-user',function () { |