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.constant.EmailConstant;
|
||||
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.springframework.beans.factory.annotation.Autowired;
|
||||
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 java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("sysEmailLog")
|
||||
|
@ -27,7 +31,7 @@ public class SysEmailLogController {
|
|||
|
||||
@GetMapping("status")
|
||||
@ApiOperation("邮箱服务器状态")
|
||||
public Result status(@RequestParam("emailId") String emailId){
|
||||
public Result<?> status(@RequestParam("emailId") String emailId){
|
||||
String key = EmailConstant.EMAIL_STATUS_PREFIX;
|
||||
Boolean emailSatus = (Boolean) redisUtil.hget(key, emailId);
|
||||
return Result.OK(emailSatus == null ? false : emailSatus);
|
||||
|
@ -35,29 +39,25 @@ public class SysEmailLogController {
|
|||
|
||||
@GetMapping("space")
|
||||
@ApiOperation("邮箱服务器空间")
|
||||
public Result space(@RequestParam("emailId") String emailId){
|
||||
HashMap<String, String> map = MapUtil.newHashMap();
|
||||
map.put("total","500G");
|
||||
map.put("residue","300G");
|
||||
map.put("usage","74.3%");
|
||||
return Result.OK(map);
|
||||
public Result<?> space(@RequestParam("emailId") String emailId){
|
||||
return Result.OK(sysEmailLogService.space(emailId));
|
||||
}
|
||||
|
||||
@GetMapping("total")
|
||||
@ApiOperation("今天|昨天|过去一周邮件量")
|
||||
public Result totalEmail(@RequestParam("emailId") String emailId){
|
||||
public Result<?> totalEmail(@RequestParam("emailId") String emailId){
|
||||
return sysEmailLogService.totalEmail(emailId);
|
||||
}
|
||||
|
||||
@GetMapping("today")
|
||||
@ApiOperation("今日邮件接收量")
|
||||
public Result today(@RequestParam("emailId") String emailId){
|
||||
public Result<?> today(@RequestParam("emailId") String emailId){
|
||||
return sysEmailLogService.todayMin(emailId);
|
||||
}
|
||||
|
||||
@GetMapping("analysis")
|
||||
@ApiOperation("根据日期统计-折线图")
|
||||
public Result analysis(@RequestParam("emailId") String emailId,
|
||||
public Result<?> analysis(@RequestParam("emailId") String emailId,
|
||||
@RequestParam("startDate") String startDate,
|
||||
@RequestParam("endDate") String endDate){
|
||||
return sysEmailLogService.analysis(emailId, startDate, endDate);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.jeecg.modules.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.base.dto.EmailDto;
|
||||
import org.jeecg.modules.base.dto.IdCount;
|
||||
|
@ -9,7 +10,7 @@ import org.jeecg.modules.entity.AlarmHistory;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface SysEmailMapper extends BaseMapper<SysEmail> {
|
||||
|
||||
List<AlarmHistory> findAlarmHistory(Map<String,Object> params);
|
||||
|
|
|
@ -13,15 +13,11 @@ public class InstanceSDK {
|
|||
|
||||
public static QiyeOpenPlatSDK getInstance() {
|
||||
//init
|
||||
//Environment env = SpringContextUtils.getBean(Environment.class);
|
||||
/*String appId = env.getProperty("qiyeEmail.appId");
|
||||
Environment env = SpringContextUtils.getBean(Environment.class);
|
||||
String appId = env.getProperty("qiyeEmail.appId");
|
||||
String orgOpenId = env.getProperty("qiyeEmail.orgOpenId");
|
||||
String authCode = env.getProperty("qiyeEmail.authCode");
|
||||
String urlPrefix = env.getProperty("qiyeEmail.urlPrefix");*/
|
||||
String appId = "qy20231114144636B85B";
|
||||
String orgOpenId = "9c96b0ec1e6be89a";
|
||||
String authCode = "O1eSXJwU";
|
||||
String urlPrefix = "https://api.qiye.163.com";
|
||||
String urlPrefix = env.getProperty("qiyeEmail.urlPrefix");
|
||||
|
||||
QiyeOpenPlatSDKConfig qiyeOpenPlatSDKConfig = QiyeOpenPlatSDKConfig.builder()
|
||||
//应用ID
|
||||
|
|
|
@ -22,20 +22,15 @@ public class Account {
|
|||
Q reqParam = Q.init(rParam);
|
||||
R result = platSDK.commonInvoke(reqParam, AccountAPI.ACCOUNTINFO);
|
||||
String responseText = result.getResponseText();
|
||||
AccountInfo accountInfo = new AccountInfo();
|
||||
try {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
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) {
|
||||
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.modules.base.entity.postgre.SysEmailLog;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
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.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 com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.DateConstant;
|
||||
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.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.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
|
@ -26,6 +37,9 @@ import java.util.stream.IntStream;
|
|||
@Service("sysEmailLogService")
|
||||
public class SysEmailLogServiceImpl extends ServiceImpl<SysEmailLogMapper, SysEmailLog> implements ISysEmailLogService {
|
||||
|
||||
@Autowired
|
||||
private SysEmailMapper sysEmailMapper;
|
||||
|
||||
@Override
|
||||
public Result<?> totalEmail(String emailId) {
|
||||
// 当日邮件量
|
||||
|
@ -59,6 +73,37 @@ public class SysEmailLogServiceImpl extends ServiceImpl<SysEmailLogMapper, SysEm
|
|||
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
|
||||
public Result<?> todayHour(String emailId) {
|
||||
LambdaQueryWrapper<SysEmailLog> wrapper = new LambdaQueryWrapper<>();
|
||||
|
|
|
@ -196,38 +196,4 @@ public class SysEmailServiceImpl extends ServiceImpl<SysEmailMapper, SysEmail> i
|
|||
}
|
||||
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>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<!--以下配置用于在打包时添加自己引入的<scope>system</scope>-->
|
||||
<configuration>
|
||||
<includeSystemScope>true</includeSystemScope>
|
||||
</configuration>
|
||||
<!--<configuration>
|
||||
<layout>ZIP</layout>
|
||||
<includes>
|
||||
|
|
Loading…
Reference in New Issue
Block a user