Merge remote-tracking branch 'origin/station' into station
This commit is contained in:
commit
ce637d74b4
|
@ -6,6 +6,9 @@ import io.swagger.annotations.ApiOperation;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.constant.EmailConstant;
|
import org.jeecg.common.constant.EmailConstant;
|
||||||
import org.jeecg.common.util.RedisUtil;
|
import org.jeecg.common.util.RedisUtil;
|
||||||
|
import org.jeecg.modules.qiyeEmail.base.RParam;
|
||||||
|
import org.jeecg.modules.qiyeEmail.base.dto.AccountInfo;
|
||||||
|
import org.jeecg.modules.qiyeEmail.service.Account;
|
||||||
import org.jeecg.modules.service.ISysEmailLogService;
|
import org.jeecg.modules.service.ISysEmailLogService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
@ -14,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("sysEmailLog")
|
@RequestMapping("sysEmailLog")
|
||||||
|
@ -27,7 +31,7 @@ public class SysEmailLogController {
|
||||||
|
|
||||||
@GetMapping("status")
|
@GetMapping("status")
|
||||||
@ApiOperation("邮箱服务器状态")
|
@ApiOperation("邮箱服务器状态")
|
||||||
public Result status(@RequestParam("emailId") String emailId){
|
public Result<?> status(@RequestParam("emailId") String emailId){
|
||||||
String key = EmailConstant.EMAIL_STATUS_PREFIX;
|
String key = EmailConstant.EMAIL_STATUS_PREFIX;
|
||||||
Boolean emailSatus = (Boolean) redisUtil.hget(key, emailId);
|
Boolean emailSatus = (Boolean) redisUtil.hget(key, emailId);
|
||||||
return Result.OK(emailSatus == null ? false : emailSatus);
|
return Result.OK(emailSatus == null ? false : emailSatus);
|
||||||
|
@ -35,29 +39,25 @@ public class SysEmailLogController {
|
||||||
|
|
||||||
@GetMapping("space")
|
@GetMapping("space")
|
||||||
@ApiOperation("邮箱服务器空间")
|
@ApiOperation("邮箱服务器空间")
|
||||||
public Result space(@RequestParam("emailId") String emailId){
|
public Result<?> space(@RequestParam("emailId") String emailId){
|
||||||
HashMap<String, String> map = MapUtil.newHashMap();
|
return Result.OK(sysEmailLogService.space(emailId));
|
||||||
map.put("total","500G");
|
|
||||||
map.put("residue","300G");
|
|
||||||
map.put("usage","74.3%");
|
|
||||||
return Result.OK(map);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("total")
|
@GetMapping("total")
|
||||||
@ApiOperation("今天|昨天|过去一周邮件量")
|
@ApiOperation("今天|昨天|过去一周邮件量")
|
||||||
public Result totalEmail(@RequestParam("emailId") String emailId){
|
public Result<?> totalEmail(@RequestParam("emailId") String emailId){
|
||||||
return sysEmailLogService.totalEmail(emailId);
|
return sysEmailLogService.totalEmail(emailId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("today")
|
@GetMapping("today")
|
||||||
@ApiOperation("今日邮件接收量")
|
@ApiOperation("今日邮件接收量")
|
||||||
public Result today(@RequestParam("emailId") String emailId){
|
public Result<?> today(@RequestParam("emailId") String emailId){
|
||||||
return sysEmailLogService.todayMin(emailId);
|
return sysEmailLogService.todayMin(emailId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("analysis")
|
@GetMapping("analysis")
|
||||||
@ApiOperation("根据日期统计-折线图")
|
@ApiOperation("根据日期统计-折线图")
|
||||||
public Result analysis(@RequestParam("emailId") String emailId,
|
public Result<?> analysis(@RequestParam("emailId") String emailId,
|
||||||
@RequestParam("startDate") String startDate,
|
@RequestParam("startDate") String startDate,
|
||||||
@RequestParam("endDate") String endDate){
|
@RequestParam("endDate") String endDate){
|
||||||
return sysEmailLogService.analysis(emailId, startDate, endDate);
|
return sysEmailLogService.analysis(emailId, startDate, endDate);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.jeecg.modules.mapper;
|
package org.jeecg.modules.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.jeecg.modules.base.dto.EmailDto;
|
import org.jeecg.modules.base.dto.EmailDto;
|
||||||
import org.jeecg.modules.base.dto.IdCount;
|
import org.jeecg.modules.base.dto.IdCount;
|
||||||
|
@ -9,7 +10,7 @@ import org.jeecg.modules.entity.AlarmHistory;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@Mapper
|
||||||
public interface SysEmailMapper extends BaseMapper<SysEmail> {
|
public interface SysEmailMapper extends BaseMapper<SysEmail> {
|
||||||
|
|
||||||
List<AlarmHistory> findAlarmHistory(Map<String,Object> params);
|
List<AlarmHistory> findAlarmHistory(Map<String,Object> params);
|
||||||
|
|
|
@ -13,15 +13,11 @@ public class InstanceSDK {
|
||||||
|
|
||||||
public static QiyeOpenPlatSDK getInstance() {
|
public static QiyeOpenPlatSDK getInstance() {
|
||||||
//init
|
//init
|
||||||
//Environment env = SpringContextUtils.getBean(Environment.class);
|
Environment env = SpringContextUtils.getBean(Environment.class);
|
||||||
/*String appId = env.getProperty("qiyeEmail.appId");
|
String appId = env.getProperty("qiyeEmail.appId");
|
||||||
String orgOpenId = env.getProperty("qiyeEmail.orgOpenId");
|
String orgOpenId = env.getProperty("qiyeEmail.orgOpenId");
|
||||||
String authCode = env.getProperty("qiyeEmail.authCode");
|
String authCode = env.getProperty("qiyeEmail.authCode");
|
||||||
String urlPrefix = env.getProperty("qiyeEmail.urlPrefix");*/
|
String urlPrefix = env.getProperty("qiyeEmail.urlPrefix");
|
||||||
String appId = "qy20231114144636B85B";
|
|
||||||
String orgOpenId = "9c96b0ec1e6be89a";
|
|
||||||
String authCode = "O1eSXJwU";
|
|
||||||
String urlPrefix = "https://api.qiye.163.com";
|
|
||||||
|
|
||||||
QiyeOpenPlatSDKConfig qiyeOpenPlatSDKConfig = QiyeOpenPlatSDKConfig.builder()
|
QiyeOpenPlatSDKConfig qiyeOpenPlatSDKConfig = QiyeOpenPlatSDKConfig.builder()
|
||||||
//应用ID
|
//应用ID
|
||||||
|
|
|
@ -22,20 +22,15 @@ public class Account {
|
||||||
Q reqParam = Q.init(rParam);
|
Q reqParam = Q.init(rParam);
|
||||||
R result = platSDK.commonInvoke(reqParam, AccountAPI.ACCOUNTINFO);
|
R result = platSDK.commonInvoke(reqParam, AccountAPI.ACCOUNTINFO);
|
||||||
String responseText = result.getResponseText();
|
String responseText = result.getResponseText();
|
||||||
|
AccountInfo accountInfo = new AccountInfo();
|
||||||
try {
|
try {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
ResponseText response = objectMapper.readValue(responseText, ResponseText.class);
|
ResponseText response = objectMapper.readValue(responseText, ResponseText.class);
|
||||||
return BeanUtil.mapToBean(response.getCon(),AccountInfo.class, CopyOptions.create());
|
accountInfo = BeanUtil.mapToBean(response.getCon(), AccountInfo.class, CopyOptions.create());
|
||||||
|
return accountInfo;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return accountInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
RParam rParam = new RParam();
|
|
||||||
rParam.setDomain("ndc.org.cn");
|
|
||||||
rParam.setAccount_name("cnndc.rn.ng");
|
|
||||||
System.out.println(getMailAccountInfo(rParam));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,16 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.modules.base.entity.postgre.SysEmailLog;
|
import org.jeecg.modules.base.entity.postgre.SysEmailLog;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public interface ISysEmailLogService extends IService<SysEmailLog> {
|
public interface ISysEmailLogService extends IService<SysEmailLog> {
|
||||||
Result totalEmail(String emailId);
|
Result<?> totalEmail(String emailId);
|
||||||
|
|
||||||
Result todayHour(String emailId);
|
Map<String,Object> space(String emailId);
|
||||||
|
|
||||||
Result todayMin(String emailId);
|
Result<?> todayHour(String emailId);
|
||||||
|
|
||||||
Result analysis(String emailId, String startDate, String endDate);
|
Result<?> todayMin(String emailId);
|
||||||
|
|
||||||
|
Result<?> analysis(String emailId, String startDate, String endDate);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,28 @@ package org.jeecg.modules.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.collection.ListUtil;
|
import cn.hutool.core.collection.ListUtil;
|
||||||
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.constant.DateConstant;
|
import org.jeecg.common.constant.DateConstant;
|
||||||
import org.jeecg.common.constant.Prompt;
|
import org.jeecg.common.constant.Prompt;
|
||||||
|
import org.jeecg.modules.base.entity.postgre.SysEmail;
|
||||||
import org.jeecg.modules.base.entity.postgre.SysEmailLog;
|
import org.jeecg.modules.base.entity.postgre.SysEmailLog;
|
||||||
import org.jeecg.modules.mapper.SysEmailLogMapper;
|
import org.jeecg.modules.mapper.SysEmailLogMapper;
|
||||||
|
import org.jeecg.modules.mapper.SysEmailMapper;
|
||||||
|
import org.jeecg.modules.qiyeEmail.base.RParam;
|
||||||
|
import org.jeecg.modules.qiyeEmail.base.dto.AccountInfo;
|
||||||
|
import org.jeecg.modules.qiyeEmail.service.Account;
|
||||||
import org.jeecg.modules.service.ISysEmailLogService;
|
import org.jeecg.modules.service.ISysEmailLogService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
|
@ -26,6 +37,9 @@ import java.util.stream.IntStream;
|
||||||
@Service("sysEmailLogService")
|
@Service("sysEmailLogService")
|
||||||
public class SysEmailLogServiceImpl extends ServiceImpl<SysEmailLogMapper, SysEmailLog> implements ISysEmailLogService {
|
public class SysEmailLogServiceImpl extends ServiceImpl<SysEmailLogMapper, SysEmailLog> implements ISysEmailLogService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysEmailMapper sysEmailMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<?> totalEmail(String emailId) {
|
public Result<?> totalEmail(String emailId) {
|
||||||
// 当日邮件量
|
// 当日邮件量
|
||||||
|
@ -59,6 +73,37 @@ public class SysEmailLogServiceImpl extends ServiceImpl<SysEmailLogMapper, SysEm
|
||||||
return Result.OK(result);
|
return Result.OK(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> space(String emailId) {
|
||||||
|
SysEmail sysEmail = sysEmailMapper.selectById(emailId);
|
||||||
|
String emailUsername = sysEmail.getUsername();
|
||||||
|
Map<String, Object> map = MapUtil.newHashMap();
|
||||||
|
if (ObjectUtil.isNull(sysEmail) || StrUtil.isBlank(emailUsername))
|
||||||
|
return map;
|
||||||
|
String[] info = StrUtil.split(emailUsername, "@");
|
||||||
|
if (ArrayUtil.length(info) < 2)
|
||||||
|
return map;
|
||||||
|
RParam rParam = new RParam();
|
||||||
|
rParam.setDomain(info[1]);
|
||||||
|
rParam.setAccount_name(info[0]);
|
||||||
|
AccountInfo mailAccountInfo = Account.getMailAccountInfo(rParam);
|
||||||
|
Integer usedQuota = mailAccountInfo.getUsedQuota();
|
||||||
|
Integer maxQuota = mailAccountInfo.getMaxQuota();
|
||||||
|
map.put("total", maxQuota < 0 ? maxQuota + "(No Limit)" : m2G(maxQuota));
|
||||||
|
map.put("residue", m2G(usedQuota));
|
||||||
|
map.put("usage","74.3%");
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String m2G(Integer mb) {
|
||||||
|
if (ObjectUtil.isNull(mb))
|
||||||
|
return "0.00GB";
|
||||||
|
BigDecimal bigMB = new BigDecimal(mb);
|
||||||
|
BigDecimal bigGB = bigMB.divide(BigDecimal.valueOf(1024),
|
||||||
|
2, RoundingMode.HALF_UP);
|
||||||
|
return bigGB + "GB";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<?> todayHour(String emailId) {
|
public Result<?> todayHour(String emailId) {
|
||||||
LambdaQueryWrapper<SysEmailLog> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SysEmailLog> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
|
@ -196,38 +196,4 @@ public class SysEmailServiceImpl extends ServiceImpl<SysEmailMapper, SysEmail> i
|
||||||
}
|
}
|
||||||
return sourceDtos;
|
return sourceDtos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws MessagingException {
|
|
||||||
Properties prop = System.getProperties();
|
|
||||||
|
|
||||||
String host = "imaphz.qiye.163.com";
|
|
||||||
String username = "cnndc.rn.dr@ndc.org.cn";
|
|
||||||
String password = "cnndc66367220";
|
|
||||||
|
|
||||||
prop.setProperty("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
|
|
||||||
prop.setProperty("mail.imap.host", host);
|
|
||||||
prop.setProperty("mail.imap.port", "993");
|
|
||||||
prop.setProperty("mail.imap.starttls.enable", "true");
|
|
||||||
prop.setProperty("mail.imap.socketFactory.fallback", "false");
|
|
||||||
prop.setProperty("mail.debug", "true");
|
|
||||||
|
|
||||||
Session ses = Session.getInstance(prop, null);
|
|
||||||
Store store = ses.getStore("imap");
|
|
||||||
store.connect(host, username, password);
|
|
||||||
|
|
||||||
if (!IMAPStore.class.isInstance(store))
|
|
||||||
throw new IllegalStateException("Is not IMAPStore");
|
|
||||||
IMAPStore imapStore = (IMAPStore) store;
|
|
||||||
Quota[] quotas = imapStore.getQuota("INBOX");
|
|
||||||
|
|
||||||
for (Quota quota : quotas) {
|
|
||||||
System.out.println(String.format("quotaRoot:%s", quota.quotaRoot));
|
|
||||||
|
|
||||||
for (Quota.Resource resource : quota.resources) {
|
|
||||||
System.out.println(String.format("name:%s, limit:%s, usage:%s",
|
|
||||||
resource.name, resource.limit, resource.usage));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,10 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<!--以下配置用于在打包时添加自己引入的<scope>system</scope>-->
|
||||||
|
<configuration>
|
||||||
|
<includeSystemScope>true</includeSystemScope>
|
||||||
|
</configuration>
|
||||||
<!--<configuration>
|
<!--<configuration>
|
||||||
<layout>ZIP</layout>
|
<layout>ZIP</layout>
|
||||||
<includes>
|
<includes>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user