This commit is contained in:
2024-08-26 11:05:19 +08:00
70 changed files with 10006 additions and 6241 deletions
@@ -1,11 +1,13 @@
package com.fangjia.bkoff.controllers;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.util.DateUtils;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.fangjia.bkoff.model.ApiUserModel;
import com.fangjia.bkoff.model.JsonModel;
import com.fangjia.core.util.BeanUtils;
import com.fangjia.core.util.DataUtil;
import com.fangjia.core.util.DateUtil;
import com.fangjia.core.util.StringUtil;
import com.fangjia.core.util.*;
import com.fangjia.dal.QueryParam;
import com.fangjia.dal.mongo.fangjia.model.ServerArea;
import com.fangjia.dal.mongo.model.ApiInvokeStatistical;
import com.fangjia.dal.mongo.model.ApiUserCfg;
@@ -27,23 +29,33 @@ import com.fangjia.service.sql.UserService;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.bson.types.ObjectId;
import org.json.JSONArray;
import org.sothis.core.util.CollectionUtils;
import org.sothis.web.mvc.ActionContext;
import org.sothis.web.mvc.annotation.Param;
import scala.Int;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* api用户开通等管理controller
*
@@ -62,7 +74,6 @@ public class ApiUserController {
private ApiVisitCountService apiVisitCountService;
private ApiCountCityService apiCountCityService;
/**
* 所有api用户的信息展示
*
@@ -78,7 +89,21 @@ public class ApiUserController {
* @param ApiUser
* :用户的appKey username、等资料
*/
List<ApiUser> apiUsers = this.apiUserService.findApiUsersByParamsSortDate(null);
ArrayList<QueryParam> queryParams = new ArrayList<QueryParam>();
if (model.getStatus() != null) {
queryParams.add(new QueryParam("status", model.getStatus()));
}else {
queryParams.add(new QueryParam("status",0));
}
if (model.getIsTest()!=null){
queryParams.add(new QueryParam("isTest",model.getIsTest()));
}else {
queryParams.add(new QueryParam("isTest",0));
}
if (model.getPurpose()!=null){
queryParams.add(new QueryParam("purpose",model.getPurpose()));
}
List<ApiUser> apiUsers = this.apiUserService.findApiUsersByParamsSortDate(queryParams);
List<ApiUserBo> apiUserBoList = new ArrayList<ApiUserBo>();
for (ApiUser apiUser : apiUsers) {
User user = this.userService.findById(apiUser.getId());
@@ -184,6 +209,8 @@ public class ApiUserController {
apiUser.setDeadTime(model.getDeadTime());
apiUser.setManager(model.getManager());
apiUser.setIsMonitor(model.getIsMonitor());
apiUser.setContact(model.getContact());
apiUser.setPhone(model.getPhone());
this.apiUserService.save(apiUser);
// 新增用户,默认挂牌价改为默认评估价
model.setPriceType("evaluate");
@@ -227,6 +254,8 @@ public class ApiUserController {
bo.setDeadTime(apiUser.getDeadTime());
bo.setManager(apiUser.getManager());
bo.setIsMonitor(apiUser.getIsMonitor());
bo.setContact(apiUser.getContact());
bo.setPhone(apiUser.getPhone());
ApiUserCfg apiUserCfg_rate = apiUserCfgService.findByUserId(apiUser.getId(), ApiUserCfg.ApiUserCfgKey.EVALUATE_RATE);
if (apiUserCfg_rate != null) {
bo.setEvaluateRate((Double) apiUserCfg_rate.getCfgValue());
@@ -280,6 +309,8 @@ public class ApiUserController {
dataApiUser.put("deadTime", model.getDeadTime());
dataApiUser.put("manager", model.getManager());
dataApiUser.put("isMonitor", model.getIsMonitor());
dataApiUser.put("contact", model.getContact());
dataApiUser.put("phone", model.getPhone());
this.apiUserService.update(dataApiUser, userId);
// 更改用户密码
// this.userService.updateById(user,userId);
@@ -303,14 +334,15 @@ public class ApiUserController {
user.put("password", DigestUtils.md5Hex(model.getPassword()));
//
// // 更改用户密码
this.userService.updateById(user,userId);
this.userService.updateById(user, userId);
// 刷新缓存
this.apiUserService.clearApiUserAuthorityCache(userId);
model.setViewType("redirect");
model.setViewParam("location", "/apiUser/edit?userId="+userId);
model.setViewParam("location", "/apiUser/edit?userId=" + userId);
return model;
}
public Object editPwdAction(ApiUserModel model) {
Long userId = model.getUserId();
User user = this.userService.findById(userId);
@@ -975,7 +1007,21 @@ public class ApiUserController {
} else {
cities = new ArrayList<String>();
}
List<OpenUriAnaly> analys = openUriAnalyService.findOpenUriAnalyLogs(model.getUserId(), null, startDate, endDate);
// 只查询正式账号
List<QueryParam> queryParams = Arrays.asList(new QueryParam("isTest", 0));
List<ApiUser> apiUsers = this.apiUserService.findApiUsersByParamsSortDate(queryParams);
// 获取正式账号的ids
List<Integer> ids = new ArrayList<Integer>();
for (ApiUser apiUser : apiUsers) {
ids.add((int) apiUser.getId());
}
List<OpenUriAnaly> analyAll = openUriAnalyService.findOpenUriAnalyLogs(model.getUserId(), null, startDate, endDate);
List<OpenUriAnaly> analys = new ArrayList<OpenUriAnaly>();
for (OpenUriAnaly analy : analyAll) {
if (ids.contains(analy.getApiUserId())) {
analys.add(analy);
}
}
List<StatAnalyBo> bos = null;
List<EachCityBo> eachCityBos = null;
if (model.getWay() == null) {
@@ -1016,9 +1062,7 @@ public class ApiUserController {
}
}
}
List<Long> userIds = new ArrayList<Long>();
for (StatAnalyBo boTemp : bos) {
userIds.add(Long.valueOf(boTemp.getUserId()));
List<ApiVisitCount> apiVisitCounts = apiVisitCountService.findAllApiVisitCount(Long.valueOf(boTemp.getUserId()), null, startDate, endDate);
int total = 0;
for (ApiVisitCount apiVisitCount : apiVisitCounts) {
@@ -1027,7 +1071,6 @@ public class ApiUserController {
boTemp.setBillingCount(total);
}
List<ApiUser> apiUsers = apiUserService.findApiUserByIds(userIds);
Map<Long, ApiUser> idUserMap = new HashMap<Long, ApiUser>();
for (ApiUser apiUser : apiUsers) {
idUserMap.put(apiUser.getId(), apiUser);
@@ -1051,8 +1094,234 @@ public class ApiUserController {
return model;
}
public Object exportAction(ApiUserModel model, HttpServletResponse response) throws IllegalAccessException {
Date startDate = null;
Date endDate = null;
if (StringUtils.isBlank(model.getBegDate()) && StringUtils.isBlank(model.getEndDate())) {
startDate = DateUtil.add(DateUtil.formatToYYYYMMDD(new Date()), -7);
endDate = DateUtil.parseStringToDate(DateUtil.formatToYYYYMMDD(new Date()));
} else {
if (StringUtils.isNotBlank(model.getBegDate())) {
startDate = DateUtil.parseStringToDate(model.getBegDate());
}
if (StringUtils.isNotBlank(model.getEndDate())) {
endDate = DateUtil.parseStringToDate(model.getEndDate());
}
public Object userVisitStatAction(ApiUserModel model) {
}
if (startDate != null) {
model.setBegDate(DateUtil.formatToYYYYMMDD(startDate));
}
if (endDate != null) {
model.setEndDate(DateUtil.formatToYYYYMMDD(endDate));
}
Date nowDate = DateUtil.parseStringToDate(DateUtil.formatToYYYYMMDD(new Date()));
Date lastWeek = DateUtil.add(DateUtil.formatToYYYYMMDD(new Date()), -7);
Date lastMonth = DateUtil.add(DateUtil.formatToYYYYMMDD(new Date()), -30);
long diffInMillies = Math.abs(endDate.getTime() - startDate.getTime());
// 将毫秒转换为天数
long days = diffInMillies / (1000 * 60 * 60 * 24); // 使用long来计算天数
// 只查询正式账号、未过期、未禁用
List<QueryParam> queryParams = Arrays.asList(new QueryParam("isTest", 0),
new QueryParam("status", 0),
new QueryParam("deadTime", QueryParam.GREATER_THAN_EQUAL_OPERATOR, new Date()));
List<ApiUser> apiUsers = this.apiUserService.findApiUsersByParamsSortDate(queryParams);
//所有API
List<OpenResource> allApi = openResourceService.findAll();
// 所有API的URI与name对应Map
Map<String, String> apiMap = converMapData(allApi);
List<StatAnalyBo> bosAll = new ArrayList<StatAnalyBo>();
if (CollectionUtils.isNotEmpty(apiUsers)) {
// 根据访问遍历用户
for (ApiUser apiUser : apiUsers) {
long id = apiUser.getId();
// 获取每个用户的访问
ApiUserAuthority authority = apiUserAuthorityService.findByUserId(id);
// 用户有的api
List<String> userApi = authority.getOpenResourseUris();
Map<String, Integer> countMap = authority.getTotalCountMap();
// 获取用户名
User user = userService.findById(id);
long date = DateUtil.parseStringToDate("2016-11-23").getTime();
if (startDate.getTime() >= date && endDate.getTime() > date) {
List<ApiInvokeStatistical> apiInvokeStatisticalList = apiInvokeStatisticalService.findApiInvokeStatisticalList(id, startDate, endDate);
List<ApiInvokeStatistical> weekApiInvokeStatisticalList;
if (lastWeek == startDate && nowDate == endDate) {
weekApiInvokeStatisticalList = apiInvokeStatisticalList;
} else {
weekApiInvokeStatisticalList = apiInvokeStatisticalService.findApiInvokeStatisticalList(id, lastWeek, nowDate);
}
List<ApiInvokeStatistical> monthApiInvokeStatisticalList;
if (lastMonth == startDate && nowDate == endDate) {
monthApiInvokeStatisticalList = apiInvokeStatisticalList;
} else {
monthApiInvokeStatisticalList = apiInvokeStatisticalService.findApiInvokeStatisticalList(id, lastMonth, nowDate);
}
Map<String, Map<String, Integer>> resultMap = getCountByUri(apiInvokeStatisticalList);
Map<String, Map<String, Integer>> weekResultMap = getCountByUri(weekApiInvokeStatisticalList);
Map<String, Map<String, Integer>> monthResultMap = getCountByUri(monthApiInvokeStatisticalList);
// 遍历用户所有的api
for (String url : userApi) {
// 统计用过的api
String urlName = apiMap.get(url);
StatAnalyBo bo = new StatAnalyBo();
if (resultMap.containsKey(url)) {
// 自定义时间的数据
bo.setSuccessEffectiveTime(resultMap.get(url).get("successEffectiveCount"));
bo.setSuccessInvalidTime(resultMap.get(url).get("successInvalidCount"));
bo.setDefeatTime(resultMap.get(url).get("defeatCount"));
bo.setCount(resultMap.get(url).get("totalCount"));
double dailyUse = bo.getCount() * 1.0 / days;
bo.setDailyUse(dailyUse);
}
if (weekResultMap.containsKey(url)) {
// 近一周数据
bo.setWeekSuccessEffectiveTime(weekResultMap.get(url).get("successEffectiveCount"));
bo.setWeekSuccessInvalidTime(weekResultMap.get(url).get("successInvalidCount"));
bo.setWeekDefeatTime(weekResultMap.get(url).get("defeatCount"));
bo.setWeekCount(weekResultMap.get(url).get("totalCount"));
double dailyUse = bo.getWeekCount() * 1.0 / 7;
bo.setWeekDailyUse(dailyUse);
}
if (monthResultMap.containsKey(url)) {
// 成功有效次数
bo.setMonthSuccessEffectiveTime(monthResultMap.get(url).get("successEffectiveCount"));
// 成功无效次数
bo.setMonthSuccessInvalidTime(monthResultMap.get(url).get("successInvalidCount"));
// 失败次数
bo.setMonthDefeatTime(monthResultMap.get(url).get("defeatCount"));
bo.setMonthCount(monthResultMap.get(url).get("totalCount"));
double dailyUse = bo.getMonthCount() * 1.0 / 30;
bo.setMonthDailyUse(dailyUse);
}
bo.setUrl(url);
bo.setUrlName(urlName);
bo.setDeadline(apiUser.getDeadTime());
bo.setUserId((int) id);
bo.setUserName(user.getDisplayName());
//剩余调用量
long curVistedCount = apiVisitCountService.findApiVisitCountByDay(id, url, DateUtil.truncateDay(new Date()));
long historyCount = apiVisitCountService.findApiVisitAllCount(id, url, DateUtil.truncateDay(new Date()));
if (countMap != null && countMap.containsKey(url)) {
Integer totalCount = countMap.get(url);
long usedCount = curVistedCount + historyCount;
bo.setSurplusCallCount(Integer.valueOf((int) (totalCount - usedCount)));
}
bosAll.add(bo);
}
}
}
this.buildReport(bosAll, response, startDate, endDate);
}
model.setViewType("stream");
return model;
}
private void buildReport(List<StatAnalyBo> bos, HttpServletResponse response, Date startDate, Date endDate) {
try {
List<List<String>> dataList = new ArrayList<List<String>>();
for (StatAnalyBo bo : bos) {
List<String> row = new ArrayList<String>();
row.add(bo.getUserId() != null ? bo.getUserId().toString() : "");
row.add(bo.getUserName() != null ? bo.getUserName().toString() : "");
row.add(bo.getDeadline() != null ? DateUtils.format(bo.getDeadline(), "yyyy/MM/dd") : "");
row.add(bo.getUrl() != null ? bo.getUrl().toString() : "");
row.add(bo.getUrlName() != null ? bo.getUrlName().toString() : "");
row.add(bo.getSurplusCallCount() != null ? bo.getSurplusCallCount().toString() : "");
// 上周
row.add(bo.getWeekCount() != null ? bo.getWeekCount().toString() : "");
if (bo.getWeekDailyUse() != null) {
// 格式化为保留一位小数的字符串
String formattedDailyUse = String.format("%.1f", bo.getWeekDailyUse());
row.add(formattedDailyUse);
} else {
row.add("");
}
row.add(bo.getWeekSuccessEffectiveTime() != null ? bo.getWeekSuccessEffectiveTime().toString() : "");
row.add(bo.getWeekSuccessInvalidTime() != null ? bo.getWeekSuccessInvalidTime().toString() : "");
row.add(bo.getWeekDefeatTime() != null ? bo.getWeekDefeatTime().toString() : "");
// 上个月
row.add(bo.getMonthCount() != null ? bo.getMonthCount().toString() : "");
if (bo.getMonthDailyUse() != null) {
// 格式化为保留一位小数的字符串
String formattedDailyUse = String.format("%.1f", bo.getMonthDailyUse());
row.add(formattedDailyUse);
} else {
row.add("");
}
row.add(bo.getMonthSuccessEffectiveTime() != null ? bo.getMonthSuccessEffectiveTime().toString() : "");
row.add(bo.getMonthSuccessInvalidTime() != null ? bo.getMonthSuccessInvalidTime().toString() : "");
row.add(bo.getMonthDefeatTime() != null ? bo.getMonthDefeatTime().toString() : "");
// 自定义时间
row.add(bo.getCount() != null ? bo.getCount().toString() : "");
if (bo.getDailyUse() != null) {
// 格式化为保留一位小数的字符串
String formattedDailyUse = String.format("%.1f", bo.getDailyUse());
row.add(formattedDailyUse);
} else {
row.add("");
}
row.add(bo.getSuccessEffectiveTime() != null ? bo.getSuccessEffectiveTime().toString() : "");
row.add(bo.getSuccessInvalidTime() != null ? bo.getSuccessInvalidTime().toString() : "");
row.add(bo.getDefeatTime() != null ? bo.getDefeatTime().toString() : "");
dataList.add(row);
}
String dateStr = "(" + DateUtils.format(startDate, "yyyy/MM/dd") + "—" + DateUtils.format(endDate, "yyyy/MM/dd") + ")";
String fileName = "用户账号使用统计" + dateStr + ".xlsx";
// ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).build();
String displayName = URLEncoder.encode(fileName, "UTF-8");
response.setHeader("Content-Disposition", "attachment; filename=\"" + displayName + "\"");
response.setContentType("application/x-download;charset=utf-8");
Workbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet("用户账号使用统计");
List<String> head = Arrays.asList(
"用户ID", "账号", "合同到期时间", "接口", "接口名称", "剩余使用次数",
"访问次数(近一周)", "日均访问量(近一周)", "成功并有效(近一周)", "成功并无效(近一周)", "失败次数(近一周)",
"访问次数(近一月)", "日均访问量(近一月)", "成功并有效(近一月)", "成功并无效(近一月)", "失败次数(近一月)",
"访问次数" + dateStr, "日均访问量" + dateStr, "成功并有效" + dateStr, "成功并无效" + dateStr, "失败次数" + dateStr
);
// 创建表头
Row headRow = sheet.createRow(0);
for (int i = 0; i < head.size(); i++) {
Cell cell = headRow.createCell(i);
cell.setCellValue(head.get(i));
}
// 写入数据,从第二行
for (int i = 0; i < dataList.size(); i++) {
Row row = sheet.createRow(i + 1);
List<String> data = dataList.get(i);
for (int j = 0; j < data.size(); j++) {
Cell cell = row.createCell(j);
cell.setCellValue(data.get(j));
}
}
ServletOutputStream outputStream = response.getOutputStream();
workbook.write(outputStream);
} catch (IOException e) {
}
}
List<List<String>> formatHead(String[] headArr) {
List<List<String>> head = new ArrayList<List<String>>();
for (String name : headArr) {
List<String> temp = new ArrayList<String>();
temp.add(name);
head.add(temp);
}
return head;
}
public Object userVisitStatAction(ApiUserModel model) throws IllegalAccessException {
Date startDate = null;
Date endDate = null;
if (StringUtils.isNotBlank(model.getBegDate())) {
@@ -1075,8 +1344,12 @@ public class ApiUserController {
// bos = createAnalyBosByUser(analys);
// model.setChartSeries(toChartString(bos));
// }else if(model.getWay() == 2){
Long userId = model.getUserId();
ApiUserAuthority authority = apiUserAuthorityService.findByUserId(userId);
Map<String, Integer> countMap = authority.getTotalCountMap();
ApiUser apiUser = apiUserService.findApiUserById(userId);
if (model.getWay() == 2) {
User user = userService.findById(model.getUserId());
User user = userService.findById(userId);
if (user != null) {
model.setUserName(user.getDisplayName());
}
@@ -1120,6 +1393,16 @@ public class ApiUserController {
boTemp.setSuccessEffectiveTime(resultMap.get(url).get("successEffectiveCount"));
boTemp.setSuccessInvalidTime(resultMap.get(url).get("successInvalidCount"));
boTemp.setDefeatTime(resultMap.get(url).get("defeatCount"));
if (apiUser != null) {
boTemp.setDeadline(apiUser.getDeadTime());
}
long curVistedCount = apiVisitCountService.findApiVisitCountByDay(userId, url, DateUtil.truncateDay(new Date()));
long historyCount = apiVisitCountService.findApiVisitAllCount(userId, url, DateUtil.truncateDay(new Date()));
if (countMap != null && countMap.containsKey(url)) {
Integer totalCount = countMap.get(url);
long usedCount = curVistedCount + historyCount;
boTemp.setSurplusCallCount(Integer.valueOf((int) (totalCount - usedCount)));
}
}
}
}
@@ -1625,6 +1908,7 @@ public class ApiUserController {
Integer successEffectiveCount = detailMap.get("successEffectiveCount");
Integer successInvalidCount = detailMap.get("successInvalidCount");
Integer defeatCount = detailMap.get("defeatCount");
Integer totalCount = detailMap.get("totalCount");
if (successEffectiveCount != null) {
successEffectiveCount = successEffectiveCount + apiInvokeStatistical.getSuccessEffectiveTime();
} else {
@@ -1641,10 +1925,16 @@ public class ApiUserController {
} else {
defeatCount = apiInvokeStatistical.getDefeatTime();
}
if (totalCount != null) {
totalCount = totalCount + apiInvokeStatistical.getTotalTime();
} else {
totalCount = apiInvokeStatistical.getTotalTime();
}
detailMap.put("successEffectiveCount", successEffectiveCount);
detailMap.put("successInvalidCount", successInvalidCount);
detailMap.put("defeatCount", defeatCount);
detailMap.put("totalCount", totalCount);
}
return resultMap;
@@ -40,6 +40,10 @@ public class ApiUserModel extends BaseModel {
private Map<String,Double> priceRatingMap;
private Integer isMonitor;
private String contact;
private String phone;
public String getPriceType() {
return priceType;
}
@@ -70,7 +74,7 @@ public class ApiUserModel extends BaseModel {
private String type;
private String citys;// spell
private String unCheckCitys;// 页面反选的city
private int status;
private Integer status;
private String uri;
private boolean hasAuth;
private boolean supportLatLng;
@@ -378,15 +382,15 @@ public class ApiUserModel extends BaseModel {
this.limit = limit;
}
public int getStatus() {
public Integer getStatus() {
return status;
}
public void setStatus(int status) {
public void setStatus(Integer status) {
this.status = status;
}
public String getCompany() {
public String getCompany() {
return company;
}
@@ -615,4 +619,20 @@ public class ApiUserModel extends BaseModel {
public void setIsMonitor(Integer isMonitor) {
this.isMonitor = isMonitor;
}
public String getContact() {
return contact;
}
public void setContact(String contact) {
this.contact = contact;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
}
@@ -34,12 +34,12 @@
<form id="addForm" action="doAdd" method="post">
<tr>
<td><b>昵称</b></td>
<td><input name="displayName" value="${displayName!}"/></td>
<td><input id="displayName" name="displayName" placeholder="必填项" value="${displayName!}"/></td>
</tr>
<tr>
<td><b>用户名</b></td>
<input name="userId" value="${userId!}" type="hidden"/>
<td><input id="userName" name="userName" value="${userName!}"/></td>
<td><input id="userName" name="userName" placeholder="必填项" value="${userName!}"/></td>
</tr>
<tr>
<td><b>密码</b></td>
@@ -51,6 +51,7 @@
<select name="isTest">
<option value="0">正式账户</option>
<option value="1">测试账户</option>
<option value="2">内部账户</option>
</select>
</td>
</tr>
@@ -58,7 +59,7 @@
<td>账户用途</td>
<td>
<select name="purpose">
<option value="">请选择</option>
<#-- <option value="">请选择</option>-->
<option value="1">API</option>
<option value="2">PDS</option>
<option value="4">房生活</option>
@@ -74,15 +75,15 @@
</tr>
<tr>
<td>Email</td>
<td><input name="email" value="${email!}"/></td>
<td><input id="email" name="email" placeholder="必填项" value="${email!}"/></td>
</tr>
<tr>
<td>销售负责人</td>
<td><input name="manager" value="${manager!}"/></td>
<td><input id="manager" name="manager" placeholder="必填项" value="${manager!}"/></td>
</tr>
<tr>
<td>公司</td>
<td><input name="company" value="${company!}"/></td>
<td><input id="company" name="company" placeholder="必填项" value="${company!}"/></td>
</tr>
<tr>
<td>估价调整比率</td>
@@ -91,13 +92,21 @@
</tr>
<tr>
<td>siteName</td>
<td><input name="siteName" value="${siteName!}"/></td>
<td><input name="siteName" value="${siteName!}"/></td>
</tr>
<tr>
<td>到期时间</td>
<td><input name="deadTime"
<td><input name="deadTime" id="deadTime" placeholder="必填项"
onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'%y-%M-{%d+7}'})"/></td>
</tr>
<tr>
<td>客户联系人</td>
<td><input id="contact" name="contact" placeholder="必填项" value="${contact!}"/></td>
</tr>
<tr>
<td>客户联系人电话</td>
<td><input id="phone" name="phone" placeholder="必填项" value="${phone!}"/></td>
</tr>
<tr>
<td>ip地址</td>
<td><textarea id="ip" name="ip" rows="5" cols="12"
@@ -124,6 +133,57 @@
return false
}
}
// 检查其他字段是否为空
var displayName = $.trim($("#displayName").val());
var userName = $.trim($("#userName").val());
var password = $.trim($("#password").val());
var email = $.trim($("#email").val());
var manager = $.trim($("#manager").val());
var company = $.trim($("#company").val());
var deadTime = $.trim($("#deadTime").val());
var contact = $.trim($("#contact").val());
var phone = $.trim($("#phone").val());
if (displayName === '') {
alert("昵称不能为空!");
return false;
}
if (userName === '') {
alert("用户名不能为空!");
return false;
}
if (password === '') {
alert("密码不能为空!");
return false;
}
if (email === '') {
alert("邮箱不能为空!");
return false;
}
if (manager === '') {
alert("销售负责人不能为空!");
return false;
}
if (company === '') {
alert("公司不能为空!");
return false;
}
if (deadTime === '') {
alert("到期时间不能为空!");
return false;
}
if (contact === '') {
alert("客户联系人不能为空!");
return false;
}
if (phone === '') {
alert("客户联系人电话不能为空!");
return false;
}
if (email === '') {
alert("邮箱不能为空!");
return false;
}
if (_userNameCheck) {
$("#addForm").submit();
}
@@ -12,9 +12,9 @@
<link rel="stylesheet" type="text/css" href="../style/main.css?v=${version}" />
<script type="text/javascript" src="../js/My97DatePicker/WdatePicker.js"></script>
<style>
label{display:inline-block}
.main-content {
padding-bottom: 0;
}
@@ -47,28 +47,51 @@
</span>
</div>
<form action="<#if way?? && way==0>../apiUser/pandect<#else>../apiUser/apiVisitStat</#if>" method="post">
<input type="hidden" name="way" value="${way!}"/>
<#if way!=3>
<label for="districtName" style="margin-left: 15px;">用户ID:</label>
<input type="text" name="userId" value="${userId!}" class="input-medium" style="margin-top:9px;" ></input>
<#else>
<label for="districtName" style="margin-left: 15px;">城市:</label>
<input type="text" class="input-medium" readonly="readonly" id="city" name="citys" value="${citys!}"/><input type="button" class="input-medium" id="butt" value="选择城市"/>
</#if>
<label for="startDate">&nbsp;&nbsp;&nbsp;&nbsp;日期:</label>
<input placeholder="开始时间" class="form-control" style="width:140px;" name="begDate" id="begDate" value="<#if begDate??>${begDate}</#if>" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" />-
<input id="endDate" placeholder="结束时间" class="form-control" style="width:140px;" name="endDate" value="${endDate!}" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"/>
<form id="myForm" action="<#if way?? && way==0>../apiUser/pandect<#else>../apiUser/apiVisitStat</#if>" method="post">
<input type="hidden" name="way" value="${way!}"/>
<input id="queryBtn" class ="btn btn-primary" type="submit" value="查询" />
<#if way!=3>
<label for="districtName" style="margin-left: 15px;">用户ID:</label>
<input type="text" name="userId" value="${userId!}" class="input-medium" style="margin-top:9px;" />
<#else>
<label for="districtName" style="margin-left: 15px;">城市:</label>
<input type="text" class="input-medium" readonly="readonly" id="city" name="citys" value="${citys!}"/>
<input type="button" class="input-medium" id="butt" value="选择城市"/>
</#if>
<#if way!=3>
<label for="">(备注:成功有效、成功无效、失败的次数统计从2016-11-23开始)</label>
</#if>
</form>
<label for="startDate">&nbsp;&nbsp;&nbsp;&nbsp;日期:</label>
<!-- 下拉菜单选择最近一周、最近一月或自定义 -->
<select id="dateRange" class="form-control" style="width:160px;" onchange="updateDateRange(this.value)">
<option value="custom">自定义</option>
<option value="lastWeek">最近一周</option>
<option value="lastMonth">最近一月</option>
</select>
<!-- 自定义日期输入框 -->
<input placeholder="开始时间" class="form-control" style="width:140px;" name="begDate" id="begDate"
value="<#if begDate??>${begDate}</#if>"
onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" />
-
<input id="endDate" placeholder="结束时间" class="form-control" style="width:140px;" name="endDate"
value="${endDate!}"
onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" />
<!-- 查询按钮 -->
<input id="queryBtn" class="btn btn-primary" type="submit" value="查询" onclick="submitForm('query')" />
<!-- 下载按钮 -->
<input id="downloadBtn" class="btn btn-secondary" type="submit" value="导出" onclick="submitForm('download')" />
<#if way!=3>
<label for="">(备注:成功有效、成功无效、失败的次数统计从2016-11-23开始)</label>
</#if>
</form>
<#--<input id="expect" class ="btn btn-primary" type="submit" value="导出" />-->
<a class="btn common_btn" href="importExcel?city=${citys!}&begDate=${begDate!}&endDate=${endDate!}">导出</a>
<#-- <a class="btn common_btn" href="importExcel?city=${citys!}&begDate=${begDate!}&endDate=${endDate!}">导出</a>-->
<div id="isHide" style="display: none">
<ul>
@@ -544,7 +567,7 @@
</tr>
</thead>
<tbody>
<#if statAnalyBoList??>
<#if statAnalyBoList??>
<#list statAnalyBoList as bo>
<tr>
<#if way?? && way==1>
@@ -591,7 +614,7 @@
<#else>
<tr><td ></td></tr>
</#if>
</tbody>
</table>
<div class="tabbable" style="padding-top: 60px;">
@@ -643,7 +666,7 @@
$("#statBut3").removeClass("cur");
});
$("#statBut2").click(function(){
this.addClass("cur");
$("#statBut1").removeClass("cur");
@@ -697,8 +720,8 @@
}
})
});
$(function () {
$('#container').highcharts({
@@ -734,8 +757,46 @@
});
});
</script>
function updateDateRange(option) {
const now = new Date();
const begDateInput = document.getElementById('begDate');
const endDateInput = document.getElementById('endDate');
if (option === 'lastWeek') {
const lastWeek = new Date();
lastWeek.setDate(now.getDate() - 7);
begDateInput.value = formatDate(lastWeek);
endDateInput.value = formatDate(now);
} else if (option === 'lastMonth') {
const lastMonth = new Date();
lastMonth.setMonth(now.getMonth() - 1);
begDateInput.value = formatDate(lastMonth);
endDateInput.value = formatDate(now);
} else {
begDateInput.value = '';
endDateInput.value = '';
}
}
function formatDate(date) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
return year + '-' + month + '-' + day;
}
function submitForm(action) {
const form = document.getElementById('myForm');
if (action === 'query') {
debugger
form.action = "<#if way?? && way==0>../apiUser/pandect<#else>../apiUser/apiVisitStat</#if>";
} else if (action === 'download') {
form.action = "../apiUser/export";
}
form.submit();
}
</script>
</body>
</html>
</#compress>
@@ -61,12 +61,18 @@
<td>账户类型</td>
<td>
<select name="isTest">
<#if apiUserBo.isTest==0>
<#if apiUserBo.isTest == 0>
<option value="0" selected="selected">正式账户</option>
<option value="1">测试账户</option>
<#else>
<option value="0"> 正式账户</option>
<option value="2">内部账户</option>
<#elseif apiUserBo.isTest == 1>
<option value="0">正式账户</option>
<option value="1" selected="selected">测试账户</option>
<option value="2">内部账户</option>
<#else>
<option value="0">正式账户</option>
<option value="1">测试账户</option>
<option value="2" selected="selected">内部账户</option>
</#if>
</select>
</td>
@@ -91,15 +97,15 @@
</tr>
<tr>
<td>Email</td>
<td><input name="email" value="${apiUserBo.email!}"/></td>
<td><input id="email" name="email" placeholder="必填项" value="${apiUserBo.email!}"/></td>
</tr>
<tr>
<td>销售负责人</td>
<td><input name="manager" value="${apiUserBo.manager!}" /></td>
<td><input id="manager" name="manager" placeholder="必填项" value="${apiUserBo.manager!}" /></td>
</tr>
<tr>
<td>公司</td>
<td><input name="company" value="${apiUserBo.company!}"/></td>
<td><input id="company" name="company" placeholder="必填项" value="${apiUserBo.company!}"/></td>
</tr>
<tr>
<td>估价调整比率</td>
@@ -122,7 +128,15 @@
</tr>
<tr>
<td>到期时间</td>
<td><input name="deadTime" value="<#if apiUserBo.deadTime??>${apiUserBo.deadTime?string("yyyy-MM-dd")}</#if>" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"/></td>
<td><input id="deadTime" name="deadTime" placeholder="必填项" value="<#if apiUserBo.deadTime??>${apiUserBo.deadTime?string("yyyy-MM-dd")}</#if>" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"/></td>
</tr>
<tr>
<td>客户联系人</td>
<td><input id="contact" name="contact" placeholder="必填项" value="${apiUserBo.contact!}"/></td>
</tr>
<tr>
<td>客户联系人电话</td>
<td><input id="phone" name="phone" placeholder="必填项" value="${apiUserBo.phone!}"/></td>
</tr>
<tr>
<td>ip地址</td>
@@ -150,6 +164,42 @@
return false
}
}
// 检查其他字段是否为空
var email = $.trim($("#email").val());
var manager = $.trim($("#manager").val());
var company = $.trim($("#company").val());
var deadTime = $.trim($("#deadTime").val());
var contact = $.trim($("#contact").val());
var phone = $.trim($("#phone").val());
if (email === '') {
alert("邮箱不能为空!");
return false;
}
if (manager === '') {
alert("销售负责人不能为空!");
return false;
}
if (company === '') {
alert("公司不能为空!");
return false;
}
if (deadTime === '') {
alert("到期时间不能为空!");
return false;
}
if (contact === '') {
alert("客户联系人不能为空!");
return false;
}
if (phone === '') {
alert("客户联系人电话不能为空!");
return false;
}
if (email === '') {
alert("邮箱不能为空!");
return false;
}
$("#submitForm").attr("action", "update");
$("#submitForm").submit();
}
@@ -47,6 +47,35 @@
<div style="padding-left:5px;">
共有用户<b>${apiUserBoList?size}</b>个
</div>
<form action="../apiUser/list" id="_search_log_form">
<div>
<div class="form-group">
<label for="purpose" class="form-label">账号用途:</label>
<select name="purpose" class="form-select">
<option value="1">API</option>
<option value="2">PDS</option>
<option value="4">房生活</option>
<option >请选择</option>
</select>
</div>
<div class="form-group">
<label for="isTest" class="form-label">账号类型:</label>
<select name="isTest" class="form-select">
<option value="0">正式账号</option>
<option value="1">测试账号</option>
<option value="2">内部账号</option>
</select>
</div>
<div class="form-group">
<label for="status" class="form-label">账号状态:</label>
<select name="status" class="form-select">
<option value="0">正常</option>
<option value="1">禁用</option>
</select>
</div>
<input id="queryBtn" class="btn btn-primary form-button" type="submit" value="查询"/>
</div>
</form>
<table width="100%">
<thead>
<tr>
@@ -56,9 +85,9 @@
<th align="center" width="100px">
昵称
</th>
<th align="center" width="60px">
账户用途
</th>
<#-- <th align="center" width="60px">-->
<#-- 账户用途-->
<#-- </th>-->
<th align="center" width="100px">
username
</th>
@@ -100,15 +129,15 @@
<td align="center">
<a href="../apiUser/edit?userId=${bo.userId!}">${bo.displayName!}</a>
</td>
<td>
<#if bo.purpose?? && bo.purpose == 1>
API
<#elseif bo.purpose?? && bo.purpose == 2>
PDS
<#elseif bo.purpose?? && bo.purpose == 4>
房生活
</#if>
</td>
<#-- <td>-->
<#-- <#if bo.purpose?? && bo.purpose == 1>-->
<#-- API-->
<#-- <#elseif bo.purpose?? && bo.purpose == 2>-->
<#-- PDS-->
<#-- <#elseif bo.purpose?? && bo.purpose == 4>-->
<#-- 房生活-->
<#-- </#if>-->
<#-- </td>-->
<td align="center">
${bo.userName!}
</td>
@@ -131,8 +160,10 @@
<td align="center">
<#if bo.isTest==0>
正式账户
<#else>
<#elseif bo.isTest==1>
测试账户
<#else>
内部账户
</#if>
</td>
<td>
@@ -175,5 +206,23 @@
</div>
</div>
</body>
<style>
.form-label {
font-size: 15px; /* 增加标签的字体大小 */
}
.form-select {
font-size: 15px; /* 增加选择框的字体大小 */
margin-right: 10px; /* 调整选择框之间的间距 */
}
.form-button {
font-size: 15px; /* 增加按钮的字体大小 */
}
.form-group {
display: inline-block; /* 使每个表单组不换行 */
}
</style>
</html>
</#compress>
@@ -91,6 +91,12 @@ table tr th {
<#if query=="uri">URL<#elseif query=="day">日期<#else>访问时长</#if>
</#if>
</th>
<th width="9%" colspan="1">
剩余使用次数
</th>
<th width="9%" colspan="1">
合同到期时间
</th>
<th width="9%" colspan="1">
访问次数
</th>
@@ -145,6 +151,8 @@ table tr th {
</#if>
</#if>
</td>
<td width="9%"><#if bo.surplusCallCount??>${bo.surplusCallCount}</#if></td>
<td width="9%"><#if bo.deadline??>${bo.deadline?string("yyyy-MM-dd")}</#if></td>
<td width="9%">${bo.count}</td>
<td width="9%">${bo.percent}</td>
<#if way==2 && query=='uri'><td>${resourceMap[bo.key]!}</td></#if>