Commit 730e554e by java-lixy

1、添加记录举报人IP地址信息,并通过IP判断所属城市;

2、每页显示20条记录,并且序列号顺延(即每页不重新排号)
parent bd9261f5
......@@ -65,7 +65,7 @@ public class GConstants {
public static final String FILE_IMAGE_THUMBS = "thumbs";// 缩略图文件顶级路径名称 201605/thumbs/images/user/png/0d7ed36548c9ea6586363d4de5cb322c.png
public static final String FILE_IMAGE_ACTUALS = "actuals";// 原图文件顶级路径名称 201605/actuals/images/user/png/0d7ed36548c9ea6586363d4de5cb322c.png
public static final String PUSH_SERVER_URL = GConstants.getValue("push.server.url");// 推送服务器地址
public static final int PAGE_SIZE = GConstants.getIntValue("page.size", 10);// 默认分页条数,默认10条
public static final int PAGE_SIZE = GConstants.getIntValue("page.size", 20);// 默认分页条数,默认10条
public static final int MAX_UPLOAD_SIZE = GConstants.getIntValue("file.max.upload.size", 10485760);// 允许最多上传文件大小,默认10M
public static final String FAQ_BASE_API = GConstants.getValue("faq.base.api"); // 接口地址
public static final String ORG_DISPLAY_NAME = GConstants.getValue("user.office.name", "");// 登录区域
......
......@@ -3,7 +3,6 @@ package com.ejweb.modules.front.report.bean;
import com.ejweb.core.base.BaseBean;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
/**
......@@ -34,6 +33,8 @@ public class FrontReportBean extends BaseBean{
private String exchangeBeforeUser; //varchar(255) DEFAULT NULL COMMENT '移交/转交前用户id',
private String exchangeAfterUser; //varchar(255) DEFAULT NULL COMMENT '移交/转交后用户id(只记录最新的移交用户,此处不记录历史)',
private String oaName;
private String reportIp; //记录ip地址
private String ipCity; //ip地址对应城市
private String createBy; //创建人
private Timestamp createDate; //创建时间
private String updateBy; //更新人\
......@@ -292,4 +293,20 @@ public class FrontReportBean extends BaseBean{
public void setOaName(String oaName) {
this.oaName = oaName;
}
public String getReportIp() {
return reportIp;
}
public void setReportIp(String reportIp) {
this.reportIp = reportIp;
}
public String getIpCity() {
return ipCity;
}
public void setIpCity(String ipCity) {
this.ipCity = ipCity;
}
}
package com.ejweb.modules.front.report.entity;
public class IP2Regions {
private int ret;
private int start;
private int end;
private String country;
private String province;
private String city;
private String district;
private String isp;
private String type;
private String desc;
public int getRet() {
return ret;
}
public void setRet(int ret) {
this.ret = ret;
}
public int getStart() {
return start;
}
public void setStart(int start) {
this.start = start;
}
public int getEnd() {
return end;
}
public void setEnd(int end) {
this.end = end;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getProvince() {
return province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getDistrict() {
return district;
}
public void setDistrict(String district) {
this.district = district;
}
public String getIsp() {
return isp;
}
public void setIsp(String isp) {
this.isp = isp;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
package com.ejweb.modules.front.report.service;
import com.alibaba.fastjson.JSON;
import com.ejweb.conf.ErrorCode;
import com.ejweb.conf.GConstants;
import com.ejweb.core.api.ResponseBean;
import com.ejweb.core.service.CrudService;
import com.ejweb.core.utils.DateUtils;
import com.ejweb.core.utils.IdWorker;
import com.ejweb.core.utils.SpringContextHolder;
import com.ejweb.core.utils.StringUtils;
import com.ejweb.core.web.Servlets;
import com.ejweb.modules.front.report.bean.FrontReportBean;
import com.ejweb.modules.front.report.dao.FrontReportDao;
import com.ejweb.modules.front.report.entity.FrontReportEntity;
import com.ejweb.modules.front.sso.dao.SsoDao;
import com.ejweb.modules.front.report.entity.IP2Regions;
import com.ejweb.modules.front.report.utils.IpUtils;
import com.ejweb.modules.front.upload.util.ReportAttachmentUtils;
import com.ejweb.modules.sys.dao.SysUserDao;
import com.ejweb.modules.sys.entity.User;
import com.ejweb.modules.sys.utils.UserUtils;
import com.kingdee.eas.cp.eip.sso.ltpa.LtpaToken;
import com.kingdee.eas.cp.eip.sso.ltpa.LtpaTokenManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
......@@ -28,9 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.net.URLDecoder;
import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by lenovo on 2017/9/8.
......@@ -86,6 +84,18 @@ public class FrontReportService extends CrudService<FrontReportDao,FrontReportEn
Timestamp d = new Timestamp(System.currentTimeMillis());
bean.setCreateDate(d);
bean.setUpdateDate(d);
String ip = StringUtils.getRemoteAddr(Servlets.getRequest());
/** 根据ip获得城市 */
String url = "http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=" + ip;
String ipResult = IpUtils.getURLContent(url).replace(";", "");
if (ipResult != "-2") {
IP2Regions json = JSON.parseObject(ipResult.split("=")[1], IP2Regions.class);
String city = json.getCity();
bean.setIpCity(city);
}
bean.setReportIp(ip);
//
// bean.setExchangeBeforeUser("");
// 添加举报信息表
......
package com.ejweb.modules.front.report.utils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
public class IpUtils {
/**
* 访问url获得返回数据
*
* @param urlStr
* 请求接口地址
* @return
*/
public static String getURLContent(String urlStr) {
/** 网络的url地址 */
URL url = null;
/** 输入流 */
BufferedReader in = null;
StringBuffer sb = new StringBuffer();
try {
url = new URL(urlStr);
in = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"));
String str = null;
while ((str = in.readLine()) != null) {
sb.append(str);
}
} catch (Exception ex) {
System.out.println(ex.getMessage());
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException ex) {
System.out.println(ex.getMessage());
}
}
String result = sb.toString();
return result;
}
}
......@@ -42,8 +42,10 @@ public class ReportEntity extends DataEntity<ReportEntity> {
private String supplementAttachment; //补充提交文件
private String dealAttachment; //处理成果文件
private String oaname;//当前用户名
private String transferName; //移交给
private String reportIp; //记录ip地址
private String ipCity; //ip地址对应城市
private String transferName; //移交给
public String getOaname() {
return oaname;
......@@ -317,4 +319,22 @@ public class ReportEntity extends DataEntity<ReportEntity> {
public void setTransferName(String transferName) {
this.transferName = transferName;
}
@ExcelField(title="IP", align=2, sort=44)
public String getReportIp() {
return reportIp;
}
public void setReportIp(String reportIp) {
this.reportIp = reportIp;
}
@ExcelField(title="对应城市", align=2, sort=46)
public String getIpCity() {
return ipCity;
}
public void setIpCity(String ipCity) {
this.ipCity = ipCity;
}
}
package com.ejweb.modules.report.service;
import com.ejweb.conf.GConstants;
import com.alibaba.fastjson.JSON;
import com.ejweb.core.persistence.Page;
import com.ejweb.core.service.CrudService;
import com.ejweb.core.utils.IdGen;
import com.ejweb.core.utils.SpringContextHolder;
import com.ejweb.core.utils.StringUtils;
import com.ejweb.core.utils.excel.annotation.ExcelField;
import com.ejweb.modules.front.report.entity.IP2Regions;
import com.ejweb.modules.front.report.utils.IpUtils;
import com.ejweb.modules.report.dao.ReportDao;
import com.ejweb.modules.report.entity.ReportAttachmentEntity;
import com.ejweb.modules.report.entity.ReportEntity;
......@@ -18,24 +18,16 @@ import com.ejweb.modules.sys.entity.Role;
import com.ejweb.modules.sys.entity.User;
import com.ejweb.modules.sys.utils.UserUtils;
import com.ejweb.modules.workbench.entity.ReportNotice;
import org.apache.ibatis.javassist.bytecode.AnnotationsAttribute;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 举报Service
......@@ -90,6 +82,16 @@ public class ReportService extends CrudService<ReportDao, ReportEntity> {
if (!this.checkRole(user)) {
reportEntity.setExchangeAfterUser(reportEntity.getCreateBy().getId());
}
String ip = user.getLoginIp();
// ip = "183.129.142.154";
String url = "http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js&ip=" + ip;
String ipResult = IpUtils.getURLContent(url).replace(";", "");
if (ipResult != "-2") {
IP2Regions json = JSON.parseObject(ipResult.split("=")[1], IP2Regions.class);
String city = json.getCity();
reportEntity.setIpCity(city);
}
reportEntity.setReportIp(ip);
dao.addReport(reportEntity);
if (StringUtils.isNotBlank(reportEntity.getReportAttachment())) {
......@@ -269,7 +271,8 @@ public class ReportService extends CrudService<ReportDao, ReportEntity> {
if (flag.equals("answer")){
//当前只有杨杨是系统管理员,处理后消息发给杨杨,以后如果新增了系统管理员需修改
//findAdmin()方法获取所有系统管理员
reportNotice.setSendToId("8434980248282724540228");
// reportNotice.setSendToId("8434980248282724540228");
reportNotice.setSendToId("1");
reportNotice.setTitle("“"+reportEntity.getSupplementTitle()+"”已由"+user.getName()+"于"+dateStr+"处理完成");
}if (flag.equals("meanWhile")){
reportNotice.setTitle("“"+reportEntity.getSupplementTitle()+"”已由"+user.getName()+"于"+dateStr+"处理完成");
......@@ -440,6 +443,8 @@ public class ReportService extends CrudService<ReportDao, ReportEntity> {
}else{
report.setTransferName("");
}
report.setReportIp(report.getReportIp() == null?"--":report.getReportIp());
report.setIpCity(report.getIpCity() == null?"--":report.getIpCity());
}
return reportList;
}
......
......@@ -112,6 +112,14 @@ public class ReportToWordController {
XWPFTableRow reportTime = basicInfoTable.createRow();
reportTime.getCell(0).setText("举报时间:");
reportTime.getCell(1).setText(reportEntity.getReportTime()==null?"":reportEntity.getReportTime());
XWPFTableRow reportIp = basicInfoTable.createRow();
reportIp.getCell(0).setText("IP:");
reportIp.getCell(1).setText(reportEntity.getReportIp()==null?"":reportEntity.getReportIp());
XWPFTableRow ipCity = basicInfoTable.createRow();
ipCity.getCell(0).setText("对应城市:");
ipCity.getCell(1).setText(reportEntity.getIpCity()==null?"":reportEntity.getIpCity());
//表格第五行
XWPFTableRow reportContent = basicInfoTable.createRow();
reportContent.getCell(0).setText("内容:");
......
......@@ -49,7 +49,9 @@
create_date,
update_by,
update_date,
oa_name
oa_name,
report_ip,
ip_city
) VALUES(
#{id},
#{reportProject},
......@@ -69,7 +71,9 @@
#{createDate},
#{updateBy},
#{updateDate},
#{oaName}
#{oaName},
#{reportIp},
#{ipCity}
)
</insert>
......
......@@ -30,7 +30,9 @@
r.create_date AS "createDate",
r.update_by AS "updateBy",
r.update_date AS "updateDate",
r.oa_name AS "oaname"
r.oa_name AS "oaname",
r.report_ip AS "reportIp",
r.ip_city AS "ipCity"
</sql>
......@@ -171,7 +173,9 @@
create_date,
update_by,
update_date,
oa_name
oa_name,
report_ip,
ip_city
) VALUES (
#{id},
#{reportProject},
......@@ -192,7 +196,9 @@
#{createDate},
#{updateBy.id},
#{updateDate},
#{oaname}
#{oaname},
#{reportIp},
#{ipCity}
)
</insert>
......
......@@ -116,6 +116,18 @@
</div>
</div>
<div class="control-group">
<label class="control-label">IP:</label>
<div class="controls">
<form:input path="reportIp" htmlEscape="false" maxlength="200" class="input-xlarge required"/>
</div>
</div>
<div class="control-group">
<label class="control-label">对应城市:</label>
<div class="controls">
<form:input path="ipCity" htmlEscape="false" maxlength="200" class="input-xlarge required"/>
</div>
</div>
<div class="control-group">
<label class="control-label">内容:</label>
<div class="controls">
<form:textarea id="reportContent" htmlEscape="true" style="width:90%" path="reportContent" rows="6" maxlength="500" class="input-xxlarge" disabled="true"/>
......
......@@ -27,6 +27,14 @@
var flag = $("#flag").val();
window.location.href = "${ctx}/report/list?flag="+flag;
});
var i = 1;
var pageNo = $("#pageNo").val();
var pageSize = $("#pageSize").val();
$(".reportList").each(function(){
var num = (pageNo-1)*pageSize + i;
i += 1;
$(this).children("td:first-child").html(num);
});
});
function page(n,s){
$("#pageNo").val(n);
......@@ -135,14 +143,16 @@
<c:if test="${isAdmin eq true}">
<th>移交给</th>
</c:if>
<th>IP</th>
<th>对应城市</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<c:if test="${page.list.size()>0}">
<c:forEach items="${page.list}" var="report" varStatus="vs">
<tr>
<td>${vs.count}</td>
<tr class="reportList">
<td></td>
<td>${report.supplementTitle}</td>
<td>${report.supplementType}</td>
<td>${report.reportProject}</td>
......@@ -197,6 +207,8 @@
<c:if test="${report.transferName ne null && report.exchangeType ne null}">${report.transferName}</c:if>
</td>
</c:if>
<td>${report.reportIp}</td>
<td>${report.ipCity}</td>
<td>
<a href="${ctx}/report/view?id=${report.id}">查看</a>
<c:if test="${report.reportStatus ne '2'}"><a href="${ctx}/report/track?id=${report.id}">跟踪</a></c:if>
......
......@@ -254,6 +254,8 @@
path1 += "被举报人:${report.supplementInformant}%0D%0A";
path1 += "举报时间:${report.reportTime}%0D%0A";
path1 += "所在城市:${report.reportCity}%0D%0A";
path1 += "IP:${report.reportIp}%0D%0A";
path1 += "对应城市:${report.ipCity}%0D%0A";
var reportContent = $("#reportContent").val();
path1 += "内容:";
var path2 = "%0D%0A附件:%0D%0A";
......@@ -441,6 +443,18 @@
</div>
</div>
<div class="control-group">
<label class="control-label">IP:</label>
<div class="controls">
<form:input path="reportIp" htmlEscape="false" maxlength="200" disabled="true" class="input-xlarge required"/>
</div>
</div>
<div class="control-group">
<label class="control-label">对应城市:</label>
<div class="controls">
<form:input path="ipCity" htmlEscape="false" maxlength="200" disabled="true" class="input-xlarge required"/>
</div>
</div>
<div class="control-group">
<label class="control-label">内容:</label>
<div class="controls">
<form:textarea id="reportContent" htmlEscape="true" style="width:90%" path="reportContent" rows="6" maxlength="500" class="input-xxlarge" disabled="true"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment